mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: "Claude Opus 4.6" <noreply@anthropic.com>,
	Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 5/6] mach-mpc85xx: speed: add fsl_set_timebase_clock() override
Date: Mon,  9 Feb 2026 10:10:30 +0100	[thread overview]
Message-ID: <20260209091513.3563412-6-a.fatoum@barebox.org> (raw)
In-Reply-To: <20260209091513.3563412-1-a.fatoum@barebox.org>

Some platforms (e.g. QEMU) don't implement the GUTS PORPLLSR register,
so the register-based timebase frequency calculation returns 0. Add
fsl_set_timebase_clock() that allows board code to provide the correct
timebase frequency before initcalls run, bypassing the register read.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 arch/powerpc/mach-mpc85xx/include/mach/clock.h |  1 +
 arch/powerpc/mach-mpc85xx/speed.c              | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/arch/powerpc/mach-mpc85xx/include/mach/clock.h b/arch/powerpc/mach-mpc85xx/include/mach/clock.h
index bfd9cf4d8ecd..2d0f079f5c68 100644
--- a/arch/powerpc/mach-mpc85xx/include/mach/clock.h
+++ b/arch/powerpc/mach-mpc85xx/include/mach/clock.h
@@ -14,6 +14,7 @@ struct sys_info {
 
 unsigned long fsl_get_bus_freq(ulong dummy);
 unsigned long fsl_get_ddr_freq(ulong dummy);
+void fsl_set_timebase_clock(unsigned long freq);
 unsigned long fsl_get_timebase_clock(void);
 unsigned long fsl_get_i2c_freq(void);
 void fsl_get_sys_info(struct sys_info *sysInfo);
diff --git a/arch/powerpc/mach-mpc85xx/speed.c b/arch/powerpc/mach-mpc85xx/speed.c
index 4a69de3dc81a..8018132874ba 100644
--- a/arch/powerpc/mach-mpc85xx/speed.c
+++ b/arch/powerpc/mach-mpc85xx/speed.c
@@ -104,10 +104,20 @@ unsigned long fsl_get_ddr_freq(ulong dummy)
 	return sys_info.freqDDRBus;
 }
 
+static unsigned long timebase_clock_override;
+
+void fsl_set_timebase_clock(unsigned long freq)
+{
+	timebase_clock_override = freq;
+}
+
 unsigned long fsl_get_timebase_clock(void)
 {
 	struct sys_info sysinfo;
 
+	if (timebase_clock_override)
+		return timebase_clock_override;
+
 	fsl_get_sys_info(&sysinfo);
 
 	return (sysinfo.freqSystemBus + 4UL)/8UL;
-- 
2.47.3




  parent reply	other threads:[~2026-02-09  9:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-09  9:10 [PATCH 0/6] ppc: add QEMU ppce500 test in CI Ahmad Fatoum
2026-02-09  9:10 ` [PATCH 1/6] include: array_size.h: make header self-contained Ahmad Fatoum
2026-02-09  9:10 ` [PATCH 2/6] serial: ns16550: add "ns16550" compatible string Ahmad Fatoum
2026-02-09  9:10 ` [PATCH 3/6] lib: stackprot: omit HAVE_STACKPROTECTOR for powerpc Ahmad Fatoum
2026-02-09  9:10 ` [PATCH 4/6] gpio: mpc8xxx: allow build on MPC85xx platforms Ahmad Fatoum
2026-02-09  9:10 ` Ahmad Fatoum [this message]
2026-02-09  9:10 ` [PATCH 6/6] powerpc: add QEMU ppce500 board support with CI test infrastructure Ahmad Fatoum
2026-02-11  9:34 ` [PATCH 0/6] ppc: add QEMU ppce500 test in CI Sascha Hauer

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=20260209091513.3563412-6-a.fatoum@barebox.org \
    --to=a.fatoum@barebox.org \
    --cc=barebox@lists.infradead.org \
    --cc=noreply@anthropic.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox