xref: /openbmc/u-boot/arch/sandbox/include/asm/gpio.h (revision 8d30fcd9)
1*8d30fcd9SSimon Glass /*
2*8d30fcd9SSimon Glass  * This is the interface to the sandbox GPIO driver for test code which
3*8d30fcd9SSimon Glass  * wants to change the GPIO values reported to U-Boot.
4*8d30fcd9SSimon Glass  *
5*8d30fcd9SSimon Glass  * Copyright (c) 2011 The Chromium OS Authors.
6*8d30fcd9SSimon Glass  * See file CREDITS for list of people who contributed to this
7*8d30fcd9SSimon Glass  * project.
8*8d30fcd9SSimon Glass  *
9*8d30fcd9SSimon Glass  * This program is free software; you can redistribute it and/or
10*8d30fcd9SSimon Glass  * modify it under the terms of the GNU General Public License as
11*8d30fcd9SSimon Glass  * published by the Free Software Foundation; either version 2 of
12*8d30fcd9SSimon Glass  * the License, or (at your option) any later version.
13*8d30fcd9SSimon Glass  *
14*8d30fcd9SSimon Glass  * This program is distributed in the hope that it will be useful,
15*8d30fcd9SSimon Glass  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16*8d30fcd9SSimon Glass  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17*8d30fcd9SSimon Glass  * GNU General Public License for more details.
18*8d30fcd9SSimon Glass  *
19*8d30fcd9SSimon Glass  * You should have received a copy of the GNU General Public License
20*8d30fcd9SSimon Glass  * along with this program; if not, write to the Free Software
21*8d30fcd9SSimon Glass  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22*8d30fcd9SSimon Glass  * MA 02111-1307 USA
23*8d30fcd9SSimon Glass  */
24*8d30fcd9SSimon Glass 
25*8d30fcd9SSimon Glass #ifndef __ASM_SANDBOX_GPIO_H
26*8d30fcd9SSimon Glass #define __ASM_SANDBOX_GPIO_H
27*8d30fcd9SSimon Glass 
28*8d30fcd9SSimon Glass /*
29*8d30fcd9SSimon Glass  * We use the generic interface, and add a back-channel.
30*8d30fcd9SSimon Glass  *
31*8d30fcd9SSimon Glass  * The back-channel functions are declared in this file. They should not be used
32*8d30fcd9SSimon Glass  * except in test code.
33*8d30fcd9SSimon Glass  *
34*8d30fcd9SSimon Glass  * Test code can, for example, call sandbox_gpio_set_value() to set the value of
35*8d30fcd9SSimon Glass  * a simulated GPIO. From then on, normal code in U-Boot will see this new
36*8d30fcd9SSimon Glass  * value when it calls gpio_get_value().
37*8d30fcd9SSimon Glass  *
38*8d30fcd9SSimon Glass  * NOTE: DO NOT use the functions in this file except in test code!
39*8d30fcd9SSimon Glass  */
40*8d30fcd9SSimon Glass #include <asm-generic/gpio.h>
41*8d30fcd9SSimon Glass 
42*8d30fcd9SSimon Glass /**
43*8d30fcd9SSimon Glass  * Return the simulated value of a GPIO (used only in sandbox test code)
44*8d30fcd9SSimon Glass  *
45*8d30fcd9SSimon Glass  * @param gp	GPIO number
46*8d30fcd9SSimon Glass  * @return -1 on error, 0 if GPIO is low, >0 if high
47*8d30fcd9SSimon Glass  */
48*8d30fcd9SSimon Glass int sandbox_gpio_get_value(unsigned gp);
49*8d30fcd9SSimon Glass 
50*8d30fcd9SSimon Glass /**
51*8d30fcd9SSimon Glass  * Set the simulated value of a GPIO (used only in sandbox test code)
52*8d30fcd9SSimon Glass  *
53*8d30fcd9SSimon Glass  * @param gp	GPIO number
54*8d30fcd9SSimon Glass  * @param value	value to set (0 for low, non-zero for high)
55*8d30fcd9SSimon Glass  * @return -1 on error, 0 if ok
56*8d30fcd9SSimon Glass  */
57*8d30fcd9SSimon Glass int sandbox_gpio_set_value(unsigned gp, int value);
58*8d30fcd9SSimon Glass 
59*8d30fcd9SSimon Glass /**
60*8d30fcd9SSimon Glass  * Return the simulated direction of a GPIO (used only in sandbox test code)
61*8d30fcd9SSimon Glass  *
62*8d30fcd9SSimon Glass  * @param gp	GPIO number
63*8d30fcd9SSimon Glass  * @return -1 on error, 0 if GPIO is input, >0 if output
64*8d30fcd9SSimon Glass  */
65*8d30fcd9SSimon Glass int sandbox_gpio_get_direction(unsigned gp);
66*8d30fcd9SSimon Glass 
67*8d30fcd9SSimon Glass /**
68*8d30fcd9SSimon Glass  * Set the simulated direction of a GPIO (used only in sandbox test code)
69*8d30fcd9SSimon Glass  *
70*8d30fcd9SSimon Glass  * @param gp	GPIO number
71*8d30fcd9SSimon Glass  * @param output 0 to set as input, 1 to set as output
72*8d30fcd9SSimon Glass  * @return -1 on error, 0 if ok
73*8d30fcd9SSimon Glass  */
74*8d30fcd9SSimon Glass int sandbox_gpio_set_direction(unsigned gp, int output);
75*8d30fcd9SSimon Glass 
76*8d30fcd9SSimon Glass /* Display information about each GPIO */
77*8d30fcd9SSimon Glass void gpio_info(void);
78*8d30fcd9SSimon Glass 
79*8d30fcd9SSimon Glass #define gpio_status()	gpio_info()
80*8d30fcd9SSimon Glass 
81*8d30fcd9SSimon Glass #endif
82