uhci_struct.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef _SOC_UHCI_STRUCT_H_
  14. #define _SOC_UHCI_STRUCT_H_
  15. typedef volatile struct {
  16. union {
  17. struct {
  18. uint32_t in_rst: 1; /*Set this bit to reset in link operations.*/
  19. uint32_t out_rst: 1; /*Set this bit to reset out link operations.*/
  20. uint32_t ahbm_fifo_rst: 1; /*Set this bit to reset dma ahb fifo.*/
  21. uint32_t ahbm_rst: 1; /*Set this bit to reset dma ahb interface.*/
  22. uint32_t in_loop_test: 1; /*Set this bit to enable loop test for in links.*/
  23. uint32_t out_loop_test: 1; /*Set this bit to enable loop test for out links.*/
  24. uint32_t out_auto_wrback: 1; /*when in link's length is 0 go on to use the next in link automatically.*/
  25. uint32_t out_no_restart_clr: 1; /*don't use*/
  26. uint32_t out_eof_mode: 1; /*Set this bit to produce eof after DMA pops all data clear this bit to produce eof after DMA pushes all data*/
  27. uint32_t uart0_ce: 1; /*Set this bit to use UART to transmit or receive data.*/
  28. uint32_t uart1_ce: 1; /*Set this bit to use UART1 to transmit or receive data.*/
  29. uint32_t uart2_ce: 1; /*Set this bit to use UART2 to transmit or receive data.*/
  30. uint32_t outdscr_burst_en: 1; /*Set this bit to enable DMA in links to use burst mode.*/
  31. uint32_t indscr_burst_en: 1; /*Set this bit to enable DMA out links to use burst mode.*/
  32. uint32_t out_data_burst_en: 1; /*Set this bit to enable DMA burst MODE*/
  33. uint32_t mem_trans_en: 1;
  34. uint32_t seper_en: 1; /*Set this bit to use special char to separate the data frame.*/
  35. uint32_t head_en: 1; /*Set this bit to enable to use head packet before the data frame.*/
  36. uint32_t crc_rec_en: 1; /*Set this bit to enable receiver''s ability of crc calculation when crc_en bit in head packet is 1 then there will be crc bytes after data_frame*/
  37. uint32_t uart_idle_eof_en: 1; /*Set this bit to enable to use idle time when the idle time after data frame is satisfied this means the end of a data frame.*/
  38. uint32_t len_eof_en: 1; /*Set this bit to enable to use packet_len in packet head when the received data is equal to packet_len this means the end of a data frame.*/
  39. uint32_t encode_crc_en: 1; /*Set this bit to enable crc calculation for data frame when bit6 in the head packet is 1.*/
  40. uint32_t clk_en: 1; /*Set this bit to enable clock-gating for read or write registers.*/
  41. uint32_t uart_rx_brk_eof_en: 1; /*Set this bit to enable to use brk char as the end of a data frame.*/
  42. uint32_t reserved24: 8;
  43. };
  44. uint32_t val;
  45. } conf0;
  46. union {
  47. struct {
  48. uint32_t rx_start: 1; /*when a separator char has been send it will produce uhci_rx_start_int interrupt.*/
  49. uint32_t tx_start: 1; /*when DMA detects a separator char it will produce uhci_tx_start_int interrupt.*/
  50. uint32_t rx_hung: 1; /*when DMA takes a lot of time to receive a data it will produce uhci_rx_hung_int interrupt.*/
  51. uint32_t tx_hung: 1; /*when DMA takes a lot of time to read a data from RAM it will produce uhci_tx_hung_int interrupt.*/
  52. uint32_t in_done: 1; /*when a in link descriptor has been completed it will produce uhci_in_done_int interrupt.*/
  53. uint32_t in_suc_eof: 1; /*when a data packet has been received it will produce uhci_in_suc_eof_int interrupt.*/
  54. uint32_t in_err_eof: 1; /*when there are some errors about eof in in link descriptor it will produce uhci_in_err_eof_int interrupt.*/
  55. uint32_t out_done: 1; /*when a out link descriptor is completed it will produce uhci_out_done_int interrupt.*/
  56. uint32_t out_eof: 1; /*when the current descriptor's eof bit is 1 it will produce uhci_out_eof_int interrupt.*/
  57. uint32_t in_dscr_err: 1; /*when there are some errors about the out link descriptor it will produce uhci_in_dscr_err_int interrupt.*/
  58. uint32_t out_dscr_err: 1; /*when there are some errors about the in link descriptor it will produce uhci_out_dscr_err_int interrupt.*/
  59. uint32_t in_dscr_empty: 1; /*when there are not enough in links for DMA it will produce uhci_in_dscr_err_int interrupt.*/
  60. uint32_t outlink_eof_err: 1; /*when there are some errors about eof in outlink descriptor it will produce uhci_outlink_eof_err_int interrupt.*/
  61. uint32_t out_total_eof: 1; /*When all data have been send it will produce uhci_out_total_eof_int interrupt.*/
  62. uint32_t send_s_q: 1; /*When use single send registers to send a short packets it will produce this interrupt when dma has send the short packet.*/
  63. uint32_t send_a_q: 1; /*When use always_send registers to send a series of short packets it will produce this interrupt when dma has send the short packet.*/
  64. uint32_t dma_in_fifo_full_wm: 1;
  65. uint32_t reserved17: 15;
  66. };
  67. uint32_t val;
  68. } int_raw;
  69. union {
  70. struct {
  71. uint32_t rx_start: 1;
  72. uint32_t tx_start: 1;
  73. uint32_t rx_hung: 1;
  74. uint32_t tx_hung: 1;
  75. uint32_t in_done: 1;
  76. uint32_t in_suc_eof: 1;
  77. uint32_t in_err_eof: 1;
  78. uint32_t out_done: 1;
  79. uint32_t out_eof: 1;
  80. uint32_t in_dscr_err: 1;
  81. uint32_t out_dscr_err: 1;
  82. uint32_t in_dscr_empty: 1;
  83. uint32_t outlink_eof_err: 1;
  84. uint32_t out_total_eof: 1;
  85. uint32_t send_s_q: 1;
  86. uint32_t send_a_q: 1;
  87. uint32_t dma_in_fifo_full_wm: 1;
  88. uint32_t reserved17: 15;
  89. };
  90. uint32_t val;
  91. } int_st;
  92. union {
  93. struct {
  94. uint32_t rx_start: 1;
  95. uint32_t tx_start: 1;
  96. uint32_t rx_hung: 1;
  97. uint32_t tx_hung: 1;
  98. uint32_t in_done: 1;
  99. uint32_t in_suc_eof: 1;
  100. uint32_t in_err_eof: 1;
  101. uint32_t out_done: 1;
  102. uint32_t out_eof: 1;
  103. uint32_t in_dscr_err: 1;
  104. uint32_t out_dscr_err: 1;
  105. uint32_t in_dscr_empty: 1;
  106. uint32_t outlink_eof_err: 1;
  107. uint32_t out_total_eof: 1;
  108. uint32_t send_s_q: 1;
  109. uint32_t send_a_q: 1;
  110. uint32_t dma_in_fifo_full_wm: 1;
  111. uint32_t reserved17: 15;
  112. };
  113. uint32_t val;
  114. } int_ena;
  115. union {
  116. struct {
  117. uint32_t rx_start: 1;
  118. uint32_t tx_start: 1;
  119. uint32_t rx_hung: 1;
  120. uint32_t tx_hung: 1;
  121. uint32_t in_done: 1;
  122. uint32_t in_suc_eof: 1;
  123. uint32_t in_err_eof: 1;
  124. uint32_t out_done: 1;
  125. uint32_t out_eof: 1;
  126. uint32_t in_dscr_err: 1;
  127. uint32_t out_dscr_err: 1;
  128. uint32_t in_dscr_empty: 1;
  129. uint32_t outlink_eof_err: 1;
  130. uint32_t out_total_eof: 1;
  131. uint32_t send_s_q: 1;
  132. uint32_t send_a_q: 1;
  133. uint32_t dma_in_fifo_full_wm: 1;
  134. uint32_t reserved17: 15;
  135. };
  136. uint32_t val;
  137. } int_clr;
  138. union {
  139. struct {
  140. uint32_t full: 1; /*1:DMA out link descriptor's fifo is full.*/
  141. uint32_t empty: 1; /*1:DMA in link descriptor's fifo is empty.*/
  142. uint32_t reserved2: 30;
  143. };
  144. uint32_t val;
  145. } dma_out_status;
  146. union {
  147. struct {
  148. uint32_t fifo_wdata: 9; /*This is the data need to be pushed into out link descriptor's fifo.*/
  149. uint32_t reserved9: 7;
  150. uint32_t fifo_push: 1; /*Set this bit to push data in out link descriptor's fifo.*/
  151. uint32_t reserved17:15;
  152. };
  153. uint32_t val;
  154. } dma_out_push;
  155. union {
  156. struct {
  157. uint32_t full: 1;
  158. uint32_t empty: 1;
  159. uint32_t reserved2: 2;
  160. uint32_t rx_err_cause: 3; /*This register stores the errors caused in out link descriptor's data packet.*/
  161. uint32_t reserved7: 25;
  162. };
  163. uint32_t val;
  164. } dma_in_status;
  165. union {
  166. struct {
  167. uint32_t fifo_rdata: 12; /*This register stores the data pop from in link descriptor's fifo.*/
  168. uint32_t reserved12: 4;
  169. uint32_t fifo_pop: 1; /*Set this bit to pop data in in link descriptor's fifo.*/
  170. uint32_t reserved17: 15;
  171. };
  172. uint32_t val;
  173. } dma_in_pop;
  174. union {
  175. struct {
  176. uint32_t addr: 20; /*This register stores the least 20 bits of the first out link descriptor's address.*/
  177. uint32_t reserved20: 8;
  178. uint32_t stop: 1; /*Set this bit to stop dealing with the out link descriptors.*/
  179. uint32_t start: 1; /*Set this bit to start dealing with the out link descriptors.*/
  180. uint32_t restart: 1; /*Set this bit to mount on new out link descriptors*/
  181. uint32_t park: 1; /*1: the out link descriptor's fsm is in idle state. 0:the out link descriptor's fsm is working.*/
  182. };
  183. uint32_t val;
  184. } dma_out_link;
  185. union {
  186. struct {
  187. uint32_t addr: 20; /*This register stores the least 20 bits of the first in link descriptor's address.*/
  188. uint32_t auto_ret: 1; /*1:when a packet is wrong in link descriptor returns to the descriptor which is lately used.*/
  189. uint32_t reserved21: 7;
  190. uint32_t stop: 1; /*Set this bit to stop dealing with the in link descriptors.*/
  191. uint32_t start: 1; /*Set this bit to start dealing with the in link descriptors.*/
  192. uint32_t restart: 1; /*Set this bit to mount on new in link descriptors*/
  193. uint32_t park: 1; /*1:the in link descriptor's fsm is in idle state. 0:the in link descriptor's fsm is working*/
  194. };
  195. uint32_t val;
  196. } dma_in_link;
  197. union {
  198. struct {
  199. uint32_t check_sum_en: 1; /*Set this bit to enable decoder to check check_sum in packet header.*/
  200. uint32_t check_seq_en: 1; /*Set this bit to enable decoder to check seq num in packet header.*/
  201. uint32_t crc_disable: 1; /*Set this bit to disable crc calculation.*/
  202. uint32_t save_head: 1; /*Set this bit to save packet header .*/
  203. uint32_t tx_check_sum_re: 1; /*Set this bit to enable hardware replace check_sum in packet header automatically.*/
  204. uint32_t tx_ack_num_re: 1; /*Set this bit to enable hardware replace ack num in packet header automatically.*/
  205. uint32_t check_owner: 1; /*Set this bit to check the owner bit in link descriptor.*/
  206. uint32_t wait_sw_start: 1; /*Set this bit to enable software way to add packet header.*/
  207. uint32_t sw_start: 1; /*Set this bit to start inserting the packet header.*/
  208. uint32_t dma_in_fifo_full_thrs:12; /*when data amount in link descriptor's fifo is more than this register value it will produce uhci_dma_in_fifo_full_wm_int interrupt.*/
  209. uint32_t reserved21: 11;
  210. };
  211. uint32_t val;
  212. } conf1;
  213. uint32_t state0; /**/
  214. uint32_t state1; /**/
  215. uint32_t dma_out_eof_des_addr; /*This register stores the address of out link description when eof bit in this descriptor is 1.*/
  216. uint32_t dma_in_suc_eof_des_addr; /*This register stores the address of in link descriptor when eof bit in this descriptor is 1.*/
  217. uint32_t dma_in_err_eof_des_addr; /*This register stores the address of in link descriptor when there are some errors in this descriptor.*/
  218. uint32_t dma_out_eof_bfr_des_addr; /*This register stores the address of out link descriptor when there are some errors in this descriptor.*/
  219. union {
  220. struct {
  221. uint32_t test_mode: 3; /*bit2 is ahb bus test enable ,bit1 is used to choose write(1) or read(0) mode. bit0 is used to choose test only once(1) or continue(0)*/
  222. uint32_t reserved3: 1;
  223. uint32_t test_addr: 2; /*The two bits represent ahb bus address bit[20:19]*/
  224. uint32_t reserved6: 26;
  225. };
  226. uint32_t val;
  227. } ahb_test;
  228. uint32_t dma_in_dscr; /*The content of current in link descriptor's third dword*/
  229. uint32_t dma_in_dscr_bf0; /*The content of current in link descriptor's first dword*/
  230. uint32_t dma_in_dscr_bf1; /*The content of current in link descriptor's second dword*/
  231. uint32_t dma_out_dscr; /*The content of current out link descriptor's third dword*/
  232. uint32_t dma_out_dscr_bf0; /*The content of current out link descriptor's first dword*/
  233. uint32_t dma_out_dscr_bf1; /*The content of current out link descriptor's second dword*/
  234. union {
  235. struct {
  236. uint32_t tx_c0_esc_en: 1; /*Set this bit to enable 0xc0 char decode when DMA receives data.*/
  237. uint32_t tx_db_esc_en: 1; /*Set this bit to enable 0xdb char decode when DMA receives data.*/
  238. uint32_t tx_11_esc_en: 1; /*Set this bit to enable flow control char 0x11 decode when DMA receives data.*/
  239. uint32_t tx_13_esc_en: 1; /*Set this bit to enable flow control char 0x13 decode when DMA receives data.*/
  240. uint32_t rx_c0_esc_en: 1; /*Set this bit to enable 0xc0 char replace when DMA sends data.*/
  241. uint32_t rx_db_esc_en: 1; /*Set this bit to enable 0xdb char replace when DMA sends data.*/
  242. uint32_t rx_11_esc_en: 1; /*Set this bit to enable flow control char 0x11 replace when DMA sends data.*/
  243. uint32_t rx_13_esc_en: 1; /*Set this bit to enable flow control char 0x13 replace when DMA sends data.*/
  244. uint32_t reserved8: 24;
  245. };
  246. uint32_t val;
  247. } escape_conf;
  248. union {
  249. struct {
  250. uint32_t txfifo_timeout: 8; /*This register stores the timeout value.when DMA takes more time than this register value to receive a data it will produce uhci_tx_hung_int interrupt.*/
  251. uint32_t txfifo_timeout_shift: 3; /*The tick count is cleared when its value >=(17'd8000>>reg_txfifo_timeout_shift)*/
  252. uint32_t txfifo_timeout_ena: 1; /*The enable bit for tx fifo receive data timeout*/
  253. uint32_t rxfifo_timeout: 8; /*This register stores the timeout value.when DMA takes more time than this register value to read a data from RAM it will produce uhci_rx_hung_int interrupt.*/
  254. uint32_t rxfifo_timeout_shift: 3; /*The tick count is cleared when its value >=(17'd8000>>reg_rxfifo_timeout_shift)*/
  255. uint32_t rxfifo_timeout_ena: 1; /*This is the enable bit for DMA send data timeout*/
  256. uint32_t reserved24: 8;
  257. };
  258. uint32_t val;
  259. } hung_conf;
  260. uint32_t ack_num; /**/
  261. uint32_t rx_head; /*This register stores the packet header received by DMA*/
  262. union {
  263. struct {
  264. uint32_t single_send_num: 3; /*The bits are used to choose which short packet*/
  265. uint32_t single_send_en: 1; /*Set this bit to enable send a short packet*/
  266. uint32_t always_send_num: 3; /*The bits are used to choose which short packet*/
  267. uint32_t always_send_en: 1; /*Set this bit to enable continuously send the same short packet*/
  268. uint32_t reserved8: 24;
  269. };
  270. uint32_t val;
  271. } quick_sent;
  272. struct{
  273. uint32_t w_data[2]; /*This register stores the content of short packet's dword*/
  274. } q_data[7];
  275. union {
  276. struct {
  277. uint32_t seper_char: 8; /*This register stores the separator char separator char is used to separate the data frame.*/
  278. uint32_t seper_esc_char0: 8; /*This register stores the first char used to replace separator char in data.*/
  279. uint32_t seper_esc_char1: 8; /*This register stores the second char used to replace separator char in data . 0xdc 0xdb replace 0xc0 by default.*/
  280. uint32_t reserved24: 8;
  281. };
  282. uint32_t val;
  283. } esc_conf0;
  284. union {
  285. struct {
  286. uint32_t seq0: 8; /*This register stores the first substitute char used to replace the separate char.*/
  287. uint32_t seq0_char0: 8; /*This register stores the first char used to replace reg_esc_seq0 in data.*/
  288. uint32_t seq0_char1: 8; /*This register stores the second char used to replace the reg_esc_seq0 in data*/
  289. uint32_t reserved24: 8;
  290. };
  291. uint32_t val;
  292. } esc_conf1;
  293. union {
  294. struct {
  295. uint32_t seq1: 8; /*This register stores the flow control char to turn on the flow_control*/
  296. uint32_t seq1_char0: 8; /*This register stores the first char used to replace the reg_esc_seq1 in data.*/
  297. uint32_t seq1_char1: 8; /*This register stores the second char used to replace the reg_esc_seq1 in data.*/
  298. uint32_t reserved24: 8;
  299. };
  300. uint32_t val;
  301. } esc_conf2;
  302. union {
  303. struct {
  304. uint32_t seq2: 8; /*This register stores the flow_control char to turn off the flow_control*/
  305. uint32_t seq2_char0: 8; /*This register stores the first char used to replace the reg_esc_seq2 in data.*/
  306. uint32_t seq2_char1: 8; /*This register stores the second char used to replace the reg_esc_seq2 in data.*/
  307. uint32_t reserved24: 8;
  308. };
  309. uint32_t val;
  310. } esc_conf3;
  311. union {
  312. struct {
  313. uint32_t thrs: 13; /*when the amount of packet payload is larger than this value the process of receiving data is done.*/
  314. uint32_t reserved13:19;
  315. };
  316. uint32_t val;
  317. } pkt_thres;
  318. uint32_t reserved_c4;
  319. uint32_t reserved_c8;
  320. uint32_t reserved_cc;
  321. uint32_t reserved_d0;
  322. uint32_t reserved_d4;
  323. uint32_t reserved_d8;
  324. uint32_t reserved_dc;
  325. uint32_t reserved_e0;
  326. uint32_t reserved_e4;
  327. uint32_t reserved_e8;
  328. uint32_t reserved_ec;
  329. uint32_t reserved_f0;
  330. uint32_t reserved_f4;
  331. uint32_t reserved_f8;
  332. uint32_t date; /*version information*/
  333. } uhci_dev_t;
  334. extern uhci_dev_t UHCI0;
  335. extern uhci_dev_t UHCI1;
  336. #endif /* _SOC_UHCI_STRUCT_H_ */