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 * 29*21047b31Smario.six@gdsys.cc * @param dev device to use 30*21047b31Smario.six@gdsys.cc * @param offset GPIO offset within bank 318d30fcd9SSimon Glass * @return -1 on error, 0 if GPIO is low, >0 if high 328d30fcd9SSimon Glass */ 3354c5d08aSHeiko Schocher int sandbox_gpio_get_value(struct udevice *dev, unsigned int offset); 348d30fcd9SSimon Glass 358d30fcd9SSimon Glass /** 368d30fcd9SSimon Glass * Set the simulated value of a GPIO (used only in sandbox test code) 378d30fcd9SSimon Glass * 38*21047b31Smario.six@gdsys.cc * @param dev device to use 39*21047b31Smario.six@gdsys.cc * @param offset GPIO offset within bank 408d30fcd9SSimon Glass * @param value value to set (0 for low, non-zero for high) 418d30fcd9SSimon Glass * @return -1 on error, 0 if ok 428d30fcd9SSimon Glass */ 4354c5d08aSHeiko Schocher int sandbox_gpio_set_value(struct udevice *dev, unsigned int offset, int value); 448d30fcd9SSimon Glass 458d30fcd9SSimon Glass /** 46743268f5Smario.six@gdsys.cc * Set or reset the simulated open drain mode of a GPIO (used only in sandbox 47743268f5Smario.six@gdsys.cc * test code) 48743268f5Smario.six@gdsys.cc * 49743268f5Smario.six@gdsys.cc * @param gp GPIO number 50743268f5Smario.six@gdsys.cc * @param value value to set (0 for enabled open drain mode, non-zero for 51743268f5Smario.six@gdsys.cc * disabled) 52743268f5Smario.six@gdsys.cc * @return -1 on error, 0 if ok 53743268f5Smario.six@gdsys.cc */ 54743268f5Smario.six@gdsys.cc int sandbox_gpio_set_open_drain(struct udevice *dev, unsigned offset, int value); 55743268f5Smario.six@gdsys.cc 56743268f5Smario.six@gdsys.cc /** 57743268f5Smario.six@gdsys.cc * Return the state of the simulated open drain mode of a GPIO (used only in 58743268f5Smario.six@gdsys.cc * sandbox test code) 59743268f5Smario.six@gdsys.cc * 60743268f5Smario.six@gdsys.cc * @param gp GPIO number 61743268f5Smario.six@gdsys.cc * @return -1 on error, 0 if GPIO is input, >0 if output 62743268f5Smario.six@gdsys.cc */ 63743268f5Smario.six@gdsys.cc int sandbox_gpio_get_open_drain(struct udevice *dev, unsigned offset); 64743268f5Smario.six@gdsys.cc 65743268f5Smario.six@gdsys.cc /** 668d30fcd9SSimon Glass * Return the simulated direction of a GPIO (used only in sandbox test code) 678d30fcd9SSimon Glass * 68*21047b31Smario.six@gdsys.cc * @param dev device to use 69*21047b31Smario.six@gdsys.cc * @param offset GPIO offset within bank 708d30fcd9SSimon Glass * @return -1 on error, 0 if GPIO is input, >0 if output 718d30fcd9SSimon Glass */ 7254c5d08aSHeiko Schocher int sandbox_gpio_get_direction(struct udevice *dev, unsigned int offset); 738d30fcd9SSimon Glass 748d30fcd9SSimon Glass /** 758d30fcd9SSimon Glass * Set the simulated direction of a GPIO (used only in sandbox test code) 768d30fcd9SSimon Glass * 77*21047b31Smario.six@gdsys.cc * @param dev device to use 78*21047b31Smario.six@gdsys.cc * @param offset GPIO offset within bank 798d30fcd9SSimon Glass * @param output 0 to set as input, 1 to set as output 808d30fcd9SSimon Glass * @return -1 on error, 0 if ok 818d30fcd9SSimon Glass */ 8254c5d08aSHeiko Schocher int sandbox_gpio_set_direction(struct udevice *dev, unsigned int offset, 83e2d8a714SSimon Glass int output); 848d30fcd9SSimon Glass 858d30fcd9SSimon Glass #endif 86