In scripts as well as interactively, it's much nicer to be able to
refer to GPIOs via their names defined in the device tree property
"gpio-line-names", instead of the rather opaque names derived from the
bank name with a _xx suffix. E.g.
gpio read factory_reset FACTORY_RESET
if test $factory_reset = 1 ; then ...
versus
gpio read factory_reset gpio@481ac000_16
if test $factory_reset = 1 ; then ...
This is also consistent with the move on the linux/userspace side towards
using line names instead of legacy chip+offset or the even more legacy
global gpio numbering in sysfs.
As dev_read_stringlist_search() depends on both OF_CONTROL and
OF_LIBFDT (which matters for the SPL case), we need some .config
conditional. However, it only adds about ~50 bytes of code to U-Boot
proper, and dm_gpio_lookup_name() most often ends up being GC'ed for
SPL, thus adds no overhead there, so for now make it a hidden symbol
which is merely a convenient shorthand for
CONFIG_IS_ENABLED(OF_CONTROL) && CONFIG_IS_ENABLED(OF_LIBFDT).
Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
Reviewed-by: Heiko Schocher <hs@nabladev.com>
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
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) {
*/
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)