From 2bd261dd1712561b8363fbf6f9f630176fe99caa Mon Sep 17 00:00:00 2001 From: Heiko Schocher Date: Fri, 22 May 2020 11:08:59 +0200 Subject: gpio: search for gpio label if gpio is not found through bank name dm_gpio_lookup_name() searches for a gpio through the bank name. But we have also gpio labels, and it makes sense to search for a gpio also in the labels we have defined, if no gpio is found through the bank name definition. This is useful for example if you have a wp pin on different gpios on different board versions. If dm_gpio_lookup_name() searches also for the gpio labels, you can give the gpio an unique label name and search for this label, and do not need to differ between board revisions. Signed-off-by: Heiko Schocher Reviewed-by: Simon Glass [trini: Don't enable by default] Signed-off-by: Tom Rini --- test/dm/gpio.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test') diff --git a/test/dm/gpio.c b/test/dm/gpio.c index ecba566983..fcee1fe598 100644 --- a/test/dm/gpio.c +++ b/test/dm/gpio.c @@ -132,6 +132,15 @@ static int dm_test_gpio(struct unit_test_state *uts) ut_assertok(dm_gpio_set_value(desc, 0)); ut_asserteq(0, dm_gpio_get_value(desc)); + /* Check if lookup for labels work */ + ut_assertok(gpio_lookup_name("hog_input_active_low", &dev, &offset, + &gpio)); + ut_asserteq_str(dev->name, "base-gpios"); + ut_asserteq(0, offset); + ut_asserteq(CONFIG_SANDBOX_GPIO_COUNT + 0, gpio); + ut_assert(gpio_lookup_name("hog_not_exist", &dev, &offset, + &gpio)); + return 0; } DM_TEST(dm_test_gpio, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); -- cgit v1.2.1