diff mbox series

[U-Boot,05/21] sandbox: sysreset: Update to support power-on reset

Message ID 20181124042944.239106-6-sjg@chromium.org
State Accepted
Commit 2a07269062a8e63dadc23be0f8b0d4638da7d2d2
Delegated to: Simon Glass
Headers show
Series Various patches for verified boot support | expand

Commit Message

Simon Glass Nov. 24, 2018, 4:29 a.m. UTC
If U-Boot is started from SPL or TPL, then those earlier phases deal with
the reset cause. On real hardware this cause may be lost once it is read.
Emulate that behaviour in sandbox by reporting a warm reset when a
previous phase has run since start-up.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/sysreset/sysreset_sandbox.c | 8 +++++++-
 test/dm/sysreset.c                  | 4 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)

Comments

Simon Glass Dec. 5, 2018, 11:10 p.m. UTC | #1
If U-Boot is started from SPL or TPL, then those earlier phases deal with
the reset cause. On real hardware this cause may be lost once it is read.
Emulate that behaviour in sandbox by reporting a warm reset when a
previous phase has run since start-up.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/sysreset/sysreset_sandbox.c | 8 +++++++-
 test/dm/sysreset.c                  | 4 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)

Applied to u-boot-dm/master, thanks!
diff mbox series

Patch

diff --git a/drivers/sysreset/sysreset_sandbox.c b/drivers/sysreset/sysreset_sandbox.c
index 7f6d4186e16..38e2a7e241d 100644
--- a/drivers/sysreset/sysreset_sandbox.c
+++ b/drivers/sysreset/sysreset_sandbox.c
@@ -84,7 +84,13 @@  int sandbox_sysreset_get_status(struct udevice *dev, char *buf, int size)
 
 int sandbox_sysreset_get_last(struct udevice *dev)
 {
-	return SYSRESET_COLD;
+	struct sandbox_state *state = state_get_current();
+
+	/*
+	 * The first phase is a power reset, after that we assume we don't
+	 * know.
+	 */
+	return state->jumped_fname ? SYSRESET_WARM : SYSRESET_POWER;
 }
 
 static struct sysreset_ops sandbox_sysreset_ops = {
diff --git a/test/dm/sysreset.c b/test/dm/sysreset.c
index e1b7bf5277d..5b2358ef674 100644
--- a/test/dm/sysreset.c
+++ b/test/dm/sysreset.c
@@ -102,10 +102,10 @@  static int dm_test_sysreset_get_last(struct unit_test_state *uts)
 
 	/* Device 2 is the cold sysreset device */
 	ut_assertok(uclass_get_device(UCLASS_SYSRESET, 2, &dev));
-	ut_asserteq(SYSRESET_COLD, sysreset_get_last(dev));
+	ut_asserteq(SYSRESET_POWER, sysreset_get_last(dev));
 
 	/* This is device 0, the non-DT one */
-	ut_asserteq(SYSRESET_COLD, sysreset_get_last_walk());
+	ut_asserteq(SYSRESET_POWER, sysreset_get_last_walk());
 
 	return 0;
 }