blob: cae7d55d7290f471a5bb606fc61ae0cf35120aad [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Dieter Kiermaiere740eb82009-06-29 14:45:08 +02002/*
3 * arch/asm-arm/mach-kirkwood/include/mach/gpio.h
Dieter Kiermaiere740eb82009-06-29 14:45:08 +02004 */
5
6/*
7 * Based on (mostly copied from) plat-orion based Linux 2.6 kernel driver.
8 * Removed kernel level irq handling. Took some macros from kernel to
9 * allow build.
10 *
11 * Dieter Kiermaier dk-arm-linux@gmx.de
12 */
13
14#ifndef __KIRKWOOD_GPIO_H
15#define __KIRKWOOD_GPIO_H
16
Dieter Kiermaiere740eb82009-06-29 14:45:08 +020017#define GPIO_MAX 50
18#define GPIO_OFF(pin) (((pin) >> 5) ? 0x0040 : 0x0000)
Stefan Roesec50ab392014-10-22 12:13:11 +020019#define GPIO_OUT(pin) (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x00)
20#define GPIO_IO_CONF(pin) (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x04)
21#define GPIO_BLINK_EN(pin) (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x08)
22#define GPIO_IN_POL(pin) (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x0c)
23#define GPIO_DATA_IN(pin) (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x10)
24#define GPIO_EDGE_CAUSE(pin) (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x14)
25#define GPIO_EDGE_MASK(pin) (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x18)
26#define GPIO_LEVEL_MASK(pin) (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x1c)
Dieter Kiermaiere740eb82009-06-29 14:45:08 +020027
28/*
29 * Kirkwood-specific GPIO API
30 */
Heiko Schocherf70f3422009-07-16 09:58:31 +020031
32void kw_gpio_set_valid(unsigned pin, int mode);
Dieter Kiermaiere740eb82009-06-29 14:45:08 +020033int kw_gpio_is_valid(unsigned pin, int mode);
34int kw_gpio_direction_input(unsigned pin);
35int kw_gpio_direction_output(unsigned pin, int value);
36int kw_gpio_get_value(unsigned pin);
37void kw_gpio_set_value(unsigned pin, int value);
38void kw_gpio_set_blink(unsigned pin, int blink);
39void kw_gpio_set_unused(unsigned pin);
40
41#define GPIO_INPUT_OK (1 << 0)
42#define GPIO_OUTPUT_OK (1 << 1)
43
44#endif