Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / usb / host / ehci-dbg.c
index bb8bf4c..65ac9fe 100644 (file)
 /* this file is part of ehci-hcd.c */
 
 #define ehci_dbg(ehci, fmt, args...) \
-       dev_dbg ((ehci)->hcd.self.controller , fmt , ## args )
+       dev_dbg (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
 #define ehci_err(ehci, fmt, args...) \
-       dev_err ((ehci)->hcd.self.controller , fmt , ## args )
+       dev_err (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
 #define ehci_info(ehci, fmt, args...) \
-       dev_info ((ehci)->hcd.self.controller , fmt , ## args )
+       dev_info (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
 #define ehci_warn(ehci, fmt, args...) \
-       dev_warn ((ehci)->hcd.self.controller , fmt , ## args )
+       dev_warn (ehci_to_hcd(ehci)->self.controller , fmt , ## args )
 
 #ifdef EHCI_VERBOSE_DEBUG
 #      define vdbg dbg
@@ -185,7 +185,7 @@ dbg_sitd (const char *label, struct ehci_hcd *ehci, struct ehci_sitd *sitd)
 }
 
 static int __attribute__((__unused__))
-dbg_status_buf (char *buf, unsigned len, char *label, u32 status)
+dbg_status_buf (char *buf, unsigned len, const char *label, u32 status)
 {
        return scnprintf (buf, len,
                "%s%sstatus %04x%s%s%s%s%s%s%s%s%s%s",
@@ -204,7 +204,7 @@ dbg_status_buf (char *buf, unsigned len, char *label, u32 status)
 }
 
 static int __attribute__((__unused__))
-dbg_intr_buf (char *buf, unsigned len, char *label, u32 enable)
+dbg_intr_buf (char *buf, unsigned len, const char *label, u32 enable)
 {
        return scnprintf (buf, len,
                "%s%sintrenable %02x%s%s%s%s%s%s",
@@ -221,7 +221,8 @@ dbg_intr_buf (char *buf, unsigned len, char *label, u32 enable)
 static const char *const fls_strings [] =
     { "1024", "512", "256", "??" };
 
-static int dbg_command_buf (char *buf, unsigned len, char *label, u32 command)
+static int
+dbg_command_buf (char *buf, unsigned len, const char *label, u32 command)
 {
        return scnprintf (buf, len,
                "%s%scommand %06x %s=%d ithresh=%d%s%s%s%s period=%s%s %s",
@@ -240,7 +241,7 @@ static int dbg_command_buf (char *buf, unsigned len, char *label, u32 command)
 }
 
 static int
-dbg_port_buf (char *buf, unsigned len, char *label, int port, u32 status)
+dbg_port_buf (char *buf, unsigned len, const char *label, int port, u32 status)
 {
        char    *sig;
 
@@ -253,7 +254,7 @@ dbg_port_buf (char *buf, unsigned len, char *label, int port, u32 status)
        }
 
        return scnprintf (buf, len,
-               "%s%sport %d status %06x%s%s sig=%s %s%s%s%s%s%s%s%s%s",
+               "%s%sport %d status %06x%s%s sig=%s%s%s%s%s%s%s%s%s%s",
                label, label [0] ? " " : "", port, status,
                (status & PORT_POWER) ? " POWER" : "",
                (status & PORT_OWNER) ? " OWNER" : "",
@@ -276,19 +277,19 @@ dbg_qh (char *label, struct ehci_hcd *ehci, struct ehci_qh *qh)
 {}
 
 static inline int __attribute__((__unused__))
-dbg_status_buf (char *buf, unsigned len, char *label, u32 status)
+dbg_status_buf (char *buf, unsigned len, const char *label, u32 status)
 { return 0; }
 
 static inline int __attribute__((__unused__))
-dbg_command_buf (char *buf, unsigned len, char *label, u32 command)
+dbg_command_buf (char *buf, unsigned len, const char *label, u32 command)
 { return 0; }
 
 static inline int __attribute__((__unused__))
-dbg_intr_buf (char *buf, unsigned len, char *label, u32 enable)
+dbg_intr_buf (char *buf, unsigned len, const char *label, u32 enable)
 { return 0; }
 
 static inline int __attribute__((__unused__))
-dbg_port_buf (char *buf, unsigned len, char *label, int port, u32 status)
+dbg_port_buf (char *buf, unsigned len, const char *label, int port, u32 status)
 { return 0; }
 
 #endif /* DEBUG */
@@ -393,7 +394,7 @@ static void qh_lines (
                mark = ' ';
                if (hw_curr == td->qtd_dma)
                        mark = '*';
-               else if (qh->hw_qtd_next == td->qtd_dma)
+               else if (qh->hw_qtd_next == cpu_to_le32(td->qtd_dma))
                        mark = '+';
                else if (QTD_LENGTH (scratch)) {
                        if (td->hw_alt_next == ehci->async->hw_alt_next)
@@ -449,7 +450,7 @@ show_async (struct class_device *class_dev, char *buf)
 
        *buf = 0;
 
-       bus = to_usb_bus(class_dev);
+       bus = class_get_devdata(class_dev);
        hcd = bus->hcpriv;
        ehci = hcd_to_ehci (hcd);
        next = buf;
@@ -495,7 +496,7 @@ show_periodic (struct class_device *class_dev, char *buf)
                return 0;
        seen_count = 0;
 
-       bus = to_usb_bus(class_dev);
+       bus = class_get_devdata(class_dev);
        hcd = bus->hcpriv;
        ehci = hcd_to_ehci (hcd);
        next = buf;
@@ -526,7 +527,7 @@ show_periodic (struct class_device *class_dev, char *buf)
                                                p.qh->period,
                                                le32_to_cpup (&p.qh->hw_info2)
                                                        /* uframe masks */
-                                                       & 0xffff,
+                                                       & (QH_CMASK | QH_SMASK),
                                                p.qh);
                                size -= temp;
                                next += temp;
@@ -632,7 +633,7 @@ show_registers (struct class_device *class_dev, char *buf)
        static char             fmt [] = "%*s\n";
        static char             label [] = "";
 
-       bus = to_usb_bus(class_dev);
+       bus = class_get_devdata(class_dev);
        hcd = bus->hcpriv;
        ehci = hcd_to_ehci (hcd);
        next = buf;
@@ -640,12 +641,14 @@ show_registers (struct class_device *class_dev, char *buf)
 
        spin_lock_irqsave (&ehci->lock, flags);
 
-       if (bus->controller->power.power_state) {
+       if (bus->controller->power.power_state.event) {
                size = scnprintf (next, size,
                        "bus %s, device %s (driver " DRIVER_VERSION ")\n"
+                       "%s\n"
                        "SUSPENDED (no register access)\n",
                        hcd->self.controller->bus->name,
-                       hcd->self.controller->bus_id);
+                       hcd->self.controller->bus_id,
+                       hcd->product_desc);
                goto done;
        }
 
@@ -653,13 +656,53 @@ show_registers (struct class_device *class_dev, char *buf)
        i = HC_VERSION(readl (&ehci->caps->hc_capbase));
        temp = scnprintf (next, size,
                "bus %s, device %s (driver " DRIVER_VERSION ")\n"
+               "%s\n"
                "EHCI %x.%02x, hcd state %d\n",
                hcd->self.controller->bus->name,
                hcd->self.controller->bus_id,
-               i >> 8, i & 0x0ff, ehci->hcd.state);
+               hcd->product_desc,
+               i >> 8, i & 0x0ff, hcd->state);
        size -= temp;
        next += temp;
 
+#ifdef CONFIG_PCI
+       /* EHCI 0.96 and later may have "extended capabilities" */
+       if (hcd->self.controller->bus == &pci_bus_type) {
+               struct pci_dev  *pdev;
+               u32             offset, cap, cap2;
+               unsigned        count = 256/4;
+
+               pdev = to_pci_dev(ehci_to_hcd(ehci)->self.controller);
+               offset = HCC_EXT_CAPS (readl (&ehci->caps->hcc_params));
+               while (offset && count--) {
+                       pci_read_config_dword (pdev, offset, &cap);
+                       switch (cap & 0xff) {
+                       case 1:
+                               temp = scnprintf (next, size,
+                                       "ownership %08x%s%s\n", cap,
+                                       (cap & (1 << 24)) ? " linux" : "",
+                                       (cap & (1 << 16)) ? " firmware" : "");
+                               size -= temp;
+                               next += temp;
+
+                               offset += 4;
+                               pci_read_config_dword (pdev, offset, &cap2);
+                               temp = scnprintf (next, size,
+                                       "SMI sts/enable 0x%08x\n", cap2);
+                               size -= temp;
+                               next += temp;
+                               break;
+                       case 0:         /* illegal reserved capability */
+                               cap = 0;
+                               /* FALLTHROUGH */
+                       default:                /* unknown */
+                               break;
+                       }
+                       temp = (cap >> 8) & 0xff;
+               }
+       }
+#endif
+
        // FIXME interpret both types of params
        i = readl (&ehci->caps->hcs_params);
        temp = scnprintf (next, size, "structural params 0x%08x\n", i);
@@ -695,12 +738,19 @@ show_registers (struct class_device *class_dev, char *buf)
        size -= temp;
        next += temp;
 
-       for (i = 0; i < HCS_N_PORTS (ehci->hcs_params); i++) {
-               temp = dbg_port_buf (scratch, sizeof scratch, label, i + 1,
-                               readl (&ehci->regs->port_status [i]));
+       for (i = 1; i <= HCS_N_PORTS (ehci->hcs_params); i++) {
+               temp = dbg_port_buf (scratch, sizeof scratch, label, i,
+                               readl (&ehci->regs->port_status [i - 1]));
                temp = scnprintf (next, size, fmt, temp, scratch);
                size -= temp;
                next += temp;
+               if (i == HCS_DEBUG_PORT(ehci->hcs_params) && ehci->debug) {
+                       temp = scnprintf (next, size,
+                                       "    debug control %08x\n",
+                                       readl (&ehci->debug->control));
+                       size -= temp;
+                       next += temp;
+               }
        }
 
        if (ehci->reclaim) {
@@ -732,18 +782,22 @@ done:
 }
 static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL);
 
-static inline void create_debug_files (struct ehci_hcd *bus)
+static inline void create_debug_files (struct ehci_hcd *ehci)
 {
-       class_device_create_file(&bus->hcd.self.class_dev, &class_device_attr_async);
-       class_device_create_file(&bus->hcd.self.class_dev, &class_device_attr_periodic);
-       class_device_create_file(&bus->hcd.self.class_dev, &class_device_attr_registers);
+       struct class_device *cldev = ehci_to_hcd(ehci)->self.class_dev;
+
+       class_device_create_file(cldev, &class_device_attr_async);
+       class_device_create_file(cldev, &class_device_attr_periodic);
+       class_device_create_file(cldev, &class_device_attr_registers);
 }
 
-static inline void remove_debug_files (struct ehci_hcd *bus)
+static inline void remove_debug_files (struct ehci_hcd *ehci)
 {
-       class_device_remove_file(&bus->hcd.self.class_dev, &class_device_attr_async);
-       class_device_remove_file(&bus->hcd.self.class_dev, &class_device_attr_periodic);
-       class_device_remove_file(&bus->hcd.self.class_dev, &class_device_attr_registers);
+       struct class_device *cldev = ehci_to_hcd(ehci)->self.class_dev;
+
+       class_device_remove_file(cldev, &class_device_attr_async);
+       class_device_remove_file(cldev, &class_device_attr_periodic);
+       class_device_remove_file(cldev, &class_device_attr_registers);
 }
 
 #endif /* STUB_DEBUG_FILES */