blob: 8317db1ad3d896a5f7ddefea6b9dd8dfe2a4dae3 [file] [log] [blame]
Googlere00b8eb2019-07-08 16:37:07 -07001/*
2 * This is the interface to the sandbox GPIO driver for test code which
3 * wants to change the GPIO values reported to U-Boot.
4 *
5 * Copyright (c) 2011 The Chromium OS Authors.
Googlerbd67ccb2023-03-14 15:50:59 +08006 * SPDX-License-Identifier: GPL-2.0+
Googlere00b8eb2019-07-08 16:37:07 -07007 */
8
9#ifndef __ASM_SANDBOX_GPIO_H
10#define __ASM_SANDBOX_GPIO_H
11
12/*
13 * We use the generic interface, and add a back-channel.
14 *
15 * The back-channel functions are declared in this file. They should not be used
16 * except in test code.
17 *
18 * Test code can, for example, call sandbox_gpio_set_value() to set the value of
19 * a simulated GPIO. From then on, normal code in U-Boot will see this new
20 * value when it calls gpio_get_value().
21 *
22 * NOTE: DO NOT use the functions in this file except in test code!
23 */
24#include <asm-generic/gpio.h>
25
26/**
27 * Return the simulated value of a GPIO (used only in sandbox test code)
28 *
Googlerbd67ccb2023-03-14 15:50:59 +080029 * @param gp GPIO number
Googlere00b8eb2019-07-08 16:37:07 -070030 * @return -1 on error, 0 if GPIO is low, >0 if high
31 */
32int sandbox_gpio_get_value(struct udevice *dev, unsigned int offset);
33
34/**
35 * Set the simulated value of a GPIO (used only in sandbox test code)
36 *
Googlerbd67ccb2023-03-14 15:50:59 +080037 * @param gp GPIO number
38 * @param value value to set (0 for low, non-zero for high)
Googlere00b8eb2019-07-08 16:37:07 -070039 * @return -1 on error, 0 if ok
40 */
41int sandbox_gpio_set_value(struct udevice *dev, unsigned int offset, int value);
42
43/**
Googler0bcd2362023-05-09 16:45:27 +080044 * Return the simulated direction of a GPIO (used only in sandbox test code)
45 *
Googlerbd67ccb2023-03-14 15:50:59 +080046 * @param gp GPIO number
Googlere00b8eb2019-07-08 16:37:07 -070047 * @return -1 on error, 0 if GPIO is input, >0 if output
48 */
49int sandbox_gpio_get_direction(struct udevice *dev, unsigned int offset);
50
51/**
52 * Set the simulated direction of a GPIO (used only in sandbox test code)
53 *
Googlerbd67ccb2023-03-14 15:50:59 +080054 * @param gp GPIO number
55 * @param output 0 to set as input, 1 to set as output
Googlere00b8eb2019-07-08 16:37:07 -070056 * @return -1 on error, 0 if ok
57 */
58int sandbox_gpio_set_direction(struct udevice *dev, unsigned int offset,
59 int output);
60
61#endif