aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-ep93xx/core.c
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 /arch/arm/mach-ep93xx/core.c
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 'arch/arm/mach-ep93xx/core.c')
-rw-r--r--arch/arm/mach-ep93xx/core.c63
1 files changed, 44 insertions, 19 deletions
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index 70b2c7801110..8a7340661377 100644
--- a/arch/arm/mach-ep93xx/core.c
+++ b/arch/arm/mach-ep93xx/core.c
@@ -188,7 +188,7 @@ static unsigned char data_direction_register_offset[8] = {
188 0x10, 0x14, 0x18, 0x1c, 0x24, 0x34, 0x3c, 0x44, 188 0x10, 0x14, 0x18, 0x1c, 0x24, 0x34, 0x3c, 0x44,
189}; 189};
190 190
191void gpio_line_config(int line, int direction) 191static void ep93xx_gpio_set_direction(unsigned line, int direction)
192{ 192{
193 unsigned int data_direction_register; 193 unsigned int data_direction_register;
194 unsigned long flags; 194 unsigned long flags;
@@ -219,39 +219,64 @@ void gpio_line_config(int line, int direction)
219 } 219 }
220 local_irq_restore(flags); 220 local_irq_restore(flags);
221} 221}
222
223void __deprecated gpio_line_config(int line, int direction)
224{
225 ep93xx_gpio_set_direction(line, direction);
226}
222EXPORT_SYMBOL(gpio_line_config); 227EXPORT_SYMBOL(gpio_line_config);
223 228
224int gpio_line_get(int line) 229int gpio_direction_input(unsigned gpio)
230{
231 if (gpio > EP93XX_GPIO_LINE_H(7))
232 return -EINVAL;
233
234 ep93xx_gpio_set_direction(gpio, GPIO_IN);
235
236 return 0;
237}
238EXPORT_SYMBOL(gpio_direction_input);
239
240int gpio_direction_output(unsigned gpio, int value)
241{
242 if (gpio > EP93XX_GPIO_LINE_H(7))
243 return -EINVAL;
244
245 gpio_set_value(gpio, value);
246 ep93xx_gpio_set_direction(gpio, GPIO_OUT);
247
248 return 0;
249}
250EXPORT_SYMBOL(gpio_direction_output);
251
252int gpio_get_value(unsigned gpio)
225{ 253{
226 unsigned int data_register; 254 unsigned int data_register;
227 255
228 data_register = EP93XX_GPIO_REG(data_register_offset[line >> 3]); 256 data_register = EP93XX_GPIO_REG(data_register_offset[gpio >> 3]);
229 257
230 return !!(__raw_readb(data_register) & (1 << (line & 7))); 258 return !!(__raw_readb(data_register) & (1 << (gpio & 7)));
231} 259}
232EXPORT_SYMBOL(gpio_line_get); 260EXPORT_SYMBOL(gpio_get_value);
233 261
234void gpio_line_set(int line, int value) 262void gpio_set_value(unsigned gpio, int value)
235{ 263{
236 unsigned int data_register; 264 unsigned int data_register;
237 unsigned long flags; 265 unsigned long flags;
238 unsigned char v; 266 unsigned char v;
239 267
240 data_register = EP93XX_GPIO_REG(data_register_offset[line >> 3]); 268 data_register = EP93XX_GPIO_REG(data_register_offset[gpio >> 3]);
241 269
242 local_irq_save(flags); 270 local_irq_save(flags);
243 if (value == EP93XX_GPIO_HIGH) { 271 v = __raw_readb(data_register);
244 v = __raw_readb(data_register); 272 if (value)
245 v |= 1 << (line & 7); 273 v |= 1 << (gpio & 7);
246 __raw_writeb(v, data_register); 274 else
247 } else if (value == EP93XX_GPIO_LOW) { 275 v &= ~(1 << (gpio & 7));
248 v = __raw_readb(data_register); 276 __raw_writeb(v, data_register);
249 v &= ~(1 << (line & 7));
250 __raw_writeb(v, data_register);
251 }
252 local_irq_restore(flags); 277 local_irq_restore(flags);
253} 278}
254EXPORT_SYMBOL(gpio_line_set); 279EXPORT_SYMBOL(gpio_set_value);
255 280
256 281
257/************************************************************************* 282/*************************************************************************
@@ -334,9 +359,9 @@ static int ep93xx_gpio_irq_type(unsigned int irq, unsigned int type)
334 359
335 line = irq - IRQ_EP93XX_GPIO(0); 360 line = irq - IRQ_EP93XX_GPIO(0);
336 if (line >= 0 && line < 16) { 361 if (line >= 0 && line < 16) {
337 gpio_line_config(line, GPIO_IN); 362 ep93xx_gpio_set_direction(line, GPIO_IN);
338 } else { 363 } else {
339 gpio_line_config(EP93XX_GPIO_LINE_F(line-16), GPIO_IN); 364 ep93xx_gpio_set_direction(EP93XX_GPIO_LINE_F(line-16), GPIO_IN);
340 } 365 }
341 366
342 port = line >> 3; 367 port = line >> 3;