gpio.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #ifndef __LINUX_GPIO_H
  2. #define __LINUX_GPIO_H
  3. /* see Documentation/gpio.txt */
  4. #ifdef CONFIG_GENERIC_GPIO
  5. #include <asm/gpio.h>
  6. #else
  7. /*
  8. * Some platforms don't support the GPIO programming interface.
  9. *
  10. * In case some driver uses it anyway (it should normally have
  11. * depended on GENERIC_GPIO), these routines help the compiler
  12. * optimize out much GPIO-related code ... or trigger a runtime
  13. * warning when something is wrongly called.
  14. */
  15. static inline int gpio_is_valid(int number)
  16. {
  17. return 0;
  18. }
  19. static inline int gpio_request(unsigned gpio, const char *label)
  20. {
  21. return -ENOSYS;
  22. }
  23. static inline void gpio_free(unsigned gpio)
  24. {
  25. /* GPIO can never have been requested */
  26. WARN_ON(1);
  27. }
  28. static inline int gpio_direction_input(unsigned gpio)
  29. {
  30. return -ENOSYS;
  31. }
  32. static inline int gpio_direction_output(unsigned gpio, int value)
  33. {
  34. return -ENOSYS;
  35. }
  36. static inline int gpio_get_value(unsigned gpio)
  37. {
  38. /* GPIO can never have been requested or set as {in,out}put */
  39. WARN_ON(1);
  40. return 0;
  41. }
  42. static inline void gpio_set_value(unsigned gpio, int value)
  43. {
  44. /* GPIO can never have been requested or set as output */
  45. WARN_ON(1);
  46. }
  47. static inline int gpio_cansleep(unsigned gpio)
  48. {
  49. /* GPIO can never have been requested or set as {in,out}put */
  50. WARN_ON(1);
  51. return 0;
  52. }
  53. static inline int gpio_get_value_cansleep(unsigned gpio)
  54. {
  55. /* GPIO can never have been requested or set as {in,out}put */
  56. WARN_ON(1);
  57. return 0;
  58. }
  59. static inline void gpio_set_value_cansleep(unsigned gpio, int value)
  60. {
  61. /* GPIO can never have been requested or set as output */
  62. WARN_ON(1);
  63. }
  64. static inline int gpio_to_irq(unsigned gpio)
  65. {
  66. /* GPIO can never have been requested or set as input */
  67. WARN_ON(1);
  68. return -EINVAL;
  69. }
  70. static inline int irq_to_gpio(unsigned irq)
  71. {
  72. /* irq can never have been returned from gpio_to_irq() */
  73. WARN_ON(1);
  74. return -EINVAL;
  75. }
  76. #endif
  77. #endif /* __LINUX_GPIO_H */