xref: /openbmc/u-boot/arch/sandbox/include/asm/gpio.h (revision 54c5d08a)
18d30fcd9SSimon Glass /*
28d30fcd9SSimon Glass  * This is the interface to the sandbox GPIO driver for test code which
38d30fcd9SSimon Glass  * wants to change the GPIO values reported to U-Boot.
48d30fcd9SSimon Glass  *
58d30fcd9SSimon Glass  * Copyright (c) 2011 The Chromium OS Authors.
61a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
78d30fcd9SSimon Glass  */
88d30fcd9SSimon Glass 
98d30fcd9SSimon Glass #ifndef __ASM_SANDBOX_GPIO_H
108d30fcd9SSimon Glass #define __ASM_SANDBOX_GPIO_H
118d30fcd9SSimon Glass 
128d30fcd9SSimon Glass /*
138d30fcd9SSimon Glass  * We use the generic interface, and add a back-channel.
148d30fcd9SSimon Glass  *
158d30fcd9SSimon Glass  * The back-channel functions are declared in this file. They should not be used
168d30fcd9SSimon Glass  * except in test code.
178d30fcd9SSimon Glass  *
188d30fcd9SSimon Glass  * Test code can, for example, call sandbox_gpio_set_value() to set the value of
198d30fcd9SSimon Glass  * a simulated GPIO. From then on, normal code in U-Boot will see this new
208d30fcd9SSimon Glass  * value when it calls gpio_get_value().
218d30fcd9SSimon Glass  *
228d30fcd9SSimon Glass  * NOTE: DO NOT use the functions in this file except in test code!
238d30fcd9SSimon Glass  */
248d30fcd9SSimon Glass #include <asm-generic/gpio.h>
258d30fcd9SSimon Glass 
268d30fcd9SSimon Glass /**
278d30fcd9SSimon Glass  * Return the simulated value of a GPIO (used only in sandbox test code)
288d30fcd9SSimon Glass  *
298d30fcd9SSimon Glass  * @param gp	GPIO number
308d30fcd9SSimon Glass  * @return -1 on error, 0 if GPIO is low, >0 if high
318d30fcd9SSimon Glass  */
32*54c5d08aSHeiko Schocher int sandbox_gpio_get_value(struct udevice *dev, unsigned int offset);
338d30fcd9SSimon Glass 
348d30fcd9SSimon Glass /**
358d30fcd9SSimon Glass  * Set the simulated value of a GPIO (used only in sandbox test code)
368d30fcd9SSimon Glass  *
378d30fcd9SSimon Glass  * @param gp	GPIO number
388d30fcd9SSimon Glass  * @param value	value to set (0 for low, non-zero for high)
398d30fcd9SSimon Glass  * @return -1 on error, 0 if ok
408d30fcd9SSimon Glass  */
41*54c5d08aSHeiko Schocher int sandbox_gpio_set_value(struct udevice *dev, unsigned int offset, int value);
428d30fcd9SSimon Glass 
438d30fcd9SSimon Glass /**
448d30fcd9SSimon Glass  * Return the simulated direction of a GPIO (used only in sandbox test code)
458d30fcd9SSimon Glass  *
468d30fcd9SSimon Glass  * @param gp	GPIO number
478d30fcd9SSimon Glass  * @return -1 on error, 0 if GPIO is input, >0 if output
488d30fcd9SSimon Glass  */
49*54c5d08aSHeiko Schocher int sandbox_gpio_get_direction(struct udevice *dev, unsigned int offset);
508d30fcd9SSimon Glass 
518d30fcd9SSimon Glass /**
528d30fcd9SSimon Glass  * Set the simulated direction of a GPIO (used only in sandbox test code)
538d30fcd9SSimon Glass  *
548d30fcd9SSimon Glass  * @param gp	GPIO number
558d30fcd9SSimon Glass  * @param output 0 to set as input, 1 to set as output
568d30fcd9SSimon Glass  * @return -1 on error, 0 if ok
578d30fcd9SSimon Glass  */
58*54c5d08aSHeiko Schocher int sandbox_gpio_set_direction(struct udevice *dev, unsigned int offset,
59e2d8a714SSimon Glass 			       int output);
608d30fcd9SSimon Glass 
618d30fcd9SSimon Glass #endif
62