Skip to content

Commit c8980f4

Browse files
juhosgpopcornmix
authored andcommitted
pinctrl: armada-37xx: set GPIO output value before setting direction
commit e6ebd49 upstream. 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: [email protected] Fixes: 6702abb ("pinctrl: armada-37xx: Fix direction_output() callback behavior") Signed-off-by: Imre Kaloz <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: Gabor Juhos <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7d2c8a5 commit c8980f4

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)