From 9f3e2e3becac7148e01fbfcdcfb735622620a742 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 10 Sep 2013 16:01:44 -0600 Subject: [PATCH] SAMA5: Add tracing support to the OHCI driver --- arch/arm/src/sama5/sam_ohci.c | 130 ++++++++++++++++++++----------- arch/arm/src/sama5/sam_usbhost.c | 41 ++++++++++ arch/arm/src/sama5/sam_usbhost.h | 52 +++++++++++-- 3 files changed, 171 insertions(+), 52 deletions(-) diff --git a/arch/arm/src/sama5/sam_ohci.c b/arch/arm/src/sama5/sam_ohci.c index a59d441b07..0fe396a7cf 100644 --- a/arch/arm/src/sama5/sam_ohci.c +++ b/arch/arm/src/sama5/sam_ohci.c @@ -54,6 +54,7 @@ #include #include #include +#include #include @@ -1003,7 +1004,7 @@ static inline int sam_addinted(const FAR struct usbhost_epdesc_s *epdesc, interval = sam_getinterval(epdesc->interval); ed->interval = interval; - uvdbg("interval: %d->%d\n", epdesc->interval, interval); + usbhost_vtrace2(OHCI_VTRACE2_INTERVAL, epdesc->interval, interval); /* Get the offset associated with the ED direction. IN EDs get the even * entries, OUT EDs get the odd entries. @@ -1037,7 +1038,7 @@ static inline int sam_addinted(const FAR struct usbhost_epdesc_s *epdesc, } } - uvdbg("Min interval: %d offset: %d\n", interval, offset); + usbhost_vtrace2(OHCI_VTRACE2_MININTERVAL, interval, offset); /* Get the (physical) head of the first of the duplicated entries. The * first offset entry is always guaranteed to contain the common ED list @@ -1062,7 +1063,7 @@ static inline int sam_addinted(const FAR struct usbhost_epdesc_s *epdesc, physed = sam_physramaddr((uintptr_t)ed); sam_setinttab((uint32_t)physed, interval, offset); - uvdbg("head: %08x next: %08x\n", physed, physhead); + usbhost_vtrace1(OHCI_VTRACE1_PHYSED, physed); /* Re-enable periodic list processing */ @@ -1138,8 +1139,12 @@ static inline int sam_reminted(struct sam_ed_s *ed) physhead = g_hcca.inttbl[offset]; head = (struct sam_ed_s *)sam_virtramaddr((uintptr_t)physhead); +#ifdef CONFIG_USBHOST_TRACE + usbhost_vtrace1(OHCI_VTRACE1_VIRTED, (uintptr_t)ed); +#else uvdbg("ed: %08x head: %08x next: %08x offset: %d\n", ed, physhead, head ? head->hw.nexted : 0, offset); +#endif /* Find the ED to be removed in the ED list */ @@ -1174,8 +1179,12 @@ static inline int sam_reminted(struct sam_ed_s *ed) prev->hw.nexted = ed->hw.nexted; } +#ifdef CONFIG_USBHOST_TRACE + usbhost_vtrace1(OHCI_VTRACE1_VIRTED, (uintptr_t)ed); +#else uvdbg("ed: %08x head: %08x next: %08x\n", ed, physhead, head ? head->hw.nexted : 0); +#endif /* Calculate the new minimum interval for this list */ @@ -1188,7 +1197,7 @@ static inline int sam_reminted(struct sam_ed_s *ed) } } - uvdbg("Min interval: %d offset: %d\n", interval, offset); + usbhost_vtrace2(OHCI_VTRACE2_MININTERVAL, interval, offset); /* Save the new minimum interval */ @@ -1630,7 +1639,7 @@ static int sam_ctrltd(struct sam_rhport_s *rhport, uint32_t dirpid, ret = sam_wdhwait(rhport, edctrl); if (ret != OK) { - udbg("ERROR: Device disconnected\n"); + usbhost_trace1(OHCI_TRACE1_DEVDISCONN, rhport->rhpndx + 1); return ret; } @@ -1698,7 +1707,8 @@ static int sam_ctrltd(struct sam_rhport_s *rhport, uint32_t dirpid, } else { - udbg("ERROR: Bad TD completion status: %d\n", edctrl->tdstatus); + usbhost_trace2(OHCI_TRACE2_BADTDSTATUS, rhport->rhpndx + 1, + edctrl->tdstatus); ret = -EIO; } } @@ -1733,12 +1743,12 @@ static void sam_rhsc_bottomhalf(void) regaddr = SAM_USBHOST_RHPORTST(rhpndx+1); rhportst = sam_getreg(regaddr); - uvdbg("RHPORTST%d: %08x\n", rhpndx + 1, rhportst); + usbhost_vtrace2(OHCI_VTRACE2_RHPORTST, rhpndx + 1, (uint16_t)rhportst); if ((rhportst & OHCI_RHPORTST_CSC) != 0) { uint32_t rhstatus = sam_getreg(SAM_USBHOST_RHSTATUS); - uvdbg("Connect Status Change, RHSTATUS: %08x\n", rhstatus); + usbhost_vtrace1(OHCI_VTRACE1_CSC, rhstatus); /* If DRWE is set, Connect Status Change indicates a remote * wake-up event @@ -1746,7 +1756,7 @@ static void sam_rhsc_bottomhalf(void) if (rhstatus & OHCI_RHSTATUS_DRWE) { - uvdbg("DRWE: Remote wake-up\n"); + usbhost_vtrace1(OHCI_VTRACE1_DRWE, rhstatus); } /* Otherwise... Not a remote wake-up event */ @@ -1765,8 +1775,8 @@ static void sam_rhsc_bottomhalf(void) rhport->connected = true; - uvdbg("RHPort%d connected, rhswait: %d\n", - rhpndx + 1, g_ohci.rhswait); + usbhost_vtrace2(OHCI_VTRACE2_CONNECTED, + rhpndx + 1, g_ohci.rhswait); /* Notify any waiters */ @@ -1778,7 +1788,7 @@ static void sam_rhsc_bottomhalf(void) } else { - uvdbg("Spurious status change (connected)\n"); + usbhost_vtrace1(OHCI_VTRACE1_ALREADYCONN, rhportst); } /* The LSDA (Low speed device attached) bit is valid @@ -1786,7 +1796,7 @@ static void sam_rhsc_bottomhalf(void) */ rhport->lowspeed = (rhportst & OHCI_RHPORTST_LSDA) != 0; - uvdbg("Speed: %s\n", rhport->lowspeed ? "LOW" : "FULL"); + usbhost_vtrace1(OHCI_VTRACE1_SPEED, rhport->lowspeed); } /* Check if we are now disconnected */ @@ -1795,7 +1805,9 @@ static void sam_rhsc_bottomhalf(void) { /* Yes.. disconnect the device */ - uvdbg("RHport%d disconnected\n", rhpndx+1); + usbhost_vtrace2(OHCI_VTRACE2_DISCONNECTED, + rhpndx + 1, g_ohci.rhswait); + rhport->connected = false; rhport->lowspeed = false; @@ -1821,7 +1833,7 @@ static void sam_rhsc_bottomhalf(void) } else { - uvdbg("Spurious status change (disconnected)\n"); + usbhost_vtrace1(OHCI_VTRACE1_ALREADYDISCONN, rhportst); } } @@ -1903,7 +1915,7 @@ static void sam_wdh_bottomhalf(void) eplist = ed->eplist; DEBUGASSERT(eplist != NULL); - /* Also nvalidate the control ED so that it two will be re-read from + /* Also invalidate the control ED so that it two will be re-read from * memory. */ @@ -1916,13 +1928,12 @@ static void sam_wdh_bottomhalf(void) ed->tdstatus = (td->hw.ctrl & GTD_STATUS_CC_MASK) >> GTD_STATUS_CC_SHIFT; -#ifdef CONFIG_DEBUG_USB +#if defined(CONFIG_DEBUG_USB) || defined(CONFIG_USBHOST_TRACE) if (ed->tdstatus != TD_CC_NOERROR) { /* The transfer failed for some reason... dump some diagnostic info. */ - udbg("ERROR: ED xfrtype: %d TD CTRL: %08x/CC: %d\n", - ed->xfrtype, td->hw.ctrl, ed->tdstatus); + usbhost_trace2(OHCI_TRACE2_WHDTDSTATUS, ed->tdstatus, ed->xfrtype); } #endif @@ -1970,7 +1981,7 @@ static void sam_ohci_bottomhalf(void *arg) { /* Handle root hub status change on each root port */ - uvdbg("Root Hub Status Change\n"); + usbhost_vtrace1(OHCI_VTRACE1_RHSC, pending); sam_rhsc_bottomhalf(); } @@ -1983,7 +1994,7 @@ static void sam_ohci_bottomhalf(void *arg) * in the preceding frame. */ - uvdbg("Writeback Done Head interrupt\n"); + usbhost_vtrace1(OHCI_VTRACE1_WDHINTR, pending); sam_wdh_bottomhalf(); } @@ -2002,12 +2013,12 @@ static void sam_ohci_bottomhalf(void *arg) * interrupt will not be occurring). */ - udbg("ERROR: Unrecoverable error. pending: %08x\n", pending); + usbhost_trace1(OHCI_TRACE1_INTRUNRECOVERABLE, pending); sam_wdh_bottomhalf(); } else { - udbg("ERROR: Unhandled interrupts pending: %08x\n", pending); + usbhost_trace1(OHCI_TRACE1_INTRUNHANDLED, pending); } } #endif @@ -2090,10 +2101,8 @@ static int sam_wait(FAR struct usbhost_connection_s *conn, */ irqrestore(flags); - - uvdbg("RHPort%d connected: %s\n", - rhpndx + 1, g_ohci.rhport[rhpndx].connected ? "YES" : "NO"); - + usbhost_vtrace2(OHCI_VTRACE2_WAKEUP, + rhpndx + 1, g_ohci.rhport[rhpndx].connected); return rhpndx; } } @@ -2153,7 +2162,7 @@ static int sam_enumerate(FAR struct usbhost_connection_s *conn, int rhpndx) { /* No, return an error */ - uvdbg("Not connected\n"); + usbhost_vtrace1(OHCI_VTRACE1_ENUMDISCONN, rhport->rhpndx + 1); return -ENODEV; } @@ -2164,7 +2173,8 @@ static int sam_enumerate(FAR struct usbhost_connection_s *conn, int rhpndx) ret = sam_ep0enqueue(rhport); if (ret < 0) { - udbg("ERROR: Failed to enqueue EP0\n"); + usbhost_trace2(OHCI_TRACE2_EP0ENQUEUE_FAILED, rhport->rhpndx + 1, + -ret); return ret; } @@ -2177,7 +2187,9 @@ static int sam_enumerate(FAR struct usbhost_connection_s *conn, int rhpndx) up_mdelay(100); - /* Put the root hub port in reset (the SAMA5 supports three downstream ports) */ + /* Put the root hub port in reset (the SAMA5 supports three downstream + * ports) + */ regaddr = SAM_USBHOST_RHPORTST(rhpndx+1); sam_putreg(OHCI_RHPORTST_PRS, regaddr); @@ -2195,8 +2207,14 @@ static int sam_enumerate(FAR struct usbhost_connection_s *conn, int rhpndx) * FunctionAddress (USB address) is set to the root hub port number for now. */ - uvdbg("Enumerate the device\n"); - return usbhost_enumerate(&g_ohci.rhport[rhpndx].drvr, rhpndx+1, &rhport->class); + usbhost_vtrace2(OHCI_VTRACE2_CLASSENUM, rhpndx+1, rhpndx+1); + ret = usbhost_enumerate(&g_ohci.rhport[rhpndx].drvr, rhpndx+1, &rhport->class); + if (ret < 0) + { + usbhost_trace2(OHCI_TRACE2_CLASSENUM_FAILED, rhpndx+1, -ret); + } + + return ret; } /************************************************************************************ @@ -2261,7 +2279,8 @@ static int sam_ep0configure(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr, (uintptr_t)edctrl + sizeof(struct ohci_ed_s) - 1); sam_givesem(&g_ohci.exclsem); - uvdbg("RHPort%d EP0 CTRL: %08x\n", rhport->rhpndx + 1, edctrl->hw.ctrl); + usbhost_vtrace2(OHCI_VTRACE2_EP0CONFIGURE, + rhport->rhpndx + 1, (uint16_t)edctrl->hw.ctrl); return OK; } @@ -2339,7 +2358,7 @@ static int sam_epalloc(FAR struct usbhost_driver_s *drvr, eplist = (struct sam_eplist_s *)kzalloc(sizeof(struct sam_eplist_s)); if (!eplist) { - udbg("ERROR: Failed to allocate EP list\n"); + usbhost_trace1(OHCI_TRACE1_EPLISTALLOC_FAILED, 0); goto errout; } @@ -2358,14 +2377,14 @@ static int sam_epalloc(FAR struct usbhost_driver_s *drvr, ed = sam_edalloc(); if (!ed) { - udbg("ERROR: Failed to allocate ED\n"); + usbhost_trace1(OHCI_TRACE1_EDALLOC_FAILED, 0); goto errout_with_semaphore; } td = sam_tdalloc(); if (!td) { - udbg("ERROR: Failed to allocate TD\n"); + usbhost_trace1(OHCI_TRACE1_TDALLOC_FAILED, 0); goto errout_with_ed; } @@ -2413,7 +2432,7 @@ static int sam_epalloc(FAR struct usbhost_driver_s *drvr, #endif ed->eplist = eplist; - uvdbg("EP%d CTRL: %08x\n", epdesc->addr, ed->hw.ctrl); + usbhost_vtrace2(OHCI_VTRACE2_EPALLOC, epdesc->addr, (uint16_t)ed->hw.ctrl); /* Configure the tail descriptor. */ @@ -2461,7 +2480,7 @@ static int sam_epalloc(FAR struct usbhost_driver_s *drvr, { /* No.. destroy it and report the error */ - udbg("ERROR: Failed to queue ED for transfer type: %d\n", ed->xfrtype); + usbhost_trace2(OHCI_TRACE2_EDENQUEUE_FAILED, ed->xfrtype, -ret); goto errout_with_td; } @@ -2764,9 +2783,14 @@ static int sam_ctrlin(FAR struct usbhost_driver_s *drvr, int ret; DEBUGASSERT(rhport && req); + +#ifdef CONFIG_USBHOST_TRACE + usbhost_vtrace2(OHCI_VTRACE2_CTRLIN, rhport->rhpndx + 1, req->req); +#else uvdbg("RHPort%d type: %02x req: %02x value: %02x%02x index: %02x%02x len: %02x%02x\n", rhport->rhpndx + 1, req->type, req->req, req->value[1], req->value[0], req->index[1], req->index[0], req->len[1], req->len[0]); +#endif /* We must have exclusive access to EP0 and the control list */ @@ -2805,9 +2829,14 @@ static int sam_ctrlout(FAR struct usbhost_driver_s *drvr, int ret; DEBUGASSERT(rhport && req); + +#ifdef CONFIG_USBHOST_TRACE + usbhost_vtrace2(OHCI_VTRACE2_CTRLOUT, rhport->rhpndx + 1, req->req); +#else uvdbg("RHPort%d type: %02x req: %02x value: %02x%02x index: %02x%02x len: %02x%02x\n", rhport->rhpndx + 1, req->type, req->req, req->value[1], req->value[0], req->index[1], req->index[0], req->len[1], req->len[0]); +#endif /* We must have exclusive access to EP0 and the control list */ @@ -2887,12 +2916,18 @@ static int sam_transfer(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep, ed = eplist->ed; in = (ed->hw.ctrl & ED_CONTROL_D_MASK) == ED_CONTROL_D_IN; +#ifdef CONFIG_USBHOST_TRACE + usbhost_vtrace2(OHCI_VTRACE2_TRANSFER, + (ed->hw.ctrl & ED_CONTROL_EN_MASK) >> ED_CONTROL_EN_SHIFT, + (uint16_t)buflen); +#else uvdbg("EP%d %s toggle: %d maxpacket: %d buflen: %d\n", (ed->hw.ctrl & ED_CONTROL_EN_MASK) >> ED_CONTROL_EN_SHIFT, in ? "IN" : "OUT", (ed->hw.headp & ED_HEADP_C) != 0 ? 1 : 0, (ed->hw.ctrl & ED_CONTROL_MPS_MASK) >> ED_CONTROL_MPS_SHIFT, buflen); +#endif /* We must have exclusive access to the endpoint, the TD pool, the I/O buffer * pool, the bulk and interrupt lists, and the HCCA interrupt table. @@ -2907,7 +2942,7 @@ static int sam_transfer(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep, ret = sam_wdhwait(rhport, ed); if (ret != OK) { - udbg("ERROR: Device disconnected\n"); + usbhost_trace1(OHCI_TRACE1_DEVDISCONN, rhport->rhpndx + 1); goto errout; } @@ -2990,7 +3025,8 @@ static int sam_transfer(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep, } else { - udbg("ERROR: Bad TD completion status: %d\n", ed->tdstatus); + usbhost_trace2(OHCI_TRACE2_BADTDSTATUS, rhport->rhpndx + 1, + ed->tdstatus); ret = ed->tdstatus == TD_CC_STALL ? -EPERM : -EIO; } } @@ -3150,7 +3186,7 @@ FAR struct usbhost_connection_s *sam_ohci_initialize(int controller) * dedicated function */ - uvdbg("Initializing OHCI Stack\n"); + usbhost_vtrace1(OHCI_VTRACE1_INITIALIZING, 0); /* Initialize all the HCCA to 0 */ @@ -3256,7 +3292,7 @@ FAR struct usbhost_connection_s *sam_ohci_initialize(int controller) if (irq_attach(SAM_IRQ_UHPHS, sam_ohci_tophalf) != 0) { - udbg("ERROR: Failed to attach IRQ\n"); + usbhost_trace1(OHCI_TRACE1_IRQATTACH, SAM_IRQ_UHPHS); return NULL; } @@ -3290,8 +3326,8 @@ FAR struct usbhost_connection_s *sam_ohci_initialize(int controller) regval = sam_getreg(SAM_USBHOST_RHPORTST(i)); g_ohci.rhport[i].connected = ((regval & OHCI_RHPORTST_CCS) != 0); - uvdbg("RHPort%d Device connected: %s\n", - i+1, g_ohci.rhport[i].connected ? "YES" : "NO"); + usbhost_vtrace2(OHCI_VTRACE2_INITCONNECTED, + i+1, g_ohci.rhport[i].connected); } /* Enable interrupts at the interrupt controller. If ECHI is enabled, @@ -3302,7 +3338,7 @@ FAR struct usbhost_connection_s *sam_ohci_initialize(int controller) #endif /* CONFIG_SAMA5_EHCI */ - uvdbg("USB OHCI Initialized\n"); + usbhost_vtrace1(OHCI_VTRACE1_INITIALIZED, 0); /* Initialize and return the connection interface */ @@ -3329,9 +3365,9 @@ int sam_ohci_tophalf(int irq, FAR void *context) /* Read Interrupt Status and mask out interrupts that are not enabled. */ - intst = sam_getreg(SAM_USBHOST_INTST); + intst = sam_getreg(SAM_USBHOST_INTST); inten = sam_getreg(SAM_USBHOST_INTEN); - ullvdbg("INST: %08x INTEN: %08x\n", intst, inten); + usbhost_vtrace1(OHCI_VTRACE1_INTRPENDING, intst & inten); #ifdef CONFIG_SAMA5_EHCI /* Check the Master Interrupt Enable bit (MIE). It this function is called diff --git a/arch/arm/src/sama5/sam_usbhost.c b/arch/arm/src/sama5/sam_usbhost.c index 80765f1472..95125c7463 100644 --- a/arch/arm/src/sama5/sam_usbhost.c +++ b/arch/arm/src/sama5/sam_usbhost.c @@ -87,7 +87,28 @@ struct sam_usbhost_trace_s static const struct sam_usbhost_trace_s g_trace1[TRACE1_NSTRINGS] = { #ifdef CONFIG_SAMA5_OHCI + TRENTRY(OHCI_TRACE1_DEVDISCONN, TR_OHCI, TR_FMT1, "OHCI ERROR: RHport%d Device disconnected\n"), + TRENTRY(OHCI_TRACE1_INTRUNRECOVERABLE, TR_OHCI, TR_FMT1, "OHCI ERROR: Unrecoverable error. pending: %06x\n"), + TRENTRY(OHCI_TRACE1_INTRUNHANDLED, TR_OHCI, TR_FMT1, "OHCI ERROR: Unhandled interrupts pending: %06x\n"), + TRENTRY(OHCI_TRACE1_EPLISTALLOC_FAILED, TR_OHCI, TR_FMT1, "OHCI ERROR: Failed to allocate EP list\n"), + TRENTRY(OHCI_TRACE1_EDALLOC_FAILED, TR_OHCI, TR_FMT1, "OHCI ERROR: Failed to allocate ED\n"), + TRENTRY(OHCI_TRACE1_TDALLOC_FAILED, TR_OHCI, TR_FMT1, "OHCI ERROR: Failed to allocate TD\n"), + TRENTRY(OHCI_TRACE1_IRQATTACH, TR_OHCI, TR_FMT1, "OHCI ERROR: Failed to attach IRQ%d\n"), + #ifdef CONFIG_USBHOST_TRACE_VERBOSE + TRENTRY(OHCI_VTRACE1_PHYSED, TR_OHCI, TR_FMT1, "OHCI physed: %06x\n"), + TRENTRY(OHCI_VTRACE1_VIRTED, TR_OHCI, TR_FMT1, "OHCI ed: %06x\n"), + TRENTRY(OHCI_VTRACE1_CSC, TR_OHCI, TR_FMT1, "OHCI Connect Status Change, RHSTATUS: %06x\n"), + TRENTRY(OHCI_VTRACE1_DRWE, TR_OHCI, TR_FMT1, "OHCI DRWE: Remote wake-up, RHSTATUS: %06x\n"), + TRENTRY(OHCI_VTRACE1_ALREADYCONN, TR_OHCI, TR_FMT1, "OHCI Already connected, RHPORTST%d: %06x\n"), + TRENTRY(OHCI_VTRACE1_SPEED, TR_OHCI, TR_FMT1, "OHCI Low speed: %d\n"), + TRENTRY(OHCI_VTRACE1_ALREADYDISCONN, TR_OHCI, TR_FMT1, "OHCI Already disconnected, RHPORTST%d: %06x\n"), + TRENTRY(OHCI_VTRACE1_RHSC, TR_OHCI, TR_FMT1, "OHCI Root Hub Status Change. Pending: %06x\n"), + TRENTRY(OHCI_VTRACE1_WDHINTR, TR_OHCI, TR_FMT1, "OHCI Writeback Done Head interrupt. Pending: %06x\n"), + TRENTRY(OHCI_VTRACE1_ENUMDISCONN, TR_OHCI, TR_FMT1, "OHCI RHport%dNot connected\n"), + TRENTRY(OHCI_VTRACE1_INITIALIZING, TR_OHCI, TR_FMT1, "OHCI Initializing Stack\n"), + TRENTRY(OHCI_VTRACE1_INITIALIZED, TR_OHCI, TR_FMT1, "OHCI Initialized\n"), + TRENTRY(OHCI_VTRACE1_INTRPENDING, TR_OHCI, TR_FMT1, "OHCI Interrupts pending: %06x\n"), #endif #endif @@ -117,6 +138,7 @@ static const struct sam_usbhost_trace_s g_trace1[TRACE1_NSTRINGS] = TRENTRY(EHCI_TRACE1_RESET_FAILED, TR_EHCI, TR_FMT1, "EHCI ERROR: sam_reset failed: %d\n"), TRENTRY(EHCI_TRACE1_RUN_FAILED, TR_EHCI, TR_FMT1, "EHCI ERROR: EHCI Failed to run: USBSTS=%08x\n"), TRENTRY(EHCI_TRACE1_IRQATTACH_FAILED, TR_EHCI, TR_FMT1, "EHCI ERROR: Failed to attach IRQ%d\n"), + #ifdef CONFIG_USBHOST_TRACE_VERBOSE TRENTRY(EHCI_VTRACE1_PORTSC_CSC, TR_EHCI, TR_FMT1, "EHCI Connect Status Change: %06x\n"), TRENTRY(EHCI_VTRACE1_PORTSC_CONNALREADY, TR_EHCI, TR_FMT1, "EHCI Already connected: %06x\n"), @@ -135,7 +157,26 @@ static const struct sam_usbhost_trace_s g_trace1[TRACE1_NSTRINGS] = static const struct sam_usbhost_trace_s g_trace2[TRACE2_NSTRINGS] = { #ifdef CONFIG_SAMA5_OHCI + TRENTRY(OHCI_TRACE2_BADTDSTATUS, TR_OHCI, TR_FMT2, "OHCI ERROR: RHport%d Bad TD completion status: %d\n"), + TRENTRY(OHCI_TRACE2_WHDTDSTATUS, TR_OHCI, TR_FMT2, "OHCI ERROR: WHD Bad TD completion status: %d xfrtype: %d\n"), + TRENTRY(OHCI_TRACE2_EP0ENQUEUE_FAILED, TR_OHCI, TR_FMT2, "OHCI ERROR: RHport%d Failed to enqueue EP0: %d\n"), + TRENTRY(OHCI_TRACE2_EDENQUEUE_FAILED, TR_OHCI, TR_FMT2, "OHCI ERROR: Failed to queue ED for transfer type %d: %d\n"), + TRENTRY(OHCI_TRACE2_CLASSENUM_FAILED, TR_OHCI, TR_FMT2, "OHCI RHport%d usbhost_enumerate() failed: %d\n"), + #ifdef CONFIG_USBHOST_TRACE_VERBOSE + TRENTRY(OHCI_VTRACE2_INTERVAL, TR_OHCI, TR_FMT2, "OHCI interval: %d->%d\n"), + TRENTRY(OHCI_VTRACE2_MININTERVAL, TR_OHCI, TR_FMT2, "OHCI MIN interval: %d offset: %d\n"), + TRENTRY(OHCI_VTRACE2_RHPORTST, TR_OHCI, TR_FMT2, "OHCI RHPORTST%d: %04x\n"), + TRENTRY(OHCI_VTRACE2_CONNECTED, TR_OHCI, TR_FMT2, "OHCI RHPort%d connected, rhswait: %d\n"), + TRENTRY(OHCI_VTRACE2_DISCONNECTED, TR_OHCI, TR_FMT2, "OHCI RHPort%d disconnected, rhswait: %d\n"), + TRENTRY(OHCI_VTRACE2_WAKEUP, TR_OHCI, TR_FMT2, "OHCI RHPort%d connected: %d\n"), + TRENTRY(OHCI_VTRACE2_CLASSENUM, TR_OHCI, TR_FMT2, "OHCI RHPort%d: Enumerate the device, devaddr=%02x\n"), + TRENTRY(OHCI_VTRACE2_EP0CONFIGURE, TR_OHCI, TR_FMT2, "OHCI RHPort%d EP0 CTRL: %04x\n"), + TRENTRY(OHCI_VTRACE2_EPALLOC, TR_OHCI, TR_FMT2, "OHCI EP%d CTRL: %04x\n"), + TRENTRY(OHCI_VTRACE2_CTRLIN, TR_OHCI, TR_FMT2, "OHCI CTRLIN RHPort%d req: %02x\n"), + TRENTRY(OHCI_VTRACE2_CTRLOUT, TR_OHCI, TR_FMT2, "OHCI CTRLOUT RHPort%d req: %02x\n"), + TRENTRY(OHCI_VTRACE2_TRANSFER, TR_OHCI, TR_FMT2, "OHCI EP%d buflen: %d\n"), + TRENTRY(OHCI_VTRACE2_INITCONNECTED, TR_OHCI, TR_FMT2, "OHCI RHPort%d Device connected: %d\n"), #endif #endif diff --git a/arch/arm/src/sama5/sam_usbhost.h b/arch/arm/src/sama5/sam_usbhost.h index 2adfa3fd2b..74928a6a06 100644 --- a/arch/arm/src/sama5/sam_usbhost.h +++ b/arch/arm/src/sama5/sam_usbhost.h @@ -68,13 +68,36 @@ enum usbhost_trace1codes_e { + __TRACE1_BASEVALUE = 0, /* This will force the first value to be 1 */ + #ifdef CONFIG_SAMA5_OHCI + OHCI_TRACE1_DEVDISCONN, /* OHCI ERROR: RHport Device disconnected */ + OHCI_TRACE1_INTRUNRECOVERABLE, /* OHCI ERROR: Unrecoverable error */ + OHCI_TRACE1_INTRUNHANDLED, /* OHCI ERROR: Unhandled interrupts */ + OHCI_TRACE1_EPLISTALLOC_FAILED, /* OHCI ERROR: Failed to allocate EP list */ + OHCI_TRACE1_EDALLOC_FAILED, /* OHCI ERROR: Failed to allocate ED */ + OHCI_TRACE1_TDALLOC_FAILED, /* OHCI ERROR: Failed to allocate TD */ + OHCI_TRACE1_IRQATTACH, /* OHCI ERROR: Failed to attach IRQ */ + #ifdef CONFIG_USBHOST_TRACE_VERBOSE + OHCI_VTRACE1_PHYSED, /* OHCI physed */ + OHCI_VTRACE1_VIRTED, /* OHCI ed */ + OHCI_VTRACE1_CSC, /* OHCI Connect Status Change */ + OHCI_VTRACE1_DRWE, /* OHCI DRWE: Remote wake-up */ + OHCI_VTRACE1_ALREADYCONN, /* OHCI Already connected */ + OHCI_VTRACE1_SPEED, /* OHCI Low speed */ + OHCI_VTRACE1_ALREADYDISCONN, /* OHCI Already disconnected */ + OHCI_VTRACE1_RHSC, /* OHCI Root Hub Status Change */ + OHCI_VTRACE1_WDHINTR, /* OHCI Writeback Done Head interrupt */ + OHCI_VTRACE1_ENUMDISCONN, /* OHCI RHport Not connected */ + OHCI_VTRACE1_INITIALIZING, /* OHCI Initializing Stack */ + OHCI_VTRACE1_INITIALIZED, /* OHCI Initialized */ + OHCI_VTRACE1_INTRPENDING, /* OHCI Interrupts pending */ #endif #endif #ifdef CONFIG_SAMA5_EHCI - EHCI_TRACE1_SYSTEMERROR = 0, /* EHCI ERROR: System error */ + EHCI_TRACE1_SYSTEMERROR, /* EHCI ERROR: System error */ EHCI_TRACE1_QTDFOREACH_FAILED, /* EHCI ERROR: sam_qtd_foreach failed */ EHCI_TRACE1_QHALLOC_FAILED, /* EHCI ERROR: Failed to allocate a QH */ EHCI_TRACE1_BUFTOOBIG, /* EHCI ERROR: Buffer too big */ @@ -114,10 +137,29 @@ enum usbhost_trace1codes_e #endif #endif - __TRACE1_NSTRINGS, + __TRACE1_NSTRINGS, /* Separates the format 1 from the format 2 strings */ #ifdef CONFIG_SAMA5_OHCI + OHCI_TRACE2_BADTDSTATUS, /* OHCI ERROR: RHport Bad TD completion status */ + OHCI_TRACE2_WHDTDSTATUS, /* OHCI ERROR: WDH Bad TD completion status */ + OHCI_TRACE2_EP0ENQUEUE_FAILED, /* OHCI ERROR: RHport Failed to enqueue EP0 */ + OHCI_TRACE2_EDENQUEUE_FAILED, /* OHCI ERROR: Failed to queue ED for transfer type */ + OHCI_TRACE2_CLASSENUM_FAILED, /* OHCI usbhost_enumerate() failed */ + #ifdef CONFIG_USBHOST_TRACE_VERBOSE + OHCI_VTRACE2_INTERVAL, /* OHCI interval */ + OHCI_VTRACE2_MININTERVAL, /* OHCI MIN interval/offset */ + OHCI_VTRACE2_RHPORTST, /* OHCI RHPORTST */ + OHCI_VTRACE2_CONNECTED, /* OHCI RHPort connected */ + OHCI_VTRACE2_DISCONNECTED, /* OHCI RHPort disconnected */ + OHCI_VTRACE2_WAKEUP, /* OHCI RHPort connected */ + OHCI_VTRACE2_CLASSENUM, /* OHCI Enumerate the device */ + OHCI_VTRACE2_EP0CONFIGURE, /* OHCI RHPort EP0 CTRL */ + OHCI_VTRACE2_EPALLOC, /* OHCI EP CTRL */ + OHCI_VTRACE2_CTRLIN, /* OHCI CTRLIN */ + OHCI_VTRACE2_CTRLOUT, /* OHCI CTRLOUT */ + OHCI_VTRACE2_TRANSFER, /* OHCI EP buflen */ + OHCI_VTRACE2_INITCONNECTED, /* OHCI RHPort Device connected */ #endif #endif @@ -142,14 +184,14 @@ enum usbhost_trace1codes_e #endif #endif - __TRACE2_NSTRINGS + __TRACE2_NSTRINGS /* Total number of enumeration values */ }; -#define TRACE1_FIRST 0 +#define TRACE1_FIRST ((int)__TRACE1_BASEVALUE + 1) #define TRACE1_INDEX(id) ((int)(id) - TRACE1_FIRST) #define TRACE1_NSTRINGS TRACE1_INDEX(__TRACE1_NSTRINGS) -#define TRACE2_FIRST (__TRACE1_NSTRINGS + 1) +#define TRACE2_FIRST ((int)__TRACE1_NSTRINGS + 1) #define TRACE2_INDEX(id) ((int)(id) - TRACE2_FIRST) #define TRACE2_NSTRINGS TRACE2_INDEX(__TRACE2_NSTRINGS)