mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] sandbox: power: register power device without a DT node
@ 2026-09-28 10:41 Ahmad Fatoum
  0 siblings, 0 replies; only message in thread
From: Ahmad Fatoum @ 2026-09-28 10:41 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Since the power driver probes from device tree, sandbox has no poweroff
or restart handler when started with a --dtb that lacks a
barebox,sandbox-power node.
The poweroff and reset commands will then end up in hang(), which spins
at 100% CPU until the process is killed.

Let's register the device ourselves when the device tree has no such
node.

Fixes: d2748c1ae720 ("sandbox: poweroff: migrate to driver probed from device tree")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/sandbox/board/power.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/arch/sandbox/board/power.c b/arch/sandbox/board/power.c
index 9caaea5be2f0..a95e25b57215 100644
--- a/arch/sandbox/board/power.c
+++ b/arch/sandbox/board/power.c
@@ -2,6 +2,8 @@
 
 #include <common.h>
 #include <driver.h>
+#include <init.h>
+#include <of.h>
 #include <poweroff.h>
 #include <restart.h>
 #include <mach/linux.h>
@@ -68,6 +70,9 @@ static int sandbox_power_probe(struct device *dev)
 	if (IS_ENABLED(CONFIG_SANDBOX_REEXEC))
 		restart_handler_register(&power->rst_reexec);
 
+	if (!dev->of_node)
+		return 0;
+
 	power->reset_source_cell = of_nvmem_cell_get(dev->of_node,
 						     "reset-source");
 	if (IS_ERR(power->reset_source_cell)) {
@@ -100,3 +105,18 @@ static struct driver sandbox_power_drv = {
 	.probe = sandbox_power_probe,
 };
 coredevice_platform_driver(sandbox_power_drv);
+
+/*
+ * A device tree passed with --dtb need not have a sandbox-power node.
+ * Without one, poweroff and reset end in hang(), which busy-loops forever,
+ * so register the device ourselves in this case.
+ */
+static int sandbox_power_fallback(void)
+{
+	if (!of_find_compatible_node(NULL, NULL, "barebox,sandbox-power"))
+		add_generic_device("sandbox-power", DEVICE_ID_SINGLE, NULL, 0,
+				   0, 0, NULL);
+
+	return 0;
+}
+coredevice_initcall(sandbox_power_fallback);
-- 
2.47.3




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-28 11:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-28 10:41 [PATCH] sandbox: power: register power device without a DT node Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox