Ying-Chun Liu (PaulLiu) | 4fb84fb | 2018-12-21 03:32:10 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019, Linaro Limited |
| 3 | * Copyright (c) 2019, Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org> |
| 4 | * |
| 5 | * SPDX-License-Identifier: BSD-3-Clause |
| 6 | */ |
| 7 | |
| 8 | #ifndef RPI3_GPIO_H |
| 9 | #define RPI3_GPIO_H |
| 10 | |
| 11 | #include <stdint.h> |
| 12 | #include <drivers/gpio.h> |
| 13 | |
| 14 | struct rpi3_gpio_params { |
| 15 | uintptr_t reg_base; |
| 16 | }; |
| 17 | |
| 18 | void rpi3_gpio_init(struct rpi3_gpio_params *params); |
| 19 | int rpi3_gpio_get_select(int gpio); |
| 20 | void rpi3_gpio_set_select(int gpio, int fsel); |
| 21 | |
| 22 | #define RPI3_GPIO_GPFSEL(n) ((n) * U(0x04)) |
| 23 | #define RPI3_GPIO_GPSET(n) (((n) * U(0x04)) + U(0x1C)) |
| 24 | #define RPI3_GPIO_GPCLR(n) (((n) * U(0x04)) + U(0x28)) |
| 25 | #define RPI3_GPIO_GPLEV(n) (((n) * U(0x04)) + U(0x34)) |
| 26 | #define RPI3_GPIO_GPPUD U(0x94) |
| 27 | #define RPI3_GPIO_GPPUDCLK(n) (((n) * U(0x04)) + U(0x98)) |
| 28 | |
| 29 | #define RPI3_GPIO_FUNC_INPUT U(0) |
| 30 | #define RPI3_GPIO_FUNC_OUTPUT U(1) |
| 31 | #define RPI3_GPIO_FUNC_ALT0 U(4) |
| 32 | #define RPI3_GPIO_FUNC_ALT1 U(5) |
| 33 | #define RPI3_GPIO_FUNC_ALT2 U(6) |
| 34 | #define RPI3_GPIO_FUNC_ALT3 U(7) |
| 35 | #define RPI3_GPIO_FUNC_ALT4 U(3) |
| 36 | #define RPI3_GPIO_FUNC_ALT5 U(2) |
| 37 | |
| 38 | #endif /* RPI3_GPIO_H */ |