ioregs.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. #ifndef IODEV_H
  2. #define IODEV_H
  3. #include "iodevs.h"
  4. #include "iodeva.h"
  5. #define CPU_HZ 84000000
  6. #define TIMER_HZ (1 << TIMER_SHIFT)
  7. /* Basic system registers */
  8. #define SYS_MAGIC IODEVRL(SYS,0)
  9. #define SYS_BOARDCFG IODEVRL(SYS,1)
  10. #define SYS_BOARDFIX IODEVRB0(SYS,1)
  11. #define SYS_BOARDMINOR IODEVRB1(SYS,1)
  12. #define SYS_BOARDMAJOR IODEVRB2(SYS,1)
  13. #define SYS_BOARDFPGA IODEVRB3(SYS,1)
  14. #define SYS_LED IODEVL(SYS,2)
  15. #define SYS_RESET IODEVL(SYS,3)
  16. #define SYS_RESET_SOFT 1
  17. #define SYS_RESET_HARD 2
  18. #define SYS_RESET_RECONFIG 3
  19. #define ROMCOPY_RAMADDR IODEVL(ROMCOPY,0)
  20. #define ROMCOPY_ROMCMD IODEVL(ROMCOPY,1)
  21. #define ROMCOPY_DATALEN IODEVL(ROMCOPY,2)
  22. #define ROMCOPY_SPI_CMDLEN(x) ((x) << 24)
  23. #define ROMCOPY_ZERO_BUFFER ROMCOPY_SPI_CMDLEN(0)
  24. #define ROMCOPY_SPI_DUAL (1 << 27)
  25. #define ROMCOPY_SPI_MORE (1 << 28)
  26. #define ROMCOPY_WRITE_RAM (1 << 29)
  27. #define ROMCOPY_STATUS IODEVRL(ROMCOPY,3)
  28. #define ROMCOPY_INPUT IODEVRL(ROMCOPY,4)
  29. #define ROMCOPY_STATUS_DONE 1
  30. /* n = 0...7 */
  31. #define TTY_DATA(n) IODEVB(TTY,0+((n) << 2))
  32. #define TTY_WATERCTL(n) IODEVH0(TTY,1+((n) << 2))
  33. #define TTY_WATERCTL_TX_LOW(x) ((x) << 0)
  34. #define TTY_WATERCTL_TX_HIGH(x) ((x) << 4)
  35. #define TTY_WATERCTL_RX_LOW(x) ((x) << 8)
  36. #define TTY_WATERCTL_RX_HIGH(x) ((x) << 12)
  37. #define TTY_STATUS(n) IODEVH0(TTY,2+((n) << 2))
  38. #define TTY_STATUS_TX_EMPTY 0x0001
  39. #define TTY_STATUS_TX_LOW 0x0002
  40. #define TTY_STATUS_TX_HIGH 0x0004
  41. #define TTY_STATUS_TX_FULL 0x0008
  42. #define TTY_STATUS_RX_EMPTY 0x0010
  43. #define TTY_STATUS_RX_LOW 0x0020
  44. #define TTY_STATUS_RX_HIGH 0x0040
  45. #define TTY_STATUS_RX_FULL 0x0080
  46. #define TTY_STATUS_RX_STALE 0x0100
  47. #define TTY_STATUS_RX_BREAK 0x0200
  48. #define TTY_STATUS_USB_CONFIG 0x0400
  49. #define TTY_STATUS_DTR_IN 0x0800
  50. #define TTY_STATUS_RTS_IN 0x1000
  51. #define TTY_IRQEN(n) IODEVH0(TTY,3+((n) << 2))
  52. #define TTY_IRQPOL(n) IODEVH1(TTY,3+((n) << 2))
  53. #define TTY_CHANNEL_MASK ((1U << TTY_CHANNELS) - 1)
  54. #define TTY_IRQ_MASK (TTY_CHANNEL_MASK << TTY_IRQ)
  55. #define TTY_NIRQ(n) (TTY_IRQ+(n))
  56. #define CON_DATA TTY_DATA(0)
  57. #define CON_WATERCTL TTY_WATERCTL(0)
  58. #define CON_STATUS TTY_STATUS(0)
  59. #define CON_IRQEN TTY_IRQEN(0)
  60. #define CON_IRQ TTY_NIRQ(0)
  61. #define SDCARD_CTL IODEVL(SDCARD,0)
  62. #define SDCARD_CTL_SPEED IODEVB0(SDCARD,0)
  63. #define SDCARD_CTL_IRQEN IODEVB1(SDCARD,0)
  64. #define SDCARD_CTL_CLRCRC IODEVB2(SDCARD,0)
  65. #define SDCARD_CRC7_RD IODEVRB0(SDCARD,4)
  66. #define SDCARD_CRC16_RD IODEVRH1(SDCARD,4)
  67. #define SDCARD_CRC7_WR IODEVRB0(SDCARD,5)
  68. #define SDCARD_CRC16_WR IODEVRH1(SDCARD,5)
  69. #define SDCARD_IRQ_READY 1
  70. #define SDCARD_IRQ_CD 2
  71. #define SDCARD_IRQ_EXT 4
  72. /* Speed values, not including -1 adjustment */
  73. #define SD_SLOW 128 /* 328 kHz */
  74. #define SD_20MHZ 3 /* Really 14 MHz */
  75. #define SD_25MHZ 2 /* Really 21 MHz */
  76. #define SD_50MHZ 1 /* Really 42 MHz */
  77. #define I2C_WDATA IODEVL(I2C,0)
  78. #define I2C_WDATA_DATA IODEVB1(I2C,0)
  79. #define I2C_RDATA IODEVL(I2C,1)
  80. #define I2C_RDATA_DATA IODEVB1(I2C,1)
  81. #define I2C_BUSY 1
  82. #define I2C_SR 2
  83. #define I2C_P 4
  84. #define I2C_DUMMY 6
  85. #define I2C_STARTED 0x10
  86. #define I2C_SCL 0x20
  87. #define I2C_SDA 0x40
  88. #define I2C_NAK 0x80
  89. #define I2C_DIVISOR IODEVL(I2C,2)
  90. #define SYSCLOCK_DATETIME IODEVL(SYSCLOCK,0)
  91. #define SYSCLOCK_TICK IODEVL(SYSCLOCK,1)
  92. #define SYSCLOCK_TICK_HOLD IODEVH0(SYSCLOCK,1)
  93. #define SYSCLOCK_TICK_NOW IODEVH1(SYSCLOCK,1)
  94. #define ABC_STATUS IODEVL(ABC,0)
  95. #define ABC_STATUS_LIVE 1
  96. #define ABC_STATUS_RST 2
  97. #define ABC_STATUS_800 4
  98. #define ABC_STATUS_FORCE_80 0x100
  99. #define ABC_STATUS_FORCE_800 0x200
  100. #define ABC_IOSEL IODEVL(ABC,1)
  101. #define ABC_IOSEL_INVALID 0x100
  102. #define ABC_BUSY IODEVL(ABC,2)
  103. #define ABC_BUSY_STATUS IODEVH0(ABC,2)
  104. #define ABC_BUSY_MASK IODEVH1(ABC,2)
  105. #define ABC_BUSY_OUT 0x00ff
  106. #define ABC_BUSY_INP 0x0300
  107. #define ABC_BUSY_BUSCHG 0xf000
  108. #define ABC_BUSCTL IODEVL(ABC,3)
  109. #define ABC_BUSCTL_WAIT 1
  110. #define ABC_BUSCTL_INT 2
  111. #define ABC_BUSCTL_NMI 4
  112. #define ABC_BUSCTL_RESET 8
  113. #define ABC_OUT IODEVL(ABC,4)
  114. #define ABC_OUT_DATA IODEVB0(ABC,4)
  115. #define ABC_OUT_ADDR IODEVB1(ABC,4)
  116. #define ABC_INP IODEVL(ABC,5)
  117. #define ABC_INP0_DATA IODEVB0(ABC,5)
  118. #define ABC_INP1_DATA IODEVB1(ABC,5)
  119. #define ABC_INP_ENABLE IODEVB2(ABC,5)
  120. #define ABC_LATENCY IODEVRL(ABC,7)
  121. #define ABC_LATENCY_CTR IODEVRB0(ABC,7)
  122. #define ABC_LATENCY_ERR IODEVRB1(ABC,7)
  123. #define ABC_MAP_MAC800_CFG IODEVL(ABC,8)
  124. #define ABC_MAP_MAC800_MAPS IODEVL(ABC,9)
  125. #define ABC_MAP_CFG IODEVL(ABC,10)
  126. #define ABC_MAP_CFG_MAP IODEVB0(ABC,10)
  127. #define ABC_MAP_CFG_SAM IODEVB1(ABC,10)
  128. /* n = 0 ... 511 for one of 8 64x1K maps */
  129. #define ABCMEMMAP_PAGE(n) IODEVL(ABCMEMMAP,n)
  130. #define ABCMEMMAP_MAPS 8
  131. #define ABCMEMMAP_PAGE_SHIFT 10
  132. #define ABCMEMMAP_PAGE_SIZE (1 << ABCMEMMAP_PAGE_SHIFT)
  133. #define ABCMEMMAP_PAGE_MASK (0xffff & ~(ABCMEMMAP_PAGE_SIZE-1))
  134. #define ABCMEMMAP_PAGE_COUNT ((0x10000 >> ABCMEMMAP_PAGE_SHIFT) \
  135. * ABCMEMMAP_MAPS)
  136. #define ABCMEMMAP_WR 1
  137. #define ABCMEMMAP_RD 2
  138. #define ABCMEMMAP_XM 4
  139. #define RANDOM_DATA IODEVRL(RANDOM,0)
  140. #define ESP_CPU_IRQ IODEVL(ESP,0)
  141. #define ESP_CPU_IRQ_CLR IODEVL(ESP,1)
  142. #define ESP_SPI_IRQ IODEVL(ESP,2)
  143. #define ESP_SPI_IRQ_SET IODEVL(ESP,3)
  144. #define ESP_TIMESTAMP IODEVRL(ESP,4)
  145. #define VJTAG_CPUCMD IODEVRL(VJTAG,0)
  146. #define VJTAG_CPUINFO IODEVL(VJTAG,1)
  147. #define VJTAG_CPUSTATUS IODEVL(VJTAG,2)
  148. #define VJTAG_CPUSTATUS_SET IODEVL(VJTAG,3)
  149. #define USBDESC_ROM IODEVL(USBDESC,0)
  150. #define usbdesc_rom PTR(USBDESC_ROM)
  151. #define DIRTY_PAGE_REG IODEVL(DIRTY,0)
  152. #endif /* IODEV_H */