gpio.h 2.6 KB

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