[PATCH 1/7] sandbox: power: set $global.system.reset=POR on poweroff

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <a.fatoum@xxxxxxxxxxxxxx>
---
 arch/sandbox/board/power.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/arch/sandbox/board/power.c b/arch/sandbox/board/power.c
index 3112c80348e7..aa778792c155 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",
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux