]>
git.ipfire.org Git - people/ms/u-boot.git/blob - test/dm/reset.c
2 * Copyright (C) 2015 Google, Inc
4 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/state.h>
15 /* Test that we can use particular reset devices */
16 static int dm_test_reset_base(struct unit_test_state
*uts
)
18 struct sandbox_state
*state
= state_get_current();
21 /* Device 0 is the platform data device - it should never respond */
22 ut_assertok(uclass_get_device(UCLASS_RESET
, 0, &dev
));
23 ut_asserteq(-ENODEV
, reset_request(dev
, RESET_WARM
));
24 ut_asserteq(-ENODEV
, reset_request(dev
, RESET_COLD
));
25 ut_asserteq(-ENODEV
, reset_request(dev
, RESET_POWER
));
27 /* Device 1 is the warm reset device */
28 ut_assertok(uclass_get_device(UCLASS_RESET
, 1, &dev
));
29 ut_asserteq(-EACCES
, reset_request(dev
, RESET_WARM
));
30 ut_asserteq(-ENOSYS
, reset_request(dev
, RESET_COLD
));
31 ut_asserteq(-ENOSYS
, reset_request(dev
, RESET_POWER
));
33 state
->reset_allowed
[RESET_WARM
] = true;
34 ut_asserteq(-EINPROGRESS
, reset_request(dev
, RESET_WARM
));
35 state
->reset_allowed
[RESET_WARM
] = false;
37 /* Device 2 is the cold reset device */
38 ut_assertok(uclass_get_device(UCLASS_RESET
, 2, &dev
));
39 ut_asserteq(-ENOSYS
, reset_request(dev
, RESET_WARM
));
40 ut_asserteq(-EACCES
, reset_request(dev
, RESET_COLD
));
41 state
->reset_allowed
[RESET_POWER
] = false;
42 ut_asserteq(-EACCES
, reset_request(dev
, RESET_POWER
));
43 state
->reset_allowed
[RESET_POWER
] = true;
47 DM_TEST(dm_test_reset_base
, DM_TESTF_SCAN_PDATA
| DM_TESTF_SCAN_FDT
);
49 /* Test that we can walk through the reset devices */
50 static int dm_test_reset_walk(struct unit_test_state
*uts
)
52 struct sandbox_state
*state
= state_get_current();
54 /* If we generate a power reset, we will exit sandbox! */
55 state
->reset_allowed
[RESET_POWER
] = false;
56 ut_asserteq(-EACCES
, reset_walk(RESET_WARM
));
57 ut_asserteq(-EACCES
, reset_walk(RESET_COLD
));
58 ut_asserteq(-EACCES
, reset_walk(RESET_POWER
));
61 * Enable cold reset - this should make cold reset work, plus a warm
62 * reset should be promoted to cold, since this is the next step
65 state
->reset_allowed
[RESET_COLD
] = true;
66 ut_asserteq(-EINPROGRESS
, reset_walk(RESET_WARM
));
67 ut_asserteq(-EINPROGRESS
, reset_walk(RESET_COLD
));
68 ut_asserteq(-EACCES
, reset_walk(RESET_POWER
));
69 state
->reset_allowed
[RESET_COLD
] = false;
70 state
->reset_allowed
[RESET_POWER
] = true;
74 DM_TEST(dm_test_reset_walk
, DM_TESTF_SCAN_PDATA
| DM_TESTF_SCAN_FDT
);