From: Peng Fan <peng.fan@nxp.com>
To: linus.walleij@linaro.org, robh@kernel.org
Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>
Subject: [PATCH 2/2] gpio: 74x164: handling enable-gpios
Date: Mon, 7 Aug 2017 20:27:13 +0800 [thread overview]
Message-ID: <1502108833-10317-2-git-send-email-peng.fan@nxp.com> (raw)
In-Reply-To: <1502108833-10317-1-git-send-email-peng.fan@nxp.com>
To 74hc595 and 74lv595, there is an OE(low active) input pin.
To some boards, this pin is controller by GPIO, so handling
this pin in driver. When driver probe, use GPIOD_OUT_LOW flag
when requesting the gpio, so OE is set to low when probe.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
---
drivers/gpio/gpio-74x164.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c
index a6607fa..e44422c 100644
--- a/drivers/gpio/gpio-74x164.c
+++ b/drivers/gpio/gpio-74x164.c
@@ -23,6 +23,7 @@ struct gen_74x164_chip {
struct gpio_chip gpio_chip;
struct mutex lock;
u32 registers;
+ struct gpio_desc *enable_gpio;
/*
* Since the registers are chained, every byte sent will make
* the previous byte shift to the next register in the
@@ -142,6 +143,12 @@ static int gen_74x164_probe(struct spi_device *spi)
chip->gpio_chip.parent = &spi->dev;
chip->gpio_chip.owner = THIS_MODULE;
+ chip->enable_gpio = devm_gpiod_get(&spi->dev, "enable", GPIOD_OUT_LOW);
+ if (IS_ERR(chip->enable_gpio)) {
+ dev_dbg(&spi->dev, "No enable-gpios property\n");
+ chip->enable_gpio = NULL;
+ }
+
mutex_init(&chip->lock);
ret = __gen_74x164_write_config(chip);
@@ -164,6 +171,8 @@ static int gen_74x164_remove(struct spi_device *spi)
{
struct gen_74x164_chip *chip = spi_get_drvdata(spi);
+ if (chip->enable_gpio)
+ gpiod_set_value(chip->enable_gpio, 0);
gpiochip_remove(&chip->gpio_chip);
mutex_destroy(&chip->lock);
--
2.6.6
next prev parent reply other threads:[~2017-08-07 12:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-07 12:27 [PATCH 1/2] devicetree: gpio: 74x164: optional enable-gpios Peng Fan
2017-08-07 12:27 ` Peng Fan [this message]
2017-08-07 12:36 ` [PATCH 2/2] gpio: 74x164: handling enable-gpios Fabio Estevam
2017-08-07 12:40 ` Fabio Estevam
2017-08-08 1:15 ` Peng Fan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1502108833-10317-2-git-send-email-peng.fan@nxp.com \
--to=peng.fan@nxp.com \
--cc=devicetree@vger.kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).