gpio.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. #include <linux/kernel.h>
  8. #include <linux/types.h>
  9. #include <linux/errno.h>
  10. struct device;
  11. struct gpio;
  12. struct gpio_chip;
  13. /*
  14. * Some platforms don't support the GPIO programming interface.
  15. *
  16. * In case some driver uses it anyway (it should normally have
  17. * depended on GENERIC_GPIO), these routines help the compiler
  18. * optimize out much GPIO-related code ... or trigger a runtime
  19. * warning when something is wrongly called.
  20. */
  21. static inline int gpio_is_valid(int number)
  22. {
  23. return 0;
  24. }
  25. static inline int gpio_request(unsigned gpio, const char *label)
  26. {
  27. return -ENOSYS;
  28. }
  29. static inline int __must_check gpio_request_one(unsigned gpio,
  30. unsigned long flags, const char *label)
  31. {
  32. return -ENOSYS;
  33. }
  34. static inline int __must_check gpio_request_array(struct gpio *array, size_t num)
  35. {
  36. return -ENOSYS;
  37. }
  38. static inline void gpio_free(unsigned gpio)
  39. {
  40. might_sleep();
  41. /* GPIO can never have been requested */
  42. WARN_ON(1);
  43. }
  44. static inline void gpio_free_array(struct gpio *array, size_t num)
  45. {
  46. might_sleep();
  47. /* GPIO can never have been requested */
  48. WARN_ON(1);
  49. }
  50. static inline int gpio_direction_input(unsigned gpio)
  51. {
  52. return -ENOSYS;
  53. }
  54. static inline int gpio_direction_output(unsigned gpio, int value)
  55. {
  56. return -ENOSYS;
  57. }
  58. static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
  59. {
  60. return -ENOSYS;
  61. }
  62. static inline int gpio_get_value(unsigned gpio)
  63. {
  64. /* GPIO can never have been requested or set as {in,out}put */
  65. WARN_ON(1);
  66. return 0;
  67. }
  68. static inline void gpio_set_value(unsigned gpio, int value)
  69. {
  70. /* GPIO can never have been requested or set as output */
  71. WARN_ON(1);
  72. }
  73. static inline int gpio_cansleep(unsigned gpio)
  74. {
  75. /* GPIO can never have been requested or set as {in,out}put */
  76. WARN_ON(1);
  77. return 0;
  78. }
  79. static inline int gpio_get_value_cansleep(unsigned gpio)
  80. {
  81. /* GPIO can never have been requested or set as {in,out}put */
  82. WARN_ON(1);
  83. return 0;
  84. }
  85. static inline void gpio_set_value_cansleep(unsigned gpio, int value)
  86. {
  87. /* GPIO can never have been requested or set as output */
  88. WARN_ON(1);
  89. }
  90. static inline int gpio_export(unsigned gpio, bool direction_may_change)
  91. {
  92. /* GPIO can never have been requested or set as {in,out}put */
  93. WARN_ON(1);
  94. return -EINVAL;
  95. }
  96. static inline int gpio_export_link(struct device *dev, const char *name,
  97. unsigned gpio)
  98. {
  99. /* GPIO can never have been exported */
  100. WARN_ON(1);
  101. return -EINVAL;
  102. }
  103. static inline int gpio_sysfs_set_active_low(unsigned gpio, int value)
  104. {
  105. /* GPIO can never have been requested */
  106. WARN_ON(1);
  107. return -EINVAL;
  108. }
  109. static inline void gpio_unexport(unsigned gpio)
  110. {
  111. /* GPIO can never have been exported */
  112. WARN_ON(1);
  113. }
  114. static inline int gpio_to_irq(unsigned gpio)
  115. {
  116. /* GPIO can never have been requested or set as input */
  117. WARN_ON(1);
  118. return -EINVAL;
  119. }
  120. static inline int irq_to_gpio(unsigned irq)
  121. {
  122. /* irq can never have been returned from gpio_to_irq() */
  123. WARN_ON(1);
  124. return -EINVAL;
  125. }
  126. #endif
  127. #endif /* __LINUX_GPIO_H */