[PATCH] dm: gpio: Return error when pull up/down is requested but set_flags ops is not implmentated

Zixun LI admin at hifiphile.com
Mon Oct 21 17:04:51 CEST 2024


Currently in _dm_gpio_set_flags() when set_flags ops is not implemented
direction_output()/_input() is used, but pull up/down is not supported by
these ops.

Signed-off-by: Zixun LI <admin at hifiphile.com>
---
We have updated our AT91 BSP to use DM, on field testing few boards
went into a failed state due to gpio pullup is not enabled. A floating
gpio doesn't always fail and can sometimes be hard to diagostic.
---
 drivers/gpio/gpio-uclass.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 712119c341..a58513c946 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -661,6 +661,9 @@ static int _dm_gpio_set_flags(struct gpio_desc *desc, ulong flags)
 	if (ops->set_flags) {
 		ret = ops->set_flags(dev, desc->offset, flags);
 	} else {
+		if (flags & GPIOD_MASK_PULL)
+			return -EINVAL;
+
 		if (flags & GPIOD_IS_OUT) {
 			bool value = flags & GPIOD_IS_OUT_ACTIVE;
 
-- 
2.46.2



More information about the U-Boot mailing list