Skip to content

Commit d7fd3f9

Browse files
wqyoungbebarino
authored andcommitted
clk: zynqmp: move zynqmp_pll_set_mode out of round_rate callback
The round_rate callback should only perform rate calculation and not involve calling zynqmp_pll_set_mode to change the pll mode. So let's move zynqmp_pll_set_mode out of round_rate and to set_rate callback. Fixes: 3fde0e1 ("drivers: clk: Add ZynqMP clock driver") Reported-by: Laurent Pinchart <[email protected]> Signed-off-by: Quanyang Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 21f2375 commit d7fd3f9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/clk/zynqmp/pll.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ static long zynqmp_pll_round_rate(struct clk_hw *hw, unsigned long rate,
100100
/* Enable the fractional mode if needed */
101101
rate_div = (rate * FRAC_DIV) / *prate;
102102
f = rate_div % FRAC_DIV;
103-
zynqmp_pll_set_mode(hw, !!f);
104-
105-
if (zynqmp_pll_get_mode(hw) == PLL_MODE_FRAC) {
103+
if (f) {
106104
if (rate > PS_PLL_VCO_MAX) {
107105
fbdiv = rate / PS_PLL_VCO_MAX;
108106
rate = rate / (fbdiv + 1);
@@ -173,10 +171,12 @@ static int zynqmp_pll_set_rate(struct clk_hw *hw, unsigned long rate,
173171
long rate_div, frac, m, f;
174172
int ret;
175173

176-
if (zynqmp_pll_get_mode(hw) == PLL_MODE_FRAC) {
177-
rate_div = (rate * FRAC_DIV) / parent_rate;
174+
rate_div = (rate * FRAC_DIV) / parent_rate;
175+
f = rate_div % FRAC_DIV;
176+
zynqmp_pll_set_mode(hw, !!f);
177+
178+
if (f) {
178179
m = rate_div / FRAC_DIV;
179-
f = rate_div % FRAC_DIV;
180180
m = clamp_t(u32, m, (PLL_FBDIV_MIN), (PLL_FBDIV_MAX));
181181
rate = parent_rate * m;
182182
frac = (parent_rate * f) / FRAC_DIV;

0 commit comments

Comments
 (0)