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.
5 * Copyright (c) 2011 The Chromium OS Authors.
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 #ifndef __ASM_SANDBOX_GPIO_H
26 #define __ASM_SANDBOX_GPIO_H
29 * We use the generic interface, and add a back-channel.
31 * The back-channel functions are declared in this file. They should not be used
32 * except in test code.
34 * Test code can, for example, call sandbox_gpio_set_value() to set the value of
35 * a simulated GPIO. From then on, normal code in U-Boot will see this new
36 * value when it calls gpio_get_value().
38 * NOTE: DO NOT use the functions in this file except in test code!
40 #include <asm-generic/gpio.h>
43 * Return the simulated value of a GPIO (used only in sandbox test code)
45 * @param gp GPIO number
46 * @return -1 on error, 0 if GPIO is low, >0 if high
48 int sandbox_gpio_get_value(unsigned gp);
51 * Set the simulated value of a GPIO (used only in sandbox test code)
53 * @param gp GPIO number
54 * @param value value to set (0 for low, non-zero for high)
55 * @return -1 on error, 0 if ok
57 int sandbox_gpio_set_value(unsigned gp, int value);
60 * Return the simulated direction of a GPIO (used only in sandbox test code)
62 * @param gp GPIO number
63 * @return -1 on error, 0 if GPIO is input, >0 if output
65 int sandbox_gpio_get_direction(unsigned gp);
68 * Set the simulated direction of a GPIO (used only in sandbox test code)
70 * @param gp GPIO number
71 * @param output 0 to set as input, 1 to set as output
72 * @return -1 on error, 0 if ok
74 int sandbox_gpio_set_direction(unsigned gp, int output);
76 /* Display information about each GPIO */
79 #define gpio_status() gpio_info()