summaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorFabio Estevam <fabio.estevam@nxp.com>2017-08-07 09:41:50 -0300
committerLinus Walleij <linus.walleij@linaro.org>2017-08-14 16:24:02 +0200
commit7ebc194d0fd4bb0fc8c7aca4b500b5b24e733267 (patch)
treeaf692d51b340c436bb39432618a21b977c29d983 /drivers/gpio
parentee949b51e4165107fe4d9ed18c23829119078722 (diff)
downloadlinux-stable-7ebc194d0fd4bb0fc8c7aca4b500b5b24e733267.tar.gz
linux-stable-7ebc194d0fd4bb0fc8c7aca4b500b5b24e733267.tar.bz2
linux-stable-7ebc194d0fd4bb0fc8c7aca4b500b5b24e733267.zip
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: Fabio Estevam <fabio.estevam@nxp.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-74x164.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c
index a6607faf2fdf..6b535ec858cc 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);