gpio.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. #ifndef __LINUX_GPIO_H
  2. #define __LINUX_GPIO_H
  3. /* see Documentation/gpio.txt */
  4. /* make these flag values available regardless of GPIO kconfig options */
  5. #define GPIOF_DIR_OUT (0 << 0)
  6. #define GPIOF_DIR_IN (1 << 0)
  7. #define GPIOF_INIT_LOW (0 << 1)
  8. #define GPIOF_INIT_HIGH (1 << 1)
  9. #define GPIOF_IN (GPIOF_DIR_IN)
  10. #define GPIOF_OUT_INIT_LOW (GPIOF_DIR_OUT | GPIOF_INIT_LOW)
  11. #define GPIOF_OUT_INIT_HIGH (GPIOF_DIR_OUT | GPIOF_INIT_HIGH)
  12. /**
  13. * struct gpio - a structure describing a GPIO with configuration
  14. * @gpio: the GPIO number
  15. * @flags: GPIO configuration as specified by GPIOF_*
  16. * @label: a literal description string of this GPIO
  17. */
  18. struct gpio {
  19. unsigned gpio;
  20. unsigned long flags;
  21. const char *label;
  22. };
  23. #ifdef CONFIG_GENERIC_GPIO
  24. #include <asm/gpio.h>
  25. #else
  26. #include <linux/kernel.h>
  27. #include <linux/types.h>
  28. #include <linux/errno.h>
  29. #include <linux/bug.h>
  30. struct device;
  31. struct gpio_chip;
  32. static inline bool gpio_is_valid(int number)
  33. {
  34. return false;
  35. }
  36. static inline int gpio_request(unsigned gpio, const char *label)
  37. {
  38. return -ENOSYS;
  39. }
  40. static inline int gpio_request_one(unsigned gpio,
  41. unsigned long flags, const char *label)
  42. {
  43. return -ENOSYS;
  44. }
  45. static inline int gpio_request_array(const struct gpio *array, size_t num)
  46. {
  47. return -ENOSYS;
  48. }
  49. static inline void gpio_free(unsigned gpio)
  50. {
  51. might_sleep();
  52. /* GPIO can never have been requested */
  53. WARN_ON(1);
  54. }
  55. static inline void gpio_free_array(const struct gpio *array, size_t num)
  56. {
  57. might_sleep();
  58. /* GPIO can never have been requested */
  59. WARN_ON(1);
  60. }
  61. static inline int gpio_direction_input(unsigned gpio)
  62. {
  63. return -ENOSYS;
  64. }
  65. static inline int gpio_direction_output(unsigned gpio, int value)
  66. {
  67. return -ENOSYS;
  68. }
  69. static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
  70. {
  71. return -ENOSYS;
  72. }
  73. static inline int gpio_get_value(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 void gpio_set_value(unsigned gpio, int value)
  80. {
  81. /* GPIO can never have been requested or set as output */
  82. WARN_ON(1);
  83. }
  84. static inline int gpio_cansleep(unsigned gpio)
  85. {
  86. /* GPIO can never have been requested or set as {in,out}put */
  87. WARN_ON(1);
  88. return 0;
  89. }
  90. static inline int gpio_get_value_cansleep(unsigned gpio)
  91. {
  92. /* GPIO can never have been requested or set as {in,out}put */
  93. WARN_ON(1);
  94. return 0;
  95. }
  96. static inline void gpio_set_value_cansleep(unsigned gpio, int value)
  97. {
  98. /* GPIO can never have been requested or set as output */
  99. WARN_ON(1);
  100. }
  101. static inline int gpio_export(unsigned gpio, bool direction_may_change)
  102. {
  103. /* GPIO can never have been requested or set as {in,out}put */
  104. WARN_ON(1);
  105. return -EINVAL;
  106. }
  107. static inline int gpio_export_link(struct device *dev, const char *name,
  108. unsigned gpio)
  109. {
  110. /* GPIO can never have been exported */
  111. WARN_ON(1);
  112. return -EINVAL;
  113. }
  114. static inline int gpio_sysfs_set_active_low(unsigned gpio, int value)
  115. {
  116. /* GPIO can never have been requested */
  117. WARN_ON(1);
  118. return -EINVAL;
  119. }
  120. static inline void gpio_unexport(unsigned gpio)
  121. {
  122. /* GPIO can never have been exported */
  123. WARN_ON(1);
  124. }
  125. static inline int gpio_to_irq(unsigned gpio)
  126. {
  127. /* GPIO can never have been requested or set as input */
  128. WARN_ON(1);
  129. return -EINVAL;
  130. }
  131. static inline int irq_to_gpio(unsigned irq)
  132. {
  133. /* irq can never have been returned from gpio_to_irq() */
  134. WARN_ON(1);
  135. return -EINVAL;
  136. }
  137. #endif
  138. #endif /* __LINUX_GPIO_H */