Skip to content

Commit f52f000

Browse files
TE-N-ShengjiuWangabelvesa
authored andcommitted
clk: imx: pll14xx: change naming of fvco to fout
pll14xx_calc_rate() output the fout clock not the fvco clock The relation of fvco and fout is: fout = fvco / (1 << sdiv) So use correct naming for the clock. Signed-off-by: Shengjiu Wang <[email protected]> Reviewed-by: Peng Fan <[email protected]> Reviewed-by: Marco Felsch <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Abel Vesa <[email protected]>
1 parent 3f5f63a commit f52f000

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

drivers/clk/imx/clk-pll14xx.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ static const struct imx_pll14xx_rate_table *imx_get_pll_settings(
104104
static long pll14xx_calc_rate(struct clk_pll14xx *pll, int mdiv, int pdiv,
105105
int sdiv, int kdiv, unsigned long prate)
106106
{
107-
u64 fvco = prate;
107+
u64 fout = prate;
108108

109-
/* fvco = (m * 65536 + k) * Fin / (p * 65536) */
110-
fvco *= (mdiv * 65536 + kdiv);
109+
/* fout = (m * 65536 + k) * Fin / (p * 65536) / (1 << sdiv) */
110+
fout *= (mdiv * 65536 + kdiv);
111111
pdiv *= 65536;
112112

113-
do_div(fvco, pdiv << sdiv);
113+
do_div(fout, pdiv << sdiv);
114114

115-
return fvco;
115+
return fout;
116116
}
117117

118118
static long pll1443x_calc_kdiv(int mdiv, int pdiv, int sdiv,
@@ -131,7 +131,7 @@ static void imx_pll14xx_calc_settings(struct clk_pll14xx *pll, unsigned long rat
131131
{
132132
u32 pll_div_ctl0, pll_div_ctl1;
133133
int mdiv, pdiv, sdiv, kdiv;
134-
long fvco, rate_min, rate_max, dist, best = LONG_MAX;
134+
long fout, rate_min, rate_max, dist, best = LONG_MAX;
135135
const struct imx_pll14xx_rate_table *tt;
136136

137137
/*
@@ -143,6 +143,7 @@ static void imx_pll14xx_calc_settings(struct clk_pll14xx *pll, unsigned long rat
143143
* d) -32768 <= k <= 32767
144144
*
145145
* fvco = (m * 65536 + k) * prate / (p * 65536)
146+
* fout = (m * 65536 + k) * prate / (p * 65536) / (1 << sdiv)
146147
*/
147148

148149
/* First try if we can get the desired rate from one of the static entries */
@@ -173,8 +174,8 @@ static void imx_pll14xx_calc_settings(struct clk_pll14xx *pll, unsigned long rat
173174
pr_debug("%s: in=%ld, want=%ld Only adjust kdiv %ld -> %d\n",
174175
clk_hw_get_name(&pll->hw), prate, rate,
175176
FIELD_GET(KDIV_MASK, pll_div_ctl1), kdiv);
176-
fvco = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate);
177-
t->rate = (unsigned int)fvco;
177+
fout = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate);
178+
t->rate = (unsigned int)fout;
178179
t->mdiv = mdiv;
179180
t->pdiv = pdiv;
180181
t->sdiv = sdiv;
@@ -190,13 +191,13 @@ static void imx_pll14xx_calc_settings(struct clk_pll14xx *pll, unsigned long rat
190191
mdiv = clamp(mdiv, 64, 1023);
191192

192193
kdiv = pll1443x_calc_kdiv(mdiv, pdiv, sdiv, rate, prate);
193-
fvco = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate);
194+
fout = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate);
194195

195196
/* best match */
196-
dist = abs((long)rate - (long)fvco);
197+
dist = abs((long)rate - (long)fout);
197198
if (dist < best) {
198199
best = dist;
199-
t->rate = (unsigned int)fvco;
200+
t->rate = (unsigned int)fout;
200201
t->mdiv = mdiv;
201202
t->pdiv = pdiv;
202203
t->sdiv = sdiv;

0 commit comments

Comments
 (0)