Dieter Kiermaier | ec16441 | 2009-06-29 14:45:08 +0200 | [diff] [blame] | 1 | /* |
| 2 | * arch/asm-arm/mach-kirkwood/include/mach/gpio.h |
| 3 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Dieter Kiermaier | ec16441 | 2009-06-29 14:45:08 +0200 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | /* |
| 8 | * Based on (mostly copied from) plat-orion based Linux 2.6 kernel driver. |
| 9 | * Removed kernel level irq handling. Took some macros from kernel to |
| 10 | * allow build. |
| 11 | * |
| 12 | * Dieter Kiermaier dk-arm-linux@gmx.de |
| 13 | */ |
| 14 | |
| 15 | #ifndef __KIRKWOOD_GPIO_H |
| 16 | #define __KIRKWOOD_GPIO_H |
| 17 | |
Dieter Kiermaier | ec16441 | 2009-06-29 14:45:08 +0200 | [diff] [blame] | 18 | /* got from kernel include/linux/bitops.h */ |
| 19 | #define BITS_PER_BYTE 8 |
| 20 | #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) |
| 21 | |
| 22 | #define GPIO_MAX 50 |
| 23 | #define GPIO_OFF(pin) (((pin) >> 5) ? 0x0040 : 0x0000) |
Stefan Roese | d5c5132 | 2014-10-22 12:13:11 +0200 | [diff] [blame] | 24 | #define GPIO_OUT(pin) (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x00) |
| 25 | #define GPIO_IO_CONF(pin) (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x04) |
| 26 | #define GPIO_BLINK_EN(pin) (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x08) |
| 27 | #define GPIO_IN_POL(pin) (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x0c) |
| 28 | #define GPIO_DATA_IN(pin) (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x10) |
| 29 | #define GPIO_EDGE_CAUSE(pin) (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x14) |
| 30 | #define GPIO_EDGE_MASK(pin) (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x18) |
| 31 | #define GPIO_LEVEL_MASK(pin) (MVEBU_GPIO0_BASE + GPIO_OFF(pin) + 0x1c) |
Dieter Kiermaier | ec16441 | 2009-06-29 14:45:08 +0200 | [diff] [blame] | 32 | |
| 33 | /* |
| 34 | * Kirkwood-specific GPIO API |
| 35 | */ |
Heiko Schocher | 57215cd | 2009-07-16 09:58:31 +0200 | [diff] [blame] | 36 | |
| 37 | void kw_gpio_set_valid(unsigned pin, int mode); |
Dieter Kiermaier | ec16441 | 2009-06-29 14:45:08 +0200 | [diff] [blame] | 38 | int kw_gpio_is_valid(unsigned pin, int mode); |
| 39 | int kw_gpio_direction_input(unsigned pin); |
| 40 | int kw_gpio_direction_output(unsigned pin, int value); |
| 41 | int kw_gpio_get_value(unsigned pin); |
| 42 | void kw_gpio_set_value(unsigned pin, int value); |
| 43 | void kw_gpio_set_blink(unsigned pin, int blink); |
| 44 | void kw_gpio_set_unused(unsigned pin); |
| 45 | |
| 46 | #define GPIO_INPUT_OK (1 << 0) |
| 47 | #define GPIO_OUTPUT_OK (1 << 1) |
| 48 | |
| 49 | #endif |