summaryrefslogtreecommitdiffstats
path: root/include/asm-arm
diff options
context:
space:
mode:
authorPhilipp Zabel <philipp.zabel@gmail.com>2007-02-20 13:58:15 -0800
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-02-20 17:10:16 -0800
commit3deac046e2883686a732960050ab74fca0db11fa (patch)
treede8e8b19148d201147f8be4084efba156f9e6709 /include/asm-arm
parent5d4675a811fb71fd922109d7ebae3f987401ace1 (diff)
downloadtalos-obmc-linux-3deac046e2883686a732960050ab74fca0db11fa.tar.gz
talos-obmc-linux-3deac046e2883686a732960050ab74fca0db11fa.zip
[PATCH] GPIO API: PXA wrapper cleanup
Based on the discussion last december (http://lkml.org/lkml/2006/12/20/242), this patch: - moves the PXA_LAST_GPIO check into pxa_gpio_mode - fixes comment and includes in gpio.h - replaces the gpio_set/get_value macros with inline functions and adds a non-inline version to avoid code explosion when gpio is not a constant. Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Nicolas Pitre <nico@cam.org> Cc: Russell King <rmk@arm.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/asm-arm')
-rw-r--r--include/asm-arm/arch-pxa/gpio.h42
-rw-r--r--include/asm-arm/arch-pxa/hardware.h12
2 files changed, 36 insertions, 18 deletions
diff --git a/include/asm-arm/arch-pxa/gpio.h b/include/asm-arm/arch-pxa/gpio.h
index e67c23821017..3d348a351157 100644
--- a/include/asm-arm/arch-pxa/gpio.h
+++ b/include/asm-arm/arch-pxa/gpio.h
@@ -25,10 +25,8 @@
#define __ASM_ARCH_PXA_GPIO_H
#include <asm/arch/pxa-regs.h>
-#include <asm/arch/irqs.h>
-#include <asm/arch/hardware.h>
-
-#include <asm/errno.h>
+#include <asm/irq.h>
+#include <asm/hardware.h>
static inline int gpio_request(unsigned gpio, const char *label)
{
@@ -42,26 +40,36 @@ static inline void gpio_free(unsigned gpio)
static inline int gpio_direction_input(unsigned gpio)
{
- if (gpio > PXA_LAST_GPIO)
- return -EINVAL;
- pxa_gpio_mode(gpio | GPIO_IN);
+ return pxa_gpio_mode(gpio | GPIO_IN);
}
static inline int gpio_direction_output(unsigned gpio)
{
- if (gpio > PXA_LAST_GPIO)
- return -EINVAL;
- pxa_gpio_mode(gpio | GPIO_OUT);
+ return pxa_gpio_mode(gpio | GPIO_OUT);
}
-/* REVISIT these macros are correct, but suffer code explosion
- * for non-constant parameters. Provide out-line versions too.
- */
-#define gpio_get_value(gpio) \
- (GPLR(gpio) & GPIO_bit(gpio))
+static inline int __gpio_get_value(unsigned gpio)
+{
+ return GPLR(gpio) & GPIO_bit(gpio);
+}
+
+#define gpio_get_value(gpio) \
+ (__builtin_constant_p(gpio) ? \
+ __gpio_get_value(gpio) : \
+ pxa_gpio_get_value(gpio))
+
+static inline void __gpio_set_value(unsigned gpio, int value)
+{
+ if (value)
+ GPSR(gpio) = GPIO_bit(gpio);
+ else
+ GPCR(gpio) = GPIO_bit(gpio);
+}
-#define gpio_set_value(gpio,value) \
- ((value) ? (GPSR(gpio) = GPIO_bit(gpio)):(GPCR(gpio) = GPIO_bit(gpio)))
+#define gpio_set_value(gpio,value) \
+ (__builtin_constant_p(gpio) ? \
+ __gpio_set_value(gpio, value) : \
+ pxa_gpio_set_value(gpio, value))
#include <asm-generic/gpio.h> /* cansleep wrappers */
diff --git a/include/asm-arm/arch-pxa/hardware.h b/include/asm-arm/arch-pxa/hardware.h
index 3e70bd95472c..e2bdc2fbede1 100644
--- a/include/asm-arm/arch-pxa/hardware.h
+++ b/include/asm-arm/arch-pxa/hardware.h
@@ -65,7 +65,17 @@
/*
* Handy routine to set GPIO alternate functions
*/
-extern void pxa_gpio_mode( int gpio_mode );
+extern int pxa_gpio_mode( int gpio_mode );
+
+/*
+ * Return GPIO level, nonzero means high, zero is low
+ */
+extern int pxa_gpio_get_value(unsigned gpio);
+
+/*
+ * Set output GPIO level
+ */
+extern void pxa_gpio_set_value(unsigned gpio, int value);
/*
* Routine to enable or disable CKEN
OpenPOWER on IntegriCloud