mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Barry Song <Baohua.Song@csr.com>
To: <grant.likely@secretlab.ca>
Cc: <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>, <workgroup.linux@csr.com>,
	Barry Song <Baohua.Song@csr.com>
Subject: [PATCH] GPIOLIB: add generic gpio_set_pull API
Date: Sun, 7 Aug 2011 22:19:33 -0700	[thread overview]
Message-ID: <1312780773-23142-1-git-send-email-Baohua.Song@csr.com> (raw)

Now there are many different implementations for GPIO pull configuration, for
example:
s3c_gpio_setpull()
tegra_pinmux_set_pullupdown()
chipcHw_setPinPullup()
gpio_pullup()
s3c2410_gpio_pullup()

This patch adds a new generic gpio_set_pull API so that all SoCs can have unified
codes.

Signed-off-by: Barry Song <Baohua.Song@csr.com>
---
 drivers/gpio/gpiolib.c     |   17 +++++++++++++++++
 include/asm-generic/gpio.h |    3 +++
 include/linux/gpio.h       |    4 ++++
 3 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index a971e3d..a2afa95 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1620,6 +1620,23 @@ int __gpio_to_irq(unsigned gpio)
 }
 EXPORT_SYMBOL_GPL(__gpio_to_irq);
 
+/**
+ * __gpio_set_pull() - set pull up, pull down or no pull for a gpio
+ * @gpio: gpio which will be configurated
+ * @mode: one of GPIO_PULL_NONE, GPIO_PULL_UP and GPIO_PULL_DOWN
+ * Context: any
+ *
+ * This is used directly or indirectly to implement gpio_set_pull().
+ */
+void __gpio_set_pull(unsigned gpio, unsigned mode)
+{
+	struct gpio_chip	*chip;
+
+	chip = gpio_to_chip(gpio);
+
+	chip->pull(chip, gpio, mode);
+}
+EXPORT_SYMBOL_GPL(__gpio_set_pull);
 
 
 /* There's no value in making it easy to inline GPIO calls that may sleep.
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index d494001..f953835 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -112,6 +112,9 @@ struct gpio_chip {
 	int			(*to_irq)(struct gpio_chip *chip,
 						unsigned offset);
 
+	void			(*pull)(struct gpio_chip *chip,
+						unsigned offset, unsigned mode);
+
 	void			(*dbg_show)(struct seq_file *s,
 						struct gpio_chip *chip);
 	int			base;
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 17b5a0d..ac48166 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -14,6 +14,10 @@
 #define GPIOF_OUT_INIT_LOW	(GPIOF_DIR_OUT | GPIOF_INIT_LOW)
 #define GPIOF_OUT_INIT_HIGH	(GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
 
+#define GPIO_PULL_NONE	0
+#define GPIO_PULL_UP	1
+#define GPIO_PULL_DOWN	2
+
 #ifdef CONFIG_GENERIC_GPIO
 #include <asm/gpio.h>
 
-- 
1.7.1



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog

             reply	other threads:[~2011-08-08  5:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-08  5:19 Barry Song [this message]
2011-08-08  8:15 ` Paul Mundt
2011-08-08 18:24   ` Grant Likely
2011-08-08 22:57     ` Kyungmin Park
2011-08-09  1:45       ` Rohit Vaswani
2011-08-09  2:51         ` Barry Song
2011-08-09 10:11         ` Linus Walleij
2012-06-19  3:25           ` Barry Song
2012-06-20  8:15             ` Linus Walleij
2012-06-20 10:07               ` Barry Song
2012-06-20 14:31               ` Paul Mundt
2012-06-21  7:48                 ` Linus Walleij
2011-08-09 10:07       ` Linus Walleij
2011-08-09 10:04     ` Linus Walleij

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=1312780773-23142-1-git-send-email-Baohua.Song@csr.com \
    --to=baohua.song@csr.com \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=workgroup.linux@csr.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

all inboxes | Powered by JetHome®