diff options
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-ep93xx/core.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c index f831f74dc8cc..7d3e79990fad 100644 --- a/arch/arm/mach-ep93xx/core.c +++ b/arch/arm/mach-ep93xx/core.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <asm/mach/map.h> | 45 | #include <asm/mach/map.h> |
46 | #include <asm/mach/time.h> | 46 | #include <asm/mach/time.h> |
47 | #include <asm/mach/irq.h> | 47 | #include <asm/mach/irq.h> |
48 | #include <asm/arch/gpio.h> | ||
48 | 49 | ||
49 | #include <asm/hardware/vic.h> | 50 | #include <asm/hardware/vic.h> |
50 | 51 | ||
@@ -147,6 +148,73 @@ struct sys_timer ep93xx_timer = { | |||
147 | 148 | ||
148 | 149 | ||
149 | /************************************************************************* | 150 | /************************************************************************* |
151 | * GPIO handling for EP93xx | ||
152 | *************************************************************************/ | ||
153 | static unsigned char data_register_offset[8] = { | ||
154 | 0x00, 0x04, 0x08, 0x0c, 0x20, 0x30, 0x38, 0x40, | ||
155 | }; | ||
156 | |||
157 | static unsigned char data_direction_register_offset[8] = { | ||
158 | 0x10, 0x14, 0x18, 0x1c, 0x24, 0x34, 0x3c, 0x44, | ||
159 | }; | ||
160 | |||
161 | void gpio_line_config(int line, int direction) | ||
162 | { | ||
163 | unsigned int data_direction_register; | ||
164 | unsigned long flags; | ||
165 | unsigned char v; | ||
166 | |||
167 | data_direction_register = | ||
168 | EP93XX_GPIO_REG(data_direction_register_offset[line >> 3]); | ||
169 | |||
170 | local_irq_save(flags); | ||
171 | if (direction == GPIO_OUT) { | ||
172 | v = __raw_readb(data_direction_register); | ||
173 | v |= 1 << (line & 7); | ||
174 | __raw_writeb(v, data_direction_register); | ||
175 | } else if (direction == GPIO_IN) { | ||
176 | v = __raw_readb(data_direction_register); | ||
177 | v &= ~(1 << (line & 7)); | ||
178 | __raw_writeb(v, data_direction_register); | ||
179 | } | ||
180 | local_irq_restore(flags); | ||
181 | } | ||
182 | EXPORT_SYMBOL(gpio_line_config); | ||
183 | |||
184 | int gpio_line_get(int line) | ||
185 | { | ||
186 | unsigned int data_register; | ||
187 | |||
188 | data_register = EP93XX_GPIO_REG(data_register_offset[line >> 3]); | ||
189 | |||
190 | return !!(__raw_readb(data_register) & (1 << (line & 7))); | ||
191 | } | ||
192 | EXPORT_SYMBOL(gpio_line_get); | ||
193 | |||
194 | void gpio_line_set(int line, int value) | ||
195 | { | ||
196 | unsigned int data_register; | ||
197 | unsigned long flags; | ||
198 | unsigned char v; | ||
199 | |||
200 | data_register = EP93XX_GPIO_REG(data_register_offset[line >> 3]); | ||
201 | |||
202 | local_irq_save(flags); | ||
203 | if (value == EP93XX_GPIO_HIGH) { | ||
204 | v = __raw_readb(data_register); | ||
205 | v |= 1 << (line & 7); | ||
206 | __raw_writeb(v, data_register); | ||
207 | } else if (value == EP93XX_GPIO_LOW) { | ||
208 | v = __raw_readb(data_register); | ||
209 | v &= ~(1 << (line & 7)); | ||
210 | __raw_writeb(v, data_register); | ||
211 | } | ||
212 | local_irq_restore(flags); | ||
213 | } | ||
214 | EXPORT_SYMBOL(gpio_line_set); | ||
215 | |||
216 | |||
217 | /************************************************************************* | ||
150 | * EP93xx IRQ handling | 218 | * EP93xx IRQ handling |
151 | *************************************************************************/ | 219 | *************************************************************************/ |
152 | void __init ep93xx_init_irq(void) | 220 | void __init ep93xx_init_irq(void) |