mirror of
https://github.com/torvalds/linux.git
synced 2026-05-29 17:43:52 +02:00
clk: ti: dpll: convert from round_rate() to determine_rate()
The round_rate() clk ops is deprecated, so migrate this driver from round_rate() to determine_rate(). Part of these changes were done using the Coccinelle semantic patch on the cover letter of this series, and the rest of the changes were manually done. omap4_dpll_regm4xen_round_rate() is now only called by omap4_dpll_regm4xen_determine_rate(), so let's merge that functionality into one function. This is needed for another cleanup to completely remove the round_rate() clk ops from the clk core. Tested-by: Anddreas Kemnade <andreas@kemnade.info> # OMAP3 GTA04, OMAP4 Panda Reviewed-by: Kevin Hilman <khilman@baylibre.com> Tested-by: Kevin Hilman <khilman@baylibre.com> Signed-off-by: Brian Masney <bmasney@redhat.com>
This commit is contained in:
parent
fa55aea3dc
commit
e465ad7ef5
|
|
@ -268,10 +268,9 @@ unsigned long omap2_get_dpll_rate(struct clk_hw_omap *clk)
|
|||
/* DPLL rate rounding code */
|
||||
|
||||
/**
|
||||
* omap2_dpll_round_rate - round a target rate for an OMAP DPLL
|
||||
* omap2_dpll_determine_rate - round a target rate for an OMAP DPLL
|
||||
* @hw: struct clk_hw containing the struct clk * for a DPLL
|
||||
* @target_rate: desired DPLL clock rate
|
||||
* @parent_rate: parent's DPLL clock rate
|
||||
* @req: rate request
|
||||
*
|
||||
* Given a DPLL and a desired target rate, round the target rate to a
|
||||
* possible, programmable rate for this DPLL. Attempts to select the
|
||||
|
|
@ -280,8 +279,7 @@ unsigned long omap2_get_dpll_rate(struct clk_hw_omap *clk)
|
|||
* (expensive) function again. Returns -EINVAL if the target rate
|
||||
* cannot be rounded, or the rounded rate upon success.
|
||||
*/
|
||||
long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate,
|
||||
unsigned long *parent_rate)
|
||||
int omap2_dpll_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
|
||||
{
|
||||
struct clk_hw_omap *clk = to_clk_hw_omap(hw);
|
||||
int m, n, r, scaled_max_m;
|
||||
|
|
@ -299,15 +297,15 @@ long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate,
|
|||
|
||||
dd = clk->dpll_data;
|
||||
|
||||
if (dd->max_rate && target_rate > dd->max_rate)
|
||||
target_rate = dd->max_rate;
|
||||
if (dd->max_rate && req->rate > dd->max_rate)
|
||||
req->rate = dd->max_rate;
|
||||
|
||||
ref_rate = clk_hw_get_rate(dd->clk_ref);
|
||||
clk_name = clk_hw_get_name(hw);
|
||||
pr_debug("clock: %s: starting DPLL round_rate, target rate %lu\n",
|
||||
clk_name, target_rate);
|
||||
clk_name, req->rate);
|
||||
|
||||
scaled_rt_rp = target_rate / (ref_rate / DPLL_SCALE_FACTOR);
|
||||
scaled_rt_rp = req->rate / (ref_rate / DPLL_SCALE_FACTOR);
|
||||
scaled_max_m = dd->max_multiplier * DPLL_SCALE_FACTOR;
|
||||
|
||||
dd->last_rounded_rate = 0;
|
||||
|
|
@ -332,7 +330,7 @@ long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate,
|
|||
if (m > scaled_max_m)
|
||||
break;
|
||||
|
||||
r = _dpll_test_mult(&m, n, &new_rate, target_rate,
|
||||
r = _dpll_test_mult(&m, n, &new_rate, req->rate,
|
||||
ref_rate);
|
||||
|
||||
/* m can't be set low enough for this n - try with a larger n */
|
||||
|
|
@ -340,7 +338,7 @@ long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate,
|
|||
continue;
|
||||
|
||||
/* skip rates above our target rate */
|
||||
delta = target_rate - new_rate;
|
||||
delta = req->rate - new_rate;
|
||||
if (delta < 0)
|
||||
continue;
|
||||
|
||||
|
|
@ -359,13 +357,15 @@ long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate,
|
|||
|
||||
if (prev_min_delta == LONG_MAX) {
|
||||
pr_debug("clock: %s: cannot round to rate %lu\n",
|
||||
clk_name, target_rate);
|
||||
clk_name, req->rate);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dd->last_rounded_m = min_delta_m;
|
||||
dd->last_rounded_n = min_delta_n;
|
||||
dd->last_rounded_rate = target_rate - prev_min_delta;
|
||||
dd->last_rounded_rate = req->rate - prev_min_delta;
|
||||
|
||||
return dd->last_rounded_rate;
|
||||
req->rate = dd->last_rounded_rate;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -273,8 +273,7 @@ int omap3_noncore_dpll_set_rate_and_parent(struct clk_hw *hw,
|
|||
u8 index);
|
||||
int omap3_noncore_dpll_determine_rate(struct clk_hw *hw,
|
||||
struct clk_rate_request *req);
|
||||
long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate,
|
||||
unsigned long *parent_rate);
|
||||
int omap2_dpll_determine_rate(struct clk_hw *hw, struct clk_rate_request *req);
|
||||
unsigned long omap3_clkoutx2_recalc(struct clk_hw *hw,
|
||||
unsigned long parent_rate);
|
||||
|
||||
|
|
@ -296,9 +295,6 @@ void omap3_clk_lock_dpll5(void);
|
|||
|
||||
unsigned long omap4_dpll_regm4xen_recalc(struct clk_hw *hw,
|
||||
unsigned long parent_rate);
|
||||
long omap4_dpll_regm4xen_round_rate(struct clk_hw *hw,
|
||||
unsigned long target_rate,
|
||||
unsigned long *parent_rate);
|
||||
int omap4_dpll_regm4xen_determine_rate(struct clk_hw *hw,
|
||||
struct clk_rate_request *req);
|
||||
int omap2_clk_for_each(int (*fn)(struct clk_hw_omap *hw));
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ const struct clk_hw_omap_ops clkhwops_omap3_dpll = {};
|
|||
static const struct clk_ops omap2_dpll_core_ck_ops = {
|
||||
.get_parent = &omap2_init_dpll_parent,
|
||||
.recalc_rate = &omap2_dpllcore_recalc,
|
||||
.round_rate = &omap2_dpll_round_rate,
|
||||
.determine_rate = &omap2_dpll_determine_rate,
|
||||
.set_rate = &omap2_reprogram_dpllcore,
|
||||
};
|
||||
#else
|
||||
|
|
@ -88,7 +88,7 @@ static const struct clk_ops omap2_dpll_core_ck_ops = {};
|
|||
static const struct clk_ops omap3_dpll_core_ck_ops = {
|
||||
.get_parent = &omap2_init_dpll_parent,
|
||||
.recalc_rate = &omap3_dpll_recalc,
|
||||
.round_rate = &omap2_dpll_round_rate,
|
||||
.determine_rate = &omap2_dpll_determine_rate,
|
||||
};
|
||||
|
||||
static const struct clk_ops omap3_dpll_ck_ops = {
|
||||
|
|
|
|||
|
|
@ -587,6 +587,7 @@ int omap3_noncore_dpll_determine_rate(struct clk_hw *hw,
|
|||
{
|
||||
struct clk_hw_omap *clk = to_clk_hw_omap(hw);
|
||||
struct dpll_data *dd;
|
||||
int ret;
|
||||
|
||||
if (!req->rate)
|
||||
return -EINVAL;
|
||||
|
|
@ -599,8 +600,10 @@ int omap3_noncore_dpll_determine_rate(struct clk_hw *hw,
|
|||
(dd->modes & (1 << DPLL_LOW_POWER_BYPASS))) {
|
||||
req->best_parent_hw = dd->clk_bypass;
|
||||
} else {
|
||||
req->rate = omap2_dpll_round_rate(hw, req->rate,
|
||||
&req->best_parent_rate);
|
||||
ret = omap2_dpll_determine_rate(hw, req);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
req->best_parent_hw = dd->clk_ref;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -133,61 +133,6 @@ unsigned long omap4_dpll_regm4xen_recalc(struct clk_hw *hw,
|
|||
return rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* omap4_dpll_regm4xen_round_rate - round DPLL rate, considering REGM4XEN bit
|
||||
* @hw: struct hw_clk containing the struct clk * of the DPLL to round a rate for
|
||||
* @target_rate: the desired rate of the DPLL
|
||||
* @parent_rate: clock rate of the DPLL parent
|
||||
*
|
||||
* Compute the rate that would be programmed into the DPLL hardware
|
||||
* for @clk if set_rate() were to be provided with the rate
|
||||
* @target_rate. Takes the REGM4XEN bit into consideration, which is
|
||||
* needed for the OMAP4 ABE DPLL. Returns the rounded rate (before
|
||||
* M-dividers) upon success, -EINVAL if @clk is null or not a DPLL, or
|
||||
* ~0 if an error occurred in omap2_dpll_round_rate().
|
||||
*/
|
||||
long omap4_dpll_regm4xen_round_rate(struct clk_hw *hw,
|
||||
unsigned long target_rate,
|
||||
unsigned long *parent_rate)
|
||||
{
|
||||
struct clk_hw_omap *clk = to_clk_hw_omap(hw);
|
||||
struct dpll_data *dd;
|
||||
long r;
|
||||
|
||||
if (!clk || !clk->dpll_data)
|
||||
return -EINVAL;
|
||||
|
||||
dd = clk->dpll_data;
|
||||
|
||||
dd->last_rounded_m4xen = 0;
|
||||
|
||||
/*
|
||||
* First try to compute the DPLL configuration for
|
||||
* target rate without using the 4X multiplier.
|
||||
*/
|
||||
r = omap2_dpll_round_rate(hw, target_rate, NULL);
|
||||
if (r != ~0)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* If we did not find a valid DPLL configuration, try again, but
|
||||
* this time see if using the 4X multiplier can help. Enabling the
|
||||
* 4X multiplier is equivalent to dividing the target rate by 4.
|
||||
*/
|
||||
r = omap2_dpll_round_rate(hw, target_rate / OMAP4430_REGM4XEN_MULT,
|
||||
NULL);
|
||||
if (r == ~0)
|
||||
return r;
|
||||
|
||||
dd->last_rounded_rate *= OMAP4430_REGM4XEN_MULT;
|
||||
dd->last_rounded_m4xen = 1;
|
||||
|
||||
out:
|
||||
omap4_dpll_lpmode_recalc(dd);
|
||||
|
||||
return dd->last_rounded_rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* omap4_dpll_regm4xen_determine_rate - determine rate for a DPLL
|
||||
* @hw: pointer to the clock to determine rate for
|
||||
|
|
@ -195,7 +140,7 @@ long omap4_dpll_regm4xen_round_rate(struct clk_hw *hw,
|
|||
*
|
||||
* Determines which DPLL mode to use for reaching a desired rate.
|
||||
* Checks whether the DPLL shall be in bypass or locked mode, and if
|
||||
* locked, calculates the M,N values for the DPLL via round-rate.
|
||||
* locked, calculates the M,N values for the DPLL.
|
||||
* Returns 0 on success and a negative error value otherwise.
|
||||
*/
|
||||
int omap4_dpll_regm4xen_determine_rate(struct clk_hw *hw,
|
||||
|
|
@ -215,8 +160,36 @@ int omap4_dpll_regm4xen_determine_rate(struct clk_hw *hw,
|
|||
(dd->modes & (1 << DPLL_LOW_POWER_BYPASS))) {
|
||||
req->best_parent_hw = dd->clk_bypass;
|
||||
} else {
|
||||
req->rate = omap4_dpll_regm4xen_round_rate(hw, req->rate,
|
||||
&req->best_parent_rate);
|
||||
struct clk_rate_request tmp_req;
|
||||
long r;
|
||||
|
||||
clk_hw_init_rate_request(hw, &tmp_req, req->rate);
|
||||
dd->last_rounded_m4xen = 0;
|
||||
|
||||
/*
|
||||
* First try to compute the DPLL configuration for
|
||||
* target rate without using the 4X multiplier.
|
||||
*/
|
||||
|
||||
r = omap2_dpll_determine_rate(hw, &tmp_req);
|
||||
if (r < 0) {
|
||||
/*
|
||||
* If we did not find a valid DPLL configuration, try again, but
|
||||
* this time see if using the 4X multiplier can help. Enabling the
|
||||
* 4X multiplier is equivalent to dividing the target rate by 4.
|
||||
*/
|
||||
tmp_req.rate /= OMAP4430_REGM4XEN_MULT;
|
||||
r = omap2_dpll_determine_rate(hw, &tmp_req);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
dd->last_rounded_rate *= OMAP4430_REGM4XEN_MULT;
|
||||
dd->last_rounded_m4xen = 1;
|
||||
}
|
||||
|
||||
omap4_dpll_lpmode_recalc(dd);
|
||||
|
||||
req->rate = dd->last_rounded_rate;
|
||||
req->best_parent_hw = dd->clk_ref;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,14 +34,14 @@ struct clk_omap_reg {
|
|||
* @clk_ref: struct clk_hw pointer to the clock's reference clock input
|
||||
* @control_reg: register containing the DPLL mode bitfield
|
||||
* @enable_mask: mask of the DPLL mode bitfield in @control_reg
|
||||
* @last_rounded_rate: cache of the last rate result of omap2_dpll_round_rate()
|
||||
* @last_rounded_m: cache of the last M result of omap2_dpll_round_rate()
|
||||
* @last_rounded_rate: cache of the last rate result of omap2_dpll_determine_rate()
|
||||
* @last_rounded_m: cache of the last M result of omap2_dpll_determine_rate()
|
||||
* @last_rounded_m4xen: cache of the last M4X result of
|
||||
* omap4_dpll_regm4xen_round_rate()
|
||||
* omap4_dpll_regm4xen_determine_rate()
|
||||
* @last_rounded_lpmode: cache of the last lpmode result of
|
||||
* omap4_dpll_lpmode_recalc()
|
||||
* @max_multiplier: maximum valid non-bypass multiplier value (actual)
|
||||
* @last_rounded_n: cache of the last N result of omap2_dpll_round_rate()
|
||||
* @last_rounded_n: cache of the last N result of omap2_dpll_determine_rate()
|
||||
* @min_divider: minimum valid non-bypass divider value (actual)
|
||||
* @max_divider: maximum valid non-bypass divider value (actual)
|
||||
* @max_rate: maximum clock rate for the DPLL
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user