Skip to content

Commit ee4adbb

Browse files
Taniya Dasbebarino
authored andcommitted
clk: qcom: clk-alpha-pll: Refactor trion PLL
Remove duplicate function for calculating the round rate of PLL and also update the trion pll ops to use the common function. Signed-off-by: Taniya Das <[email protected]> Signed-off-by: Venkata Narendra Kumar Gutta <[email protected]> Signed-off-by: Vinod Koul <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Reviewed-by: Bryan O'Donoghue <[email protected]> Tested-by: Bryan O'Donoghue <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 57d98e8 commit ee4adbb

File tree

1 file changed

+6
-27
lines changed

1 file changed

+6
-27
lines changed

drivers/clk/qcom/clk-alpha-pll.c

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -845,33 +845,12 @@ static unsigned long
845845
clk_trion_pll_recalc_rate(struct clk_hw *hw, unsigned long parent_rate)
846846
{
847847
struct clk_alpha_pll *pll = to_clk_alpha_pll(hw);
848-
struct regmap *regmap = pll->clkr.regmap;
849-
u32 l, frac;
850-
u64 prate = parent_rate;
851-
852-
regmap_read(regmap, PLL_L_VAL(pll), &l);
853-
regmap_read(regmap, PLL_ALPHA_VAL(pll), &frac);
854-
855-
return alpha_pll_calc_rate(prate, l, frac, ALPHA_REG_16BIT_WIDTH);
856-
}
857-
858-
static long clk_trion_pll_round_rate(struct clk_hw *hw, unsigned long rate,
859-
unsigned long *prate)
860-
{
861-
struct clk_alpha_pll *pll = to_clk_alpha_pll(hw);
862-
unsigned long min_freq, max_freq;
863-
u32 l;
864-
u64 a;
865-
866-
rate = alpha_pll_round_rate(rate, *prate,
867-
&l, &a, ALPHA_REG_16BIT_WIDTH);
868-
if (!pll->vco_table || alpha_pll_find_vco(pll, rate))
869-
return rate;
848+
u32 l, frac, alpha_width = pll_alpha_width(pll);
870849

871-
min_freq = pll->vco_table[0].min_freq;
872-
max_freq = pll->vco_table[pll->num_vco - 1].max_freq;
850+
regmap_read(pll->clkr.regmap, PLL_L_VAL(pll), &l);
851+
regmap_read(pll->clkr.regmap, PLL_ALPHA_VAL(pll), &frac);
873852

874-
return clamp(rate, min_freq, max_freq);
853+
return alpha_pll_calc_rate(parent_rate, l, frac, alpha_width);
875854
}
876855

877856
const struct clk_ops clk_alpha_pll_fixed_ops = {
@@ -917,7 +896,7 @@ const struct clk_ops clk_trion_fixed_pll_ops = {
917896
.disable = clk_trion_pll_disable,
918897
.is_enabled = clk_trion_pll_is_enabled,
919898
.recalc_rate = clk_trion_pll_recalc_rate,
920-
.round_rate = clk_trion_pll_round_rate,
899+
.round_rate = clk_alpha_pll_round_rate,
921900
};
922901
EXPORT_SYMBOL_GPL(clk_trion_fixed_pll_ops);
923902

@@ -1173,7 +1152,7 @@ static int alpha_pll_fabia_set_rate(struct clk_hw *hw, unsigned long rate,
11731152
* Due to limited number of bits for fractional rate programming, the
11741153
* rounded up rate could be marginally higher than the requested rate.
11751154
*/
1176-
if (rrate > max || rrate < rate) {
1155+
if (rrate > (rate + PLL_RATE_MARGIN) || rrate < rate) {
11771156
pr_err("%s: Rounded rate %lu not within range [%lu, %lu)\n",
11781157
clk_hw_get_name(hw), rrate, rate, max);
11791158
return -EINVAL;

0 commit comments

Comments
 (0)