From patchwork Tue Apr 22 09:23:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yegor Yefremov X-Patchwork-Id: 4030431 Return-Path: X-Original-To: patchwork-linux-omap@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 B22C49F1F4 for ; Tue, 22 Apr 2014 09:51:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AC2C520211 for ; Tue, 22 Apr 2014 09:51:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 958CD20173 for ; Tue, 22 Apr 2014 09:50:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755011AbaDVJu4 (ORCPT ); Tue, 22 Apr 2014 05:50:56 -0400 Received: from hhlx01.visionsystems.de ([62.145.30.242]:48153 "EHLO mail.visionsystems.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754735AbaDVJuz (ORCPT ); Tue, 22 Apr 2014 05:50:55 -0400 X-Greylist: delayed 1592 seconds by postgrey-1.27 at vger.kernel.org; Tue, 22 Apr 2014 05:50:54 EDT Received: from localhost (localhost [127.0.0.1]) by mail.visionsystems.de (Postfix) with ESMTP id 3B7552E1832; Tue, 22 Apr 2014 11:24:21 +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 25369-07; Tue, 22 Apr 2014 11:24:07 +0200 (CEST) Received: from visionsystems.de (kallisto.visionsystems.local [192.168.1.3]) by mail.visionsystems.de (Postfix) with ESMTP id BD4E72E0061; Tue, 22 Apr 2014 11:24:07 +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 11:24:03 +0200 From: yegorslists@googlemail.com To: linux-gpio@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, tony@atomide.com, linus.walleij@linaro.org, Yegor Yefremov Subject: [PATCH] gpio: omap: implement get_direction Date: Tue, 22 Apr 2014 11:23:55 +0200 Message-Id: <1398158635-18415-1-git-send-email-yegorslists@googlemail.com> X-Mailer: git-send-email 1.7.7 X-OriginalArrivalTime: 22 Apr 2014 09:24:03.0987 (UTC) FILETIME=[9A639630:01CF5E0C] X-Virus-Scanned: amavisd-new at visionsystems.de Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham 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 --- drivers/gpio/gpio-omap.c | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-) diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index 19b886c..b55bf7b 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c @@ -102,6 +102,20 @@ 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; + u32 mask = 1 << gpio; + + reg += bank->regs->direction; + l = readl_relaxed(reg); + if (l & mask) + return 1; + + return 0; +} + static void _set_gpio_direction(struct gpio_bank *bank, int gpio, int is_input) { void __iomem *reg = bank->base; @@ -936,6 +950,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 +1119,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;