From f8cc882812259f763f785ec41e8efae45aee05d8 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Mon, 28 Jun 2021 08:45:11 +0200 Subject: sandbox: power: set $global.system.reset=POR on poweroff Now that the stickypage is a regular hostfile, it survives poweroff. This $global.system.reset will only be POR on first boot. For subsequent boots, the power driver must itself take care to write POR to the nvmem cell. While at it remove two minor issues: - src_offset is unused - len is used to store a length into. Its original value is unused Signed-off-by: Ahmad Fatoum Link: https://lore.barebox.org/20210628064517.28636-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer --- arch/sandbox/board/power.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'arch/sandbox') diff --git a/arch/sandbox/board/power.c b/arch/sandbox/board/power.c index 3112c80348..aa778792c1 100644 --- a/arch/sandbox/board/power.c +++ b/arch/sandbox/board/power.c @@ -8,12 +8,15 @@ struct sandbox_power { struct restart_handler rst_hang, rst_reexec; + struct poweroff_handler poweroff; struct nvmem_cell *reset_source_cell; - u32 src_offset; }; 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); linux_exit(); } @@ -36,10 +39,15 @@ static void sandbox_rst_reexec(struct restart_handler *rst) static int sandbox_power_probe(struct device_d *dev) { struct sandbox_power *power = xzalloc(sizeof(*power)); - size_t len = 1; + size_t len; u8 *rst; - poweroff_handler_register_fn(sandbox_poweroff); + power->poweroff = (struct poweroff_handler) { + .name = "exit", + .poweroff = sandbox_poweroff + }; + + poweroff_handler_register(&power->poweroff); power->rst_hang = (struct restart_handler) { .name = "hang", -- cgit v1.2.3