diff options
author | Paul Walmsley <paul@pwsan.com> | 2012-10-29 22:56:17 -0400 |
---|---|---|
committer | Paul Walmsley <paul@pwsan.com> | 2012-11-08 14:33:08 -0500 |
commit | b6ffa05091978c68e94d2802200f2aaa06a598d9 (patch) | |
tree | 4e2b9cc71015ba1103efe7ded485294a3aab19e7 | |
parent | 187e3e06e8d7050a77c3208f54edff1e1bfae31d (diff) |
ARM: OMAP2xxx: APLL/CM: convert to use omap2_cm_wait_module_ready()
Convert the OMAP2xxx APLL code to use omap2_cm_wait_module_ready(),
and move the low-level CM register manipulation functions to
mach-omap2/cm2xxx.c. The objectives here are to remove the dependency
on the deprecated omap2_cm_wait_idlest() function in
mach-omap2/prcm.c, so that code can be removed later; and move
low-level register accesses to the CM IP block to the CM code, which
will soon be moved into drivers/.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Tested-by: Vaibhav Hiremath <hvaibhav@ti.com>
-rw-r--r-- | arch/arm/mach-omap2/clkt2xxx_apll.c | 56 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock2420_data.c | 1 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock2430_data.c | 1 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock2xxx.h | 2 | ||||
-rw-r--r-- | arch/arm/mach-omap2/cm-regbits-24xx.h | 2 | ||||
-rw-r--r-- | arch/arm/mach-omap2/cm2xxx.c | 65 | ||||
-rw-r--r-- | arch/arm/mach-omap2/cm2xxx_3xxx.h | 6 |
7 files changed, 85 insertions, 48 deletions
diff --git a/arch/arm/mach-omap2/clkt2xxx_apll.c b/arch/arm/mach-omap2/clkt2xxx_apll.c index e3f0c1e262a7..75561a6b04d3 100644 --- a/arch/arm/mach-omap2/clkt2xxx_apll.c +++ b/arch/arm/mach-omap2/clkt2xxx_apll.c | |||
@@ -37,44 +37,16 @@ | |||
37 | #define APLLS_CLKIN_13MHZ 2 | 37 | #define APLLS_CLKIN_13MHZ 2 |
38 | #define APLLS_CLKIN_12MHZ 3 | 38 | #define APLLS_CLKIN_12MHZ 3 |
39 | 39 | ||
40 | void __iomem *cm_idlest_pll; | ||
41 | |||
42 | /* Private functions */ | 40 | /* Private functions */ |
43 | 41 | ||
44 | /* Enable an APLL if off */ | 42 | static int _apll96_enable(struct clk *clk) |
45 | static int omap2_clk_apll_enable(struct clk *clk, u32 status_mask) | ||
46 | { | ||
47 | u32 cval, apll_mask; | ||
48 | |||
49 | apll_mask = EN_APLL_LOCKED << clk->enable_bit; | ||
50 | |||
51 | cval = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKEN); | ||
52 | |||
53 | if ((cval & apll_mask) == apll_mask) | ||
54 | return 0; /* apll already enabled */ | ||
55 | |||
56 | cval &= ~apll_mask; | ||
57 | cval |= apll_mask; | ||
58 | omap2_cm_write_mod_reg(cval, PLL_MOD, CM_CLKEN); | ||
59 | |||
60 | omap2_cm_wait_idlest(cm_idlest_pll, status_mask, | ||
61 | OMAP24XX_CM_IDLEST_VAL, __clk_get_name(clk)); | ||
62 | |||
63 | /* | ||
64 | * REVISIT: Should we return an error code if omap2_wait_clock_ready() | ||
65 | * fails? | ||
66 | */ | ||
67 | return 0; | ||
68 | } | ||
69 | |||
70 | static int omap2_clk_apll96_enable(struct clk *clk) | ||
71 | { | 43 | { |
72 | return omap2_clk_apll_enable(clk, OMAP24XX_ST_96M_APLL_MASK); | 44 | return omap2xxx_cm_apll96_enable(); |
73 | } | 45 | } |
74 | 46 | ||
75 | static int omap2_clk_apll54_enable(struct clk *clk) | 47 | static int _apll54_enable(struct clk *clk) |
76 | { | 48 | { |
77 | return omap2_clk_apll_enable(clk, OMAP24XX_ST_54M_APLL_MASK); | 49 | return omap2xxx_cm_apll54_enable(); |
78 | } | 50 | } |
79 | 51 | ||
80 | static void _apll96_allow_idle(struct clk *clk) | 52 | static void _apll96_allow_idle(struct clk *clk) |
@@ -97,28 +69,28 @@ static void _apll54_deny_idle(struct clk *clk) | |||
97 | omap2xxx_cm_set_apll54_disable_autoidle(); | 69 | omap2xxx_cm_set_apll54_disable_autoidle(); |
98 | } | 70 | } |
99 | 71 | ||
100 | /* Stop APLL */ | 72 | static void _apll96_disable(struct clk *clk) |
101 | static void omap2_clk_apll_disable(struct clk *clk) | ||
102 | { | 73 | { |
103 | u32 cval; | 74 | omap2xxx_cm_apll96_disable(); |
75 | } | ||
104 | 76 | ||
105 | cval = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKEN); | 77 | static void _apll54_disable(struct clk *clk) |
106 | cval &= ~(EN_APLL_LOCKED << clk->enable_bit); | 78 | { |
107 | omap2_cm_write_mod_reg(cval, PLL_MOD, CM_CLKEN); | 79 | omap2xxx_cm_apll54_disable(); |
108 | } | 80 | } |
109 | 81 | ||
110 | /* Public data */ | 82 | /* Public data */ |
111 | 83 | ||
112 | const struct clkops clkops_apll96 = { | 84 | const struct clkops clkops_apll96 = { |
113 | .enable = omap2_clk_apll96_enable, | 85 | .enable = _apll96_enable, |
114 | .disable = omap2_clk_apll_disable, | 86 | .disable = _apll96_disable, |
115 | .allow_idle = _apll96_allow_idle, | 87 | .allow_idle = _apll96_allow_idle, |
116 | .deny_idle = _apll96_deny_idle, | 88 | .deny_idle = _apll96_deny_idle, |
117 | }; | 89 | }; |
118 | 90 | ||
119 | const struct clkops clkops_apll54 = { | 91 | const struct clkops clkops_apll54 = { |
120 | .enable = omap2_clk_apll54_enable, | 92 | .enable = _apll54_enable, |
121 | .disable = omap2_clk_apll_disable, | 93 | .disable = _apll54_disable, |
122 | .allow_idle = _apll54_allow_idle, | 94 | .allow_idle = _apll54_allow_idle, |
123 | .deny_idle = _apll54_deny_idle, | 95 | .deny_idle = _apll54_deny_idle, |
124 | }; | 96 | }; |
diff --git a/arch/arm/mach-omap2/clock2420_data.c b/arch/arm/mach-omap2/clock2420_data.c index 49ea3b62bb09..608874b651e8 100644 --- a/arch/arm/mach-omap2/clock2420_data.c +++ b/arch/arm/mach-omap2/clock2420_data.c | |||
@@ -1928,7 +1928,6 @@ int __init omap2420_clk_init(void) | |||
1928 | struct omap_clk *c; | 1928 | struct omap_clk *c; |
1929 | 1929 | ||
1930 | prcm_clksrc_ctrl = OMAP2420_PRCM_CLKSRC_CTRL; | 1930 | prcm_clksrc_ctrl = OMAP2420_PRCM_CLKSRC_CTRL; |
1931 | cm_idlest_pll = OMAP_CM_REGADDR(PLL_MOD, CM_IDLEST); | ||
1932 | cpu_mask = RATE_IN_242X; | 1931 | cpu_mask = RATE_IN_242X; |
1933 | rate_table = omap2420_rate_table; | 1932 | rate_table = omap2420_rate_table; |
1934 | 1933 | ||
diff --git a/arch/arm/mach-omap2/clock2430_data.c b/arch/arm/mach-omap2/clock2430_data.c index 6f1e26c21b91..b179b6ef4329 100644 --- a/arch/arm/mach-omap2/clock2430_data.c +++ b/arch/arm/mach-omap2/clock2430_data.c | |||
@@ -2027,7 +2027,6 @@ int __init omap2430_clk_init(void) | |||
2027 | struct omap_clk *c; | 2027 | struct omap_clk *c; |
2028 | 2028 | ||
2029 | prcm_clksrc_ctrl = OMAP2430_PRCM_CLKSRC_CTRL; | 2029 | prcm_clksrc_ctrl = OMAP2430_PRCM_CLKSRC_CTRL; |
2030 | cm_idlest_pll = OMAP_CM_REGADDR(PLL_MOD, CM_IDLEST); | ||
2031 | cpu_mask = RATE_IN_243X; | 2030 | cpu_mask = RATE_IN_243X; |
2032 | rate_table = omap2430_rate_table; | 2031 | rate_table = omap2430_rate_table; |
2033 | 2032 | ||
diff --git a/arch/arm/mach-omap2/clock2xxx.h b/arch/arm/mach-omap2/clock2xxx.h index 25b8d0207527..ce809c913b6f 100644 --- a/arch/arm/mach-omap2/clock2xxx.h +++ b/arch/arm/mach-omap2/clock2xxx.h | |||
@@ -35,7 +35,7 @@ int omap2430_clk_init(void); | |||
35 | #define omap2430_clk_init() do { } while(0) | 35 | #define omap2430_clk_init() do { } while(0) |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | extern void __iomem *prcm_clksrc_ctrl, *cm_idlest_pll; | 38 | extern void __iomem *prcm_clksrc_ctrl; |
39 | 39 | ||
40 | extern const struct clkops clkops_omap2430_i2chs_wait; | 40 | extern const struct clkops clkops_omap2430_i2chs_wait; |
41 | extern const struct clkops clkops_oscck; | 41 | extern const struct clkops clkops_oscck; |
diff --git a/arch/arm/mach-omap2/cm-regbits-24xx.h b/arch/arm/mach-omap2/cm-regbits-24xx.h index 686290437568..11eaf16880c4 100644 --- a/arch/arm/mach-omap2/cm-regbits-24xx.h +++ b/arch/arm/mach-omap2/cm-regbits-24xx.h | |||
@@ -333,7 +333,9 @@ | |||
333 | #define OMAP24XX_EN_DPLL_MASK (0x3 << 0) | 333 | #define OMAP24XX_EN_DPLL_MASK (0x3 << 0) |
334 | 334 | ||
335 | /* CM_IDLEST_CKGEN */ | 335 | /* CM_IDLEST_CKGEN */ |
336 | #define OMAP24XX_ST_54M_APLL_SHIFT 9 | ||
336 | #define OMAP24XX_ST_54M_APLL_MASK (1 << 9) | 337 | #define OMAP24XX_ST_54M_APLL_MASK (1 << 9) |
338 | #define OMAP24XX_ST_96M_APLL_SHIFT 8 | ||
337 | #define OMAP24XX_ST_96M_APLL_MASK (1 << 8) | 339 | #define OMAP24XX_ST_96M_APLL_MASK (1 << 8) |
338 | #define OMAP24XX_ST_54M_CLK_MASK (1 << 6) | 340 | #define OMAP24XX_ST_54M_CLK_MASK (1 << 6) |
339 | #define OMAP24XX_ST_12M_CLK_MASK (1 << 5) | 341 | #define OMAP24XX_ST_12M_CLK_MASK (1 << 5) |
diff --git a/arch/arm/mach-omap2/cm2xxx.c b/arch/arm/mach-omap2/cm2xxx.c index 64165013daf9..e96cd7041b66 100644 --- a/arch/arm/mach-omap2/cm2xxx.c +++ b/arch/arm/mach-omap2/cm2xxx.c | |||
@@ -35,6 +35,9 @@ | |||
35 | #define OMAP2XXX_APLL_AUTOIDLE_DISABLE 0x0 | 35 | #define OMAP2XXX_APLL_AUTOIDLE_DISABLE 0x0 |
36 | #define OMAP2XXX_APLL_AUTOIDLE_LOW_POWER_STOP 0x3 | 36 | #define OMAP2XXX_APLL_AUTOIDLE_LOW_POWER_STOP 0x3 |
37 | 37 | ||
38 | /* CM_IDLEST_PLL bit value offset for APLLs (OMAP2xxx only) */ | ||
39 | #define EN_APLL_LOCKED 3 | ||
40 | |||
38 | static const u8 omap2xxx_cm_idlest_offs[] = { | 41 | static const u8 omap2xxx_cm_idlest_offs[] = { |
39 | CM_IDLEST1, CM_IDLEST2, OMAP2430_CM_IDLEST3, OMAP24XX_CM_IDLEST4 | 42 | CM_IDLEST1, CM_IDLEST2, OMAP2430_CM_IDLEST3, OMAP24XX_CM_IDLEST4 |
40 | }; | 43 | }; |
@@ -99,7 +102,7 @@ void omap2xxx_cm_set_dpll_auto_low_power_stop(void) | |||
99 | } | 102 | } |
100 | 103 | ||
101 | /* | 104 | /* |
102 | * APLL autoidle control | 105 | * APLL control |
103 | */ | 106 | */ |
104 | 107 | ||
105 | static void _omap2xxx_set_apll_autoidle(u8 m, u32 mask) | 108 | static void _omap2xxx_set_apll_autoidle(u8 m, u32 mask) |
@@ -136,6 +139,65 @@ void omap2xxx_cm_set_apll96_auto_low_power_stop(void) | |||
136 | OMAP24XX_AUTO_96M_MASK); | 139 | OMAP24XX_AUTO_96M_MASK); |
137 | } | 140 | } |
138 | 141 | ||
142 | /* Enable an APLL if off */ | ||
143 | static int _omap2xxx_apll_enable(u8 enable_bit, u8 status_bit) | ||
144 | { | ||
145 | u32 v, m; | ||
146 | |||
147 | m = EN_APLL_LOCKED << enable_bit; | ||
148 | |||
149 | v = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKEN); | ||
150 | if (v & m) | ||
151 | return 0; /* apll already enabled */ | ||
152 | |||
153 | v |= m; | ||
154 | omap2_cm_write_mod_reg(v, PLL_MOD, CM_CLKEN); | ||
155 | |||
156 | omap2xxx_cm_wait_module_ready(PLL_MOD, 1, status_bit); | ||
157 | |||
158 | /* | ||
159 | * REVISIT: Should we return an error code if | ||
160 | * omap2xxx_cm_wait_module_ready() fails? | ||
161 | */ | ||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | /* Stop APLL */ | ||
166 | static void _omap2xxx_apll_disable(u8 enable_bit) | ||
167 | { | ||
168 | u32 v; | ||
169 | |||
170 | v = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKEN); | ||
171 | v &= ~(EN_APLL_LOCKED << enable_bit); | ||
172 | omap2_cm_write_mod_reg(v, PLL_MOD, CM_CLKEN); | ||
173 | } | ||
174 | |||
175 | /* Enable an APLL if off */ | ||
176 | int omap2xxx_cm_apll54_enable(void) | ||
177 | { | ||
178 | return _omap2xxx_apll_enable(OMAP24XX_EN_54M_PLL_SHIFT, | ||
179 | OMAP24XX_ST_54M_APLL_SHIFT); | ||
180 | } | ||
181 | |||
182 | /* Enable an APLL if off */ | ||
183 | int omap2xxx_cm_apll96_enable(void) | ||
184 | { | ||
185 | return _omap2xxx_apll_enable(OMAP24XX_EN_96M_PLL_SHIFT, | ||
186 | OMAP24XX_ST_96M_APLL_SHIFT); | ||
187 | } | ||
188 | |||
189 | /* Stop APLL */ | ||
190 | void omap2xxx_cm_apll54_disable(void) | ||
191 | { | ||
192 | _omap2xxx_apll_disable(OMAP24XX_EN_54M_PLL_SHIFT); | ||
193 | } | ||
194 | |||
195 | /* Stop APLL */ | ||
196 | void omap2xxx_cm_apll96_disable(void) | ||
197 | { | ||
198 | _omap2xxx_apll_disable(OMAP24XX_EN_96M_PLL_SHIFT); | ||
199 | } | ||
200 | |||
139 | /* | 201 | /* |
140 | * | 202 | * |
141 | */ | 203 | */ |
@@ -252,4 +314,3 @@ struct clkdm_ops omap2_clkdm_operations = { | |||
252 | .clkdm_clk_enable = omap2xxx_clkdm_clk_enable, | 314 | .clkdm_clk_enable = omap2xxx_clkdm_clk_enable, |
253 | .clkdm_clk_disable = omap2xxx_clkdm_clk_disable, | 315 | .clkdm_clk_disable = omap2xxx_clkdm_clk_disable, |
254 | }; | 316 | }; |
255 | |||
diff --git a/arch/arm/mach-omap2/cm2xxx_3xxx.h b/arch/arm/mach-omap2/cm2xxx_3xxx.h index 0e26bb1bf7e2..f74a5d1b803f 100644 --- a/arch/arm/mach-omap2/cm2xxx_3xxx.h +++ b/arch/arm/mach-omap2/cm2xxx_3xxx.h | |||
@@ -96,6 +96,11 @@ static inline u32 omap2_cm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx) | |||
96 | return omap2_cm_rmw_mod_reg_bits(bits, 0x0, module, idx); | 96 | return omap2_cm_rmw_mod_reg_bits(bits, 0x0, module, idx); |
97 | } | 97 | } |
98 | 98 | ||
99 | extern int omap2xxx_cm_apll54_enable(void); | ||
100 | extern void omap2xxx_cm_apll54_disable(void); | ||
101 | extern int omap2xxx_cm_apll96_enable(void); | ||
102 | extern void omap2xxx_cm_apll96_disable(void); | ||
103 | |||
99 | #endif | 104 | #endif |
100 | 105 | ||
101 | /* CM register bits shared between 24XX and 3430 */ | 106 | /* CM register bits shared between 24XX and 3430 */ |
@@ -111,5 +116,4 @@ static inline u32 omap2_cm_clear_mod_reg_bits(u32 bits, s16 module, s16 idx) | |||
111 | /* CM_IDLEST_GFX */ | 116 | /* CM_IDLEST_GFX */ |
112 | #define OMAP_ST_GFX_MASK (1 << 0) | 117 | #define OMAP_ST_GFX_MASK (1 << 0) |
113 | 118 | ||
114 | |||
115 | #endif | 119 | #endif |