Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Fabio Estevam and committed by
Linus Walleij
7ebc194d ee949b51

+13
+3
Documentation/devicetree/bindings/gpio/gpio-74x164.txt
··· 12 12 1 = active low 13 13 - registers-number: Number of daisy-chained shift registers 14 14 15 + Optional properties: 16 + - enable-gpios: GPIO connected to the OE (Output Enable) pin. 17 + 15 18 Example: 16 19 17 20 gpio5: gpio5@0 {
+10
drivers/gpio/gpio-74x164.c
··· 9 9 * published by the Free Software Foundation. 10 10 */ 11 11 12 + #include <linux/gpio/consumer.h> 12 13 #include <linux/init.h> 13 14 #include <linux/mutex.h> 14 15 #include <linux/spi/spi.h> ··· 32 31 * numbering, store the bytes in reverse order. 33 32 */ 34 33 u8 buffer[0]; 34 + struct gpio_desc *gpiod_oe; 35 35 }; 36 36 37 37 static int __gen_74x164_write_config(struct gen_74x164_chip *chip) ··· 128 126 if (!chip) 129 127 return -ENOMEM; 130 128 129 + chip->gpiod_oe = devm_gpiod_get_optional(&spi->dev, "enable", 130 + GPIOD_OUT_LOW); 131 + if (IS_ERR(chip->gpiod_oe)) 132 + return PTR_ERR(chip->gpiod_oe); 133 + 134 + gpiod_set_value_cansleep(chip->gpiod_oe, 1); 135 + 131 136 spi_set_drvdata(spi, chip); 132 137 133 138 chip->gpio_chip.label = spi->modalias; ··· 173 164 { 174 165 struct gen_74x164_chip *chip = spi_get_drvdata(spi); 175 166 167 + gpiod_set_value_cansleep(chip->gpiod_oe, 0); 176 168 gpiochip_remove(&chip->gpio_chip); 177 169 mutex_destroy(&chip->lock); 178 170