gpio.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 dev device to use
  27. * @param offset GPIO offset within bank
  28. * @return -1 on error, 0 if GPIO is low, >0 if high
  29. */
  30. int sandbox_gpio_get_value(struct udevice *dev, unsigned int offset);
  31. /**
  32. * Set the simulated value of a GPIO (used only in sandbox test code)
  33. *
  34. * @param dev device to use
  35. * @param offset GPIO offset within bank
  36. * @param value value to set (0 for low, non-zero for high)
  37. * @return -1 on error, 0 if ok
  38. */
  39. int sandbox_gpio_set_value(struct udevice *dev, unsigned int offset, int value);
  40. /**
  41. * Set or reset the simulated open drain mode of a GPIO (used only in sandbox
  42. * test code)
  43. *
  44. * @param gp GPIO number
  45. * @param value value to set (0 for enabled open drain mode, non-zero for
  46. * disabled)
  47. * @return -1 on error, 0 if ok
  48. */
  49. int sandbox_gpio_set_open_drain(struct udevice *dev, unsigned offset, int value);
  50. /**
  51. * Return the state of the simulated open drain mode of a GPIO (used only in
  52. * sandbox test code)
  53. *
  54. * @param gp GPIO number
  55. * @return -1 on error, 0 if GPIO is input, >0 if output
  56. */
  57. int sandbox_gpio_get_open_drain(struct udevice *dev, unsigned offset);
  58. /**
  59. * Return the simulated direction of a GPIO (used only in sandbox test code)
  60. *
  61. * @param dev device to use
  62. * @param offset GPIO offset within bank
  63. * @return -1 on error, 0 if GPIO is input, >0 if output
  64. */
  65. int sandbox_gpio_get_direction(struct udevice *dev, unsigned int offset);
  66. /**
  67. * Set the simulated direction of a GPIO (used only in sandbox test code)
  68. *
  69. * @param dev device to use
  70. * @param offset GPIO offset within bank
  71. * @param output 0 to set as input, 1 to set as output
  72. * @return -1 on error, 0 if ok
  73. */
  74. int sandbox_gpio_set_direction(struct udevice *dev, unsigned int offset,
  75. int output);
  76. #endif