blob: a79102ba54d7f01a633e5e0e14a0cc88db9dc509 [file] [log] [blame]
Dieter Kiermaierec164412009-06-29 14:45:08 +02001/*
2 * arch/asm-arm/mach-kirkwood/include/mach/gpio.h
3 *
4 * This file is licensed under the terms of the GNU General Public
5 * License version 2. This program is licensed "as is" without any
6 * warranty of any kind, whether express or implied.
7 */
8
9/*
10 * Based on (mostly copied from) plat-orion based Linux 2.6 kernel driver.
11 * Removed kernel level irq handling. Took some macros from kernel to
12 * allow build.
13 *
14 * Dieter Kiermaier dk-arm-linux@gmx.de
15 */
16
17#ifndef __KIRKWOOD_GPIO_H
18#define __KIRKWOOD_GPIO_H
19
20/* got from kernel include/linux/kernel.h */
21#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
22/* got from kernel include/linux/bitops.h */
23#define BITS_PER_BYTE 8
24#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
25
26#define GPIO_MAX 50
27#define GPIO_OFF(pin) (((pin) >> 5) ? 0x0040 : 0x0000)
28#define GPIO_OUT(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x00)
29#define GPIO_IO_CONF(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x04)
30#define GPIO_BLINK_EN(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x08)
31#define GPIO_IN_POL(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x0c)
32#define GPIO_DATA_IN(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x10)
33#define GPIO_EDGE_CAUSE(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x14)
34#define GPIO_EDGE_MASK(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x18)
35#define GPIO_LEVEL_MASK(pin) (KW_GPIO0_BASE + GPIO_OFF(pin) + 0x1c)
36
37/*
38 * Kirkwood-specific GPIO API
39 */
Heiko Schocher57215cd2009-07-16 09:58:31 +020040
41void kw_gpio_set_valid(unsigned pin, int mode);
Dieter Kiermaierec164412009-06-29 14:45:08 +020042int kw_gpio_is_valid(unsigned pin, int mode);
43int kw_gpio_direction_input(unsigned pin);
44int kw_gpio_direction_output(unsigned pin, int value);
45int kw_gpio_get_value(unsigned pin);
46void kw_gpio_set_value(unsigned pin, int value);
47void kw_gpio_set_blink(unsigned pin, int blink);
48void kw_gpio_set_unused(unsigned pin);
49
50#define GPIO_INPUT_OK (1 << 0)
51#define GPIO_OUTPUT_OK (1 << 1)
52
53#endif