gpio.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * arch/arm/mach-dove/include/mach/gpio.h
  3. *
  4. * This file is licensed under the terms of the GNU General Public
  5. * License version 2. This program is licensed "as is" without any
  6. * warranty of any kind, whether express or implied.
  7. */
  8. #ifndef __ASM_ARCH_GPIO_H
  9. #define __ASM_ARCH_GPIO_H
  10. #include <asm/errno.h>
  11. #include <mach/irqs.h>
  12. #include <plat/gpio.h>
  13. #include <asm-generic/gpio.h> /* cansleep wrappers */
  14. #define GPIO_MAX 72
  15. #define GPIO_BASE_LO (DOVE_GPIO_VIRT_BASE + 0x00)
  16. #define GPIO_BASE_HI (DOVE_GPIO_VIRT_BASE + 0x20)
  17. #define GPIO_BASE(pin) ((pin < 32) ? GPIO_BASE_LO : \
  18. ((pin < 64) ? GPIO_BASE_HI : \
  19. DOVE_GPIO2_VIRT_BASE))
  20. #define GPIO_OUT(pin) (GPIO_BASE(pin) + 0x00)
  21. #define GPIO_IO_CONF(pin) (GPIO_BASE(pin) + 0x04)
  22. #define GPIO_BLINK_EN(pin) (GPIO_BASE(pin) + 0x08)
  23. #define GPIO_IN_POL(pin) (GPIO_BASE(pin) + 0x0c)
  24. #define GPIO_DATA_IN(pin) (GPIO_BASE(pin) + 0x10)
  25. #define GPIO_EDGE_CAUSE(pin) (GPIO_BASE(pin) + 0x14)
  26. #define GPIO_EDGE_MASK(pin) (GPIO_BASE(pin) + 0x18)
  27. #define GPIO_LEVEL_MASK(pin) (GPIO_BASE(pin) + 0x1c)
  28. static inline int gpio_to_irq(int pin)
  29. {
  30. if (pin < NR_GPIO_IRQS)
  31. return pin + IRQ_DOVE_GPIO_START;
  32. return -EINVAL;
  33. }
  34. static inline int irq_to_gpio(int irq)
  35. {
  36. if (IRQ_DOVE_GPIO_START < irq && irq < NR_IRQS)
  37. return irq - IRQ_DOVE_GPIO_START;
  38. return -EINVAL;
  39. }
  40. #endif