Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5454901rwd; Wed, 24 May 2023 01:54:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ZVtTwf2w+rIUsCkszRs39tfTc+qvoYnLbUQD0YX6i8VhpFgMToVR/CDugzY867byLEYeU X-Received: by 2002:a05:6a00:1a56:b0:64d:3227:b800 with SMTP id h22-20020a056a001a5600b0064d3227b800mr2286341pfv.16.1684918473884; Wed, 24 May 2023 01:54:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684918473; cv=none; d=google.com; s=arc-20160816; b=gRk11vkRP/H7+/0ECNkj/SbCNhqRqF4gldu7T758zDdC/KmYqnBKwSyd/zHFX7nYD6 Zd/0LT61DTNJZ49UPM+v04yYrsBjVDFXSD6nKlYetgGt+bdkLFO9brbb/mylIdE5Cbah UJ3ap04eYsIJpqKNZXS6lQ0oU3TjV3fg2Qql1tmH312dAKkem4gDuAs+hscSCAm1H+X4 PZQpABUwkGmTBUe4rJy6lYkg1raZh5AJtGxHnws82kd83viJxOJuRjY4o5YAGC4QPL7o IQ/VPz/q/uTP7461MaiEcMjL4RW2h9tDJ77Wtuu/WAmabH3d3hKz8NcuQ3VWeIReS4MJ 56uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=+bIjQm6ziDdb4wIl/M0UarPTfW0kCRNPKIPmT8NDJbI=; b=WMzLa9AGAdKIJQHu/NG+IWsIrudRa2YzDqCjHKWTCSHwPyJWeBAIPLjtHyBY6dXTfc 6ZmpBuxa7C8oUt1NbnbOaP+gNmfOmQtIAQSmf3hkvAwieqUXxws2f+6SDoqGAa5malSu WibvLAiu91V38rIu8DuM3Y1i/gQipxN85Bd9S6O0BnyW659qucHX2hIc1/7WHjJ4+lLy iAy0SsGMPUJbSUicFn7QW/DEFztBpNdWWUEI66H7F1gnghbt4rEDeQP+hu/T8AScNLBZ fUMSNltvJYd+1M9ZFxjK97HLO4DCP0LWpZKOWbu+VmILOPRc04DPOnjMie0gpwIbVydQ a1KQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s144-20020a632c96000000b0053427ab083asi8100264pgs.650.2023.05.24.01.54.20; Wed, 24 May 2023 01:54:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240268AbjEXIdJ (ORCPT + 99 others); Wed, 24 May 2023 04:33:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240205AbjEXIcf (ORCPT ); Wed, 24 May 2023 04:32:35 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60DEA12B for ; Wed, 24 May 2023 01:32:33 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q1juY-0002l9-Rd; Wed, 24 May 2023 10:31:58 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1q1juX-002RZO-8Q; Wed, 24 May 2023 10:31:57 +0200 Received: from sha by dude02.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1q1juW-009j7E-At; Wed, 24 May 2023 10:31:56 +0200 From: Sascha Hauer To: linux-rockchip@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Heiko Stuebner , Kyungmin Park , MyungJoo Ham , Will Deacon , Mark Rutland , kernel@pengutronix.de, Michael Riesch , Robin Murphy , Vincent Legoll , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, Sascha Hauer Subject: [PATCH v5 07/25] PM / devfreq: rockchip-dfi: introduce channel mask Date: Wed, 24 May 2023 10:31:35 +0200 Message-Id: <20230524083153.2046084-8-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230524083153.2046084-1-s.hauer@pengutronix.de> References: <20230524083153.2046084-1-s.hauer@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Different Rockchip SoC variants have a different number of channels. Introduce a channel mask to make the number of channels configurable from SoC initialization code. Signed-off-by: Sascha Hauer --- drivers/devfreq/event/rockchip-dfi.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/devfreq/event/rockchip-dfi.c b/drivers/devfreq/event/rockchip-dfi.c index 126bb744645b6..82de24a027579 100644 --- a/drivers/devfreq/event/rockchip-dfi.c +++ b/drivers/devfreq/event/rockchip-dfi.c @@ -18,10 +18,11 @@ #include #include #include +#include #include -#define RK3399_DMC_NUM_CH 2 +#define DMC_MAX_CHANNELS 2 /* DDRMON_CTRL */ #define DDRMON_CTRL 0x04 @@ -44,7 +45,7 @@ struct dmc_count_channel { }; struct dmc_count { - struct dmc_count_channel c[RK3399_DMC_NUM_CH]; + struct dmc_count_channel c[DMC_MAX_CHANNELS]; }; /* @@ -61,6 +62,7 @@ struct rockchip_dfi { struct regmap *regmap_pmu; struct clk *clk; u32 ddr_type; + unsigned int channel_mask; }; static void rockchip_dfi_start_hardware_counter(struct devfreq_event_dev *edev) @@ -95,7 +97,9 @@ static void rockchip_dfi_read_counters(struct devfreq_event_dev *edev, struct dm u32 i; void __iomem *dfi_regs = dfi->regs; - for (i = 0; i < RK3399_DMC_NUM_CH; i++) { + for (i = 0; i < DMC_MAX_CHANNELS; i++) { + if (!(dfi->channel_mask & BIT(i))) + continue; count->c[i].access = readl_relaxed(dfi_regs + DDRMON_CH0_DFI_ACCESS_NUM + i * 20); count->c[i].total = readl_relaxed(dfi_regs + @@ -145,9 +149,14 @@ static int rockchip_dfi_get_event(struct devfreq_event_dev *edev, rockchip_dfi_read_counters(edev, &count); /* We can only report one channel, so find the busiest one */ - for (i = 0; i < RK3399_DMC_NUM_CH; i++) { - u32 a = count.c[i].access - last->c[i].access; - u32 t = count.c[i].total - last->c[i].total; + for (i = 0; i < DMC_MAX_CHANNELS; i++) { + u32 a, t; + + if (!(dfi->channel_mask & BIT(i))) + continue; + + a = count.c[i].access - last->c[i].access; + t = count.c[i].total - last->c[i].total; if (a > access) { access = a; @@ -185,6 +194,8 @@ static int rk3399_dfi_init(struct rockchip_dfi *dfi) dfi->ddr_type = (val >> RK3399_PMUGRF_DDRTYPE_SHIFT) & RK3399_PMUGRF_DDRTYPE_MASK; + dfi->channel_mask = GENMASK(1, 0); + return 0; }; -- 2.39.2