aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-ep93xx
diff options
context:
space:
mode:
authorLennert Buytenhek <buytenh@wantstofly.org>2006-03-20 12:10:14 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2006-03-21 17:06:12 -0500
commita8e19667a42d752f3eca6eaa17aa5d6f93066dfe (patch)
tree7bf3b7eb8ac3fb6c18b3a8c33a88d6d2158f45e4 /arch/arm/mach-ep93xx
parente7736d47a11a771ba87314be563b2cb6b8d11d14 (diff)
[ARM] 3371/1: ep93xx: gpio support
Patch from Lennert Buytenhek Add support for setting the direction of and getting/setting the value of the 64 GPIO lines. Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-ep93xx')
-rw-r--r--arch/arm/mach-ep93xx/core.c68
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 *************************************************************************/
153static unsigned char data_register_offset[8] = {
154 0x00, 0x04, 0x08, 0x0c, 0x20, 0x30, 0x38, 0x40,
155};
156
157static unsigned char data_direction_register_offset[8] = {
158 0x10, 0x14, 0x18, 0x1c, 0x24, 0x34, 0x3c, 0x44,
159};
160
161void 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}
182EXPORT_SYMBOL(gpio_line_config);
183
184int 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}
192EXPORT_SYMBOL(gpio_line_get);
193
194void 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}
214EXPORT_SYMBOL(gpio_line_set);
215
216
217/*************************************************************************
150 * EP93xx IRQ handling 218 * EP93xx IRQ handling
151 *************************************************************************/ 219 *************************************************************************/
152void __init ep93xx_init_irq(void) 220void __init ep93xx_init_irq(void)