mt_musb_qmu.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. /*
  2. * Copyright (c) 2013 MediaTek Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining
  5. * a copy of this software and associated documentation files
  6. * (the "Software"), to deal in the Software without restriction,
  7. * including without limitation the rights to use, copy, modify, merge,
  8. * publish, distribute, sublicense, and/or sell copies of the Software,
  9. * and to permit persons to whom the Software is furnished to do so,
  10. * subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be
  13. * included in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  18. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  19. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  20. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  21. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. #include <platform/mt_reg_base.h>
  24. #ifndef MTK_QMU_H
  25. #define MTK_QMU_H
  26. #define USB_HW_QMU_BASE 0x86000800
  27. #define USB_HW_QMU_LENGTH 0x500
  28. /// @brief Define DMAQ Register Bass Address
  29. /// @Author_Name:tianhao.fei 4/29/2010
  30. /// @{
  31. #define USB_QMUBASE USB_BASE + 0x800
  32. #define USB_QISAR USB_BASE + 0xc00
  33. #define USB_QIMR USB_BASE + 0xc04
  34. #define USB_HW_QMU_OFF USB_QMUBASE + 0x0000
  35. #define USB_HW_QUCS_OFF USB_QMUBASE + 0x0300
  36. #define USB_HW_QIRQ_OFF USB_QMUBASE + 0x0400
  37. #define USB_HW_QDBG_OFF USB_QMUBASE + 0x04F0
  38. /// @}
  39. //#define GPD_LEN_ALIGNED (32) /* Note: ARM should align cache line size */
  40. #define GPD_LEN_ALIGNED (64) /* > sizeof (TGPD) + sizeof (list_head)*/
  41. // KOBE , modify
  42. #define RXQ_NUM 1
  43. #define TXQ_NUM 1
  44. /// @brief Define DMAQ Register Offset
  45. /// @Author_Name:tianhao.fei 4/29/2010
  46. /// @{
  47. #define MGC_O_QMU_QCR0 0x0000
  48. #define MGC_O_QMU_QCR2 0x0008
  49. #define MGC_O_QMU_QCR3 0x000C
  50. #define MGC_O_QMU_RQCSR0 0x0010
  51. #define MGC_O_QMU_RQSAR0 0x0014
  52. #define MGC_O_QMU_RQCPR0 0x0018
  53. #define MGC_O_QMU_RQCSR(n) (MGC_O_QMU_RQCSR0+0x0010*((n)-1))
  54. #define MGC_O_QMU_RQSAR(n) (MGC_O_QMU_RQSAR0+0x0010*((n)-1))
  55. #define MGC_O_QMU_RQCPR(n) (MGC_O_QMU_RQCPR0+0x0010*((n)-1))
  56. #define MGC_O_QMU_RQTR_BASE 0x0090
  57. #define MGC_O_QMU_RQTR(n) (MGC_O_QMU_RQTR_BASE+0x4*((n)-1))
  58. #define MGC_O_QMU_RQLDPR0 0x0100
  59. #define MGC_O_QMU_RQLDPR(n) (MGC_O_QMU_RQLDPR0+0x4*((n)-1))
  60. #define MGC_O_QMU_TQCSR0 0x0200
  61. #define MGC_O_QMU_TQSAR0 0x0204
  62. #define MGC_O_QMU_TQCPR0 0x0208
  63. #define MGC_O_QMU_TQCSR(n) (MGC_O_QMU_TQCSR0+0x0010*((n)-1))
  64. #define MGC_O_QMU_TQSAR(n) (MGC_O_QMU_TQSAR0+0x0010*((n)-1))
  65. #define MGC_O_QMU_TQCPR(n) (MGC_O_QMU_TQCPR0+0x0010*((n)-1))
  66. #define MGC_O_QMU_QAR 0x0300
  67. #define MGC_O_QUCS_USBGCSR 0x0000
  68. #ifdef MTK_WDMAQ
  69. /*wimax only*/
  70. #define MGC_O_QUCS_TQUSBSC_BASE 0x0080
  71. #define MGC_O_QUCS_TQUSBSC(n) (MGC_O_QUCS_TQUSBSC_BASE+0x4*((n)-1))
  72. #define MGC_O_QUCS_FW1 0x0004
  73. #define MGC_O_QUCS_FW2 0x0008
  74. /*end*/
  75. #endif
  76. #define MGC_O_QIRQ_QISAR 0x0000
  77. #define MGC_O_QIRQ_QIMR 0x0004
  78. #define MGC_O_QIRQ_QIMCR 0x0008
  79. #define MGC_O_QIRQ_QIMSR 0x000C
  80. #ifdef MTK_WDMAQ
  81. /*wimax only*/
  82. #define MGC_O_QIRQ_QSISAR 0x0010
  83. #define MGC_O_QIRQ_DSIMR 0x0014
  84. #define MGC_O_QIRQ_DSIMCR 0x0018
  85. #define MGC_O_QIRQ_DSIMSR 0x001C
  86. #define MGC_O_QIRQ_DSICR 0x0020
  87. /*end*/
  88. #endif
  89. #define MGC_O_QIRQ_IOCDISR 0x0030
  90. #define MGC_O_QIRQ_TEPEMPR 0x0060
  91. #define MGC_O_QIRQ_TEPEMPMR 0x0064
  92. #define MGC_O_QIRQ_TEPEMPMCR 0x0068
  93. #define MGC_O_QIRQ_TEPEMPMSR 0x006C
  94. #define MGC_O_QIRQ_REPEMPR 0x0070
  95. #define MGC_O_QIRQ_REPEMPMR 0x0074
  96. #define MGC_O_QIRQ_REPEMPMCR 0x0078
  97. #define MGC_O_QIRQ_REPEMPMSR 0x007C
  98. #define MGC_O_QIRQ_RQEIR 0x0090
  99. #define MGC_O_QIRQ_RQEIMR 0x0094
  100. #define MGC_O_QIRQ_RQEIMCR 0x0098
  101. #define MGC_O_QIRQ_RQEIMSR 0x009C
  102. #define MGC_O_QIRQ_REPEIR 0x00A0
  103. #define MGC_O_QIRQ_REPEIMR 0x00A4
  104. #define MGC_O_QIRQ_REPEIMCR 0x00A8
  105. #define MGC_O_QIRQ_REPEIMSR 0x00AC
  106. #define MGC_O_QIRQ_TQEIR 0x00B0
  107. #define MGC_O_QIRQ_TQEIMR 0x00B4
  108. #define MGC_O_QIRQ_TQEIMCR 0x00B8
  109. #define MGC_O_QIRQ_TQEIMSR 0x00BC
  110. #define MGC_O_QIRQ_TEPEIR 0x00C0
  111. #define MGC_O_QIRQ_TEPEIMR 0x00C4
  112. #define MGC_O_QIRQ_TEPEIMCR 0x00C8
  113. #define MGC_O_QIRQ_TEPEIMSR 0x00CC
  114. #define MGC_O_QDBG_DFCR 0x0000
  115. #define MGC_O_QDBG_DFMR 0x0004
  116. /// @}
  117. /// @brief Queue Control value Definition
  118. /// @Author_Name:tianhao.fei 4/29/2010
  119. /// @{
  120. #define DQMU_QUE_START 0x00000001
  121. #define DQMU_QUE_RESUME 0x00000002
  122. #define DQMU_QUE_STOP 0x00000004
  123. #define DQMU_QUE_ACTIVE 0x00008000
  124. /// @}
  125. /// @brief USB QMU Special Control USBGCSR value Definition
  126. /// @Author_Name:tianhao.fei 4/29/2010
  127. /// @{
  128. #define USB_QMU_Tx0_EN 0x00000001
  129. #define USB_QMU_Tx_EN(n) (USB_QMU_Tx0_EN<<((n)-1))
  130. #if 1 //CC_TEST
  131. #define USB_QMU_Rx0_EN 0x00010000
  132. #else
  133. #define USB_QMU_Rx0_EN 0x00000020
  134. #endif
  135. #define USB_QMU_Rx_EN(n) (USB_QMU_Rx0_EN<<((n)-1))
  136. #define USB_QMU_HIFEVT_EN 0x00000100
  137. #define USB_QMU_HIFCMD_EN 0x01000000
  138. #define DQMU_SW_RESET 0x00010000
  139. #define DQMU_CS16B_EN 0x80000000
  140. #define DQMU_TQ0CS_EN 0x00010000
  141. #define DQMU_TQCS_EN(n) (DQMU_TQ0CS_EN<<((n)-1))
  142. #define DQMU_RQ0CS_EN 0x00000001
  143. #define DQMU_RQCS_EN(n) (DQMU_RQ0CS_EN<<((n)-1))
  144. #define DQMU_TX0_ZLP 0x01000000
  145. #define DQMU_TX_ZLP(n) (DQMU_TX0_ZLP<<((n)-1))
  146. #define DQMU_TX0_MULTIPLE 0x00010000
  147. #define DQMU_TX_MULTIPLE(n) (DQMU_TX0_MULTIPLE<<((n)-1))
  148. #ifdef MTK_WDMAQ
  149. #define DQMU_TX_PADDING 0x00000002
  150. #define DQMU_TX_SDUHDR 0x00000001
  151. #endif
  152. #define DQMU_RX0_MULTIPLE 0x00010000
  153. #define DQMU_RX_MULTIPLE(n) (DQMU_RX0_MULTIPLE<<((n)-1))
  154. #ifdef MTK_WDMAQ
  155. #define DQMU_RX_SDUHDR 0x00000001
  156. #endif
  157. #define DQMU_RX0_ZLP 0x01000000
  158. #define DQMU_RX_ZLP(n) (DQMU_RX0_ZLP<<((n)-1))
  159. #define DQMU_M_TXEP_ERR 0x10000000
  160. #define DQMU_M_TXQ_ERR 0x08000000
  161. #define DQMU_M_RXEP_ERR 0x04000000
  162. #define DQMU_M_RXQ_ERR 0x02000000
  163. #define DQMU_M_RQ_EMPTY 0x00020000
  164. #define DQMU_M_TQ_EMPTY 0x00010000
  165. #define DQMU_M_RX0_EMPTY 0x00000001
  166. #define DQMU_M_RX_EMPTY(n) (DQMU_M_RX0_EMPTY<<((n)-1))
  167. #define DQMU_M_TX0_EMPTY 0x00000001
  168. #define DQMU_M_TX_EMPTY(n) (DQMU_M_TX0_EMPTY<<((n)-1))
  169. #define DQMU_M_RX0_DONE 0x00000100
  170. #define DQMU_M_RX_DONE(n) (DQMU_M_RX0_DONE<<((n)-1))
  171. #define DQMU_M_TX0_DONE 0x00000001
  172. #define DQMU_M_TX_DONE(n) (DQMU_M_TX0_DONE<<((n)-1))
  173. #define DQMU_M_RX0_ZLP_ERR 0x01000000
  174. #define DQMU_M_RX_ZLP_ERR(n) (DQMU_M_RX0_ZLP_ERR<<((n)-1))
  175. #ifdef MTK_WDMAQ
  176. #define DQMU_M_RX0_HDR_ERR 0x00010000
  177. #define DQMU_M_RX_HDR_ERR(n) (DQMU_M_RX0_HDR_ERR<<((n)-1))
  178. #endif
  179. #define DQMU_M_RX0_LEN_ERR 0x00000100
  180. #define DQMU_M_RX_LEN_ERR(n) (DQMU_M_RX0_LEN_ERR<<((n)-1))
  181. #define DQMU_M_RX0_GPDCS_ERR 0x00000001
  182. #define DQMU_M_RX_GPDCS_ERR(n) (DQMU_M_RX0_GPDCS_ERR<<((n)-1))
  183. #define DQMU_M_TX0_LEN_ERR 0x00010000
  184. #define DQMU_M_TX_LEN_ERR(n) (DQMU_M_TX0_LEN_ERR<<((n)-1))
  185. #define DQMU_M_TX0_GPDCS_ERR 0x00000100
  186. #define DQMU_M_TX_GPDCS_ERR(n) (DQMU_M_TX0_GPDCS_ERR<<((n)-1))
  187. #define DQMU_M_TX0_BDCS_ERR 0x00000001
  188. #define DQMU_M_TX_BDCS_ERR(n) (DQMU_M_TX0_BDCS_ERR<<((n)-1))
  189. #define DQMU_M_TX0_EP_ERR 0x00000001
  190. #define DQMU_M_TX_EP_ERR(n) (DQMU_M_TX0_EP_ERR<<((n)-1))
  191. #define DQMU_M_RX0_EP_ERR 0x00000001
  192. #define DQMU_M_RX_EP_ERR(n) (DQMU_M_RX0_EP_ERR<<((n)-1))
  193. #define DQMU_M_RQ_DIS_IOC(n) (0x100<<((n)-1))
  194. /// @}
  195. /**
  196. * @brief Read a 8-bit register from the core
  197. * @param _pBase core base address in memory
  198. * @param _offset offset into the core's register space
  199. * @return 16-bit datum
  200. */
  201. #define MGC_ReadQMU8(_offset) \
  202. DRV_Reg8((USB_HW_QMU_OFF + _offset))
  203. #define MGC_ReadQUCS8(base,_offset) \
  204. DRV_Reg8((USB_HW_QUCS_OFF + _offset))
  205. #define MGC_ReadQIRQ8(base,_offset) \
  206. DRV_Reg8((USB_HW_QIRQ_OFF + _offset))
  207. /**
  208. * @brief Read a 16-bit register from the core
  209. * @param _pBase core base address in memory
  210. * @param _offset offset into the core's register space
  211. * @return 16-bit datum
  212. */
  213. #define MGC_ReadQMU16(_offset) \
  214. DRV_Reg((USB_HW_QMU_OFF + _offset))
  215. #define MGC_ReadQUCS16(_offset) \
  216. DRV_Reg((USB_HW_QUCS_OFF + _offset))
  217. #define MGC_ReadQIRQ16(_offset) \
  218. DRV_Reg((USB_HW_QIRQ_OFF + _offset))
  219. /**
  220. * @brief Read a 32-bit register from the core
  221. * @param _pBase core base address in memory
  222. * @param _offset offset into the core's register space
  223. * @return 32-bit datum
  224. */
  225. #define MGC_ReadQMU32(_offset) \
  226. DRV_Reg32((USB_HW_QMU_OFF + _offset))
  227. #define MGC_ReadQUCS32(_offset) \
  228. DRV_Reg32((USB_HW_QUCS_OFF + _offset))
  229. #define MGC_ReadQIRQ32(_offset) \
  230. DRV_Reg32((USB_HW_QIRQ_OFF + _offset))
  231. /**
  232. * @briefWrite a 32-bit core register
  233. * @param _pBase core base address in memory
  234. * @param _offset offset into the core's register space
  235. * @param _data 32-bit datum
  236. */
  237. #define MGC_WriteQMU32(_offset, _data) \
  238. DRV_WriteReg32((USB_HW_QMU_OFF + _offset), _data)
  239. #define MGC_WriteQUCS32(_offset, _data) \
  240. DRV_WriteReg32((USB_HW_QUCS_OFF + _offset), _data)
  241. #define MGC_WriteQIRQ32(_offset, _data) \
  242. DRV_WriteReg32((USB_HW_QIRQ_OFF + _offset), _data)
  243. /**
  244. * TGPD
  245. */
  246. typedef struct _TGPD {
  247. unsigned char flag;
  248. unsigned char chksum;
  249. unsigned short DataBufferLen; /*Rx Allow Length*/
  250. struct _TGPD* pNext;
  251. unsigned char* pBuf;
  252. unsigned short bufLen;
  253. unsigned char ExtLength;
  254. unsigned char ZTepFlag;
  255. } TGPD, *PGPD;
  256. typedef struct {
  257. TGPD gpd[2];
  258. kal_uint8 cur_gpd_index;
  259. TGPD *cur_ptr_gpd;
  260. } gpd_pool;
  261. /**
  262. * TBD
  263. */
  264. typedef struct _TBD {
  265. unsigned char flag;
  266. unsigned char chksum;
  267. unsigned short reserved1;
  268. struct _TBD *pNext;
  269. unsigned char* pBuf;
  270. unsigned short bufLen;
  271. unsigned char extLen;
  272. unsigned char reserved2;
  273. } TBD, *PBD;
  274. /// @}
  275. #define GPD_BUF_SIZE 65532
  276. #define GPD_BUF_SIZE_ALIGN 64512 /* 63 * 1024 */
  277. #define BD_BUF_SIZE 32768 //set to half of 64K of max size
  278. void qmu_done_interrupt(u32 qmu_val);
  279. void qmu_handler(u32 qmu_val);
  280. struct tgpd {
  281. u8 flag;
  282. u8 chksum;
  283. u16 databuf_len; /*Rx Allow Length*/
  284. struct tgpd *pnext;
  285. u8 *pBuf;
  286. u16 bufLen;
  287. u8 ExtLength;
  288. u8 ZTepFlag;
  289. };
  290. struct tbd {
  291. u8 flag;
  292. u8 chksum;
  293. u16 databuf_len; /* Rx Allow Length */
  294. struct tbd *pnext;
  295. u8 *pBuf;
  296. u16 bufLen;
  297. u8 extLen;
  298. u8 reserved;
  299. };
  300. struct gpd_range {
  301. struct tbd *pnext;
  302. struct tbd *pstart;
  303. struct tbd *pend;
  304. };
  305. #define AT_GPD_EXT_LEN 256
  306. #define AT_BD_EXT_LEN 256
  307. //#define MAX_GPD_NUM 30 /* we've got problem when gpd is larger */
  308. #define MAX_GPD_NUM 4
  309. //#define MAX_BD_NUM 500
  310. #define MAX_BD_NUM 3
  311. #define STRESS_IOC_TH 8
  312. #define STRESS_GPD_TH 24
  313. #define RANDOM_STOP_DELAY 80
  314. #define STRESS_DATA_LENGTH 1024*64 //1024*16
  315. #define NO_ZLP 0
  316. #define HW_MODE 1
  317. #define GPD_MODE 2
  318. #define TXZLP HW_MODE
  319. #define MAX_QMU_EP 1
  320. #define TGPD_FLAGS_HWO 0x01
  321. #define TGPD_IS_FLAGS_HWO(_pd) (((struct tgpd *)_pd)->flag & TGPD_FLAGS_HWO)
  322. #define TGPD_SET_FLAGS_HWO(_pd) (((struct tgpd *)_pd)->flag |= TGPD_FLAGS_HWO)
  323. #define TGPD_CLR_FLAGS_HWO(_pd) (((struct tgpd *)_pd)->flag &= (~TGPD_FLAGS_HWO))
  324. #define TGPD_FORMAT_BDP 0x02
  325. #define TGPD_IS_FORMAT_BDP(_pd) (((struct tgpd *)_pd)->flag & TGPD_FORMAT_BDP)
  326. #define TGPD_SET_FORMAT_BDP(_pd) (((struct tgpd *)_pd)->flag |= TGPD_FORMAT_BDP)
  327. #define TGPD_CLR_FORMAT_BDP(_pd) (((struct tgpd *)_pd)->flag &= (~TGPD_FORMAT_BDP))
  328. #define TGPD_FORMAT_BPS 0x04
  329. #define TGPD_IS_FORMAT_BPS(_pd) (((struct tgpd *)_pd)->flag & TGPD_FORMAT_BPS)
  330. #define TGPD_SET_FORMAT_BPS(_pd) (((struct tgpd *)_pd)->flag |= TGPD_FORMAT_BPS)
  331. #define TGPD_CLR_FORMAT_BPS(_pd) (((struct tgpd *)_pd)->flag &= (~TGPD_FORMAT_BPS))
  332. #define TGPD_SET_FLAG(_pd, _flag) ((struct tgpd *)_pd)->flag = (((struct tgpd *)_pd)->flag&(~TGPD_FLAGS_HWO))|(_flag)
  333. #define TGPD_GET_FLAG(_pd) (((struct tgpd *)_pd)->flag & TGPD_FLAGS_HWO)
  334. #define TGPD_SET_CHKSUM(_pd, _n) ((struct tgpd *)_pd)->chksum = mu3d_hal_cal_checksum((u8 *)_pd, _n)-1
  335. #define TGPD_SET_CHKSUM_HWO(_pd, _n) ((struct tgpd *)_pd)->chksum = mu3d_hal_cal_checksum((u8 *)_pd, _n)-1
  336. #define TGPD_GET_CHKSUM(_pd) ((struct tgpd *)_pd)->chksum
  337. #define TGPD_SET_FORMAT(_pd, _fmt) ((struct tgpd *)_pd)->flag = (((struct tgpd *)_pd)->flag&(~TGPD_FORMAT_BDP))|(_fmt)
  338. #define TGPD_GET_FORMAT(_pd) ((((struct tgpd *)_pd)->flag & TGPD_FORMAT_BDP)>>1)
  339. #define TGPD_SET_DATABUF_LEN(_pd, _len) ((struct tgpd *)_pd)->databuf_len = _len
  340. #define TGPD_ADD_DATABUF_LEN(_pd, _len) ((struct tgpd *)_pd)->databuf_len += _len
  341. #define TGPD_GET_DATABUF_LEN(_pd) ((struct tgpd *)_pd)->databuf_len
  342. #define TGPD_SET_NEXT(_pd, _next) ((struct tgpd *)_pd)->pnext = (struct tgpd *)_next;
  343. #define TGPD_GET_NEXT(_pd) (struct tgpd *)((struct tgpd *)_pd)->pnext
  344. #define TGPD_SET_TBD(_pd, _tbd) ((struct tgpd *)_pd)->pBuf = (u8 *)_tbd;\
  345. TGPD_SET_FORMAT_BDP(_pd)
  346. #define TGPD_GET_TBD(_pd) (struct tbd *)((struct tgpd *)_pd)->pBuf
  347. #define TGPD_SET_DATA(_pd, _data) ((struct tgpd *)_pd)->pBuf = (u8 *)_data
  348. #define TGPD_GET_DATA(_pd) (u8*)((struct tgpd *)_pd)->pBuf
  349. #define TGPD_SET_BUF_LEN(_pd, _len) ((struct tgpd *)_pd)->bufLen = _len
  350. #define TGPD_ADD_BUF_LEN(_pd, _len) ((struct tgpd *)_pd)->bufLen += _len
  351. #define TGPD_GET_BUF_LEN(_pd) ((struct tgpd *)_pd)->bufLen
  352. #define TGPD_SET_EXT_LEN(_pd, _len) ((struct tgpd *)_pd)->ExtLength = _len
  353. #define TGPD_GET_EXT_LEN(_pd) ((struct tgpd *)_pd)->ExtLength
  354. #define TGPD_SET_EPaddr(_pd, _EP) ((struct tgpd *)_pd)->ZTepFlag =(((struct tgpd *)_pd)->ZTepFlag&0xF0)|(_EP)
  355. #define TGPD_GET_EPaddr(_pd) ((struct tgpd *)_pd)->ZTepFlag & 0x0F
  356. #define TGPD_FORMAT_TGL 0x10
  357. #define TGPD_IS_FORMAT_TGL(_pd) (((struct tgpd *)_pd)->ZTepFlag & TGPD_FORMAT_TGL)
  358. #define TGPD_SET_FORMAT_TGL(_pd) (((struct tgpd *)_pd)->ZTepFlag |=TGPD_FORMAT_TGL)
  359. #define TGPD_CLR_FORMAT_TGL(_pd) (((struct tgpd *)_pd)->ZTepFlag &= (~TGPD_FORMAT_TGL))
  360. #define TGPD_FORMAT_ZLP 0x20
  361. #define TGPD_IS_FORMAT_ZLP(_pd) (((struct tgpd *)_pd)->ZTepFlag & TGPD_FORMAT_ZLP)
  362. #define TGPD_SET_FORMAT_ZLP(_pd) (((struct tgpd *)_pd)->ZTepFlag |=TGPD_FORMAT_ZLP)
  363. #define TGPD_CLR_FORMAT_ZLP(_pd) (((struct tgpd *)_pd)->ZTepFlag &= (~TGPD_FORMAT_ZLP))
  364. #define TGPD_FORMAT_IOC 0x80
  365. #define TGPD_IS_FORMAT_IOC(_pd) (((struct tgpd *)_pd)->flag & TGPD_FORMAT_IOC)
  366. #define TGPD_SET_FORMAT_IOC(_pd) (((struct tgpd *)_pd)->flag |=TGPD_FORMAT_IOC)
  367. #define TGPD_CLR_FORMAT_IOC(_pd) (((struct tgpd *)_pd)->flag &= (~TGPD_FORMAT_IOC))
  368. #define TGPD_SET_TGL(_pd, _TGL) ((struct tgpd *)_pd)->ZTepFlag |=(( _TGL) ? 0x10: 0x00)
  369. #define TGPD_GET_TGL(_pd) ((struct tgpd *)_pd)->ZTepFlag & 0x10 ? 1:0
  370. #define TGPD_SET_ZLP(_pd, _ZLP) ((struct tgpd *)_pd)->ZTepFlag |= ((_ZLP) ? 0x20: 0x00)
  371. #define TGPD_GET_ZLP(_pd) ((struct tgpd *)_pd)->ZTepFlag & 0x20 ? 1:0
  372. #define TGPD_GET_EXT(_pd) ((u8 *)_pd + sizeof(struct tgpd))
  373. #define TBD_FLAGS_EOL 0x01
  374. #define TBD_IS_FLAGS_EOL(_bd) (((struct tbd *)_bd)->flag & TBD_FLAGS_EOL)
  375. #define TBD_SET_FLAGS_EOL(_bd) (((struct tbd *)_bd)->flag |= TBD_FLAGS_EOL)
  376. #define TBD_CLR_FLAGS_EOL(_bd) (((struct tbd *)_bd)->flag &= (~TBD_FLAGS_EOL))
  377. #define TBD_SET_FLAG(_bd, _flag) ((struct tbd *)_bd)->flag = (u8)_flag
  378. #define TBD_GET_FLAG(_bd) ((struct tbd *)_bd)->flag
  379. #define TBD_SET_CHKSUM(_pd, _n) ((struct tbd *)_pd)->chksum = mu3d_hal_cal_checksum((u8 *)_pd, _n)
  380. #define TBD_GET_CHKSUM(_pd) ((struct tbd *)_pd)->chksum
  381. #define TBD_SET_DATABUF_LEN(_pd, _len) ((struct tbd *)_pd)->databuf_len = _len
  382. #define TBD_GET_DATABUF_LEN(_pd) ((struct tbd *)_pd)->databuf_len
  383. #define TBD_SET_NEXT(_bd, _next) ((struct tbd *)_bd)->pnext = (struct tbd *)_next
  384. #define TBD_GET_NEXT(_bd) (struct tbd *)((struct tbd *)_bd)->pnext
  385. #define TBD_SET_DATA(_bd, _data) ((struct tbd *)_bd)->pBuf = (u8 *)_data
  386. #define TBD_GET_DATA(_bd) (u8*)((struct tbd *)_bd)->pBuf
  387. #define TBD_SET_BUF_LEN(_bd, _len) ((struct tbd *)_bd)->bufLen = _len
  388. #define TBD_ADD_BUF_LEN(_bd, _len) ((struct tbd *)_bd)->bufLen += _len
  389. #define TBD_GET_BUF_LEN(_bd) ((struct tbd *)_bd)->bufLen
  390. #define TBD_SET_EXT_LEN(_bd, _len) ((struct tbd *)_bd)->extLen = _len
  391. #define TBD_ADD_EXT_LEN(_bd, _len) ((struct tbd *)_bd)->extLen += _len
  392. #define TBD_GET_EXT_LEN(_bd) ((struct tbd *)_bd)->extLen
  393. #define TBD_GET_EXT(_bd) ((u8 *)_bd + sizeof(struct tbd))
  394. u32 gpd_buf_size;
  395. u32 g_dma_buffer_size;
  396. struct tgpd *rx_gpd_head[15];
  397. struct tgpd *tx_gpd_head[15];
  398. struct tgpd *rx_gpd_end[15];
  399. struct tgpd *tx_gpd_end[15];
  400. struct tgpd *rx_gpd_last[15];
  401. struct tgpd *tx_gpd_last[15];
  402. struct gpd_range rx_gpd_list[15] __attribute__((aligned(64)));
  403. struct gpd_range tx_gpd_list[15] __attribute__((aligned(64)));
  404. u32 rx_gpd_offset[15];
  405. u32 tx_gpd_offset[15];
  406. /*
  407. * declare function
  408. */
  409. void mu3d_hal_insert_transfer_gpd(int ep_num, u8 dir, u8* buf, u32 count, u8 ishwo, u8 ioc, u8 bps, u8 zlp, u32 max_pkt_size);
  410. void mu3d_hal_resume_qmu(int q_ep_num, u8 dir);
  411. void mu3d_hal_alloc_qmu_mem(void);
  412. void mu3d_hal_init_qmu(void);
  413. void usb_start_qmu(int q_ep_num, u8 dir);
  414. void mu3d_hal_stop_qmu(int q_ep_num, u8 dir);
  415. void mu3d_hal_flush_qmu(int q_ep_num, u8 dir);
  416. #endif