[PATCH v3 3/3] gpio: pxa: request pinmux function for gpio

From: Haojian Zhuang
Date: Thu Dec 22 2011 - 03:13:43 EST


While gpio is requested for pxa, gpio driver will request function ready
on pin.

Signed-off-by: Haojian Zhuang <haojian.zhuang@xxxxxxxxxxx>
---
drivers/gpio/gpio-pxa.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index b2d3ee1..4f33ba2 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -19,6 +19,7 @@
#include <linux/irq.h>
#include <linux/io.h>
#include <linux/platform_device.h>
+#include <linux/pinctrl/pinmux.h>
#include <linux/syscore_ops.h>
#include <linux/slab.h>

@@ -267,6 +268,21 @@ static void pxa_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
(value ? GPSR_OFFSET : GPCR_OFFSET));
}

+#ifdef CONFIG_PINMUX
+static int pxa_gpio_request(struct gpio_chip *chip, unsigned offset)
+{
+ return pinmux_request_gpio(chip->base + offset);
+}
+
+static void pxa_gpio_free(struct gpio_chip *chip, unsigned offset)
+{
+ pinmux_free_gpio(chip->base + offset);
+}
+#else
+static int pxa_gpio_request(struct gpio_chip *chip, unsigned offset) {return 0;}
+static void pxa_gpio_free(struct gpio_chip *chip, unsigned offset) {}
+#endif
+
static int __devinit pxa_init_gpio_chip(int gpio_end)
{
int i, gpio, nbanks = gpio_to_bank(gpio_end) + 1;
@@ -292,6 +308,8 @@ static int __devinit pxa_init_gpio_chip(int gpio_end)
c->get = pxa_gpio_get;
c->set = pxa_gpio_set;
c->to_irq = pxa_gpio_to_irq;
+ c->request = pxa_gpio_request;
+ c->free = pxa_gpio_free;

/* number of GPIOs on last bank may be less than 32 */
c->ngpio = (gpio + 31 > gpio_end) ? (gpio_end - gpio + 1) : 32;
--
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/