From: Fabian Vogt <fabian@ritter-vogt.de>
To: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>
Cc: Daniel Tang <dt.tangr@gmail.com>, linux-clk@vger.kernel.org
Subject: [PATCH] clk: clk-nspire: Use a more complete algorithm for divider calculation
Date: Wed, 24 Mar 2021 15:37:24 +0100 [thread overview]
Message-ID: <5001083.BWDE7HjgcL@linux-e202.suse.de> (raw)
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
reply other threads:[~2021-03-24 14:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5001083.BWDE7HjgcL@linux-e202.suse.de \
--to=fabian@ritter-vogt.de \
--cc=dt.tangr@gmail.com \
--cc=linux-clk@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.