2 * arch/asm-arm/mach-kirkwood/include/mach/gpio.h
4 * See file CREDITS for list of people who contributed to this
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.
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.
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,
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
28 * Dieter Kiermaier dk-arm-linux@gmx.de
31 #ifndef __KIRKWOOD_GPIO_H
32 #define __KIRKWOOD_GPIO_H
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))
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)
50 * Kirkwood-specific GPIO API
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);
62 #define GPIO_INPUT_OK (1 << 0)
63 #define GPIO_OUTPUT_OK (1 << 1)