Skip to contentSkip to conversation

gpio: 74x164: add lines-initial-states property

PATCH In review David Bauer 3 participants 4 messages Aug 15, 2018 – Aug 19, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: 74x164: add lines-initial-states property

This adds the ability to define the initial state of each output line on device probe.

---
 Documentation/devicetree/bindings/gpio/gpio-74x164.txt | 5 +++++
 drivers/gpio/gpio-74x164.c                             | 3 +++
 2 files changed, 8 insertions(+)
Documentation/devicetree/bindings/gpio/gpio-74x164.txt +5 -0
index 2a97553d8d76..580b18065ad3 100644
@@ -14,6 +14,11 @@ Required properties:
 
 Optional properties:
 - enable-gpios: GPIO connected to the OE (Output Enable) pin.
+- lines-initial-states: Bitmask that specifies the initial state of
+  each line. When a bit is set to zero, the corresponding output line
+  is initialized LOW. When a bit is set to one, the corresponding
+  output line is initialized HIGH. In case this property is not
+  defined, all lines will be initialized as LOW.
 
 Example:
 
drivers/gpio/gpio-74x164.c +3 -0
index fb7b620763a2..275310a0a538 100644
@@ -150,6 +150,9 @@ static int gen_74x164_probe(struct spi_device *spi)
 	chip->gpio_chip.parent = &spi->dev;
 	chip->gpio_chip.owner = THIS_MODULE;
 
+	of_property_read_u8_array(spi->dev.of_node, "lines-initial-states",
+				  chip->buffer, chip->registers);
+
 	mutex_init(&chip->lock);
 
 	ret = __gen_74x164_write_config(chip);
Signature · 1 line
2.18.0
#1 lore raw

Hi David,

Quoted 4 lines · David Bauer

This adds the ability to define the initial state of each output line on device probe.

(...)

Documentation/devicetree/bindings/gpio/gpio-74x164.txt Required properties: · line 21

Quoted 7 lines

Optional properties:
- enable-gpios: GPIO connected to the OE (Output Enable) pin.
+- lines-initial-states: Bitmask that specifies the initial state of

Documentation/devicetree/bindings/gpio/gpio-74x164.txt +4 -0
+  each line. When a bit is set to zero, the corresponding output line
+  is initialized LOW. When a bit is set to one, the corresponding
+  output line is initialized HIGH. In case this property is not
+  defined, all lines will be initialized as LOW.

This sounds like something that should be generic, and not use a bitmask, but offsets. It should work even if the number of GPIOs from the chip is > 32.

Is the usecase different from hogs?
See Documentation/devicetree/bindings/gpio.txt

There has been extensive discussion about supporting initial values with something similar to hogs, but I haven't got anything ACKed by the DT maintainers so it has kind of stalled.

I would make sure to both make it generic, get ACK from the DT mainatiners, and make sure to implement it in drivers/gpio/gpiolib-of.c and not locally in drivers.

Yours,
Linus Walleij

#2 lore raw

Hi Linus,

Quoted 6 lines · Linus Walleij

This sounds like something that should be generic, and not use a bitmask, but offsets. It should work even if the number of GPIOs from the chip is > 32.

Is the usecase different from hogs?
See Documentation/devicetree/bindings/gpio.txt

Thanks for pointing that out. Indeed for my use-case (Asserting single output to be high on driver probe) hogs are are sufficient solution.

Best wishes
David

maintainer
#3 lore raw
In reply to David Bauer

Hi, this email is from Rob's (experimental) review bot. I found a couple of common problems with your patch. Please see below.

Quoted 4 lines · David Bauer

This adds the ability to define the initial state of each output line on device probe.

The preferred subject prefix is "dt-bindings: <binding dir>: ...".

Quoted 5 lines
---
 Documentation/devicetree/bindings/gpio/gpio-74x164.txt | 5 +++++
 drivers/gpio/gpio-74x164.c                             | 3 +++
 2 files changed, 8 insertions(+)

DT bindings (including binding headers) should be a separate patch. See Documentation/devicetree/bindings/submitting-patches.txt.