Skip to contentSkip to conversation

gpio: 74x164: Enable output pins after registers are reset

PATCH Superseded Arturas Moskvinas 3 participants 7 messages Feb 29, 2024 1 message not in the archive GPIO

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 gpio: 74x164: Enable output pins after registers are reset

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 in chip. Change fixes 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.

[1] - https://elixir.bootlin.com/linux/v6.7.4/source/drivers/gpio/gpio-74x164.c#L130
[2] - https://elixir.bootlin.com/linux/v6.7.4/source/drivers/gpio/gpio-74x164.c#L150

---
v1 -> v2
* Updated commit message to contain more information why a change is made.

---
 drivers/gpio/gpio-74x164.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-74x164.c +2 -2
index e00c33310517..753e7be039e4 100644
@@ -127,8 +127,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;
@@ -153,6 +151,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;

base-commit: d206a76d7d2726f3b096037f2079ce0bd3ba329b

Signature · 1 line
2.44.0
#1 lore raw
Quoted 6 lines · Arturas Moskvinas

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 in chip. Change fixes that behavior by making sure chip is fully reset before all outputs are enabled.

Use imperative mood in commit messages - make it: "Fix that behavior by making sure ...".

Quoted 4 lines

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).

Quoted 8 lines

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.

[1] - https://elixir.bootlin.com/linux/v6.7.4/source/drivers/gpio/gpio-74x164.c#L130
[2] - https://elixir.bootlin.com/linux/v6.7.4/source/drivers/gpio/gpio-74x164.c#L150

This looks much better, can you add a Fixes: tag as well?

Bartosz

Quoted 35 lines

---
v1 -> v2
* Updated commit message to contain more information why a change is made.

---
 drivers/gpio/gpio-74x164.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-74x164.c +2 -2
index e00c33310517..753e7be039e4 100644
@@ -127,8 +127,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;
@@ -153,6 +151,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;

base-commit: d206a76d7d2726f3b096037f2079ce0bd3ba329b --
2.44.0

#2 lore raw
Quoted 9 lines · Bartosz Golaszewski
Quoted 5 lines · Arturas Moskvinas

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 in chip. Change fixes that behavior by making sure chip is fully reset before all outputs are enabled.

Use imperative mood in commit messages - make it: "Fix that behavior by making sure ...".

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 in chip. Fix that behavior by making sure chip is fully reset before all outputs are enabled.

Bartosz, does this look better?

Arturas Moskvinas

#3 lore raw
Quoted 13 lines · Arturas Moskvinas
Quoted 9 lines · Bartosz Golaszewski
Quoted 5 lines · Arturas Moskvinas

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 in chip. Change fixes that behavior by making sure chip is fully reset before all outputs are enabled.

Use imperative mood in commit messages - make it: "Fix that behavior by making sure ...".

Quoted 7 lines

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 in chip.
Fix that behavior by making sure chip is fully reset before all outputs are enabled.

Bartosz, does this look better?

... if previous pin value was set to 1 period

Bart

Quoted 2 lines

Arturas Moskvinas

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 35 lines · Arturas Moskvinas

On 2/29/24 15:25, Bartosz Golaszewski wrote:

On Thu, Feb 29, 2024 at 1:23 PM Arturas Moskvinas
<[email protected]> wrote:

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 in chip.
Fix that behavior by making sure chip is fully reset before all outputs are enabled.

Bartosz, does this look better?

... if previous pin value was set to 1 period

Andriy, Bartosz, is commit message ok?
===
gpio: 74x164: Enable output pins after registers are reset

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.

Quoted 7 lines

===

Arturas Moskvinas

Looks good to me.

Bart

#6 lore raw
In reply to a message not in the archive
Quoted 9 lines · Arturas Moskvinas
Quoted 8 lines · Bartosz Golaszewski
Quoted 6 lines · Arturas Moskvinas

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 in chip.
Fix that behavior by making sure chip is fully reset before all outputs are enabled.

Quoted 3 lines
Quoted 2 lines
Quoted 1 line

Bartosz, does this look better?

... if previous pin value was set to 1 period

Andriy, Bartosz, is commit message ok?

LGTM! Please, send a v3 with it.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw
In reply to Arturas Moskvinas
Quoted 9 lines · Arturas Moskvinas

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 in chip. Change fixes 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).

Quoted 6 lines

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.

[1] - https://elixir.bootlin.com/linux/v6.7.4/source/drivers/gpio/gpio-74x164.c#L130
[2] - https://elixir.bootlin.com/linux/v6.7.4/source/drivers/gpio/gpio-74x164.c#L150

Please, convert these to be Link tags, so

at the end it will look like

Fixes:
Link: URL1 [1]
Link: URL2 [2]
Signed-off-by:

Signature · 2 lines
With Best Regards,
Andy Shevchenko