diff mbox series

clk: imx: pll14xx: change naming of fvco to fout

Message ID 1703068389-6130-1-git-send-email-shengjiu.wang@nxp.com (mailing list archive)
State Awaiting Upstream, archived
Headers show
Series clk: imx: pll14xx: change naming of fvco to fout | expand

Commit Message

Shengjiu Wang Dec. 20, 2023, 10:33 a.m. UTC
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 <shengjiu.wang@nxp.com>
---
 drivers/clk/imx/clk-pll14xx.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

Comments

Marco Felsch Dec. 20, 2023, 11:53 a.m. UTC | #1
Hi,

thanks for the patch.

On 23-12-20, Shengjiu Wang wrote:
> 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 <shengjiu.wang@nxp.com>

lgtm

Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>

> ---
>  drivers/clk/imx/clk-pll14xx.c | 23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/clk/imx/clk-pll14xx.c b/drivers/clk/imx/clk-pll14xx.c
> index 0d58d85c375e..d63564dbb12c 100644
> --- a/drivers/clk/imx/clk-pll14xx.c
> +++ b/drivers/clk/imx/clk-pll14xx.c
> @@ -104,15 +104,15 @@ static const struct imx_pll14xx_rate_table *imx_get_pll_settings(
>  static long pll14xx_calc_rate(struct clk_pll14xx *pll, int mdiv, int pdiv,
>  			      int sdiv, int kdiv, unsigned long prate)
>  {
> -	u64 fvco = prate;
> +	u64 fout = prate;
>  
> -	/* fvco = (m * 65536 + k) * Fin / (p * 65536) */
> -	fvco *= (mdiv * 65536 + kdiv);
> +	/* fout = (m * 65536 + k) * Fin / (p * 65536) / (1 << sdiv) */
> +	fout *= (mdiv * 65536 + kdiv);
>  	pdiv *= 65536;
>  
> -	do_div(fvco, pdiv << sdiv);
> +	do_div(fout, pdiv << sdiv);
>  
> -	return fvco;
> +	return fout;
>  }
>  
>  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
>  {
>  	u32 pll_div_ctl0, pll_div_ctl1;
>  	int mdiv, pdiv, sdiv, kdiv;
> -	long fvco, rate_min, rate_max, dist, best = LONG_MAX;
> +	long fout, rate_min, rate_max, dist, best = LONG_MAX;
>  	const struct imx_pll14xx_rate_table *tt;
>  
>  	/*
> @@ -143,6 +143,7 @@ static void imx_pll14xx_calc_settings(struct clk_pll14xx *pll, unsigned long rat
>  	 * d) -32768 <= k <= 32767
>  	 *
>  	 * fvco = (m * 65536 + k) * prate / (p * 65536)
> +	 * fout = (m * 65536 + k) * prate / (p * 65536) / (1 << sdiv)
>  	 */
>  
>  	/* 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
>  		pr_debug("%s: in=%ld, want=%ld Only adjust kdiv %ld -> %d\n",
>  			 clk_hw_get_name(&pll->hw), prate, rate,
>  			 FIELD_GET(KDIV_MASK, pll_div_ctl1), kdiv);
> -		fvco = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate);
> -		t->rate = (unsigned int)fvco;
> +		fout = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate);
> +		t->rate = (unsigned int)fout;
>  		t->mdiv = mdiv;
>  		t->pdiv = pdiv;
>  		t->sdiv = sdiv;
> @@ -190,13 +191,13 @@ static void imx_pll14xx_calc_settings(struct clk_pll14xx *pll, unsigned long rat
>  			mdiv = clamp(mdiv, 64, 1023);
>  
>  			kdiv = pll1443x_calc_kdiv(mdiv, pdiv, sdiv, rate, prate);
> -			fvco = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate);
> +			fout = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate);
>  
>  			/* best match */
> -			dist = abs((long)rate - (long)fvco);
> +			dist = abs((long)rate - (long)fout);
>  			if (dist < best) {
>  				best = dist;
> -				t->rate = (unsigned int)fvco;
> +				t->rate = (unsigned int)fout;
>  				t->mdiv = mdiv;
>  				t->pdiv = pdiv;
>  				t->sdiv = sdiv;
> -- 
> 2.34.1
> 
> 
>
Peng Fan Dec. 21, 2023, 2:05 a.m. UTC | #2
> Subject: [PATCH] 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 <shengjiu.wang@nxp.com>

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Abel Vesa Dec. 21, 2023, 1:03 p.m. UTC | #3
On Wed, 20 Dec 2023 18:33:09 +0800, Shengjiu Wang wrote:
> 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.
> 
> 
> [...]

Applied, thanks!

[1/1] clk: imx: pll14xx: change naming of fvco to fout
      commit: f52f00069888e410cec718792b3e314624f209ea

Best regards,
diff mbox series

Patch

diff --git a/drivers/clk/imx/clk-pll14xx.c b/drivers/clk/imx/clk-pll14xx.c
index 0d58d85c375e..d63564dbb12c 100644
--- a/drivers/clk/imx/clk-pll14xx.c
+++ b/drivers/clk/imx/clk-pll14xx.c
@@ -104,15 +104,15 @@  static const struct imx_pll14xx_rate_table *imx_get_pll_settings(
 static long pll14xx_calc_rate(struct clk_pll14xx *pll, int mdiv, int pdiv,
 			      int sdiv, int kdiv, unsigned long prate)
 {
-	u64 fvco = prate;
+	u64 fout = prate;
 
-	/* fvco = (m * 65536 + k) * Fin / (p * 65536) */
-	fvco *= (mdiv * 65536 + kdiv);
+	/* fout = (m * 65536 + k) * Fin / (p * 65536) / (1 << sdiv) */
+	fout *= (mdiv * 65536 + kdiv);
 	pdiv *= 65536;
 
-	do_div(fvco, pdiv << sdiv);
+	do_div(fout, pdiv << sdiv);
 
-	return fvco;
+	return fout;
 }
 
 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
 {
 	u32 pll_div_ctl0, pll_div_ctl1;
 	int mdiv, pdiv, sdiv, kdiv;
-	long fvco, rate_min, rate_max, dist, best = LONG_MAX;
+	long fout, rate_min, rate_max, dist, best = LONG_MAX;
 	const struct imx_pll14xx_rate_table *tt;
 
 	/*
@@ -143,6 +143,7 @@  static void imx_pll14xx_calc_settings(struct clk_pll14xx *pll, unsigned long rat
 	 * d) -32768 <= k <= 32767
 	 *
 	 * fvco = (m * 65536 + k) * prate / (p * 65536)
+	 * fout = (m * 65536 + k) * prate / (p * 65536) / (1 << sdiv)
 	 */
 
 	/* 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
 		pr_debug("%s: in=%ld, want=%ld Only adjust kdiv %ld -> %d\n",
 			 clk_hw_get_name(&pll->hw), prate, rate,
 			 FIELD_GET(KDIV_MASK, pll_div_ctl1), kdiv);
-		fvco = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate);
-		t->rate = (unsigned int)fvco;
+		fout = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate);
+		t->rate = (unsigned int)fout;
 		t->mdiv = mdiv;
 		t->pdiv = pdiv;
 		t->sdiv = sdiv;
@@ -190,13 +191,13 @@  static void imx_pll14xx_calc_settings(struct clk_pll14xx *pll, unsigned long rat
 			mdiv = clamp(mdiv, 64, 1023);
 
 			kdiv = pll1443x_calc_kdiv(mdiv, pdiv, sdiv, rate, prate);
-			fvco = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate);
+			fout = pll14xx_calc_rate(pll, mdiv, pdiv, sdiv, kdiv, prate);
 
 			/* best match */
-			dist = abs((long)rate - (long)fvco);
+			dist = abs((long)rate - (long)fout);
 			if (dist < best) {
 				best = dist;
-				t->rate = (unsigned int)fvco;
+				t->rate = (unsigned int)fout;
 				t->mdiv = mdiv;
 				t->pdiv = pdiv;
 				t->sdiv = sdiv;