public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: Neil Armstrong <neil.armstrong@linaro•org>
To: xianwei.zhao@amlogic•com, Linus Walleij <linusw@kernel•org>,
	Kevin Hilman <khilman@baylibre•com>,
	Jerome Brunet <jbrunet@baylibre•com>,
	Martin Blumenstingl <martin.blumenstingl@googlemail•com>
Cc: linux-amlogic@lists•infradead.org, linux-gpio@vger•kernel.org,
	linux-arm-kernel@lists•infradead.org,
	linux-kernel@vger•kernel.org
Subject: Re: [PATCH] pinctrl: meson: amlogic-a4: fix gpio output glitch
Date: Mon, 18 May 2026 16:32:00 +0200	[thread overview]
Message-ID: <72b341e6-5ada-48e9-a9c1-a442810b15da@linaro.org> (raw)
In-Reply-To: <20260518-fix-set-value-glitch-v1-1-d350732dc934@amlogic.com>

On 5/18/26 10:26, Xianwei Zhao via B4 Relay wrote:
> From: Xianwei Zhao <xianwei.zhao@amlogic•com>
> 
> When the system transitions from bootloader to kernel, the GPIO is
> expected to keep driving high.
> 
> However, the Linux kernel first configures the pin direction and then
> sets the output value. This may cause a brief low-level glitch on the
> GPIO line, which can be problematic for regulator control.
> 
> By configuring the output value before switching the pin direction to
> output, the glitch can be avoided.
> 
> This commit fixes the issue by swapping the configuration order.
> 
> Fixes: 6e9be3abb78c ("pinctrl: Add driver support for Amlogic SoCs")
> Signed-off-by: Xianwei Zhao <xianwei.zhao@amlogic•com>
> ---
> fix one issue when set gpio line high.
> ---
>   drivers/pinctrl/meson/pinctrl-amlogic-a4.c | 15 +++++++--------
>   1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/pinctrl/meson/pinctrl-amlogic-a4.c b/drivers/pinctrl/meson/pinctrl-amlogic-a4.c
> index 35d27626a336..1bd58fbbd26a 100644
> --- a/drivers/pinctrl/meson/pinctrl-amlogic-a4.c
> +++ b/drivers/pinctrl/meson/pinctrl-amlogic-a4.c
> @@ -548,11 +548,11 @@ static int aml_pinconf_set_output_drive(struct aml_pinctrl *info,
>   {
>   	int ret;
>   
> -	ret = aml_pinconf_set_output(info, pin, true);
> +	ret = aml_pinconf_set_drive(info, pin, high);
>   	if (ret)
>   		return ret;
>   
> -	return aml_pinconf_set_drive(info, pin, high);
> +	return aml_pinconf_set_output(info, pin, true);
>   }
>   
>   static int aml_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin,
> @@ -921,15 +921,14 @@ static int aml_gpio_direction_output(struct gpio_chip *chip, unsigned int gpio,
>   	unsigned int bit, reg;
>   	int ret;
>   
> -	aml_gpio_calc_reg_and_bit(bank, AML_REG_DIR, gpio, &reg, &bit);
> -	ret = regmap_update_bits(bank->reg_gpio, reg, BIT(bit), 0);
> +	aml_gpio_calc_reg_and_bit(bank, AML_REG_OUT, gpio, &reg, &bit);
> +	ret = regmap_update_bits(bank->reg_gpio, reg, BIT(bit),
> +				 value ? BIT(bit) : 0);
>   	if (ret < 0)
>   		return ret;
>   
> -	aml_gpio_calc_reg_and_bit(bank, AML_REG_OUT, gpio, &reg, &bit);
> -
> -	return regmap_update_bits(bank->reg_gpio, reg, BIT(bit),
> -				  value ? BIT(bit) : 0);
> +	aml_gpio_calc_reg_and_bit(bank, AML_REG_DIR, gpio, &reg, &bit);
> +	return regmap_update_bits(bank->reg_gpio, reg, BIT(bit), 0);
>   }
>   
>   static int aml_gpio_set(struct gpio_chip *chip, unsigned int gpio, int value)
> 
> ---
> base-commit: 73d4991a6949eedb51e442d4e81415017d85975b
> change-id: 20260518-fix-set-value-glitch-f43cd366c295
> 
> Best regards,

Reviewed-by: Neil Armstrong <neil.armstrong@linaro•org>

Thanks,
Neil


  reply	other threads:[~2026-05-18 14:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-18  8:26 [PATCH] pinctrl: meson: amlogic-a4: fix gpio output glitch Xianwei Zhao via B4 Relay
2026-05-18 14:32 ` Neil Armstrong [this message]
2026-05-25  8:34 ` Linus Walleij
2026-05-25 11:16   ` Xianwei Zhao
2026-05-26  9:54 ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=72b341e6-5ada-48e9-a9c1-a442810b15da@linaro.org \
    --to=neil.armstrong@linaro$(echo .)org \
    --cc=jbrunet@baylibre$(echo .)com \
    --cc=khilman@baylibre$(echo .)com \
    --cc=linusw@kernel$(echo .)org \
    --cc=linux-amlogic@lists$(echo .)infradead.org \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    --cc=linux-gpio@vger$(echo .)kernel.org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=martin.blumenstingl@googlemail$(echo .)com \
    --cc=xianwei.zhao@amlogic$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox