Haojian Zhuang | 70f2bd0 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 1 | /* |
Jona Stubbe | 2860fe0 | 2020-12-22 13:06:10 +0100 | [diff] [blame] | 2 | * Copyright (c) 2016-2021, ARM Limited and Contributors. All rights reserved. |
Haojian Zhuang | 70f2bd0 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Haojian Zhuang | 70f2bd0 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 7 | #ifndef GPIO_H |
| 8 | #define GPIO_H |
Haojian Zhuang | 70f2bd0 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 9 | |
Julius Werner | 2a231e3 | 2019-05-28 21:03:58 -0700 | [diff] [blame] | 10 | #include <export/drivers/gpio_exp.h> |
Haojian Zhuang | 70f2bd0 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 11 | |
Julius Werner | 2a231e3 | 2019-05-28 21:03:58 -0700 | [diff] [blame] | 12 | #define GPIO_DIR_OUT ARM_TF_GPIO_DIR_OUT |
| 13 | #define GPIO_DIR_IN ARM_TF_GPIO_DIR_IN |
| 14 | |
| 15 | #define GPIO_LEVEL_LOW ARM_TF_GPIO_LEVEL_LOW |
| 16 | #define GPIO_LEVEL_HIGH ARM_TF_GPIO_LEVEL_HIGH |
Haojian Zhuang | 70f2bd0 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 17 | |
Julius Werner | 2a231e3 | 2019-05-28 21:03:58 -0700 | [diff] [blame] | 18 | #define GPIO_PULL_NONE ARM_TF_GPIO_PULL_NONE |
| 19 | #define GPIO_PULL_UP ARM_TF_GPIO_PULL_UP |
| 20 | #define GPIO_PULL_DOWN ARM_TF_GPIO_PULL_DOWN |
Jona Stubbe | 2860fe0 | 2020-12-22 13:06:10 +0100 | [diff] [blame] | 21 | #define GPIO_PULL_REPEATER ARM_TF_GPIO_PULL_REPEATER |
Caesar Wang | 8abdf1c | 2016-05-25 18:48:45 +0800 | [diff] [blame] | 22 | |
Haojian Zhuang | 70f2bd0 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 23 | typedef struct gpio_ops { |
| 24 | int (*get_direction)(int gpio); |
| 25 | void (*set_direction)(int gpio, int direction); |
| 26 | int (*get_value)(int gpio); |
| 27 | void (*set_value)(int gpio, int value); |
Caesar Wang | 8abdf1c | 2016-05-25 18:48:45 +0800 | [diff] [blame] | 28 | void (*set_pull)(int gpio, int pull); |
| 29 | int (*get_pull)(int gpio); |
Haojian Zhuang | 70f2bd0 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 30 | } gpio_ops_t; |
| 31 | |
| 32 | int gpio_get_direction(int gpio); |
| 33 | void gpio_set_direction(int gpio, int direction); |
| 34 | int gpio_get_value(int gpio); |
| 35 | void gpio_set_value(int gpio, int value); |
Caesar Wang | 8abdf1c | 2016-05-25 18:48:45 +0800 | [diff] [blame] | 36 | void gpio_set_pull(int gpio, int pull); |
| 37 | int gpio_get_pull(int gpio); |
Haojian Zhuang | 70f2bd0 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 38 | void gpio_init(const gpio_ops_t *ops); |
| 39 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 40 | #endif /* GPIO_H */ |