sunxi_gpio_set_flags() always programs the pull register when
switching a pin to input. When neither GPIOD_PULL_UP nor
GPIOD_PULL_DOWN is requested, this writes 0 (pull disabled)
and can clobber an existing bias configuration applied via pinctrl.

Only update the pull configuration when a pull-up or pull-down is
explicitly requested, leaving existing pull settings unchanged.

Fixes: 35ae126c16a6 ("gpio: sunxi: Implement .set_flags")
Signed-off-by: James Hilliard <[email protected]>
---
 drivers/gpio/sunxi_gpio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/sunxi_gpio.c b/drivers/gpio/sunxi_gpio.c
index 094c45a6927..ad891da3a97 100644
--- a/drivers/gpio/sunxi_gpio.c
+++ b/drivers/gpio/sunxi_gpio.c
@@ -301,7 +301,8 @@ static int sunxi_gpio_set_flags(struct udevice *dev, 
unsigned int offset,
                        pull = 1;
                else if (flags & GPIOD_PULL_DOWN)
                        pull = 2;
-               sunxi_gpio_set_pull_bank(plat->regs, offset, pull);
+               if (pull)
+                       sunxi_gpio_set_pull_bank(plat->regs, offset, pull);
                sunxi_gpio_set_cfgbank(plat->regs, offset, SUNXI_GPIO_INPUT);
        }
 
-- 
2.43.0

Reply via email to