]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - include/asm-arm/arch-kirkwood/gpio.h
cd1bc008ee32e94d575a0815af4b12c1959f3ef4
[karo-tx-uboot.git] / include / asm-arm / arch-kirkwood / gpio.h
1 /*
2  * arch/asm-arm/mach-kirkwood/include/mach/gpio.h
3  *
4  * See file CREDITS for list of people who contributed to this
5  * project.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of
10  * the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20  * MA 02110-1301 USA
21  */
22
23 /*
24  * Based on (mostly copied from) plat-orion based Linux 2.6 kernel driver.
25  * Removed kernel level irq handling. Took some macros from kernel to
26  * allow build.
27  *
28  * Dieter Kiermaier dk-arm-linux@gmx.de
29  */
30
31 #ifndef __KIRKWOOD_GPIO_H
32 #define __KIRKWOOD_GPIO_H
33
34 /* got from kernel include/linux/bitops.h */
35 #define BITS_PER_BYTE 8
36 #define BITS_TO_LONGS(nr)       DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
37
38 #define GPIO_MAX                50
39 #define GPIO_OFF(pin)           (((pin) >> 5) ? 0x0040 : 0x0000)
40 #define GPIO_OUT(pin)           (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x00)
41 #define GPIO_IO_CONF(pin)       (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x04)
42 #define GPIO_BLINK_EN(pin)      (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x08)
43 #define GPIO_IN_POL(pin)        (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x0c)
44 #define GPIO_DATA_IN(pin)       (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x10)
45 #define GPIO_EDGE_CAUSE(pin)    (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x14)
46 #define GPIO_EDGE_MASK(pin)     (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x18)
47 #define GPIO_LEVEL_MASK(pin)    (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x1c)
48
49 /*
50  * Kirkwood-specific GPIO API
51  */
52
53 void kw_gpio_set_valid(unsigned pin, int mode);
54 int kw_gpio_is_valid(unsigned pin, int mode);
55 int kw_gpio_direction_input(unsigned pin);
56 int kw_gpio_direction_output(unsigned pin, int value);
57 int kw_gpio_get_value(unsigned pin);
58 void kw_gpio_set_value(unsigned pin, int value);
59 void kw_gpio_set_blink(unsigned pin, int blink);
60 void kw_gpio_set_unused(unsigned pin);
61
62 #define GPIO_INPUT_OK           (1 << 0)
63 #define GPIO_OUTPUT_OK          (1 << 1)
64
65 #endif