Skip to content

Commit

Permalink
sandbox: sysreset: Update to support power-on reset
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
sjg20 committed Dec 5, 2018
1 parent e628bba commit 2a07269
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion drivers/sysreset/sysreset_sandbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions test/dm/sysreset.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 2a07269

Please sign in to comment.