debug_uart.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _DEBUG_UART_H_
  13. #define _DEBUG_UART_H_
  14. // Auto generated by dtools(see dtools.txt for its version).
  15. // Don't edit it manually!
  16. #define DEBUG_UART_RX_FIFO_SIZE (16)
  17. #define DEBUG_UART_TX_FIFO_SIZE (16)
  18. #define DEBUG_UART_NB_RX_FIFO_BITS (4)
  19. #define DEBUG_UART_NB_TX_FIFO_BITS (4)
  20. #define ESC_DAT (92)
  21. #define REG_DEBUG_UART_BASE (0x51402000)
  22. typedef volatile struct
  23. {
  24. uint32_t ctrl; // 0x00000000
  25. uint32_t status; // 0x00000004
  26. uint32_t rxtx_buffer; // 0x00000008
  27. uint32_t irq_mask; // 0x0000000c
  28. uint32_t irq_cause; // 0x00000010
  29. uint32_t triggers; // 0x00000014
  30. uint32_t xchar; // 0x00000018
  31. } HWP_DEBUG_UART_T;
  32. #define hwp_debugUart ((HWP_DEBUG_UART_T *)REG_ACCESS_ADDRESS(REG_DEBUG_UART_BASE))
  33. // ctrl
  34. typedef union {
  35. uint32_t v;
  36. struct
  37. {
  38. uint32_t enable : 1; // [0]
  39. uint32_t data_bits : 1; // [1]
  40. uint32_t tx_stop_bits : 1; // [2]
  41. uint32_t parity_enable : 1; // [3]
  42. uint32_t parity_select : 2; // [5:4]
  43. uint32_t tx_break_control : 1; // [6]
  44. uint32_t rx_fifo_reset : 1; // [7]
  45. uint32_t tx_fifo_reset : 1; // [8]
  46. uint32_t dma_mode : 1; // [9]
  47. uint32_t __11_10 : 2; // [11:10]
  48. uint32_t swrx_flow_ctrl : 2; // [13:12]
  49. uint32_t swtx_flow_ctrl : 2; // [15:14]
  50. uint32_t backslash_en : 1; // [16]
  51. uint32_t __18_17 : 2; // [18:17]
  52. uint32_t tx_finish_n_wait : 1; // [19]
  53. uint32_t divisor_mode : 1; // [20]
  54. uint32_t irda_enable : 1; // [21]
  55. uint32_t rx_rts : 1; // [22]
  56. uint32_t auto_flow_control : 1; // [23]
  57. uint32_t loop_back_mode : 1; // [24]
  58. uint32_t rx_lock_err : 1; // [25]
  59. uint32_t hst_txd_oen : 1; // [26]
  60. uint32_t __27_27 : 1; // [27]
  61. uint32_t rx_break_length : 4; // [31:28]
  62. } b;
  63. } REG_DEBUG_UART_CTRL_T;
  64. // status
  65. typedef union {
  66. uint32_t v;
  67. struct
  68. {
  69. uint32_t rx_fifo_level : 5; // [4:0], read only
  70. uint32_t __7_5 : 3; // [7:5]
  71. uint32_t tx_fifo_level : 5; // [12:8], read only
  72. uint32_t tx_active : 1; // [13], read only
  73. uint32_t rx_active : 1; // [14], read only
  74. uint32_t __15_15 : 1; // [15]
  75. uint32_t rx_overflow_err : 1; // [16], read only
  76. uint32_t tx_overflow_err : 1; // [17], read only
  77. uint32_t rx_parity_err : 1; // [18], read only
  78. uint32_t rx_framing_err : 1; // [19], read only
  79. uint32_t rx_break_int : 1; // [20], read only
  80. uint32_t __23_21 : 3; // [23:21]
  81. uint32_t tx_dcts : 1; // [24], read only
  82. uint32_t tx_cts : 1; // [25], read only
  83. uint32_t __27_26 : 2; // [27:26]
  84. uint32_t tx_fifo_rsted_l : 1; // [28], read only
  85. uint32_t rx_fifo_rsted_l : 1; // [29], read only
  86. uint32_t enable_n_finished : 1; // [30], read only
  87. uint32_t clk_enabled : 1; // [31], read only
  88. } b;
  89. } REG_DEBUG_UART_STATUS_T;
  90. // rxtx_buffer
  91. typedef union {
  92. uint32_t v;
  93. struct
  94. {
  95. uint32_t rx_data : 8; // [7:0], read only
  96. uint32_t tx_data : 8; // [7:0]
  97. uint32_t __31_8 : 24; // [31:8]
  98. } b;
  99. } REG_DEBUG_UART_RXTX_BUFFER_T;
  100. // irq_mask
  101. typedef union {
  102. uint32_t v;
  103. struct
  104. {
  105. uint32_t tx_modem_status : 1; // [0]
  106. uint32_t rx_data_available : 1; // [1]
  107. uint32_t tx_data_needed : 1; // [2]
  108. uint32_t rx_timeout : 1; // [3]
  109. uint32_t rx_line_err : 1; // [4]
  110. uint32_t tx_dma_done : 1; // [5]
  111. uint32_t rx_dma_done : 1; // [6]
  112. uint32_t rx_dma_timeout : 1; // [7]
  113. uint32_t xoff_detected : 1; // [8]
  114. uint32_t __31_9 : 23; // [31:9]
  115. } b;
  116. } REG_DEBUG_UART_IRQ_MASK_T;
  117. // irq_cause
  118. typedef union {
  119. uint32_t v;
  120. struct
  121. {
  122. uint32_t tx_modem_status : 1; // [0], read only
  123. uint32_t rx_data_available : 1; // [1], read only
  124. uint32_t tx_data_needed : 1; // [2], read only
  125. uint32_t rx_timeout : 1; // [3], read only
  126. uint32_t rx_line_err : 1; // [4], read only
  127. uint32_t tx_dma_done : 1; // [5]
  128. uint32_t rx_dma_done : 1; // [6]
  129. uint32_t rx_dma_timeout : 1; // [7]
  130. uint32_t __15_8 : 8; // [15:8]
  131. uint32_t tx_modem_status_u : 1; // [16], read only
  132. uint32_t rx_data_available_u : 1; // [17], read only
  133. uint32_t tx_data_needed_u : 1; // [18], read only
  134. uint32_t rx_timeout_u : 1; // [19], read only
  135. uint32_t rx_line_err_u : 1; // [20], read only
  136. uint32_t tx_dma_done_u : 1; // [21], read only
  137. uint32_t rx_dma_done_u : 1; // [22], read only
  138. uint32_t rx_dma_timeout_u : 1; // [23], read only
  139. uint32_t __31_24 : 8; // [31:24]
  140. } b;
  141. } REG_DEBUG_UART_IRQ_CAUSE_T;
  142. // triggers
  143. typedef union {
  144. uint32_t v;
  145. struct
  146. {
  147. uint32_t rx_trigger : 4; // [3:0]
  148. uint32_t tx_trigger : 4; // [7:4]
  149. uint32_t afc_level : 4; // [11:8]
  150. uint32_t __31_12 : 20; // [31:12]
  151. } b;
  152. } REG_DEBUG_UART_TRIGGERS_T;
  153. // xchar
  154. typedef union {
  155. uint32_t v;
  156. struct
  157. {
  158. uint32_t xon1 : 8; // [7:0]
  159. uint32_t xoff1 : 8; // [15:8]
  160. uint32_t xon2 : 8; // [23:16]
  161. uint32_t xoff2 : 8; // [31:24]
  162. } b;
  163. } REG_DEBUG_UART_XCHAR_T;
  164. // ctrl
  165. #define DEBUG_UART_ENABLE_DISABLE (0 << 0)
  166. #define DEBUG_UART_ENABLE_ENABLE (1 << 0)
  167. #define DEBUG_UART_DATA_BITS_7_BITS (0 << 1)
  168. #define DEBUG_UART_DATA_BITS_8_BITS (1 << 1)
  169. #define DEBUG_UART_TX_STOP_BITS_1_BIT (0 << 2)
  170. #define DEBUG_UART_TX_STOP_BITS_2_BITS (1 << 2)
  171. #define DEBUG_UART_PARITY_ENABLE_NO (0 << 3)
  172. #define DEBUG_UART_PARITY_ENABLE_YES (1 << 3)
  173. #define DEBUG_UART_PARITY_SELECT(n) (((n)&0x3) << 4)
  174. #define DEBUG_UART_PARITY_SELECT_ODD (0 << 4)
  175. #define DEBUG_UART_PARITY_SELECT_EVEN (1 << 4)
  176. #define DEBUG_UART_PARITY_SELECT_SPACE (2 << 4)
  177. #define DEBUG_UART_PARITY_SELECT_MARK (3 << 4)
  178. #define DEBUG_UART_TX_BREAK_CONTROL_OFF (0 << 6)
  179. #define DEBUG_UART_TX_BREAK_CONTROL_ON (1 << 6)
  180. #define DEBUG_UART_RX_FIFO_RESET (1 << 7)
  181. #define DEBUG_UART_TX_FIFO_RESET (1 << 8)
  182. #define DEBUG_UART_DMA_MODE_DISABLE (0 << 9)
  183. #define DEBUG_UART_DMA_MODE_ENABLE (1 << 9)
  184. #define DEBUG_UART_SWRX_FLOW_CTRL(n) (((n)&0x3) << 12)
  185. #define DEBUG_UART_SWTX_FLOW_CTRL(n) (((n)&0x3) << 14)
  186. #define DEBUG_UART_BACKSLASH_EN (1 << 16)
  187. #define DEBUG_UART_TX_FINISH_N_WAIT (1 << 19)
  188. #define DEBUG_UART_DIVISOR_MODE (1 << 20)
  189. #define DEBUG_UART_IRDA_ENABLE (1 << 21)
  190. #define DEBUG_UART_RX_RTS_INACTIVE (0 << 22)
  191. #define DEBUG_UART_RX_RTS_ACTIVE (1 << 22)
  192. #define DEBUG_UART_AUTO_FLOW_CONTROL_ENABLE (1 << 23)
  193. #define DEBUG_UART_AUTO_FLOW_CONTROL_DISABLE (0 << 23)
  194. #define DEBUG_UART_LOOP_BACK_MODE (1 << 24)
  195. #define DEBUG_UART_RX_LOCK_ERR_DISABLE (0 << 25)
  196. #define DEBUG_UART_RX_LOCK_ERR_ENABLE (1 << 25)
  197. #define DEBUG_UART_HST_TXD_OEN_DISABLE (1 << 26)
  198. #define DEBUG_UART_HST_TXD_OEN_ENABLE (0 << 26)
  199. #define DEBUG_UART_RX_BREAK_LENGTH(n) (((n)&0xf) << 28)
  200. #define DEBUG_UART_ENABLE_V_DISABLE (0)
  201. #define DEBUG_UART_ENABLE_V_ENABLE (1)
  202. #define DEBUG_UART_DATA_BITS_V_7_BITS (0)
  203. #define DEBUG_UART_DATA_BITS_V_8_BITS (1)
  204. #define DEBUG_UART_TX_STOP_BITS_V_1_BIT (0)
  205. #define DEBUG_UART_TX_STOP_BITS_V_2_BITS (1)
  206. #define DEBUG_UART_PARITY_ENABLE_V_NO (0)
  207. #define DEBUG_UART_PARITY_ENABLE_V_YES (1)
  208. #define DEBUG_UART_PARITY_SELECT_V_ODD (0)
  209. #define DEBUG_UART_PARITY_SELECT_V_EVEN (1)
  210. #define DEBUG_UART_PARITY_SELECT_V_SPACE (2)
  211. #define DEBUG_UART_PARITY_SELECT_V_MARK (3)
  212. #define DEBUG_UART_TX_BREAK_CONTROL_V_OFF (0)
  213. #define DEBUG_UART_TX_BREAK_CONTROL_V_ON (1)
  214. #define DEBUG_UART_DMA_MODE_V_DISABLE (0)
  215. #define DEBUG_UART_DMA_MODE_V_ENABLE (1)
  216. #define DEBUG_UART_RX_RTS_V_INACTIVE (0)
  217. #define DEBUG_UART_RX_RTS_V_ACTIVE (1)
  218. #define DEBUG_UART_AUTO_FLOW_CONTROL_V_ENABLE (1)
  219. #define DEBUG_UART_AUTO_FLOW_CONTROL_V_DISABLE (0)
  220. #define DEBUG_UART_RX_LOCK_ERR_V_DISABLE (0)
  221. #define DEBUG_UART_RX_LOCK_ERR_V_ENABLE (1)
  222. #define DEBUG_UART_HST_TXD_OEN_V_DISABLE (1)
  223. #define DEBUG_UART_HST_TXD_OEN_V_ENABLE (0)
  224. // status
  225. #define DEBUG_UART_RX_FIFO_LEVEL(n) (((n)&0x1f) << 0)
  226. #define DEBUG_UART_TX_FIFO_LEVEL(n) (((n)&0x1f) << 8)
  227. #define DEBUG_UART_TX_ACTIVE (1 << 13)
  228. #define DEBUG_UART_RX_ACTIVE (1 << 14)
  229. #define DEBUG_UART_RX_OVERFLOW_ERR (1 << 16)
  230. #define DEBUG_UART_TX_OVERFLOW_ERR (1 << 17)
  231. #define DEBUG_UART_RX_PARITY_ERR (1 << 18)
  232. #define DEBUG_UART_RX_FRAMING_ERR (1 << 19)
  233. #define DEBUG_UART_RX_BREAK_INT (1 << 20)
  234. #define DEBUG_UART_TX_DCTS (1 << 24)
  235. #define DEBUG_UART_TX_CTS (1 << 25)
  236. #define DEBUG_UART_TX_FIFO_RSTED_L (1 << 28)
  237. #define DEBUG_UART_RX_FIFO_RSTED_L (1 << 29)
  238. #define DEBUG_UART_ENABLE_N_FINISHED (1 << 30)
  239. #define DEBUG_UART_CLK_ENABLED (1 << 31)
  240. // rxtx_buffer
  241. #define DEBUG_UART_RX_DATA(n) (((n)&0xff) << 0)
  242. #define DEBUG_UART_TX_DATA(n) (((n)&0xff) << 0)
  243. // irq_mask
  244. #define DEBUG_UART_TX_MODEM_STATUS (1 << 0)
  245. #define DEBUG_UART_RX_DATA_AVAILABLE (1 << 1)
  246. #define DEBUG_UART_TX_DATA_NEEDED (1 << 2)
  247. #define DEBUG_UART_RX_TIMEOUT (1 << 3)
  248. #define DEBUG_UART_RX_LINE_ERR (1 << 4)
  249. #define DEBUG_UART_TX_DMA_DONE (1 << 5)
  250. #define DEBUG_UART_RX_DMA_DONE (1 << 6)
  251. #define DEBUG_UART_RX_DMA_TIMEOUT (1 << 7)
  252. #define DEBUG_UART_XOFF_DETECTED (1 << 8)
  253. // irq_cause
  254. #define DEBUG_UART_TX_MODEM_STATUS (1 << 0)
  255. #define DEBUG_UART_RX_DATA_AVAILABLE (1 << 1)
  256. #define DEBUG_UART_TX_DATA_NEEDED (1 << 2)
  257. #define DEBUG_UART_RX_TIMEOUT (1 << 3)
  258. #define DEBUG_UART_RX_LINE_ERR (1 << 4)
  259. #define DEBUG_UART_TX_DMA_DONE (1 << 5)
  260. #define DEBUG_UART_RX_DMA_DONE (1 << 6)
  261. #define DEBUG_UART_RX_DMA_TIMEOUT (1 << 7)
  262. #define DEBUG_UART_TX_MODEM_STATUS_U (1 << 16)
  263. #define DEBUG_UART_RX_DATA_AVAILABLE_U (1 << 17)
  264. #define DEBUG_UART_TX_DATA_NEEDED_U (1 << 18)
  265. #define DEBUG_UART_RX_TIMEOUT_U (1 << 19)
  266. #define DEBUG_UART_RX_LINE_ERR_U (1 << 20)
  267. #define DEBUG_UART_TX_DMA_DONE_U (1 << 21)
  268. #define DEBUG_UART_RX_DMA_DONE_U (1 << 22)
  269. #define DEBUG_UART_RX_DMA_TIMEOUT_U (1 << 23)
  270. // triggers
  271. #define DEBUG_UART_RX_TRIGGER(n) (((n)&0xf) << 0)
  272. #define DEBUG_UART_TX_TRIGGER(n) (((n)&0xf) << 4)
  273. #define DEBUG_UART_AFC_LEVEL(n) (((n)&0xf) << 8)
  274. // xchar
  275. #define DEBUG_UART_XON1(n) (((n)&0xff) << 0)
  276. #define DEBUG_UART_XOFF1(n) (((n)&0xff) << 8)
  277. #define DEBUG_UART_XON2(n) (((n)&0xff) << 16)
  278. #define DEBUG_UART_XOFF2(n) (((n)&0xff) << 24)
  279. #endif // _DEBUG_UART_H_