From patchwork Fri Feb 10 23:21:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 9567599 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 36F68602B6 for ; Fri, 10 Feb 2017 23:21:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 309E528541 for ; Fri, 10 Feb 2017 23:21:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 253A5285DE; Fri, 10 Feb 2017 23:21:35 +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 A2D7328570 for ; Fri, 10 Feb 2017 23:21:34 +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=NePfJzK3BaKhwvHmAEmrx5gwQf6NoK/VR/ZBjbGHcRM=; b=sV1xEmvZ3+5GvY qffnjXm0govfQ4k4b1d2J2y0dhCMMECy/qRq3DBE9u+eYdHNSm7RrDYcXG8a7fflcikTfPVI/5MkR 5qawPpY1Va9iGgjbty6bA5cAX3mzzEKgiwLv2+e0dmVjyrS9aPiRwkOeT2x+HkWzIJ7y2ACojq16+ SWbpfGoSAHe1HoCgrP6Po6EJQcmNPp/is6WQPZnbmoV81AOocuLdgpt4chyVRpQS/wrjcJinh3/Ao XIC7d3vwWoymalx+9jj7ba6wCDj9ABjucCj1eHDnTskIzNCYyO4HT/jTAISOhKoUL0y8qR1f0xb+5 0jB4bXbZPWAid9Am8GgA==; 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 1ccKVP-0000Sc-6V; Fri, 10 Feb 2017 23:21:31 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ccKVL-0000Rq-06 for linux-arm-kernel@lists.infradead.org; Fri, 10 Feb 2017 23:21:29 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 224C360269; Fri, 10 Feb 2017 23:21:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1486768866; bh=4C0QbMjhznH4xl+ohhu9hlmvoYA9BC7HvQ3Eds1lWSU=; h=From:To:Subject:Date:From; b=X7y0DfpzQKC3Gj3enMfgVtMogyMnh5ktxbS3ZZvfKNn773TL39xW1k69n5CN35uOV uMhG2GqM2fhfupcrKN43XEsLwj+yeKd0rX8pV+091u0KbrxIJq0SonDo+njU2ouDwU n3/hJrhAK7+4VX6koEWbDsvhIF6o5ozA8mV4pTWg= 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 489D2600C5; Fri, 10 Feb 2017 23:21:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1486768865; bh=4C0QbMjhznH4xl+ohhu9hlmvoYA9BC7HvQ3Eds1lWSU=; h=From:To:Subject:Date:From; b=NqSogIXSaTCxv/5NZbN3VkZP6mn9Quac0+r88K6CHQd9ocIrCve0e8i8cM22zTp0P tSo/6nihx9LiehzBxZ4eu69xCM08wN3Qv5ppu0FtkvlnFIjMf++VlMUGtzyI1iCkkn TRl48ed9kQSg6GVxw1IoqDtZ4AU0zJcbxd/UMO1A= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 489D2600C5 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] pinctrl: qcom: add get_direction function Date: Fri, 10 Feb 2017 17:21:00 -0600 Message-Id: <1486768860-18237-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_152127_092786_7787A4FE X-CRM114-Status: GOOD ( 10.81 ) 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 --- drivers/pinctrl/qcom/pinctrl-msm.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index f8e9e1c..c978be5 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c @@ -422,6 +422,20 @@ 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); + + /* 0 = output, 1 = input */ + return val & BIT(g->oe_bit) ? 0 : 1; +} + static int msm_gpio_get(struct gpio_chip *chip, unsigned offset) { const struct msm_pingroup *g; @@ -510,6 +524,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,