From patchwork Sat Jun 7 21:56:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 4316231 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7B0D8BEEAA for ; Sat, 7 Jun 2014 21:58:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A96532025A for ; Sat, 7 Jun 2014 21:58:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C011D20225 for ; Sat, 7 Jun 2014 21:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753378AbaFGV5k (ORCPT ); Sat, 7 Jun 2014 17:57:40 -0400 Received: from mail-pd0-f171.google.com ([209.85.192.171]:59618 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753365AbaFGV5i (ORCPT ); Sat, 7 Jun 2014 17:57:38 -0400 Received: by mail-pd0-f171.google.com with SMTP id y13so3808678pdi.2 for ; Sat, 07 Jun 2014 14:57:38 -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=hB6SN7zHlQ6NqRicF+FsoAUqmALiGfKMuLSWN9pjdO4=; b=XrOjrwe0YbhkHOcEK1SqI04/TB80Q7Jp1Ms0iqgTUReQEBV2timSzkZ/vjsLIKq+ZW I+9aGg8Pyh7oSVXBQ8npzMcUSjdMDDbw8EXBE2ss8vfAgxkalCxlh5PBT0mzBthWnneH 6+H3TMSt4mlKafV0oLVA8j6WWEigVDFyZL3vqPB5e7dJxgqkJJbCWhqi1U80P0SJ9dot H9l1+dm4g7vvIxh0/Taw/66yZZ0lg2I6HSOiTg1ontPkUASh9BrQzvFyA4Y4AUywI87K zvG0XEnUw0qO4qQqAbbEQSZ+H/bsIDPCnr3hKmLUdgNXfFU/LnffDHSpbGAzvQ2h1shM nk2Q== X-Received: by 10.68.245.162 with SMTP id xp2mr15678113pbc.69.1402178258500; Sat, 07 Jun 2014 14:57:38 -0700 (PDT) Received: from slongerb-fremont-linux.mgc.mentorg.com (c-98-248-118-71.hsd1.ca.comcast.net. [98.248.118.71]) by mx.google.com with ESMTPSA id fx5sm52769595pbb.62.2014.06.07.14.57.37 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 07 Jun 2014 14:57:38 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam Subject: [PATCH 36/43] gpio: pca953x: Add reset-gpios property Date: Sat, 7 Jun 2014 14:56:38 -0700 Message-Id: <1402178205-22697-37-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1402178205-22697-1-git-send-email-steve_longerbeam@mentor.com> References: <1402178205-22697-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-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 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 | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index d550d8e..6e212f7 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -22,6 +22,7 @@ #include #ifdef CONFIG_OF_GPIO #include +#include #endif #define PCA953X_INPUT 0 @@ -98,6 +99,11 @@ struct pca953x_chip { struct gpio_chip gpio_chip; const char *const *names; int chip_type; + +#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, @@ -735,6 +741,26 @@ static int pca953x_probe(struct i2c_client *client, /* If I2C node has no interrupts property, disable GPIO interrupts */ if (of_find_property(client->dev.of_node, "interrupts", NULL) == NULL) irq_base = -1; + + /* 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 }