Now that gpio_request() is handled by the uclass, updates the tests accordingly.
Signed-off-by: Simon Glass <s...@chromium.org> --- doc/driver-model/README.txt | 25 +++++++++++++++++++-- test/dm/gpio.c | 55 +++++++++++++++++++++++++++------------------ 2 files changed, 56 insertions(+), 24 deletions(-) diff --git a/doc/driver-model/README.txt b/doc/driver-model/README.txt index 8dfcf75..1ff454a 100644 --- a/doc/driver-model/README.txt +++ b/doc/driver-model/README.txt @@ -95,7 +95,7 @@ are provided in test/dm. To run them, try: You should see something like this: <...U-Boot banner...> - Running 22 driver model tests + Running 26 driver model tests Test: dm_test_autobind Test: dm_test_autoprobe Test: dm_test_bus_children @@ -115,7 +115,8 @@ You should see something like this: Device 'd-test': seq 3 is in use by 'b-test' Device 'a-test': seq 0 is in use by 'd-test' Test: dm_test_gpio - sandbox_gpio: sb_gpio_get_value: error: offset 4 not reserved + extra-gpios: get_value: error: gpio b5 not reserved + Test: dm_test_gpio_anon Test: dm_test_leak Test: dm_test_lifecycle Test: dm_test_operations @@ -123,6 +124,26 @@ You should see something like this: Test: dm_test_platdata Test: dm_test_pre_reloc Test: dm_test_remove + Test: dm_test_spi_find + Invalid chip select 0:0 (err=-19) + SF: Failed to get idcodes + Device 'name-emul': seq 0 is in use by 'name-emul' + SF: Detected M25P16 with page size 256 Bytes, erase size 64 KiB, total 2 MiB + Test: dm_test_spi_flash + 2097152 bytes written in 0 ms + SF: Detected M25P16 with page size 256 Bytes, erase size 64 KiB, total 2 MiB + SPI flash test: + 0 erase: 0 ticks, 65536000 KiB/s 524288.000 Mbps + 1 check: 0 ticks, 65536000 KiB/s 524288.000 Mbps + 2 write: 0 ticks, 65536000 KiB/s 524288.000 Mbps + 3 read: 0 ticks, 65536000 KiB/s 524288.000 Mbps + Test passed + 0 erase: 0 ticks, 65536000 KiB/s 524288.000 Mbps + 1 check: 0 ticks, 65536000 KiB/s 524288.000 Mbps + 2 write: 0 ticks, 65536000 KiB/s 524288.000 Mbps + 3 read: 0 ticks, 65536000 KiB/s 524288.000 Mbps + Test: dm_test_spi_xfer + SF: Detected M25P16 with page size 256 Bytes, erase size 64 KiB, total 2 MiB Test: dm_test_uclass Test: dm_test_uclass_before_ready Failures: 0 diff --git a/test/dm/gpio.c b/test/dm/gpio.c index 2b2b0b5..ad56ca5 100644 --- a/test/dm/gpio.c +++ b/test/dm/gpio.c @@ -39,52 +39,51 @@ static int dm_test_gpio(struct dm_test_state *dms) /* Get the operations for this device */ ops = gpio_get_ops(dev); - ut_assert(ops->get_state); + ut_assert(ops->get_function); /* Cannot get a value until it is reserved */ - ut_asserteq(-1, ops->get_value(dev, offset)); - + ut_asserteq(-EBUSY, gpio_get_value(gpio + 1)); /* * Now some tests that use the 'sandbox' back door. All GPIOs * should default to input, include b4 that we are using here. */ - ut_assertok(ops->get_state(dev, offset, buf, sizeof(buf))); - ut_asserteq_str("b4: in: 0 [ ]", buf); + ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf))); + ut_asserteq_str("b4: input: 0 [ ]", buf); /* Change it to an output */ sandbox_gpio_set_direction(dev, offset, 1); - ut_assertok(ops->get_state(dev, offset, buf, sizeof(buf))); - ut_asserteq_str("b4: out: 0 [ ]", buf); + ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf))); + ut_asserteq_str("b4: output: 0 [ ]", buf); sandbox_gpio_set_value(dev, offset, 1); - ut_assertok(ops->get_state(dev, offset, buf, sizeof(buf))); - ut_asserteq_str("b4: out: 1 [ ]", buf); + ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf))); + ut_asserteq_str("b4: output: 1 [ ]", buf); - ut_assertok(ops->request(dev, offset, "testing")); - ut_assertok(ops->get_state(dev, offset, buf, sizeof(buf))); - ut_asserteq_str("b4: out: 1 [x] testing", buf); + ut_assertok(gpio_request(gpio, "testing")); + ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf))); + ut_asserteq_str("b4: output: 1 [x] testing", buf); /* Change the value a bit */ ut_asserteq(1, ops->get_value(dev, offset)); ut_assertok(ops->set_value(dev, offset, 0)); ut_asserteq(0, ops->get_value(dev, offset)); - ut_assertok(ops->get_state(dev, offset, buf, sizeof(buf))); - ut_asserteq_str("b4: out: 0 [x] testing", buf); + ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf))); + ut_asserteq_str("b4: output: 0 [x] testing", buf); ut_assertok(ops->set_value(dev, offset, 1)); ut_asserteq(1, ops->get_value(dev, offset)); /* Make it an input */ ut_assertok(ops->direction_input(dev, offset)); - ut_assertok(ops->get_state(dev, offset, buf, sizeof(buf))); - ut_asserteq_str("b4: in: 1 [x] testing", buf); + ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf))); + ut_asserteq_str("b4: input: 1 [x] testing", buf); sandbox_gpio_set_value(dev, offset, 0); ut_asserteq(0, sandbox_gpio_get_value(dev, offset)); - ut_assertok(ops->get_state(dev, offset, buf, sizeof(buf))); - ut_asserteq_str("b4: in: 0 [x] testing", buf); + ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf))); + ut_asserteq_str("b4: input: 0 [x] testing", buf); - ut_assertok(ops->free(dev, offset)); - ut_assertok(ops->get_state(dev, offset, buf, sizeof(buf))); - ut_asserteq_str("b4: in: 0 [ ]", buf); + ut_assertok(gpio_free(gpio)); + ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf))); + ut_asserteq_str("b4: input: 0 [ ]", buf); /* Check the 'a' bank also */ ut_assertok(gpio_lookup_name("a15", &dev, &offset, &gpio)); @@ -96,6 +95,18 @@ static int dm_test_gpio(struct dm_test_state *dms) ut_asserteq_str("a", name); ut_asserteq(20, offset_count); + return 0; +} +DM_TEST(dm_test_gpio, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test that sandbox anonymous GPIOs work correctly */ +static int dm_test_gpio_anon(struct dm_test_state *dms) +{ + unsigned int offset, gpio; + struct udevice *dev; + const char *name; + int offset_count; + /* And the anonymous bank */ ut_assertok(gpio_lookup_name("14", &dev, &offset, &gpio)); ut_asserteq_str(dev->name, "gpio_sandbox"); @@ -108,4 +119,4 @@ static int dm_test_gpio(struct dm_test_state *dms) return 0; } -DM_TEST(dm_test_gpio, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); +DM_TEST(dm_test_gpio_anon, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); -- 2.1.0.rc2.206.gedb03e5 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot