diff options
author | Ben Dooks <ben-linux@fluff.org> | 2008-10-21 09:06:34 -0400 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2008-12-15 16:46:02 -0500 |
commit | e24b864ab3e1a5916c87e13cfdc94c1d02f0578b (patch) | |
tree | f2c894494fc6831c72cd980b9d836efa900f5be3 /arch/arm | |
parent | 93bc6b6371b6b7303ffdae0d69dcdc443b8b0d8a (diff) |
[ARM] S3C24XX: Split pll code out of regs-clock.h
Move the PLL calculation code into it's own header
file for re-use with the other plat-s3c24xx based
systems such as the S3C24A0.
Note, we change the name of s3c2410_get_pll to the
more generically named s3c24xx_get_pll as well as
the related defintions.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-s3c2410/include/mach/regs-clock.h | 33 | ||||
-rw-r--r-- | arch/arm/mach-s3c2410/mach-h1940.c | 8 | ||||
-rw-r--r-- | arch/arm/mach-s3c2410/s3c2410.c | 3 | ||||
-rw-r--r-- | arch/arm/mach-s3c2412/s3c2412.c | 3 | ||||
-rw-r--r-- | arch/arm/plat-s3c24xx/clock.c | 3 | ||||
-rw-r--r-- | arch/arm/plat-s3c24xx/include/plat/pll.h | 37 | ||||
-rw-r--r-- | arch/arm/plat-s3c24xx/s3c244x.c | 3 |
7 files changed, 49 insertions, 41 deletions
diff --git a/arch/arm/mach-s3c2410/include/mach/regs-clock.h b/arch/arm/mach-s3c2410/include/mach/regs-clock.h index b3f90aa78076..2a5d90e957fb 100644 --- a/arch/arm/mach-s3c2410/include/mach/regs-clock.h +++ b/arch/arm/mach-s3c2410/include/mach/regs-clock.h | |||
@@ -42,13 +42,6 @@ | |||
42 | #define S3C2410_CLKCON_IIS (1<<17) | 42 | #define S3C2410_CLKCON_IIS (1<<17) |
43 | #define S3C2410_CLKCON_SPI (1<<18) | 43 | #define S3C2410_CLKCON_SPI (1<<18) |
44 | 44 | ||
45 | #define S3C2410_PLLCON_MDIVSHIFT 12 | ||
46 | #define S3C2410_PLLCON_PDIVSHIFT 4 | ||
47 | #define S3C2410_PLLCON_SDIVSHIFT 0 | ||
48 | #define S3C2410_PLLCON_MDIVMASK ((1<<(1+(19-12)))-1) | ||
49 | #define S3C2410_PLLCON_PDIVMASK ((1<<5)-1) | ||
50 | #define S3C2410_PLLCON_SDIVMASK 3 | ||
51 | |||
52 | /* DCLKCON register addresses in gpio.h */ | 45 | /* DCLKCON register addresses in gpio.h */ |
53 | 46 | ||
54 | #define S3C2410_DCLKCON_DCLK0EN (1<<0) | 47 | #define S3C2410_DCLKCON_DCLK0EN (1<<0) |
@@ -76,32 +69,6 @@ | |||
76 | #define S3C2410_CLKSLOW_SLOWVAL(x) (x) | 69 | #define S3C2410_CLKSLOW_SLOWVAL(x) (x) |
77 | #define S3C2410_CLKSLOW_GET_SLOWVAL(x) ((x) & 7) | 70 | #define S3C2410_CLKSLOW_GET_SLOWVAL(x) ((x) & 7) |
78 | 71 | ||
79 | #ifndef __ASSEMBLY__ | ||
80 | |||
81 | #include <asm/div64.h> | ||
82 | |||
83 | static inline unsigned int | ||
84 | s3c2410_get_pll(unsigned int pllval, unsigned int baseclk) | ||
85 | { | ||
86 | unsigned int mdiv, pdiv, sdiv; | ||
87 | uint64_t fvco; | ||
88 | |||
89 | mdiv = pllval >> S3C2410_PLLCON_MDIVSHIFT; | ||
90 | pdiv = pllval >> S3C2410_PLLCON_PDIVSHIFT; | ||
91 | sdiv = pllval >> S3C2410_PLLCON_SDIVSHIFT; | ||
92 | |||
93 | mdiv &= S3C2410_PLLCON_MDIVMASK; | ||
94 | pdiv &= S3C2410_PLLCON_PDIVMASK; | ||
95 | sdiv &= S3C2410_PLLCON_SDIVMASK; | ||
96 | |||
97 | fvco = (uint64_t)baseclk * (mdiv + 8); | ||
98 | do_div(fvco, (pdiv + 2) << sdiv); | ||
99 | |||
100 | return (unsigned int)fvco; | ||
101 | } | ||
102 | |||
103 | #endif /* __ASSEMBLY__ */ | ||
104 | |||
105 | #if defined(CONFIG_CPU_S3C2440) || defined(CONFIG_CPU_S3C2442) | 72 | #if defined(CONFIG_CPU_S3C2440) || defined(CONFIG_CPU_S3C2442) |
106 | 73 | ||
107 | /* extra registers */ | 74 | /* extra registers */ |
diff --git a/arch/arm/mach-s3c2410/mach-h1940.c b/arch/arm/mach-s3c2410/mach-h1940.c index 32d550fcff4d..836508b829bb 100644 --- a/arch/arm/mach-s3c2410/mach-h1940.c +++ b/arch/arm/mach-s3c2410/mach-h1940.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #include <plat/clock.h> | 43 | #include <plat/clock.h> |
44 | #include <plat/devs.h> | 44 | #include <plat/devs.h> |
45 | #include <plat/cpu.h> | 45 | #include <plat/cpu.h> |
46 | #include <plat/pll.h> | ||
46 | #include <plat/pm.h> | 47 | #include <plat/pm.h> |
47 | 48 | ||
48 | static struct map_desc h1940_iodesc[] __initdata = { | 49 | static struct map_desc h1940_iodesc[] __initdata = { |
@@ -223,10 +224,9 @@ static void __init h1940_init(void) | |||
223 | S3C2410_MISCCR_USBSUSPND0 | | 224 | S3C2410_MISCCR_USBSUSPND0 | |
224 | S3C2410_MISCCR_USBSUSPND1, 0x0); | 225 | S3C2410_MISCCR_USBSUSPND1, 0x0); |
225 | 226 | ||
226 | tmp = ( | 227 | tmp = (0x78 << S3C24XX_PLLCON_MDIVSHIFT) |
227 | 0x78 << S3C2410_PLLCON_MDIVSHIFT) | 228 | | (0x02 << S3C24XX_PLLCON_PDIVSHIFT) |
228 | | (0x02 << S3C2410_PLLCON_PDIVSHIFT) | 229 | | (0x03 << S3C24XX_PLLCON_SDIVSHIFT); |
229 | | (0x03 << S3C2410_PLLCON_SDIVSHIFT); | ||
230 | writel(tmp, S3C2410_UPLLCON); | 230 | writel(tmp, S3C2410_UPLLCON); |
231 | 231 | ||
232 | platform_add_devices(h1940_devices, ARRAY_SIZE(h1940_devices)); | 232 | platform_add_devices(h1940_devices, ARRAY_SIZE(h1940_devices)); |
diff --git a/arch/arm/mach-s3c2410/s3c2410.c b/arch/arm/mach-s3c2410/s3c2410.c index 1db39c609d78..4e23bc05f4b5 100644 --- a/arch/arm/mach-s3c2410/s3c2410.c +++ b/arch/arm/mach-s3c2410/s3c2410.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <plat/cpu.h> | 35 | #include <plat/cpu.h> |
36 | #include <plat/devs.h> | 36 | #include <plat/devs.h> |
37 | #include <plat/clock.h> | 37 | #include <plat/clock.h> |
38 | #include <plat/pll.h> | ||
38 | 39 | ||
39 | /* Initial IO mappings */ | 40 | /* Initial IO mappings */ |
40 | 41 | ||
@@ -74,7 +75,7 @@ void __init s3c2410_init_clocks(int xtal) | |||
74 | /* now we've got our machine bits initialised, work out what | 75 | /* now we've got our machine bits initialised, work out what |
75 | * clocks we've got */ | 76 | * clocks we've got */ |
76 | 77 | ||
77 | fclk = s3c2410_get_pll(__raw_readl(S3C2410_MPLLCON), xtal); | 78 | fclk = s3c24xx_get_pll(__raw_readl(S3C2410_MPLLCON), xtal); |
78 | 79 | ||
79 | tmp = __raw_readl(S3C2410_CLKDIVN); | 80 | tmp = __raw_readl(S3C2410_CLKDIVN); |
80 | 81 | ||
diff --git a/arch/arm/mach-s3c2412/s3c2412.c b/arch/arm/mach-s3c2412/s3c2412.c index 22d22a035782..4bd2b5fb8669 100644 --- a/arch/arm/mach-s3c2412/s3c2412.c +++ b/arch/arm/mach-s3c2412/s3c2412.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <plat/devs.h> | 47 | #include <plat/devs.h> |
48 | #include <plat/clock.h> | 48 | #include <plat/clock.h> |
49 | #include <plat/pm.h> | 49 | #include <plat/pm.h> |
50 | #include <plat/pll.h> | ||
50 | 51 | ||
51 | #ifndef CONFIG_CPU_S3C2412_ONLY | 52 | #ifndef CONFIG_CPU_S3C2412_ONLY |
52 | void __iomem *s3c24xx_va_gpio2 = S3C24XX_VA_GPIO; | 53 | void __iomem *s3c24xx_va_gpio2 = S3C24XX_VA_GPIO; |
@@ -165,7 +166,7 @@ void __init s3c2412_init_clocks(int xtal) | |||
165 | /* now we've got our machine bits initialised, work out what | 166 | /* now we've got our machine bits initialised, work out what |
166 | * clocks we've got */ | 167 | * clocks we've got */ |
167 | 168 | ||
168 | fclk = s3c2410_get_pll(__raw_readl(S3C2410_MPLLCON), xtal*2); | 169 | fclk = s3c24xx_get_pll(__raw_readl(S3C2410_MPLLCON), xtal*2); |
169 | 170 | ||
170 | clk_mpll.rate = fclk; | 171 | clk_mpll.rate = fclk; |
171 | 172 | ||
diff --git a/arch/arm/plat-s3c24xx/clock.c b/arch/arm/plat-s3c24xx/clock.c index bf2633bd3996..1ff1b9836042 100644 --- a/arch/arm/plat-s3c24xx/clock.c +++ b/arch/arm/plat-s3c24xx/clock.c | |||
@@ -49,6 +49,7 @@ | |||
49 | 49 | ||
50 | #include <plat/clock.h> | 50 | #include <plat/clock.h> |
51 | #include <plat/cpu.h> | 51 | #include <plat/cpu.h> |
52 | #include <plat/pll.h> | ||
52 | 53 | ||
53 | /* clock information */ | 54 | /* clock information */ |
54 | 55 | ||
@@ -332,7 +333,7 @@ int __init s3c24xx_setup_clocks(unsigned long xtal, | |||
332 | /* initialise the main system clocks */ | 333 | /* initialise the main system clocks */ |
333 | 334 | ||
334 | clk_xtal.rate = xtal; | 335 | clk_xtal.rate = xtal; |
335 | clk_upll.rate = s3c2410_get_pll(__raw_readl(S3C2410_UPLLCON), xtal); | 336 | clk_upll.rate = s3c24xx_get_pll(__raw_readl(S3C2410_UPLLCON), xtal); |
336 | 337 | ||
337 | clk_mpll.rate = fclk; | 338 | clk_mpll.rate = fclk; |
338 | clk_h.rate = hclk; | 339 | clk_h.rate = hclk; |
diff --git a/arch/arm/plat-s3c24xx/include/plat/pll.h b/arch/arm/plat-s3c24xx/include/plat/pll.h new file mode 100644 index 000000000000..7ea8bffa7a9c --- /dev/null +++ b/arch/arm/plat-s3c24xx/include/plat/pll.h | |||
@@ -0,0 +1,37 @@ | |||
1 | /* linux/arch/arm/plat-s3c24xx/include/plat/pll.h | ||
2 | * | ||
3 | * Copyright 2008 Simtec Electronics | ||
4 | * Ben Dooks <ben@simtec.co.uk> | ||
5 | * http://armlinux.simtec.co.uk/ | ||
6 | * | ||
7 | * S3C24xx - common pll registers and code | ||
8 | */ | ||
9 | |||
10 | #define S3C24XX_PLLCON_MDIVSHIFT 12 | ||
11 | #define S3C24XX_PLLCON_PDIVSHIFT 4 | ||
12 | #define S3C24XX_PLLCON_SDIVSHIFT 0 | ||
13 | #define S3C24XX_PLLCON_MDIVMASK ((1<<(1+(19-12)))-1) | ||
14 | #define S3C24XX_PLLCON_PDIVMASK ((1<<5)-1) | ||
15 | #define S3C24XX_PLLCON_SDIVMASK 3 | ||
16 | |||
17 | #include <asm/div64.h> | ||
18 | |||
19 | static inline unsigned int | ||
20 | s3c24xx_get_pll(unsigned int pllval, unsigned int baseclk) | ||
21 | { | ||
22 | unsigned int mdiv, pdiv, sdiv; | ||
23 | uint64_t fvco; | ||
24 | |||
25 | mdiv = pllval >> S3C24XX_PLLCON_MDIVSHIFT; | ||
26 | pdiv = pllval >> S3C24XX_PLLCON_PDIVSHIFT; | ||
27 | sdiv = pllval >> S3C24XX_PLLCON_SDIVSHIFT; | ||
28 | |||
29 | mdiv &= S3C24XX_PLLCON_MDIVMASK; | ||
30 | pdiv &= S3C24XX_PLLCON_PDIVMASK; | ||
31 | sdiv &= S3C24XX_PLLCON_SDIVMASK; | ||
32 | |||
33 | fvco = (uint64_t)baseclk * (mdiv + 8); | ||
34 | do_div(fvco, (pdiv + 2) << sdiv); | ||
35 | |||
36 | return (unsigned int)fvco; | ||
37 | } | ||
diff --git a/arch/arm/plat-s3c24xx/s3c244x.c b/arch/arm/plat-s3c24xx/s3c244x.c index d1152d1f9ba0..7f33cef20bac 100644 --- a/arch/arm/plat-s3c24xx/s3c244x.c +++ b/arch/arm/plat-s3c24xx/s3c244x.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include <plat/devs.h> | 42 | #include <plat/devs.h> |
43 | #include <plat/cpu.h> | 43 | #include <plat/cpu.h> |
44 | #include <plat/pm.h> | 44 | #include <plat/pm.h> |
45 | #include <plat/pll.h> | ||
45 | 46 | ||
46 | static struct map_desc s3c244x_iodesc[] __initdata = { | 47 | static struct map_desc s3c244x_iodesc[] __initdata = { |
47 | IODESC_ENT(CLKPWR), | 48 | IODESC_ENT(CLKPWR), |
@@ -80,7 +81,7 @@ void __init s3c244x_init_clocks(int xtal) | |||
80 | /* now we've got our machine bits initialised, work out what | 81 | /* now we've got our machine bits initialised, work out what |
81 | * clocks we've got */ | 82 | * clocks we've got */ |
82 | 83 | ||
83 | fclk = s3c2410_get_pll(__raw_readl(S3C2410_MPLLCON), xtal) * 2; | 84 | fclk = s3c24xx_get_pll(__raw_readl(S3C2410_MPLLCON), xtal) * 2; |
84 | 85 | ||
85 | clkdiv = __raw_readl(S3C2410_CLKDIVN); | 86 | clkdiv = __raw_readl(S3C2410_CLKDIVN); |
86 | camdiv = __raw_readl(S3C2440_CAMDIVN); | 87 | camdiv = __raw_readl(S3C2440_CAMDIVN); |