From patchwork Tue Apr 22 13:31:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yegor Yefremov X-Patchwork-Id: 4031941 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C5C459F1F4 for ; Tue, 22 Apr 2014 13:36:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 749FE201EF for ; Tue, 22 Apr 2014 13:35:56 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD6E6201ED for ; Tue, 22 Apr 2014 13:35:51 +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 1Wcaoq-0008MK-Qx; Tue, 22 Apr 2014 13:33:04 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wcaoo-0008Lw-GQ for linux-arm-kernel@bombadil.infradead.org; Tue, 22 Apr 2014 13:33:02 +0000 Received: from ns.visionsystems.de ([62.145.30.242] helo=mail.visionsystems.de) by casper.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wcaom-0002uo-2E for linux-arm-kernel@lists.infradead.org; Tue, 22 Apr 2014 13:33:00 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.visionsystems.de (Postfix) with ESMTP id 0E4082E4D58; Tue, 22 Apr 2014 15:32:20 +0200 (CEST) Received: from mail.visionsystems.de ([127.0.0.1]) by localhost (mail.visionsystems.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 29552-08; Tue, 22 Apr 2014 15:32:06 +0200 (CEST) Received: from visionsystems.de (kallisto.visionsystems.local [192.168.1.3]) by mail.visionsystems.de (Postfix) with ESMTP id 8EBD52E4D55; Tue, 22 Apr 2014 15:32:06 +0200 (CEST) Received: from development1.visionsystems.local ([192.168.1.36]) by visionsystems.de with Microsoft SMTPSVC(6.0.3790.4675); Tue, 22 Apr 2014 15:32:05 +0200 From: yegorslists@googlemail.com To: linux-gpio@vger.kernel.org Subject: [PATCH v2] gpio: omap: implement get_direction Date: Tue, 22 Apr 2014 15:31:45 +0200 Message-Id: <1398173505-28193-1-git-send-email-yegorslists@googlemail.com> X-Mailer: git-send-email 1.7.7 X-OriginalArrivalTime: 22 Apr 2014 13:32:05.0615 (UTC) FILETIME=[4087CFF0:01CF5E2F] X-Virus-Scanned: amavisd-new at visionsystems.de X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140422_143300_170868_A81B883D X-CRM114-Status: GOOD ( 13.10 ) X-Spam-Score: -1.6 (-) Cc: tony@atomide.com, linus.walleij@linaro.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Yegor Yefremov X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, 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 From: Yegor Yefremov This patch implements gpio_chip's get_direction() routine, that lets other drivers get particular GPIOs direction using struct gpio_desc. Signed-off-by: Yegor Yefremov Acked-by: Javier Martinez Canillas --- Changes: v2: rework return value calculation drivers/gpio/gpio-omap.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index 19b886c..fadc45e 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -102,6 +102,17 @@ static int omap_gpio_to_irq(struct gpio_chip *chip, unsigned offset) return irq_find_mapping(bank->domain, offset); } +static int _get_gpio_direction(struct gpio_bank *bank, int gpio) +{ + void __iomem *reg = bank->base; + u32 l; + + reg += bank->regs->direction; + l = (readl_relaxed(reg) >> gpio); + + return (l & 0x00000001); +} + static void _set_gpio_direction(struct gpio_bank *bank, int gpio, int is_input) { void __iomem *reg = bank->base; @@ -936,6 +947,19 @@ static inline void mpuio_init(struct gpio_bank *bank) /*---------------------------------------------------------------------*/ +static int gpio_get_direction(struct gpio_chip *chip, unsigned offset) +{ + struct gpio_bank *bank; + unsigned long flags; + int dir; + + bank = container_of(chip, struct gpio_bank, chip); + spin_lock_irqsave(&bank->lock, flags); + dir = _get_gpio_direction(bank, offset); + spin_unlock_irqrestore(&bank->lock, flags); + return dir; +} + static int gpio_input(struct gpio_chip *chip, unsigned offset) { struct gpio_bank *bank; @@ -1092,6 +1116,7 @@ static void omap_gpio_chip_init(struct gpio_bank *bank) */ bank->chip.request = omap_gpio_request; bank->chip.free = omap_gpio_free; + bank->chip.get_direction = gpio_get_direction; bank->chip.direction_input = gpio_input; bank->chip.get = gpio_get; bank->chip.direction_output = gpio_output;