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]>
---
Changes v1 -> v2:
  - remove no local pull variable
---
 drivers/gpio/sunxi_gpio.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/sunxi_gpio.c b/drivers/gpio/sunxi_gpio.c
index 094c45a6927..9acf1c2ecab 100644
--- a/drivers/gpio/sunxi_gpio.c
+++ b/drivers/gpio/sunxi_gpio.c
@@ -295,13 +295,10 @@ static int sunxi_gpio_set_flags(struct udevice *dev, 
unsigned int offset,
                sunxi_gpio_set_value_bank(plat->regs, offset, value);
                sunxi_gpio_set_cfgbank(plat->regs, offset, SUNXI_GPIO_OUTPUT);
        } else if (flags & GPIOD_IS_IN) {
-               u32 pull = 0;
-
                if (flags & GPIOD_PULL_UP)
-                       pull = 1;
+                       sunxi_gpio_set_pull_bank(plat->regs, offset, 1);
                else if (flags & GPIOD_PULL_DOWN)
-                       pull = 2;
-               sunxi_gpio_set_pull_bank(plat->regs, offset, pull);
+                       sunxi_gpio_set_pull_bank(plat->regs, offset, 2);
                sunxi_gpio_set_cfgbank(plat->regs, offset, SUNXI_GPIO_INPUT);
        }
 
-- 
2.43.0

Reply via email to