diff options
author | Seungwhan Youn <sw.youn@samsung.com> | 2010-10-13 21:39:08 -0400 |
---|---|---|
committer | Kukjin Kim <kgene.kim@samsung.com> | 2010-10-25 03:05:56 -0400 |
commit | d4b34c6c849d67b7afaa90d55dc7fab981c72950 (patch) | |
tree | c6b5c6bfe622832865a98fecec1159cb350bc18a /arch/arm | |
parent | 900fa0196c564895bfa2eb412d2a83421d3f3444 (diff) |
ARM: S5P: Reduce duplicated EPLL control codes
S5P Samsung SoCs has a EPLL to support various PLL clock sources for other
H/W blocks. Until now, to control EPLL, each of SoCs make their own functions
in 'mach-s5pxxx/clock.c'. But some of functions, 'xxx_epll_get_rate()' and
'xxx_epll_enable()', are exactly same in all S5P SoCs, so this patch move
these duplicated codes to common EPLL functions that use platform wide.
Signed-off-by: Seungwhan Youn <sw.youn@samsung.com>
Acked-by: Jassi Brar <jassi.brar@samsung.com>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-s5p64x0/clock-s5p6440.c | 4 | ||||
-rw-r--r-- | arch/arm/mach-s5p64x0/clock-s5p6450.c | 4 | ||||
-rw-r--r-- | arch/arm/mach-s5p64x0/clock.c | 18 | ||||
-rw-r--r-- | arch/arm/mach-s5p64x0/include/mach/regs-clock.h | 2 | ||||
-rw-r--r-- | arch/arm/mach-s5pc100/clock.c | 22 | ||||
-rw-r--r-- | arch/arm/mach-s5pv310/include/mach/regs-clock.h | 4 | ||||
-rw-r--r-- | arch/arm/plat-s5p/clock.c | 20 | ||||
-rw-r--r-- | arch/arm/plat-s5p/include/plat/s5p-clock.h | 4 |
8 files changed, 36 insertions, 42 deletions
diff --git a/arch/arm/mach-s5p64x0/clock-s5p6440.c b/arch/arm/mach-s5p64x0/clock-s5p6440.c index f93dcd8b4d6a..cfccdff744d2 100644 --- a/arch/arm/mach-s5p64x0/clock-s5p6440.c +++ b/arch/arm/mach-s5p64x0/clock-s5p6440.c | |||
@@ -85,7 +85,7 @@ static int s5p6440_epll_set_rate(struct clk *clk, unsigned long rate) | |||
85 | } | 85 | } |
86 | 86 | ||
87 | static struct clk_ops s5p6440_epll_ops = { | 87 | static struct clk_ops s5p6440_epll_ops = { |
88 | .get_rate = s5p64x0_epll_get_rate, | 88 | .get_rate = s5p_epll_get_rate, |
89 | .set_rate = s5p6440_epll_set_rate, | 89 | .set_rate = s5p6440_epll_set_rate, |
90 | }; | 90 | }; |
91 | 91 | ||
@@ -548,7 +548,7 @@ void __init_or_cpufreq s5p6440_setup_clocks(void) | |||
548 | 548 | ||
549 | /* Set S5P6440 functions for clk_fout_epll */ | 549 | /* Set S5P6440 functions for clk_fout_epll */ |
550 | 550 | ||
551 | clk_fout_epll.enable = s5p64x0_epll_enable; | 551 | clk_fout_epll.enable = s5p_epll_enable; |
552 | clk_fout_epll.ops = &s5p6440_epll_ops; | 552 | clk_fout_epll.ops = &s5p6440_epll_ops; |
553 | 553 | ||
554 | clk_48m.enable = s5p64x0_clk48m_ctrl; | 554 | clk_48m.enable = s5p64x0_clk48m_ctrl; |
diff --git a/arch/arm/mach-s5p64x0/clock-s5p6450.c b/arch/arm/mach-s5p64x0/clock-s5p6450.c index f9afb05b217c..f1498d35111b 100644 --- a/arch/arm/mach-s5p64x0/clock-s5p6450.c +++ b/arch/arm/mach-s5p64x0/clock-s5p6450.c | |||
@@ -86,7 +86,7 @@ static int s5p6450_epll_set_rate(struct clk *clk, unsigned long rate) | |||
86 | } | 86 | } |
87 | 87 | ||
88 | static struct clk_ops s5p6450_epll_ops = { | 88 | static struct clk_ops s5p6450_epll_ops = { |
89 | .get_rate = s5p64x0_epll_get_rate, | 89 | .get_rate = s5p_epll_get_rate, |
90 | .set_rate = s5p6450_epll_set_rate, | 90 | .set_rate = s5p6450_epll_set_rate, |
91 | }; | 91 | }; |
92 | 92 | ||
@@ -581,7 +581,7 @@ void __init_or_cpufreq s5p6450_setup_clocks(void) | |||
581 | 581 | ||
582 | /* Set S5P6450 functions for clk_fout_epll */ | 582 | /* Set S5P6450 functions for clk_fout_epll */ |
583 | 583 | ||
584 | clk_fout_epll.enable = s5p64x0_epll_enable; | 584 | clk_fout_epll.enable = s5p_epll_enable; |
585 | clk_fout_epll.ops = &s5p6450_epll_ops; | 585 | clk_fout_epll.ops = &s5p6450_epll_ops; |
586 | 586 | ||
587 | clk_48m.enable = s5p64x0_clk48m_ctrl; | 587 | clk_48m.enable = s5p64x0_clk48m_ctrl; |
diff --git a/arch/arm/mach-s5p64x0/clock.c b/arch/arm/mach-s5p64x0/clock.c index 523ba8039ac2..b52c6e2f37a6 100644 --- a/arch/arm/mach-s5p64x0/clock.c +++ b/arch/arm/mach-s5p64x0/clock.c | |||
@@ -73,24 +73,6 @@ static const u32 clock_table[][3] = { | |||
73 | {L2 * 1000, (3 << ARM_DIV_RATIO_SHIFT), (0 << S5P64X0_CLKDIV0_HCLK_SHIFT)}, | 73 | {L2 * 1000, (3 << ARM_DIV_RATIO_SHIFT), (0 << S5P64X0_CLKDIV0_HCLK_SHIFT)}, |
74 | }; | 74 | }; |
75 | 75 | ||
76 | int s5p64x0_epll_enable(struct clk *clk, int enable) | ||
77 | { | ||
78 | unsigned int ctrlbit = clk->ctrlbit; | ||
79 | unsigned int epll_con = __raw_readl(S5P64X0_EPLL_CON) & ~ctrlbit; | ||
80 | |||
81 | if (enable) | ||
82 | __raw_writel(epll_con | ctrlbit, S5P64X0_EPLL_CON); | ||
83 | else | ||
84 | __raw_writel(epll_con, S5P64X0_EPLL_CON); | ||
85 | |||
86 | return 0; | ||
87 | } | ||
88 | |||
89 | unsigned long s5p64x0_epll_get_rate(struct clk *clk) | ||
90 | { | ||
91 | return clk->rate; | ||
92 | } | ||
93 | |||
94 | unsigned long s5p64x0_armclk_get_rate(struct clk *clk) | 76 | unsigned long s5p64x0_armclk_get_rate(struct clk *clk) |
95 | { | 77 | { |
96 | unsigned long rate = clk_get_rate(clk->parent); | 78 | unsigned long rate = clk_get_rate(clk->parent); |
diff --git a/arch/arm/mach-s5p64x0/include/mach/regs-clock.h b/arch/arm/mach-s5p64x0/include/mach/regs-clock.h index 58e1bc813804..a133f22fa155 100644 --- a/arch/arm/mach-s5p64x0/include/mach/regs-clock.h +++ b/arch/arm/mach-s5p64x0/include/mach/regs-clock.h | |||
@@ -60,4 +60,6 @@ | |||
60 | #define ARM_DIV_RATIO_SHIFT 0 | 60 | #define ARM_DIV_RATIO_SHIFT 0 |
61 | #define ARM_DIV_MASK (0xF << ARM_DIV_RATIO_SHIFT) | 61 | #define ARM_DIV_MASK (0xF << ARM_DIV_RATIO_SHIFT) |
62 | 62 | ||
63 | #define S5P_EPLL_CON S5P64X0_EPLL_CON | ||
64 | |||
63 | #endif /* __ASM_ARCH_REGS_CLOCK_H */ | 65 | #endif /* __ASM_ARCH_REGS_CLOCK_H */ |
diff --git a/arch/arm/mach-s5pc100/clock.c b/arch/arm/mach-s5pc100/clock.c index 306ae743ad72..42c2636ca3ac 100644 --- a/arch/arm/mach-s5pc100/clock.c +++ b/arch/arm/mach-s5pc100/clock.c | |||
@@ -273,24 +273,6 @@ static struct clksrc_clk clk_div_hdmi = { | |||
273 | .reg_div = { .reg = S5P_CLK_DIV3, .shift = 28, .size = 4 }, | 273 | .reg_div = { .reg = S5P_CLK_DIV3, .shift = 28, .size = 4 }, |
274 | }; | 274 | }; |
275 | 275 | ||
276 | static int s5pc100_epll_enable(struct clk *clk, int enable) | ||
277 | { | ||
278 | unsigned int ctrlbit = clk->ctrlbit; | ||
279 | unsigned int epll_con = __raw_readl(S5P_EPLL_CON) & ~ctrlbit; | ||
280 | |||
281 | if (enable) | ||
282 | __raw_writel(epll_con | ctrlbit, S5P_EPLL_CON); | ||
283 | else | ||
284 | __raw_writel(epll_con, S5P_EPLL_CON); | ||
285 | |||
286 | return 0; | ||
287 | } | ||
288 | |||
289 | static unsigned long s5pc100_epll_get_rate(struct clk *clk) | ||
290 | { | ||
291 | return clk->rate; | ||
292 | } | ||
293 | |||
294 | static u32 epll_div[][4] = { | 276 | static u32 epll_div[][4] = { |
295 | { 32750000, 131, 3, 4 }, | 277 | { 32750000, 131, 3, 4 }, |
296 | { 32768000, 131, 3, 4 }, | 278 | { 32768000, 131, 3, 4 }, |
@@ -347,7 +329,7 @@ static int s5pc100_epll_set_rate(struct clk *clk, unsigned long rate) | |||
347 | } | 329 | } |
348 | 330 | ||
349 | static struct clk_ops s5pc100_epll_ops = { | 331 | static struct clk_ops s5pc100_epll_ops = { |
350 | .get_rate = s5pc100_epll_get_rate, | 332 | .get_rate = s5p_epll_get_rate, |
351 | .set_rate = s5pc100_epll_set_rate, | 333 | .set_rate = s5pc100_epll_set_rate, |
352 | }; | 334 | }; |
353 | 335 | ||
@@ -1261,7 +1243,7 @@ void __init_or_cpufreq s5pc100_setup_clocks(void) | |||
1261 | unsigned int ptr; | 1243 | unsigned int ptr; |
1262 | 1244 | ||
1263 | /* Set S5PC100 functions for clk_fout_epll */ | 1245 | /* Set S5PC100 functions for clk_fout_epll */ |
1264 | clk_fout_epll.enable = s5pc100_epll_enable; | 1246 | clk_fout_epll.enable = s5p_epll_enable; |
1265 | clk_fout_epll.ops = &s5pc100_epll_ops; | 1247 | clk_fout_epll.ops = &s5pc100_epll_ops; |
1266 | 1248 | ||
1267 | printk(KERN_DEBUG "%s: registering clocks\n", __func__); | 1249 | printk(KERN_DEBUG "%s: registering clocks\n", __func__); |
diff --git a/arch/arm/mach-s5pv310/include/mach/regs-clock.h b/arch/arm/mach-s5pv310/include/mach/regs-clock.h index 12e983c11ad4..f1028cad9788 100644 --- a/arch/arm/mach-s5pv310/include/mach/regs-clock.h +++ b/arch/arm/mach-s5pv310/include/mach/regs-clock.h | |||
@@ -84,4 +84,8 @@ | |||
84 | 84 | ||
85 | #define S5P_CLKGATE_SCLKCPU S5P_CLKREG(0x14800) | 85 | #define S5P_CLKGATE_SCLKCPU S5P_CLKREG(0x14800) |
86 | 86 | ||
87 | /* Compatibility defines */ | ||
88 | |||
89 | #define S5P_EPLL_CON S5P_EPLL_CON0 | ||
90 | |||
87 | #endif /* __ASM_ARCH_REGS_CLOCK_H */ | 91 | #endif /* __ASM_ARCH_REGS_CLOCK_H */ |
diff --git a/arch/arm/plat-s5p/clock.c b/arch/arm/plat-s5p/clock.c index 818800962694..8d081d968c58 100644 --- a/arch/arm/plat-s5p/clock.c +++ b/arch/arm/plat-s5p/clock.c | |||
@@ -21,6 +21,8 @@ | |||
21 | #include <linux/io.h> | 21 | #include <linux/io.h> |
22 | #include <asm/div64.h> | 22 | #include <asm/div64.h> |
23 | 23 | ||
24 | #include <mach/regs-clock.h> | ||
25 | |||
24 | #include <plat/clock.h> | 26 | #include <plat/clock.h> |
25 | #include <plat/clock-clksrc.h> | 27 | #include <plat/clock-clksrc.h> |
26 | #include <plat/s5p-clock.h> | 28 | #include <plat/s5p-clock.h> |
@@ -148,6 +150,24 @@ int s5p_gatectrl(void __iomem *reg, struct clk *clk, int enable) | |||
148 | return 0; | 150 | return 0; |
149 | } | 151 | } |
150 | 152 | ||
153 | int s5p_epll_enable(struct clk *clk, int enable) | ||
154 | { | ||
155 | unsigned int ctrlbit = clk->ctrlbit; | ||
156 | unsigned int epll_con = __raw_readl(S5P_EPLL_CON) & ~ctrlbit; | ||
157 | |||
158 | if (enable) | ||
159 | __raw_writel(epll_con | ctrlbit, S5P_EPLL_CON); | ||
160 | else | ||
161 | __raw_writel(epll_con, S5P_EPLL_CON); | ||
162 | |||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | unsigned long s5p_epll_get_rate(struct clk *clk) | ||
167 | { | ||
168 | return clk->rate; | ||
169 | } | ||
170 | |||
151 | static struct clk *s5p_clks[] __initdata = { | 171 | static struct clk *s5p_clks[] __initdata = { |
152 | &clk_ext_xtal_mux, | 172 | &clk_ext_xtal_mux, |
153 | &clk_48m, | 173 | &clk_48m, |
diff --git a/arch/arm/plat-s5p/include/plat/s5p-clock.h b/arch/arm/plat-s5p/include/plat/s5p-clock.h index 17036c898409..2b6dcff8ab2b 100644 --- a/arch/arm/plat-s5p/include/plat/s5p-clock.h +++ b/arch/arm/plat-s5p/include/plat/s5p-clock.h | |||
@@ -43,4 +43,8 @@ extern struct clksrc_sources clk_src_dpll; | |||
43 | 43 | ||
44 | extern int s5p_gatectrl(void __iomem *reg, struct clk *clk, int enable); | 44 | extern int s5p_gatectrl(void __iomem *reg, struct clk *clk, int enable); |
45 | 45 | ||
46 | /* Common EPLL operations for S5P platform */ | ||
47 | extern int s5p_epll_enable(struct clk *clk, int enable); | ||
48 | extern unsigned long s5p_epll_get_rate(struct clk *clk); | ||
49 | |||
46 | #endif /* __ASM_PLAT_S5P_CLOCK_H */ | 50 | #endif /* __ASM_PLAT_S5P_CLOCK_H */ |