[PATCH v3] pinctrl: meson: support gpio toggle command
Neil Armstrong
neil.armstrong at linaro.org
Tue Jun 17 10:33:43 CEST 2025
On 16/06/2025 19:01, Yang Xiwen via B4 Relay wrote:
> From: Yang Xiwen <forbidden405 at outlook.com>
>
> 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 at outlook.com>
> ---
> Changes in v3:
> - remove unused reg_type assignment.
> - Link to v2: https://lore.kernel.org/r/20250617-meson_ppinctrl-v2-1-16d1cb294ef4@outlook.com
>
> Changes in v2:
> - return -EINVAL directly in case of error. (Neil Armstrong <neil.armstrong at linaro.org>)
> - Link to v1: https://lore.kernel.org/r/20250617-meson_ppinctrl-v1-1-593aa15f288a@outlook.com
> ---
> drivers/pinctrl/meson/pinctrl-meson.c | 20 +++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
> index babf1bccc969..7dbaf966f93f 100644
> --- a/drivers/pinctrl/meson/pinctrl-meson.c
> +++ b/drivers/pinctrl/meson/pinctrl-meson.c
> @@ -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, ®,
> + 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, ®,
> &bit);
> if (ret)
> return ret;
>
> ---
> base-commit: c5afa1fef49f55146e78d6157470520391c40eca
> change-id: 20250617-meson_ppinctrl-5139ca06b828
>
> Best regards,
Reviewed-by: Neil Armstrong <neil.armstrong at linaro.org>
More information about the U-Boot
mailing list