diff options
author | Antonio Niño Díaz <antonio.ninodiaz@arm.com> | 2019-01-28 12:04:13 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-28 12:04:13 +0000 |
commit | d4dcadb067e0ebdbb633562fd80e03538f3b7214 (patch) | |
tree | 10235820271dee070ea5c7bca1a535664f3b3654 /include | |
parent | 83a2285ec8d5e4bdbf12481b441489eed5bb6018 (diff) | |
parent | 2be86dd3954a5a3bd5111c3861a74c1f8a592884 (diff) |
Merge pull request #1773 from grandpaul/rpi3-gpio-driver
Rpi3 gpio driver
Diffstat (limited to 'include')
-rw-r--r-- | include/drivers/rpi3/gpio/rpi3_gpio.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/include/drivers/rpi3/gpio/rpi3_gpio.h b/include/drivers/rpi3/gpio/rpi3_gpio.h new file mode 100644 index 00000000..159a2e08 --- /dev/null +++ b/include/drivers/rpi3/gpio/rpi3_gpio.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2019, Linaro Limited + * Copyright (c) 2019, Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org> + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef RPI3_GPIO_H +#define RPI3_GPIO_H + +#include <stdint.h> +#include <drivers/gpio.h> + +struct rpi3_gpio_params { + uintptr_t reg_base; +}; + +void rpi3_gpio_init(struct rpi3_gpio_params *params); +int rpi3_gpio_get_select(int gpio); +void rpi3_gpio_set_select(int gpio, int fsel); + +#define RPI3_GPIO_GPFSEL(n) ((n) * U(0x04)) +#define RPI3_GPIO_GPSET(n) (((n) * U(0x04)) + U(0x1C)) +#define RPI3_GPIO_GPCLR(n) (((n) * U(0x04)) + U(0x28)) +#define RPI3_GPIO_GPLEV(n) (((n) * U(0x04)) + U(0x34)) +#define RPI3_GPIO_GPPUD U(0x94) +#define RPI3_GPIO_GPPUDCLK(n) (((n) * U(0x04)) + U(0x98)) + +#define RPI3_GPIO_FUNC_INPUT U(0) +#define RPI3_GPIO_FUNC_OUTPUT U(1) +#define RPI3_GPIO_FUNC_ALT0 U(4) +#define RPI3_GPIO_FUNC_ALT1 U(5) +#define RPI3_GPIO_FUNC_ALT2 U(6) +#define RPI3_GPIO_FUNC_ALT3 U(7) +#define RPI3_GPIO_FUNC_ALT4 U(3) +#define RPI3_GPIO_FUNC_ALT5 U(2) + +#endif /* RPI3_GPIO_H */ |