gpio.h 2.4 KB

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