* [PATCH] clk: clk-nspire: Use a more complete algorithm for divider calculation
@ 2021-03-24 14:37 Fabian Vogt
0 siblings, 0 replies; only message in thread
From: Fabian Vogt @ 2021-03-24 14:37 UTC (permalink / raw)
To: Michael Turquette, Stephen Boyd; +Cc: Daniel Tang, linux-clk
For some reason it implemented a mixture of the fixed base and variable
base paths. Those actually differ, which led to a division by zero in some
cases.
Signed-off-by: Fabian Vogt <fabian@ritter-vogt.de>
---
drivers/clk/clk-nspire.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/drivers/clk/clk-nspire.c b/drivers/clk/clk-nspire.c
index 6305058dd0d3..97bad9423960 100644
--- a/drivers/clk/clk-nspire.c
+++ b/drivers/clk/clk-nspire.c
@@ -27,7 +27,7 @@
#define CX_BASE_SHIFT 15
#define CX_BASE_MASK 0x3F
-#define CX_UNKNOWN_SHIFT 21
+#define CX_UNKNOWN_SHIFT 30
#define CX_UNKNOWN_MASK 0x03
struct nspire_clk_info {
@@ -40,13 +40,17 @@ struct nspire_clk_info {
#define EXTRACT(var, prop) (((var)>>prop##_SHIFT) & prop##_MASK)
static void nspire_clkinfo_cx(u32 val, struct nspire_clk_info *clk)
{
- if (EXTRACT(val, FIXED_BASE))
+ if (EXTRACT(val, FIXED_BASE)) {
clk->base_clock = 48 * MHZ;
- else
+ clk->base_cpu_ratio = 1 << EXTRACT(val, CX_UNKNOWN);
+ clk->base_ahb_ratio = clk->base_cpu_ratio * 2;
+ } else {
clk->base_clock = 6 * EXTRACT(val, CX_BASE) * MHZ;
-
- clk->base_cpu_ratio = EXTRACT(val, BASE_CPU) * EXTRACT(val, CX_UNKNOWN);
- clk->base_ahb_ratio = clk->base_cpu_ratio * (EXTRACT(val, CPU_AHB) + 1);
+ clk->base_cpu_ratio = 2;
+ if (EXTRACT(val, BASE_CPU))
+ clk->base_cpu_ratio = EXTRACT(val, BASE_CPU) * 2;
+ clk->base_ahb_ratio = clk->base_cpu_ratio * (EXTRACT(val, CPU_AHB) + 1);
+ }
}
static void nspire_clkinfo_classic(u32 val, struct nspire_clk_info *clk)
--
2.25.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-03-24 14:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24 14:37 [PATCH] clk: clk-nspire: Use a more complete algorithm for divider calculation Fabian Vogt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.