public inbox for linux-clk@vger.kernel.org
 help / color / mirror / Atom feed
* bounds of pdiv in clk-pll14xx.c
@ 2023-06-21 11:24 Rasmus Villemoes
  2023-07-13 17:54 ` Marco Felsch
  2023-08-02  6:46 ` Sascha Hauer
  0 siblings, 2 replies; 12+ messages in thread
From: Rasmus Villemoes @ 2023-06-21 11:24 UTC (permalink / raw)
  To: Abel Vesa, Sascha Hauer
  Cc: Pengutronix Kernel Team, linux-clk, NXP Linux Team

I'm a bit confused by the range of pdiv used in
imx_pll14xx_calc_settings(), introduced in commit b09c68dc57c9 (clk:
imx: pll14xx: Support dynamic rates).

We have this comment

        /*
         * Fractional PLL constrains:
         *
         * a) 6MHz <= prate <= 25MHz
         * b) 1 <= p <= 63 (1 <= p <= 4 prate = 24MHz)
         * c) 64 <= m <= 1023
         * d) 0 <= s <= 6
         * e) -32768 <= k <= 32767

and those values match what I can find in the reference manuals for the
imx8mm, imx8mn and imx8mp SOCs. But the code then only loops over 1 <= p
<= 7. I also don't really understand what the parenthesis

   (1 <= p <= 4 prate = 24MHz)

is supposed to mean. Is p restricted to <= 4 when the parent rate is
24MHz? That doesn't seem to make any sense, and in any case the loop
does go up to p==7.

It also seems that the built-in entries for 393216000 and 361267200 are
suboptimal. Using m=655, p=5, s=3, k=23593 would give 393216000 exactly,
and that set would be found by the loop if it wasn't being preceded by
the table lookup.

Similarly, m=151, p=5, s=1, k=-30933 would be found and results in
361267199, while an exact match (well, at least within 1Hz) is possible
with the wider range of p values: m=497, p=33, s=0, k=-16882.

I could understand if the hardware also imposes some limits on e.g. the
value of intermediate expressions like (m + k/65536)*F_in, but I can't
find any restrictions beyond those in the above comment (disregarding
the mysterious parenthetical).

So, what's the reality here?

Rasmus

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-08-07  7:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-21 11:24 bounds of pdiv in clk-pll14xx.c Rasmus Villemoes
2023-07-13 17:54 ` Marco Felsch
2023-07-13 21:59   ` [EXT] " Adrian Alonso
2023-07-14  7:09     ` Marco Felsch
2023-07-14 13:39       ` Adam Ford
2023-07-14 13:49         ` [PATCH] clk: imx: pll14xx: align pdiv with reference manual Marco Felsch
2023-07-25  7:38           ` Abel Vesa
2023-07-25 19:59             ` Adam Ford
2023-08-06 13:55           ` Adam Ford
2023-08-07  7:45             ` Marco Felsch
2023-07-20 13:07     ` [EXT] Re: bounds of pdiv in clk-pll14xx.c Ahmad Fatoum
2023-08-02  6:46 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox