Skip to contentSkip to conversation

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

PATCH In review Zixun LI 2 participants 2 messages Oct 21, 2024 – Dec 6, 2024 GPIO

lore
Share & tools
lore

Zixun LI

author
#0 lore raw

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

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.

---
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(+)
drivers/gpio/gpio-uclass.c +3 -0
index 712119c341..a58513c946 100644
@@ -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;
 
Signature · 1 line
2.46.2
#1 lore raw
Quoted 5 lines · Zixun LI

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.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom