diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2009-02-19 08:29:22 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-02-19 12:28:30 -0500 |
commit | c0bf31320dea2cbcbab1f53ee15a8520f762409b (patch) | |
tree | 1b4fbb4396da448eb116f2bee8b58030b63cfe3b | |
parent | 8b9dbc16d4f5786c6c930ab028722e3ed7e4285b (diff) |
[ARM] omap: add support for bypassing DPLLs
This roughly corresponds with OMAP commits: 7d06c48, 3241b19,
88b5d9b, 18a5500, 9c909ac, 5c6497b, 8b1f0bd, 2ac1da8.
For both OMAP2 and OMAP3, we note the reference and bypass clocks in
the DPLL data structure. Whenever we modify the DPLL rate, we first
ensure that both the reference and bypass clocks are enabled. Then,
we decide whether to use the reference and DPLL, or the bypass clock
if the desired rate is identical to the bypass rate, and program the
DPLL appropriately. Finally, we update the clock's parent, and then
disable the unused clocks.
This keeps the parents correctly balanced, and more importantly ensures
that the bypass clock is running whenever we reprogram the DPLL. This
is especially important because the procedure for reprogramming the DPLL
involves switching to the bypass clock.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | arch/arm/mach-omap2/clock.c | 47 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock.h | 15 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock24xx.c | 39 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock24xx.h | 4 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock34xx.c | 90 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock34xx.h | 177 | ||||
-rw-r--r-- | arch/arm/mach-omap2/sdrc2xxx.c | 2 | ||||
-rw-r--r-- | arch/arm/plat-omap/include/mach/clock.h | 11 |
8 files changed, 186 insertions, 199 deletions
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c index 5020cb1f2e7e..40cb65ba1fac 100644 --- a/arch/arm/mach-omap2/clock.c +++ b/arch/arm/mach-omap2/clock.c | |||
@@ -211,25 +211,52 @@ void omap2_init_clksel_parent(struct clk *clk) | |||
211 | return; | 211 | return; |
212 | } | 212 | } |
213 | 213 | ||
214 | /* Returns the DPLL rate */ | 214 | /** |
215 | * omap2_get_dpll_rate - returns the current DPLL CLKOUT rate | ||
216 | * @clk: struct clk * of a DPLL | ||
217 | * | ||
218 | * DPLLs can be locked or bypassed - basically, enabled or disabled. | ||
219 | * When locked, the DPLL output depends on the M and N values. When | ||
220 | * bypassed, on OMAP2xxx, the output rate is either the 32KiHz clock | ||
221 | * or sys_clk. Bypass rates on OMAP3 depend on the DPLL: DPLLs 1 and | ||
222 | * 2 are bypassed with dpll1_fclk and dpll2_fclk respectively | ||
223 | * (generated by DPLL3), while DPLL 3, 4, and 5 bypass rates are sys_clk. | ||
224 | * Returns the current DPLL CLKOUT rate (*not* CLKOUTX2) if the DPLL is | ||
225 | * locked, or the appropriate bypass rate if the DPLL is bypassed, or 0 | ||
226 | * if the clock @clk is not a DPLL. | ||
227 | */ | ||
215 | u32 omap2_get_dpll_rate(struct clk *clk) | 228 | u32 omap2_get_dpll_rate(struct clk *clk) |
216 | { | 229 | { |
217 | long long dpll_clk; | 230 | long long dpll_clk; |
218 | u32 dpll_mult, dpll_div, dpll; | 231 | u32 dpll_mult, dpll_div, v; |
219 | struct dpll_data *dd; | 232 | struct dpll_data *dd; |
220 | 233 | ||
221 | dd = clk->dpll_data; | 234 | dd = clk->dpll_data; |
222 | /* REVISIT: What do we return on error? */ | ||
223 | if (!dd) | 235 | if (!dd) |
224 | return 0; | 236 | return 0; |
225 | 237 | ||
226 | dpll = __raw_readl(dd->mult_div1_reg); | 238 | /* Return bypass rate if DPLL is bypassed */ |
227 | dpll_mult = dpll & dd->mult_mask; | 239 | v = __raw_readl(dd->control_reg); |
240 | v &= dd->enable_mask; | ||
241 | v >>= __ffs(dd->enable_mask); | ||
242 | |||
243 | if (cpu_is_omap24xx()) { | ||
244 | if (v == OMAP2XXX_EN_DPLL_LPBYPASS || | ||
245 | v == OMAP2XXX_EN_DPLL_FRBYPASS) | ||
246 | return dd->clk_bypass->rate; | ||
247 | } else if (cpu_is_omap34xx()) { | ||
248 | if (v == OMAP3XXX_EN_DPLL_LPBYPASS || | ||
249 | v == OMAP3XXX_EN_DPLL_FRBYPASS) | ||
250 | return dd->clk_bypass->rate; | ||
251 | } | ||
252 | |||
253 | v = __raw_readl(dd->mult_div1_reg); | ||
254 | dpll_mult = v & dd->mult_mask; | ||
228 | dpll_mult >>= __ffs(dd->mult_mask); | 255 | dpll_mult >>= __ffs(dd->mult_mask); |
229 | dpll_div = dpll & dd->div1_mask; | 256 | dpll_div = v & dd->div1_mask; |
230 | dpll_div >>= __ffs(dd->div1_mask); | 257 | dpll_div >>= __ffs(dd->div1_mask); |
231 | 258 | ||
232 | dpll_clk = (long long)clk->parent->rate * dpll_mult; | 259 | dpll_clk = (long long)dd->clk_ref->rate * dpll_mult; |
233 | do_div(dpll_clk, dpll_div + 1); | 260 | do_div(dpll_clk, dpll_div + 1); |
234 | 261 | ||
235 | return dpll_clk; | 262 | return dpll_clk; |
@@ -930,7 +957,7 @@ long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate) | |||
930 | pr_debug("clock: starting DPLL round_rate for clock %s, target rate " | 957 | pr_debug("clock: starting DPLL round_rate for clock %s, target rate " |
931 | "%ld\n", clk->name, target_rate); | 958 | "%ld\n", clk->name, target_rate); |
932 | 959 | ||
933 | scaled_rt_rp = target_rate / (clk->parent->rate / DPLL_SCALE_FACTOR); | 960 | scaled_rt_rp = target_rate / (dd->clk_ref->rate / DPLL_SCALE_FACTOR); |
934 | scaled_max_m = dd->max_multiplier * DPLL_SCALE_FACTOR; | 961 | scaled_max_m = dd->max_multiplier * DPLL_SCALE_FACTOR; |
935 | 962 | ||
936 | dd->last_rounded_rate = 0; | 963 | dd->last_rounded_rate = 0; |
@@ -957,7 +984,7 @@ long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate) | |||
957 | break; | 984 | break; |
958 | 985 | ||
959 | r = _dpll_test_mult(&m, n, &new_rate, target_rate, | 986 | r = _dpll_test_mult(&m, n, &new_rate, target_rate, |
960 | clk->parent->rate); | 987 | dd->clk_ref->rate); |
961 | 988 | ||
962 | /* m can't be set low enough for this n - try with a larger n */ | 989 | /* m can't be set low enough for this n - try with a larger n */ |
963 | if (r == DPLL_MULT_UNDERFLOW) | 990 | if (r == DPLL_MULT_UNDERFLOW) |
@@ -988,7 +1015,7 @@ long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate) | |||
988 | 1015 | ||
989 | dd->last_rounded_m = min_e_m; | 1016 | dd->last_rounded_m = min_e_m; |
990 | dd->last_rounded_n = min_e_n; | 1017 | dd->last_rounded_n = min_e_n; |
991 | dd->last_rounded_rate = _dpll_compute_new_rate(clk->parent->rate, | 1018 | dd->last_rounded_rate = _dpll_compute_new_rate(dd->clk_ref->rate, |
992 | min_e_m, min_e_n); | 1019 | min_e_m, min_e_n); |
993 | 1020 | ||
994 | pr_debug("clock: final least error: e = %d, m = %d, n = %d\n", | 1021 | pr_debug("clock: final least error: e = %d, m = %d, n = %d\n", |
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h index ca6bf226859e..2679ddfa6424 100644 --- a/arch/arm/mach-omap2/clock.h +++ b/arch/arm/mach-omap2/clock.h | |||
@@ -21,6 +21,21 @@ | |||
21 | /* The maximum error between a target DPLL rate and the rounded rate in Hz */ | 21 | /* The maximum error between a target DPLL rate and the rounded rate in Hz */ |
22 | #define DEFAULT_DPLL_RATE_TOLERANCE 50000 | 22 | #define DEFAULT_DPLL_RATE_TOLERANCE 50000 |
23 | 23 | ||
24 | /* CM_CLKSEL2_PLL.CORE_CLK_SRC bits (2XXX) */ | ||
25 | #define CORE_CLK_SRC_32K 0x0 | ||
26 | #define CORE_CLK_SRC_DPLL 0x1 | ||
27 | #define CORE_CLK_SRC_DPLL_X2 0x2 | ||
28 | |||
29 | /* OMAP2xxx CM_CLKEN_PLL.EN_DPLL bits - for omap2_get_dpll_rate() */ | ||
30 | #define OMAP2XXX_EN_DPLL_LPBYPASS 0x1 | ||
31 | #define OMAP2XXX_EN_DPLL_FRBYPASS 0x2 | ||
32 | #define OMAP2XXX_EN_DPLL_LOCKED 0x3 | ||
33 | |||
34 | /* OMAP3xxx CM_CLKEN_PLL*.EN_*_DPLL bits - for omap2_get_dpll_rate() */ | ||
35 | #define OMAP3XXX_EN_DPLL_LPBYPASS 0x5 | ||
36 | #define OMAP3XXX_EN_DPLL_FRBYPASS 0x6 | ||
37 | #define OMAP3XXX_EN_DPLL_LOCKED 0x7 | ||
38 | |||
24 | int omap2_clk_init(void); | 39 | int omap2_clk_init(void); |
25 | int omap2_clk_enable(struct clk *clk); | 40 | int omap2_clk_enable(struct clk *clk); |
26 | void omap2_clk_disable(struct clk *clk); | 41 | void omap2_clk_disable(struct clk *clk); |
diff --git a/arch/arm/mach-omap2/clock24xx.c b/arch/arm/mach-omap2/clock24xx.c index f2b74e9b7d8d..1e839c5a28c5 100644 --- a/arch/arm/mach-omap2/clock24xx.c +++ b/arch/arm/mach-omap2/clock24xx.c | |||
@@ -236,19 +236,32 @@ static struct clk *sclk; | |||
236 | * Omap24xx specific clock functions | 236 | * Omap24xx specific clock functions |
237 | *-------------------------------------------------------------------------*/ | 237 | *-------------------------------------------------------------------------*/ |
238 | 238 | ||
239 | /* This actually returns the rate of core_ck, not dpll_ck. */ | 239 | /** |
240 | static u32 omap2_get_dpll_rate_24xx(struct clk *tclk) | 240 | * omap2xxx_clk_get_core_rate - return the CORE_CLK rate |
241 | * @clk: pointer to the combined dpll_ck + core_ck (currently "dpll_ck") | ||
242 | * | ||
243 | * Returns the CORE_CLK rate. CORE_CLK can have one of three rate | ||
244 | * sources on OMAP2xxx: the DPLL CLKOUT rate, DPLL CLKOUTX2, or 32KHz | ||
245 | * (the latter is unusual). This currently should be called with | ||
246 | * struct clk *dpll_ck, which is a composite clock of dpll_ck and | ||
247 | * core_ck. | ||
248 | */ | ||
249 | static unsigned long omap2xxx_clk_get_core_rate(struct clk *clk) | ||
241 | { | 250 | { |
242 | long long dpll_clk; | 251 | long long core_clk; |
243 | u8 amult; | 252 | u32 v; |
244 | 253 | ||
245 | dpll_clk = omap2_get_dpll_rate(tclk); | 254 | core_clk = omap2_get_dpll_rate(clk); |
246 | 255 | ||
247 | amult = cm_read_mod_reg(PLL_MOD, CM_CLKSEL2); | 256 | v = cm_read_mod_reg(PLL_MOD, CM_CLKSEL2); |
248 | amult &= OMAP24XX_CORE_CLK_SRC_MASK; | 257 | v &= OMAP24XX_CORE_CLK_SRC_MASK; |
249 | dpll_clk *= amult; | 258 | |
259 | if (v == CORE_CLK_SRC_32K) | ||
260 | core_clk = 32768; | ||
261 | else | ||
262 | core_clk *= v; | ||
250 | 263 | ||
251 | return dpll_clk; | 264 | return core_clk; |
252 | } | 265 | } |
253 | 266 | ||
254 | static int omap2_enable_osc_ck(struct clk *clk) | 267 | static int omap2_enable_osc_ck(struct clk *clk) |
@@ -371,7 +384,7 @@ static long omap2_dpllcore_round_rate(unsigned long target_rate) | |||
371 | 384 | ||
372 | static unsigned long omap2_dpllcore_recalc(struct clk *clk) | 385 | static unsigned long omap2_dpllcore_recalc(struct clk *clk) |
373 | { | 386 | { |
374 | return omap2_get_dpll_rate_24xx(clk); | 387 | return omap2xxx_clk_get_core_rate(clk); |
375 | } | 388 | } |
376 | 389 | ||
377 | static int omap2_reprogram_dpllcore(struct clk *clk, unsigned long rate) | 390 | static int omap2_reprogram_dpllcore(struct clk *clk, unsigned long rate) |
@@ -381,7 +394,7 @@ static int omap2_reprogram_dpllcore(struct clk *clk, unsigned long rate) | |||
381 | struct prcm_config tmpset; | 394 | struct prcm_config tmpset; |
382 | const struct dpll_data *dd; | 395 | const struct dpll_data *dd; |
383 | 396 | ||
384 | cur_rate = omap2_get_dpll_rate_24xx(&dpll_ck); | 397 | cur_rate = omap2xxx_clk_get_core_rate(&dpll_ck); |
385 | mult = cm_read_mod_reg(PLL_MOD, CM_CLKSEL2); | 398 | mult = cm_read_mod_reg(PLL_MOD, CM_CLKSEL2); |
386 | mult &= OMAP24XX_CORE_CLK_SRC_MASK; | 399 | mult &= OMAP24XX_CORE_CLK_SRC_MASK; |
387 | 400 | ||
@@ -516,7 +529,7 @@ static int omap2_select_table_rate(struct clk *clk, unsigned long rate) | |||
516 | } | 529 | } |
517 | 530 | ||
518 | curr_prcm_set = prcm; | 531 | curr_prcm_set = prcm; |
519 | cur_rate = omap2_get_dpll_rate_24xx(&dpll_ck); | 532 | cur_rate = omap2xxx_clk_get_core_rate(&dpll_ck); |
520 | 533 | ||
521 | if (prcm->dpll_speed == cur_rate / 2) { | 534 | if (prcm->dpll_speed == cur_rate / 2) { |
522 | omap2xxx_sdrc_reprogram(CORE_CLK_SRC_DPLL, 1); | 535 | omap2xxx_sdrc_reprogram(CORE_CLK_SRC_DPLL, 1); |
@@ -728,7 +741,7 @@ int __init omap2_clk_init(void) | |||
728 | } | 741 | } |
729 | 742 | ||
730 | /* Check the MPU rate set by bootloader */ | 743 | /* Check the MPU rate set by bootloader */ |
731 | clkrate = omap2_get_dpll_rate_24xx(&dpll_ck); | 744 | clkrate = omap2xxx_clk_get_core_rate(&dpll_ck); |
732 | for (prcm = rate_table; prcm->mpu_speed; prcm++) { | 745 | for (prcm = rate_table; prcm->mpu_speed; prcm++) { |
733 | if (!(prcm->flags & cpu_mask)) | 746 | if (!(prcm->flags & cpu_mask)) |
734 | continue; | 747 | continue; |
diff --git a/arch/arm/mach-omap2/clock24xx.h b/arch/arm/mach-omap2/clock24xx.h index 11da6215392b..33c3e5b14323 100644 --- a/arch/arm/mach-omap2/clock24xx.h +++ b/arch/arm/mach-omap2/clock24xx.h | |||
@@ -663,6 +663,10 @@ static struct dpll_data dpll_dd = { | |||
663 | .mult_div1_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKSEL1), | 663 | .mult_div1_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKSEL1), |
664 | .mult_mask = OMAP24XX_DPLL_MULT_MASK, | 664 | .mult_mask = OMAP24XX_DPLL_MULT_MASK, |
665 | .div1_mask = OMAP24XX_DPLL_DIV_MASK, | 665 | .div1_mask = OMAP24XX_DPLL_DIV_MASK, |
666 | .clk_bypass = &sys_ck, | ||
667 | .clk_ref = &sys_ck, | ||
668 | .control_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKEN), | ||
669 | .enable_mask = OMAP24XX_EN_DPLL_MASK, | ||
666 | .max_multiplier = 1024, | 670 | .max_multiplier = 1024, |
667 | .min_divider = 1, | 671 | .min_divider = 1, |
668 | .max_divider = 16, | 672 | .max_divider = 16, |
diff --git a/arch/arm/mach-omap2/clock34xx.c b/arch/arm/mach-omap2/clock34xx.c index fb0f53b96811..0a14dca31e30 100644 --- a/arch/arm/mach-omap2/clock34xx.c +++ b/arch/arm/mach-omap2/clock34xx.c | |||
@@ -93,7 +93,6 @@ static struct omap_clk omap34xx_clks[] = { | |||
93 | CLK(NULL, "omap_96m_alwon_fck", &omap_96m_alwon_fck, CK_343X), | 93 | CLK(NULL, "omap_96m_alwon_fck", &omap_96m_alwon_fck, CK_343X), |
94 | CLK(NULL, "omap_96m_fck", &omap_96m_fck, CK_343X), | 94 | CLK(NULL, "omap_96m_fck", &omap_96m_fck, CK_343X), |
95 | CLK(NULL, "cm_96m_fck", &cm_96m_fck, CK_343X), | 95 | CLK(NULL, "cm_96m_fck", &cm_96m_fck, CK_343X), |
96 | CLK(NULL, "virt_omap_54m_fck", &virt_omap_54m_fck, CK_343X), | ||
97 | CLK(NULL, "omap_54m_fck", &omap_54m_fck, CK_343X), | 96 | CLK(NULL, "omap_54m_fck", &omap_54m_fck, CK_343X), |
98 | CLK(NULL, "omap_48m_fck", &omap_48m_fck, CK_343X), | 97 | CLK(NULL, "omap_48m_fck", &omap_48m_fck, CK_343X), |
99 | CLK(NULL, "omap_12m_fck", &omap_12m_fck, CK_343X), | 98 | CLK(NULL, "omap_12m_fck", &omap_12m_fck, CK_343X), |
@@ -110,7 +109,6 @@ static struct omap_clk omap34xx_clks[] = { | |||
110 | CLK(NULL, "emu_per_alwon_ck", &emu_per_alwon_ck, CK_343X), | 109 | CLK(NULL, "emu_per_alwon_ck", &emu_per_alwon_ck, CK_343X), |
111 | CLK(NULL, "dpll5_ck", &dpll5_ck, CK_3430ES2), | 110 | CLK(NULL, "dpll5_ck", &dpll5_ck, CK_3430ES2), |
112 | CLK(NULL, "dpll5_m2_ck", &dpll5_m2_ck, CK_3430ES2), | 111 | CLK(NULL, "dpll5_m2_ck", &dpll5_m2_ck, CK_3430ES2), |
113 | CLK(NULL, "omap_120m_fck", &omap_120m_fck, CK_3430ES2), | ||
114 | CLK(NULL, "clkout2_src_ck", &clkout2_src_ck, CK_343X), | 112 | CLK(NULL, "clkout2_src_ck", &clkout2_src_ck, CK_343X), |
115 | CLK(NULL, "sys_clkout2", &sys_clkout2, CK_343X), | 113 | CLK(NULL, "sys_clkout2", &sys_clkout2, CK_343X), |
116 | CLK(NULL, "corex2_fck", &corex2_fck, CK_343X), | 114 | CLK(NULL, "corex2_fck", &corex2_fck, CK_343X), |
@@ -344,7 +342,7 @@ static u16 _omap3_dpll_compute_freqsel(struct clk *clk, u8 n) | |||
344 | unsigned long fint; | 342 | unsigned long fint; |
345 | u16 f = 0; | 343 | u16 f = 0; |
346 | 344 | ||
347 | fint = clk->parent->rate / (n + 1); | 345 | fint = clk->dpll_data->clk_ref->rate / (n + 1); |
348 | 346 | ||
349 | pr_debug("clock: fint is %lu\n", fint); | 347 | pr_debug("clock: fint is %lu\n", fint); |
350 | 348 | ||
@@ -411,7 +409,7 @@ static int _omap3_noncore_dpll_lock(struct clk *clk) | |||
411 | } | 409 | } |
412 | 410 | ||
413 | /* | 411 | /* |
414 | * omap3_noncore_dpll_bypass - instruct a DPLL to bypass and wait for readiness | 412 | * _omap3_noncore_dpll_bypass - instruct a DPLL to bypass and wait for readiness |
415 | * @clk: pointer to a DPLL struct clk | 413 | * @clk: pointer to a DPLL struct clk |
416 | * | 414 | * |
417 | * Instructs a non-CORE DPLL to enter low-power bypass mode. In | 415 | * Instructs a non-CORE DPLL to enter low-power bypass mode. In |
@@ -501,14 +499,25 @@ static int _omap3_noncore_dpll_stop(struct clk *clk) | |||
501 | static int omap3_noncore_dpll_enable(struct clk *clk) | 499 | static int omap3_noncore_dpll_enable(struct clk *clk) |
502 | { | 500 | { |
503 | int r; | 501 | int r; |
502 | struct dpll_data *dd; | ||
504 | 503 | ||
505 | if (clk == &dpll3_ck) | 504 | if (clk == &dpll3_ck) |
506 | return -EINVAL; | 505 | return -EINVAL; |
507 | 506 | ||
508 | if (clk->parent->rate == omap2_get_dpll_rate(clk)) | 507 | dd = clk->dpll_data; |
508 | if (!dd) | ||
509 | return -EINVAL; | ||
510 | |||
511 | if (clk->rate == dd->clk_bypass->rate) { | ||
512 | WARN_ON(clk->parent != dd->clk_bypass); | ||
509 | r = _omap3_noncore_dpll_bypass(clk); | 513 | r = _omap3_noncore_dpll_bypass(clk); |
510 | else | 514 | } else { |
515 | WARN_ON(clk->parent != dd->clk_ref); | ||
511 | r = _omap3_noncore_dpll_lock(clk); | 516 | r = _omap3_noncore_dpll_lock(clk); |
517 | } | ||
518 | /* FIXME: this is dubious - if clk->rate has changed, what about propagating? */ | ||
519 | if (!r) | ||
520 | clk->rate = omap2_get_dpll_rate(clk); | ||
512 | 521 | ||
513 | return r; | 522 | return r; |
514 | } | 523 | } |
@@ -583,13 +592,18 @@ static int omap3_noncore_dpll_program(struct clk *clk, u16 m, u8 n, u16 freqsel) | |||
583 | * @clk: struct clk * of DPLL to set | 592 | * @clk: struct clk * of DPLL to set |
584 | * @rate: rounded target rate | 593 | * @rate: rounded target rate |
585 | * | 594 | * |
586 | * Program the DPLL with the rounded target rate. Returns -EINVAL upon | 595 | * Set the DPLL CLKOUT to the target rate. If the DPLL can enter |
587 | * error, or 0 upon success. | 596 | * low-power bypass, and the target rate is the bypass source clock |
597 | * rate, then configure the DPLL for bypass. Otherwise, round the | ||
598 | * target rate if it hasn't been done already, then program and lock | ||
599 | * the DPLL. Returns -EINVAL upon error, or 0 upon success. | ||
588 | */ | 600 | */ |
589 | static int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate) | 601 | static int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate) |
590 | { | 602 | { |
603 | struct clk *new_parent = NULL; | ||
591 | u16 freqsel; | 604 | u16 freqsel; |
592 | struct dpll_data *dd; | 605 | struct dpll_data *dd; |
606 | int ret; | ||
593 | 607 | ||
594 | if (!clk || !rate) | 608 | if (!clk || !rate) |
595 | return -EINVAL; | 609 | return -EINVAL; |
@@ -601,18 +615,56 @@ static int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate) | |||
601 | if (rate == omap2_get_dpll_rate(clk)) | 615 | if (rate == omap2_get_dpll_rate(clk)) |
602 | return 0; | 616 | return 0; |
603 | 617 | ||
604 | if (dd->last_rounded_rate != rate) | 618 | /* |
605 | omap2_dpll_round_rate(clk, rate); | 619 | * Ensure both the bypass and ref clocks are enabled prior to |
620 | * doing anything; we need the bypass clock running to reprogram | ||
621 | * the DPLL. | ||
622 | */ | ||
623 | omap2_clk_enable(dd->clk_bypass); | ||
624 | omap2_clk_enable(dd->clk_ref); | ||
625 | |||
626 | if (dd->clk_bypass->rate == rate && | ||
627 | (clk->dpll_data->modes & (1 << DPLL_LOW_POWER_BYPASS))) { | ||
628 | pr_debug("clock: %s: set rate: entering bypass.\n", clk->name); | ||
606 | 629 | ||
607 | if (dd->last_rounded_rate == 0) | 630 | ret = _omap3_noncore_dpll_bypass(clk); |
608 | return -EINVAL; | 631 | if (!ret) |
632 | new_parent = dd->clk_bypass; | ||
633 | } else { | ||
634 | if (dd->last_rounded_rate != rate) | ||
635 | omap2_dpll_round_rate(clk, rate); | ||
636 | |||
637 | if (dd->last_rounded_rate == 0) | ||
638 | return -EINVAL; | ||
639 | |||
640 | freqsel = _omap3_dpll_compute_freqsel(clk, dd->last_rounded_n); | ||
641 | if (!freqsel) | ||
642 | WARN_ON(1); | ||
609 | 643 | ||
610 | freqsel = _omap3_dpll_compute_freqsel(clk, dd->last_rounded_n); | 644 | pr_debug("clock: %s: set rate: locking rate to %lu.\n", |
611 | if (!freqsel) | 645 | clk->name, rate); |
612 | WARN_ON(1); | ||
613 | 646 | ||
614 | omap3_noncore_dpll_program(clk, dd->last_rounded_m, dd->last_rounded_n, | 647 | ret = omap3_noncore_dpll_program(clk, dd->last_rounded_m, |
615 | freqsel); | 648 | dd->last_rounded_n, freqsel); |
649 | if (!ret) | ||
650 | new_parent = dd->clk_ref; | ||
651 | } | ||
652 | if (!ret) { | ||
653 | /* | ||
654 | * Switch the parent clock in the heirarchy, and make sure | ||
655 | * that the new parent's usecount is correct. Note: we | ||
656 | * enable the new parent before disabling the old to avoid | ||
657 | * any unnecessary hardware disable->enable transitions. | ||
658 | */ | ||
659 | if (clk->usecount) { | ||
660 | omap2_clk_enable(new_parent); | ||
661 | omap2_clk_disable(clk->parent); | ||
662 | } | ||
663 | clk_reparent(clk, new_parent); | ||
664 | clk->rate = rate; | ||
665 | } | ||
666 | omap2_clk_disable(dd->clk_ref); | ||
667 | omap2_clk_disable(dd->clk_bypass); | ||
616 | 668 | ||
617 | return 0; | 669 | return 0; |
618 | } | 670 | } |
@@ -804,11 +856,11 @@ static unsigned long omap3_clkoutx2_recalc(struct clk *clk) | |||
804 | 856 | ||
805 | dd = pclk->dpll_data; | 857 | dd = pclk->dpll_data; |
806 | 858 | ||
807 | WARN_ON(!dd->control_reg || !dd->enable_mask); | 859 | WARN_ON(!dd->enable_mask); |
808 | 860 | ||
809 | v = __raw_readl(dd->control_reg) & dd->enable_mask; | 861 | v = __raw_readl(dd->control_reg) & dd->enable_mask; |
810 | v >>= __ffs(dd->enable_mask); | 862 | v >>= __ffs(dd->enable_mask); |
811 | if (v != DPLL_LOCKED) | 863 | if (v != OMAP3XXX_EN_DPLL_LOCKED) |
812 | rate = clk->parent->rate; | 864 | rate = clk->parent->rate; |
813 | else | 865 | else |
814 | rate = clk->parent->rate * 2; | 866 | rate = clk->parent->rate * 2; |
diff --git a/arch/arm/mach-omap2/clock34xx.h b/arch/arm/mach-omap2/clock34xx.h index 764c7cd9fd84..70ec10deb654 100644 --- a/arch/arm/mach-omap2/clock34xx.h +++ b/arch/arm/mach-omap2/clock34xx.h | |||
@@ -48,6 +48,10 @@ static int omap3_core_dpll_m2_set_rate(struct clk *clk, unsigned long rate); | |||
48 | * DPLL5 supplies other peripheral clocks (USBHOST, USIM). | 48 | * DPLL5 supplies other peripheral clocks (USBHOST, USIM). |
49 | */ | 49 | */ |
50 | 50 | ||
51 | /* Forward declarations for DPLL bypass clocks */ | ||
52 | static struct clk dpll1_fck; | ||
53 | static struct clk dpll2_fck; | ||
54 | |||
51 | /* CM_CLKEN_PLL*.EN* bit values - not all are available for every DPLL */ | 55 | /* CM_CLKEN_PLL*.EN* bit values - not all are available for every DPLL */ |
52 | #define DPLL_LOW_POWER_STOP 0x1 | 56 | #define DPLL_LOW_POWER_STOP 0x1 |
53 | #define DPLL_LOW_POWER_BYPASS 0x5 | 57 | #define DPLL_LOW_POWER_BYPASS 0x5 |
@@ -217,16 +221,6 @@ static struct clk sys_clkout1 = { | |||
217 | 221 | ||
218 | /* CM CLOCKS */ | 222 | /* CM CLOCKS */ |
219 | 223 | ||
220 | static const struct clksel_rate dpll_bypass_rates[] = { | ||
221 | { .div = 1, .val = 0, .flags = RATE_IN_343X | DEFAULT_RATE }, | ||
222 | { .div = 0 } | ||
223 | }; | ||
224 | |||
225 | static const struct clksel_rate dpll_locked_rates[] = { | ||
226 | { .div = 1, .val = 1, .flags = RATE_IN_343X | DEFAULT_RATE }, | ||
227 | { .div = 0 } | ||
228 | }; | ||
229 | |||
230 | static const struct clksel_rate div16_dpll_rates[] = { | 224 | static const struct clksel_rate div16_dpll_rates[] = { |
231 | { .div = 1, .val = 1, .flags = RATE_IN_343X | DEFAULT_RATE }, | 225 | { .div = 1, .val = 1, .flags = RATE_IN_343X | DEFAULT_RATE }, |
232 | { .div = 2, .val = 2, .flags = RATE_IN_343X }, | 226 | { .div = 2, .val = 2, .flags = RATE_IN_343X }, |
@@ -254,6 +248,8 @@ static struct dpll_data dpll1_dd = { | |||
254 | .mult_div1_reg = OMAP_CM_REGADDR(MPU_MOD, OMAP3430_CM_CLKSEL1_PLL), | 248 | .mult_div1_reg = OMAP_CM_REGADDR(MPU_MOD, OMAP3430_CM_CLKSEL1_PLL), |
255 | .mult_mask = OMAP3430_MPU_DPLL_MULT_MASK, | 249 | .mult_mask = OMAP3430_MPU_DPLL_MULT_MASK, |
256 | .div1_mask = OMAP3430_MPU_DPLL_DIV_MASK, | 250 | .div1_mask = OMAP3430_MPU_DPLL_DIV_MASK, |
251 | .clk_bypass = &dpll1_fck, | ||
252 | .clk_ref = &sys_ck, | ||
257 | .freqsel_mask = OMAP3430_MPU_DPLL_FREQSEL_MASK, | 253 | .freqsel_mask = OMAP3430_MPU_DPLL_FREQSEL_MASK, |
258 | .control_reg = OMAP_CM_REGADDR(MPU_MOD, OMAP3430_CM_CLKEN_PLL), | 254 | .control_reg = OMAP_CM_REGADDR(MPU_MOD, OMAP3430_CM_CLKEN_PLL), |
259 | .enable_mask = OMAP3430_EN_MPU_DPLL_MASK, | 255 | .enable_mask = OMAP3430_EN_MPU_DPLL_MASK, |
@@ -324,6 +320,8 @@ static struct dpll_data dpll2_dd = { | |||
324 | .mult_div1_reg = OMAP_CM_REGADDR(OMAP3430_IVA2_MOD, OMAP3430_CM_CLKSEL1_PLL), | 320 | .mult_div1_reg = OMAP_CM_REGADDR(OMAP3430_IVA2_MOD, OMAP3430_CM_CLKSEL1_PLL), |
325 | .mult_mask = OMAP3430_IVA2_DPLL_MULT_MASK, | 321 | .mult_mask = OMAP3430_IVA2_DPLL_MULT_MASK, |
326 | .div1_mask = OMAP3430_IVA2_DPLL_DIV_MASK, | 322 | .div1_mask = OMAP3430_IVA2_DPLL_DIV_MASK, |
323 | .clk_bypass = &dpll2_fck, | ||
324 | .clk_ref = &sys_ck, | ||
327 | .freqsel_mask = OMAP3430_IVA2_DPLL_FREQSEL_MASK, | 325 | .freqsel_mask = OMAP3430_IVA2_DPLL_FREQSEL_MASK, |
328 | .control_reg = OMAP_CM_REGADDR(OMAP3430_IVA2_MOD, OMAP3430_CM_CLKEN_PLL), | 326 | .control_reg = OMAP_CM_REGADDR(OMAP3430_IVA2_MOD, OMAP3430_CM_CLKEN_PLL), |
329 | .enable_mask = OMAP3430_EN_IVA2_DPLL_MASK, | 327 | .enable_mask = OMAP3430_EN_IVA2_DPLL_MASK, |
@@ -384,6 +382,8 @@ static struct dpll_data dpll3_dd = { | |||
384 | .mult_div1_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKSEL1), | 382 | .mult_div1_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKSEL1), |
385 | .mult_mask = OMAP3430_CORE_DPLL_MULT_MASK, | 383 | .mult_mask = OMAP3430_CORE_DPLL_MULT_MASK, |
386 | .div1_mask = OMAP3430_CORE_DPLL_DIV_MASK, | 384 | .div1_mask = OMAP3430_CORE_DPLL_DIV_MASK, |
385 | .clk_bypass = &sys_ck, | ||
386 | .clk_ref = &sys_ck, | ||
387 | .freqsel_mask = OMAP3430_CORE_DPLL_FREQSEL_MASK, | 387 | .freqsel_mask = OMAP3430_CORE_DPLL_FREQSEL_MASK, |
388 | .control_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKEN), | 388 | .control_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKEN), |
389 | .enable_mask = OMAP3430_EN_CORE_DPLL_MASK, | 389 | .enable_mask = OMAP3430_EN_CORE_DPLL_MASK, |
@@ -477,37 +477,19 @@ static struct clk dpll3_m2_ck = { | |||
477 | .recalc = &omap2_clksel_recalc, | 477 | .recalc = &omap2_clksel_recalc, |
478 | }; | 478 | }; |
479 | 479 | ||
480 | static const struct clksel core_ck_clksel[] = { | ||
481 | { .parent = &sys_ck, .rates = dpll_bypass_rates }, | ||
482 | { .parent = &dpll3_m2_ck, .rates = dpll_locked_rates }, | ||
483 | { .parent = NULL } | ||
484 | }; | ||
485 | |||
486 | static struct clk core_ck = { | 480 | static struct clk core_ck = { |
487 | .name = "core_ck", | 481 | .name = "core_ck", |
488 | .ops = &clkops_null, | 482 | .ops = &clkops_null, |
489 | .init = &omap2_init_clksel_parent, | 483 | .parent = &dpll3_m2_ck, |
490 | .clksel_reg = OMAP_CM_REGADDR(PLL_MOD, CM_IDLEST), | 484 | .recalc = &followparent_recalc, |
491 | .clksel_mask = OMAP3430_ST_CORE_CLK_MASK, | ||
492 | .clksel = core_ck_clksel, | ||
493 | .recalc = &omap2_clksel_recalc, | ||
494 | }; | ||
495 | |||
496 | static const struct clksel dpll3_m2x2_ck_clksel[] = { | ||
497 | { .parent = &sys_ck, .rates = dpll_bypass_rates }, | ||
498 | { .parent = &dpll3_x2_ck, .rates = dpll_locked_rates }, | ||
499 | { .parent = NULL } | ||
500 | }; | 485 | }; |
501 | 486 | ||
502 | static struct clk dpll3_m2x2_ck = { | 487 | static struct clk dpll3_m2x2_ck = { |
503 | .name = "dpll3_m2x2_ck", | 488 | .name = "dpll3_m2x2_ck", |
504 | .ops = &clkops_null, | 489 | .ops = &clkops_null, |
505 | .init = &omap2_init_clksel_parent, | 490 | .parent = &dpll3_x2_ck, |
506 | .clksel_reg = OMAP_CM_REGADDR(PLL_MOD, CM_IDLEST), | ||
507 | .clksel_mask = OMAP3430_ST_CORE_CLK_MASK, | ||
508 | .clksel = dpll3_m2x2_ck_clksel, | ||
509 | .clkdm_name = "dpll3_clkdm", | 491 | .clkdm_name = "dpll3_clkdm", |
510 | .recalc = &omap2_clksel_recalc, | 492 | .recalc = &followparent_recalc, |
511 | }; | 493 | }; |
512 | 494 | ||
513 | /* The PWRDN bit is apparently only available on 3430ES2 and above */ | 495 | /* The PWRDN bit is apparently only available on 3430ES2 and above */ |
@@ -541,22 +523,12 @@ static struct clk dpll3_m3x2_ck = { | |||
541 | .recalc = &omap3_clkoutx2_recalc, | 523 | .recalc = &omap3_clkoutx2_recalc, |
542 | }; | 524 | }; |
543 | 525 | ||
544 | static const struct clksel emu_core_alwon_ck_clksel[] = { | ||
545 | { .parent = &sys_ck, .rates = dpll_bypass_rates }, | ||
546 | { .parent = &dpll3_m3x2_ck, .rates = dpll_locked_rates }, | ||
547 | { .parent = NULL } | ||
548 | }; | ||
549 | |||
550 | static struct clk emu_core_alwon_ck = { | 526 | static struct clk emu_core_alwon_ck = { |
551 | .name = "emu_core_alwon_ck", | 527 | .name = "emu_core_alwon_ck", |
552 | .ops = &clkops_null, | 528 | .ops = &clkops_null, |
553 | .parent = &dpll3_m3x2_ck, | 529 | .parent = &dpll3_m3x2_ck, |
554 | .init = &omap2_init_clksel_parent, | ||
555 | .clksel_reg = OMAP_CM_REGADDR(PLL_MOD, CM_IDLEST), | ||
556 | .clksel_mask = OMAP3430_ST_CORE_CLK_MASK, | ||
557 | .clksel = emu_core_alwon_ck_clksel, | ||
558 | .clkdm_name = "dpll3_clkdm", | 530 | .clkdm_name = "dpll3_clkdm", |
559 | .recalc = &omap2_clksel_recalc, | 531 | .recalc = &followparent_recalc, |
560 | }; | 532 | }; |
561 | 533 | ||
562 | /* DPLL4 */ | 534 | /* DPLL4 */ |
@@ -566,6 +538,8 @@ static struct dpll_data dpll4_dd = { | |||
566 | .mult_div1_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKSEL2), | 538 | .mult_div1_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKSEL2), |
567 | .mult_mask = OMAP3430_PERIPH_DPLL_MULT_MASK, | 539 | .mult_mask = OMAP3430_PERIPH_DPLL_MULT_MASK, |
568 | .div1_mask = OMAP3430_PERIPH_DPLL_DIV_MASK, | 540 | .div1_mask = OMAP3430_PERIPH_DPLL_DIV_MASK, |
541 | .clk_bypass = &sys_ck, | ||
542 | .clk_ref = &sys_ck, | ||
569 | .freqsel_mask = OMAP3430_PERIPH_DPLL_FREQSEL_MASK, | 543 | .freqsel_mask = OMAP3430_PERIPH_DPLL_FREQSEL_MASK, |
570 | .control_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKEN), | 544 | .control_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKEN), |
571 | .enable_mask = OMAP3430_EN_PERIPH_DPLL_MASK, | 545 | .enable_mask = OMAP3430_EN_PERIPH_DPLL_MASK, |
@@ -637,12 +611,6 @@ static struct clk dpll4_m2x2_ck = { | |||
637 | .recalc = &omap3_clkoutx2_recalc, | 611 | .recalc = &omap3_clkoutx2_recalc, |
638 | }; | 612 | }; |
639 | 613 | ||
640 | static const struct clksel omap_96m_alwon_fck_clksel[] = { | ||
641 | { .parent = &sys_ck, .rates = dpll_bypass_rates }, | ||
642 | { .parent = &dpll4_m2x2_ck, .rates = dpll_locked_rates }, | ||
643 | { .parent = NULL } | ||
644 | }; | ||
645 | |||
646 | /* | 614 | /* |
647 | * DPLL4 generates DPLL4_M2X2_CLK which is then routed into the PRM as | 615 | * DPLL4 generates DPLL4_M2X2_CLK which is then routed into the PRM as |
648 | * PRM_96M_ALWON_(F)CLK. Two clocks then emerge from the PRM: | 616 | * PRM_96M_ALWON_(F)CLK. Two clocks then emerge from the PRM: |
@@ -653,11 +621,7 @@ static struct clk omap_96m_alwon_fck = { | |||
653 | .name = "omap_96m_alwon_fck", | 621 | .name = "omap_96m_alwon_fck", |
654 | .ops = &clkops_null, | 622 | .ops = &clkops_null, |
655 | .parent = &dpll4_m2x2_ck, | 623 | .parent = &dpll4_m2x2_ck, |
656 | .init = &omap2_init_clksel_parent, | 624 | .recalc = &followparent_recalc, |
657 | .clksel_reg = OMAP_CM_REGADDR(PLL_MOD, CM_IDLEST), | ||
658 | .clksel_mask = OMAP3430_ST_PERIPH_CLK_MASK, | ||
659 | .clksel = omap_96m_alwon_fck_clksel, | ||
660 | .recalc = &omap2_clksel_recalc, | ||
661 | }; | 625 | }; |
662 | 626 | ||
663 | static struct clk cm_96m_fck = { | 627 | static struct clk cm_96m_fck = { |
@@ -720,23 +684,6 @@ static struct clk dpll4_m3x2_ck = { | |||
720 | .recalc = &omap3_clkoutx2_recalc, | 684 | .recalc = &omap3_clkoutx2_recalc, |
721 | }; | 685 | }; |
722 | 686 | ||
723 | static const struct clksel virt_omap_54m_fck_clksel[] = { | ||
724 | { .parent = &sys_ck, .rates = dpll_bypass_rates }, | ||
725 | { .parent = &dpll4_m3x2_ck, .rates = dpll_locked_rates }, | ||
726 | { .parent = NULL } | ||
727 | }; | ||
728 | |||
729 | static struct clk virt_omap_54m_fck = { | ||
730 | .name = "virt_omap_54m_fck", | ||
731 | .ops = &clkops_null, | ||
732 | .parent = &dpll4_m3x2_ck, | ||
733 | .init = &omap2_init_clksel_parent, | ||
734 | .clksel_reg = OMAP_CM_REGADDR(PLL_MOD, CM_IDLEST), | ||
735 | .clksel_mask = OMAP3430_ST_PERIPH_CLK_MASK, | ||
736 | .clksel = virt_omap_54m_fck_clksel, | ||
737 | .recalc = &omap2_clksel_recalc, | ||
738 | }; | ||
739 | |||
740 | static const struct clksel_rate omap_54m_d4m3x2_rates[] = { | 687 | static const struct clksel_rate omap_54m_d4m3x2_rates[] = { |
741 | { .div = 1, .val = 0, .flags = RATE_IN_343X | DEFAULT_RATE }, | 688 | { .div = 1, .val = 0, .flags = RATE_IN_343X | DEFAULT_RATE }, |
742 | { .div = 0 } | 689 | { .div = 0 } |
@@ -748,7 +695,7 @@ static const struct clksel_rate omap_54m_alt_rates[] = { | |||
748 | }; | 695 | }; |
749 | 696 | ||
750 | static const struct clksel omap_54m_clksel[] = { | 697 | static const struct clksel omap_54m_clksel[] = { |
751 | { .parent = &virt_omap_54m_fck, .rates = omap_54m_d4m3x2_rates }, | 698 | { .parent = &dpll4_m3x2_ck, .rates = omap_54m_d4m3x2_rates }, |
752 | { .parent = &sys_altclk, .rates = omap_54m_alt_rates }, | 699 | { .parent = &sys_altclk, .rates = omap_54m_alt_rates }, |
753 | { .parent = NULL } | 700 | { .parent = NULL } |
754 | }; | 701 | }; |
@@ -891,6 +838,8 @@ static struct dpll_data dpll5_dd = { | |||
891 | .mult_div1_reg = OMAP_CM_REGADDR(PLL_MOD, OMAP3430ES2_CM_CLKSEL4), | 838 | .mult_div1_reg = OMAP_CM_REGADDR(PLL_MOD, OMAP3430ES2_CM_CLKSEL4), |
892 | .mult_mask = OMAP3430ES2_PERIPH2_DPLL_MULT_MASK, | 839 | .mult_mask = OMAP3430ES2_PERIPH2_DPLL_MULT_MASK, |
893 | .div1_mask = OMAP3430ES2_PERIPH2_DPLL_DIV_MASK, | 840 | .div1_mask = OMAP3430ES2_PERIPH2_DPLL_DIV_MASK, |
841 | .clk_bypass = &sys_ck, | ||
842 | .clk_ref = &sys_ck, | ||
894 | .freqsel_mask = OMAP3430ES2_PERIPH2_DPLL_FREQSEL_MASK, | 843 | .freqsel_mask = OMAP3430ES2_PERIPH2_DPLL_FREQSEL_MASK, |
895 | .control_reg = OMAP_CM_REGADDR(PLL_MOD, OMAP3430ES2_CM_CLKEN2), | 844 | .control_reg = OMAP_CM_REGADDR(PLL_MOD, OMAP3430ES2_CM_CLKEN2), |
896 | .enable_mask = OMAP3430ES2_EN_PERIPH2_DPLL_MASK, | 845 | .enable_mask = OMAP3430ES2_EN_PERIPH2_DPLL_MASK, |
@@ -936,23 +885,6 @@ static struct clk dpll5_m2_ck = { | |||
936 | .recalc = &omap2_clksel_recalc, | 885 | .recalc = &omap2_clksel_recalc, |
937 | }; | 886 | }; |
938 | 887 | ||
939 | static const struct clksel omap_120m_fck_clksel[] = { | ||
940 | { .parent = &sys_ck, .rates = dpll_bypass_rates }, | ||
941 | { .parent = &dpll5_m2_ck, .rates = dpll_locked_rates }, | ||
942 | { .parent = NULL } | ||
943 | }; | ||
944 | |||
945 | static struct clk omap_120m_fck = { | ||
946 | .name = "omap_120m_fck", | ||
947 | .ops = &clkops_null, | ||
948 | .parent = &dpll5_m2_ck, | ||
949 | .init = &omap2_init_clksel_parent, | ||
950 | .clksel_reg = OMAP_CM_REGADDR(PLL_MOD, CM_IDLEST2), | ||
951 | .clksel_mask = OMAP3430ES2_ST_PERIPH2_CLK_MASK, | ||
952 | .clksel = omap_120m_fck_clksel, | ||
953 | .recalc = &omap2_clksel_recalc, | ||
954 | }; | ||
955 | |||
956 | /* CM EXTERNAL CLOCK OUTPUTS */ | 888 | /* CM EXTERNAL CLOCK OUTPUTS */ |
957 | 889 | ||
958 | static const struct clksel_rate clkout2_src_core_rates[] = { | 890 | static const struct clksel_rate clkout2_src_core_rates[] = { |
@@ -1058,28 +990,12 @@ static struct clk dpll1_fck = { | |||
1058 | .recalc = &omap2_clksel_recalc, | 990 | .recalc = &omap2_clksel_recalc, |
1059 | }; | 991 | }; |
1060 | 992 | ||
1061 | /* | ||
1062 | * MPU clksel: | ||
1063 | * If DPLL1 is locked, mpu_ck derives from DPLL1; otherwise, mpu_ck | ||
1064 | * derives from the high-frequency bypass clock originating from DPLL3, | ||
1065 | * called 'dpll1_fck' | ||
1066 | */ | ||
1067 | static const struct clksel mpu_clksel[] = { | ||
1068 | { .parent = &dpll1_fck, .rates = dpll_bypass_rates }, | ||
1069 | { .parent = &dpll1_x2m2_ck, .rates = dpll_locked_rates }, | ||
1070 | { .parent = NULL } | ||
1071 | }; | ||
1072 | |||
1073 | static struct clk mpu_ck = { | 993 | static struct clk mpu_ck = { |
1074 | .name = "mpu_ck", | 994 | .name = "mpu_ck", |
1075 | .ops = &clkops_null, | 995 | .ops = &clkops_null, |
1076 | .parent = &dpll1_x2m2_ck, | 996 | .parent = &dpll1_x2m2_ck, |
1077 | .init = &omap2_init_clksel_parent, | ||
1078 | .clksel_reg = OMAP_CM_REGADDR(MPU_MOD, OMAP3430_CM_IDLEST_PLL), | ||
1079 | .clksel_mask = OMAP3430_ST_MPU_CLK_MASK, | ||
1080 | .clksel = mpu_clksel, | ||
1081 | .clkdm_name = "mpu_clkdm", | 997 | .clkdm_name = "mpu_clkdm", |
1082 | .recalc = &omap2_clksel_recalc, | 998 | .recalc = &followparent_recalc, |
1083 | }; | 999 | }; |
1084 | 1000 | ||
1085 | /* arm_fck is divided by two when DPLL1 locked; otherwise, passthrough mpu_ck */ | 1001 | /* arm_fck is divided by two when DPLL1 locked; otherwise, passthrough mpu_ck */ |
@@ -1129,19 +1045,6 @@ static struct clk dpll2_fck = { | |||
1129 | .recalc = &omap2_clksel_recalc, | 1045 | .recalc = &omap2_clksel_recalc, |
1130 | }; | 1046 | }; |
1131 | 1047 | ||
1132 | /* | ||
1133 | * IVA2 clksel: | ||
1134 | * If DPLL2 is locked, iva2_ck derives from DPLL2; otherwise, iva2_ck | ||
1135 | * derives from the high-frequency bypass clock originating from DPLL3, | ||
1136 | * called 'dpll2_fck' | ||
1137 | */ | ||
1138 | |||
1139 | static const struct clksel iva2_clksel[] = { | ||
1140 | { .parent = &dpll2_fck, .rates = dpll_bypass_rates }, | ||
1141 | { .parent = &dpll2_m2_ck, .rates = dpll_locked_rates }, | ||
1142 | { .parent = NULL } | ||
1143 | }; | ||
1144 | |||
1145 | static struct clk iva2_ck = { | 1048 | static struct clk iva2_ck = { |
1146 | .name = "iva2_ck", | 1049 | .name = "iva2_ck", |
1147 | .ops = &clkops_omap2_dflt_wait, | 1050 | .ops = &clkops_omap2_dflt_wait, |
@@ -1149,12 +1052,8 @@ static struct clk iva2_ck = { | |||
1149 | .init = &omap2_init_clksel_parent, | 1052 | .init = &omap2_init_clksel_parent, |
1150 | .enable_reg = OMAP_CM_REGADDR(OMAP3430_IVA2_MOD, CM_FCLKEN), | 1053 | .enable_reg = OMAP_CM_REGADDR(OMAP3430_IVA2_MOD, CM_FCLKEN), |
1151 | .enable_bit = OMAP3430_CM_FCLKEN_IVA2_EN_IVA2_SHIFT, | 1054 | .enable_bit = OMAP3430_CM_FCLKEN_IVA2_EN_IVA2_SHIFT, |
1152 | .clksel_reg = OMAP_CM_REGADDR(OMAP3430_IVA2_MOD, | ||
1153 | OMAP3430_CM_IDLEST_PLL), | ||
1154 | .clksel_mask = OMAP3430_ST_IVA2_CLK_MASK, | ||
1155 | .clksel = iva2_clksel, | ||
1156 | .clkdm_name = "iva2_clkdm", | 1055 | .clkdm_name = "iva2_clkdm", |
1157 | .recalc = &omap2_clksel_recalc, | 1056 | .recalc = &followparent_recalc, |
1158 | }; | 1057 | }; |
1159 | 1058 | ||
1160 | /* Common interface clocks */ | 1059 | /* Common interface clocks */ |
@@ -1384,7 +1283,7 @@ static struct clk ts_fck = { | |||
1384 | static struct clk usbtll_fck = { | 1283 | static struct clk usbtll_fck = { |
1385 | .name = "usbtll_fck", | 1284 | .name = "usbtll_fck", |
1386 | .ops = &clkops_omap2_dflt, | 1285 | .ops = &clkops_omap2_dflt, |
1387 | .parent = &omap_120m_fck, | 1286 | .parent = &dpll5_m2_ck, |
1388 | .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP3430ES2_CM_FCLKEN3), | 1287 | .enable_reg = OMAP_CM_REGADDR(CORE_MOD, OMAP3430ES2_CM_FCLKEN3), |
1389 | .enable_bit = OMAP3430ES2_EN_USBTLL_SHIFT, | 1288 | .enable_bit = OMAP3430ES2_EN_USBTLL_SHIFT, |
1390 | .recalc = &followparent_recalc, | 1289 | .recalc = &followparent_recalc, |
@@ -2094,24 +1993,14 @@ static struct clk des1_ick = { | |||
2094 | }; | 1993 | }; |
2095 | 1994 | ||
2096 | /* DSS */ | 1995 | /* DSS */ |
2097 | static const struct clksel dss1_alwon_fck_clksel[] = { | ||
2098 | { .parent = &sys_ck, .rates = dpll_bypass_rates }, | ||
2099 | { .parent = &dpll4_m4x2_ck, .rates = dpll_locked_rates }, | ||
2100 | { .parent = NULL } | ||
2101 | }; | ||
2102 | |||
2103 | static struct clk dss1_alwon_fck = { | 1996 | static struct clk dss1_alwon_fck = { |
2104 | .name = "dss1_alwon_fck", | 1997 | .name = "dss1_alwon_fck", |
2105 | .ops = &clkops_omap2_dflt, | 1998 | .ops = &clkops_omap2_dflt, |
2106 | .parent = &dpll4_m4x2_ck, | 1999 | .parent = &dpll4_m4x2_ck, |
2107 | .init = &omap2_init_clksel_parent, | ||
2108 | .enable_reg = OMAP_CM_REGADDR(OMAP3430_DSS_MOD, CM_FCLKEN), | 2000 | .enable_reg = OMAP_CM_REGADDR(OMAP3430_DSS_MOD, CM_FCLKEN), |
2109 | .enable_bit = OMAP3430_EN_DSS1_SHIFT, | 2001 | .enable_bit = OMAP3430_EN_DSS1_SHIFT, |
2110 | .clksel_reg = OMAP_CM_REGADDR(PLL_MOD, CM_IDLEST), | ||
2111 | .clksel_mask = OMAP3430_ST_PERIPH_CLK_MASK, | ||
2112 | .clksel = dss1_alwon_fck_clksel, | ||
2113 | .clkdm_name = "dss_clkdm", | 2002 | .clkdm_name = "dss_clkdm", |
2114 | .recalc = &omap2_clksel_recalc, | 2003 | .recalc = &followparent_recalc, |
2115 | }; | 2004 | }; |
2116 | 2005 | ||
2117 | static struct clk dss_tv_fck = { | 2006 | static struct clk dss_tv_fck = { |
@@ -2161,24 +2050,14 @@ static struct clk dss_ick = { | |||
2161 | 2050 | ||
2162 | /* CAM */ | 2051 | /* CAM */ |
2163 | 2052 | ||
2164 | static const struct clksel cam_mclk_clksel[] = { | ||
2165 | { .parent = &sys_ck, .rates = dpll_bypass_rates }, | ||
2166 | { .parent = &dpll4_m5x2_ck, .rates = dpll_locked_rates }, | ||
2167 | { .parent = NULL } | ||
2168 | }; | ||
2169 | |||
2170 | static struct clk cam_mclk = { | 2053 | static struct clk cam_mclk = { |
2171 | .name = "cam_mclk", | 2054 | .name = "cam_mclk", |
2172 | .ops = &clkops_omap2_dflt_wait, | 2055 | .ops = &clkops_omap2_dflt_wait, |
2173 | .parent = &dpll4_m5x2_ck, | 2056 | .parent = &dpll4_m5x2_ck, |
2174 | .init = &omap2_init_clksel_parent, | ||
2175 | .clksel_reg = OMAP_CM_REGADDR(PLL_MOD, CM_IDLEST), | ||
2176 | .clksel_mask = OMAP3430_ST_PERIPH_CLK_MASK, | ||
2177 | .clksel = cam_mclk_clksel, | ||
2178 | .enable_reg = OMAP_CM_REGADDR(OMAP3430_CAM_MOD, CM_FCLKEN), | 2057 | .enable_reg = OMAP_CM_REGADDR(OMAP3430_CAM_MOD, CM_FCLKEN), |
2179 | .enable_bit = OMAP3430_EN_CAM_SHIFT, | 2058 | .enable_bit = OMAP3430_EN_CAM_SHIFT, |
2180 | .clkdm_name = "cam_clkdm", | 2059 | .clkdm_name = "cam_clkdm", |
2181 | .recalc = &omap2_clksel_recalc, | 2060 | .recalc = &followparent_recalc, |
2182 | }; | 2061 | }; |
2183 | 2062 | ||
2184 | static struct clk cam_ick = { | 2063 | static struct clk cam_ick = { |
@@ -2209,7 +2088,7 @@ static struct clk csi2_96m_fck = { | |||
2209 | static struct clk usbhost_120m_fck = { | 2088 | static struct clk usbhost_120m_fck = { |
2210 | .name = "usbhost_120m_fck", | 2089 | .name = "usbhost_120m_fck", |
2211 | .ops = &clkops_omap2_dflt_wait, | 2090 | .ops = &clkops_omap2_dflt_wait, |
2212 | .parent = &omap_120m_fck, | 2091 | .parent = &dpll5_m2_ck, |
2213 | .init = &omap2_init_clk_clkdm, | 2092 | .init = &omap2_init_clk_clkdm, |
2214 | .enable_reg = OMAP_CM_REGADDR(OMAP3430ES2_USBHOST_MOD, CM_FCLKEN), | 2093 | .enable_reg = OMAP_CM_REGADDR(OMAP3430ES2_USBHOST_MOD, CM_FCLKEN), |
2215 | .enable_bit = OMAP3430ES2_EN_USBHOST2_SHIFT, | 2094 | .enable_bit = OMAP3430ES2_EN_USBHOST2_SHIFT, |
@@ -2260,7 +2139,7 @@ static const struct clksel_rate usim_120m_rates[] = { | |||
2260 | 2139 | ||
2261 | static const struct clksel usim_clksel[] = { | 2140 | static const struct clksel usim_clksel[] = { |
2262 | { .parent = &omap_96m_fck, .rates = usim_96m_rates }, | 2141 | { .parent = &omap_96m_fck, .rates = usim_96m_rates }, |
2263 | { .parent = &omap_120m_fck, .rates = usim_120m_rates }, | 2142 | { .parent = &dpll5_m2_ck, .rates = usim_120m_rates }, |
2264 | { .parent = &sys_ck, .rates = div2_rates }, | 2143 | { .parent = &sys_ck, .rates = div2_rates }, |
2265 | { .parent = NULL }, | 2144 | { .parent = NULL }, |
2266 | }; | 2145 | }; |
diff --git a/arch/arm/mach-omap2/sdrc2xxx.c b/arch/arm/mach-omap2/sdrc2xxx.c index 3a47aba29031..0afdad5ae9fb 100644 --- a/arch/arm/mach-omap2/sdrc2xxx.c +++ b/arch/arm/mach-omap2/sdrc2xxx.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <mach/sram.h> | 29 | #include <mach/sram.h> |
30 | 30 | ||
31 | #include "prm.h" | 31 | #include "prm.h" |
32 | 32 | #include "clock.h" | |
33 | #include <mach/sdrc.h> | 33 | #include <mach/sdrc.h> |
34 | #include "sdrc.h" | 34 | #include "sdrc.h" |
35 | 35 | ||
diff --git a/arch/arm/plat-omap/include/mach/clock.h b/arch/arm/plat-omap/include/mach/clock.h index 7b6f6bcbff94..073a2c5569f0 100644 --- a/arch/arm/plat-omap/include/mach/clock.h +++ b/arch/arm/plat-omap/include/mach/clock.h | |||
@@ -39,6 +39,10 @@ struct dpll_data { | |||
39 | void __iomem *mult_div1_reg; | 39 | void __iomem *mult_div1_reg; |
40 | u32 mult_mask; | 40 | u32 mult_mask; |
41 | u32 div1_mask; | 41 | u32 div1_mask; |
42 | struct clk *clk_bypass; | ||
43 | struct clk *clk_ref; | ||
44 | void __iomem *control_reg; | ||
45 | u32 enable_mask; | ||
42 | unsigned int rate_tolerance; | 46 | unsigned int rate_tolerance; |
43 | unsigned long last_rounded_rate; | 47 | unsigned long last_rounded_rate; |
44 | u16 last_rounded_m; | 48 | u16 last_rounded_m; |
@@ -49,10 +53,8 @@ struct dpll_data { | |||
49 | u16 max_multiplier; | 53 | u16 max_multiplier; |
50 | # if defined(CONFIG_ARCH_OMAP3) | 54 | # if defined(CONFIG_ARCH_OMAP3) |
51 | u8 modes; | 55 | u8 modes; |
52 | void __iomem *control_reg; | ||
53 | void __iomem *autoidle_reg; | 56 | void __iomem *autoidle_reg; |
54 | void __iomem *idlest_reg; | 57 | void __iomem *idlest_reg; |
55 | u32 enable_mask; | ||
56 | u32 autoidle_mask; | 58 | u32 autoidle_mask; |
57 | u32 freqsel_mask; | 59 | u32 freqsel_mask; |
58 | u32 idlest_mask; | 60 | u32 idlest_mask; |
@@ -154,9 +156,4 @@ extern const struct clkops clkops_null; | |||
154 | #define RATE_IN_24XX (RATE_IN_242X | RATE_IN_243X) | 156 | #define RATE_IN_24XX (RATE_IN_242X | RATE_IN_243X) |
155 | 157 | ||
156 | 158 | ||
157 | /* CM_CLKSEL2_PLL.CORE_CLK_SRC options (24XX) */ | ||
158 | #define CORE_CLK_SRC_32K 0 | ||
159 | #define CORE_CLK_SRC_DPLL 1 | ||
160 | #define CORE_CLK_SRC_DPLL_X2 2 | ||
161 | |||
162 | #endif | 159 | #endif |