Haojian Zhuang | 70f2bd0 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. |
| 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 | |
| 7 | #ifndef __GPIO_H__ |
| 8 | #define __GPIO_H__ |
| 9 | |
| 10 | #define GPIO_DIR_OUT 0 |
| 11 | #define GPIO_DIR_IN 1 |
| 12 | |
| 13 | #define GPIO_LEVEL_LOW 0 |
| 14 | #define GPIO_LEVEL_HIGH 1 |
| 15 | |
Caesar Wang | 8abdf1c | 2016-05-25 18:48:45 +0800 | [diff] [blame] | 16 | #define GPIO_PULL_NONE 0 |
| 17 | #define GPIO_PULL_UP 1 |
| 18 | #define GPIO_PULL_DOWN 2 |
| 19 | |
Haojian Zhuang | 70f2bd0 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 20 | typedef struct gpio_ops { |
| 21 | int (*get_direction)(int gpio); |
| 22 | void (*set_direction)(int gpio, int direction); |
| 23 | int (*get_value)(int gpio); |
| 24 | void (*set_value)(int gpio, int value); |
Caesar Wang | 8abdf1c | 2016-05-25 18:48:45 +0800 | [diff] [blame] | 25 | void (*set_pull)(int gpio, int pull); |
| 26 | int (*get_pull)(int gpio); |
Haojian Zhuang | 70f2bd0 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 27 | } gpio_ops_t; |
| 28 | |
| 29 | int gpio_get_direction(int gpio); |
| 30 | void gpio_set_direction(int gpio, int direction); |
| 31 | int gpio_get_value(int gpio); |
| 32 | void gpio_set_value(int gpio, int value); |
Caesar Wang | 8abdf1c | 2016-05-25 18:48:45 +0800 | [diff] [blame] | 33 | void gpio_set_pull(int gpio, int pull); |
| 34 | int gpio_get_pull(int gpio); |
Haojian Zhuang | 70f2bd0 | 2016-01-27 13:18:21 +0800 | [diff] [blame] | 35 | void gpio_init(const gpio_ops_t *ops); |
| 36 | |
| 37 | #endif /* __GPIO_H__ */ |