All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: 74x164: Introduce 'enable-gpios' property
@ 2017-08-07 12:41 Fabio Estevam
       [not found] ` <1502109710-31624-1-git-send-email-festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2017-08-14 14:36 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Fabio Estevam @ 2017-08-07 12:41 UTC (permalink / raw)
  To: linus.walleij; +Cc: linux-gpio, robh+dt, peng.fan, Fabio Estevam

From: Fabio Estevam <fabio.estevam@nxp.com>

74HC595 has an /OE (output enable) pin that can be controlled by a GPIO.

Introduce an optional property called 'enable-gpios' that allows
controlling the /OE pin.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
 Documentation/devicetree/bindings/gpio/gpio-74x164.txt |  3 +++
 drivers/gpio/gpio-74x164.c                             | 10 ++++++++++
 2 files changed, 13 insertions(+)

diff --git a/Documentation/devicetree/bindings/gpio/gpio-74x164.txt b/Documentation/devicetree/bindings/gpio/gpio-74x164.txt
index ce1b223..2a97553 100644
--- a/Documentation/devicetree/bindings/gpio/gpio-74x164.txt
+++ b/Documentation/devicetree/bindings/gpio/gpio-74x164.txt
@@ -12,6 +12,9 @@ Required properties:
       1 = active low
 - registers-number: Number of daisy-chained shift registers
 
+Optional properties:
+- enable-gpios: GPIO connected to the OE (Output Enable) pin.
+
 Example:
 
 gpio5: gpio5@0 {
diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c
index a6607fa..6b535ec 100644
--- a/drivers/gpio/gpio-74x164.c
+++ b/drivers/gpio/gpio-74x164.c
@@ -9,6 +9,7 @@
  *  published by the Free Software Foundation.
  */
 
+#include <linux/gpio/consumer.h>
 #include <linux/init.h>
 #include <linux/mutex.h>
 #include <linux/spi/spi.h>
@@ -31,6 +32,7 @@ struct gen_74x164_chip {
 	 * numbering, store the bytes in reverse order.
 	 */
 	u8			buffer[0];
+	struct gpio_desc	*gpiod_oe;
 };
 
 static int __gen_74x164_write_config(struct gen_74x164_chip *chip)
@@ -126,6 +128,13 @@ static int gen_74x164_probe(struct spi_device *spi)
 	if (!chip)
 		return -ENOMEM;
 
+	chip->gpiod_oe = devm_gpiod_get_optional(&spi->dev, "enable",
+						 GPIOD_OUT_LOW);
+	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;
@@ -164,6 +173,7 @@ static int gen_74x164_remove(struct spi_device *spi)
 {
 	struct gen_74x164_chip *chip = spi_get_drvdata(spi);
 
+	gpiod_set_value_cansleep(chip->gpiod_oe, 0);
 	gpiochip_remove(&chip->gpio_chip);
 	mutex_destroy(&chip->lock);
 
-- 
2.7.4


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

* Re: [PATCH] gpio: 74x164: Introduce 'enable-gpios' property
       [not found] ` <1502109710-31624-1-git-send-email-festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2017-08-07 18:17   ` Rob Herring
  0 siblings, 0 replies; 3+ messages in thread
From: Rob Herring @ 2017-08-07 18:17 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Linus Walleij, linux-gpio-u79uwXL29TY76Z2rM5mHXA, Peng Fan,
	Fabio Estevam, devicetree-u79uwXL29TY76Z2rM5mHXA

Please send bindings to the DT list.

On Mon, Aug 7, 2017 at 7:41 AM, Fabio Estevam <festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> From: Fabio Estevam <fabio.estevam-3arQi8VN3Tc@public.gmane.org>
>
> 74HC595 has an /OE (output enable) pin that can be controlled by a GPIO.
>
> Introduce an optional property called 'enable-gpios' that allows
> controlling the /OE pin.
>
> Signed-off-by: Fabio Estevam <fabio.estevam-3arQi8VN3Tc@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/gpio/gpio-74x164.txt |  3 +++
>  drivers/gpio/gpio-74x164.c                             | 10 ++++++++++
>  2 files changed, 13 insertions(+)

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] gpio: 74x164: Introduce 'enable-gpios' property
  2017-08-07 12:41 [PATCH] gpio: 74x164: Introduce 'enable-gpios' property Fabio Estevam
       [not found] ` <1502109710-31624-1-git-send-email-festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2017-08-14 14:36 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2017-08-14 14:36 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: linux-gpio, Rob Herring, peng.fan, Fabio Estevam

On Mon, Aug 7, 2017 at 2:41 PM, Fabio Estevam <festevam@gmail.com> wrote:

> From: Fabio Estevam <fabio.estevam@nxp.com>
>
> 74HC595 has an /OE (output enable) pin that can be controlled by a GPIO.
>
> Introduce an optional property called 'enable-gpios' that allows
> controlling the /OE pin.
>
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>

Patch applied with Rob's ACK.

Yours,
Linus Walleij

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

end of thread, other threads:[~2017-08-14 14:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-07 12:41 [PATCH] gpio: 74x164: Introduce 'enable-gpios' property Fabio Estevam
     [not found] ` <1502109710-31624-1-git-send-email-festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-08-07 18:17   ` Rob Herring
2017-08-14 14:36 ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.