diff mbox series

[v3,2/2] gpio: 74x164: Introduce the 'registers-default' property

Message ID 20201230214918.17133-2-festevam@gmail.com
State Superseded
Headers show
Series None | expand

Commit Message

Fabio Estevam Dec. 30, 2020, 9:49 p.m. UTC
From: Sandor Yu <sandor.yu@nxp.com>

On the imx7d-sdb board, there is one output pin of the 74x164 that
controls all peripherals power supply (PERI_3V).

This pin should be at high voltage level when the 74x164 is probed,
otherwise the modules dependent on PERI_3V3 will not be powered.

Add a new optional property called 'registers-default' that allows
describing the default output value for each shift register.

Signed-off-by: Sandor Yu <sandor.yu@nxp.com>
Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
Changes since v2:
-Add Sandor's Signed-off-by tag.

 drivers/gpio/gpio-74x164.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Linus Walleij Jan. 5, 2021, 3:40 p.m. UTC | #1
On Wed, Dec 30, 2020 at 10:49 PM Fabio Estevam <festevam@gmail.com> wrote:

> From: Sandor Yu <sandor.yu@nxp.com>

>

> On the imx7d-sdb board, there is one output pin of the 74x164 that

> controls all peripherals power supply (PERI_3V).

>

> This pin should be at high voltage level when the 74x164 is probed,

> otherwise the modules dependent on PERI_3V3 will not be powered.


This seems like a usecase for a fixed GPIO regulator.
Documentation/devicetree/bindings/regulator/fixed-regulator.yaml
drivers/regulator/fixed.c

> Add a new optional property called 'registers-default' that allows

> describing the default output value for each shift register.

>

> Signed-off-by: Sandor Yu <sandor.yu@nxp.com>

> Signed-off-by: Fabio Estevam <festevam@gmail.com>

> ---

> Changes since v2:

> -Add Sandor's Signed-off-by tag.


Again while poking some defaults into some registers does indeed
solve the problem, what we really want is to assign initial values
to GPIO lines for cases where there are no consumers.

If there are actually no device drivers on the GPIO line you can
use GPIO hogs.
Documentation/devicetree/bindings/gpio/gpio.txt

Otherwise e.g. properly obtain reset or GPIO regulator etc.

Deferred probe will sort things out,

If you just need the line to go to a certain level for the short
period between initializing the GPIO driver and the proper device
driver taking control of the line, we need initial GPIO line
values, which was discussed in my previous mail.

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c
index 05637d585152..a11637518774 100644
--- a/drivers/gpio/gpio-74x164.c
+++ b/drivers/gpio/gpio-74x164.c
@@ -141,6 +141,9 @@  static int gen_74x164_probe(struct spi_device *spi)
 	chip->registers = nregs;
 	chip->gpio_chip.ngpio = GEN_74X164_NUMBER_GPIOS * chip->registers;
 
+	device_property_read_u8_array(&spi->dev, "registers-default",
+				      chip->buffer, chip->registers);
+
 	chip->gpio_chip.can_sleep = true;
 	chip->gpio_chip.parent = &spi->dev;
 	chip->gpio_chip.owner = THIS_MODULE;