Lines Matching +full:bypass +full:- +full:enable
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2005-2008 Texas Instruments, Inc.
6 * Copyright (C) 2004-2010 Nokia Corporation
9 * Richard Woodruff <r-woodruff2@ti.com>
17 #include <linux/clk-provider.h>
30 #define DPLL_MULT_UNDERFLOW -1
51 #define DPLL_FINT_UNDERFLOW -1
52 #define DPLL_FINT_INVALID -2
57 * _dpll_test_fint - test whether an Fint value is valid for the DPLL
63 * Correction". Returns 0 if OK, -1 if the enclosing loop can terminate
64 * (assuming that it is counting N upwards), or -2 if the enclosing loop
73 dd = clk->dpll_data; in _dpll_test_fint()
76 fint = clk_hw_get_rate(clk_hw_get_parent(&clk->hw)) / n; in _dpll_test_fint()
78 if (dd->flags & DPLL_J_TYPE) { in _dpll_test_fint()
82 fint_min = ti_clk_get_features()->fint_min; in _dpll_test_fint()
83 fint_max = ti_clk_get_features()->fint_max; in _dpll_test_fint()
91 if (fint < ti_clk_get_features()->fint_min) { in _dpll_test_fint()
94 dd->max_divider = n; in _dpll_test_fint()
96 } else if (fint > ti_clk_get_features()->fint_max) { in _dpll_test_fint()
99 dd->min_divider = n; in _dpll_test_fint()
101 } else if (fint > ti_clk_get_features()->fint_band1_max && in _dpll_test_fint()
102 fint < ti_clk_get_features()->fint_band2_min) { in _dpll_test_fint()
121 * _dpll_test_mult - test a DPLL multiplier value
133 * a non-scaled m upon return. This non-scaled m will result in a
137 * non-scaled m attempted to underflow, which can allow the calling
157 (*m)--; in _dpll_test_mult()
175 * _omap2_dpll_is_in_bypass - check if DPLL is in bypass mode or not
176 * @v: bitfield value of the DPLL enable
178 * Checks given DPLL enable bitfield to see whether the DPLL is in bypass
179 * mode or not. Returns 1 if the DPLL is in bypass, 0 otherwise.
185 mask = ti_clk_get_features()->dpll_bypass_vals; in _omap2_dpll_is_in_bypass()
188 * Each set bit in the mask corresponds to a bypass value equal in _omap2_dpll_is_in_bypass()
189 * to the bitshift. Go through each set-bit in the mask and in _omap2_dpll_is_in_bypass()
209 dd = clk->dpll_data; in omap2_init_dpll_parent()
211 return -EINVAL; in omap2_init_dpll_parent()
213 v = ti_clk_ll_ops->clk_readl(&dd->control_reg); in omap2_init_dpll_parent()
214 v &= dd->enable_mask; in omap2_init_dpll_parent()
215 v >>= __ffs(dd->enable_mask); in omap2_init_dpll_parent()
217 /* Reparent the struct clk in case the dpll is in bypass */ in omap2_init_dpll_parent()
225 * omap2_get_dpll_rate - returns the current DPLL CLKOUT rate
228 * DPLLs can be locked or bypassed - basically, enabled or disabled.
231 * or sys_clk. Bypass rates on OMAP3 depend on the DPLL: DPLLs 1 and
233 * (generated by DPLL3), while DPLL 3, 4, and 5 bypass rates are sys_clk.
235 * locked, or the appropriate bypass rate if the DPLL is bypassed, or 0
244 dd = clk->dpll_data; in omap2_get_dpll_rate()
248 /* Return bypass rate if DPLL is bypassed */ in omap2_get_dpll_rate()
249 v = ti_clk_ll_ops->clk_readl(&dd->control_reg); in omap2_get_dpll_rate()
250 v &= dd->enable_mask; in omap2_get_dpll_rate()
251 v >>= __ffs(dd->enable_mask); in omap2_get_dpll_rate()
254 return clk_hw_get_rate(dd->clk_bypass); in omap2_get_dpll_rate()
256 v = ti_clk_ll_ops->clk_readl(&dd->mult_div1_reg); in omap2_get_dpll_rate()
257 dpll_mult = v & dd->mult_mask; in omap2_get_dpll_rate()
258 dpll_mult >>= __ffs(dd->mult_mask); in omap2_get_dpll_rate()
259 dpll_div = v & dd->div1_mask; in omap2_get_dpll_rate()
260 dpll_div >>= __ffs(dd->div1_mask); in omap2_get_dpll_rate()
262 dpll_clk = (u64)clk_hw_get_rate(dd->clk_ref) * dpll_mult; in omap2_get_dpll_rate()
271 * omap2_dpll_round_rate - round a target rate for an OMAP DPLL
297 if (!clk || !clk->dpll_data) in omap2_dpll_round_rate()
300 dd = clk->dpll_data; in omap2_dpll_round_rate()
302 if (dd->max_rate && target_rate > dd->max_rate) in omap2_dpll_round_rate()
303 target_rate = dd->max_rate; in omap2_dpll_round_rate()
305 ref_rate = clk_hw_get_rate(dd->clk_ref); in omap2_dpll_round_rate()
311 scaled_max_m = dd->max_multiplier * DPLL_SCALE_FACTOR; in omap2_dpll_round_rate()
313 dd->last_rounded_rate = 0; in omap2_dpll_round_rate()
315 for (n = dd->min_divider; n <= dd->max_divider; n++) { in omap2_dpll_round_rate()
338 /* m can't be set low enough for this n - try with a larger n */ in omap2_dpll_round_rate()
343 delta = target_rate - new_rate; in omap2_dpll_round_rate()
366 dd->last_rounded_m = min_delta_m; in omap2_dpll_round_rate()
367 dd->last_rounded_n = min_delta_n; in omap2_dpll_round_rate()
368 dd->last_rounded_rate = target_rate - prev_min_delta; in omap2_dpll_round_rate()
370 return dd->last_rounded_rate; in omap2_dpll_round_rate()