* [PATCH] pinctrl: meson: amlogic-a4: fix gpio output glitch
@ 2026-05-18 8:26 Xianwei Zhao via B4 Relay
2026-05-18 14:32 ` Neil Armstrong
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Xianwei Zhao via B4 Relay @ 2026-05-18 8:26 UTC (permalink / raw)
To: Linus Walleij, Neil Armstrong, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl
Cc: linux-amlogic, linux-gpio, linux-arm-kernel, linux-kernel,
Xianwei Zhao
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, ®, &bit);
- ret = regmap_update_bits(bank->reg_gpio, reg, BIT(bit), 0);
+ aml_gpio_calc_reg_and_bit(bank, AML_REG_OUT, gpio, ®, &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, ®, &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, ®, &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,
--
Xianwei Zhao <xianwei.zhao@amlogic•com>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] pinctrl: meson: amlogic-a4: fix gpio output glitch
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
2026-05-25 8:34 ` Linus Walleij
2026-05-26 9:54 ` Linus Walleij
2 siblings, 0 replies; 5+ messages in thread
From: Neil Armstrong @ 2026-05-18 14:32 UTC (permalink / raw)
To: xianwei.zhao, Linus Walleij, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl
Cc: linux-amlogic, linux-gpio, linux-arm-kernel, linux-kernel
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, ®, &bit);
> - ret = regmap_update_bits(bank->reg_gpio, reg, BIT(bit), 0);
> + aml_gpio_calc_reg_and_bit(bank, AML_REG_OUT, gpio, ®, &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, ®, &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, ®, &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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] pinctrl: meson: amlogic-a4: fix gpio output glitch
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
@ 2026-05-25 8:34 ` Linus Walleij
2026-05-25 11:16 ` Xianwei Zhao
2026-05-26 9:54 ` Linus Walleij
2 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2026-05-25 8:34 UTC (permalink / raw)
To: xianwei.zhao
Cc: Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
linux-amlogic, linux-gpio, linux-arm-kernel, linux-kernel
On Mon, May 18, 2026 at 10:26 AM Xianwei Zhao via B4 Relay
<devnull+xianwei.zhao.amlogic.com@kernel•org> 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>
Is this a regression? I.e. does it cause problems on a supported
system with mainline?
Linus (the big penguin) is unhappy with too many non-critical fixes
so I wanna check this before this goes into fixes.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] pinctrl: meson: amlogic-a4: fix gpio output glitch
2026-05-25 8:34 ` Linus Walleij
@ 2026-05-25 11:16 ` Xianwei Zhao
0 siblings, 0 replies; 5+ messages in thread
From: Xianwei Zhao @ 2026-05-25 11:16 UTC (permalink / raw)
To: Linus Walleij
Cc: Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
linux-amlogic, linux-gpio, linux-arm-kernel, linux-kernel
Hi Linus,
Thanks for your review.
On 2026/5/25 16:34, Linus Walleij wrote:
> On Mon, May 18, 2026 at 10:26 AM Xianwei Zhao via B4 Relay
> <devnull+xianwei.zhao.amlogic.com@kernel•org> 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>
> Is this a regression? I.e. does it cause problems on a supported
> system with mainline?
>
> Linus (the big penguin) is unhappy with too many non-critical fixes
> so I wanna check this before this goes into fixes.
>
The issue only occurs when the critical power supply uses GPIO control.
Otherwise, it is not significant.
> Yours,
> Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] pinctrl: meson: amlogic-a4: fix gpio output glitch
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
2026-05-25 8:34 ` Linus Walleij
@ 2026-05-26 9:54 ` Linus Walleij
2 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2026-05-26 9:54 UTC (permalink / raw)
To: xianwei.zhao
Cc: Neil Armstrong, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
linux-amlogic, linux-gpio, linux-arm-kernel, linux-kernel
On Mon, May 18, 2026 at 10:26 AM Xianwei Zhao via B4 Relay
<devnull+xianwei.zhao.amlogic.com@kernel•org> 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>
Patch applied as non-critical fix based on my gut feeling.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-05-26 9:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2026-05-25 8:34 ` Linus Walleij
2026-05-25 11:16 ` Xianwei Zhao
2026-05-26 9:54 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox