diff options
author | Simon Glass <sjg@chromium.org> | 2018-10-01 12:22:46 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2018-10-09 04:40:27 -0600 |
commit | 751fed426f87204517df14de76762461cd2a4203 (patch) | |
tree | 97843e594f8276674c09d73665fe376bba040ae3 /test | |
parent | eb517315a67320e770cf4a100a922e8ae18fa54e (diff) | |
download | u-boot-751fed426f87204517df14de76762461cd2a4203.zip u-boot-751fed426f87204517df14de76762461cd2a4203.tar.gz u-boot-751fed426f87204517df14de76762461cd2a4203.tar.bz2 |
sysreset: Add a way to find the last reset
We have a method to return the last reset as a string for humans, but not
a method that allows it to be used programmatically. Add a new method that
returns the last reset as an enum.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/dm/sysreset.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/dm/sysreset.c b/test/dm/sysreset.c index 218cc23..e1b7bf5 100644 --- a/test/dm/sysreset.c +++ b/test/dm/sysreset.c @@ -71,6 +71,7 @@ static int dm_test_sysreset_walk(struct unit_test_state *uts) /* If we generate a power sysreset, we will exit sandbox! */ state->sysreset_allowed[SYSRESET_POWER] = false; + state->sysreset_allowed[SYSRESET_POWER_OFF] = false; ut_asserteq(-EACCES, sysreset_walk(SYSRESET_WARM)); ut_asserteq(-EACCES, sysreset_walk(SYSRESET_COLD)); ut_asserteq(-EACCES, sysreset_walk(SYSRESET_POWER)); @@ -90,3 +91,22 @@ static int dm_test_sysreset_walk(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_sysreset_walk, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +static int dm_test_sysreset_get_last(struct unit_test_state *uts) +{ + struct udevice *dev; + + /* Device 1 is the warm sysreset device */ + ut_assertok(uclass_get_device(UCLASS_SYSRESET, 1, &dev)); + ut_asserteq(SYSRESET_WARM, sysreset_get_last(dev)); + + /* Device 2 is the cold sysreset device */ + ut_assertok(uclass_get_device(UCLASS_SYSRESET, 2, &dev)); + ut_asserteq(SYSRESET_COLD, sysreset_get_last(dev)); + + /* This is device 0, the non-DT one */ + ut_asserteq(SYSRESET_COLD, sysreset_get_last_walk()); + + return 0; +} +DM_TEST(dm_test_sysreset_get_last, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |