summaryrefslogtreecommitdiff
path: root/test/dm/gpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/dm/gpio.c')
-rw-r--r--test/dm/gpio.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/dm/gpio.c b/test/dm/gpio.c
index 33ae98701f..a8c35d4370 100644
--- a/test/dm/gpio.c
+++ b/test/dm/gpio.c
@@ -778,3 +778,33 @@ static int dm_test_gpio_get_values_as_int_base3(struct unit_test_state *uts)
}
DM_TEST(dm_test_gpio_get_values_as_int_base3,
UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+
+/* Check that gpio_get_status return the label of a GPIO configured as GPIOD_AF */
+static int dm_test_gpio_function(struct unit_test_state *uts)
+{
+ struct gpio_desc desc;
+ struct udevice *dev;
+ ulong flags;
+ unsigned int offset, gpio;
+ char buf[80];
+
+ ut_assertok(uclass_get_device(UCLASS_TEST_FDT, 0, &dev));
+ ut_asserteq_str("a-test", dev->name);
+
+ /* request gpio_b 5 */
+ ut_assertok(gpio_request_by_name(dev, "test-gpios", 2, &desc, 0));
+ /* update gpio_b 5 function to GPIO_AF */
+ ut_assertok(dm_gpio_clrset_flags(&desc, GPIOD_IS_AF, GPIOD_IS_AF));
+ ut_assertok(dm_gpio_get_flags(&desc, &flags));
+ ut_asserteq(GPIOD_IS_AF, flags);
+ /* check using gpio_get_status that label is displayed for a pin with GPIO_AF function */
+ ut_assertok(gpio_lookup_name("b5", &dev, &offset, &gpio));
+ ut_assertok(gpio_get_status(dev, offset, buf, sizeof(buf)));
+ ut_asserteq_str("b5: func a-test.test-gpios2", buf);
+
+ ut_assertok(dm_gpio_free(dev, &desc));
+
+ return 0;
+}
+DM_TEST(dm_test_gpio_function,
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);