From: Alek Du <alek.du@intel.com>
To: Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Ben Dooks <ben-linux@fluff.org>,
Florian Fainelli <florian@openwrt.org>,
Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: [PATCH v2] gpiolib: Add gpio_debounce and gpio_alt_func features to GPIOLIB
Date: Wed, 17 Jun 2009 14:59:55 +0800 [thread overview]
Message-ID: <20090617145955.355ef2a9@dxy.sh.intel.com> (raw)
In-Reply-To: <20090616083948.GB14476@trinity.fluff.org>
Changes from v1:
Removed gpio_detect since we should do that with irq_chip.set_type function.
>From 6b3c9398acf338c263170fcb74c0b2b345ad5369 Mon Sep 17 00:00:00 2001
From: Alek Du <alek.du@intel.com>
Date: Wed, 17 Jun 2009 14:50:51 +0800
Subject: [PATCH] GPIO: Add gpio_debounce and gpio_alt_func features to GPIOLIB
Add gpio_debounce and gpio_alt_func features to GPIOLIB:
* gpio_debounce is to adjust signal HW debounce value (need HW support)
* gpio_alt_func is to set GPIO as alternative function (need HW support)
Signed-off-by: Alek Du <alek.du@intel.com>
---
drivers/gpio/gpiolib.c | 22 ++++++++++++++++++++++
include/asm-generic/gpio.h | 11 ++++++++++-
include/linux/gpio.h | 10 ++++++++++
3 files changed, 42 insertions(+), 1 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 51a8d41..6365038 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1066,6 +1066,28 @@ void __gpio_set_value(unsigned gpio, int value)
}
EXPORT_SYMBOL_GPL(__gpio_set_value);
+void gpio_debounce(unsigned gpio, int value)
+{
+ struct gpio_chip *chip;
+
+ chip = gpio_to_chip(gpio);
+ WARN_ON(extra_checks && chip->can_sleep);
+ if (chip->debounce)
+ chip->debounce(chip, gpio - chip->base, value);
+}
+EXPORT_SYMBOL_GPL(gpio_debounce);
+
+void gpio_alt_func(unsigned gpio, int value)
+{
+ struct gpio_chip *chip;
+
+ chip = gpio_to_chip(gpio);
+ WARN_ON(extra_checks && chip->can_sleep);
+ if (chip->alt_func)
+ chip->alt_func(chip, gpio - chip->base, value);
+}
+EXPORT_SYMBOL_GPL(gpio_alt_func);
+
/**
* __gpio_cansleep() - report whether gpio value access will sleep
* @gpio: gpio in question
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index d6c379d..bc98c96 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -44,6 +44,8 @@ struct module;
* returns either the value actually sensed, or zero
* @direction_output: configures signal "offset" as output, or returns error
* @set: assigns output value for signal "offset"
+ * @debounce: Adjust signal hardware debounce level
+ * @alt_func: configures signal as GPIO or alternative function
* @to_irq: optional hook supporting non-static gpio_to_irq() mappings;
* implementation may not sleep
* @dbg_show: optional routine to show contents in debugfs; default code
@@ -89,6 +91,12 @@ struct gpio_chip {
void (*set)(struct gpio_chip *chip,
unsigned offset, int value);
+ void (*debounce)(struct gpio_chip *chip,
+ unsigned offset,
+ int value);
+ void (*alt_func)(struct gpio_chip *chip,
+ unsigned offset, int value);
+
int (*to_irq)(struct gpio_chip *chip,
unsigned offset);
@@ -118,7 +126,8 @@ extern void gpio_free(unsigned gpio);
extern int gpio_direction_input(unsigned gpio);
extern int gpio_direction_output(unsigned gpio, int value);
-
+extern void gpio_debounce(unsigned gpio, int value);
+extern void gpio_alt_func(unsigned gpio, int value);
extern int gpio_get_value_cansleep(unsigned gpio);
extern void gpio_set_value_cansleep(unsigned gpio, int value);
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index e10c49a..cf005d5 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -82,6 +82,16 @@ static inline void gpio_set_value_cansleep(unsigned gpio, int value)
WARN_ON(1);
}
+static inline void gpio_debounce(unsigned gpio, int value)
+{
+ WARN_ON(1);
+}
+
+static inline void gpio_alt_func(unsigned gpio, int value)
+{
+ WARN_ON(1);
+}
+
static inline int gpio_export(unsigned gpio, bool direction_may_change)
{
/* GPIO can never have been requested or set as {in,out}put */
--
1.6.0.4
next prev parent reply other threads:[~2009-06-17 7:06 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-15 9:15 [PATCH] gpiolib: Add gpio_detect, gpio_debounce and gpio_alt_func features to GPIOLIB Alek Du
2009-06-15 9:50 ` Ben Dooks
2009-06-15 10:02 ` Mark Brown
2009-06-15 11:19 ` Alek Du
2009-06-15 12:56 ` Florian Fainelli
2009-06-15 12:50 ` Ben Dooks
2009-06-15 13:07 ` Mark Brown
2009-06-15 11:29 ` Alek Du
2009-06-15 12:51 ` Ben Dooks
2009-06-15 13:04 ` Florian Fainelli
2009-06-15 13:09 ` Ben Dooks
2009-06-16 1:28 ` Alek Du
2009-06-16 8:39 ` Ben Dooks
2009-06-17 6:59 ` Alek Du [this message]
2009-06-17 9:36 ` [PATCH v2] gpiolib: Add " Ben Nizette
2009-06-16 1:21 ` [PATCH] gpiolib: Add gpio_detect, " Alek Du
2009-06-16 8:45 ` Ben Dooks
2009-06-16 8:51 ` Alek Du
2009-06-16 9:02 ` Ben Dooks
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=20090617145955.355ef2a9@dxy.sh.intel.com \
--to=alek.du@intel.com \
--cc=ben-linux@fluff.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=florian@openwrt.org \
--cc=linux-kernel@vger.kernel.org \
/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