Merge branch 'intelfb-patches' of master.kernel.org:/pub/scm/linux/kernel/git/airlied...
[pandora-kernel.git] / arch / arm / plat-iop / gpio.c
1 /*
2  * arch/arm/plat-iop/gpio.c
3  * GPIO handling for Intel IOP3xx processors.
4  *
5  * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or (at
10  * your option) any later version.
11  */
12
13 #include <linux/device.h>
14 #include <asm/hardware/iop3xx.h>
15
16 void gpio_line_config(int line, int direction)
17 {
18         unsigned long flags;
19
20         local_irq_save(flags);
21         if (direction == GPIO_IN) {
22                 *IOP3XX_GPOE |= 1 << line;
23         } else if (direction == GPIO_OUT) {
24                 *IOP3XX_GPOE &= ~(1 << line);
25         }
26         local_irq_restore(flags);
27 }
28 EXPORT_SYMBOL(gpio_line_config);
29
30 int gpio_line_get(int line)
31 {
32         return !!(*IOP3XX_GPID & (1 << line));
33 }
34 EXPORT_SYMBOL(gpio_line_get);
35
36 void gpio_line_set(int line, int value)
37 {
38         unsigned long flags;
39
40         local_irq_save(flags);
41         if (value == GPIO_LOW) {
42                 *IOP3XX_GPOD &= ~(1 << line);
43         } else if (value == GPIO_HIGH) {
44                 *IOP3XX_GPOD |= 1 << line;
45         }
46         local_irq_restore(flags);
47 }
48 EXPORT_SYMBOL(gpio_line_set);