gpio.h 1.03 KB
Newer Older
Haojian Zhuang's avatar
Haojian Zhuang committed
1
/*
2
 * Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
Haojian Zhuang's avatar
Haojian Zhuang committed
3
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
Haojian Zhuang's avatar
Haojian Zhuang committed
5
6
 */

7
8
#ifndef GPIO_H
#define GPIO_H
Haojian Zhuang's avatar
Haojian Zhuang committed
9

10
#include <export/drivers/gpio_exp.h>
Haojian Zhuang's avatar
Haojian Zhuang committed
11

12
13
#define GPIO_DIR_OUT		ARM_TF_GPIO_DIR_OUT
#define GPIO_DIR_IN		ARM_TF_GPIO_DIR_IN
Haojian Zhuang's avatar
Haojian Zhuang committed
14

15
16
17
18
19
20
#define GPIO_LEVEL_LOW		ARM_TF_GPIO_LEVEL_LOW
#define GPIO_LEVEL_HIGH		ARM_TF_GPIO_LEVEL_HIGH

#define GPIO_PULL_NONE		ARM_TF_GPIO_PULL_NONE
#define GPIO_PULL_UP		ARM_TF_GPIO_PULL_UP
#define GPIO_PULL_DOWN		ARM_TF_GPIO_PULL_DOWN
21

Haojian Zhuang's avatar
Haojian Zhuang committed
22
23
24
25
26
typedef struct gpio_ops {
	int (*get_direction)(int gpio);
	void (*set_direction)(int gpio, int direction);
	int (*get_value)(int gpio);
	void (*set_value)(int gpio, int value);
27
28
	void (*set_pull)(int gpio, int pull);
	int (*get_pull)(int gpio);
Haojian Zhuang's avatar
Haojian Zhuang committed
29
30
31
32
33
34
} gpio_ops_t;

int gpio_get_direction(int gpio);
void gpio_set_direction(int gpio, int direction);
int gpio_get_value(int gpio);
void gpio_set_value(int gpio, int value);
35
36
void gpio_set_pull(int gpio, int pull);
int gpio_get_pull(int gpio);
Haojian Zhuang's avatar
Haojian Zhuang committed
37
38
void gpio_init(const gpio_ops_t *ops);

39
#endif /* GPIO_H */