Commit 91f5f8b73ccba5bf591912fe6e8c500a7d51eb93

Authored by Neil Armstrong
Committed by Tom Rini
1 parent 0c28233903

reset: add sandbox test for bulk API

This patch adds the bulk reset API tests for the sandbox test suite.

Unlike the main test, it also check the "other" reset signal using the bulk API
and checks if the resets are correctly asserted/deasserted.

To allow the bulk API to work, and avoid changing the DT, the number of resets
of the sandbox reset controller has been bumped to 101 for the "other" reset
line to be valid.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

Showing 4 changed files with 67 additions and 1 deletions Side-by-side Diff

arch/sandbox/include/asm/reset.h
... ... @@ -14,9 +14,13 @@
14 14 int sandbox_reset_query(struct udevice *dev, unsigned long id);
15 15  
16 16 int sandbox_reset_test_get(struct udevice *dev);
  17 +int sandbox_reset_test_get_bulk(struct udevice *dev);
17 18 int sandbox_reset_test_assert(struct udevice *dev);
  19 +int sandbox_reset_test_assert_bulk(struct udevice *dev);
18 20 int sandbox_reset_test_deassert(struct udevice *dev);
  21 +int sandbox_reset_test_deassert_bulk(struct udevice *dev);
19 22 int sandbox_reset_test_free(struct udevice *dev);
  23 +int sandbox_reset_test_release_bulk(struct udevice *dev);
20 24  
21 25 #endif
drivers/reset/sandbox-reset-test.c
... ... @@ -12,6 +12,7 @@
12 12  
13 13 struct sandbox_reset_test {
14 14 struct reset_ctl ctl;
  15 + struct reset_ctl_bulk bulk;
15 16 };
16 17  
17 18 int sandbox_reset_test_get(struct udevice *dev)
... ... @@ -21,6 +22,13 @@
21 22 return reset_get_by_name(dev, "test", &sbrt->ctl);
22 23 }
23 24  
  25 +int sandbox_reset_test_get_bulk(struct udevice *dev)
  26 +{
  27 + struct sandbox_reset_test *sbrt = dev_get_priv(dev);
  28 +
  29 + return reset_get_bulk(dev, &sbrt->bulk);
  30 +}
  31 +
24 32 int sandbox_reset_test_assert(struct udevice *dev)
25 33 {
26 34 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
... ... @@ -28,6 +36,13 @@
28 36 return reset_assert(&sbrt->ctl);
29 37 }
30 38  
  39 +int sandbox_reset_test_assert_bulk(struct udevice *dev)
  40 +{
  41 + struct sandbox_reset_test *sbrt = dev_get_priv(dev);
  42 +
  43 + return reset_assert_bulk(&sbrt->bulk);
  44 +}
  45 +
31 46 int sandbox_reset_test_deassert(struct udevice *dev)
32 47 {
33 48 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
34 49  
... ... @@ -35,11 +50,25 @@
35 50 return reset_deassert(&sbrt->ctl);
36 51 }
37 52  
  53 +int sandbox_reset_test_deassert_bulk(struct udevice *dev)
  54 +{
  55 + struct sandbox_reset_test *sbrt = dev_get_priv(dev);
  56 +
  57 + return reset_deassert_bulk(&sbrt->bulk);
  58 +}
  59 +
38 60 int sandbox_reset_test_free(struct udevice *dev)
39 61 {
40 62 struct sandbox_reset_test *sbrt = dev_get_priv(dev);
41 63  
42 64 return reset_free(&sbrt->ctl);
  65 +}
  66 +
  67 +int sandbox_reset_test_release_bulk(struct udevice *dev)
  68 +{
  69 + struct sandbox_reset_test *sbrt = dev_get_priv(dev);
  70 +
  71 + return reset_release_bulk(&sbrt->bulk);
43 72 }
44 73  
45 74 static const struct udevice_id sandbox_reset_test_ids[] = {
drivers/reset/sandbox-reset.c
... ... @@ -10,7 +10,7 @@
10 10 #include <asm/io.h>
11 11 #include <asm/reset.h>
12 12  
13   -#define SANDBOX_RESET_SIGNALS 3
  13 +#define SANDBOX_RESET_SIGNALS 101
14 14  
15 15 struct sandbox_reset_signal {
16 16 bool asserted;
... ... @@ -13,6 +13,9 @@
13 13 /* This must match the specifier for mbox-names="test" in the DT node */
14 14 #define TEST_RESET_ID 2
15 15  
  16 +/* This is the other reset phandle specifier handled by bulk */
  17 +#define OTHER_RESET_ID 2
  18 +
16 19 static int dm_test_reset(struct unit_test_state *uts)
17 20 {
18 21 struct udevice *dev_reset;
... ... @@ -37,4 +40,34 @@
37 40 return 0;
38 41 }
39 42 DM_TEST(dm_test_reset, DM_TESTF_SCAN_FDT);
  43 +
  44 +static int dm_test_reset_bulk(struct unit_test_state *uts)
  45 +{
  46 + struct udevice *dev_reset;
  47 + struct udevice *dev_test;
  48 +
  49 + ut_assertok(uclass_get_device_by_name(UCLASS_RESET, "reset-ctl",
  50 + &dev_reset));
  51 + ut_asserteq(0, sandbox_reset_query(dev_reset, TEST_RESET_ID));
  52 + ut_asserteq(0, sandbox_reset_query(dev_reset, OTHER_RESET_ID));
  53 +
  54 + ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "reset-ctl-test",
  55 + &dev_test));
  56 + ut_assertok(sandbox_reset_test_get_bulk(dev_test));
  57 +
  58 + ut_assertok(sandbox_reset_test_assert_bulk(dev_test));
  59 + ut_asserteq(1, sandbox_reset_query(dev_reset, TEST_RESET_ID));
  60 + ut_asserteq(1, sandbox_reset_query(dev_reset, OTHER_RESET_ID));
  61 +
  62 + ut_assertok(sandbox_reset_test_deassert_bulk(dev_test));
  63 + ut_asserteq(0, sandbox_reset_query(dev_reset, TEST_RESET_ID));
  64 + ut_asserteq(0, sandbox_reset_query(dev_reset, OTHER_RESET_ID));
  65 +
  66 + ut_assertok(sandbox_reset_test_release_bulk(dev_test));
  67 + ut_asserteq(1, sandbox_reset_query(dev_reset, TEST_RESET_ID));
  68 + ut_asserteq(1, sandbox_reset_query(dev_reset, OTHER_RESET_ID));
  69 +
  70 + return 0;
  71 +}
  72 +DM_TEST(dm_test_reset_bulk, DM_TESTF_SCAN_FDT);