diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2008-11-04 09:02:46 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-02-02 09:52:18 -0500 |
commit | 548d849574847b788fe846fe21a41386063be161 (patch) | |
tree | 6c2ac7379c376793368affab03e5202abd0f1efa /arch/arm/mach-omap2 | |
parent | db8ac47cfccaafd3fa4c5c15320809d44f4fcef9 (diff) |
[ARM] omap: introduce clock operations structure
Collect up all the common enable/disable clock operation functions
into a separate operations structure.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-omap2')
-rw-r--r-- | arch/arm/mach-omap2/clock.c | 8 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock24xx.c | 16 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock24xx.h | 13 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock34xx.c | 10 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock34xx.h | 11 |
5 files changed, 34 insertions, 24 deletions
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c index ad721e0cbf7a..d3213f565d5f 100644 --- a/arch/arm/mach-omap2/clock.c +++ b/arch/arm/mach-omap2/clock.c | |||
@@ -274,8 +274,8 @@ int _omap2_clk_enable(struct clk *clk) | |||
274 | if (clk->flags & (ALWAYS_ENABLED | PARENT_CONTROLS_CLOCK)) | 274 | if (clk->flags & (ALWAYS_ENABLED | PARENT_CONTROLS_CLOCK)) |
275 | return 0; | 275 | return 0; |
276 | 276 | ||
277 | if (clk->enable) | 277 | if (clk->ops && clk->ops->enable) |
278 | return clk->enable(clk); | 278 | return clk->ops->enable(clk); |
279 | 279 | ||
280 | if (unlikely(clk->enable_reg == NULL)) { | 280 | if (unlikely(clk->enable_reg == NULL)) { |
281 | printk(KERN_ERR "clock.c: Enable for %s without enable code\n", | 281 | printk(KERN_ERR "clock.c: Enable for %s without enable code\n", |
@@ -304,8 +304,8 @@ void _omap2_clk_disable(struct clk *clk) | |||
304 | if (clk->flags & (ALWAYS_ENABLED | PARENT_CONTROLS_CLOCK)) | 304 | if (clk->flags & (ALWAYS_ENABLED | PARENT_CONTROLS_CLOCK)) |
305 | return; | 305 | return; |
306 | 306 | ||
307 | if (clk->disable) { | 307 | if (clk->ops && clk->ops->disable) { |
308 | clk->disable(clk); | 308 | clk->ops->disable(clk); |
309 | return; | 309 | return; |
310 | } | 310 | } |
311 | 311 | ||
diff --git a/arch/arm/mach-omap2/clock24xx.c b/arch/arm/mach-omap2/clock24xx.c index d382eb0184ac..866a618c4d8d 100644 --- a/arch/arm/mach-omap2/clock24xx.c +++ b/arch/arm/mach-omap2/clock24xx.c | |||
@@ -34,12 +34,16 @@ | |||
34 | 34 | ||
35 | #include "memory.h" | 35 | #include "memory.h" |
36 | #include "clock.h" | 36 | #include "clock.h" |
37 | #include "clock24xx.h" | ||
38 | #include "prm.h" | 37 | #include "prm.h" |
39 | #include "prm-regbits-24xx.h" | 38 | #include "prm-regbits-24xx.h" |
40 | #include "cm.h" | 39 | #include "cm.h" |
41 | #include "cm-regbits-24xx.h" | 40 | #include "cm-regbits-24xx.h" |
42 | 41 | ||
42 | static const struct clkops clkops_oscck; | ||
43 | static const struct clkops clkops_fixed; | ||
44 | |||
45 | #include "clock24xx.h" | ||
46 | |||
43 | /* CM_CLKEN_PLL.EN_{54,96}M_PLL options (24XX) */ | 47 | /* CM_CLKEN_PLL.EN_{54,96}M_PLL options (24XX) */ |
44 | #define EN_APLL_STOPPED 0 | 48 | #define EN_APLL_STOPPED 0 |
45 | #define EN_APLL_LOCKED 3 | 49 | #define EN_APLL_LOCKED 3 |
@@ -96,6 +100,11 @@ static void omap2_disable_osc_ck(struct clk *clk) | |||
96 | OMAP24XX_PRCM_CLKSRC_CTRL); | 100 | OMAP24XX_PRCM_CLKSRC_CTRL); |
97 | } | 101 | } |
98 | 102 | ||
103 | static const struct clkops clkops_oscck = { | ||
104 | .enable = &omap2_enable_osc_ck, | ||
105 | .disable = &omap2_disable_osc_ck, | ||
106 | }; | ||
107 | |||
99 | #ifdef OLD_CK | 108 | #ifdef OLD_CK |
100 | /* Recalculate SYST_CLK */ | 109 | /* Recalculate SYST_CLK */ |
101 | static void omap2_sys_clk_recalc(struct clk * clk) | 110 | static void omap2_sys_clk_recalc(struct clk * clk) |
@@ -149,6 +158,11 @@ static void omap2_clk_fixed_disable(struct clk *clk) | |||
149 | cm_write_mod_reg(cval, PLL_MOD, CM_CLKEN); | 158 | cm_write_mod_reg(cval, PLL_MOD, CM_CLKEN); |
150 | } | 159 | } |
151 | 160 | ||
161 | static const struct clkops clkops_fixed = { | ||
162 | .enable = &omap2_clk_fixed_enable, | ||
163 | .disable = &omap2_clk_fixed_disable, | ||
164 | }; | ||
165 | |||
152 | /* | 166 | /* |
153 | * Uses the current prcm set to tell if a rate is valid. | 167 | * Uses the current prcm set to tell if a rate is valid. |
154 | * You can go slower, but not faster within a given rate set. | 168 | * You can go slower, but not faster within a given rate set. |
diff --git a/arch/arm/mach-omap2/clock24xx.h b/arch/arm/mach-omap2/clock24xx.h index 8c57a2e180f6..2aa0b5e65608 100644 --- a/arch/arm/mach-omap2/clock24xx.h +++ b/arch/arm/mach-omap2/clock24xx.h | |||
@@ -31,10 +31,6 @@ static void omap2_sys_clk_recalc(struct clk *clk); | |||
31 | static void omap2_osc_clk_recalc(struct clk *clk); | 31 | static void omap2_osc_clk_recalc(struct clk *clk); |
32 | static void omap2_sys_clk_recalc(struct clk *clk); | 32 | static void omap2_sys_clk_recalc(struct clk *clk); |
33 | static void omap2_dpllcore_recalc(struct clk *clk); | 33 | static void omap2_dpllcore_recalc(struct clk *clk); |
34 | static int omap2_clk_fixed_enable(struct clk *clk); | ||
35 | static void omap2_clk_fixed_disable(struct clk *clk); | ||
36 | static int omap2_enable_osc_ck(struct clk *clk); | ||
37 | static void omap2_disable_osc_ck(struct clk *clk); | ||
38 | static int omap2_reprogram_dpllcore(struct clk *clk, unsigned long rate); | 34 | static int omap2_reprogram_dpllcore(struct clk *clk, unsigned long rate); |
39 | 35 | ||
40 | /* Key dividers which make up a PRCM set. Ratio's for a PRCM are mandated. | 36 | /* Key dividers which make up a PRCM set. Ratio's for a PRCM are mandated. |
@@ -633,11 +629,10 @@ static struct clk func_32k_ck = { | |||
633 | /* Typical 12/13MHz in standalone mode, will be 26Mhz in chassis mode */ | 629 | /* Typical 12/13MHz in standalone mode, will be 26Mhz in chassis mode */ |
634 | static struct clk osc_ck = { /* (*12, *13, 19.2, *26, 38.4)MHz */ | 630 | static struct clk osc_ck = { /* (*12, *13, 19.2, *26, 38.4)MHz */ |
635 | .name = "osc_ck", | 631 | .name = "osc_ck", |
632 | .ops = &clkops_oscck, | ||
636 | .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | | 633 | .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | |
637 | RATE_PROPAGATES, | 634 | RATE_PROPAGATES, |
638 | .clkdm_name = "wkup_clkdm", | 635 | .clkdm_name = "wkup_clkdm", |
639 | .enable = &omap2_enable_osc_ck, | ||
640 | .disable = &omap2_disable_osc_ck, | ||
641 | .recalc = &omap2_osc_clk_recalc, | 636 | .recalc = &omap2_osc_clk_recalc, |
642 | }; | 637 | }; |
643 | 638 | ||
@@ -695,6 +690,7 @@ static struct clk dpll_ck = { | |||
695 | 690 | ||
696 | static struct clk apll96_ck = { | 691 | static struct clk apll96_ck = { |
697 | .name = "apll96_ck", | 692 | .name = "apll96_ck", |
693 | .ops = &clkops_fixed, | ||
698 | .parent = &sys_ck, | 694 | .parent = &sys_ck, |
699 | .rate = 96000000, | 695 | .rate = 96000000, |
700 | .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | | 696 | .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | |
@@ -702,13 +698,12 @@ static struct clk apll96_ck = { | |||
702 | .clkdm_name = "wkup_clkdm", | 698 | .clkdm_name = "wkup_clkdm", |
703 | .enable_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKEN), | 699 | .enable_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKEN), |
704 | .enable_bit = OMAP24XX_EN_96M_PLL_SHIFT, | 700 | .enable_bit = OMAP24XX_EN_96M_PLL_SHIFT, |
705 | .enable = &omap2_clk_fixed_enable, | ||
706 | .disable = &omap2_clk_fixed_disable, | ||
707 | .recalc = &propagate_rate, | 701 | .recalc = &propagate_rate, |
708 | }; | 702 | }; |
709 | 703 | ||
710 | static struct clk apll54_ck = { | 704 | static struct clk apll54_ck = { |
711 | .name = "apll54_ck", | 705 | .name = "apll54_ck", |
706 | .ops = &clkops_fixed, | ||
712 | .parent = &sys_ck, | 707 | .parent = &sys_ck, |
713 | .rate = 54000000, | 708 | .rate = 54000000, |
714 | .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | | 709 | .flags = CLOCK_IN_OMAP242X | CLOCK_IN_OMAP243X | |
@@ -716,8 +711,6 @@ static struct clk apll54_ck = { | |||
716 | .clkdm_name = "wkup_clkdm", | 711 | .clkdm_name = "wkup_clkdm", |
717 | .enable_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKEN), | 712 | .enable_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKEN), |
718 | .enable_bit = OMAP24XX_EN_54M_PLL_SHIFT, | 713 | .enable_bit = OMAP24XX_EN_54M_PLL_SHIFT, |
719 | .enable = &omap2_clk_fixed_enable, | ||
720 | .disable = &omap2_clk_fixed_disable, | ||
721 | .recalc = &propagate_rate, | 714 | .recalc = &propagate_rate, |
722 | }; | 715 | }; |
723 | 716 | ||
diff --git a/arch/arm/mach-omap2/clock34xx.c b/arch/arm/mach-omap2/clock34xx.c index 31bb7010bd48..2f2d43db2dd8 100644 --- a/arch/arm/mach-omap2/clock34xx.c +++ b/arch/arm/mach-omap2/clock34xx.c | |||
@@ -33,12 +33,15 @@ | |||
33 | 33 | ||
34 | #include "memory.h" | 34 | #include "memory.h" |
35 | #include "clock.h" | 35 | #include "clock.h" |
36 | #include "clock34xx.h" | ||
37 | #include "prm.h" | 36 | #include "prm.h" |
38 | #include "prm-regbits-34xx.h" | 37 | #include "prm-regbits-34xx.h" |
39 | #include "cm.h" | 38 | #include "cm.h" |
40 | #include "cm-regbits-34xx.h" | 39 | #include "cm-regbits-34xx.h" |
41 | 40 | ||
41 | static const struct clkops clkops_noncore_dpll_ops; | ||
42 | |||
43 | #include "clock34xx.h" | ||
44 | |||
42 | /* CM_AUTOIDLE_PLL*.AUTO_* bit values */ | 45 | /* CM_AUTOIDLE_PLL*.AUTO_* bit values */ |
43 | #define DPLL_AUTOIDLE_DISABLE 0x0 | 46 | #define DPLL_AUTOIDLE_DISABLE 0x0 |
44 | #define DPLL_AUTOIDLE_LOW_POWER_STOP 0x1 | 47 | #define DPLL_AUTOIDLE_LOW_POWER_STOP 0x1 |
@@ -270,6 +273,11 @@ static void omap3_noncore_dpll_disable(struct clk *clk) | |||
270 | _omap3_noncore_dpll_stop(clk); | 273 | _omap3_noncore_dpll_stop(clk); |
271 | } | 274 | } |
272 | 275 | ||
276 | static const struct clkops clkops_noncore_dpll_ops = { | ||
277 | .enable = &omap3_noncore_dpll_enable, | ||
278 | .disable = &omap3_noncore_dpll_disable, | ||
279 | }; | ||
280 | |||
273 | /** | 281 | /** |
274 | * omap3_dpll_autoidle_read - read a DPLL's autoidle bits | 282 | * omap3_dpll_autoidle_read - read a DPLL's autoidle bits |
275 | * @clk: struct clk * of the DPLL to read | 283 | * @clk: struct clk * of the DPLL to read |
diff --git a/arch/arm/mach-omap2/clock34xx.h b/arch/arm/mach-omap2/clock34xx.h index a826094d89b5..8b188fb9beab 100644 --- a/arch/arm/mach-omap2/clock34xx.h +++ b/arch/arm/mach-omap2/clock34xx.h | |||
@@ -32,8 +32,6 @@ static void omap3_clkoutx2_recalc(struct clk *clk); | |||
32 | static void omap3_dpll_allow_idle(struct clk *clk); | 32 | static void omap3_dpll_allow_idle(struct clk *clk); |
33 | static void omap3_dpll_deny_idle(struct clk *clk); | 33 | static void omap3_dpll_deny_idle(struct clk *clk); |
34 | static u32 omap3_dpll_autoidle_read(struct clk *clk); | 34 | static u32 omap3_dpll_autoidle_read(struct clk *clk); |
35 | static int omap3_noncore_dpll_enable(struct clk *clk); | ||
36 | static void omap3_noncore_dpll_disable(struct clk *clk); | ||
37 | 35 | ||
38 | /* Maximum DPLL multiplier, divider values for OMAP3 */ | 36 | /* Maximum DPLL multiplier, divider values for OMAP3 */ |
39 | #define OMAP3_MAX_DPLL_MULT 2048 | 37 | #define OMAP3_MAX_DPLL_MULT 2048 |
@@ -347,11 +345,10 @@ static struct dpll_data dpll2_dd = { | |||
347 | 345 | ||
348 | static struct clk dpll2_ck = { | 346 | static struct clk dpll2_ck = { |
349 | .name = "dpll2_ck", | 347 | .name = "dpll2_ck", |
348 | .ops = &clkops_noncore_dpll_ops, | ||
350 | .parent = &sys_ck, | 349 | .parent = &sys_ck, |
351 | .dpll_data = &dpll2_dd, | 350 | .dpll_data = &dpll2_dd, |
352 | .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES, | 351 | .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES, |
353 | .enable = &omap3_noncore_dpll_enable, | ||
354 | .disable = &omap3_noncore_dpll_disable, | ||
355 | .round_rate = &omap2_dpll_round_rate, | 352 | .round_rate = &omap2_dpll_round_rate, |
356 | .recalc = &omap3_dpll_recalc, | 353 | .recalc = &omap3_dpll_recalc, |
357 | }; | 354 | }; |
@@ -582,11 +579,10 @@ static struct dpll_data dpll4_dd = { | |||
582 | 579 | ||
583 | static struct clk dpll4_ck = { | 580 | static struct clk dpll4_ck = { |
584 | .name = "dpll4_ck", | 581 | .name = "dpll4_ck", |
582 | .ops = &clkops_noncore_dpll_ops, | ||
585 | .parent = &sys_ck, | 583 | .parent = &sys_ck, |
586 | .dpll_data = &dpll4_dd, | 584 | .dpll_data = &dpll4_dd, |
587 | .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES, | 585 | .flags = CLOCK_IN_OMAP343X | RATE_PROPAGATES, |
588 | .enable = &omap3_noncore_dpll_enable, | ||
589 | .disable = &omap3_noncore_dpll_disable, | ||
590 | .round_rate = &omap2_dpll_round_rate, | 586 | .round_rate = &omap2_dpll_round_rate, |
591 | .recalc = &omap3_dpll_recalc, | 587 | .recalc = &omap3_dpll_recalc, |
592 | }; | 588 | }; |
@@ -884,11 +880,10 @@ static struct dpll_data dpll5_dd = { | |||
884 | 880 | ||
885 | static struct clk dpll5_ck = { | 881 | static struct clk dpll5_ck = { |
886 | .name = "dpll5_ck", | 882 | .name = "dpll5_ck", |
883 | .ops = &clkops_noncore_dpll_ops, | ||
887 | .parent = &sys_ck, | 884 | .parent = &sys_ck, |
888 | .dpll_data = &dpll5_dd, | 885 | .dpll_data = &dpll5_dd, |
889 | .flags = CLOCK_IN_OMAP3430ES2 | RATE_PROPAGATES, | 886 | .flags = CLOCK_IN_OMAP3430ES2 | RATE_PROPAGATES, |
890 | .enable = &omap3_noncore_dpll_enable, | ||
891 | .disable = &omap3_noncore_dpll_disable, | ||
892 | .round_rate = &omap2_dpll_round_rate, | 887 | .round_rate = &omap2_dpll_round_rate, |
893 | .recalc = &omap3_dpll_recalc, | 888 | .recalc = &omap3_dpll_recalc, |
894 | }; | 889 | }; |