[PATCH 7/9] arm/mach-pxa: add gpio direction functions
Robert Jarzmik
robert.jarzmik at free.fr
Wed Nov 23 22:02:42 EST 2011
From: Robert Jarzmik <robert.jarzmik at atosorigin.com>
Add missing function for generic GPIO support.
Both gpio_direction_input() and gpio_direction_output() were
added.
Add also generic GPIO support as a PXA native configuration
option.
Signed-off-by: Robert Jarzmik <robert.jarzmik at free.fr>
---
arch/arm/Kconfig | 1 +
arch/arm/mach-pxa/include/mach/gpio.h | 1 -
arch/arm/mach-pxa/include/plat/gpio.h | 19 +++++++++++++++++++
3 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 4487484..40677a3 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -64,6 +64,7 @@ config ARCH_OMAP
config ARCH_PXA
bool "Intel/Marvell PXA based"
+ select GENERIC_GPIO
config ARCH_S3C24xx
bool "Samsung S3C2410, S3C2412, S3C2413, S3C2440, S3C2442, S3C2443"
diff --git a/arch/arm/mach-pxa/include/mach/gpio.h b/arch/arm/mach-pxa/include/mach/gpio.h
index 16fccd1..8f00677 100644
--- a/arch/arm/mach-pxa/include/mach/gpio.h
+++ b/arch/arm/mach-pxa/include/mach/gpio.h
@@ -132,6 +132,5 @@ static inline int __gpio_is_occupied(unsigned gpio)
} else
return GPDR(gpio) & GPIO_bit(gpio);
}
-
#include <plat/gpio.h>
#endif
diff --git a/arch/arm/mach-pxa/include/plat/gpio.h b/arch/arm/mach-pxa/include/plat/gpio.h
index 0eb38d1..4c7b526 100644
--- a/arch/arm/mach-pxa/include/plat/gpio.h
+++ b/arch/arm/mach-pxa/include/plat/gpio.h
@@ -44,6 +44,25 @@ static inline void gpio_set_value(unsigned gpio, int value)
GPCR(gpio) = GPIO_bit(gpio);
}
+static inline int gpio_direction_input(unsigned gpio)
+{
+ if (__gpio_is_inverted(gpio))
+ GPDR(gpio) |= GPIO_bit(gpio);
+ else
+ GPDR(gpio) &= ~GPIO_bit(gpio);
+ return 0;
+}
+
+static inline int gpio_direction_output(unsigned gpio, int value)
+{
+ gpio_set_value(gpio, value);
+ if (__gpio_is_inverted(gpio))
+ GPDR(gpio) &= ~GPIO_bit(gpio);
+ else
+ GPDR(gpio) |= GPIO_bit(gpio);
+ return 0;
+}
+
/* NOTE: some PXAs have fewer on-chip GPIOs (like PXA255, with 85).
* Those cases currently cause holes in the GPIO number space, the
* actual number of the last GPIO is recorded by 'pxa_last_gpio'.
--
1.7.5.4
More information about the barebox
mailing list