diff options
Diffstat (limited to 'arch/arm/mach-omap2/dpll44xx.c')
-rw-r--r-- | arch/arm/mach-omap2/dpll44xx.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/dpll44xx.c b/arch/arm/mach-omap2/dpll44xx.c index 4613f1e86988..535822fcf4bb 100644 --- a/arch/arm/mach-omap2/dpll44xx.c +++ b/arch/arm/mach-omap2/dpll44xx.c | |||
@@ -207,3 +207,44 @@ out: | |||
207 | 207 | ||
208 | return dd->last_rounded_rate; | 208 | return dd->last_rounded_rate; |
209 | } | 209 | } |
210 | |||
211 | /** | ||
212 | * omap4_dpll_regm4xen_determine_rate - determine rate for a DPLL | ||
213 | * @hw: pointer to the clock to determine rate for | ||
214 | * @rate: target rate for the DPLL | ||
215 | * @best_parent_rate: pointer for returning best parent rate | ||
216 | * @best_parent_clk: pointer for returning best parent clock | ||
217 | * | ||
218 | * Determines which DPLL mode to use for reaching a desired rate. | ||
219 | * Checks whether the DPLL shall be in bypass or locked mode, and if | ||
220 | * locked, calculates the M,N values for the DPLL via round-rate. | ||
221 | * Returns a positive clock rate with success, negative error value | ||
222 | * in failure. | ||
223 | */ | ||
224 | long omap4_dpll_regm4xen_determine_rate(struct clk_hw *hw, unsigned long rate, | ||
225 | unsigned long *best_parent_rate, | ||
226 | struct clk **best_parent_clk) | ||
227 | { | ||
228 | struct clk_hw_omap *clk = to_clk_hw_omap(hw); | ||
229 | struct dpll_data *dd; | ||
230 | |||
231 | if (!hw || !rate) | ||
232 | return -EINVAL; | ||
233 | |||
234 | dd = clk->dpll_data; | ||
235 | if (!dd) | ||
236 | return -EINVAL; | ||
237 | |||
238 | if (__clk_get_rate(dd->clk_bypass) == rate && | ||
239 | (dd->modes & (1 << DPLL_LOW_POWER_BYPASS))) { | ||
240 | *best_parent_clk = dd->clk_bypass; | ||
241 | } else { | ||
242 | rate = omap4_dpll_regm4xen_round_rate(hw, rate, | ||
243 | best_parent_rate); | ||
244 | *best_parent_clk = dd->clk_ref; | ||
245 | } | ||
246 | |||
247 | *best_parent_rate = rate; | ||
248 | |||
249 | return rate; | ||
250 | } | ||