Skip to content

Commit e6ebd49

Browse files
juhosglinusw
authored andcommitted
pinctrl: armada-37xx: set GPIO output value before setting direction
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: 6702abb ("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> Link: https://lore.kernel.org/20250514-pinctrl-a37xx-fixes-v2-2-07e9ac1ab737@gmail.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 947c93e commit e6ebd49

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

drivers/pinctrl/mvebu/pinctrl-armada-37xx.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -417,23 +417,22 @@ static int armada_37xx_gpio_direction_output(struct gpio_chip *chip,
417417
unsigned int offset, int value)
418418
{
419419
struct armada_37xx_pinctrl *info = gpiochip_get_data(chip);
420-
unsigned int val_offset = offset;
421-
unsigned int reg = OUTPUT_EN;
420+
unsigned int en_offset = offset;
421+
unsigned int reg = OUTPUT_VAL;
422422
unsigned int mask, val, ret;
423423

424424
armada_37xx_update_reg(&reg, &offset);
425425
mask = BIT(offset);
426+
val = value ? mask : 0;
426427

427-
ret = regmap_update_bits(info->regmap, reg, mask, mask);
428-
428+
ret = regmap_update_bits(info->regmap, reg, mask, val);
429429
if (ret)
430430
return ret;
431431

432-
reg = OUTPUT_VAL;
433-
armada_37xx_update_reg(&reg, &val_offset);
432+
reg = OUTPUT_EN;
433+
armada_37xx_update_reg(&reg, &en_offset);
434434

435-
val = value ? mask : 0;
436-
regmap_update_bits(info->regmap, reg, mask, val);
435+
regmap_update_bits(info->regmap, reg, mask, mask);
437436

438437
return 0;
439438
}

0 commit comments

Comments
 (0)