blob: 5722051f502749ea0f49b42719e777a12455b6e6 [file] [log] [blame]
Haojian Zhuang70f2bd02016-01-27 13:18:21 +08001/*
2 * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Haojian Zhuang70f2bd02016-01-27 13:18:21 +08005 */
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 Wang8abdf1c2016-05-25 18:48:45 +080016#define GPIO_PULL_NONE 0
17#define GPIO_PULL_UP 1
18#define GPIO_PULL_DOWN 2
19
Haojian Zhuang70f2bd02016-01-27 13:18:21 +080020typedef 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 Wang8abdf1c2016-05-25 18:48:45 +080025 void (*set_pull)(int gpio, int pull);
26 int (*get_pull)(int gpio);
Haojian Zhuang70f2bd02016-01-27 13:18:21 +080027} gpio_ops_t;
28
29int gpio_get_direction(int gpio);
30void gpio_set_direction(int gpio, int direction);
31int gpio_get_value(int gpio);
32void gpio_set_value(int gpio, int value);
Caesar Wang8abdf1c2016-05-25 18:48:45 +080033void gpio_set_pull(int gpio, int pull);
34int gpio_get_pull(int gpio);
Haojian Zhuang70f2bd02016-01-27 13:18:21 +080035void gpio_init(const gpio_ops_t *ops);
36
37#endif /* __GPIO_H__ */