diff options
author | Heiko St?bner <heiko@sntech.de> | 2011-10-14 06:08:56 (GMT) |
---|---|---|
committer | Kukjin Kim <kgene.kim@samsung.com> | 2011-10-14 06:15:49 (GMT) |
commit | aab08eebdf87d3e6eda5c81f119423af63f5aee1 (patch) | |
tree | dc8b3182c00b3e4b4989d6c9a559153068804094 /arch/arm/mach-s3c2443 | |
parent | d9a3bfbd7e80ecf24d2322659d5c0542f9d95e78 (diff) | |
download | linux-fsl-qoriq-aab08eebdf87d3e6eda5c81f119423af63f5aee1.tar.xz |
ARM: S3C2443: Move clk_arm and clk_armdiv to common code
The system-layout of the armdiv and armclk is common to
S3C2443/S3C2416/S3C2450 and only differs in the array of
possible dividers. Therefore it is possible to reuse the
clock definitions for all of these SoCs.
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
Diffstat (limited to 'arch/arm/mach-s3c2443')
-rw-r--r-- | arch/arm/mach-s3c2443/clock.c | 85 |
1 files changed, 2 insertions, 83 deletions
diff --git a/arch/arm/mach-s3c2443/clock.c b/arch/arm/mach-s3c2443/clock.c index 88edc55..6fda4bf 100644 --- a/arch/arm/mach-s3c2443/clock.c +++ b/arch/arm/mach-s3c2443/clock.c @@ -61,10 +61,10 @@ * * this clock is sourced from msysclk and can have a number of * divider values applied to it to then be fed into armclk. + * The real clock definition is done in s3c2443-clock.c, + * only the armdiv divisor table must be defined here. */ -/* armdiv divisor table */ - static unsigned int armdiv[16] = { [S3C2443_CLKDIV0_ARMDIV_1 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 1, [S3C2443_CLKDIV0_ARMDIV_2 >> S3C2443_CLKDIV0_ARMDIV_SHIFT] = 2, @@ -83,85 +83,6 @@ static inline unsigned int s3c2443_fclk_div(unsigned long clkcon0) return armdiv[clkcon0 >> S3C2443_CLKDIV0_ARMDIV_SHIFT]; } -static unsigned long s3c2443_armclk_roundrate(struct clk *clk, - unsigned long rate) -{ - unsigned long parent = clk_get_rate(clk->parent); - unsigned long calc; - unsigned best = 256; /* bigger than any value */ - unsigned div; - int ptr; - - for (ptr = 0; ptr < ARRAY_SIZE(armdiv); ptr++) { - div = armdiv[ptr]; - calc = parent / div; - if (calc <= rate && div < best) - best = div; - } - - return parent / best; -} - -static int s3c2443_armclk_setrate(struct clk *clk, unsigned long rate) -{ - unsigned long parent = clk_get_rate(clk->parent); - unsigned long calc; - unsigned div; - unsigned best = 256; /* bigger than any value */ - int ptr; - int val = -1; - - for (ptr = 0; ptr < ARRAY_SIZE(armdiv); ptr++) { - div = armdiv[ptr]; - calc = parent / div; - if (calc <= rate && div < best) { - best = div; - val = ptr; - } - } - - if (val >= 0) { - unsigned long clkcon0; - - clkcon0 = __raw_readl(S3C2443_CLKDIV0); - clkcon0 &= ~S3C2443_CLKDIV0_ARMDIV_MASK; - clkcon0 |= val << S3C2443_CLKDIV0_ARMDIV_SHIFT; - __raw_writel(clkcon0, S3C2443_CLKDIV0); - } - - return (val == -1) ? -EINVAL : 0; -} - -static struct clk clk_armdiv = { - .name = "armdiv", - .parent = &clk_msysclk.clk, - .ops = &(struct clk_ops) { - .round_rate = s3c2443_armclk_roundrate, - .set_rate = s3c2443_armclk_setrate, - }, -}; - -/* armclk - * - * this is the clock fed into the ARM core itself, from armdiv or from hclk. - */ - -static struct clk *clk_arm_sources[] = { - [0] = &clk_armdiv, - [1] = &clk_h, -}; - -static struct clksrc_clk clk_arm = { - .clk = { - .name = "armclk", - }, - .sources = &(struct clksrc_sources) { - .sources = clk_arm_sources, - .nr_sources = ARRAY_SIZE(clk_arm_sources), - }, - .reg_src = { .reg = S3C2443_CLKDIV0, .size = 1, .shift = 13 }, -}; - /* hsspi * * high-speed spi clock, sourced from esysclk @@ -260,14 +181,12 @@ static struct clk init_clocks[] = { /* clocks to add straight away */ static struct clksrc_clk *clksrcs[] __initdata = { - &clk_arm, &clk_hsspi, &clk_hsmmc_div, }; static struct clk *clks[] __initdata = { &clk_hsmmc, - &clk_armdiv, }; void __init_or_cpufreq s3c2443_setup_clocks(void) |