summaryrefslogtreecommitdiffstats
path: root/arch/sandbox
diff options
context:
space:
mode:
authorAhmad Fatoum <ahmad@a3f.at>2023-04-24 14:18:00 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2023-05-02 11:33:58 +0200
commit5faba01e3248dbea15d58e46b395c791155a535e (patch)
treebdbe0486f46143c017697dd90c0262bb8024dbc0 /arch/sandbox
parent0dac61dffee68f1dc0173e3b192f197abe02bb20 (diff)
downloadbarebox-5faba01e3248dbea15d58e46b395c791155a535e.tar.gz
barebox-5faba01e3248dbea15d58e46b395c791155a535e.tar.xz
sandbox: power: handle missing stickypage gracefully
To enable simulation of $global.system.reset in sandbox, the power driver writes the reset-source into the stickypage for readout during subsequent barebox startup. This is an optional feature, so it should happen before watchdog registration, but not break watchdog operation if not available. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20230424121805.150434-2-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/sandbox')
-rw-r--r--arch/sandbox/board/power.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/arch/sandbox/board/power.c b/arch/sandbox/board/power.c
index 51f0968447..4adc8d7455 100644
--- a/arch/sandbox/board/power.c
+++ b/arch/sandbox/board/power.c
@@ -5,7 +5,7 @@
#include <poweroff.h>
#include <restart.h>
#include <mach/linux.h>
-#include <reset_source.h>
+#include <asm/reset_source.h>
#include <linux/nvmem-consumer.h>
struct sandbox_power {
@@ -18,7 +18,8 @@ static void sandbox_poweroff(struct poweroff_handler *poweroff)
{
struct sandbox_power *power = container_of(poweroff, struct sandbox_power, poweroff);
- nvmem_cell_write(power->reset_source_cell, &(u8) { RESET_POR }, 1);
+ sandbox_save_reset_source(power->reset_source_cell, RESET_POR);
+
linux_exit();
}
@@ -29,11 +30,9 @@ static void sandbox_rst_hang(struct restart_handler *rst)
static void sandbox_rst_reexec(struct restart_handler *rst)
{
- u8 reason = RESET_RST;
struct sandbox_power *power = container_of(rst, struct sandbox_power, rst_reexec);
- if (!IS_ERR(power->reset_source_cell))
- WARN_ON(nvmem_cell_write(power->reset_source_cell, &reason, 1) <= 0);
+ sandbox_save_reset_source(power->reset_source_cell, RESET_RST);
linux_reexec();
}
@@ -69,7 +68,10 @@ static int sandbox_power_probe(struct device *dev)
power->reset_source_cell = of_nvmem_cell_get(dev->of_node,
"reset-source");
if (IS_ERR(power->reset_source_cell)) {
- dev_warn(dev, "No reset source info available: %pe\n", power->reset_source_cell);
+ if (PTR_ERR(power->reset_source_cell) != -EPROBE_DEFER)
+ dev_warn(dev, "No reset source info available: %pe\n",
+ power->reset_source_cell);
+ power->reset_source_cell = NULL;
return 0;
}