blob: 99c18a4bb58b6f42dbace2b4b4b45e0bcf33b48d [file] [log] [blame]
Haojian Zhuang70f2bd02016-01-27 13:18:21 +08001/*
Julius Werner2a231e32019-05-28 21:03:58 -07002 * Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
Haojian Zhuang70f2bd02016-01-27 13:18:21 +08003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Haojian Zhuang70f2bd02016-01-27 13:18:21 +08005 */
6
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +00007#ifndef GPIO_H
8#define GPIO_H
Haojian Zhuang70f2bd02016-01-27 13:18:21 +08009
Julius Werner2a231e32019-05-28 21:03:58 -070010#include <export/drivers/gpio_exp.h>
Haojian Zhuang70f2bd02016-01-27 13:18:21 +080011
Julius Werner2a231e32019-05-28 21:03:58 -070012#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 Zhuang70f2bd02016-01-27 13:18:21 +080017
Julius Werner2a231e32019-05-28 21:03:58 -070018#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
Caesar Wang8abdf1c2016-05-25 18:48:45 +080021
Haojian Zhuang70f2bd02016-01-27 13:18:21 +080022typedef struct gpio_ops {
23 int (*get_direction)(int gpio);
24 void (*set_direction)(int gpio, int direction);
25 int (*get_value)(int gpio);
26 void (*set_value)(int gpio, int value);
Caesar Wang8abdf1c2016-05-25 18:48:45 +080027 void (*set_pull)(int gpio, int pull);
28 int (*get_pull)(int gpio);
Haojian Zhuang70f2bd02016-01-27 13:18:21 +080029} gpio_ops_t;
30
31int gpio_get_direction(int gpio);
32void gpio_set_direction(int gpio, int direction);
33int gpio_get_value(int gpio);
34void gpio_set_value(int gpio, int value);
Caesar Wang8abdf1c2016-05-25 18:48:45 +080035void gpio_set_pull(int gpio, int pull);
36int gpio_get_pull(int gpio);
Haojian Zhuang70f2bd02016-01-27 13:18:21 +080037void gpio_init(const gpio_ops_t *ops);
38
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000039#endif /* GPIO_H */