From patchwork Tue Jul 29 07:24:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Pargmann X-Patchwork-Id: 4638871 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 700749F4D4 for ; Tue, 29 Jul 2014 07:28:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C0462201B9 for ; Tue, 29 Jul 2014 07:28:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EA5252018B for ; Tue, 29 Jul 2014 07:28:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XC1oG-0005zH-8C; Tue, 29 Jul 2014 07:26:56 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XC1nv-0005i2-5U for linux-arm-kernel@lists.infradead.org; Tue, 29 Jul 2014 07:26:35 +0000 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:a236:9fff:fe00:814]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1XC1mz-0005q9-QW; Tue, 29 Jul 2014 09:25:37 +0200 Received: from mpa by dude.hi.pengutronix.de with local (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1XC1mx-0004Lz-8v; Tue, 29 Jul 2014 09:25:35 +0200 From: Markus Pargmann To: Linus Walleij Subject: [PATCH 4/4] gpio: pca953x: Add DT binding for reset gpio Date: Tue, 29 Jul 2014 09:24:46 +0200 Message-Id: <1406618686-22385-5-git-send-email-mpa@pengutronix.de> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1406618686-22385-1-git-send-email-mpa@pengutronix.de> References: <1406618686-22385-1-git-send-email-mpa@pengutronix.de> X-SA-Exim-Connect-IP: 2001:6f8:1178:2:a236:9fff:fe00:814 X-SA-Exim-Mail-From: mpa@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140729_002635_412024_4E496432 X-CRM114-Status: GOOD ( 14.34 ) X-Spam-Score: -0.7 (/) Cc: Alexandre Courbot , linux-gpio@vger.kernel.org, kernel@pengutronix.de, Markus Pargmann , Aaron Sierra , Toby Smith , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- .../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 #include #include #include @@ -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;