gpio.h 2.2 KB

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