2 * OMAP3/4 - specific DPLL control functions
4 * Copyright (C) 2009-2010 Texas Instruments, Inc.
5 * Copyright (C) 2009-2010 Nokia Corporation
7 * Written by Paul Walmsley
8 * Testing and integration fixes by Jouni Högander
10 * 36xx support added by Vishwanath BS, Richard Woodruff, and Nishanth
13 * Parts of this code are based on code written by
14 * Richard Woodruff, Tony Lindgren, Tuukka Tikkanen, Karthik Dasu
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License version 2 as
18 * published by the Free Software Foundation.
21 #include <linux/kernel.h>
22 #include <linux/device.h>
23 #include <linux/list.h>
24 #include <linux/errno.h>
25 #include <linux/delay.h>
26 #include <linux/clk.h>
28 #include <linux/bitops.h>
29 #include <linux/clkdev.h>
32 #include "clockdomain.h"
34 #include "cm2xxx_3xxx.h"
35 #include "cm-regbits-34xx.h"
37 /* CM_AUTOIDLE_PLL*.AUTO_* bit values */
38 #define DPLL_AUTOIDLE_DISABLE 0x0
39 #define DPLL_AUTOIDLE_LOW_POWER_STOP 0x1
41 #define MAX_DPLL_WAIT_TRIES 1000000
43 /* Private functions */
45 /* _omap3_dpll_write_clken - write clken_bits arg to a DPLL's enable bits */
46 #ifdef CONFIG_COMMON_CLK
47 static void _omap3_dpll_write_clken(struct clk_hw_omap *clk, u8 clken_bits)
49 static void _omap3_dpll_write_clken(struct clk *clk, u8 clken_bits)
52 const struct dpll_data *dd;
57 v = __raw_readl(dd->control_reg);
58 v &= ~dd->enable_mask;
59 v |= clken_bits << __ffs(dd->enable_mask);
60 __raw_writel(v, dd->control_reg);
63 /* _omap3_wait_dpll_status: wait for a DPLL to enter a specific state */
64 #ifdef CONFIG_COMMON_CLK
65 static int _omap3_wait_dpll_status(struct clk_hw_omap *clk, u8 state)
67 static int _omap3_wait_dpll_status(struct clk *clk, u8 state)
70 const struct dpll_data *dd;
76 #ifdef CONFIG_COMMON_CLK
77 clk_name = __clk_get_name(clk->hw.clk);
79 clk_name = __clk_get_name(clk);
82 state <<= __ffs(dd->idlest_mask);
84 while (((__raw_readl(dd->idlest_reg) & dd->idlest_mask) != state) &&
85 i < MAX_DPLL_WAIT_TRIES) {
90 if (i == MAX_DPLL_WAIT_TRIES) {
91 printk(KERN_ERR "clock: %s failed transition to '%s'\n",
92 clk_name, (state) ? "locked" : "bypassed");
94 pr_debug("clock: %s transition to '%s' in %d loops\n",
95 clk_name, (state) ? "locked" : "bypassed", i);
103 /* From 3430 TRM ES2 4.7.6.2 */
104 #ifdef CONFIG_COMMON_CLK
105 static u16 _omap3_dpll_compute_freqsel(struct clk_hw_omap *clk, u8 n)
107 static u16 _omap3_dpll_compute_freqsel(struct clk *clk, u8 n)
113 fint = __clk_get_rate(clk->dpll_data->clk_ref) / n;
115 pr_debug("clock: fint is %lu\n", fint);
117 if (fint >= 750000 && fint <= 1000000)
119 else if (fint > 1000000 && fint <= 1250000)
121 else if (fint > 1250000 && fint <= 1500000)
123 else if (fint > 1500000 && fint <= 1750000)
125 else if (fint > 1750000 && fint <= 2100000)
127 else if (fint > 7500000 && fint <= 10000000)
129 else if (fint > 10000000 && fint <= 12500000)
131 else if (fint > 12500000 && fint <= 15000000)
133 else if (fint > 15000000 && fint <= 17500000)
135 else if (fint > 17500000 && fint <= 21000000)
138 pr_debug("clock: unknown freqsel setting for %d\n", n);
144 * _omap3_noncore_dpll_lock - instruct a DPLL to lock and wait for readiness
145 * @clk: pointer to a DPLL struct clk
147 * Instructs a non-CORE DPLL to lock. Waits for the DPLL to report
148 * readiness before returning. Will save and restore the DPLL's
149 * autoidle state across the enable, per the CDP code. If the DPLL
150 * locked successfully, return 0; if the DPLL did not lock in the time
151 * allotted, or DPLL3 was passed in, return -EINVAL.
153 #ifdef CONFIG_COMMON_CLK
154 static int _omap3_noncore_dpll_lock(struct clk_hw_omap *clk)
156 static int _omap3_noncore_dpll_lock(struct clk *clk)
159 const struct dpll_data *dd;
164 #ifdef CONFIG_COMMON_CLK
165 pr_debug("clock: locking DPLL %s\n", __clk_get_name(clk->hw.clk));
167 pr_debug("clock: locking DPLL %s\n", __clk_get_name(clk));
171 state <<= __ffs(dd->idlest_mask);
173 /* Check if already locked */
174 if ((__raw_readl(dd->idlest_reg) & dd->idlest_mask) == state)
177 ai = omap3_dpll_autoidle_read(clk);
180 omap3_dpll_deny_idle(clk);
182 _omap3_dpll_write_clken(clk, DPLL_LOCKED);
184 r = _omap3_wait_dpll_status(clk, 1);
187 omap3_dpll_allow_idle(clk);
194 * _omap3_noncore_dpll_bypass - instruct a DPLL to bypass and wait for readiness
195 * @clk: pointer to a DPLL struct clk
197 * Instructs a non-CORE DPLL to enter low-power bypass mode. In
198 * bypass mode, the DPLL's rate is set equal to its parent clock's
199 * rate. Waits for the DPLL to report readiness before returning.
200 * Will save and restore the DPLL's autoidle state across the enable,
201 * per the CDP code. If the DPLL entered bypass mode successfully,
202 * return 0; if the DPLL did not enter bypass in the time allotted, or
203 * DPLL3 was passed in, or the DPLL does not support low-power bypass,
206 #ifdef CONFIG_COMMON_CLK
207 static int _omap3_noncore_dpll_bypass(struct clk_hw_omap *clk)
209 static int _omap3_noncore_dpll_bypass(struct clk *clk)
215 if (!(clk->dpll_data->modes & (1 << DPLL_LOW_POWER_BYPASS)))
218 pr_debug("clock: configuring DPLL %s for low-power bypass\n",
219 #ifdef CONFIG_COMMON_CLK
220 __clk_get_name(clk->hw.clk));
222 __clk_get_name(clk));
225 ai = omap3_dpll_autoidle_read(clk);
227 _omap3_dpll_write_clken(clk, DPLL_LOW_POWER_BYPASS);
229 r = _omap3_wait_dpll_status(clk, 0);
232 omap3_dpll_allow_idle(clk);
238 * _omap3_noncore_dpll_stop - instruct a DPLL to stop
239 * @clk: pointer to a DPLL struct clk
241 * Instructs a non-CORE DPLL to enter low-power stop. Will save and
242 * restore the DPLL's autoidle state across the stop, per the CDP
243 * code. If DPLL3 was passed in, or the DPLL does not support
244 * low-power stop, return -EINVAL; otherwise, return 0.
246 #ifdef CONFIG_COMMON_CLK
247 static int _omap3_noncore_dpll_stop(struct clk_hw_omap *clk)
249 static int _omap3_noncore_dpll_stop(struct clk *clk)
254 if (!(clk->dpll_data->modes & (1 << DPLL_LOW_POWER_STOP)))
257 #ifdef CONFIG_COMMON_CLK
258 pr_debug("clock: stopping DPLL %s\n", __clk_get_name(clk->hw.clk));
260 pr_debug("clock: stopping DPLL %s\n", __clk_get_name(clk));
263 ai = omap3_dpll_autoidle_read(clk);
265 _omap3_dpll_write_clken(clk, DPLL_LOW_POWER_STOP);
268 omap3_dpll_allow_idle(clk);
274 * _lookup_dco - Lookup DCO used by j-type DPLL
275 * @clk: pointer to a DPLL struct clk
276 * @dco: digital control oscillator selector
277 * @m: DPLL multiplier to set
278 * @n: DPLL divider to set
280 * See 36xx TRM section 3.5.3.3.3.2 "Type B DPLL (Low-Jitter)"
282 * XXX This code is not needed for 3430/AM35xx; can it be optimized
283 * out in non-multi-OMAP builds for those chips?
285 #ifdef CONFIG_COMMON_CLK
286 static void _lookup_dco(struct clk_hw_omap *clk, u8 *dco, u16 m, u8 n)
288 static void _lookup_dco(struct clk *clk, u8 *dco, u16 m, u8 n)
291 unsigned long fint, clkinp; /* watch out for overflow */
293 #ifdef CONFIG_COMMON_CLK
294 clkinp = __clk_get_rate(__clk_get_parent(clk->hw.clk));
296 clkinp = __clk_get_rate(__clk_get_parent(clk));
298 fint = (clkinp / n) * m;
300 if (fint < 1000000000)
307 * _lookup_sddiv - Calculate sigma delta divider for j-type DPLL
308 * @clk: pointer to a DPLL struct clk
309 * @sd_div: target sigma-delta divider
310 * @m: DPLL multiplier to set
311 * @n: DPLL divider to set
313 * See 36xx TRM section 3.5.3.3.3.2 "Type B DPLL (Low-Jitter)"
315 * XXX This code is not needed for 3430/AM35xx; can it be optimized
316 * out in non-multi-OMAP builds for those chips?
318 #ifdef CONFIG_COMMON_CLK
319 static void _lookup_sddiv(struct clk_hw_omap *clk, u8 *sd_div, u16 m, u8 n)
321 static void _lookup_sddiv(struct clk *clk, u8 *sd_div, u16 m, u8 n)
324 unsigned long clkinp, sd; /* watch out for overflow */
327 #ifdef CONFIG_COMMON_CLK
328 clkinp = __clk_get_rate(__clk_get_parent(clk->hw.clk));
330 clkinp = __clk_get_rate(__clk_get_parent(clk));
334 * target sigma-delta to near 250MHz
335 * sd = ceil[(m/(n+1)) * (clkinp_MHz / 250)]
337 clkinp /= 100000; /* shift from MHz to 10*Hz for 38.4 and 19.2 */
338 mod1 = (clkinp * m) % (250 * n);
339 sd = (clkinp * m) / (250 * n);
349 * _omap3_noncore_dpll_program - set non-core DPLL M,N values directly
350 * @clk: struct clk * of DPLL to set
351 * @m: DPLL multiplier to set
352 * @n: DPLL divider to set
353 * @freqsel: FREQSEL value to set
355 * Program the DPLL with the supplied M, N values, and wait for the DPLL to
356 * lock.. Returns -EINVAL upon error, or 0 upon success.
358 #ifdef CONFIG_COMMON_CLK
359 static int omap3_noncore_dpll_program(struct clk_hw_omap *clk, u16 m, u8 n,
362 static int omap3_noncore_dpll_program(struct clk *clk, u16 m, u8 n, u16 freqsel)
365 struct dpll_data *dd = clk->dpll_data;
369 /* 3430 ES2 TRM: 4.7.6.9 DPLL Programming Sequence */
370 _omap3_noncore_dpll_bypass(clk);
373 * Set jitter correction. No jitter correction for OMAP4 and 3630
374 * since freqsel field is no longer present
376 if (!soc_is_am33xx() && !cpu_is_omap44xx() && !cpu_is_omap3630()) {
377 v = __raw_readl(dd->control_reg);
378 v &= ~dd->freqsel_mask;
379 v |= freqsel << __ffs(dd->freqsel_mask);
380 __raw_writel(v, dd->control_reg);
383 /* Set DPLL multiplier, divider */
384 v = __raw_readl(dd->mult_div1_reg);
385 v &= ~(dd->mult_mask | dd->div1_mask);
386 v |= m << __ffs(dd->mult_mask);
387 v |= (n - 1) << __ffs(dd->div1_mask);
389 /* Configure dco and sd_div for dplls that have these fields */
391 _lookup_dco(clk, &dco, m, n);
392 v &= ~(dd->dco_mask);
393 v |= dco << __ffs(dd->dco_mask);
395 if (dd->sddiv_mask) {
396 _lookup_sddiv(clk, &sd_div, m, n);
397 v &= ~(dd->sddiv_mask);
398 v |= sd_div << __ffs(dd->sddiv_mask);
401 __raw_writel(v, dd->mult_div1_reg);
403 /* We let the clock framework set the other output dividers later */
405 /* REVISIT: Set ramp-up delay? */
407 _omap3_noncore_dpll_lock(clk);
412 /* Public functions */
415 * omap3_dpll_recalc - recalculate DPLL rate
416 * @clk: DPLL struct clk
418 * Recalculate and propagate the DPLL rate.
420 #ifdef CONFIG_COMMON_CLK
421 unsigned long omap3_dpll_recalc(struct clk_hw *hw, unsigned long parent_rate)
423 struct clk_hw_omap *clk = to_clk_hw_omap(hw);
425 unsigned long omap3_dpll_recalc(struct clk *clk)
428 return omap2_get_dpll_rate(clk);
431 /* Non-CORE DPLL (e.g., DPLLs that do not control SDRC) clock functions */
434 * omap3_noncore_dpll_enable - instruct a DPLL to enter bypass or lock mode
435 * @clk: pointer to a DPLL struct clk
437 * Instructs a non-CORE DPLL to enable, e.g., to enter bypass or lock.
438 * The choice of modes depends on the DPLL's programmed rate: if it is
439 * the same as the DPLL's parent clock, it will enter bypass;
440 * otherwise, it will enter lock. This code will wait for the DPLL to
441 * indicate readiness before returning, unless the DPLL takes too long
442 * to enter the target state. Intended to be used as the struct clk's
443 * enable function. If DPLL3 was passed in, or the DPLL does not
444 * support low-power stop, or if the DPLL took too long to enter
445 * bypass or lock, return -EINVAL; otherwise, return 0.
447 #ifdef CONFIG_COMMON_CLK
448 int omap3_noncore_dpll_enable(struct clk_hw *hw)
450 struct clk_hw_omap *clk = to_clk_hw_omap(hw);
452 int omap3_noncore_dpll_enable(struct clk *clk)
456 struct dpll_data *dd;
463 #ifdef CONFIG_COMMON_CLK
465 r = clkdm_clk_enable(clk->clkdm, hw->clk);
468 "%s: could not enable %s's clockdomain %s: %d\n",
469 __func__, __clk_get_name(hw->clk),
470 clk->clkdm->name, r);
475 parent = __clk_get_parent(hw->clk);
477 if (__clk_get_rate(hw->clk) == __clk_get_rate(dd->clk_bypass)) {
479 parent = __clk_get_parent(clk);
481 if (__clk_get_rate(clk) == __clk_get_rate(dd->clk_bypass)) {
483 WARN_ON(parent != dd->clk_bypass);
484 r = _omap3_noncore_dpll_bypass(clk);
486 WARN_ON(parent != dd->clk_ref);
487 r = _omap3_noncore_dpll_lock(clk);
490 #ifndef CONFIG_COMMON_CLK
492 *FIXME: this is dubious - if clk->rate has changed, what about
496 clk->rate = (clk->recalc) ? clk->recalc(clk) :
497 omap2_get_dpll_rate(clk);
504 * omap3_noncore_dpll_disable - instruct a DPLL to enter low-power stop
505 * @clk: pointer to a DPLL struct clk
507 * Instructs a non-CORE DPLL to enter low-power stop. This function is
508 * intended for use in struct clkops. No return value.
510 #ifdef CONFIG_COMMON_CLK
511 void omap3_noncore_dpll_disable(struct clk_hw *hw)
513 struct clk_hw_omap *clk = to_clk_hw_omap(hw);
515 _omap3_noncore_dpll_stop(clk);
517 clkdm_clk_disable(clk->clkdm, hw->clk);
519 void omap3_noncore_dpll_disable(struct clk *clk)
521 _omap3_noncore_dpll_stop(clk);
523 clkdm_clk_disable(clk->clkdm, clk);
528 /* Non-CORE DPLL rate set code */
531 * omap3_noncore_dpll_set_rate - set non-core DPLL rate
532 * @clk: struct clk * of DPLL to set
533 * @rate: rounded target rate
535 * Set the DPLL CLKOUT to the target rate. If the DPLL can enter
536 * low-power bypass, and the target rate is the bypass source clock
537 * rate, then configure the DPLL for bypass. Otherwise, round the
538 * target rate if it hasn't been done already, then program and lock
539 * the DPLL. Returns -EINVAL upon error, or 0 upon success.
541 #ifdef CONFIG_COMMON_CLK
542 int omap3_noncore_dpll_set_rate(struct clk_hw *hw, unsigned long rate,
543 unsigned long parent_rate)
545 struct clk_hw_omap *clk = to_clk_hw_omap(hw);
546 struct clk *new_parent = NULL;
548 struct dpll_data *dd;
558 __clk_prepare(dd->clk_bypass);
559 clk_enable(dd->clk_bypass);
560 __clk_prepare(dd->clk_ref);
561 clk_enable(dd->clk_ref);
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));
568 ret = _omap3_noncore_dpll_bypass(clk);
570 new_parent = dd->clk_bypass;
572 if (dd->last_rounded_rate != rate)
573 rate = __clk_round_rate(hw->clk, rate);
575 if (dd->last_rounded_rate == 0)
578 /* No freqsel on OMAP4 and OMAP3630 */
579 if (!cpu_is_omap44xx() && !cpu_is_omap3630()) {
580 freqsel = _omap3_dpll_compute_freqsel(clk,
586 pr_debug("%s: %s: set rate: locking rate to %lu.\n",
587 __func__, __clk_get_name(hw->clk), rate);
589 ret = omap3_noncore_dpll_program(clk, dd->last_rounded_m,
590 dd->last_rounded_n, freqsel);
592 new_parent = dd->clk_ref;
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
602 __clk_reparent(hw->clk, new_parent);
604 clk_disable(dd->clk_ref);
605 __clk_unprepare(dd->clk_ref);
606 clk_disable(dd->clk_bypass);
607 __clk_unprepare(dd->clk_bypass);
612 int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
614 struct clk *new_parent = NULL;
615 unsigned long hw_rate, bypass_rate;
617 struct dpll_data *dd;
627 hw_rate = (clk->recalc) ? clk->recalc(clk) : omap2_get_dpll_rate(clk);
632 * Ensure both the bypass and ref clocks are enabled prior to
633 * doing anything; we need the bypass clock running to reprogram
636 omap2_clk_enable(dd->clk_bypass);
637 omap2_clk_enable(dd->clk_ref);
639 bypass_rate = __clk_get_rate(dd->clk_bypass);
640 if (bypass_rate == rate &&
641 (clk->dpll_data->modes & (1 << DPLL_LOW_POWER_BYPASS))) {
642 pr_debug("clock: %s: set rate: entering bypass.\n", clk->name);
644 ret = _omap3_noncore_dpll_bypass(clk);
646 new_parent = dd->clk_bypass;
648 if (dd->last_rounded_rate != rate)
649 rate = clk->round_rate(clk, rate);
651 if (dd->last_rounded_rate == 0)
654 /* No freqsel on OMAP4 and OMAP3630 */
655 if (!soc_is_am33xx() && !cpu_is_omap44xx() && !cpu_is_omap3630()) {
656 freqsel = _omap3_dpll_compute_freqsel(clk,
662 pr_debug("clock: %s: set rate: locking rate to %lu.\n",
663 __clk_get_name(clk), rate);
665 ret = omap3_noncore_dpll_program(clk, dd->last_rounded_m,
666 dd->last_rounded_n, freqsel);
668 new_parent = dd->clk_ref;
672 * Switch the parent clock in the hierarchy, and make sure
673 * that the new parent's usecount is correct. Note: we
674 * enable the new parent before disabling the old to avoid
675 * any unnecessary hardware disable->enable transitions.
678 omap2_clk_enable(new_parent);
679 omap2_clk_disable(clk->parent);
681 clk_reparent(clk, new_parent);
684 omap2_clk_disable(dd->clk_ref);
685 omap2_clk_disable(dd->clk_bypass);
691 /* DPLL autoidle read/set code */
694 * omap3_dpll_autoidle_read - read a DPLL's autoidle bits
695 * @clk: struct clk * of the DPLL to read
697 * Return the DPLL's autoidle bits, shifted down to bit 0. Returns
698 * -EINVAL if passed a null pointer or if the struct clk does not
699 * appear to refer to a DPLL.
701 #ifdef CONFIG_COMMON_CLK
702 u32 omap3_dpll_autoidle_read(struct clk_hw_omap *clk)
704 u32 omap3_dpll_autoidle_read(struct clk *clk)
707 const struct dpll_data *dd;
710 if (!clk || !clk->dpll_data)
715 if (!dd->autoidle_reg)
718 v = __raw_readl(dd->autoidle_reg);
719 v &= dd->autoidle_mask;
720 v >>= __ffs(dd->autoidle_mask);
726 * omap3_dpll_allow_idle - enable DPLL autoidle bits
727 * @clk: struct clk * of the DPLL to operate on
729 * Enable DPLL automatic idle control. This automatic idle mode
730 * switching takes effect only when the DPLL is locked, at least on
731 * OMAP3430. The DPLL will enter low-power stop when its downstream
732 * clocks are gated. No return value.
734 #ifdef CONFIG_COMMON_CLK
735 void omap3_dpll_allow_idle(struct clk_hw_omap *clk)
737 void omap3_dpll_allow_idle(struct clk *clk)
740 const struct dpll_data *dd;
743 if (!clk || !clk->dpll_data)
748 if (!dd->autoidle_reg) {
749 #ifndef CONFIG_COMMON_CLK
750 pr_debug("clock: DPLL %s: autoidle not supported\n",
751 __clk_get_name(clk));
757 * REVISIT: CORE DPLL can optionally enter low-power bypass
758 * by writing 0x5 instead of 0x1. Add some mechanism to
759 * optionally enter this mode.
761 v = __raw_readl(dd->autoidle_reg);
762 v &= ~dd->autoidle_mask;
763 v |= DPLL_AUTOIDLE_LOW_POWER_STOP << __ffs(dd->autoidle_mask);
764 __raw_writel(v, dd->autoidle_reg);
769 * omap3_dpll_deny_idle - prevent DPLL from automatically idling
770 * @clk: struct clk * of the DPLL to operate on
772 * Disable DPLL automatic idle control. No return value.
774 #ifdef CONFIG_COMMON_CLK
775 void omap3_dpll_deny_idle(struct clk_hw_omap *clk)
777 void omap3_dpll_deny_idle(struct clk *clk)
780 const struct dpll_data *dd;
783 if (!clk || !clk->dpll_data)
788 if (!dd->autoidle_reg) {
789 #ifndef CONFIG_COMMON_CLK
790 pr_debug("clock: DPLL %s: autoidle not supported\n",
791 __clk_get_name(clk));
796 v = __raw_readl(dd->autoidle_reg);
797 v &= ~dd->autoidle_mask;
798 v |= DPLL_AUTOIDLE_DISABLE << __ffs(dd->autoidle_mask);
799 __raw_writel(v, dd->autoidle_reg);
803 /* Clock control for DPLL outputs */
806 * omap3_clkoutx2_recalc - recalculate DPLL X2 output virtual clock rate
807 * @clk: DPLL output struct clk
809 * Using parent clock DPLL data, look up DPLL state. If locked, set our
810 * rate to the dpll_clk * 2; otherwise, just use dpll_clk.
812 #ifdef CONFIG_COMMON_CLK
813 unsigned long omap3_clkoutx2_recalc(struct clk_hw *hw,
814 unsigned long parent_rate)
816 const struct dpll_data *dd;
819 struct clk_hw_omap *pclk = NULL;
822 /* Walk up the parents of clk, looking for a DPLL */
825 parent = __clk_get_parent(hw->clk);
826 hw = __clk_get_hw(parent);
827 } while (hw && (__clk_get_flags(hw->clk) & CLK_IS_BASIC));
830 pclk = to_clk_hw_omap(hw);
831 } while (pclk && !pclk->dpll_data);
833 unsigned long omap3_clkoutx2_recalc(struct clk *clk)
835 const struct dpll_data *dd;
839 unsigned long parent_rate;
841 /* Walk up the parents of clk, looking for a DPLL */
842 pclk = __clk_get_parent(clk);
843 while (pclk && !pclk->dpll_data)
844 pclk = __clk_get_parent(pclk);
846 parent_rate = __clk_get_rate(__clk_get_parent(clk));
848 /* clk does not have a DPLL as a parent? error in the clock data */
854 dd = pclk->dpll_data;
856 WARN_ON(!dd->enable_mask);
858 v = __raw_readl(dd->control_reg) & dd->enable_mask;
859 v >>= __ffs(dd->enable_mask);
860 if ((v != OMAP3XXX_EN_DPLL_LOCKED) || (dd->flags & DPLL_J_TYPE))
863 rate = parent_rate * 2;
867 /* OMAP3/4 non-CORE DPLL clkops */
868 #ifdef CONFIG_COMMON_CLK
869 const struct clk_hw_omap_ops clkhwops_omap3_dpll = {
870 .allow_idle = omap3_dpll_allow_idle,
871 .deny_idle = omap3_dpll_deny_idle,
874 const struct clkops clkops_omap3_noncore_dpll_ops = {
875 .enable = omap3_noncore_dpll_enable,
876 .disable = omap3_noncore_dpll_disable,
877 .allow_idle = omap3_dpll_allow_idle,
878 .deny_idle = omap3_dpll_deny_idle,
881 const struct clkops clkops_omap3_core_dpll_ops = {
882 .allow_idle = omap3_dpll_allow_idle,
883 .deny_idle = omap3_dpll_deny_idle,