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: 726785 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 3vKryD00j4z9ryv for ; Sat, 11 Feb 2017 10:39:32 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=codeaurora.org header.i=@codeaurora.org header.b="OFE48hsD"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=codeaurora.org header.i=@codeaurora.org header.b="OFE48hsD"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751430AbdBJXjZ (ORCPT ); Fri, 10 Feb 2017 18:39:25 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:37502 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752151AbdBJXjY (ORCPT ); Fri, 10 Feb 2017 18:39:24 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 814E4607EE; 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= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED, T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 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 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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,