gpio.h 2.5 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. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #ifndef __ASM_SANDBOX_GPIO_H
  25. #define __ASM_SANDBOX_GPIO_H
  26. /*
  27. * We use the generic interface, and add a back-channel.
  28. *
  29. * The back-channel functions are declared in this file. They should not be used
  30. * except in test code.
  31. *
  32. * Test code can, for example, call sandbox_gpio_set_value() to set the value of
  33. * a simulated GPIO. From then on, normal code in U-Boot will see this new
  34. * value when it calls gpio_get_value().
  35. *
  36. * NOTE: DO NOT use the functions in this file except in test code!
  37. */
  38. #include <asm-generic/gpio.h>
  39. /**
  40. * Return the simulated value of a GPIO (used only in sandbox test code)
  41. *
  42. * @param gp GPIO number
  43. * @return -1 on error, 0 if GPIO is low, >0 if high
  44. */
  45. int sandbox_gpio_get_value(unsigned gp);
  46. /**
  47. * Set the simulated value of a GPIO (used only in sandbox test code)
  48. *
  49. * @param gp GPIO number
  50. * @param value value to set (0 for low, non-zero for high)
  51. * @return -1 on error, 0 if ok
  52. */
  53. int sandbox_gpio_set_value(unsigned gp, int value);
  54. /**
  55. * Return the simulated direction of a GPIO (used only in sandbox test code)
  56. *
  57. * @param gp GPIO number
  58. * @return -1 on error, 0 if GPIO is input, >0 if output
  59. */
  60. int sandbox_gpio_get_direction(unsigned gp);
  61. /**
  62. * Set the simulated direction of a GPIO (used only in sandbox test code)
  63. *
  64. * @param gp GPIO number
  65. * @param output 0 to set as input, 1 to set as output
  66. * @return -1 on error, 0 if ok
  67. */
  68. int sandbox_gpio_set_direction(unsigned gp, int output);
  69. /* Display information about each GPIO */
  70. void gpio_info(void);
  71. #define gpio_status() gpio_info()
  72. #endif