blob: c02866a2f0a6b0d7f9eccc1f8f6b0c48e2cef65d [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Stephen Warren4581b712016-06-17 09:43:59 -06002/*
3 * Copyright (c) 2016, NVIDIA CORPORATION.
Stephen Warren4581b712016-06-17 09:43:59 -06004 */
5
6#include <common.h>
7#include <dm.h>
8#include <dm/test.h>
9#include <asm/reset.h>
10#include <test/ut.h>
11
12/* This must match the specifier for mbox-names="test" in the DT node */
13#define TEST_RESET_ID 2
14
Neil Armstrong91f5f8b2018-04-03 11:40:51 +020015/* This is the other reset phandle specifier handled by bulk */
16#define OTHER_RESET_ID 2
17
Stephen Warren4581b712016-06-17 09:43:59 -060018static int dm_test_reset(struct unit_test_state *uts)
19{
20 struct udevice *dev_reset;
21 struct udevice *dev_test;
22
23 ut_assertok(uclass_get_device_by_name(UCLASS_RESET, "reset-ctl",
24 &dev_reset));
25 ut_asserteq(0, sandbox_reset_query(dev_reset, TEST_RESET_ID));
26
27 ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "reset-ctl-test",
28 &dev_test));
29 ut_assertok(sandbox_reset_test_get(dev_test));
30
31 ut_assertok(sandbox_reset_test_assert(dev_test));
32 ut_asserteq(1, sandbox_reset_query(dev_reset, TEST_RESET_ID));
33
34 ut_assertok(sandbox_reset_test_deassert(dev_test));
35 ut_asserteq(0, sandbox_reset_query(dev_reset, TEST_RESET_ID));
36
37 ut_assertok(sandbox_reset_test_free(dev_test));
38
39 return 0;
40}
41DM_TEST(dm_test_reset, DM_TESTF_SCAN_FDT);
Neil Armstrong91f5f8b2018-04-03 11:40:51 +020042
43static int dm_test_reset_bulk(struct unit_test_state *uts)
44{
45 struct udevice *dev_reset;
46 struct udevice *dev_test;
47
48 ut_assertok(uclass_get_device_by_name(UCLASS_RESET, "reset-ctl",
49 &dev_reset));
50 ut_asserteq(0, sandbox_reset_query(dev_reset, TEST_RESET_ID));
51 ut_asserteq(0, sandbox_reset_query(dev_reset, OTHER_RESET_ID));
52
53 ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "reset-ctl-test",
54 &dev_test));
55 ut_assertok(sandbox_reset_test_get_bulk(dev_test));
56
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));
60
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));
64
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));
68
69 return 0;
70}
71DM_TEST(dm_test_reset_bulk, DM_TESTF_SCAN_FDT);