linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: 74x164: add lines-initial-states property
@ 2018-08-15 20:18 David Bauer
  2018-08-16  8:11 ` Linus Walleij
  2018-08-17 15:10 ` Rob Herring
  0 siblings, 2 replies; 4+ messages in thread
From: David Bauer @ 2018-08-15 20:18 UTC (permalink / raw)
  Cc: David Bauer, Linus Walleij, Rob Herring, Mark Rutland,
	linux-gpio, devicetree, linux-kernel

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

Signed-off-by: David Bauer <mail@david-bauer.net>
---
 Documentation/devicetree/bindings/gpio/gpio-74x164.txt | 5 +++++
 drivers/gpio/gpio-74x164.c                             | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/gpio/gpio-74x164.txt b/Documentation/devicetree/bindings/gpio/gpio-74x164.txt
index 2a97553d8d76..580b18065ad3 100644
--- a/Documentation/devicetree/bindings/gpio/gpio-74x164.txt
+++ b/Documentation/devicetree/bindings/gpio/gpio-74x164.txt
@@ -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:
 
diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c
index fb7b620763a2..275310a0a538 100644
--- a/drivers/gpio/gpio-74x164.c
+++ b/drivers/gpio/gpio-74x164.c
@@ -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);
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] gpio: 74x164: add lines-initial-states property
  2018-08-15 20:18 [PATCH] gpio: 74x164: add lines-initial-states property David Bauer
@ 2018-08-16  8:11 ` Linus Walleij
  2018-08-19 23:55   ` David Bauer
  2018-08-17 15:10 ` Rob Herring
  1 sibling, 1 reply; 4+ messages in thread
From: Linus Walleij @ 2018-08-16  8:11 UTC (permalink / raw)
  To: mail
  Cc: Rob Herring, Mark Rutland, open list:GPIO SUBSYSTEM,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linux-kernel

Hi David,

On Wed, Aug 15, 2018 at 10:19 PM David Bauer <mail@david-bauer.net> wrote:

> This adds the ability to define the initial state of each output line on
> device probe.
>
> Signed-off-by: David Bauer <mail@david-bauer.net>

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gpio: 74x164: add lines-initial-states property
  2018-08-15 20:18 [PATCH] gpio: 74x164: add lines-initial-states property David Bauer
  2018-08-16  8:11 ` Linus Walleij
@ 2018-08-17 15:10 ` Rob Herring
  1 sibling, 0 replies; 4+ messages in thread
From: Rob Herring @ 2018-08-17 15:10 UTC (permalink / raw)
  To: David Bauer
  Cc: David Bauer, Linus Walleij, Mark Rutland, linux-gpio, devicetree,
	linux-kernel

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

On Wed, 15 Aug 2018 22:18:54 +0200, David Bauer wrote:
> This adds the ability to define the initial state of each output line on
> device probe.
> 
> Signed-off-by: David Bauer <mail@david-bauer.net>

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gpio: 74x164: add lines-initial-states property
  2018-08-16  8:11 ` Linus Walleij
@ 2018-08-19 23:55   ` David Bauer
  0 siblings, 0 replies; 4+ messages in thread
From: David Bauer @ 2018-08-19 23:55 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Rob Herring, Mark Rutland, open list:GPIO SUBSYSTEM,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	linux-kernel

Hi Linus,

On 8/16/18 10:11 AM, Linus Walleij wrote:
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-19 23:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-15 20:18 [PATCH] gpio: 74x164: add lines-initial-states property David Bauer
2018-08-16  8:11 ` Linus Walleij
2018-08-19 23:55   ` David Bauer
2018-08-17 15:10 ` Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).