mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/9] clocksource: make available in PBL
Date: Tue, 22 Apr 2025 07:26:27 +0200	[thread overview]
Message-ID: <20250422052635.3423961-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250422052635.3423961-1-a.fatoum@pengutronix.de>

We currently have some adhoc early_udelay implementations in PBL.
As the clocksource framework is already very lightweight, let's port it
to allow dropping early_udelay in future.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/Makefile | 1 +
 common/clock.c  | 5 ++++-
 include/sched.h | 2 +-
 pbl/Kconfig     | 3 +++
 4 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/common/Makefile b/common/Makefile
index 9b67187561bf..e12eef4691fe 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -5,6 +5,7 @@ obj-y				+= memory.o
 obj-y				+= memory_display.o
 pbl-$(CONFIG_PBL_CONSOLE)	+= memory_display.o
 obj-y				+= clock.o
+pbl-$(CONFIG_PBL_CLOCKSOURCE)	+= clock.o
 obj-y				+= console_common.o
 obj-$(CONFIG_OFDEVICE)		+= deep-probe.o
 obj-y				+= startup.o
diff --git a/common/clock.c b/common/clock.c
index b300e5798a16..15e26c67c887 100644
--- a/common/clock.c
+++ b/common/clock.c
@@ -34,7 +34,7 @@ static struct clocksource dummy_cs = {
 	.priority = -1,
 };
 
-static struct clocksource *current_clock = &dummy_cs;
+static struct clocksource *current_clock = IN_PROPER ? &dummy_cs : NULL;
 
 static int dummy_csrc_warn(void)
 {
@@ -55,6 +55,9 @@ uint64_t get_time_ns(void)
 	uint64_t cycle_now, cycle_delta;
 	uint64_t ns_offset;
 
+	if (IN_PBL && !cs)
+		panic("No PBL clocksource has been initialized\n");
+
 	/* read clocksource: */
 	cycle_now = cs->read() & cs->mask;
 
diff --git a/include/sched.h b/include/sched.h
index 4dadff20696e..0b5e91f0be44 100644
--- a/include/sched.h
+++ b/include/sched.h
@@ -2,7 +2,7 @@
 #ifndef __BAREBOX_SCHED_H_
 #define __BAREBOX_SCHED_H_
 
-#ifdef CONFIG_HAS_SCHED
+#if defined CONFIG_HAS_SCHED && IN_PROPER
 void resched(void);
 #else
 static inline void resched(void)
diff --git a/pbl/Kconfig b/pbl/Kconfig
index 98d71791454b..6e3581829d58 100644
--- a/pbl/Kconfig
+++ b/pbl/Kconfig
@@ -57,6 +57,9 @@ config PBL_VERIFY_PIGGY
 	depends on ARM || MIPS || RISCV
 	bool "Verify barebox proper hash before decompression" if COMPILE_TEST
 
+config PBL_CLOCKSOURCE
+	bool
+
 config BOARD_GENERIC_DT
 	bool
 	select LIBFDT
-- 
2.39.5




  reply	other threads:[~2025-04-22  5:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-22  5:26 [PATCH 0/9] ARM: OMAP: beaglebone: add PBL SD xload support Ahmad Fatoum
2025-04-22  5:26 ` Ahmad Fatoum [this message]
2025-04-22  5:26 ` [PATCH 2/9] clocksource: ti-dm: make available in PBL Ahmad Fatoum
2025-04-22  5:26 ` [PATCH 3/9] mci: move mci_setup_cmd definition into header Ahmad Fatoum
2025-04-22  5:26 ` [PATCH 4/9] mci: add common PBL helper for chainloading after BootROM initialization Ahmad Fatoum
2025-04-22  5:26 ` [PATCH 5/9] mci: pbl: add autodetection of BootROM-initialized standard capacity cards Ahmad Fatoum
2025-04-22  5:26 ` [PATCH 6/9] mci: omap_hsmmc: split out common code Ahmad Fatoum
2025-04-22  5:26 ` [PATCH 7/9] ARM: OMAP: add am33xx_hsmmc_start_image for PBL Ahmad Fatoum
2025-04-22  5:26 ` [PATCH 8/9] mci: omap_hsmmc: add xload implementation " Ahmad Fatoum
2025-04-22  5:26 ` [PATCH 9/9] ARM: OMAP: beaglebone: add PBL SD xload support Ahmad Fatoum
2025-04-22 10:55 ` [PATCH 0/9] " 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=20250422052635.3423961-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox