gpio.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  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.
  4. *
  5. * Copyright (c) 2011 The Chromium OS Authors.
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #ifndef __ASM_SANDBOX_GPIO_H
  9. #define __ASM_SANDBOX_GPIO_H
  10. /*
  11. * We use the generic interface, and add a back-channel.
  12. *
  13. * The back-channel functions are declared in this file. They should not be used
  14. * except in test code.
  15. *
  16. * Test code can, for example, call sandbox_gpio_set_value() to set the value of
  17. * a simulated GPIO. From then on, normal code in U-Boot will see this new
  18. * value when it calls gpio_get_value().
  19. *
  20. * NOTE: DO NOT use the functions in this file except in test code!
  21. */
  22. #include <asm-generic/gpio.h>
  23. /**
  24. * Return the simulated value of a GPIO (used only in sandbox test code)
  25. *
  26. * @param gp GPIO number
  27. * @return -1 on error, 0 if GPIO is low, >0 if high
  28. */
  29. int sandbox_gpio_get_value(unsigned gp);
  30. /**
  31. * Set the simulated value of a GPIO (used only in sandbox test code)
  32. *
  33. * @param gp GPIO number
  34. * @param value value to set (0 for low, non-zero for high)
  35. * @return -1 on error, 0 if ok
  36. */
  37. int sandbox_gpio_set_value(unsigned gp, int value);
  38. /**
  39. * Return the simulated direction of a GPIO (used only in sandbox test code)
  40. *
  41. * @param gp GPIO number
  42. * @return -1 on error, 0 if GPIO is input, >0 if output
  43. */
  44. int sandbox_gpio_get_direction(unsigned gp);
  45. /**
  46. * Set the simulated direction of a GPIO (used only in sandbox test code)
  47. *
  48. * @param gp GPIO number
  49. * @param output 0 to set as input, 1 to set as output
  50. * @return -1 on error, 0 if ok
  51. */
  52. int sandbox_gpio_set_direction(unsigned gp, int output);
  53. /* Display information about each GPIO */
  54. void gpio_info(void);
  55. #define gpio_status() gpio_info()
  56. #endif