Commit 7ebc194d authored by Fabio Estevam's avatar Fabio Estevam Committed by Linus Walleij

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

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: default avatarFabio Estevam <fabio.estevam@nxp.com>
Acked-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent ee949b51
...@@ -12,6 +12,9 @@ Required properties: ...@@ -12,6 +12,9 @@ Required properties:
1 = active low 1 = active low
- registers-number: Number of daisy-chained shift registers - registers-number: Number of daisy-chained shift registers
Optional properties:
- enable-gpios: GPIO connected to the OE (Output Enable) pin.
Example: Example:
gpio5: gpio5@0 { gpio5: gpio5@0 {
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#include <linux/gpio/consumer.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
...@@ -31,6 +32,7 @@ struct gen_74x164_chip { ...@@ -31,6 +32,7 @@ struct gen_74x164_chip {
* numbering, store the bytes in reverse order. * numbering, store the bytes in reverse order.
*/ */
u8 buffer[0]; u8 buffer[0];
struct gpio_desc *gpiod_oe;
}; };
static int __gen_74x164_write_config(struct gen_74x164_chip *chip) static int __gen_74x164_write_config(struct gen_74x164_chip *chip)
...@@ -126,6 +128,13 @@ static int gen_74x164_probe(struct spi_device *spi) ...@@ -126,6 +128,13 @@ static int gen_74x164_probe(struct spi_device *spi)
if (!chip) if (!chip)
return -ENOMEM; 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); spi_set_drvdata(spi, chip);
chip->gpio_chip.label = spi->modalias; chip->gpio_chip.label = spi->modalias;
...@@ -164,6 +173,7 @@ static int gen_74x164_remove(struct spi_device *spi) ...@@ -164,6 +173,7 @@ static int gen_74x164_remove(struct spi_device *spi)
{ {
struct gen_74x164_chip *chip = spi_get_drvdata(spi); struct gen_74x164_chip *chip = spi_get_drvdata(spi);
gpiod_set_value_cansleep(chip->gpiod_oe, 0);
gpiochip_remove(&chip->gpio_chip); gpiochip_remove(&chip->gpio_chip);
mutex_destroy(&chip->lock); mutex_destroy(&chip->lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment