blob: 9bba993c61db08f9d9ef567ae659a149078d0646 [file] [log] [blame]
Haojian Zhuang70f2bd02016-01-27 13:18:21 +08001/*
Jona Stubbe2860fe02020-12-22 13:06:10 +01002 * Copyright (c) 2016-2021, 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
Jona Stubbe2860fe02020-12-22 13:06:10 +010021#define GPIO_PULL_REPEATER ARM_TF_GPIO_PULL_REPEATER
Caesar Wang8abdf1c2016-05-25 18:48:45 +080022
Haojian Zhuang70f2bd02016-01-27 13:18:21 +080023typedef 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 Wang8abdf1c2016-05-25 18:48:45 +080028 void (*set_pull)(int gpio, int pull);
29 int (*get_pull)(int gpio);
Haojian Zhuang70f2bd02016-01-27 13:18:21 +080030} gpio_ops_t;
31
32int gpio_get_direction(int gpio);
33void gpio_set_direction(int gpio, int direction);
34int gpio_get_value(int gpio);
35void gpio_set_value(int gpio, int value);
Caesar Wang8abdf1c2016-05-25 18:48:45 +080036void gpio_set_pull(int gpio, int pull);
37int gpio_get_pull(int gpio);
Haojian Zhuang70f2bd02016-01-27 13:18:21 +080038void gpio_init(const gpio_ops_t *ops);
39
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000040#endif /* GPIO_H */