diff options
author | Philipp Zabel <philipp.zabel@gmail.com> | 2008-02-05 01:28:22 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-05 12:44:13 -0500 |
commit | 1c44f5f16fee880b294f8068354bfb9dddf1349b (patch) | |
tree | dd9815cf7a38af7d4abc55eb707574ceedd8a912 /include/asm-arm/arch-pxa/gpio.h | |
parent | 7c2db759ece63fd166cf0849b7b271589fa1b754 (diff) |
gpiolib support for the PXA architecture
This adds gpiolib support for the PXA architecture:
- move all GPIO API functions from generic.c into gpio.c
- convert the gpio_get/set_value macros into inline functions
This makes it easier to hook up GPIOs provided by external chips like
ASICs and CPLDs.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: Eric Miao <eric.miao@marvell.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Haavard Skinnemoen <hskinnemoen@atmel.com>
Cc: Ben Gardner <bgardner@wabtec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
[ Minor ARM fixup from David Brownell folded into this ]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/asm-arm/arch-pxa/gpio.h')
-rw-r--r-- | include/asm-arm/arch-pxa/gpio.h | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/include/asm-arm/arch-pxa/gpio.h b/include/asm-arm/arch-pxa/gpio.h index 9dbc2dc794f..bdbf5f9ffdd 100644 --- a/include/asm-arm/arch-pxa/gpio.h +++ b/include/asm-arm/arch-pxa/gpio.h | |||
@@ -28,43 +28,35 @@ | |||
28 | #include <asm/irq.h> | 28 | #include <asm/irq.h> |
29 | #include <asm/hardware.h> | 29 | #include <asm/hardware.h> |
30 | 30 | ||
31 | static inline int gpio_request(unsigned gpio, const char *label) | 31 | #include <asm-generic/gpio.h> |
32 | { | ||
33 | return 0; | ||
34 | } | ||
35 | 32 | ||
36 | static inline void gpio_free(unsigned gpio) | ||
37 | { | ||
38 | return; | ||
39 | } | ||
40 | 33 | ||
41 | extern int gpio_direction_input(unsigned gpio); | 34 | /* NOTE: some PXAs have fewer on-chip GPIOs (like PXA255, with 85). |
42 | extern int gpio_direction_output(unsigned gpio, int value); | 35 | * Those cases currently cause holes in the GPIO number space. |
36 | */ | ||
37 | #define NR_BUILTIN_GPIO 128 | ||
43 | 38 | ||
44 | static inline int __gpio_get_value(unsigned gpio) | 39 | static inline int gpio_get_value(unsigned gpio) |
45 | { | 40 | { |
46 | return GPLR(gpio) & GPIO_bit(gpio); | 41 | if (__builtin_constant_p(gpio) && (gpio < NR_BUILTIN_GPIO)) |
42 | return GPLR(gpio) & GPIO_bit(gpio); | ||
43 | else | ||
44 | return __gpio_get_value(gpio); | ||
47 | } | 45 | } |
48 | 46 | ||
49 | #define gpio_get_value(gpio) \ | 47 | static inline void gpio_set_value(unsigned gpio, int value) |
50 | (__builtin_constant_p(gpio) ? \ | ||
51 | __gpio_get_value(gpio) : \ | ||
52 | pxa_gpio_get_value(gpio)) | ||
53 | |||
54 | static inline void __gpio_set_value(unsigned gpio, int value) | ||
55 | { | 48 | { |
56 | if (value) | 49 | if (__builtin_constant_p(gpio) && (gpio < NR_BUILTIN_GPIO)) { |
57 | GPSR(gpio) = GPIO_bit(gpio); | 50 | if (value) |
58 | else | 51 | GPSR(gpio) = GPIO_bit(gpio); |
59 | GPCR(gpio) = GPIO_bit(gpio); | 52 | else |
53 | GPCR(gpio) = GPIO_bit(gpio); | ||
54 | } else { | ||
55 | __gpio_set_value(gpio, value); | ||
56 | } | ||
60 | } | 57 | } |
61 | 58 | ||
62 | #define gpio_set_value(gpio,value) \ | 59 | #define gpio_cansleep __gpio_cansleep |
63 | (__builtin_constant_p(gpio) ? \ | ||
64 | __gpio_set_value(gpio, value) : \ | ||
65 | pxa_gpio_set_value(gpio, value)) | ||
66 | |||
67 | #include <asm-generic/gpio.h> /* cansleep wrappers */ | ||
68 | 60 | ||
69 | #define gpio_to_irq(gpio) IRQ_GPIO(gpio) | 61 | #define gpio_to_irq(gpio) IRQ_GPIO(gpio) |
70 | #define irq_to_gpio(irq) IRQ_TO_GPIO(irq) | 62 | #define irq_to_gpio(irq) IRQ_TO_GPIO(irq) |