Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PM / devfreq: rockchip-dfi: introduce channel mask

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.

Link: https://lore.kernel.org/all/20231018061714.3553817-8-s.hauer@pengutronix.de/
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>

authored by

Sascha Hauer and committed by
Chanwoo Choi
63dcf38e 99911664

+19 -6
+19 -6
drivers/devfreq/event/rockchip-dfi.c
··· 18 18 #include <linux/list.h> 19 19 #include <linux/of.h> 20 20 #include <linux/of_device.h> 21 + #include <linux/bits.h> 21 22 22 23 #include <soc/rockchip/rk3399_grf.h> 23 24 24 - #define RK3399_DMC_NUM_CH 2 25 + #define DMC_MAX_CHANNELS 2 25 26 26 27 /* DDRMON_CTRL */ 27 28 #define DDRMON_CTRL 0x04 ··· 45 44 }; 46 45 47 46 struct dmc_count { 48 - struct dmc_count_channel c[RK3399_DMC_NUM_CH]; 47 + struct dmc_count_channel c[DMC_MAX_CHANNELS]; 49 48 }; 50 49 51 50 /* ··· 62 61 struct regmap *regmap_pmu; 63 62 struct clk *clk; 64 63 u32 ddr_type; 64 + unsigned int channel_mask; 65 + unsigned int max_channels; 65 66 }; 66 67 67 68 static void rockchip_dfi_start_hardware_counter(struct devfreq_event_dev *edev) ··· 98 95 u32 i; 99 96 void __iomem *dfi_regs = dfi->regs; 100 97 101 - for (i = 0; i < RK3399_DMC_NUM_CH; i++) { 98 + for (i = 0; i < dfi->max_channels; i++) { 99 + if (!(dfi->channel_mask & BIT(i))) 100 + continue; 102 101 count->c[i].access = readl_relaxed(dfi_regs + 103 102 DDRMON_CH0_DFI_ACCESS_NUM + i * 20); 104 103 count->c[i].total = readl_relaxed(dfi_regs + ··· 150 145 rockchip_dfi_read_counters(edev, &count); 151 146 152 147 /* We can only report one channel, so find the busiest one */ 153 - for (i = 0; i < RK3399_DMC_NUM_CH; i++) { 154 - u32 a = count.c[i].access - last->c[i].access; 155 - u32 t = count.c[i].total - last->c[i].total; 148 + for (i = 0; i < dfi->max_channels; i++) { 149 + u32 a, t; 150 + 151 + if (!(dfi->channel_mask & BIT(i))) 152 + continue; 153 + 154 + a = count.c[i].access - last->c[i].access; 155 + t = count.c[i].total - last->c[i].total; 156 156 157 157 if (a > access) { 158 158 access = a; ··· 194 184 regmap_read(regmap_pmu, RK3399_PMUGRF_OS_REG2, &val); 195 185 dfi->ddr_type = (val >> RK3399_PMUGRF_DDRTYPE_SHIFT) & 196 186 RK3399_PMUGRF_DDRTYPE_MASK; 187 + 188 + dfi->channel_mask = GENMASK(1, 0); 189 + dfi->max_channels = 2; 197 190 198 191 return 0; 199 192 };