blob: cd1bc008ee32e94d575a0815af4b12c1959f3ef4 [file] [log] [blame]
Dieter Kiermaiere740eb82009-06-29 14:45:08 +02001/*
2 * arch/asm-arm/mach-kirkwood/include/mach/gpio.h
3 *
Prafulla Wadaskar43fa12f2009-12-24 02:55:23 +05304 * 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
Dieter Kiermaiere740eb82009-06-29 14:45:08 +020021 */
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
Dieter Kiermaiere740eb82009-06-29 14:45:08 +020034/* 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 */
Heiko Schocherf70f3422009-07-16 09:58:31 +020052
53void kw_gpio_set_valid(unsigned pin, int mode);
Dieter Kiermaiere740eb82009-06-29 14:45:08 +020054int kw_gpio_is_valid(unsigned pin, int mode);
55int kw_gpio_direction_input(unsigned pin);
56int kw_gpio_direction_output(unsigned pin, int value);
57int kw_gpio_get_value(unsigned pin);
58void kw_gpio_set_value(unsigned pin, int value);
59void kw_gpio_set_blink(unsigned pin, int blink);
60void kw_gpio_set_unused(unsigned pin);
61
62#define GPIO_INPUT_OK (1 << 0)
63#define GPIO_OUTPUT_OK (1 << 1)
64
65#endif