From patchwork Fri Nov 29 00:49:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 295057 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E3AE02C009F for ; Fri, 29 Nov 2013 11:49:46 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752524Ab3K2Atp (ORCPT ); Thu, 28 Nov 2013 19:49:45 -0500 Received: from perceval.ideasonboard.com ([95.142.166.194]:36160 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752523Ab3K2Atp (ORCPT ); Thu, 28 Nov 2013 19:49:45 -0500 Received: from avalon.ideasonboard.com (179.232-240-81.adsl-dyn.isp.belgacom.be [81.240.232.179]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4C547363D2; Fri, 29 Nov 2013 01:48:57 +0100 (CET) From: Laurent Pinchart To: linux-i2c@vger.kernel.org Cc: Laurent Pinchart Subject: [PATCH 4/4] i2c: pca954x: Add reset GPIO support Date: Fri, 29 Nov 2013 01:49:37 +0100 Message-Id: <1385686177-23525-5-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1385686177-23525-1-git-send-email-laurent.pinchart@ideasonboard.com> References: <1385686177-23525-1-git-send-email-laurent.pinchart@ideasonboard.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org If a reset GPIO support is specified, request the GPIO and get the chip out of reset at probe time. Cc: devicetree@vger.kernel.org Signed-off-by: Laurent Pinchart --- .../devicetree/bindings/i2c/i2c-mux-pca954x.txt | 4 ++++ drivers/i2c/muxes/i2c-mux-pca954x.c | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt index cc7e7fd..34a3fb6 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt @@ -13,6 +13,10 @@ Required Properties: - Standard I2C mux properties. See i2c-mux.txt in this directory. - I2C child bus nodes. See i2c-mux.txt in this directory. +Optional Properties: + + - reset-gpios: Reference to the GPIO connected to the reset input. + Example: diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 2880c38..e835304 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -36,11 +36,13 @@ */ #include +#include #include #include #include #include #include +#include #include #define PCA954X_MAX_NCHANS 8 @@ -185,6 +187,7 @@ static int pca954x_probe(struct i2c_client *client, { struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent); struct pca954x_platform_data *pdata = dev_get_platdata(&client->dev); + struct device_node *np = client->dev.of_node; int num, force, class; struct pca954x *data; int ret; @@ -198,6 +201,22 @@ static int pca954x_probe(struct i2c_client *client, i2c_set_clientdata(client, data); + if (IS_ENABLED(CONFIG_OF) && np) { + enum of_gpio_flags flags; + int gpio; + + /* Get the mux out of reset if a reset GPIO is specified. */ + gpio = of_get_named_gpio_flags(np, "reset-gpio", 0, &flags); + if (gpio_is_valid(gpio)) { + ret = devm_gpio_request_one(&client->dev, gpio, + flags & OF_GPIO_ACTIVE_LOW ? + GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW, + "pca954x reset"); + if (ret < 0) + return ret; + } + } + /* Write the mux register at addr to verify * that the mux is in fact present. This also * initializes the mux to disconnected state.