2
0

ioregs.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. #ifndef IODEV_H
  2. #define IODEV_H
  3. #include "compiler.h"
  4. #include "iodevs.h"
  5. #include "iodeva.h"
  6. #define CPU_HZ 84000000
  7. #define TIMER_HZ (1 << TIMER_SHIFT)
  8. /* Basic system registers */
  9. #define SYS_MAGIC IODEVRL(SYS,0)
  10. #define SYS_BOARDCFG IODEVRL(SYS,1)
  11. #define SYS_BOARDFIX IODEVRB0(SYS,1)
  12. #define SYS_BOARDMINOR IODEVRB1(SYS,1)
  13. #define SYS_BOARDMAJOR IODEVRB2(SYS,1)
  14. #define SYS_BOARDFPGA IODEVRB3(SYS,1)
  15. #define SYS_LED IODEVL(SYS,2)
  16. #define SYS_RESET IODEVL(SYS,3)
  17. #define SYS_RESET_SOFT 1
  18. #define SYS_RESET_HARD 2
  19. #define SYS_RESET_RECONFIG 3
  20. #define SYS_EOI IODEVL(SYS,4)
  21. #define ROMCOPY_RAMADDR IODEVL(ROMCOPY,0)
  22. #define ROMCOPY_ROMCMD IODEVL(ROMCOPY,1)
  23. #define ROMCOPY_DATALEN IODEVL(ROMCOPY,2)
  24. #define ROMCOPY_SPI_CMDLEN(x) ((x) << 24)
  25. #define ROMCOPY_ZERO_BUFFER ROMCOPY_SPI_CMDLEN(0)
  26. #define ROMCOPY_SPI_DUAL (1 << 27)
  27. #define ROMCOPY_SPI_MORE (1 << 28)
  28. #define ROMCOPY_WRITE_RAM (1 << 29)
  29. #define ROMCOPY_STATUS IODEVRL(ROMCOPY,3)
  30. #define ROMCOPY_INPUT IODEVRL(ROMCOPY,4)
  31. #define ROMCOPY_STATUS_DONE 1
  32. /* n = 0...7 */
  33. #define TTY_DATA(n) IODEVB(TTY,0+((n) << 2))
  34. #define TTY_WATERCTL(n) IODEVH0(TTY,1+((n) << 2))
  35. #define TTY_WATERCTL_TX_LOW(x) ((x) << 0)
  36. #define TTY_WATERCTL_TX_HIGH(x) ((x) << 4)
  37. #define TTY_WATERCTL_RX_LOW(x) ((x) << 8)
  38. #define TTY_WATERCTL_RX_HIGH(x) ((x) << 12)
  39. #define TTY_STATUS(n) IODEVH0(TTY,2+((n) << 2))
  40. #define TTY_STATUS_TX_EMPTY 0x0001
  41. #define TTY_STATUS_TX_LOW 0x0002
  42. #define TTY_STATUS_TX_HIGH 0x0004
  43. #define TTY_STATUS_TX_FULL 0x0008
  44. #define TTY_STATUS_RX_EMPTY 0x0010
  45. #define TTY_STATUS_RX_LOW 0x0020
  46. #define TTY_STATUS_RX_HIGH 0x0040
  47. #define TTY_STATUS_RX_FULL 0x0080
  48. #define TTY_STATUS_RX_STALE 0x0100
  49. #define TTY_STATUS_RX_BREAK 0x0200
  50. #define TTY_STATUS_USB_CONFIG 0x0400
  51. #define TTY_STATUS_DTR_IN 0x0800
  52. #define TTY_STATUS_RTS_IN 0x1000
  53. #define TTY_IRQEN(n) IODEVH0(TTY,3+((n) << 2))
  54. #define TTY_IRQPOL(n) IODEVH1(TTY,3+((n) << 2))
  55. #define TTY_CHANNEL_MASK ((1U << TTY_CHANNELS) - 1)
  56. #define TTY_IRQ_MASK (TTY_CHANNEL_MASK << TTY_IRQ)
  57. #define TTY_NIRQ(n) (TTY_IRQ+(n))
  58. #define CON_DATA TTY_DATA(0)
  59. #define CON_WATERCTL TTY_WATERCTL(0)
  60. #define CON_STATUS TTY_STATUS(0)
  61. #define CON_IRQEN TTY_IRQEN(0)
  62. #define CON_IRQ TTY_NIRQ(0)
  63. #define SDCARD_CTL IODEVL(SDCARD,0)
  64. #define SDCARD_CTL_SPEED IODEVB0(SDCARD,0)
  65. #define SDCARD_CTL_IRQEN IODEVB1(SDCARD,0)
  66. #define SDCARD_CTL_CLRCRC IODEVB2(SDCARD,0)
  67. #define SDCARD_CRC7_RD IODEVRB0(SDCARD,4)
  68. #define SDCARD_CRC16_RD IODEVRH1(SDCARD,4)
  69. #define SDCARD_CRC7_WR IODEVRB0(SDCARD,5)
  70. #define SDCARD_CRC16_WR IODEVRH1(SDCARD,5)
  71. #define SDCARD_IRQ_READY 1
  72. #define SDCARD_IRQ_CD 2
  73. #define SDCARD_IRQ_EXT 4
  74. /* Speed values, not including -1 adjustment */
  75. #define SD_SLOW 128 /* 328 kHz */
  76. #define SD_20MHZ 3 /* Really 14 MHz */
  77. #define SD_25MHZ 2 /* Really 21 MHz */
  78. #define SD_50MHZ 1 /* Really 42 MHz */
  79. #define I2C_WDATA IODEVL(I2C,0)
  80. #define I2C_WDATA_DATA IODEVB1(I2C,0)
  81. #define I2C_RDATA IODEVL(I2C,1)
  82. #define I2C_RDATA_DATA IODEVB1(I2C,1)
  83. #define I2C_BUSY 1
  84. #define I2C_SR 2
  85. #define I2C_P 4
  86. #define I2C_DUMMY 6
  87. #define I2C_STARTED 0x10
  88. #define I2C_SCL 0x20
  89. #define I2C_SDA 0x40
  90. #define I2C_NAK 0x80
  91. #define I2C_DIVISOR IODEVL(I2C,2)
  92. #define SYSCLOCK_DATETIME IODEVL(SYSCLOCK,0)
  93. #define SYSCLOCK_TICK IODEVL(SYSCLOCK,1)
  94. #define SYSCLOCK_TICK_HOLD IODEVH0(SYSCLOCK,1)
  95. #define SYSCLOCK_TICK_NOW IODEVH1(SYSCLOCK,1)
  96. #define ABC_STATUS IODEVL(ABC,0)
  97. #define ABC_STATUS_LIVE 1
  98. #define ABC_STATUS_RST 2
  99. #define ABC_STATUS_800 4
  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. /* n = 0 ... 511 */
  124. #define ABCMEMMAP_PAGE(n) IODEVL(ABCMEMMAP,n)
  125. /* n = 0 ... 255 */
  126. #define ABCMEMMAP_WRPORT(n) IODEVL(ABCMEMMAP,128+((n) << 1))
  127. #define ABCMEMMAP_RDPORT(n) IODEVL(ABCMEMMAP,129+((n) << 1))
  128. #define ABCMEMMAP_WRCOUNT(n) IODEVL(ABCMEMMAP,384+((n) << 1))
  129. #define ABCMEMMAP_RDCOUNT(n) IODEVL(ABCMEMMAP,385+((n) << 1))
  130. #define ABCMEMMAP_WR (1 << 30)
  131. #define ABCMEMMAP_RD (1 << 31)
  132. #define ABCMEMMAP_STATUS(n) IODEVL(ABCMEMMAP,512+(n))
  133. #define ABCMEMMAP_CLR7DMA 0x800
  134. #define ABCMEMMAP_CLR1WEMP 0x400
  135. #define ABCMEMMAP_CLR0WEMP 0x200
  136. #define ABCMEMMAP_CLR0REMP 0x100
  137. #define RANDOM_DATA IODEVRL(RANDOM,0)
  138. #define ESP_CPU_IRQ IODEVL(ESP,0)
  139. #define ESP_CPU_IRQ_CLR IODEVL(ESP,1)
  140. #define ESP_SPI_IRQ IODEVL(ESP,2)
  141. #define ESP_SPI_IRQ_SET IODEVL(ESP,3)
  142. #define ESP_TIMESTAMP IODEVRL(ESP,4)
  143. #define VJTAG_CPUCMD IODEVRL(VJTAG,0)
  144. #define VJTAG_CPUINFO IODEVL(VJTAG,1)
  145. #define VJTAG_CPUSTATUS IODEVL(VJTAG,2)
  146. #define VJTAG_CPUSTATUS_SET IODEVL(VJTAG,3)
  147. #define USBDESC_ROM IODEVL(USBDESC,0)
  148. #define usbdesc_rom PTR(USBDESC_ROM)
  149. #endif /* IODEV_H */