From patchwork Mon Mar 28 14:58:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 8680311 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4F7CE9F54E for ; Mon, 28 Mar 2016 20:18:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0FEAE20225 for ; Mon, 28 Mar 2016 20:18:51 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 171DE20220 for ; Mon, 28 Mar 2016 20:18:50 +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 1akdaz-0006DU-4H; Mon, 28 Mar 2016 20:17:05 +0000 Received: from mout.kundenserver.de ([212.227.17.24]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1akdau-00063e-Uf; Mon, 28 Mar 2016 20:17:02 +0000 Received: from localhost.localdomain ([95.91.39.67]) by mrelayeu.kundenserver.de (mreue103) with ESMTPSA (Nemesis) id 0LfGuG-1Zw9qY1e4e-00on7n; Mon, 28 Mar 2016 16:58:46 +0200 From: Stefan Wahren To: Linus Walleij , Stephen Warren , Lee Jones , Eric Anholt Subject: [PATCH] pinctrl: bcm2835: Implement get_direction callback Date: Mon, 28 Mar 2016 14:58:24 +0000 Message-Id: <1459177104-24353-1-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 1.7.9.5 X-Provags-ID: V03:K0:ShsXxWChUmPt6i+5NG4tK6nIOGzgnzoYwMWZM0pt0Y5LIMXf0kr qU3zBOJoJH9bsfo1b5r+0jfeN2C8iShzVBZcoGQnVGdRYPMiSZmUAr6v1aYHM2roHcR2Tnw jMRGWb2U6sjN0FSeoACtElhjk7DrxS1BS3+o/P4E/iTb1dCR0sOBVNkluzQtXEQKhotw+1d t7n4Vrkthr3apOEngDBEw== X-UI-Out-Filterresults: notjunk:1; V01:K0:pQ7xoeSBpDQ=:q3U58h7tkH2V6h+g/UcUbp HBNhl6fp38WJZucPAuvCboFZw5qauH2vWBWuH+AicZk+2CCLRogJtac6ixT0rte7dOFd+RGBG 1gmI5Kl/R+eH286EQmCN6laF9XQdmm0ZjevtImLIzJ8iknhRS9wkxV4Uaf2VR+Q37vHP+uWnK h/Uk8WUgVXGy541rHCxGarMoDMxmWqbnq2k5Te50Hr5Wm3eFh2UVrXCt6/KddzRug9FIqEJrZ HD6Kw8XfUUnWBKdS7kve86xRiBEDkFgqmB3bJyWH3LcIo5TQO/jnWCDd2NQTseSTDGP7zPIP2 1TZMFVn3iT/1jT9JvYILHel8AohR7y6Vui/scWZvtmS4gGDhtx0/kypJgKr7gqAk92/Z80kR3 oR/gf61iGxt49gzWxGS+/OdqlQiMUo9gbPF6SbwF1gv2LFsTAqjheaG0U52H0O+R1eQ5mA1ky ht+/WAII/iC/VKzHTcJ4hLjKhQtxwpEKiF4qXAo4lvE3BZmOfORKzMaoiIFIRLgeOGoOOK96q C0IJmlTik/5PGOhkzUMij0xzfivzfhZ8mXHKBcitrZOjLwBhGyKNd/WEabaZyYeayUiWBA+oF /wCoqTemRebSbtCwNoA0mdjVkpyCUpjnYjKuFqYEuEnFWzpRqgSOpJXRcJ2FvyoJ10U38Nr+t WVflfYvKuCBFcW77W2itlKr0yhgSZndiuIayEyFW3ej8P+lJcDeZLl6REWyf5h8ScRh8= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160328_131701_400771_ED0D0A77 X-CRM114-Status: UNSURE ( 8.34 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) 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: Stefan Wahren , linux-gpio@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Implement gpio_chip's get_direction() callback, that lets other drivers get particular GPIOs direction using gpiod_get_direction(). Signed-off-by: Stefan Wahren Reviewed-by: Stephen Warren --- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c index 08b1d93..dd8b174 100644 --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -342,6 +342,18 @@ static int bcm2835_gpio_get(struct gpio_chip *chip, unsigned offset) return bcm2835_gpio_get_bit(pc, GPLEV0, offset); } +static int bcm2835_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) +{ + struct bcm2835_pinctrl *pc = gpiochip_get_data(chip); + enum bcm2835_fsel fsel = bcm2835_pinctrl_fsel_get(pc, offset); + + /* Alternative function doesn't clearly provide a direction */ + if (fsel > BCM2835_FSEL_GPIO_OUT) + return -EINVAL; + + return (fsel == BCM2835_FSEL_GPIO_IN); +} + static void bcm2835_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { struct bcm2835_pinctrl *pc = gpiochip_get_data(chip); @@ -370,6 +382,7 @@ static struct gpio_chip bcm2835_gpio_chip = { .free = gpiochip_generic_free, .direction_input = bcm2835_gpio_direction_input, .direction_output = bcm2835_gpio_direction_output, + .get_direction = bcm2835_gpio_get_direction, .get = bcm2835_gpio_get, .set = bcm2835_gpio_set, .to_irq = bcm2835_gpio_to_irq,