summaryrefslogtreecommitdiff
path: root/test/dm/gpio.c
diff options
context:
space:
mode:
authorHeiko Schocher <hs@denx.de>2020-05-22 11:08:58 +0200
committerTom Rini <trini@konsulko.com>2020-07-05 08:06:09 -0400
commit9ba84329dc45f28f8581e95de155b5bf0373bb3d (patch)
tree7a276566b545e1a8df7f2113d67baaace3c5b2e8 /test/dm/gpio.c
parentcd2faeba1abc08e5adba736e75dc665742cc310c (diff)
downloadu-boot-9ba84329dc45f28f8581e95de155b5bf0373bb3d.tar.gz
sandbox, test: add test for GPIO_HOG function
currently gpio hog function is not tested with "ut dm gpio" so add some basic tests for gpio hog functionality. For this enable GPIO_HOG in sandbox_defconfig, add in DTS some gpio hog entries, and add testcase in "ut dm gpio" command. Signed-off-by: Heiko Schocher <hs@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/dm/gpio.c')
-rw-r--r--test/dm/gpio.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/dm/gpio.c b/test/dm/gpio.c
index b5ee4e4f87..ecba566983 100644
--- a/test/dm/gpio.c
+++ b/test/dm/gpio.c
@@ -20,6 +20,7 @@ static int dm_test_gpio(struct unit_test_state *uts)
unsigned int offset, gpio;
struct dm_gpio_ops *ops;
struct udevice *dev;
+ struct gpio_desc *desc;
const char *name;
int offset_count;
char buf[80];
@@ -109,6 +110,28 @@ static int dm_test_gpio(struct unit_test_state *uts)
ut_asserteq_str("a", name);
ut_asserteq(20, offset_count);
+ /* add gpio hog tests */
+ ut_assertok(gpio_hog_lookup_name("hog_input_active_low", &desc));
+ ut_asserteq(GPIOD_IS_IN | GPIOD_ACTIVE_LOW, desc->flags);
+ ut_asserteq(0, desc->offset);
+ ut_asserteq(1, dm_gpio_get_value(desc));
+ ut_assertok(gpio_hog_lookup_name("hog_input_active_high", &desc));
+ ut_asserteq(GPIOD_IS_IN, desc->flags);
+ ut_asserteq(1, desc->offset);
+ ut_asserteq(0, dm_gpio_get_value(desc));
+ ut_assertok(gpio_hog_lookup_name("hog_output_low", &desc));
+ ut_asserteq(GPIOD_IS_OUT, desc->flags);
+ ut_asserteq(2, desc->offset);
+ ut_asserteq(0, dm_gpio_get_value(desc));
+ ut_assertok(dm_gpio_set_value(desc, 1));
+ ut_asserteq(1, dm_gpio_get_value(desc));
+ ut_assertok(gpio_hog_lookup_name("hog_output_high", &desc));
+ ut_asserteq(GPIOD_IS_OUT, desc->flags);
+ ut_asserteq(3, desc->offset);
+ ut_asserteq(1, dm_gpio_get_value(desc));
+ ut_assertok(dm_gpio_set_value(desc, 0));
+ ut_asserteq(0, dm_gpio_get_value(desc));
+
return 0;
}
DM_TEST(dm_test_gpio, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);