Skip to content

Commit 83501ff

Browse files
Tero KristoPaul Walmsley
authored andcommitted
ARM: OMAP4: clock: add support for determine_rate for omap4 regm4xen DPLL
Similarly to OMAP3 noncore DPLL, the implementation of this DPLL clock type is wrong. This patch adds basic functionality for determine_rate for this clock type which will be taken into use in the patches following later. Signed-off-by: Tero Kristo <t-kristo@ti.com> Signed-off-by: Paul Walmsley <paul@pwsan.com>
1 parent d539efa commit 83501ff

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

arch/arm/mach-omap2/dpll44xx.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,44 @@ long omap4_dpll_regm4xen_round_rate(struct clk_hw *hw,
207207

208208
return dd->last_rounded_rate;
209209
}
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+
}

include/linux/clk/ti.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ unsigned long omap4_dpll_regm4xen_recalc(struct clk_hw *hw,
270270
long omap4_dpll_regm4xen_round_rate(struct clk_hw *hw,
271271
unsigned long target_rate,
272272
unsigned long *parent_rate);
273+
long omap4_dpll_regm4xen_determine_rate(struct clk_hw *hw,
274+
unsigned long rate,
275+
unsigned long *best_parent_rate,
276+
struct clk **best_parent_clk);
273277
u8 omap2_init_dpll_parent(struct clk_hw *hw);
274278
unsigned long omap3_dpll_recalc(struct clk_hw *hw, unsigned long parent_rate);
275279
long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate,

0 commit comments

Comments
 (0)