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/7] sandbox: power: set $global.system.reset=POR on poweroff
Date: Mon, 28 Jun 2021 08:45:11 +0200	[thread overview]
Message-ID: <20210628064517.28636-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20210628064517.28636-1-a.fatoum@pengutronix.de>

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@pengutronix.de>
---
 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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2021-06-28  6:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-28  6:45 [PATCH 0/7] sandbox: turn into deep probe platform Ahmad Fatoum
2021-06-28  6:45 ` Ahmad Fatoum [this message]
2021-06-28  6:45 ` [PATCH 2/7] sandbox: fix probe order dependency between watchdog and power Ahmad Fatoum
2021-06-28  6:45 ` [PATCH 3/7] of: partition: implement of_partition_ensure_probed Ahmad Fatoum
2021-06-28  6:45 ` [PATCH 4/7] state: support deep probe Ahmad Fatoum
2021-06-28  6:45 ` [PATCH 5/7] nvmem: " Ahmad Fatoum
2021-06-28  6:45 ` [PATCH 6/7] sandbox: turn into deep probe platform Ahmad Fatoum
2021-06-28  6:45 ` [PATCH 7/7] Revert "sandbox: hostfile: move initcall to earlier postcore level" Ahmad Fatoum
2021-07-18  5:14 ` [PATCH 0/7] sandbox: turn into deep probe platform 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=20210628064517.28636-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