5d48a7c9958479e99917435fff14dc4ceb9c7473
[open-ath9k-htc-firmware.git] / target_firmware / magpie_fw_dev / build / magpie_1_1 / sboot / hif / usb / src / HIF_usb.c
1 /*
2  * @File: HIF_usb.c
3  * 
4  * @Abstract: USB implementation of HIF
5  * 
6  * @Notes:
7  * 
8  * Copyright (c) 2008 Atheros Communications Inc.
9  * All rights reserved.
10  *
11  */
12 #include "sys_cfg.h"
13 #include "dt_defs.h"
14 #include "reg_defs.h"
15
16 #include <osapi.h>
17 //#include <hif_api.h>
18 #include <Magpie_api.h>
19 #include <vdesc_api.h>
20 #include <adf_os_mem.h> 
21 #include <adf_os_io.h>
22 //#include <desc.h>
23 #include <dma_engine_api.h>
24
25 #include "hif_usb.h"
26
27 HIF_USB_CONTEXT g_hifUSBCtx;
28
29
30 static void send_buffer_via_fifo(VBUF *buf);
31 static int _HIFusb_get_reserved_headroom(hif_handle_t handle);
32 static struct zsDmaQueue* get_queue_from_pipe(int pipe);
33
34 int _HIFusb_get_max_msg_len(hif_handle_t handle, int pipe);
35
36 //#define OTUS_USB
37
38 static VBUF* usbfifo_get_command_buf()
39 {
40     VBUF *buf;
41      
42     buf = g_hifUSBCtx.cmdQueue;
43     g_hifUSBCtx.cmdQueue = buf->next_buf;
44     buf->next_buf = NULL;
45     return buf;
46 }
47
48 static void usbfifo_recv_command(VBUF *buf)
49 {
50 #if ENABLE_SW_SWAP_DATA_MODE
51     VDESC *currVdesc;
52     struct zsDmaDesc* usbDesc;
53 #endif
54     
55     #if ZM_FM_LOOPBACK == 1
56     send_buffer_via_fifo(buf);
57     #else
58     
59 #if ENABLE_SW_SWAP_DATA_MODE
60     currVdesc = (VDESC *)buf->desc_list;
61     usbDesc = (struct zsDmaDesc *)currVdesc->hw_desc_buf;    
62     usbDesc->dataSize = currVdesc->data_size;
63     usbDesc->dataAddr = (volatile u32_t)(currVdesc->buf_addr + currVdesc->data_offset);
64             
65     DMA_Engine_swap_data(usbDesc);
66 #endif    
67     g_hifUSBCtx.hifCb.recv_buf(NULL, buf, g_hifUSBCtx.hifCb.context);
68     #endif
69 }
70
71 static VBUF* usbfifo_get_event_buf()
72 {
73     VBUF *buf;
74
75     buf = g_hifUSBCtx.eventBufQ.head;
76     if ( g_hifUSBCtx.eventBufQ.head == g_hifUSBCtx.eventBufQ.tail ) {
77         g_hifUSBCtx.eventBufQ.head = NULL;
78         g_hifUSBCtx.eventBufQ.tail = NULL;
79     } else {
80         g_hifUSBCtx.eventBufQ.head = buf->next_buf;
81     }
82
83     buf->next_buf = NULL;    
84     return buf;    
85 }
86
87 static void usbfifo_send_event_done(VBUF *buf)
88 {
89     #if ZM_FM_LOOPBACK == 1    
90         ; // LOOPBACK? 
91     _HIFusb_return_recv_buf(NULL, HIF_USB_PIPE_COMMAND, buf);
92     #else
93     g_hifUSBCtx.hifCb.send_buf_done(buf, g_hifUSBCtx.hifCb.context); 
94     #endif
95 }
96
97 #define MAGPIE_ENABLE_USBFIFO
98
99 hif_handle_t _HIFusb_init(HIF_CONFIG *pConfig) 
100 {
101     USB_FIFO_CONFIG usbfifo;
102     
103 #ifdef MAGPIE_ENABLE_USBFIFO    
104     usbfifo.get_command_buf = usbfifo_get_command_buf;
105     usbfifo.recv_command    = usbfifo_recv_command;
106     usbfifo.get_event_buf   = usbfifo_get_event_buf;
107     usbfifo.send_event_done = usbfifo_send_event_done;
108     USBFIFO_init(&usbfifo);
109 #endif
110     
111     // Initialize the terminator descriptor for dnQ & upQ
112     DMA_Engine_init_rx_queue(&g_hifUSBCtx.dnQ);
113     DMA_Engine_init_tx_queue(&g_hifUSBCtx.upQ);
114             
115 #if SYSTEM_MODULE_HP_EP5
116     DMA_Engine_init_rx_queue(&g_hifUSBCtx.hpdnQ);    
117 #endif
118
119 #if SYSTEM_MODULE_HP_EP6
120     DMA_Engine_init_rx_queue(&g_hifUSBCtx.mpdnQ); 
121 #endif
122
123     g_hifUSBCtx.eventBufQ.head = NULL;
124     g_hifUSBCtx.eventBufQ.tail = NULL;
125     g_hifUSBCtx.cmdQueue = NULL;
126     
127     return NULL;
128 }
129
130 void _HIFusb_shutdown(hif_handle_t handle) 
131 {
132     // nothing to do in FW
133 }
134
135 void _HIFusb_register_callback(hif_handle_t handle, HIF_CALLBACK *pConfig) 
136 {
137     //HIF_INPROC_CONTEXT *hifInprocCtx = (HIF_INPROC_CONTEXT *)handle;        
138     
139     g_hifUSBCtx.hifCb.send_buf_done = pConfig->send_buf_done;
140     g_hifUSBCtx.hifCb.recv_buf      = pConfig->recv_buf;
141     g_hifUSBCtx.hifCb.context       = pConfig->context;
142         
143     return;
144 }
145
146 //#define MAGPIE_REG_USB_
147 void _HIFusb_start(hif_handle_t handle) 
148 {
149 #ifdef OTUS_USB    
150     ZM_PTA_DN_DMA_ADDRH_REG = (u32_t)g_hifUSBCtx.dnQ.head >> 16;
151     ZM_PTA_DN_DMA_ADDRL_REG = (u32_t)g_hifUSBCtx.dnQ.head & 0xffff;
152     
153     ZM_PTA_UP_DMA_ADDRH_REG = (u32_t)g_hifUSBCtx.upQ.head >> 16;
154     ZM_PTA_UP_DMA_ADDRL_REG = (u32_t)g_hifUSBCtx.upQ.head & 0xffff;       
155 #else
156     A_PRINTF("\n\r\t=>[dnQ] 0x%08x \n[", (u32_t)g_hifUSBCtx.dnQ.head);
157     A_PRINTF("\t=>[upQ] 0x%08x \n[", (u32_t)g_hifUSBCtx.upQ.head);
158     
159     MAGPIE_REG_USB_RX0_DESC_START = (u32_t)g_hifUSBCtx.dnQ.head;
160     MAGPIE_REG_USB_TX0_DESC_START = (u32_t)g_hifUSBCtx.upQ.head;
161 #if SYSTEM_MODULE_HP_EP5
162     A_PRINTF("\t=>[hp dnQ] 0x%08x \n[", (u32_t)g_hifUSBCtx.hpdnQ.head);
163     MAGPIE_REG_USB_RX1_DESC_START = (u32_t)g_hifUSBCtx.hpdnQ.head;
164 #endif
165
166 #if SYSTEM_MODULE_HP_EP6
167     A_PRINTF("\t=>[mp dnQ] 0x%08x \n[", (u32_t)g_hifUSBCtx.mpdnQ.head);
168     MAGPIE_REG_USB_RX2_DESC_START = (u32_t)g_hifUSBCtx.mpdnQ.head;
169 #endif
170
171     MAGPIE_REG_USB_INTERRUPT_MASK =  0xffffffff;    // enable all interrupt, refer to 7-34, Ryan
172     MAGPIE_REG_USB_RX0_DMA_START = 1; 
173
174 #if SYSTEM_MODULE_HP_EP5
175     MAGPIE_REG_USB_RX1_DMA_START = 1;
176  #endif
177
178 #if SYSTEM_MODULE_HP_EP6
179     MAGPIE_REG_USB_RX2_DMA_START = 1;
180 #endif
181 #endif    
182 }
183
184 static int _HIFusb_get_reserved_headroom(hif_handle_t handle)
185 {
186     return 0;
187 }
188
189 static void config_command_pipe(VDESC *desc_list)
190 {
191     VDESC *theDesc;
192     VBUF  *buf;
193     
194     theDesc = desc_list;
195     while ( theDesc != NULL ) {
196         buf = VBUF_alloc_vbuf();
197         
198         buf->desc_list = theDesc;
199         theDesc = theDesc->next_desc;
200         buf->desc_list->next_desc = NULL;
201         
202         if ( g_hifUSBCtx.cmdQueue == NULL ) {
203             g_hifUSBCtx.cmdQueue = buf;
204         } else {
205             buf->next_buf = g_hifUSBCtx.cmdQueue;
206             g_hifUSBCtx.cmdQueue = buf;
207         }
208     }    
209 }
210
211 static void enable_rx(int pipe)
212 {
213     if ( pipe == HIF_USB_PIPE_TX ) {
214         #ifdef OTUS_USB      
215         ZM_PTA_DN_DMA_TRIGGER_REG = 1;
216         #else
217         MAGPIE_REG_USB_RX0_DMA_START = 1;
218         #endif    
219     }
220 #if SYSTEM_MODULE_HP_EP5
221     else if ( pipe == HIF_USB_PIPE_HP_TX ) {
222         MAGPIE_REG_USB_RX1_DMA_START = 1;
223     }
224 #endif
225 #if SYSTEM_MODULE_HP_EP6
226     else if ( pipe == HIF_USB_PIPE_MP_TX ) {
227         MAGPIE_REG_USB_RX2_DMA_START = 1;
228     }
229 #endif      
230 }
231
232 static struct zsDmaQueue* get_queue_from_pipe(int pipe)
233 {   
234     struct zsDmaQueue* q = NULL;
235     
236     if ( pipe == HIF_USB_PIPE_TX ) {
237         q = &g_hifUSBCtx.dnQ;      
238     } 
239 #if SYSTEM_MODULE_HP_EP5
240     else if ( pipe == HIF_USB_PIPE_HP_TX )
241     {
242         q = &g_hifUSBCtx.hpdnQ;
243     }
244 #endif
245 #if SYSTEM_MODULE_HP_EP6
246     else if ( pipe == HIF_USB_PIPE_MP_TX )
247     {
248         q = &g_hifUSBCtx.mpdnQ; 
249     }
250 #endif
251     else {
252         adf_os_assert(0);
253     }
254     
255     return q;
256 }
257
258 //#define MAX_TX_BUF_SIZE            ZM_BLOCK_SIZE
259 //#define MAX_TX_BUF_SIZE            1600
260
261 //void _HIFusb_config_pipe(hif_handle_t handle, int pipe, VDESC *desc_list)
262 void _HIFusb_config_pipe(hif_handle_t handle, int pipe, int creditCount)
263 {
264     int i;
265     VDESC *desc;
266     VDESC *head = NULL;
267     struct zsDmaQueue *q;
268     
269     if ( pipe != HIF_USB_PIPE_COMMAND ) {
270         goto config_pipe;
271     }
272     
273     // USB command pipe doesn't use FIFO
274     for(i=0; i < creditCount; i++)
275     {
276         desc = VDESC_alloc_vdesc();
277         
278         adf_os_assert(desc != NULL);
279         
280         desc->buf_addr = (A_UINT8 *)adf_os_mem_alloc(HIF_get_max_msg_len(handle, pipe));
281         desc->buf_size = HIF_get_max_msg_len(handle, pipe);
282         desc->next_desc = NULL;
283         desc->data_offset = 0;
284         desc->data_size = 0;
285         desc->control = 0;
286                
287         if ( head == NULL )
288         {
289             head = desc;
290         }
291         else
292         {
293             desc->next_desc = head;
294             head = desc;
295         }
296     }         
297     
298     config_command_pipe(head);
299     return;
300     
301 config_pipe:    
302     q = get_queue_from_pipe(pipe);   
303     DMA_Engine_config_rx_queue(q, creditCount, HIF_get_max_msg_len(handle, pipe));
304     enable_rx(pipe);
305     return;
306 }
307
308 static void send_buffer_via_fifo(VBUF *buf)
309 {
310 #if ENABLE_SW_SWAP_DATA_MODE
311     VDESC *currVdesc;
312     struct zsDmaDesc* usbDesc;
313     
314     //A_PRINTF("send_buffer_via_fifo buf len %d\n", buf->buf_length);
315     currVdesc = (VDESC *)buf->desc_list;
316     usbDesc = (struct zsDmaDesc *)currVdesc->hw_desc_buf;    
317     usbDesc->dataSize = currVdesc->data_size;
318     usbDesc->dataAddr = (volatile u32_t)(currVdesc->buf_addr + currVdesc->data_offset);
319             
320     DMA_Engine_swap_data(usbDesc);
321 #endif
322     
323     if ( g_hifUSBCtx.eventBufQ.head == NULL ) {
324         g_hifUSBCtx.eventBufQ.head = buf;
325         g_hifUSBCtx.eventBufQ.tail = buf;
326     } else {
327         g_hifUSBCtx.eventBufQ.tail->next_buf = buf;
328         g_hifUSBCtx.eventBufQ.tail = buf;
329     }
330     
331     USBFIFO_enable_event_isr();
332 }
333
334 int _HIFusb_send_buffer(hif_handle_t handle, int pipe, VBUF *buf)
335
336     if ( pipe == HIF_USB_PIPE_INTERRUPT ) {
337         send_buffer_via_fifo(buf);     
338     } else {
339         DMA_Engine_xmit_buf(&g_hifUSBCtx.upQ, buf);
340 #ifdef OTUS_USB                  
341         ZM_PTA_UP_DMA_TRIGGER_REG = 1;
342 #else
343         MAGPIE_REG_USB_TX0_DMA_START = 1;
344 #endif          
345     }
346
347     return 0;
348 }
349
350
351 void _HIFusb_return_recv_buf(hif_handle_t handle, int pipe, VBUF *buf)
352 {    
353     struct zsDmaQueue *q;
354     
355     if ( pipe == HIF_USB_PIPE_COMMAND ) {
356         if ( g_hifUSBCtx.cmdQueue == NULL ) {
357             g_hifUSBCtx.cmdQueue = buf;
358         } else {
359             buf->next_buf = g_hifUSBCtx.cmdQueue;
360             g_hifUSBCtx.cmdQueue = buf;
361         }        
362     } else {
363         q = get_queue_from_pipe(pipe);
364         DMA_Engine_return_recv_buf(q, buf);   
365         enable_rx(pipe);              
366     }
367 }
368                            
369 void _HIFusb_set_recv_bufsz(hif_handle_t handle, int pipe, int bufsz)
370 {
371     (void)pipe;
372     (void)bufsz;    
373 }
374
375 void _HIFusb_pause_recv(hif_handle_t handle, int pipe)
376 {
377     (void)pipe;
378 }
379
380 void _HIFusb_resume_recv(hif_handle_t handle, int pipe)
381 {
382     (void)pipe;
383 }
384
385 int  _HIFusb_is_pipe_supported(hif_handle_t handle, int pipe)
386 {
387     if ( pipe < HIF_USB_PIPE_TX || pipe > HIF_USB_PIPE_MP_TX ) {
388         return 0;
389     } else {    
390         return 1;
391     }
392 }
393     
394 int _HIFusb_get_max_msg_len(hif_handle_t handle, int pipe)
395 {
396     switch(pipe) {
397         case HIF_USB_PIPE_INTERRUPT:
398         case HIF_USB_PIPE_COMMAND:
399             return 64;
400             
401         default:
402             return 1600;
403     }
404 }
405     
406 static void handle_tx_complete_isr()
407 {
408     VBUF *buf;
409     
410     //A_PRINTF("USB Tx complete\n\r");                           
411     #if ZM_FM_LOOPBACK == 1
412     VDESC *vdesc;
413     struct zsDmaDesc* desc;
414         
415     desc = DMA_Engine_get_packet(&g_hifUSBCtx.upQ);
416     vdesc = VDESC_HW_TO_VDESC(desc);
417     
418     if ( vdesc->control == HIF_USB_PIPE_TX ) {
419         DMA_Engine_reclaim_packet(&g_hifUSBCtx.dnQ, desc);
420     }
421     #if SYSTEM_MODULE_HP_EP5  
422     else if ( vdesc->control == HIF_USB_PIPE_HP_TX ) {
423         DMA_Engine_reclaim_packet(&g_hifUSBCtx.hpdnQ, desc);
424     }
425     #endif
426     #if SYSTEM_MODULE_HP_EP6
427     else if ( vdesc->control == HIF_USB_PIPE_MP_TX ) {
428         DMA_Engine_reclaim_packet(&g_hifUSBCtx.mpdnQ, desc);
429     }    
430     #endif
431     
432     #ifdef OTUS_USB            
433     ZM_PTA_DN_DMA_TRIGGER_REG = 1;
434     #else
435     MAGPIE_REG_USB_RX0_DMA_START = 1;
436     #endif            
437     
438     #else                               
439         buf = DMA_Engine_reap_xmited_buf(&g_hifUSBCtx.upQ);
440         g_hifUSBCtx.hifCb.send_buf_done(buf, g_hifUSBCtx.hifCb.context);
441     #endif /* ZM_FM_LOOPBACK == 1 */    
442 }
443     
444 static void handle_rx_complete_isr()
445 {
446     VBUF *buf;
447     
448     #if ZM_FM_LOOPBACK == 1
449     VDESC *vdesc;
450     struct zsDmaDesc* desc;
451                
452     //A_PRINTF("USB Rx complete\n\r");    
453     desc = DMA_Engine_get_packet(&g_hifUSBCtx.dnQ);
454     vdesc = VDESC_HW_TO_VDESC(desc);
455     vdesc->control = HIF_USB_PIPE_TX;
456     
457     DMA_Engine_put_packet(&g_hifUSBCtx.upQ, desc);
458             
459     #ifdef OTUS_USB 
460     ZM_PTA_UP_DMA_TRIGGER_REG = 1;
461     #else
462     MAGPIE_REG_USB_TX0_DMA_START = 1;
463     #endif
464             
465     #else
466     buf = DMA_Engine_reap_recv_buf(&g_hifUSBCtx.dnQ);
467     g_hifUSBCtx.hifCb.recv_buf(NULL, buf, g_hifUSBCtx.hifCb.context);
468     #endif    
469 }
470     
471 #if SYSTEM_MODULE_HP_EP5    
472 static void handle_hp_rx_complete_isr()
473 {
474     VBUF *buf;
475     
476     #if ZM_FM_LOOPBACK == 1
477     VDESC *vdesc;
478     struct zsDmaDesc* desc;    
479                
480     desc = DMA_Engine_get_packet(&g_hifUSBCtx.hpdnQ);
481     vdesc = VDESC_HW_TO_VDESC(desc);
482     vdesc->control = HIF_USB_PIPE_HP_TX;
483         
484     DMA_Engine_put_packet(&g_hifUSBCtx.upQ, desc);
485     MAGPIE_REG_USB_TX0_DMA_START = 1;
486
487     #else
488     buf = DMA_Engine_reap_recv_buf(&g_hifUSBCtx.hpdnQ);
489     g_hifUSBCtx.hifCb.recv_buf(NULL, buf, g_hifUSBCtx.hifCb.context);
490     #endif
491 }
492 #endif
493
494 #if SYSTEM_MODULE_HP_EP6
495 static void handle_mp_rx_complete_isr()
496 {
497     VBUF *buf;
498         
499     #if ZM_FM_LOOPBACK == 1
500     VDESC *vdesc;
501     struct zsDmaDesc* desc;
502                
503     desc = DMA_Engine_get_packet(&g_hifUSBCtx.mpdnQ);
504     vdesc = VDESC_HW_TO_VDESC(desc);
505     vdesc->control = HIF_USB_PIPE_MP_TX;
506         
507     DMA_Engine_put_packet(&g_hifUSBCtx.upQ, desc);
508     MAGPIE_REG_USB_TX0_DMA_START = 1;
509
510     #else
511     buf = DMA_Engine_reap_recv_buf(&g_hifUSBCtx.mpdnQ);
512     g_hifUSBCtx.hifCb.recv_buf(NULL, buf, g_hifUSBCtx.hifCb.context);
513     #endif
514 }
515 #endif
516     
517 void _HIFusb_isr_handler(hif_handle_t h)
518 {
519     //struct zsDmaDesc* desc;
520     u32_t intr;
521
522 #ifdef OTUS_USB      
523     intr = ZM_PTA_INT_FLAG_REG;
524 #else
525     intr = MAGPIE_REG_USB_INTERRUPT;
526 #endif
527     
528 #ifdef OTUS_USB     
529     if ((intr & (ZM_PTA_DOWN_INT_BIT|ZM_PTA_UP_INT_BIT))!=0)
530 #else
531     if ((intr & (MAGPIE_REG_USB_INTERRUPT_TX0_COMPL|MAGPIE_REG_USB_INTERRUPT_RX0_COMPL| 
532         MAGPIE_REG_USB_INTERRUPT_RX1_COMPL|MAGPIE_REG_USB_INTERRUPT_RX2_COMPL)) != 0)
533 #endif        
534     {       
535 #if SYSTEM_MODULE_HP_EP5
536         do
537         {
538             if ( DMA_Engine_has_compl_packets(&g_hifUSBCtx.hpdnQ) )                  
539             {
540                 handle_hp_rx_complete_isr();
541             }       
542             else
543             {
544                 break;
545             }
546         }
547         while(1);
548 #endif // endif SYSTEM_MODULE_HP_EP5               
549          
550 #if SYSTEM_MODULE_HP_EP6
551         do
552         {
553             if ( DMA_Engine_has_compl_packets(&g_hifUSBCtx.mpdnQ) )                
554             {
555                 handle_mp_rx_complete_isr();
556             }
557             else
558             {
559                 break;
560             }           
561         }
562         while(1);
563 #endif // endif SYSTEM_MODULE_HP_EP5  
564                  
565         do
566         {
567             int check = 0;
568             
569             /* zgUpQ own bits changed */
570             if ( DMA_Engine_has_compl_packets((struct zsDmaQueue *)&g_hifUSBCtx.upQ) )           
571             {
572                 handle_tx_complete_isr();                       
573                 check = 1;
574             }/* end of while */
575                 
576             /* zgDnQ own bits changed */
577             if ( DMA_Engine_has_compl_packets(&g_hifUSBCtx.dnQ) )                          
578             {
579                 handle_rx_complete_isr();
580                 check = 1;
581             }       
582             
583             if ( check == 0 )
584             {
585                 break;
586             }
587         }       
588         while(1);               
589     }        
590 }
591
592 void _HIFusb_get_default_pipe(hif_handle_t handle, A_UINT8 *pipe_uplink, A_UINT8 *pipe_downlink)
593 {
594     *pipe_uplink = HIF_USB_PIPE_COMMAND;            // Host   -> Target
595     *pipe_downlink = HIF_USB_PIPE_INTERRUPT;        // Target -> Host
596 }
597     
598 /* the exported entry point into this module. All apis are accessed through
599  * function pointers */
600 void hif_usb_module_install(struct hif_api *apis)
601 {    
602         /* hook in APIs */
603     apis->_init = _HIFusb_init;
604     apis->_start = _HIFusb_start;
605     apis->_config_pipe = _HIFusb_config_pipe;
606     apis->_isr_handler = _HIFusb_isr_handler;
607     apis->_send_buffer = _HIFusb_send_buffer;
608     apis->_return_recv_buf = _HIFusb_return_recv_buf;
609     apis->_is_pipe_supported = _HIFusb_is_pipe_supported;
610     apis->_get_max_msg_len = _HIFusb_get_max_msg_len;
611     apis->_register_callback = _HIFusb_register_callback;
612     apis->_shutdown = _HIFusb_shutdown;
613     apis->_get_reserved_headroom = _HIFusb_get_reserved_headroom;
614     apis->_get_default_pipe = _HIFusb_get_default_pipe;
615         
616         /* save ptr to the ptr to the context for external code to inspect/modify internal module state */
617     //apis->pReserved = &g_pMboxHWContext;
618 }
619
620 void HIFusb_DescTraceDump(void )
621 {    
622 #if SYSTEM_MODULE_HP_EP5
623     A_PRINTF("\n\r[hp dnQ] 0x%08x, ", (u32_t)g_hifUSBCtx.hpdnQ.head);
624     A_PRINTF("DMA TRACE 0x%08x\n\r    [", HAL_WORD_REG_READ(MAGPIE_REG_USB_RX1_CUR_TRACE_ADDR));
625
626     DMA_Engine_desc_dump(&g_hifUSBCtx.hpdnQ);
627 #endif
628
629 #if SYSTEM_MODULE_HP_EP6
630     A_PRINTF("\n\r[mp dnQ] 0x%08x, ", (u32_t)g_hifUSBCtx.mpdnQ.head);
631     A_PRINTF("DMA TRACE 0x%08x\n\r    [", HAL_WORD_REG_READ(MAGPIE_REG_USB_RX2_CUR_TRACE_ADDR));
632
633     DMA_Engine_desc_dump(&g_hifUSBCtx.mpdnQ);
634 #endif
635
636     A_PRINTF("\n\r[dnQ] 0x%08x, ", (u32_t)g_hifUSBCtx.dnQ.head);
637     A_PRINTF("DMA TRACE 0x%08x\n\r    [", HAL_WORD_REG_READ(MAGPIE_REG_USB_RX0_CUR_TRACE_ADDR));
638     DMA_Engine_desc_dump(&g_hifUSBCtx.dnQ);
639
640     A_PRINTF("\n\n\r[upQ] 0x%08x, ", (u32_t)g_hifUSBCtx.upQ.head);
641     A_PRINTF("DMA TRACE 0x%08x\n\r    [", HAL_WORD_REG_READ(MAGPIE_REG_USB_TX0_CUR_TRACE_ADDR));
642     DMA_Engine_desc_dump((struct zsDmaQueue *)&g_hifUSBCtx.upQ);
643 }
644
645