diff options
| author | Tom Rini <[email protected]> | 2025-11-11 14:53:47 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2025-11-11 14:53:47 -0600 |
| commit | 10fec1b7a36dcd902274fe136ff1e3ba280ecef4 (patch) | |
| tree | 57c4d7e03a950d09cd80091f353ab99a5a973adc /drivers/gpio | |
| parent | 62e89de7698a637c673b08ec129941d8079a5405 (diff) | |
| parent | e5e4b60c55e448e6a9a6bf6f7e9cfd01fe3103e1 (diff) | |
Merge patch series "reenable dm_gpio tests, add support for gpio-line-names lookup"
Rasmus Villemoes <[email protected]> says:
Hopefully third time's the charm.
I merely wanted to add support (mostly for use by the 'gpio' shell
command) for looking up a gpio via the gpio-line-names DT property. We
already have a "gpio_request_by_line_name()", but cmd/gpio.c does a
separate "lookup + request", so it felt more natural to teach the
lookup machinery this as well. That ran into
OF_CONTROL-but-not-OF_LIBFDT being a thing for SPL, so here's yet
another attempt.
Now, when trying to do my civic duty and add tests for this, I found
that test/dm/gpio.c has been defunct for a couple of years, and
reinstating it is not entirely trivial.
After a couple of rounds CI is now happy with this:
https://github.com/u-boot/u-boot/pull/828
Link: https://lore.kernel.org/r/[email protected]
Diffstat (limited to 'drivers/gpio')
| -rw-r--r-- | drivers/gpio/Kconfig | 16 | ||||
| -rw-r--r-- | drivers/gpio/gpio-uclass.c | 11 |
2 files changed, 26 insertions, 1 deletions
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index db077e472a8..a47c127d98c 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -97,6 +97,22 @@ config SPL_DM_GPIO_LOOKUP_LABEL different gpios on different hardware versions for the same functionality in board code. +config DM_GPIO_LOOKUP_LINE_NAME + def_bool y + depends on OF_CONTROL && OF_LIBFDT + help + This option enables specifying a GPIO by referring to its + name as defined by the "gpio-line-names" property in the + gpio controller's devicetree node. + +config SPL_DM_GPIO_LOOKUP_LINE_NAME + def_bool y + depends on SPL_OF_CONTROL && SPL_OF_LIBFDT + help + This option enables specifying a GPIO by referring to its + name as defined by the "gpio-line-names" property in the + gpio controller's devicetree node. + config ADI_GPIO bool "ADI GPIO driver" depends on DM_GPIO && ARCH_SC5XX diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index 7559b8dc7e2..38151ef1bee 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -164,7 +164,7 @@ int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc) for (uclass_first_device(UCLASS_GPIO, &dev); dev; uclass_next_device(&dev)) { - int len; + int len, ret; uc_priv = dev_get_uclass_priv(dev); if (numeric != -1) { @@ -188,6 +188,15 @@ int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc) */ if (!dm_gpio_lookup_label(name, uc_priv, &offset)) break; + + /* Also search the "gpio-line-names" property in DT for a match. */ + if (CONFIG_IS_ENABLED(DM_GPIO_LOOKUP_LINE_NAME)) { + ret = dev_read_stringlist_search(dev, "gpio-line-names", name); + if (ret >= 0) { + offset = ret; + break; + } + } } if (!dev) |
