gpio.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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_get_value(unsigned gpio)
  42. {
  43. /* GPIO can never have been requested or set as {in,out}put */
  44. WARN_ON(1);
  45. return 0;
  46. }
  47. static inline void gpio_set_value(unsigned gpio, int value)
  48. {
  49. /* GPIO can never have been requested or set as output */
  50. WARN_ON(1);
  51. }
  52. static inline int gpio_cansleep(unsigned gpio)
  53. {
  54. /* GPIO can never have been requested or set as {in,out}put */
  55. WARN_ON(1);
  56. return 0;
  57. }
  58. static inline int gpio_get_value_cansleep(unsigned gpio)
  59. {
  60. /* GPIO can never have been requested or set as {in,out}put */
  61. WARN_ON(1);
  62. return 0;
  63. }
  64. static inline void gpio_set_value_cansleep(unsigned gpio, int value)
  65. {
  66. /* GPIO can never have been requested or set as output */
  67. WARN_ON(1);
  68. }
  69. static inline int gpio_export(unsigned gpio, bool direction_may_change)
  70. {
  71. /* GPIO can never have been requested or set as {in,out}put */
  72. WARN_ON(1);
  73. return -EINVAL;
  74. }
  75. static inline int gpio_export_link(struct device *dev, const char *name,
  76. unsigned gpio)
  77. {
  78. /* GPIO can never have been exported */
  79. WARN_ON(1);
  80. return -EINVAL;
  81. }
  82. static inline int gpio_sysfs_set_active_low(unsigned gpio, int value)
  83. {
  84. /* GPIO can never have been requested */
  85. WARN_ON(1);
  86. return -EINVAL;
  87. }
  88. static inline void gpio_unexport(unsigned gpio)
  89. {
  90. /* GPIO can never have been exported */
  91. WARN_ON(1);
  92. }
  93. static inline int gpio_to_irq(unsigned gpio)
  94. {
  95. /* GPIO can never have been requested or set as input */
  96. WARN_ON(1);
  97. return -EINVAL;
  98. }
  99. static inline int irq_to_gpio(unsigned irq)
  100. {
  101. /* irq can never have been returned from gpio_to_irq() */
  102. WARN_ON(1);
  103. return -EINVAL;
  104. }
  105. #endif
  106. #endif /* __LINUX_GPIO_H */