From: Qasim Ijaz <Qasim.Ijaz@analog.com>
To: u-boot@lists.u-boot-project.org
Cc: Tom Rini <trini@konsulko.com>, Peng Fan <peng.fan@nxp.com>
Subject: [PATCH] cmd: clk: Don't truncate "clk dump" clock rates to u32
Date: Sat, 3 Oct 2026 17:55:07 +0100 [thread overview]
Message-ID: <dcc2d705-eef9-4346-a2da-ad42e53e973e@analog.com> (raw)
show_clks() prints information about the clock tree such as the rates of
various clocks. While doing this it gets the rate via clk_get_rate() and
stores it in an unsigned 32 bit integer variable. This limits the clock
rate to 4294967295 (or around 4.2GHz). If a clock rate exceeds this then
"clk dump" will print a rate which has wrapped around the unsigned 32
bit integer.
This was observed in the clock tree of an SoC ADI is currently bringing
up (the ADSP-SC846):
=> clk dump
...
cgu1_vco 505032704
cgu1_pllclk 2400000000
cclk2_1 1600000000
dclk1_1 960000000
...
In the above the VCO clock should have a rate of 4.8GHz via:
VCO = SYS_CLKIN * MSEL * 2 = 25MHz * 96 * 2 = 4,800,000,000 Hz. However,
4,800,000,000 truncated to 32 bits is 505032704, which is the value
reported above.
To fix this issue change the type of "rate" to ulong to match the
return value of clk_get_rate() also change the format specifier to
%lu to accommodate the type change.
Fixes: aeeb2e6d9c67 ("clk: support clk tree dump")
Signed-off-by: Qasim Ijaz <Qasim.Ijaz@analog.com>
---
cmd/clk.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cmd/clk.c b/cmd/clk.c
index 2fc834e5549..3c816a41730 100644
--- a/cmd/clk.c
+++ b/cmd/clk.c
@@ -15,7 +15,7 @@ static void show_clks(struct udevice *dev, int depth, int last_flag)
int i, is_last;
struct udevice *child;
struct clk *clkp, *parent;
- u32 rate;
+ ulong rate;
clkp = dev_get_clk_ptr(dev);
if (clkp) {
@@ -25,7 +25,7 @@ static void show_clks(struct udevice *dev, int depth, int last_flag)
depth++;
rate = clk_get_rate(clkp);
- printf(" %-12u %8d ", rate, clkp->enable_count);
+ printf(" %-12lu %8d ", rate, clkp->enable_count);
for (i = depth; i >= 0; i--) {
is_last = (last_flag >> i) & 1;
--
2.43.0
reply other threads:[~2026-10-03 21:33 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=dcc2d705-eef9-4346-a2da-ad42e53e973e@analog.com \
--to=qasim.ijaz@analog.com \
--cc=peng.fan@nxp.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.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.