gpio.h 939 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef __ASM_AVR32_ARCH_GPIO_H
  2. #define __ASM_AVR32_ARCH_GPIO_H
  3. #include <linux/compiler.h>
  4. #include <asm/irq.h>
  5. /* Some GPIO chips can manage IRQs; some can't. The exact numbers can
  6. * be changed if needed, but for the moment they're not configurable.
  7. */
  8. #define ARCH_NR_GPIOS (NR_GPIO_IRQS + 2 * 32)
  9. /* Arch-neutral GPIO API, supporting both "native" and external GPIOs. */
  10. #include <asm-generic/gpio.h>
  11. static inline int gpio_get_value(unsigned int gpio)
  12. {
  13. return __gpio_get_value(gpio);
  14. }
  15. static inline void gpio_set_value(unsigned int gpio, int value)
  16. {
  17. __gpio_set_value(gpio, value);
  18. }
  19. static inline int gpio_cansleep(unsigned int gpio)
  20. {
  21. return __gpio_cansleep(gpio);
  22. }
  23. static inline int gpio_to_irq(unsigned int gpio)
  24. {
  25. if (gpio < NR_GPIO_IRQS)
  26. return gpio + GPIO_IRQ_BASE;
  27. return -EINVAL;
  28. }
  29. static inline int irq_to_gpio(unsigned int irq)
  30. {
  31. return irq - GPIO_IRQ_BASE;
  32. }
  33. #endif /* __ASM_AVR32_ARCH_GPIO_H */