From patchwork Fri Feb 10 23:39:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 9567601 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 1035D601EA for ; Fri, 10 Feb 2017 23:39:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0351A285EF for ; Fri, 10 Feb 2017 23:39:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAF5C285F2; Fri, 10 Feb 2017 23:39:52 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6F8F3285EF for ; Fri, 10 Feb 2017 23:39:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=0zh4D/Rjh9kFrrpJeUSox3YmbQ7TrVPAdsQynOEOl68=; b=CbWsixmNxEr2s2 tyb2ItGKv6dCKp5xtR/iNMv9YYEZ2ywAIVELPio/wWFqbPeOZc3dpDDBSJoKZEw+1cWEvyEBxf8L6 56cONpaJ6WJAIMDmV/v38P9hQ6r/riyBqRBNFBlFjUq1NulCL78s9mWPTaTY80JTZ//yQKrs5MhoN BEhezI83FGtF/s0uxLHkQseXrRcV3heBDR/w0J/+WAcwB7cQM9Pyy67cxMXehxW08hW1enBtQ6pVA E2KUbj77lZCZqjjRe/U7OsmKwiZjRfRPk8lmUdlEbceUv3MOkb6BrwttNg0c6I5Gz4dxg3I4AzzRJ M5S2OSl5Bkzf7Xi0cwbA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ccKn5-000714-Qw; Fri, 10 Feb 2017 23:39:47 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ccKn2-0006zB-3H for linux-arm-kernel@lists.infradead.org; Fri, 10 Feb 2017 23:39:46 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8FD8B6076B; Fri, 10 Feb 2017 23:39:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1486769963; bh=9/CDz+s1g4fKS5UkT5fc9srzP5AWteba7jKVbPAMQe4=; h=From:To:Subject:Date:From; b=OFE48hsD7QO+JhoVOwdRqfgg9+ODv+cr9z36KSr7yfuTIwVqVlJylFjJbvf1+QN7+ 103GN0K121s+RecwFvrcA5BkM0s4zDjZGeRPzxVaj/n8dDhYn80qV/xHf29TGRIPxP aojje220DGWhKb2d7Jw7cscBSOhhlLQHeQQlWYpI= Received: from timur-ubuntu.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: timur@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 734496076B; Fri, 10 Feb 2017 23:39:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1486769963; bh=9/CDz+s1g4fKS5UkT5fc9srzP5AWteba7jKVbPAMQe4=; h=From:To:Subject:Date:From; b=OFE48hsD7QO+JhoVOwdRqfgg9+ODv+cr9z36KSr7yfuTIwVqVlJylFjJbvf1+QN7+ 103GN0K121s+RecwFvrcA5BkM0s4zDjZGeRPzxVaj/n8dDhYn80qV/xHf29TGRIPxP aojje220DGWhKb2d7Jw7cscBSOhhlLQHeQQlWYpI= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 734496076B Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=timur@codeaurora.org From: Timur Tabi To: Linus Walleij , Stephen Boyd , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] [v2] pinctrl: qcom: add get_direction function Date: Fri, 10 Feb 2017 17:39:19 -0600 Message-Id: <1486769959-22930-1-git-send-email-timur@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170210_153944_219657_DD0F47EC X-CRM114-Status: GOOD ( 10.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 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-Virus-Scanned: ClamAV using ClamSMTP The get_direction callback function allows gpiolib to know the current direction (input vs output) for a given GPIO. This is particularly useful on ACPI systems, where the GPIOs are configured only by firmware (typically UEFI), so the only way to know the initial values to query the hardware directly. Without this function, gpiolib thinks that all GPIOs are configured for input. Signed-off-by: Timur Tabi Reviewed-by: Stephen Boyd --- v2: Use GPIOF_DIR_IN and GPIOF_DIR_OUT drivers/pinctrl/qcom/pinctrl-msm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index f8e9e1c..1dae9f3 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c @@ -422,6 +422,19 @@ static int msm_gpio_direction_output(struct gpio_chip *chip, unsigned offset, in return 0; } +static int msm_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) +{ + struct msm_pinctrl *pctrl = gpiochip_get_data(chip); + const struct msm_pingroup *g; + u32 val; + + g = &pctrl->soc->groups[offset]; + + val = readl(pctrl->regs + g->ctl_reg); + + return val & BIT(g->oe_bit) ? GPIOF_DIR_OUT : GPIOF_DIR_IN; +} + static int msm_gpio_get(struct gpio_chip *chip, unsigned offset) { const struct msm_pingroup *g; @@ -510,6 +523,7 @@ static void msm_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) static struct gpio_chip msm_gpio_template = { .direction_input = msm_gpio_direction_input, .direction_output = msm_gpio_direction_output, + .get_direction = msm_gpio_get_direction, .get = msm_gpio_get, .set = msm_gpio_set, .request = gpiochip_generic_request,