linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: mpa@pengutronix.de (Markus Pargmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/4] gpio: pca953x: Add DT binding for reset gpio
Date: Tue, 29 Jul 2014 09:24:46 +0200	[thread overview]
Message-ID: <1406618686-22385-5-git-send-email-mpa@pengutronix.de> (raw)
In-Reply-To: <1406618686-22385-1-git-send-email-mpa@pengutronix.de>

The pca953x has a negated reset input. This patch adds a DT binding for
the reset gpio and resets the chip when it is probed. This will reset
the device and leave the gpio in the correct state so reset is not
triggered.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
---
 .../devicetree/bindings/gpio/gpio-pca953x.txt          |  5 +++++
 drivers/gpio/gpio-pca953x.c                            | 18 ++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/Documentation/devicetree/bindings/gpio/gpio-pca953x.txt b/Documentation/devicetree/bindings/gpio/gpio-pca953x.txt
index eb65157d47f6..57e31414f74d 100644
--- a/Documentation/devicetree/bindings/gpio/gpio-pca953x.txt
+++ b/Documentation/devicetree/bindings/gpio/gpio-pca953x.txt
@@ -27,6 +27,10 @@ Required properties:
 	ti,tca6424
 	exar,xra1202
 
+Optional properties:
+ - reset-gpios: phandle with arguments identifying the reset gpio. See
+   Documentation/devicetree/bindings/gpio/gpio.txt for more information
+
 Example:
 
 
@@ -37,4 +41,5 @@ Example:
 		pinctrl-0 = <&pinctrl_pca9505>;
 		interrupt-parent = <&gpio3>;
 		interrupts = <23 IRQ_TYPE_LEVEL_LOW>;
+		reset-gpios = <&gpio3 24 GPIO_ACTIVE_LOW>;
 	};
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index df5eb6e6be1e..053d8b4702e6 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -11,6 +11,7 @@
  *  the Free Software Foundation; version 2 of the License.
  */
 
+#include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/gpio.h>
@@ -660,8 +661,25 @@ static int pca953x_probe(struct i2c_client *client,
 		invert = pdata->invert;
 		chip->names = pdata->names;
 	} else {
+		struct gpio_desc *reset;
+
 		chip->gpio_start = -1;
 		irq_base = 0;
+
+		reset = devm_gpiod_get(&client->dev, "reset");
+		if (IS_ERR(reset)) {
+			if (PTR_ERR(reset) == -EPROBE_DEFER)
+				return -EPROBE_DEFER;
+			else
+				dev_info(&client->dev, "Did not find/get a gpio for reset (%ld)\n",
+						PTR_ERR(reset));
+		} else {
+			/* Reset the chip if the reset is wired */
+			gpiod_direction_output(reset, 0);
+			udelay(100);
+			gpiod_set_value(reset, 1);
+			udelay(100);
+		}
 	}
 
 	chip->client = client;
-- 
2.0.1

  parent reply	other threads:[~2014-07-29  7:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-29  7:24 [PATCH 0/4] gpio: pca953x updates for DT Markus Pargmann
2014-07-29  7:24 ` [PATCH 1/4] gpio: pca953x: Drop deprecated DT bindings Markus Pargmann
2014-08-08 13:07   ` Linus Walleij
2014-07-29  7:24 ` [PATCH 2/4] gpio: pca953x: Add DT binding documentation Markus Pargmann
2014-08-08 13:07   ` Linus Walleij
2014-07-29  7:24 ` [PATCH 3/4] gpio: pca953x: Add pca9506 as DT compatible Markus Pargmann
2014-07-30 12:52   ` Markus Pargmann
2014-07-30 13:09     ` Markus Pargmann
2014-07-29  7:24 ` Markus Pargmann [this message]
2014-08-08 13:14   ` [PATCH 4/4] gpio: pca953x: Add DT binding for reset gpio Linus Walleij
2014-08-08 14:11     ` Philipp Zabel
2014-08-11  8:43       ` Linus Walleij
2014-08-14  9:21         ` Philipp Zabel
2014-08-29  6:27           ` Linus Walleij

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=1406618686-22385-5-git-send-email-mpa@pengutronix.de \
    --to=mpa@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.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).