aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/dpll3xxx.c
diff options
context:
space:
mode:
authorMike Turquette <mturquette@linaro.org>2012-11-10 18:58:41 -0500
committerPaul Walmsley <paul@pwsan.com>2012-11-12 15:55:50 -0500
commit32cc002116b866151ca24c6e9110ba8a93754753 (patch)
tree4a7d3f08bf774ed72d37bd0de541d9dac5e3083e /arch/arm/mach-omap2/dpll3xxx.c
parentf5dd3bb53ca45f3b47c6889e5920c562f5a37359 (diff)
ARM: OMAP4: clock: Convert to common clk
Convert all OMAP4 specific platform files to use COMMON clk and keep all the changes under the CONFIG_COMMON_CLK macro check so it does not break any existing code. At a later point switch to COMMON clk and get rid of all old/legacy code. This converts all apis which will be called directly from COMMON clk to take a struct clk_hw parameter, and all the internal platform apis to take a struct clk_hw_omap parameter. Changes are based off the original patch from Mike Turquette. Signed-off-by: Rajendra Nayak <rnayak@ti.com> [paul@pwsan.com: created new omap2_clksel_find_parent_index() rather than modifying omap2_init_clksel_parent(); moved clkhwops_iclk_wait to clkt_iclk.c to fix OMAP4-only builds; added clk-provider.h include to clock.h to try to fix some 3430-builds] [mturquette@ti.com: squash patch for omap2_clkops_{en,dis}able_clkdm; omap2_dflt_clk_is_enabled should not enable clocks] Signed-off-by: Mike Turquette <mturquette@ti.com> [paul@pwsan.com: fix compiler warning; update to apply; added kerneldoc on non-trivial new functions; added the dpll3xxx clockdomain modifications] Signed-off-by: Paul Walmsley <paul@pwsan.com>
Diffstat (limited to 'arch/arm/mach-omap2/dpll3xxx.c')
-rw-r--r--arch/arm/mach-omap2/dpll3xxx.c226
1 files changed, 224 insertions, 2 deletions
diff --git a/arch/arm/mach-omap2/dpll3xxx.c b/arch/arm/mach-omap2/dpll3xxx.c
index eacf51f2bc27..f72dedb4eee8 100644
--- a/arch/arm/mach-omap2/dpll3xxx.c
+++ b/arch/arm/mach-omap2/dpll3xxx.c
@@ -29,6 +29,7 @@
29#include <linux/clkdev.h> 29#include <linux/clkdev.h>
30 30
31#include "soc.h" 31#include "soc.h"
32#include "clockdomain.h"
32#include "clock.h" 33#include "clock.h"
33#include "cm2xxx_3xxx.h" 34#include "cm2xxx_3xxx.h"
34#include "cm-regbits-34xx.h" 35#include "cm-regbits-34xx.h"
@@ -42,7 +43,11 @@
42/* Private functions */ 43/* Private functions */
43 44
44/* _omap3_dpll_write_clken - write clken_bits arg to a DPLL's enable bits */ 45/* _omap3_dpll_write_clken - write clken_bits arg to a DPLL's enable bits */
46#ifdef CONFIG_COMMON_CLK
47static void _omap3_dpll_write_clken(struct clk_hw_omap *clk, u8 clken_bits)
48#else
45static void _omap3_dpll_write_clken(struct clk *clk, u8 clken_bits) 49static void _omap3_dpll_write_clken(struct clk *clk, u8 clken_bits)
50#endif
46{ 51{
47 const struct dpll_data *dd; 52 const struct dpll_data *dd;
48 u32 v; 53 u32 v;
@@ -56,7 +61,11 @@ static void _omap3_dpll_write_clken(struct clk *clk, u8 clken_bits)
56} 61}
57 62
58/* _omap3_wait_dpll_status: wait for a DPLL to enter a specific state */ 63/* _omap3_wait_dpll_status: wait for a DPLL to enter a specific state */
64#ifdef CONFIG_COMMON_CLK
65static int _omap3_wait_dpll_status(struct clk_hw_omap *clk, u8 state)
66#else
59static int _omap3_wait_dpll_status(struct clk *clk, u8 state) 67static int _omap3_wait_dpll_status(struct clk *clk, u8 state)
68#endif
60{ 69{
61 const struct dpll_data *dd; 70 const struct dpll_data *dd;
62 int i = 0; 71 int i = 0;
@@ -64,7 +73,11 @@ static int _omap3_wait_dpll_status(struct clk *clk, u8 state)
64 const char *clk_name; 73 const char *clk_name;
65 74
66 dd = clk->dpll_data; 75 dd = clk->dpll_data;
76#ifdef CONFIG_COMMON_CLK
77 clk_name = __clk_get_name(clk->hw.clk);
78#else
67 clk_name = __clk_get_name(clk); 79 clk_name = __clk_get_name(clk);
80#endif
68 81
69 state <<= __ffs(dd->idlest_mask); 82 state <<= __ffs(dd->idlest_mask);
70 83
@@ -88,7 +101,11 @@ static int _omap3_wait_dpll_status(struct clk *clk, u8 state)
88} 101}
89 102
90/* From 3430 TRM ES2 4.7.6.2 */ 103/* From 3430 TRM ES2 4.7.6.2 */
104#ifdef CONFIG_COMMON_CLK
105static u16 _omap3_dpll_compute_freqsel(struct clk_hw_omap *clk, u8 n)
106#else
91static u16 _omap3_dpll_compute_freqsel(struct clk *clk, u8 n) 107static u16 _omap3_dpll_compute_freqsel(struct clk *clk, u8 n)
108#endif
92{ 109{
93 unsigned long fint; 110 unsigned long fint;
94 u16 f = 0; 111 u16 f = 0;
@@ -133,14 +150,22 @@ static u16 _omap3_dpll_compute_freqsel(struct clk *clk, u8 n)
133 * locked successfully, return 0; if the DPLL did not lock in the time 150 * locked successfully, return 0; if the DPLL did not lock in the time
134 * allotted, or DPLL3 was passed in, return -EINVAL. 151 * allotted, or DPLL3 was passed in, return -EINVAL.
135 */ 152 */
153#ifdef CONFIG_COMMON_CLK
154static int _omap3_noncore_dpll_lock(struct clk_hw_omap *clk)
155#else
136static int _omap3_noncore_dpll_lock(struct clk *clk) 156static int _omap3_noncore_dpll_lock(struct clk *clk)
157#endif
137{ 158{
138 const struct dpll_data *dd; 159 const struct dpll_data *dd;
139 u8 ai; 160 u8 ai;
140 u8 state = 1; 161 u8 state = 1;
141 int r = 0; 162 int r = 0;
142 163
164#ifdef CONFIG_COMMON_CLK
165 pr_debug("clock: locking DPLL %s\n", __clk_get_name(clk->hw.clk));
166#else
143 pr_debug("clock: locking DPLL %s\n", __clk_get_name(clk)); 167 pr_debug("clock: locking DPLL %s\n", __clk_get_name(clk));
168#endif
144 169
145 dd = clk->dpll_data; 170 dd = clk->dpll_data;
146 state <<= __ffs(dd->idlest_mask); 171 state <<= __ffs(dd->idlest_mask);
@@ -178,7 +203,11 @@ done:
178 * DPLL3 was passed in, or the DPLL does not support low-power bypass, 203 * DPLL3 was passed in, or the DPLL does not support low-power bypass,
179 * return -EINVAL. 204 * return -EINVAL.
180 */ 205 */
206#ifdef CONFIG_COMMON_CLK
207static int _omap3_noncore_dpll_bypass(struct clk_hw_omap *clk)
208#else
181static int _omap3_noncore_dpll_bypass(struct clk *clk) 209static int _omap3_noncore_dpll_bypass(struct clk *clk)
210#endif
182{ 211{
183 int r; 212 int r;
184 u8 ai; 213 u8 ai;
@@ -187,7 +216,11 @@ static int _omap3_noncore_dpll_bypass(struct clk *clk)
187 return -EINVAL; 216 return -EINVAL;
188 217
189 pr_debug("clock: configuring DPLL %s for low-power bypass\n", 218 pr_debug("clock: configuring DPLL %s for low-power bypass\n",
219#ifdef CONFIG_COMMON_CLK
220 __clk_get_name(clk->hw.clk));
221#else
190 __clk_get_name(clk)); 222 __clk_get_name(clk));
223#endif
191 224
192 ai = omap3_dpll_autoidle_read(clk); 225 ai = omap3_dpll_autoidle_read(clk);
193 226
@@ -210,14 +243,22 @@ static int _omap3_noncore_dpll_bypass(struct clk *clk)
210 * code. If DPLL3 was passed in, or the DPLL does not support 243 * code. If DPLL3 was passed in, or the DPLL does not support
211 * low-power stop, return -EINVAL; otherwise, return 0. 244 * low-power stop, return -EINVAL; otherwise, return 0.
212 */ 245 */
246#ifdef CONFIG_COMMON_CLK
247static int _omap3_noncore_dpll_stop(struct clk_hw_omap *clk)
248#else
213static int _omap3_noncore_dpll_stop(struct clk *clk) 249static int _omap3_noncore_dpll_stop(struct clk *clk)
250#endif
214{ 251{
215 u8 ai; 252 u8 ai;
216 253
217 if (!(clk->dpll_data->modes & (1 << DPLL_LOW_POWER_STOP))) 254 if (!(clk->dpll_data->modes & (1 << DPLL_LOW_POWER_STOP)))
218 return -EINVAL; 255 return -EINVAL;
219 256
257#ifdef CONFIG_COMMON_CLK
258 pr_debug("clock: stopping DPLL %s\n", __clk_get_name(clk->hw.clk));
259#else
220 pr_debug("clock: stopping DPLL %s\n", __clk_get_name(clk)); 260 pr_debug("clock: stopping DPLL %s\n", __clk_get_name(clk));
261#endif
221 262
222 ai = omap3_dpll_autoidle_read(clk); 263 ai = omap3_dpll_autoidle_read(clk);
223 264
@@ -241,11 +282,19 @@ static int _omap3_noncore_dpll_stop(struct clk *clk)
241 * XXX This code is not needed for 3430/AM35xx; can it be optimized 282 * XXX This code is not needed for 3430/AM35xx; can it be optimized
242 * out in non-multi-OMAP builds for those chips? 283 * out in non-multi-OMAP builds for those chips?
243 */ 284 */
285#ifdef CONFIG_COMMON_CLK
286static void _lookup_dco(struct clk_hw_omap *clk, u8 *dco, u16 m, u8 n)
287#else
244static void _lookup_dco(struct clk *clk, u8 *dco, u16 m, u8 n) 288static void _lookup_dco(struct clk *clk, u8 *dco, u16 m, u8 n)
289#endif
245{ 290{
246 unsigned long fint, clkinp; /* watch out for overflow */ 291 unsigned long fint, clkinp; /* watch out for overflow */
247 292
293#ifdef CONFIG_COMMON_CLK
294 clkinp = __clk_get_rate(__clk_get_parent(clk->hw.clk));
295#else
248 clkinp = __clk_get_rate(__clk_get_parent(clk)); 296 clkinp = __clk_get_rate(__clk_get_parent(clk));
297#endif
249 fint = (clkinp / n) * m; 298 fint = (clkinp / n) * m;
250 299
251 if (fint < 1000000000) 300 if (fint < 1000000000)
@@ -266,12 +315,20 @@ static void _lookup_dco(struct clk *clk, u8 *dco, u16 m, u8 n)
266 * XXX This code is not needed for 3430/AM35xx; can it be optimized 315 * XXX This code is not needed for 3430/AM35xx; can it be optimized
267 * out in non-multi-OMAP builds for those chips? 316 * out in non-multi-OMAP builds for those chips?
268 */ 317 */
318#ifdef CONFIG_COMMON_CLK
319static void _lookup_sddiv(struct clk_hw_omap *clk, u8 *sd_div, u16 m, u8 n)
320#else
269static void _lookup_sddiv(struct clk *clk, u8 *sd_div, u16 m, u8 n) 321static void _lookup_sddiv(struct clk *clk, u8 *sd_div, u16 m, u8 n)
322#endif
270{ 323{
271 unsigned long clkinp, sd; /* watch out for overflow */ 324 unsigned long clkinp, sd; /* watch out for overflow */
272 int mod1, mod2; 325 int mod1, mod2;
273 326
327#ifdef CONFIG_COMMON_CLK
328 clkinp = __clk_get_rate(__clk_get_parent(clk->hw.clk));
329#else
274 clkinp = __clk_get_rate(__clk_get_parent(clk)); 330 clkinp = __clk_get_rate(__clk_get_parent(clk));
331#endif
275 332
276 /* 333 /*
277 * target sigma-delta to near 250MHz 334 * target sigma-delta to near 250MHz
@@ -298,7 +355,12 @@ static void _lookup_sddiv(struct clk *clk, u8 *sd_div, u16 m, u8 n)
298 * Program the DPLL with the supplied M, N values, and wait for the DPLL to 355 * Program the DPLL with the supplied M, N values, and wait for the DPLL to
299 * lock.. Returns -EINVAL upon error, or 0 upon success. 356 * lock.. Returns -EINVAL upon error, or 0 upon success.
300 */ 357 */
358#ifdef CONFIG_COMMON_CLK
359static int omap3_noncore_dpll_program(struct clk_hw_omap *clk, u16 m, u8 n,
360 u16 freqsel)
361#else
301static int omap3_noncore_dpll_program(struct clk *clk, u16 m, u8 n, u16 freqsel) 362static int omap3_noncore_dpll_program(struct clk *clk, u16 m, u8 n, u16 freqsel)
363#endif
302{ 364{
303 struct dpll_data *dd = clk->dpll_data; 365 struct dpll_data *dd = clk->dpll_data;
304 u8 dco, sd_div; 366 u8 dco, sd_div;
@@ -355,8 +417,14 @@ static int omap3_noncore_dpll_program(struct clk *clk, u16 m, u8 n, u16 freqsel)
355 * 417 *
356 * Recalculate and propagate the DPLL rate. 418 * Recalculate and propagate the DPLL rate.
357 */ 419 */
420#ifdef CONFIG_COMMON_CLK
421unsigned long omap3_dpll_recalc(struct clk_hw *hw, unsigned long parent_rate)
422{
423 struct clk_hw_omap *clk = to_clk_hw_omap(hw);
424#else
358unsigned long omap3_dpll_recalc(struct clk *clk) 425unsigned long omap3_dpll_recalc(struct clk *clk)
359{ 426{
427#endif
360 return omap2_get_dpll_rate(clk); 428 return omap2_get_dpll_rate(clk);
361} 429}
362 430
@@ -376,8 +444,14 @@ unsigned long omap3_dpll_recalc(struct clk *clk)
376 * support low-power stop, or if the DPLL took too long to enter 444 * support low-power stop, or if the DPLL took too long to enter
377 * bypass or lock, return -EINVAL; otherwise, return 0. 445 * bypass or lock, return -EINVAL; otherwise, return 0.
378 */ 446 */
447#ifdef CONFIG_COMMON_CLK
448int omap3_noncore_dpll_enable(struct clk_hw *hw)
449{
450 struct clk_hw_omap *clk = to_clk_hw_omap(hw);
451#else
379int omap3_noncore_dpll_enable(struct clk *clk) 452int omap3_noncore_dpll_enable(struct clk *clk)
380{ 453{
454#endif
381 int r; 455 int r;
382 struct dpll_data *dd; 456 struct dpll_data *dd;
383 struct clk *parent; 457 struct clk *parent;
@@ -386,15 +460,34 @@ int omap3_noncore_dpll_enable(struct clk *clk)
386 if (!dd) 460 if (!dd)
387 return -EINVAL; 461 return -EINVAL;
388 462
463#ifdef CONFIG_COMMON_CLK
464 if (clk->clkdm) {
465 r = clkdm_clk_enable(clk->clkdm, hw->clk);
466 if (r) {
467 WARN(1,
468 "%s: could not enable %s's clockdomain %s: %d\n",
469 __func__, __clk_get_name(hw->clk),
470 clk->clkdm->name, r);
471 return r;
472 }
473 }
474
475 parent = __clk_get_parent(hw->clk);
476
477 if (__clk_get_rate(hw->clk) == __clk_get_rate(dd->clk_bypass)) {
478#else
389 parent = __clk_get_parent(clk); 479 parent = __clk_get_parent(clk);
390 480
391 if (__clk_get_rate(clk) == __clk_get_rate(dd->clk_bypass)) { 481 if (__clk_get_rate(clk) == __clk_get_rate(dd->clk_bypass)) {
482#endif
392 WARN_ON(parent != dd->clk_bypass); 483 WARN_ON(parent != dd->clk_bypass);
393 r = _omap3_noncore_dpll_bypass(clk); 484 r = _omap3_noncore_dpll_bypass(clk);
394 } else { 485 } else {
395 WARN_ON(parent != dd->clk_ref); 486 WARN_ON(parent != dd->clk_ref);
396 r = _omap3_noncore_dpll_lock(clk); 487 r = _omap3_noncore_dpll_lock(clk);
397 } 488 }
489
490#ifndef CONFIG_COMMON_CLK
398 /* 491 /*
399 *FIXME: this is dubious - if clk->rate has changed, what about 492 *FIXME: this is dubious - if clk->rate has changed, what about
400 * propagating? 493 * propagating?
@@ -402,6 +495,7 @@ int omap3_noncore_dpll_enable(struct clk *clk)
402 if (!r) 495 if (!r)
403 clk->rate = (clk->recalc) ? clk->recalc(clk) : 496 clk->rate = (clk->recalc) ? clk->recalc(clk) :
404 omap2_get_dpll_rate(clk); 497 omap2_get_dpll_rate(clk);
498#endif
405 499
406 return r; 500 return r;
407} 501}
@@ -413,9 +507,21 @@ int omap3_noncore_dpll_enable(struct clk *clk)
413 * Instructs a non-CORE DPLL to enter low-power stop. This function is 507 * Instructs a non-CORE DPLL to enter low-power stop. This function is
414 * intended for use in struct clkops. No return value. 508 * intended for use in struct clkops. No return value.
415 */ 509 */
510#ifdef CONFIG_COMMON_CLK
511void omap3_noncore_dpll_disable(struct clk_hw *hw)
512{
513 struct clk_hw_omap *clk = to_clk_hw_omap(hw);
514
515 _omap3_noncore_dpll_stop(clk);
516 if (clk->clkdm)
517 clkdm_clk_disable(clk->clkdm, hw->clk);
518#else
416void omap3_noncore_dpll_disable(struct clk *clk) 519void omap3_noncore_dpll_disable(struct clk *clk)
417{ 520{
418 _omap3_noncore_dpll_stop(clk); 521 _omap3_noncore_dpll_stop(clk);
522 if (clk->clkdm)
523 clkdm_clk_disable(clk->clkdm, clk);
524#endif
419} 525}
420 526
421 527
@@ -432,6 +538,77 @@ void omap3_noncore_dpll_disable(struct clk *clk)
432 * target rate if it hasn't been done already, then program and lock 538 * target rate if it hasn't been done already, then program and lock
433 * the DPLL. Returns -EINVAL upon error, or 0 upon success. 539 * the DPLL. Returns -EINVAL upon error, or 0 upon success.
434 */ 540 */
541#ifdef CONFIG_COMMON_CLK
542int omap3_noncore_dpll_set_rate(struct clk_hw *hw, unsigned long rate,
543 unsigned long parent_rate)
544{
545 struct clk_hw_omap *clk = to_clk_hw_omap(hw);
546 struct clk *new_parent = NULL;
547 u16 freqsel = 0;
548 struct dpll_data *dd;
549 int ret;
550
551 if (!hw || !rate)
552 return -EINVAL;
553
554 dd = clk->dpll_data;
555 if (!dd)
556 return -EINVAL;
557
558 __clk_prepare(dd->clk_bypass);
559 clk_enable(dd->clk_bypass);
560 __clk_prepare(dd->clk_ref);
561 clk_enable(dd->clk_ref);
562
563 if (__clk_get_rate(dd->clk_bypass) == rate &&
564 (dd->modes & (1 << DPLL_LOW_POWER_BYPASS))) {
565 pr_debug("%s: %s: set rate: entering bypass.\n",
566 __func__, __clk_get_name(hw->clk));
567
568 ret = _omap3_noncore_dpll_bypass(clk);
569 if (!ret)
570 new_parent = dd->clk_bypass;
571 } else {
572 if (dd->last_rounded_rate != rate)
573 rate = __clk_round_rate(hw->clk, rate);
574
575 if (dd->last_rounded_rate == 0)
576 return -EINVAL;
577
578 /* No freqsel on OMAP4 and OMAP3630 */
579 if (!cpu_is_omap44xx() && !cpu_is_omap3630()) {
580 freqsel = _omap3_dpll_compute_freqsel(clk,
581 dd->last_rounded_n);
582 if (!freqsel)
583 WARN_ON(1);
584 }
585
586 pr_debug("%s: %s: set rate: locking rate to %lu.\n",
587 __func__, __clk_get_name(hw->clk), rate);
588
589 ret = omap3_noncore_dpll_program(clk, dd->last_rounded_m,
590 dd->last_rounded_n, freqsel);
591 if (!ret)
592 new_parent = dd->clk_ref;
593 }
594 /*
595 * FIXME - this is all wrong. common code handles reparenting and
596 * migrating prepare/enable counts. dplls should be a multiplexer
597 * clock and this should be a set_parent operation so that all of that
598 * stuff is inherited for free
599 */
600
601 if (!ret)
602 __clk_reparent(hw->clk, new_parent);
603
604 clk_disable(dd->clk_ref);
605 __clk_unprepare(dd->clk_ref);
606 clk_disable(dd->clk_bypass);
607 __clk_unprepare(dd->clk_bypass);
608
609 return 0;
610}
611#else
435int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate) 612int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
436{ 613{
437 struct clk *new_parent = NULL; 614 struct clk *new_parent = NULL;
@@ -509,6 +686,7 @@ int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
509 686
510 return 0; 687 return 0;
511} 688}
689#endif
512 690
513/* DPLL autoidle read/set code */ 691/* DPLL autoidle read/set code */
514 692
@@ -520,7 +698,11 @@ int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
520 * -EINVAL if passed a null pointer or if the struct clk does not 698 * -EINVAL if passed a null pointer or if the struct clk does not
521 * appear to refer to a DPLL. 699 * appear to refer to a DPLL.
522 */ 700 */
701#ifdef CONFIG_COMMON_CLK
702u32 omap3_dpll_autoidle_read(struct clk_hw_omap *clk)
703#else
523u32 omap3_dpll_autoidle_read(struct clk *clk) 704u32 omap3_dpll_autoidle_read(struct clk *clk)
705#endif
524{ 706{
525 const struct dpll_data *dd; 707 const struct dpll_data *dd;
526 u32 v; 708 u32 v;
@@ -549,7 +731,11 @@ u32 omap3_dpll_autoidle_read(struct clk *clk)
549 * OMAP3430. The DPLL will enter low-power stop when its downstream 731 * OMAP3430. The DPLL will enter low-power stop when its downstream
550 * clocks are gated. No return value. 732 * clocks are gated. No return value.
551 */ 733 */
734#ifdef CONFIG_COMMON_CLK
735void omap3_dpll_allow_idle(struct clk_hw_omap *clk)
736#else
552void omap3_dpll_allow_idle(struct clk *clk) 737void omap3_dpll_allow_idle(struct clk *clk)
738#endif
553{ 739{
554 const struct dpll_data *dd; 740 const struct dpll_data *dd;
555 u32 v; 741 u32 v;
@@ -560,8 +746,10 @@ void omap3_dpll_allow_idle(struct clk *clk)
560 dd = clk->dpll_data; 746 dd = clk->dpll_data;
561 747
562 if (!dd->autoidle_reg) { 748 if (!dd->autoidle_reg) {
749#ifndef CONFIG_COMMON_CLK
563 pr_debug("clock: DPLL %s: autoidle not supported\n", 750 pr_debug("clock: DPLL %s: autoidle not supported\n",
564 __clk_get_name(clk)); 751 __clk_get_name(clk));
752#endif
565 return; 753 return;
566 } 754 }
567 755
@@ -583,7 +771,11 @@ void omap3_dpll_allow_idle(struct clk *clk)
583 * 771 *
584 * Disable DPLL automatic idle control. No return value. 772 * Disable DPLL automatic idle control. No return value.
585 */ 773 */
774#ifdef CONFIG_COMMON_CLK
775void omap3_dpll_deny_idle(struct clk_hw_omap *clk)
776#else
586void omap3_dpll_deny_idle(struct clk *clk) 777void omap3_dpll_deny_idle(struct clk *clk)
778#endif
587{ 779{
588 const struct dpll_data *dd; 780 const struct dpll_data *dd;
589 u32 v; 781 u32 v;
@@ -594,8 +786,10 @@ void omap3_dpll_deny_idle(struct clk *clk)
594 dd = clk->dpll_data; 786 dd = clk->dpll_data;
595 787
596 if (!dd->autoidle_reg) { 788 if (!dd->autoidle_reg) {
789#ifndef CONFIG_COMMON_CLK
597 pr_debug("clock: DPLL %s: autoidle not supported\n", 790 pr_debug("clock: DPLL %s: autoidle not supported\n",
598 __clk_get_name(clk)); 791 __clk_get_name(clk));
792#endif
599 return; 793 return;
600 } 794 }
601 795
@@ -615,6 +809,27 @@ void omap3_dpll_deny_idle(struct clk *clk)
615 * Using parent clock DPLL data, look up DPLL state. If locked, set our 809 * Using parent clock DPLL data, look up DPLL state. If locked, set our
616 * rate to the dpll_clk * 2; otherwise, just use dpll_clk. 810 * rate to the dpll_clk * 2; otherwise, just use dpll_clk.
617 */ 811 */
812#ifdef CONFIG_COMMON_CLK
813unsigned long omap3_clkoutx2_recalc(struct clk_hw *hw,
814 unsigned long parent_rate)
815{
816 const struct dpll_data *dd;
817 unsigned long rate;
818 u32 v;
819 struct clk_hw_omap *pclk = NULL;
820 struct clk *parent;
821
822 /* Walk up the parents of clk, looking for a DPLL */
823 do {
824 do {
825 parent = __clk_get_parent(hw->clk);
826 hw = __clk_get_hw(parent);
827 } while (hw && (__clk_get_flags(hw->clk) & CLK_IS_BASIC));
828 if (!hw)
829 break;
830 pclk = to_clk_hw_omap(hw);
831 } while (pclk && !pclk->dpll_data);
832#else
618unsigned long omap3_clkoutx2_recalc(struct clk *clk) 833unsigned long omap3_clkoutx2_recalc(struct clk *clk)
619{ 834{
620 const struct dpll_data *dd; 835 const struct dpll_data *dd;
@@ -628,6 +843,8 @@ unsigned long omap3_clkoutx2_recalc(struct clk *clk)
628 while (pclk && !pclk->dpll_data) 843 while (pclk && !pclk->dpll_data)
629 pclk = __clk_get_parent(pclk); 844 pclk = __clk_get_parent(pclk);
630 845
846 parent_rate = __clk_get_rate(__clk_get_parent(clk));
847#endif
631 /* clk does not have a DPLL as a parent? error in the clock data */ 848 /* clk does not have a DPLL as a parent? error in the clock data */
632 if (!pclk) { 849 if (!pclk) {
633 WARN_ON(1); 850 WARN_ON(1);
@@ -638,7 +855,6 @@ unsigned long omap3_clkoutx2_recalc(struct clk *clk)
638 855
639 WARN_ON(!dd->enable_mask); 856 WARN_ON(!dd->enable_mask);
640 857
641 parent_rate = __clk_get_rate(__clk_get_parent(clk));
642 v = __raw_readl(dd->control_reg) & dd->enable_mask; 858 v = __raw_readl(dd->control_reg) & dd->enable_mask;
643 v >>= __ffs(dd->enable_mask); 859 v >>= __ffs(dd->enable_mask);
644 if ((v != OMAP3XXX_EN_DPLL_LOCKED) || (dd->flags & DPLL_J_TYPE)) 860 if ((v != OMAP3XXX_EN_DPLL_LOCKED) || (dd->flags & DPLL_J_TYPE))
@@ -649,7 +865,12 @@ unsigned long omap3_clkoutx2_recalc(struct clk *clk)
649} 865}
650 866
651/* OMAP3/4 non-CORE DPLL clkops */ 867/* OMAP3/4 non-CORE DPLL clkops */
652 868#ifdef CONFIG_COMMON_CLK
869const struct clk_hw_omap_ops clkhwops_omap3_dpll = {
870 .allow_idle = omap3_dpll_allow_idle,
871 .deny_idle = omap3_dpll_deny_idle,
872};
873#else
653const struct clkops clkops_omap3_noncore_dpll_ops = { 874const struct clkops clkops_omap3_noncore_dpll_ops = {
654 .enable = omap3_noncore_dpll_enable, 875 .enable = omap3_noncore_dpll_enable,
655 .disable = omap3_noncore_dpll_disable, 876 .disable = omap3_noncore_dpll_disable,
@@ -661,3 +882,4 @@ const struct clkops clkops_omap3_core_dpll_ops = {
661 .allow_idle = omap3_dpll_allow_idle, 882 .allow_idle = omap3_dpll_allow_idle,
662 .deny_idle = omap3_dpll_deny_idle, 883 .deny_idle = omap3_dpll_deny_idle,
663}; 884};
885#endif