S3C24XX: unclutter clock init, mostly for S3C2443
Subsystems (3)
cover S3C24XX: unclutter clock init, mostly for S3C2443
This series tries to unclutter the clock init of S3C2443 and onward a bit. Most clock-information can be read via generic code and doesn't need special code for reading the raste of the h and p clock.
I'm not 100% sure on the sanity of the fifth patch, which removes the plat-s3c24xx/clock.c, as it duplicates a little bit of code into the s3c2412 machine directory but would remove another nearly meaningless file from plat-s3c24xx.
This series applies cleanly against current linux-next.
Heiko Stuebner (5):
S3C2443/S3C2416: remove XXX_setup_clocks methods S3C2443/S3C2416: add get_rate for clk_h S3C2443/S3C2416: add get_rate for clk_p S3C2443/S3C2416: remove call to s3c24xx_setup_clocks
S3C24XX: remove plat-s3c24xx/clock.c
arch/arm/mach-s3c2412/clock.c | 1 + arch/arm/mach-s3c2412/s3c2412.c | 7 ++- arch/arm/mach-s3c2416/clock.c | 6 -- arch/arm/mach-s3c2443/clock.c | 7 --- arch/arm/plat-s3c24xx/Makefile | 1 - arch/arm/plat-s3c24xx/clock.c | 59 ------------------------ arch/arm/plat-s3c24xx/s3c2410-clock.c | 15 ++++++ arch/arm/plat-s3c24xx/s3c2443-clock.c | 69 +++++++++++++++++++--------- arch/arm/plat-samsung/include/plat/clock.h | 1 - 9 files changed, 69 insertions(+), 97 deletions(-) delete mode 100644 arch/arm/plat-s3c24xx/clock.c
Signature · 1 line
1.7.5.4
PATCH 1/5 S3C2443/S3C2416: remove XXX_setup_clocks methods
s3c2443_common_setup_clocks is always called through s3c2443_common_init_clocks, so there is no need to call it separately. On the S3C2443 it was also called twice.
--- arch/arm/mach-s3c2416/clock.c | 6 ------ arch/arm/mach-s3c2443/clock.c | 7 ------- arch/arm/plat-samsung/include/plat/clock.h | 1 - 3 files changed, 0 insertions(+), 14 deletions(-)
arch/arm/mach-s3c2416/clock.c +0 -6
@@ -132,12 +132,6 @@ static struct clk hsmmc0_clk = { .ctrlbit = S3C2416_HCLKCON_HSMMC0, }; -void __init_or_cpufreq s3c2416_setup_clocks(void) -{ -s3c2443_common_setup_clocks (s3c2416_get_pll); -} - -static struct clksrc_clk *clksrcs[]__initdata = { &hsspi_eplldiv, &hsspi_mux,
arch/arm/mach-s3c2443/clock.c +0 -7
@@ -179,11 +179,6 @@ static struct clk *clks[] __initdata = { &clk_hsmmc, }; -void __init_or_cpufreq s3c2443_setup_clocks(void) -{ -s3c2443_common_setup_clocks (s3c2443_get_mpll); -} -void __init s3c2443_init_clocks (int xtal) {unsigned long epllcon =__raw_readl (S3C2443_EPLLCON );
@@ -196,8 +191,6 @@ void __init s3c2443_init_clocks(int xtal) armdiv,ARRAY_SIZE (armdiv), S3C2443_CLKDIV0_ARMDIV_MASK); -s3c2443_setup_clocks (); -s3c24xx_register_clocks (clks,ARRAY_SIZE (clks));for (ptr =0 ; ptr <ARRAY_SIZE (clksrcs); ptr++)
arch/arm/plat-samsung/include/plat/clock.h +0 -1
@@ -114,7 +114,6 @@ extern void s3c24xx_setup_clocks(unsigned long fclk,extern void s3c2410_setup_clocks (void );extern void s3c2412_setup_clocks (void );extern void s3c244x_setup_clocks (void ); -extern void s3c2443_setup_clocks (void );/* S3C64XX specific functions and clocks */
Signature · 1 line
1.7.5.4
PATCH 2/5 S3C2443/S3C2416: add get_rate for clk_h
In reply to Heiko StübnerCurrently the rate of clk_h is calculated once and set through the s3c24xx_setup_clocks call. As the clk_h is a child of the prediv we can evaluate its divider and calculate the rate in get_rate.
--- arch/arm/plat-s3c24xx/s3c2443-clock.c | 31 ++++++++++++++++++++++--------- 1 files changed, 22 insertions(+), 9 deletions(-)
arch/arm/plat-s3c24xx/s3c2443-clock.c +22 -9
@@ -160,6 +160,25 @@ static struct clk clk_prediv = { }, }; +/* hclk divider +* +* divides the prediv and provides the hclk. +*/ + +static unsigned long s3c2443_hclkdiv_getrate (struct clk *clk) +{ +unsigned long rate =clk_get_rate (clk->parent); +unsigned long clkdiv0 =__raw_readl (S3C2443_CLKDIV0 ); + + clkdiv0 &=S3C2443_CLKDIV0_HCLKDIV_MASK ; + +return rate / (clkdiv0 +1 ); +} + +static struct clk_ops clk_h_ops = { + .get_rate = s3c2443_hclkdiv_getrate, +}; +/* armdiv * * this clock is sourced from msysclk and can have a number of
@@ -516,13 +535,6 @@ static struct clk hsmmc1_clk = { .ctrlbit = S3C2443_HCLKCON_HSMMC, }; -static inline unsigned long s3c2443_get_hdiv (unsigned long clkcon0) -{ - clkcon0 &=S3C2443_CLKDIV0_HCLKDIV_MASK ; - -return clkcon0 +1 ; -} -/* EPLLCON compatible enough to get on/off information */ void __init_or_cpufreq s3c2443_common_setup_clocks(pll_fn get_mpll)
@@ -546,8 +558,7 @@ void __init_or_cpufreq s3c2443_common_setup_clocks(pll_fn get_mpll) clk_msysclk.clk.rate = pll; fclk =clk_get_rate (&clk_armdiv); - hclk =s3c2443_prediv_getrate (&clk_prediv); - hclk /=s3c2443_get_hdiv (clkdiv0); + hclk =clk_get_rate (&clk_h); pclk = hclk / ((clkdiv0 &S3C2443_CLKDIV0_HALF_PCLK ) ?2 :1 );s3c24xx_setup_clocks (fclk, hclk, pclk);
@@ -613,6 +624,8 @@ void __init s3c2443_common_init_clocks(int xtal, pll_fn get_mpll,/* s3c2443 parents h and p clocks from prediv */ clk_h.parent = &clk_prediv; + clk_h.ops = &clk_h_ops; + clk_p.parent = &clk_prediv; clk_usb_bus.parent = &clk_usb_bus_host.clk;
Signature · 1 line
1.7.5.4
PATCH 3/5 S3C2443/S3C2416: add get_rate for clk_p
In reply to Heiko StübnerCurrently the rate of clk_p is calculated once and set through the s3c24xx_setup_clocks call. As the clk_p is a child of clk_h we can evaluate its divider and calculate the rate in get_rate.
--- arch/arm/plat-s3c24xx/s3c2443-clock.c | 28 ++++++++++++++++++++++++---- 1 files changed, 24 insertions(+), 4 deletions(-)
arch/arm/plat-s3c24xx/s3c2443-clock.c +24 -4
@@ -179,6 +179,25 @@ static struct clk_ops clk_h_ops = { .get_rate = s3c2443_hclkdiv_getrate, }; +/* pclk divider +* +* divides the hclk and provides the pclk. +*/ + +static unsigned long s3c2443_pclkdiv_getrate (struct clk *clk) +{ +unsigned long rate =clk_get_rate (clk->parent); +unsigned long clkdiv0 =__raw_readl (S3C2443_CLKDIV0 ); + + clkdiv0 = ((clkdiv0 &S3C2443_CLKDIV0_HALF_PCLK ) ?1 :0 ); + +return rate / (clkdiv0 +1 ); +} + +static struct clk_ops clk_p_ops = { + .get_rate = s3c2443_pclkdiv_getrate, +}; +/* armdiv * * this clock is sourced from msysclk and can have a number of
@@ -541,7 +560,6 @@ void __init_or_cpufreq s3c2443_common_setup_clocks(pll_fn get_mpll) {unsigned long epllcon =__raw_readl (S3C2443_EPLLCON );unsigned long mpllcon =__raw_readl (S3C2443_MPLLCON ); -unsigned long clkdiv0 =__raw_readl (S3C2443_CLKDIV0 );struct clk *xtal_clk;unsigned long xtal;unsigned long pll;
@@ -559,7 +577,7 @@ void __init_or_cpufreq s3c2443_common_setup_clocks(pll_fn get_mpll) fclk =clk_get_rate (&clk_armdiv); hclk =clk_get_rate (&clk_h); - pclk = hclk / ((clkdiv0 &S3C2443_CLKDIV0_HALF_PCLK ) ?2 :1 ); + pclk =clk_get_rate (&clk_p);s3c24xx_setup_clocks (fclk, hclk, pclk);
@@ -622,11 +640,13 @@ void __init s3c2443_common_init_clocks(int xtal, pll_fn get_mpll, nr_armdiv = nr_divs; armdivmask = divmask; -/* s3c2443 parents h and p clocks from prediv */ +/* s3c2443 parents h clock from prediv */ clk_h.parent = &clk_prediv; clk_h.ops = &clk_h_ops; - clk_p.parent = &clk_prediv; +/* and p clock from h clock */ + clk_p.parent = &clk_h; + clk_p.ops = &clk_p_ops; clk_usb_bus.parent = &clk_usb_bus_host.clk; clk_epll.parent = &clk_epllref.clk;
Signature · 1 line
1.7.5.4
PATCH 4/5 S3C2443/S3C2416: remove call to s3c24xx_setup_clocks
In reply to Heiko StübnerAs the clocks can calculate their rate themself now, there is no need to set it statically.
--- arch/arm/plat-s3c24xx/s3c2443-clock.c | 14 +++----------- 1 files changed, 3 insertions(+), 11 deletions(-)
arch/arm/plat-s3c24xx/s3c2443-clock.c +3 -11
@@ -563,9 +563,6 @@ void __init_or_cpufreq s3c2443_common_setup_clocks(pll_fn get_mpll)struct clk *xtal_clk;unsigned long xtal;unsigned long pll; -unsigned long fclk; -unsigned long hclk; -unsigned long pclk;int ptr; xtal_clk =clk_get (NULL ,"xtal" );
@@ -574,17 +571,12 @@ void __init_or_cpufreq s3c2443_common_setup_clocks(pll_fn get_mpll) pll =get_mpll (mpllcon, xtal); clk_msysclk.clk.rate = pll; - - fclk =clk_get_rate (&clk_armdiv); - hclk =clk_get_rate (&clk_h); - pclk =clk_get_rate (&clk_p); - -s3c24xx_setup_clocks (fclk, hclk, pclk); + clk_mpll.rate = pll;printk ("CPU: MPLL %s %ld.%03ld MHz, cpu %ld.%03ld MHz, mem %ld.%03ld MHz, pclk %ld.%03ld MHz\n" , (mpllcon &S3C2443_PLLCON_OFF ) ?"off" :"on" , -print_mhz (pll),print_mhz (fclk), -print_mhz (hclk),print_mhz (pclk)); +print_mhz (pll),print_mhz (clk_get_rate (&clk_armdiv)), +print_mhz (clk_get_rate (&clk_h)),print_mhz (clk_get_rate (&clk_p)));for (ptr =0 ; ptr <ARRAY_SIZE (clksrc_clks); ptr++)s3c_set_clksrc (&clksrc_clks[ptr], true);
Signature · 1 line
1.7.5.4
PATCH 5/5 S3C24XX: remove plat-s3c24xx/clock.c
In reply to Heiko StübnerWith its users reduced, the clock.c does not need to stay around. s3c24xx_setup_clocks can move into s3c2410-clocks.c for 2410 and 244x, and its functionality also into s3c2412.c
--- arch/arm/mach-s3c2412/clock.c | 1 + arch/arm/mach-s3c2412/s3c2412.c | 7 +++- arch/arm/plat-s3c24xx/Makefile | 1 - arch/arm/plat-s3c24xx/clock.c | 59 --------------------------------- arch/arm/plat-s3c24xx/s3c2410-clock.c | 15 ++++++++ 5 files changed, 22 insertions(+), 61 deletions(-) delete mode 100644 arch/arm/plat-s3c24xx/clock.c
arch/arm/mach-s3c2412/clock.c +1 -0
@@ -44,6 +44,7 @@#include <plat/s3c2412.h> #include <plat/clock.h> #include <plat/cpu.h> +#include <plat/pll.h> /* We currently have to assume that the system is running * from the XTPll input, and that all ***REFCLKs are being
arch/arm/mach-s3c2412/s3c2412.c +6 -1
@@ -202,7 +202,12 @@ void __init_or_cpufreq s3c2412_setup_clocks(void)printk ("S3C2412: core %ld.%03ld MHz, memory %ld.%03ld MHz, peripheral %ld.%03ld MHz\n" ,print_mhz (fclk),print_mhz (hclk),print_mhz (pclk)); -s3c24xx_setup_clocks (fclk, hclk, pclk); + clk_upll.rate =s3c24xx_get_pll (__raw_readl (S3C2410_UPLLCON ), + clk_xtal.rate); + + clk_h.rate = hclk; + clk_p.rate = pclk; + clk_f.rate = fclk; }void __init s3c2412_init_clocks (int xtal)
arch/arm/plat-s3c24xx/Makefile +0 -1
@@ -15,7 +15,6 @@ obj- := obj-y += cpu.o obj-y += irq.o obj-y += dev-uart.o -obj-y += clock.o obj-$(CONFIG_S3C24XX_DCLK) += clock-dclk.o obj-$(CONFIG_CPU_FREQ_S3C24XX) += cpu-freq.o
arch/arm/plat-s3c24xx/clock.c deleted +0 -59
59 lines not on this page · raw message
arch/arm/plat-s3c24xx/s3c2410-clock.c +15 -0
@@ -44,6 +44,8 @@#include <plat/s3c2410.h> #include <plat/clock.h> #include <plat/cpu.h> +#include <plat/pll.h> +#include <plat/cpu-freq.h> int s3c2410_clkcon_enable (struct clk *clk,int enable) {
@@ -251,3 +253,16 @@ int __init s3c2410_baseclk_add(void)s3c_pwmclk_init ();return 0 ; } + +void __init_or_cpufreq s3c24xx_setup_clocks(unsigned long fclk, +unsigned long hclk, +unsigned long pclk) +{ + clk_upll.rate =s3c24xx_get_pll (__raw_readl (S3C2410_UPLLCON ), + clk_xtal.rate); + + clk_mpll.rate = fclk; + clk_h.rate = hclk; + clk_p.rate = pclk; + clk_f.rate = fclk; +}
Signature · 1 line
1.7.5.4