From patchwork Tue May 24 10:03:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 9133353 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 0A843607D3 for ; Tue, 24 May 2016 10:05:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F067B28299 for ; Tue, 24 May 2016 10:05:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E52E82829C; Tue, 24 May 2016 10:05:30 +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.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, SUSPICIOUS_RECIPS, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E2FF628299 for ; Tue, 24 May 2016 10:05:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b59Bz-0004Sj-0t; Tue, 24 May 2016 10:04:03 +0000 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b59Bw-0004S0-8e for linux-arm-kernel@lists.infradead.org; Tue, 24 May 2016 10:04:01 +0000 Received: by mail-wm0-x232.google.com with SMTP id n129so120967320wmn.1 for ; Tue, 24 May 2016 03:03:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=K2BkubgbCqzDtX88jD8FfMAfXGc7kAgW3T5boJjQino=; b=i7JgAYqdL7whggDYipg4kryDfSQHEO4iJnL4dID7DJTxbYz5w1nhYSfDCuurIb1SLY B8LV3unSAJOeb9EE6FyPOukgXOrGiOCEzD8pBfFjC1YeIEe2WR/XUGZdnhJeviEgiXTi KDWdXm5w4LWXWRQx0SApC4is3Quwx6Ze+7lU/ToNn4n6xmAKADFA9b7VQxuavF6K9fFy U7zlef+X3q6Y+0aV/R11naop+Hul90SAcGjLf8AQOHtrAmFFTCvAYxhI+ZdPnBiuIkNo 1O+1Sm/VIV+qaAMoAdupH78zBKC7YUFlM2J+8YpAsI2JyDVfUHshI7H+kjCBHh6TH2oW 0Gdg== 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; bh=K2BkubgbCqzDtX88jD8FfMAfXGc7kAgW3T5boJjQino=; b=fbPo3XalHxVmZF5pcDE9yeeFNtD+pSxURRqPoGEQBntkYYZ7BUqjuWUaxKniwjLKr+ hLeMHzE7XVxgzTs7IPXlNkUoRUbdRE4gxapUvElDvPaV4k0vm5K4EcbLd1jI2H2iJhQm +DpEBS2rKcTcyQbR3Y71WRGlliTs27afur7nv27Gk8AqdsKh5AJ0M2X20TVHzrrKRtFG BZnP8WAzzDoII2NgBLT6sMnGwZmt2wYp5w0srxqymjT0/ilWkk/ladRQ7gDrzQtU+2OR xQy3x4vJrKuqQ+OxexFVcXF1ofqQM9FMvnebxozQgzAskl460j+rc0axsASuPFWbIGK6 uQvw== X-Gm-Message-State: ALyK8tKwNuPa9rTxuzpD2QlO5NF9crSWRZYYp56VSsWfcA7rYvLFHwbcibyYxIiSjWy8KZSp X-Received: by 10.194.55.10 with SMTP id n10mr3390347wjp.28.1464084218835; Tue, 24 May 2016 03:03:38 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id n66sm2803876wmf.6.2016.05.24.03.03.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 May 2016 03:03:37 -0700 (PDT) From: Neil Armstrong To: linus.walleij@linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Subject: [PATCH] pinctrl: oxnas: Add GPIO get_direction Date: Tue, 24 May 2016 12:03:24 +0200 Message-Id: <1464084204-2271-1-git-send-email-narmstrong@baylibre.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160524_030400_459434_D0120FFD X-CRM114-Status: GOOD ( 12.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Neil Armstrong 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 Implement a get_direction callback for the OXNAS GPIO driver in order to have pin output polarity in debugfs and new userspace ABI. Signed-off-by: Neil Armstrong --- drivers/pinctrl/pinctrl-oxnas.c | 11 +++++++++++ 1 file changed, 11 insertions(+) Linus, Sorry, I should have implemented it earlier but I was focused to have a clean driver for upstream ! Thanks, Neil diff --git a/drivers/pinctrl/pinctrl-oxnas.c b/drivers/pinctrl/pinctrl-oxnas.c index 5fd113c..2c6abef 100644 --- a/drivers/pinctrl/pinctrl-oxnas.c +++ b/drivers/pinctrl/pinctrl-oxnas.c @@ -49,6 +49,7 @@ /* GPIO Registers */ #define INPUT_VALUE 0x00 +#define OUTPUT_EN 0x04 #define IRQ_PENDING 0x0c #define OUTPUT_SET 0x14 #define OUTPUT_CLEAR 0x18 @@ -431,6 +432,15 @@ static int oxnas_gpio_request_enable(struct pinctrl_dev *pctldev, return 0; } +static int oxnas_gpio_get_direction(struct gpio_chip *chip, + unsigned int offset) +{ + struct oxnas_gpio_bank *bank = gpiochip_get_data(chip); + u32 mask = BIT(offset); + + return !(readl_relaxed(bank->reg_base + OUTPUT_EN) & mask); +} + static int oxnas_gpio_direction_input(struct gpio_chip *chip, unsigned int offset) { @@ -664,6 +674,7 @@ static void oxnas_gpio_irq_handler(struct irq_desc *desc) .label = "GPIO" #_bank, \ .request = gpiochip_generic_request, \ .free = gpiochip_generic_free, \ + .get_direction = oxnas_gpio_get_direction, \ .direction_input = oxnas_gpio_direction_input, \ .direction_output = oxnas_gpio_direction_output, \ .get = oxnas_gpio_get, \