mt_gpio_base.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef _MT_GPIO_BASE_H_
  2. #define _MT_GPIO_BASE_H_
  3. #include "mt-plat/sync_write.h"
  4. #include <mach/gpio_const.h>
  5. #define GPIO_WR32(addr, data) mt_reg_sync_writel(data, (GPIO_BASE + addr))
  6. #define GPIO_RD32(addr) __raw_readl(((GPIO_BASE + addr)))
  7. /* #define GPIO_SET_BITS(BIT,REG) ((*(volatile unsigned long*)(REG)) = (unsigned long)(BIT)) */
  8. /* #define GPIO_CLR_BITS(BIT,REG) ((*(volatile unsigned long*)(REG)) &= ~((unsigned long)(BIT))) */
  9. #define GPIO_SW_SET_BITS(BIT, REG) GPIO_WR32(REG, GPIO_RD32(REG) | ((unsigned long)(BIT)))
  10. #define GPIO_SET_BITS(BIT, REG) GPIO_WR32(REG, (unsigned long)(BIT))
  11. #define GPIO_CLR_BITS(BIT, REG) GPIO_WR32(REG, GPIO_RD32(REG) & ~((unsigned long)(BIT)))
  12. /*----------------------------------------------------------------------------*/
  13. typedef struct { /*FIXME: check GPIO spec */
  14. unsigned int val;
  15. unsigned int set;
  16. unsigned int clr;
  17. unsigned int rst;
  18. } VAL_REGS;
  19. /*----------------------------------------------------------------------------*/
  20. typedef struct {
  21. VAL_REGS dir[7]; /*0x0000 ~ 0x006F: 112 bytes */
  22. unsigned char rsv00[144]; /*0x00E0 ~ 0x00FF: 32 bytes */
  23. VAL_REGS dout[7]; /*0x0400 ~ 0x04DF: 224 bytes */
  24. unsigned char rsv04[144]; /*0x04B0 ~ 0x04FF: 32 bytes */
  25. VAL_REGS din[7]; /*0x0500 ~ 0x05DF: 224 bytes */
  26. unsigned char rsv05[144]; /*0x05E0 ~ 0x05FF: 32 bytes */
  27. VAL_REGS mode[21]; /*0x0600 ~ 0x08AF: 688 bytes */
  28. } GPIO_REGS;
  29. #ifdef CONFIG_ARCH_MT6735M
  30. /* Denali2 */
  31. #define MAX_GPIO_PIN (197+1)
  32. #else
  33. /* Denali1 & Denali3 */
  34. #define MAX_GPIO_PIN (203+1)
  35. #endif
  36. #endif /* _MT_GPIO_BASE_H_ */