1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2016, NVIDIA CORPORATION.
12 /* This must match the specifier for mbox-names="test" in the DT node */
13 #define TEST_RESET_ID 2
15 /* This is the other reset phandle specifier handled by bulk */
16 #define OTHER_RESET_ID 2
18 static int dm_test_reset(struct unit_test_state *uts)
20 struct udevice *dev_reset;
21 struct udevice *dev_test;
23 ut_assertok(uclass_get_device_by_name(UCLASS_RESET, "reset-ctl",
25 ut_asserteq(0, sandbox_reset_query(dev_reset, TEST_RESET_ID));
27 ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "reset-ctl-test",
29 ut_assertok(sandbox_reset_test_get(dev_test));
31 ut_assertok(sandbox_reset_test_assert(dev_test));
32 ut_asserteq(1, sandbox_reset_query(dev_reset, TEST_RESET_ID));
34 ut_assertok(sandbox_reset_test_deassert(dev_test));
35 ut_asserteq(0, sandbox_reset_query(dev_reset, TEST_RESET_ID));
37 ut_assertok(sandbox_reset_test_free(dev_test));
41 DM_TEST(dm_test_reset, DM_TESTF_SCAN_FDT);
43 static int dm_test_reset_bulk(struct unit_test_state *uts)
45 struct udevice *dev_reset;
46 struct udevice *dev_test;
48 ut_assertok(uclass_get_device_by_name(UCLASS_RESET, "reset-ctl",
50 ut_asserteq(0, sandbox_reset_query(dev_reset, TEST_RESET_ID));
51 ut_asserteq(0, sandbox_reset_query(dev_reset, OTHER_RESET_ID));
53 ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "reset-ctl-test",
55 ut_assertok(sandbox_reset_test_get_bulk(dev_test));
57 ut_assertok(sandbox_reset_test_assert_bulk(dev_test));
58 ut_asserteq(1, sandbox_reset_query(dev_reset, TEST_RESET_ID));
59 ut_asserteq(1, sandbox_reset_query(dev_reset, OTHER_RESET_ID));
61 ut_assertok(sandbox_reset_test_deassert_bulk(dev_test));
62 ut_asserteq(0, sandbox_reset_query(dev_reset, TEST_RESET_ID));
63 ut_asserteq(0, sandbox_reset_query(dev_reset, OTHER_RESET_ID));
65 ut_assertok(sandbox_reset_test_release_bulk(dev_test));
66 ut_asserteq(1, sandbox_reset_query(dev_reset, TEST_RESET_ID));
67 ut_asserteq(1, sandbox_reset_query(dev_reset, OTHER_RESET_ID));
71 DM_TEST(dm_test_reset_bulk, DM_TESTF_SCAN_FDT);