gpio.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef __ASM_MACH_GPIO_H
  2. #define __ASM_MACH_GPIO_H
  3. #include <mach/addr-map.h>
  4. #include <mach/irqs.h>
  5. #include <asm-generic/gpio.h>
  6. #define GPIO_REGS_VIRT (APB_VIRT_BASE + 0x19000)
  7. #define BANK_OFF(n) (((n) < 3) ? (n) << 2 : 0x100 + (((n) - 3) << 2))
  8. #define GPIO_REG(x) (*((volatile u32 *)(GPIO_REGS_VIRT + (x))))
  9. #define NR_BUILTIN_GPIO (128)
  10. #define gpio_to_bank(gpio) ((gpio) >> 5)
  11. #define gpio_to_irq(gpio) (IRQ_GPIO_START + (gpio))
  12. #define irq_to_gpio(irq) ((irq) - IRQ_GPIO_START)
  13. #define __gpio_is_inverted(gpio) (0)
  14. #define __gpio_is_occupied(gpio) (0)
  15. /* NOTE: these macros are defined here to make optimization of
  16. * gpio_{get,set}_value() to work when 'gpio' is a constant.
  17. * Usage of these macros otherwise is no longer recommended,
  18. * use generic GPIO API whenever possible.
  19. */
  20. #define GPIO_bit(gpio) (1 << ((gpio) & 0x1f))
  21. #define GPLR(x) GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x00)
  22. #define GPDR(x) GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x0c)
  23. #define GPSR(x) GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x18)
  24. #define GPCR(x) GPIO_REG(BANK_OFF(gpio_to_bank(x)) + 0x24)
  25. #include <plat/gpio.h>
  26. #endif /* __ASM_MACH_GPIO_H */