From patchwork Tue Jun 14 22:49:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 9177093 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3BD146021C for ; Tue, 14 Jun 2016 22:51:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C99F282F9 for ; Tue, 14 Jun 2016 22:51:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2184A2833B; Tue, 14 Jun 2016 22:51:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C31EC282F9 for ; Tue, 14 Jun 2016 22:51:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753040AbcFNWv3 (ORCPT ); Tue, 14 Jun 2016 18:51:29 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35646 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753014AbcFNWvX (ORCPT ); Tue, 14 Jun 2016 18:51:23 -0400 Received: by mail-pf0-f196.google.com with SMTP id t190so302245pfb.2 for ; Tue, 14 Jun 2016 15:51:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Rb5Y87ufsPUW57V0xu3nAOc9fQpq7yZYdxX5OfdNuhM=; b=RGHH33MLHNWfJNm3qdWUiXad1QX9zt25Gw+f7Kt9oL/xuffZRYdEXJnZ1tXk4SnwkH O8AKR2dY3jGjst//ad4QzK4E9Z5NSQ3z+WP8RaWGohDJshp+rzmQl6iZPUx1g/cSzBk9 AQFSDGjip3czewgWxK2+uxgxR9hF66eTsHIRhBqVT9j4dmUaGKEtjevms6g3fR+hn45z j3+PE/ZWLJRZY//8cmjSuuDC8yDKAbawlNcviwVWvP/6Gpb3aa9TFtwxUWbzJRvSrJS2 guZO0jiqjy/Nv0bnIPola1b6jaVWN/nRVbX27AZFT2rYs78nz+e9HchJb3zFsWRtYqFl Iy8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Rb5Y87ufsPUW57V0xu3nAOc9fQpq7yZYdxX5OfdNuhM=; b=QJ8XvtmlPjtn1ReC8SQ1gdFtg4o93dzlTR1Y5YxkFSyefkciKoKWKL1ZRla4EgrAfg s+hgrJ2E/RRS+ARKyszqWyc2mX8M/pfljBKu0xATXzzmBEqomqwfMFLAqCEp34ll2BzD 9Wp1+W4mnc4EFzYX1BaW5QAop/PxXdLTpL7pRX4vK7EHWpJOPNhP7Kvuqhh6uuAJ2ZlA Nrvnr2MR+ZfQsNAl0VadBRCXYyCbo4GR9yXu0lhNwl7Da/CB9ggW/aC2U/yXnaJW1PvF iPVnd9gUwkCvTSwqAzs7RVZ6hAc6VUBlx8f5GxiYLRXV64LNG+0oINtn0jP573f5jnnn WGFg== X-Gm-Message-State: ALyK8tLyJmHO+bKYPp0hxw6m2/sPDMdbfboeOewV0yLHgJJAHGc92vgdS79xF1hr2pb5WQ== X-Received: by 10.66.149.66 with SMTP id ty2mr12852pab.153.1465944683156; Tue, 14 Jun 2016 15:51:23 -0700 (PDT) Received: from mothership.sklembedded.com (c-73-241-2-21.hsd1.ca.comcast.net. [73.241.2.21]) by smtp.googlemail.com with ESMTPSA id v184sm47829999pfb.24.2016.06.14.15.51.22 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 14 Jun 2016 15:51:22 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH 26/38] gpio: pca953x: Add reset-gpios property Date: Tue, 14 Jun 2016 15:49:22 -0700 Message-Id: <1465944574-15745-27-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465944574-15745-1-git-send-email-steve_longerbeam@mentor.com> References: <1465944574-15745-1-git-send-email-steve_longerbeam@mentor.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add optional reset-gpios property. If present, de-assert the specified reset gpio pin to bring the chip out of reset. Signed-off-by: Steve Longerbeam --- drivers/gpio/gpio-pca953x.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 5e3be32..475fa56 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -21,6 +21,7 @@ #include #include #include +#include #define PCA953X_INPUT 0 #define PCA953X_OUTPUT 1 @@ -111,6 +112,11 @@ struct pca953x_chip { const char *const *names; int chip_type; unsigned long driver_data; + +#ifdef CONFIG_OF_GPIO + enum of_gpio_flags reset_gpio_flags; + int reset_gpio; +#endif }; static int pca953x_read_single(struct pca953x_chip *chip, int reg, u32 *val, @@ -759,6 +765,28 @@ static int pca953x_probe(struct i2c_client *client, } else { chip->gpio_start = -1; irq_base = 0; + +#ifdef CONFIG_OF_GPIO + /* see if we need to de-assert a reset pin */ + ret = of_get_named_gpio_flags(client->dev.of_node, + "reset-gpios", 0, + &chip->reset_gpio_flags); + if (gpio_is_valid(ret)) { + chip->reset_gpio = ret; + ret = devm_gpio_request_one(&client->dev, + chip->reset_gpio, + GPIOF_DIR_OUT, + "pca953x_reset"); + if (ret == 0) { + /* bring chip out of reset */ + dev_info(&client->dev, "releasing reset\n"); + gpio_set_value(chip->reset_gpio, + (chip->reset_gpio_flags == + OF_GPIO_ACTIVE_LOW) ? 1 : 0); + } + } else if (ret == -EPROBE_DEFER) + return ret; +#endif } chip->client = client;