linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Balbi <felipe.balbi@nokia.com>
To: "Balbi Felipe (Nokia-D/Helsinki)" <felipe.balbi@nokia.com>
Cc: David Brownell <david-b@pacbell.net>,
	Tony Lindgren <tony@atomide.com>,
	Linux OMAP Mailing List <linux-omap@vger.kernel.org>
Subject: Re: [RFC/PATCH 2/4] arm: omap: gpio: implement set_debounce method
Date: Wed, 31 Mar 2010 15:56:20 +0300	[thread overview]
Message-ID: <20100331125620.GA16297@nokia.com> (raw)
In-Reply-To: <1270038435-28106-3-git-send-email-felipe.balbi@nokia.com>

[-- Attachment #1: Type: text/plain, Size: 283 bytes --]

On Wed, Mar 31, 2010 at 02:27:13PM +0200, Balbi Felipe (Nokia-D/Helsinki) wrote:
>OMAP support debouncing of gpio lines, implement
>the method using gpiolib.
>
>Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>

this one was missing dbck handling. New version attached

-- 
balbi

[-- Attachment #2: 0002-arm-omap-gpio-implement-set_debounce-method.diff --]
[-- Type: text/x-diff, Size: 2439 bytes --]

>From e37f49e1006abde377cf56604077fb20340cca0a Mon Sep 17 00:00:00 2001
From: Felipe Balbi <felipe.balbi@nokia.com>
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 <felipe.balbi@nokia.com>
---
 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


  reply	other threads:[~2010-03-31 12:57 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-31 12:27 [RFC/PATCH 0/4] teach gpiolib about gpio debouncing Felipe Balbi
2010-03-31 12:27 ` [RFC/PATCH 1/4] gpiolib: introduce set_debounce method Felipe Balbi
2010-03-31 13:46   ` Mark Brown
2010-03-31 14:50     ` Felipe Balbi
2010-03-31 14:59       ` Felipe Balbi
2010-03-31 15:04         ` Mark Brown
2010-03-31 15:06           ` Felipe Balbi
2010-03-31 15:11             ` Mark Brown
2010-03-31 15:11               ` Felipe Balbi
2010-03-31 12:27 ` [RFC/PATCH 2/4] arm: omap: gpio: implement " Felipe Balbi
2010-03-31 12:56   ` Felipe Balbi [this message]
2010-03-31 12:27 ` [RFC/PATCH 3/4] arm: omap: switch over to gpio_set_debounce Felipe Balbi
2010-03-31 12:27 ` [RFC/PATCH 4/4] arm: omap: remove the unused omap_gpio_set_debounce methods Felipe Balbi
2010-03-31 15:35 ` [RFC/PATCHv2 0/4] teach gpiolib about debouncing Felipe Balbi
2010-03-31 15:35 ` [RFC/PATCHv2 1/4] gpiolib: introduce set_debounce method Felipe Balbi
2010-04-02 12:34   ` Mark Brown
2010-05-04 22:40     ` Tony Lindgren
2010-05-05 18:37       ` Felipe Balbi
2010-03-31 15:35 ` [RFC/PATCHv2 2/4] arm: omap: gpio: implement " Felipe Balbi
2010-03-31 16:21   ` Mark Brown
2010-03-31 16:29     ` Felipe Balbi
2010-04-01  5:39       ` Felipe Balbi
2010-04-01  9:29   ` Grazvydas Ignotas
2010-04-01  9:32     ` Felipe Balbi
2010-04-01  9:37       ` Grazvydas Ignotas
2010-04-01 10:10         ` Felipe Balbi
2010-04-01 11:20           ` Grazvydas Ignotas
2010-04-01 13:11       ` Jani Nikula
2010-04-01 16:42         ` Felipe Balbi
2010-04-01 18:15           ` Mark Brown
2010-04-01 18:19             ` Felipe Balbi
2010-03-31 15:35 ` [RFC/PATCHv2 3/4] arm: omap: switch over to gpio_set_debounce Felipe Balbi
2010-03-31 15:35 ` [RFC/PATCHv2 4/4] arm: omap: remove the unused omap_gpio_set_debounce methods Felipe Balbi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100331125620.GA16297@nokia.com \
    --to=felipe.balbi@nokia.com \
    --cc=david-b@pacbell.net \
    --cc=linux-omap@vger.kernel.org \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).