From patchwork Wed Mar 31 12:56:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 89950 X-Patchwork-Delegate: tony@atomide.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2VCvaGT011509 for ; Wed, 31 Mar 2010 12:57:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932633Ab0CaM5f (ORCPT ); Wed, 31 Mar 2010 08:57:35 -0400 Received: from smtp.nokia.com ([192.100.122.230]:32387 "EHLO mgw-mx03.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932619Ab0CaM5e (ORCPT ); Wed, 31 Mar 2010 08:57:34 -0400 Received: from esebh106.NOE.Nokia.com (esebh106.ntc.nokia.com [172.21.138.213]) by mgw-mx03.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o2VCvF5w015396; Wed, 31 Mar 2010 15:57:27 +0300 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by esebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 31 Mar 2010 15:56:51 +0300 Received: from mgw-da02.ext.nokia.com ([147.243.128.26]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Wed, 31 Mar 2010 15:56:50 +0300 Received: from nokia.com (esdhcp04088.research.nokia.com [172.21.40.88]) by mgw-da02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o2VCuhHS000931 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 31 Mar 2010 15:56:45 +0300 Date: Wed, 31 Mar 2010 15:56:20 +0300 From: Felipe Balbi To: "Balbi Felipe (Nokia-D/Helsinki)" Cc: David Brownell , Tony Lindgren , Linux OMAP Mailing List Subject: Re: [RFC/PATCH 2/4] arm: omap: gpio: implement set_debounce method Message-ID: <20100331125620.GA16297@nokia.com> Reply-To: felipe.balbi@nokia.com References: <1270038435-28106-1-git-send-email-felipe.balbi@nokia.com> <1270038435-28106-3-git-send-email-felipe.balbi@nokia.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1270038435-28106-3-git-send-email-felipe.balbi@nokia.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-OriginalArrivalTime: 31 Mar 2010 12:56:51.0323 (UTC) FILETIME=[A1B534B0:01CAD0D1] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 31 Mar 2010 12:58:10 +0000 (UTC) From e37f49e1006abde377cf56604077fb20340cca0a Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 31 Mar 2010 15:17:29 +0300 Subject: [RFC/PATCH 2/4] arm: omap: gpio: implement set_debounce method OMAP support debouncing of gpio lines, implement the method using gpiolib. Signed-off-by: Felipe Balbi --- arch/arm/plat-omap/gpio.c | 51 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 51 insertions(+), 0 deletions(-) diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c index 76a347b..9df434e 100644 --- a/arch/arm/plat-omap/gpio.c +++ b/arch/arm/plat-omap/gpio.c @@ -612,6 +612,43 @@ do { \ __raw_writel(l, base + reg); \ } while(0) +static void _set_gpio_debounce(struct gpio_bank *bank, unsigned gpio, int value) +{ + void __iomem *reg = bank->base; + u32 val; + u32 l; + + value &= 0xff; + l = 1 << get_gpio_index(gpio); + + if (cpu_is_omap44xx()) + reg += OMAP4_GPIO_DEBOUNCINGTIME; + else + reg += OMAP24XX_GPIO_DEBOUNCE_VAL; + + __raw_writel(value, reg); + + reg = bank->base; + if (cpu_is_omap44xx()) + reg += OMAP4_GPIO_DEBOUNCENABLE; + else + reg += OMAP24XX_GPIO_DEBOUNCE_EN; + + val = __raw_readl(reg); + + if (value) { + val |= l; + if (cpu_is_omap34xx() || cpu_is_omap44xx()) + clk_enable(bank->dbck); + } else { + val &= ~l; + if (cpu_is_omap34xx() || cpu_is_omap44xx()) + clk_disable(bank->dbck); + } + + __raw_writel(val, reg); +} + void omap_set_gpio_debounce(int gpio, int enable) { struct gpio_bank *bank; @@ -1608,6 +1645,19 @@ static int gpio_output(struct gpio_chip *chip, unsigned offset, int value) return 0; } +static int gpio_debounce(struct gpio_chip *chip, unsigned offset, int value) +{ + struct gpio_bank *bank; + unsigned long flags; + + bank = container_of(chip, struct gpio_bank, chip); + spin_lock_irqsave(&bank->lock, flags); + _set_gpio_debounce(bank, offset, value); + spin_unlock_irqrestore(&bank->lock, flags); + + return 0; +} + static void gpio_set(struct gpio_chip *chip, unsigned offset, int value) { struct gpio_bank *bank; @@ -1860,6 +1910,7 @@ static int __init _omap_gpio_init(void) bank->chip.direction_input = gpio_input; bank->chip.get = gpio_get; bank->chip.direction_output = gpio_output; + bank->chip.set_debounce = gpio_debounce; bank->chip.set = gpio_set; bank->chip.to_irq = gpio_2irq; if (bank_is_mpuio(bank)) { -- 1.7.0.rc0.33.g7c3932