From: Gabor Juhos <j4g8y7@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>,
Gregory Clement <gregory.clement@bootlin.com>,
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Imre Kaloz <kaloz@openwrt.org>,
linux-arm-kernel@lists.infradead.org,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Gabor Juhos <j4g8y7@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH v2 2/7] pinctrl: armada-37xx: set GPIO output value before setting direction
Date: Wed, 14 May 2025 21:18:33 +0200 [thread overview]
Message-ID: <20250514-pinctrl-a37xx-fixes-v2-2-07e9ac1ab737@gmail.com> (raw)
In-Reply-To: <20250514-pinctrl-a37xx-fixes-v2-0-07e9ac1ab737@gmail.com>
Changing the direction before updating the output value in the
OUTPUT_VAL register may result in a glitch on the output line
if the previous value in the OUTPUT_VAL register is different
from the one we want to set.
In order to avoid that, update the output value before changing
the direction.
Cc: stable@vger.kernel.org
Fixes: 6702abb3bf23 ("pinctrl: armada-37xx: Fix direction_output() callback behavior")
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Gabor Juhos <j4g8y7@gmail.com>
---
Changes in v2:
- swap with patch 3 from v1
- add 'Reviewed-by' tag from Andrew
- reorder 'Signed-off-by' tags (result of 'b4 trailers -u')
---
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
index 43034d29292687e875136aafa530b62479dc55ec..79f9c08e5039c31acb170d4f38b516b1454fd9ea 100644
--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
@@ -417,23 +417,22 @@ static int armada_37xx_gpio_direction_output(struct gpio_chip *chip,
unsigned int offset, int value)
{
struct armada_37xx_pinctrl *info = gpiochip_get_data(chip);
- unsigned int val_offset = offset;
- unsigned int reg = OUTPUT_EN;
+ unsigned int en_offset = offset;
+ unsigned int reg = OUTPUT_VAL;
unsigned int mask, val, ret;
armada_37xx_update_reg(®, &offset);
mask = BIT(offset);
+ val = value ? mask : 0;
- ret = regmap_update_bits(info->regmap, reg, mask, mask);
-
+ ret = regmap_update_bits(info->regmap, reg, mask, val);
if (ret)
return ret;
- reg = OUTPUT_VAL;
- armada_37xx_update_reg(®, &val_offset);
+ reg = OUTPUT_EN;
+ armada_37xx_update_reg(®, &en_offset);
- val = value ? mask : 0;
- regmap_update_bits(info->regmap, reg, mask, val);
+ regmap_update_bits(info->regmap, reg, mask, mask);
return 0;
}
--
2.49.0
next prev parent reply other threads:[~2025-05-14 19:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-14 19:18 [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes Gabor Juhos
2025-05-14 19:18 ` [PATCH v2 1/7] pinctrl: armada-37xx: use correct OUTPUT_VAL register for GPIOs > 31 Gabor Juhos
2025-05-14 19:18 ` Gabor Juhos [this message]
2025-05-14 19:18 ` [PATCH v2 3/7] pinctrl: armada-37xx: propagate error from armada_37xx_gpio_direction_output() Gabor Juhos
2025-05-14 19:18 ` [PATCH v2 4/7] pinctrl: armada-37xx: propagate error from armada_37xx_gpio_get() Gabor Juhos
2025-05-14 19:18 ` [PATCH v2 5/7] pinctrl: armada-37xx: propagate error from armada_37xx_pmx_gpio_set_direction() Gabor Juhos
2025-05-14 19:18 ` [PATCH v2 6/7] pinctrl: armada-37xx: propagate error from armada_37xx_gpio_get_direction() Gabor Juhos
2025-05-14 19:18 ` [PATCH v2 7/7] pinctrl: armada-37xx: propagate error from armada_37xx_pmx_set_by_name() Gabor Juhos
2025-05-14 22:28 ` [PATCH v2 0/7] pinctrl: armada-37xx: a couple of small fixes Linus Walleij
2025-05-15 7:45 ` Gabor Juhos
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=20250514-pinctrl-a37xx-fixes-v2-2-07e9ac1ab737@gmail.com \
--to=j4g8y7@gmail.com \
--cc=andrew@lunn.ch \
--cc=brgl@bgdev.pl \
--cc=gregory.clement@bootlin.com \
--cc=kaloz@openwrt.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sebastian.hesselbarth@gmail.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).