Re: [PATCH v2 2/4] clk: ti: fapll: Fix clock speed calculation
From: Brian Masney
Date: Wed Nov 11 2026 - 20:14:25 EST
Hi Ettore,
> The fractional part of the divider was being treated as 1/10000000
> whereas it is in fact 1/2^24 (1/16777216). This led to incorrect clock
> speeds being reported when a fractional divider was in use. Correct it.
> As well as fixing the clock speed calculation when read, also update the
> calculation on set in a similar manner.
>
> Fixes: 163152cbbe32 ("clk: ti: Add support for FAPLL on dm816x")
> Signed-off-by: Andrew Goodbody <andrew.goodbody@xxxxxxxxxx>
Should there be a Co-Developed-By here and on the other patches?
> Signed-off-by: Ettore Chimenti <ettore.chimenti@xxxxxxxxxx>
> ---
> drivers/clk/ti/fapll.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/clk/ti/fapll.c b/drivers/clk/ti/fapll.c
> index ae2f6fed10f6..8ab9acd57b60 100644
> --- a/drivers/clk/ti/fapll.c
> +++ b/drivers/clk/ti/fapll.c
> @@ -336,8 +336,8 @@ static unsigned long ti_fapll_synth_recalc_rate(struct clk_hw *hw,
> v = readl_relaxed(synth->freq);
> synth_int_div = (v >> 24) & 0xf;
> synth_frac_div = v & 0xffffff;
> - synth_div_freq = (synth_int_div * 10000000) + synth_frac_div;
> - rate *= 10000000;
> + synth_div_freq = (synth_int_div * 16777216) + synth_frac_div;
> + rate *= 16777216;
The 16777216 magic number appears multiple times. Plugging this into my
calculator, I see it's 1 << 24. How about adding some defines:
#define SYNTH_FRAC_DIV_BITS 24
#define SYNTH_FRAC_DIV_SCALE BIT(SYNTH_FRAC_DIV_BITS)
Brian
--
Brian Masney <masneyb@xxxxxxxxxx>