Advertisement
Guest User

Untitled

a guest
Aug 7th, 2017
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. From c780c7c5c126580b15891cd05878235df054eb1a Mon Sep 17 00:00:00 2001
  2. From: Fabio Estevam <fabio.estevam@nxp.com>
  3. Date: Sat, 15 Jul 2017 16:54:29 -0300
  4. Subject: [PATCH] gpio: 74x164: Introduce 'enable-gpios' property
  5.  
  6. 74HC595 has an /OE (output enable) pin that can be controlled by a GPIO.
  7.  
  8. Introduce an optional property called 'enable-gpios' that allows
  9. controlling the /OE pin.
  10.  
  11. Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
  12. ---
  13. Documentation/devicetree/bindings/gpio/gpio-74x164.txt | 3 +++
  14. drivers/gpio/gpio-74x164.c | 10 ++++++++++
  15. 2 files changed, 13 insertions(+)
  16.  
  17. diff --git a/Documentation/devicetree/bindings/gpio/gpio-74x164.txt b/Documentation/devicetree/bindings/gpio/gpio-74x164.txt
  18. index ce1b223..2a97553 100644
  19. --- a/Documentation/devicetree/bindings/gpio/gpio-74x164.txt
  20. +++ b/Documentation/devicetree/bindings/gpio/gpio-74x164.txt
  21. @@ -12,6 +12,9 @@ Required properties:
  22. 1 = active low
  23. - registers-number: Number of daisy-chained shift registers
  24.  
  25. +Optional properties:
  26. +- enable-gpios: GPIO connected to the OE (Output Enable) pin.
  27. +
  28. Example:
  29.  
  30. gpio5: gpio5@0 {
  31. diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c
  32. index a6607fa..6b535ec 100644
  33. --- a/drivers/gpio/gpio-74x164.c
  34. +++ b/drivers/gpio/gpio-74x164.c
  35. @@ -9,6 +9,7 @@
  36. * published by the Free Software Foundation.
  37. */
  38.  
  39. +#include <linux/gpio/consumer.h>
  40. #include <linux/init.h>
  41. #include <linux/mutex.h>
  42. #include <linux/spi/spi.h>
  43. @@ -31,6 +32,7 @@ struct gen_74x164_chip {
  44. * numbering, store the bytes in reverse order.
  45. */
  46. u8 buffer[0];
  47. + struct gpio_desc *gpiod_oe;
  48. };
  49.  
  50. static int __gen_74x164_write_config(struct gen_74x164_chip *chip)
  51. @@ -126,6 +128,13 @@ static int gen_74x164_probe(struct spi_device *spi)
  52. if (!chip)
  53. return -ENOMEM;
  54.  
  55. + chip->gpiod_oe = devm_gpiod_get_optional(&spi->dev, "enable",
  56. + GPIOD_OUT_LOW);
  57. + if (IS_ERR(chip->gpiod_oe))
  58. + return PTR_ERR(chip->gpiod_oe);
  59. +
  60. + gpiod_set_value_cansleep(chip->gpiod_oe, 1);
  61. +
  62. spi_set_drvdata(spi, chip);
  63.  
  64. chip->gpio_chip.label = spi->modalias;
  65. @@ -164,6 +173,7 @@ static int gen_74x164_remove(struct spi_device *spi)
  66. {
  67. struct gen_74x164_chip *chip = spi_get_drvdata(spi);
  68.  
  69. + gpiod_set_value_cansleep(chip->gpiod_oe, 0);
  70. gpiochip_remove(&chip->gpio_chip);
  71. mutex_destroy(&chip->lock);
  72.  
  73. --
  74. 2.7.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement