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

cpufreq: s3c24xx: move low-level clk reg access into platform code

Rather than have the cpufreq drivers touch include the
common headers to get the constants, add a small indirection.
This is still not the proper way that would do this through
the common clk API, but it lets us kill off the header file
usage.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Link: https://lore.kernel.org/r/20200806182059.2431-37-krzk@kernel.org
[krzk: Rebase and fix -Wold-style-definition]
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

authored by

Arnd Bergmann and committed by
Krzysztof Kozlowski
c38758e3 44c01f5c

+51 -45
-7
arch/arm/mach-s3c24xx/Kconfig
··· 132 132 Internal node to select io timing code that is common to the s3c2410 133 133 and s3c2440/s3c2442 cpu frequency support. 134 134 135 - config S3C2410_CPUFREQ_UTILS 136 - bool 137 - depends on ARM_S3C24XX_CPUFREQ 138 - help 139 - Internal node to select timing code that is common to the s3c2410 140 - and s3c2440/s3c244 cpu frequency support. 141 - 142 135 # cpu frequency support common to s3c2412, s3c2413 and s3c2442 143 136 144 137 config S3C2412_IOTIMING
+1 -1
arch/arm/mach-s3c24xx/Makefile
··· 38 38 39 39 # common code 40 40 41 - obj-$(CONFIG_S3C2410_CPUFREQ_UTILS) += cpufreq-utils.o 41 + obj-$(CONFIG_ARM_S3C24XX_CPUFREQ) += cpufreq-utils.o 42 42 43 43 obj-$(CONFIG_S3C2410_IOTIMING) += iotiming-s3c2410.o 44 44 obj-$(CONFIG_S3C2412_IOTIMING) += iotiming-s3c2412.o
+32
arch/arm/mach-s3c24xx/cpufreq-utils.c
··· 60 60 if (!IS_ERR(cfg->mpll)) 61 61 clk_set_rate(cfg->mpll, cfg->pll.frequency); 62 62 } 63 + 64 + #if defined(CONFIG_CPU_S3C2440) || defined(CONFIG_CPU_S3C2442) 65 + u32 s3c2440_read_camdivn(void) 66 + { 67 + return __raw_readl(S3C2440_CAMDIVN); 68 + } 69 + 70 + void s3c2440_write_camdivn(u32 camdiv) 71 + { 72 + __raw_writel(camdiv, S3C2440_CAMDIVN); 73 + } 74 + #endif 75 + 76 + u32 s3c24xx_read_clkdivn(void) 77 + { 78 + return __raw_readl(S3C2410_CLKDIVN); 79 + } 80 + 81 + void s3c24xx_write_clkdivn(u32 clkdiv) 82 + { 83 + __raw_writel(clkdiv, S3C2410_CLKDIVN); 84 + } 85 + 86 + u32 s3c24xx_read_mpllcon(void) 87 + { 88 + return __raw_readl(S3C2410_MPLLCON); 89 + } 90 + 91 + void s3c24xx_write_locktime(u32 locktime) 92 + { 93 + return __raw_writel(locktime, S3C2410_LOCKTIME); 94 + }
-2
drivers/cpufreq/Kconfig.arm
··· 196 196 config ARM_S3C2410_CPUFREQ 197 197 bool 198 198 depends on ARM_S3C24XX_CPUFREQ && CPU_S3C2410 199 - select S3C2410_CPUFREQ_UTILS 200 199 help 201 200 CPU Frequency scaling support for S3C2410 202 201 ··· 232 233 config ARM_S3C2440_CPUFREQ 233 234 bool "S3C2440/S3C2442 CPU Frequency scaling support" 234 235 depends on ARM_S3C24XX_CPUFREQ && (CPU_S3C2440 || CPU_S3C2442) 235 - select S3C2410_CPUFREQ_UTILS 236 236 default y 237 237 help 238 238 CPU Frequency scaling support for S3C2440 and S3C2442 SoC CPUs.
+1 -7
drivers/cpufreq/s3c2410-cpufreq.c
··· 22 22 #include <asm/mach/arch.h> 23 23 #include <asm/mach/map.h> 24 24 25 - #include <mach/map.h> 26 - 27 - #define S3C2410_CLKREG(x) ((x) + S3C24XX_VA_CLKPWR) 28 - 29 - #define S3C2410_CLKDIVN S3C2410_CLKREG(0x14) 30 - 31 25 #define S3C2410_CLKDIVN_PDIVN (1<<0) 32 26 #define S3C2410_CLKDIVN_HDIVN (1<<1) 33 27 ··· 37 43 if (cfg->divs.p_divisor != cfg->divs.h_divisor) 38 44 clkdiv |= S3C2410_CLKDIVN_PDIVN; 39 45 40 - __raw_writel(clkdiv, S3C2410_CLKDIVN); 46 + s3c24xx_write_clkdivn(clkdiv); 41 47 } 42 48 43 49 static int s3c2410_cpufreq_calcdivs(struct s3c_cpufreq_config *cfg)
+2 -8
drivers/cpufreq/s3c2412-cpufreq.c
··· 25 25 #include <asm/mach/arch.h> 26 26 #include <asm/mach/map.h> 27 27 28 - #include <mach/map.h> 29 - 30 - #define S3C2410_CLKREG(x) ((x) + S3C24XX_VA_CLKPWR) 31 - 32 - #define S3C2410_CLKDIVN S3C2410_CLKREG(0x14) 33 - 34 28 #define S3C2412_CLKDIVN_PDIVN (1<<2) 35 29 #define S3C2412_CLKDIVN_HDIVN_MASK (3<<0) 36 30 #define S3C2412_CLKDIVN_ARMDIVN (1<<3) ··· 126 132 unsigned long clkdiv; 127 133 unsigned long olddiv; 128 134 129 - olddiv = clkdiv = __raw_readl(S3C2410_CLKDIVN); 135 + olddiv = clkdiv = s3c24xx_read_clkdivn(); 130 136 131 137 /* clear off current clock info */ 132 138 ··· 143 149 clkdiv |= S3C2412_CLKDIVN_PDIVN; 144 150 145 151 s3c_freq_dbg("%s: div %08lx => %08lx\n", __func__, olddiv, clkdiv); 146 - __raw_writel(clkdiv, S3C2410_CLKDIVN); 152 + s3c24xx_write_clkdivn(clkdiv); 147 153 148 154 clk_set_parent(armclk, cfg->divs.dvs ? hclk : fclk); 149 155 }
+5 -11
drivers/cpufreq/s3c2440-cpufreq.c
··· 26 26 #include <asm/mach/arch.h> 27 27 #include <asm/mach/map.h> 28 28 29 - #include <mach/map.h> 30 - 31 - #define S3C2410_CLKREG(x) ((x) + S3C24XX_VA_CLKPWR) 32 - #define S3C2410_CLKDIVN S3C2410_CLKREG(0x14) 33 - #define S3C2440_CAMDIVN S3C2410_CLKREG(0x18) 34 - 35 29 #define S3C2440_CLKDIVN_PDIVN (1<<0) 36 30 #define S3C2440_CLKDIVN_HDIVN_MASK (3<<1) 37 31 #define S3C2440_CLKDIVN_HDIVN_1 (0<<1) ··· 156 162 s3c_freq_dbg("%s: divisors: h=%d, p=%d\n", __func__, 157 163 cfg->divs.h_divisor, cfg->divs.p_divisor); 158 164 159 - clkdiv = __raw_readl(S3C2410_CLKDIVN); 160 - camdiv = __raw_readl(S3C2440_CAMDIVN); 165 + clkdiv = s3c24xx_read_clkdivn(); 166 + camdiv = s3c2440_read_camdivn(); 161 167 162 168 clkdiv &= ~(S3C2440_CLKDIVN_HDIVN_MASK | S3C2440_CLKDIVN_PDIVN); 163 169 camdiv &= ~CAMDIVN_HCLK_HALF; ··· 197 203 * then make a short delay and remove the hclk halving if necessary. 198 204 */ 199 205 200 - __raw_writel(camdiv | CAMDIVN_HCLK_HALF, S3C2440_CAMDIVN); 201 - __raw_writel(clkdiv, S3C2410_CLKDIVN); 206 + s3c2440_write_camdivn(camdiv | CAMDIVN_HCLK_HALF); 207 + s3c24xx_write_clkdivn(clkdiv); 202 208 203 209 ndelay(20); 204 - __raw_writel(camdiv, S3C2440_CAMDIVN); 210 + s3c2440_write_camdivn(camdiv); 205 211 206 212 clk_set_parent(armclk, cfg->divs.dvs ? hclk : fclk); 207 213 }
+3 -9
drivers/cpufreq/s3c24xx-cpufreq.c
··· 27 27 #include <asm/mach/arch.h> 28 28 #include <asm/mach/map.h> 29 29 30 - #include <mach/map.h> 31 - 32 30 /* note, cpufreq support deals in kHz, no Hz */ 33 - #define S3C2410_CLKREG(x) ((x) + S3C24XX_VA_CLKPWR) 34 - #define S3C2410_LOCKTIME S3C2410_CLKREG(0x00) 35 - #define S3C2410_MPLLCON S3C2410_CLKREG(0x04) 36 - 37 31 static struct cpufreq_driver s3c24xx_driver; 38 32 static struct s3c_cpufreq_config cpu_cur; 39 33 static struct s3c_iotimings s3c24xx_iotiming; ··· 64 70 cfg->freq.pclk = pclk = clk_get_rate(clk_pclk); 65 71 cfg->freq.armclk = armclk = clk_get_rate(clk_arm); 66 72 67 - cfg->pll.driver_data = __raw_readl(S3C2410_MPLLCON); 73 + cfg->pll.driver_data = s3c24xx_read_mpllcon(); 68 74 cfg->pll.frequency = fclk; 69 75 70 76 cfg->freq.hclk_tns = 1000000000 / (cfg->freq.hclk / 10); ··· 382 388 static int s3c_cpufreq_suspend(struct cpufreq_policy *policy) 383 389 { 384 390 suspend_pll.frequency = clk_get_rate(_clk_mpll); 385 - suspend_pll.driver_data = __raw_readl(S3C2410_MPLLCON); 391 + suspend_pll.driver_data = s3c24xx_read_mpllcon(); 386 392 suspend_freq = clk_get_rate(clk_arm); 387 393 388 394 return 0; ··· 543 549 val |= calc_locktime(rate, cpu_cur.info->locktime_m); 544 550 545 551 pr_info("%s: new locktime is 0x%08x\n", __func__, val); 546 - __raw_writel(val, S3C2410_LOCKTIME); 552 + s3c24xx_write_locktime(val); 547 553 } 548 554 549 555 static int s3c_cpufreq_build_freq(void)
+7
include/linux/soc/samsung/s3c-cpufreq-core.h
··· 289 289 return index + 1; 290 290 } 291 291 292 + u32 s3c2440_read_camdivn(void); 293 + void s3c2440_write_camdivn(u32 camdiv); 294 + u32 s3c24xx_read_clkdivn(void); 295 + void s3c24xx_write_clkdivn(u32 clkdiv); 296 + u32 s3c24xx_read_mpllcon(void); 297 + void s3c24xx_write_locktime(u32 locktime); 298 + 292 299 #endif