gpio.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. /*
  12. * Some platforms don't support the GPIO programming interface.
  13. *
  14. * In case some driver uses it anyway (it should normally have
  15. * depended on GENERIC_GPIO), these routines help the compiler
  16. * optimize out much GPIO-related code ... or trigger a runtime
  17. * warning when something is wrongly called.
  18. */
  19. static inline int gpio_is_valid(int number)
  20. {
  21. return 0;
  22. }
  23. static inline int gpio_request(unsigned gpio, const char *label)
  24. {
  25. return -ENOSYS;
  26. }
  27. static inline void gpio_free(unsigned gpio)
  28. {
  29. might_sleep();
  30. /* GPIO can never have been requested */
  31. WARN_ON(1);
  32. }
  33. static inline int gpio_direction_input(unsigned gpio)
  34. {
  35. return -ENOSYS;
  36. }
  37. static inline int gpio_direction_output(unsigned gpio, int value)
  38. {
  39. return -ENOSYS;
  40. }
  41. static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
  42. {
  43. return -ENOSYS;
  44. }
  45. static inline int gpio_get_value(unsigned gpio)
  46. {
  47. /* GPIO can never have been requested or set as {in,out}put */
  48. WARN_ON(1);
  49. return 0;
  50. }
  51. static inline void gpio_set_value(unsigned gpio, int value)
  52. {
  53. /* GPIO can never have been requested or set as output */
  54. WARN_ON(1);
  55. }
  56. static inline int gpio_cansleep(unsigned gpio)
  57. {
  58. /* GPIO can never have been requested or set as {in,out}put */
  59. WARN_ON(1);
  60. return 0;
  61. }
  62. static inline int gpio_get_value_cansleep(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_cansleep(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_export(unsigned gpio, bool direction_may_change)
  74. {
  75. /* GPIO can never have been requested or set as {in,out}put */
  76. WARN_ON(1);
  77. return -EINVAL;
  78. }
  79. static inline int gpio_export_link(struct device *dev, const char *name,
  80. unsigned gpio)
  81. {
  82. /* GPIO can never have been exported */
  83. WARN_ON(1);
  84. return -EINVAL;
  85. }
  86. static inline int gpio_sysfs_set_active_low(unsigned gpio, int value)
  87. {
  88. /* GPIO can never have been requested */
  89. WARN_ON(1);
  90. return -EINVAL;
  91. }
  92. static inline void gpio_unexport(unsigned gpio)
  93. {
  94. /* GPIO can never have been exported */
  95. WARN_ON(1);
  96. }
  97. static inline int gpio_to_irq(unsigned gpio)
  98. {
  99. /* GPIO can never have been requested or set as input */
  100. WARN_ON(1);
  101. return -EINVAL;
  102. }
  103. static inline int irq_to_gpio(unsigned irq)
  104. {
  105. /* irq can never have been returned from gpio_to_irq() */
  106. WARN_ON(1);
  107. return -EINVAL;
  108. }
  109. #endif
  110. #endif /* __LINUX_GPIO_H */