aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-arm/arch-ep93xx/gpio.h
diff options
context:
space:
mode:
authorHerbert Valerio Riedel <hvr@gnu.org>2007-11-26 12:41:02 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-01-26 09:37:31 -0500
commit4e9f9fd5148004b983b29e15de66918e71da56c0 (patch)
tree0299b61dd1cce80d529c3c4abcbc51159ae79369 /include/asm-arm/arch-ep93xx/gpio.h
parent9b73e76f3cf63379dcf45fcd4f112f5812418d0a (diff)
[ARM] 4668/1: ep93xx: implement new GPIO API
Implement new GPIO API for ep93xx platform as defined in Documentation/gpio.txt and provide transitional __deprecated wrappers for the previous gpio_line_* functions. Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org> Acked-by: Lennert Buytenhek <buytenh@wantstofly.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'include/asm-arm/arch-ep93xx/gpio.h')
-rw-r--r--include/asm-arm/arch-ep93xx/gpio.h76
1 files changed, 66 insertions, 10 deletions
diff --git a/include/asm-arm/arch-ep93xx/gpio.h b/include/asm-arm/arch-ep93xx/gpio.h
index 1ee14a14cba0..fc1e57db5fac 100644
--- a/include/asm-arm/arch-ep93xx/gpio.h
+++ b/include/asm-arm/arch-ep93xx/gpio.h
@@ -5,16 +5,6 @@
5#ifndef __ASM_ARCH_GPIO_H 5#ifndef __ASM_ARCH_GPIO_H
6#define __ASM_ARCH_GPIO_H 6#define __ASM_ARCH_GPIO_H
7 7
8#define GPIO_IN 0
9#define GPIO_OUT 1
10
11#define EP93XX_GPIO_LOW 0
12#define EP93XX_GPIO_HIGH 1
13
14extern void gpio_line_config(int line, int direction);
15extern int gpio_line_get(int line);
16extern void gpio_line_set(int line, int value);
17
18/* GPIO port A. */ 8/* GPIO port A. */
19#define EP93XX_GPIO_LINE_A(x) ((x) + 0) 9#define EP93XX_GPIO_LINE_A(x) ((x) + 0)
20#define EP93XX_GPIO_LINE_EGPIO0 EP93XX_GPIO_LINE_A(0) 10#define EP93XX_GPIO_LINE_EGPIO0 EP93XX_GPIO_LINE_A(0)
@@ -103,5 +93,71 @@ extern void gpio_line_set(int line, int value);
103#define EP93XX_GPIO_LINE_DD6 EP93XX_GPIO_LINE_H(6) 93#define EP93XX_GPIO_LINE_DD6 EP93XX_GPIO_LINE_H(6)
104#define EP93XX_GPIO_LINE_DD7 EP93XX_GPIO_LINE_H(7) 94#define EP93XX_GPIO_LINE_DD7 EP93XX_GPIO_LINE_H(7)
105 95
96/* new generic GPIO API - see Documentation/gpio.txt */
97
98static inline int gpio_request(unsigned gpio, const char *label)
99{
100 if (gpio > EP93XX_GPIO_LINE_H(7))
101 return -EINVAL;
102 return 0;
103}
104
105static inline void gpio_free(unsigned gpio)
106{
107}
108
109int gpio_direction_input(unsigned gpio);
110int gpio_direction_output(unsigned gpio, int value);
111int gpio_get_value(unsigned gpio);
112void gpio_set_value(unsigned gpio, int value);
113
114#include <asm-generic/gpio.h> /* cansleep wrappers */
115
116/*
117 * Map GPIO A0..A7 (0..7) to irq 64..71,
118 * B0..B7 (7..15) to irq 72..79, and
119 * F0..F7 (40..47) to irq 80..87.
120 */
121
122static inline int gpio_to_irq(unsigned gpio)
123{
124 if (gpio <= EP93XX_GPIO_LINE_EGPIO15)
125 return 64 + gpio;
126
127 if (gpio >= EP93XX_GPIO_LINE_F(0) && gpio <= EP93XX_GPIO_LINE_F(7))
128 return 80 + (gpio - EP93XX_GPIO_LINE_F(0));
129
130 return -EINVAL;
131}
132
133static inline int irq_to_gpio(unsigned irq)
134{
135 if (irq >= 64 && irq <= 79)
136 return irq - 64;
137
138 if (irq >= 80 && irq <= 87)
139 return (irq - 80) + EP93XX_GPIO_LINE_F(0);
140
141 return -EINVAL;
142}
143
144/* obsolete specific GPIO API */
145#define GPIO_IN 0
146#define GPIO_OUT 1
147
148#define EP93XX_GPIO_LOW 0
149#define EP93XX_GPIO_HIGH 1
150
151void __deprecated gpio_line_config(int line, int direction);
152
153static inline int __deprecated gpio_line_get(int line)
154{
155 return gpio_get_value(line);
156}
157
158static inline void __deprecated gpio_line_set(int line, int value)
159{
160 gpio_set_value(line, value);
161}
106 162
107#endif 163#endif