Skip to contentSkip to conversation

gpio: 74x164: Introduce 'enable-gpios' property

PATCH In review Fabio Estevam 3 participants 3 messages Aug 7, 2017 – Aug 14, 2017 1 message not in the archive

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

PATCH 1/1 gpio: 74x164: Introduce 'enable-gpios' property

From: Fabio Estevam <[email protected]>

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.

---
 Documentation/devicetree/bindings/gpio/gpio-74x164.txt |  3 +++
 drivers/gpio/gpio-74x164.c                             | 10 ++++++++++
 2 files changed, 13 insertions(+)
Documentation/devicetree/bindings/gpio/gpio-74x164.txt +3 -0
index ce1b223..2a97553 100644
@@ -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 {
drivers/gpio/gpio-74x164.c +10 -0
index a6607fa..6b535ec 100644
@@ -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);
 
Signature · 1 line
2.7.4

A message that is not in the archive (sent off-list or not yet received): 1502109710-31624-1-git-send-email-festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

Acked-by
#2 lore raw

Please send bindings to the DT list.

Quoted 4 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

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

Quoted 8 lines

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

---
 Documentation/devicetree/bindings/gpio/gpio-74x164.txt |  3 +++
 drivers/gpio/gpio-74x164.c                             | 10 ++++++++++
 2 files changed, 13 insertions(+)

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html