Message ID | 20250512-pinctrl-a37xx-fixes-v1-3-d470fb1116a5@gmail.com |
---|---|
State | Superseded |
Headers | show |
Series | pinctrl: armada-37xx: a couple of small fixes | expand |
On Mon, May 12, 2025 at 04:22:39PM +0200, Gabor Juhos wrote: > 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: Gabor Juhos <j4g8y7@gmail.com> > Signed-off-by: Imre Kaloz <kaloz@openwrt.org> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Andrew
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c index e0c8eebf40588a1b49b80e2a1ddcc2a35fa7c07b..8d93d36af63ab9496376219454214c05db30971f 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; - return regmap_update_bits(info->regmap, reg, mask, val); + return regmap_update_bits(info->regmap, reg, mask, mask); } static int armada_37xx_gpio_get(struct gpio_chip *chip, unsigned int offset)