Paul Cercueil
86733ab239
clk: ingenic: jz4760: Update M/N/OD calculation algorithm
...
commit ecfb9f4047 upstream.
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 >
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2023-02-14 19:18:03 +01:00
..
2023-01-24 07:22:46 +01:00
2023-02-06 07:59:01 +01:00
2021-11-06 14:13:31 +01:00
2022-12-02 17:41:00 +01:00
2023-02-09 11:26:37 +01:00
2022-08-25 11:40:15 +02:00
2022-03-08 19:12:47 +01:00
2023-02-01 08:27:14 +01:00
2023-01-18 11:48:58 +01:00
2023-01-24 07:22:42 +01:00
2023-02-09 11:26:32 +01:00
2023-01-12 11:58:57 +01:00
2023-02-14 19:18:03 +01:00
2022-12-31 13:14:04 +01:00
2023-01-24 07:22:45 +01:00
2022-12-31 13:14:30 +01:00
2023-02-01 08:27:29 +01:00
2022-12-31 13:14:01 +01:00
2023-01-12 11:58:58 +01:00
2022-07-12 16:34:58 +02:00
2022-09-28 11:11:57 +02:00
2023-01-12 11:58:51 +01:00
2022-12-31 13:14:27 +01:00
2023-02-06 07:59:00 +01:00
2022-12-02 17:41:06 +01:00
2023-02-01 08:27:25 +01:00
2023-02-06 07:59:01 +01:00
2023-02-09 11:26:32 +01:00
2023-02-09 11:26:41 +01:00
2023-02-09 11:26:44 +01:00
2023-02-09 11:26:34 +01:00
2023-02-01 08:27:28 +01:00
2023-02-09 11:26:45 +01:00
2022-04-08 14:22:50 +02:00
2023-02-06 07:59:00 +01:00
2022-12-31 13:14:32 +01:00
2022-12-31 13:14:39 +01:00
2022-12-31 13:14:44 +01:00
2022-11-16 09:58:13 +01:00
2022-12-31 13:14:30 +01:00
2023-02-09 11:26:39 +01:00
2022-03-08 19:12:37 +01:00
2022-07-23 12:54:04 +02:00
2023-02-09 11:26:47 +01:00
2023-02-14 19:17:58 +01:00
2023-02-09 11:26:41 +01:00
2022-08-17 14:23:53 +02:00
2023-01-18 11:48:52 +01:00
2022-12-31 13:14:03 +01:00
2022-12-31 13:14:37 +01:00
2022-10-26 12:34:39 +02:00
2022-12-31 13:14:35 +01:00
2022-12-31 13:14:39 +01:00
2022-12-31 13:14:30 +01:00
2023-01-18 11:48:58 +01:00
2023-01-12 11:59:06 +01:00
2023-02-01 08:27:03 +01:00
2022-12-31 13:14:17 +01:00
2023-01-12 11:58:47 +01:00
2023-01-24 07:22:47 +01:00
2023-01-24 07:22:45 +01:00
2021-11-18 19:16:08 +01:00
2023-01-12 11:58:57 +01:00
2023-02-14 19:18:02 +01:00
2023-01-18 11:48:54 +01:00
2022-08-25 11:40:14 +02:00
2022-07-07 17:53:24 +02:00
2023-02-01 08:27:28 +01:00
2023-02-09 11:26:45 +01:00
2023-02-14 19:17:57 +01:00
2022-08-17 14:24:01 +02:00
2023-01-12 11:58:59 +01:00
2022-11-26 09:24:36 +01:00
2023-01-12 11:58:58 +01:00
2022-06-14 18:36:02 +02:00
2022-12-31 13:13:58 +01:00
2023-02-09 11:26:46 +01:00
2023-02-14 19:18:02 +01:00
2023-02-09 11:26:40 +01:00
2022-12-31 13:14:02 +01:00
2022-12-31 13:14:33 +01:00
2022-10-26 12:35:30 +02:00
2022-04-08 14:23:44 +02:00
2022-04-13 20:59:01 +02:00
2022-12-31 13:14:48 +01:00
2022-12-31 13:14:05 +01:00
2023-01-18 11:48:53 +01:00
2023-01-12 11:58:59 +01:00
2023-02-01 08:27:04 +01:00
2022-10-12 09:53:28 +02:00
2023-01-12 11:58:56 +01:00
2023-01-18 11:48:58 +01:00
2023-02-09 11:26:39 +01:00
2021-11-25 09:48:31 +01:00
2022-11-26 09:24:36 +01:00
2022-11-26 09:24:44 +01:00
2023-02-01 08:27:06 +01:00
2023-01-12 11:58:49 +01:00
2023-02-14 19:18:02 +01:00
2022-10-26 12:35:19 +02:00
2023-01-24 07:22:46 +01:00
2023-02-09 11:26:39 +01:00
2022-12-02 17:41:03 +01:00
2023-02-01 08:27:28 +01:00
2023-01-24 07:22:46 +01:00
2023-02-09 11:26:46 +01:00
2022-12-31 13:14:27 +01:00
2023-02-14 19:18:03 +01:00
2023-01-24 07:22:41 +01:00
2022-12-31 13:14:27 +01:00
2023-02-09 11:26:34 +01:00
2023-02-09 11:26:47 +01:00
2022-08-25 11:40:33 +02:00
2023-01-24 07:22:41 +01:00
2022-12-31 13:14:30 +01:00
2023-02-01 08:27:14 +01:00
2023-02-09 11:26:41 +01:00
2023-02-09 11:26:34 +01:00
2021-10-07 16:51:26 +02:00
2021-12-22 09:32:39 +01:00