linux/drivers/clk/ingenic
Paul Cercueil ecfb9f4047 clk: ingenic: jz4760: Update M/N/OD calculation algorithm
The previous algorithm was pretty broken.

- The inner loop had a '(m > m_max)' condition, and the value of 'm'
  would increase in each iteration;

- Each iteration would actually multiply 'm' by two, so it is not needed
  to re-compute the whole equation at each iteration;

- It would loop until (m & 1) == 0, which means it would loop at most
  once.

- The outer loop would divide the 'n' value by two at the end of each
  iteration. This meant that for a 12 MHz parent clock and a 1.2 GHz
  requested clock, it would first try n=12, then n=6, then n=3, then
  n=1, none of which would work; the only valid value is n=2 in this
  case.

Simplify this algorithm with a single for loop, which decrements 'n'
after each iteration, addressing all of the above problems.

Fixes: bdbfc02937 ("clk: ingenic: Add support for the JZ4760")
Cc: <stable@vger.kernel.org>
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20221214123704.7305-1-paul@crapouillou.net
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
2023-01-25 16:08:27 -08:00
..
cgu.c clk: ingenic: Add .set_rate_hook() for PLL clocks 2022-10-27 11:59:05 -07:00
cgu.h clk: ingenic: Add .set_rate_hook() for PLL clocks 2022-10-27 11:59:05 -07:00
jz4725b-cgu.c clk: ingenic: Mark critical clocks in Ingenic SoCs 2022-05-18 13:56:22 -07:00
jz4740-cgu.c clk: ingenic: Mark critical clocks in Ingenic SoCs 2022-05-18 13:56:22 -07:00
jz4755-cgu.c clk: Add Ingenic JZ4755 CGU driver 2022-11-01 12:36:22 -07:00
jz4760-cgu.c clk: ingenic: jz4760: Update M/N/OD calculation algorithm 2023-01-25 16:08:27 -08:00
jz4770-cgu.c clk: ingenic: Mark critical clocks in Ingenic SoCs 2022-05-18 13:56:22 -07:00
jz4780-cgu.c clk: ingenic: Mark critical clocks in Ingenic SoCs 2022-05-18 13:56:22 -07:00
Kconfig clk: Add Ingenic JZ4755 CGU driver 2022-11-01 12:36:22 -07:00
Makefile clk: Add Ingenic JZ4755 CGU driver 2022-11-01 12:36:22 -07:00
pm.c clk: ingenic: Handle setting the Low-Power Mode bit 2019-06-25 15:43:15 -07:00
pm.h clk: ingenic: Handle setting the Low-Power Mode bit 2019-06-25 15:43:15 -07:00
tcu.c clk: ingenic-tcu: Properly enable registers before accessing timers 2022-08-31 18:28:20 -07:00
x1000-cgu.c clk: ingenic: Minor cosmetic fixups for X1000 2022-10-27 11:59:05 -07:00
x1830-cgu.c clk: ingenic: Mark critical clocks in Ingenic SoCs 2022-05-18 13:56:22 -07:00