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 */ 3254c5d08aSHeiko 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 */ 4154c5d08aSHeiko Schocher int sandbox_gpio_set_value(struct udevice *dev, unsigned int offset, int value); 428d30fcd9SSimon Glass 438d30fcd9SSimon Glass /** 44*743268f5Smario.six@gdsys.cc * Set or reset the simulated open drain mode of a GPIO (used only in sandbox 45*743268f5Smario.six@gdsys.cc * test code) 46*743268f5Smario.six@gdsys.cc * 47*743268f5Smario.six@gdsys.cc * @param gp GPIO number 48*743268f5Smario.six@gdsys.cc * @param value value to set (0 for enabled open drain mode, non-zero for 49*743268f5Smario.six@gdsys.cc * disabled) 50*743268f5Smario.six@gdsys.cc * @return -1 on error, 0 if ok 51*743268f5Smario.six@gdsys.cc */ 52*743268f5Smario.six@gdsys.cc int sandbox_gpio_set_open_drain(struct udevice *dev, unsigned offset, int value); 53*743268f5Smario.six@gdsys.cc 54*743268f5Smario.six@gdsys.cc /** 55*743268f5Smario.six@gdsys.cc * Return the state of the simulated open drain mode of a GPIO (used only in 56*743268f5Smario.six@gdsys.cc * sandbox test code) 57*743268f5Smario.six@gdsys.cc * 58*743268f5Smario.six@gdsys.cc * @param gp GPIO number 59*743268f5Smario.six@gdsys.cc * @return -1 on error, 0 if GPIO is input, >0 if output 60*743268f5Smario.six@gdsys.cc */ 61*743268f5Smario.six@gdsys.cc int sandbox_gpio_get_open_drain(struct udevice *dev, unsigned offset); 62*743268f5Smario.six@gdsys.cc 63*743268f5Smario.six@gdsys.cc /** 648d30fcd9SSimon Glass * Return the simulated direction of a GPIO (used only in sandbox test code) 658d30fcd9SSimon Glass * 668d30fcd9SSimon Glass * @param gp GPIO number 678d30fcd9SSimon Glass * @return -1 on error, 0 if GPIO is input, >0 if output 688d30fcd9SSimon Glass */ 6954c5d08aSHeiko Schocher int sandbox_gpio_get_direction(struct udevice *dev, unsigned int offset); 708d30fcd9SSimon Glass 718d30fcd9SSimon Glass /** 728d30fcd9SSimon Glass * Set the simulated direction of a GPIO (used only in sandbox test code) 738d30fcd9SSimon Glass * 748d30fcd9SSimon Glass * @param gp GPIO number 758d30fcd9SSimon Glass * @param output 0 to set as input, 1 to set as output 768d30fcd9SSimon Glass * @return -1 on error, 0 if ok 778d30fcd9SSimon Glass */ 7854c5d08aSHeiko Schocher int sandbox_gpio_set_direction(struct udevice *dev, unsigned int offset, 79e2d8a714SSimon Glass int output); 808d30fcd9SSimon Glass 818d30fcd9SSimon Glass #endif 82