diff options
author | Felipe Balbi <felipe.balbi@linux.intel.com> | 2016-05-23 10:10:08 +0200 |
---|---|---|
committer | Felipe Balbi <felipe.balbi@linux.intel.com> | 2016-06-20 11:32:39 +0200 |
commit | f75cacc468edc4826305909d6102d60fba55199f (patch) | |
tree | b4c985613ed1383a7a66b74c5890a63a0dc3f7cd /drivers/usb/dwc3/debug.h | |
parent | usb: dwc3: gadget: no more tracking endpoint type with its name (diff) | |
download | linux-f75cacc468edc4826305909d6102d60fba55199f.tar.xz linux-f75cacc468edc4826305909d6102d60fba55199f.zip |
usb: dwc3: trace: fully decode IRQ events
This will make it more human-friendly to read trace
output from dwc3.
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb/dwc3/debug.h')
-rw-r--r-- | drivers/usb/dwc3/debug.h | 110 |
1 files changed, 88 insertions, 22 deletions
diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h index 71e318025964..e3e0b4111c53 100644 --- a/drivers/usb/dwc3/debug.h +++ b/drivers/usb/dwc3/debug.h @@ -128,56 +128,112 @@ dwc3_gadget_link_string(enum dwc3_link_state link_state) * dwc3_gadget_event_string - returns event name * @event: the event code */ -static inline const char *dwc3_gadget_event_string(u8 event) +static inline const char * +dwc3_gadget_event_string(const struct dwc3_event_devt *event) { - switch (event) { + static char str[256]; + enum dwc3_link_state state = event->event_info & DWC3_LINK_STATE_MASK; + + switch (event->type) { case DWC3_DEVICE_EVENT_DISCONNECT: - return "Disconnect"; + sprintf(str, "Disconnect: [%s]", + dwc3_gadget_link_string(state)); + break; case DWC3_DEVICE_EVENT_RESET: - return "Reset"; + sprintf(str, "Reset [%s]", dwc3_gadget_link_string(state)); + break; case DWC3_DEVICE_EVENT_CONNECT_DONE: - return "Connection Done"; + sprintf(str, "Connection Done [%s]", + dwc3_gadget_link_string(state)); + break; case DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE: - return "Link Status Change"; + sprintf(str, "Link Change [%s]", + dwc3_gadget_link_string(state)); + break; case DWC3_DEVICE_EVENT_WAKEUP: - return "WakeUp"; + sprintf(str, "WakeUp [%s]", dwc3_gadget_link_string(state)); + break; case DWC3_DEVICE_EVENT_EOPF: - return "End-Of-Frame"; + sprintf(str, "End-Of-Frame [%s]", + dwc3_gadget_link_string(state)); + break; case DWC3_DEVICE_EVENT_SOF: - return "Start-Of-Frame"; + sprintf(str, "Start-Of-Frame [%s]", + dwc3_gadget_link_string(state)); + break; case DWC3_DEVICE_EVENT_ERRATIC_ERROR: - return "Erratic Error"; + sprintf(str, "Erratic Error [%s]", + dwc3_gadget_link_string(state)); + break; case DWC3_DEVICE_EVENT_CMD_CMPL: - return "Command Complete"; + sprintf(str, "Command Complete [%s]", + dwc3_gadget_link_string(state)); + break; case DWC3_DEVICE_EVENT_OVERFLOW: - return "Overflow"; + sprintf(str, "Overflow [%s]", dwc3_gadget_link_string(state)); + break; + default: + sprintf(str, "UNKNOWN"); } - return "UNKNOWN"; + return str; } /** * dwc3_ep_event_string - returns event name * @event: then event code */ -static inline const char *dwc3_ep_event_string(u8 event) +static inline const char * +dwc3_ep_event_string(const struct dwc3_event_depevt *event) { - switch (event) { + u8 epnum = event->endpoint_number; + static char str[256]; + int status; + int ret; + + ret = sprintf(str, "ep%d%s: ", epnum >> 1, + (epnum & 1) ? "in" : "in"); + if (ret < 0) + return "UNKNOWN"; + + switch (event->endpoint_event) { case DWC3_DEPEVT_XFERCOMPLETE: - return "Transfer Complete"; + strcat(str, "Transfer Complete"); + break; case DWC3_DEPEVT_XFERINPROGRESS: - return "Transfer In-Progress"; + strcat(str, "Transfer In-Progress"); + break; case DWC3_DEPEVT_XFERNOTREADY: - return "Transfer Not Ready"; + strcat(str, "Transfer Not Ready"); + status = event->status & DEPEVT_STATUS_TRANSFER_ACTIVE; + strcat(str, status ? " (Active)" : " (Not Active)"); + break; case DWC3_DEPEVT_RXTXFIFOEVT: - return "FIFO"; + strcat(str, "FIFO"); + break; case DWC3_DEPEVT_STREAMEVT: - return "Stream"; + status = event->status; + + switch (status) { + case DEPEVT_STREAMEVT_FOUND: + sprintf(str + ret, " Stream %d Found", + event->parameters); + break; + case DEPEVT_STREAMEVT_NOTFOUND: + default: + strcat(str, " Stream Not Found"); + break; + } + + break; case DWC3_DEPEVT_EPCMDCMPLT: - return "Endpoint Command Complete"; + strcat(str, "Endpoint Command Complete"); + break; + default: + sprintf(str, "UNKNOWN"); } - return "UNKNOWN"; + return str; } /** @@ -214,6 +270,16 @@ static inline const char *dwc3_gadget_event_type_string(u8 event) } } +static inline const char *dwc3_decode_event(u32 event) +{ + const union dwc3_event evt = (union dwc3_event) event; + + if (evt.type.is_devspec) + return dwc3_gadget_event_string(&evt.devt); + else + return dwc3_ep_event_string(&evt.depevt); +} + void dwc3_trace(void (*trace)(struct va_format *), const char *fmt, ...); #ifdef CONFIG_DEBUG_FS |