]> git.ipfire.org Git - people/arne_f/kernel.git/commitdiff
xhci: Add port status decoder for tracing purposes
authorMathias Nyman <mathias.nyman@linux.intel.com>
Wed, 16 Aug 2017 11:23:22 +0000 (14:23 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Aug 2017 22:26:26 +0000 (15:26 -0700)
Add PORTSC Port status and control register decoder to
show human readable tracing of portsc register

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci.h

index 18fe51c4ca856c11d0d9ba52daef158dbe91c403..2abaa4d6d39daa74ff379020171efaf34a7e9197 100644 (file)
@@ -2399,6 +2399,87 @@ static inline const char *xhci_decode_slot_context(u32 info, u32 info2,
        return str;
 }
 
+
+static inline const char *xhci_portsc_link_state_string(u32 portsc)
+{
+       switch (portsc & PORT_PLS_MASK) {
+       case XDEV_U0:
+               return "U0";
+       case XDEV_U1:
+               return "U1";
+       case XDEV_U2:
+               return "U2";
+       case XDEV_U3:
+               return "U3";
+       case XDEV_DISABLED:
+               return "Disabled";
+       case XDEV_RXDETECT:
+               return "RxDetect";
+       case XDEV_INACTIVE:
+               return "Inactive";
+       case XDEV_POLLING:
+               return "Polling";
+       case XDEV_RECOVERY:
+               return "Recovery";
+       case XDEV_HOT_RESET:
+               return "Hot Reset";
+       case XDEV_COMP_MODE:
+               return "Compliance mode";
+       case XDEV_TEST_MODE:
+               return "Test mode";
+       case XDEV_RESUME:
+               return "Resume";
+       default:
+               break;
+       }
+       return "Unknown";
+}
+
+static inline const char *xhci_decode_portsc(u32 portsc)
+{
+       static char str[256];
+       int ret;
+
+       ret = sprintf(str, "%s %s %s Link:%s ",
+                     portsc & PORT_POWER       ? "Powered" : "Powered-off",
+                     portsc & PORT_CONNECT     ? "Connected" : "Not-connected",
+                     portsc & PORT_PE          ? "Enabled" : "Disabled",
+                     xhci_portsc_link_state_string(portsc));
+
+       if (portsc & PORT_OC)
+               ret += sprintf(str + ret, "OverCurrent ");
+       if (portsc & PORT_RESET)
+               ret += sprintf(str + ret, "In-Reset ");
+
+       ret += sprintf(str + ret, "Change: ");
+       if (portsc & PORT_CSC)
+               ret += sprintf(str + ret, "CSC ");
+       if (portsc & PORT_PEC)
+               ret += sprintf(str + ret, "PEC ");
+       if (portsc & PORT_WRC)
+               ret += sprintf(str + ret, "WRC ");
+       if (portsc & PORT_OCC)
+               ret += sprintf(str + ret, "OCC ");
+       if (portsc & PORT_RC)
+               ret += sprintf(str + ret, "PRC ");
+       if (portsc & PORT_PLC)
+               ret += sprintf(str + ret, "PLC ");
+       if (portsc & PORT_CEC)
+               ret += sprintf(str + ret, "CEC ");
+       if (portsc & PORT_CAS)
+               ret += sprintf(str + ret, "CAS ");
+
+       ret += sprintf(str + ret, "Wake: ");
+       if (portsc & PORT_WKCONN_E)
+               ret += sprintf(str + ret, "WCE ");
+       if (portsc & PORT_WKDISC_E)
+               ret += sprintf(str + ret, "WDE ");
+       if (portsc & PORT_WKOC_E)
+               ret += sprintf(str + ret, "WOE ");
+
+       return str;
+}
+
 static inline const char *xhci_ep_state_string(u8 state)
 {
        switch (state) {