Skip to content

Commit 5ebaf9f

Browse files
Liu Yingabelvesa
authored andcommitted
clk: imx: clk-fracn-gppll: Return rate in rate table properly in ->recalc_rate()
The PLL parameters in rate table should be directly compared with those read from PLL registers instead of the cooked ones. Fixes: 1b26cb8 ("clk: imx: support fracn gppll") Cc: Abel Vesa <[email protected]> Cc: Michael Turquette <[email protected]> Cc: Stephen Boyd <[email protected]> Cc: Shawn Guo <[email protected]> Cc: Sascha Hauer <[email protected]> Cc: Pengutronix Kernel Team <[email protected]> Cc: Fabio Estevam <[email protected]> Cc: NXP Linux Team <[email protected]> Cc: Peng Fan <[email protected]> Signed-off-by: Liu Ying <[email protected]> Reviewed-by: Peng Fan <[email protected]> Reviewed-by: Abel Vesa <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Abel Vesa <[email protected]>
1 parent 044034e commit 5ebaf9f

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

drivers/clk/imx/clk-fracn-gppll.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,7 @@ static unsigned long clk_fracn_gppll_recalc_rate(struct clk_hw *hw, unsigned lon
131131
mfi = FIELD_GET(PLL_MFI_MASK, pll_div);
132132

133133
rdiv = FIELD_GET(PLL_RDIV_MASK, pll_div);
134-
rdiv = rdiv + 1;
135134
odiv = FIELD_GET(PLL_ODIV_MASK, pll_div);
136-
switch (odiv) {
137-
case 0:
138-
odiv = 2;
139-
break;
140-
case 1:
141-
odiv = 3;
142-
break;
143-
default:
144-
break;
145-
}
146135

147136
/*
148137
* Sometimes, the recalculated rate has deviation due to
@@ -160,6 +149,19 @@ static unsigned long clk_fracn_gppll_recalc_rate(struct clk_hw *hw, unsigned lon
160149
if (rate)
161150
return (unsigned long)rate;
162151

152+
rdiv = rdiv + 1;
153+
154+
switch (odiv) {
155+
case 0:
156+
odiv = 2;
157+
break;
158+
case 1:
159+
odiv = 3;
160+
break;
161+
default:
162+
break;
163+
}
164+
163165
/* Fvco = Fref * (MFI + MFN / MFD) */
164166
fvco = fvco * mfi * mfd + fvco * mfn;
165167
do_div(fvco, mfd * rdiv * odiv);

0 commit comments

Comments
 (0)