]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
pinctrl: meson: support gpio toggle command
authorYang Xiwen <forbidden405@outlook.com>
Mon, 16 Jun 2025 17:01:17 +0000 (01:01 +0800)
committerNeil Armstrong <neil.armstrong@linaro.org>
Tue, 30 Sep 2025 18:32:15 +0000 (20:32 +0200)
meson_gpio_get() always assumes gpio is configured to input mode. This
is incorrect and breaks `gpio toggle` command:

gpio: pin aobus-banks2 (gpio 2) value is 0
   Warning: value of pin is still 1

Fix it by adding the logic to handle both input and output mode.

Fixes: 2009a8d03fe5 ("pinctrl: meson: add GPIO support")
Signed-off-by: Yang Xiwen <forbidden405@outlook.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://lore.kernel.org/r/20250617-meson_ppinctrl-v3-1-218d9321a8d2@outlook.com
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
drivers/pinctrl/meson/pinctrl-meson.c

index babf1bccc9697596522dc93d8906ff0454cfebf5..7dbaf966f93f5fb48e8b15e63bfd1e94f0bc67f3 100644 (file)
@@ -117,8 +117,26 @@ int meson_gpio_get(struct udevice *dev, unsigned int offset)
        struct meson_pinctrl *priv = dev_get_priv(dev->parent);
        unsigned int reg, bit;
        int ret;
+       enum gpio_func_t direction;
+       enum meson_reg_type reg_type;
 
-       ret = meson_gpio_calc_reg_and_bit(dev->parent, offset, REG_IN, &reg,
+       direction = meson_gpio_get_direction(dev, offset);
+
+       switch (direction) {
+       case GPIOF_INPUT:
+               reg_type = REG_IN;
+               break;
+
+       case GPIOF_OUTPUT:
+               reg_type = REG_OUT;
+               break;
+
+       default:
+               dev_warn(dev, "Failed to get current direction of Pin %u\n", offset);
+               return -EINVAL;
+       }
+
+       ret = meson_gpio_calc_reg_and_bit(dev->parent, offset, reg_type, &reg,
                                          &bit);
        if (ret)
                return ret;