Skip to content

Commit

Permalink
gpio: 74x164: Enable output pins after registers are reset
Browse files Browse the repository at this point in the history
[ Upstream commit 530b1dbd97846b110ea8a94c7cc903eca21786e5 ]

Chip outputs are enabled[1] before actual reset is performed[2] which might
cause pin output value to flip flop if previous pin value was set to 1.
Fix that behavior by making sure chip is fully reset before all outputs are
enabled.

Flip-flop can be noticed when module is removed and inserted again and one of
the pins was changed to 1 before removal. 100 microsecond flipping is
noticeable on oscilloscope (100khz SPI bus).

For a properly reset chip - output is enabled around 100 microseconds (on 100khz
SPI bus) later during probing process hence should be irrelevant behavioral
change.

Fixes: 7ebc194 (gpio: 74x164: Introduce 'enable-gpios' property)
Link: https://elixir.bootlin.com/linux/v6.7.4/source/drivers/gpio/gpio-74x164.c#L130 [1]
Link: https://elixir.bootlin.com/linux/v6.7.4/source/drivers/gpio/gpio-74x164.c#L150 [2]
Signed-off-by: Arturas Moskvinas <[email protected]>
Signed-off-by: Bartosz Golaszewski <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
artms authored and AK-Papon committed Mar 7, 2024
1 parent 2ffe8e3 commit 219ce1d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/gpio/gpio-74x164.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ static int gen_74x164_probe(struct spi_device *spi)
if (IS_ERR(chip->gpiod_oe))
return PTR_ERR(chip->gpiod_oe);

gpiod_set_value_cansleep(chip->gpiod_oe, 1);

spi_set_drvdata(spi, chip);

chip->gpio_chip.label = spi->modalias;
Expand All @@ -158,6 +156,8 @@ static int gen_74x164_probe(struct spi_device *spi)
goto exit_destroy;
}

gpiod_set_value_cansleep(chip->gpiod_oe, 1);

ret = gpiochip_add_data(&chip->gpio_chip, chip);
if (!ret)
return 0;
Expand Down

0 comments on commit 219ce1d

Please sign in to comment.