fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / usb / host / ehci-dbg.c
index 9b347d7..56349d2 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2001-2002 by David Brownell
- * 
+ *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
  * Free Software Foundation; either version 2 of the License, or (at your
@@ -65,7 +65,7 @@ static void dbg_hcs_params (struct ehci_hcd *ehci, char *label)
                for (i = 0; i < HCS_N_PORTS (params); i++) {
                        // FIXME MIPS won't readb() ...
                        byte = readb (&ehci->caps->portroute[(i>>1)]);
-                       sprintf(tmp, "%d ", 
+                       sprintf(tmp, "%d ",
                                ((i & 0x1) ? ((byte)&0xf) : ((byte>>4)&0xf)));
                        strcat(buf, tmp);
                }
@@ -141,12 +141,12 @@ dbg_qh (const char *label, struct ehci_hcd *ehci, struct ehci_qh *qh)
 }
 
 static void __attribute__((__unused__))
-dbg_itd (const char *label, struct ehci_hcd *ehci, struct ehci_itd *itd) 
+dbg_itd (const char *label, struct ehci_hcd *ehci, struct ehci_itd *itd)
 {
        ehci_dbg (ehci, "%s [%d] itd %p, next %08x, urb %p\n",
                label, itd->frame, itd, le32_to_cpu(itd->hw_next), itd->urb);
        ehci_dbg (ehci,
-               "  trans: %08x %08x %08x %08x %08x %08x %08x %08x\n", 
+               "  trans: %08x %08x %08x %08x %08x %08x %08x %08x\n",
                le32_to_cpu(itd->hw_transaction[0]),
                le32_to_cpu(itd->hw_transaction[1]),
                le32_to_cpu(itd->hw_transaction[2]),
@@ -156,7 +156,7 @@ dbg_itd (const char *label, struct ehci_hcd *ehci, struct ehci_itd *itd)
                le32_to_cpu(itd->hw_transaction[6]),
                le32_to_cpu(itd->hw_transaction[7]));
        ehci_dbg (ehci,
-               "  buf:   %08x %08x %08x %08x %08x %08x %08x\n", 
+               "  buf:   %08x %08x %08x %08x %08x %08x %08x\n",
                le32_to_cpu(itd->hw_bufp[0]),
                le32_to_cpu(itd->hw_bufp[1]),
                le32_to_cpu(itd->hw_bufp[2]),
@@ -171,12 +171,12 @@ dbg_itd (const char *label, struct ehci_hcd *ehci, struct ehci_itd *itd)
 }
 
 static void __attribute__((__unused__))
-dbg_sitd (const char *label, struct ehci_hcd *ehci, struct ehci_sitd *sitd) 
+dbg_sitd (const char *label, struct ehci_hcd *ehci, struct ehci_sitd *sitd)
 {
        ehci_dbg (ehci, "%s [%d] sitd %p, next %08x, urb %p\n",
                label, sitd->frame, sitd, le32_to_cpu(sitd->hw_next), sitd->urb);
        ehci_dbg (ehci,
-               "  addr %08x sched %04x result %08x buf %08x %08x\n", 
+               "  addr %08x sched %04x result %08x buf %08x %08x\n",
                le32_to_cpu(sitd->hw_fullspeed_ep),
                le32_to_cpu(sitd->hw_uframe),
                le32_to_cpu(sitd->hw_results),
@@ -254,7 +254,7 @@ dbg_port_buf (char *buf, unsigned len, const 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" : "",
@@ -450,8 +450,8 @@ show_async (struct class_device *class_dev, char *buf)
 
        *buf = 0;
 
-       bus = to_usb_bus(class_dev);
-       hcd = bus->hcpriv;
+       bus = class_get_devdata(class_dev);
+       hcd = bus_to_hcd(bus);
        ehci = hcd_to_ehci (hcd);
        next = buf;
        size = PAGE_SIZE;
@@ -492,12 +492,12 @@ show_periodic (struct class_device *class_dev, char *buf)
        unsigned                i;
        __le32                  tag;
 
-       if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, SLAB_ATOMIC)))
+       if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, GFP_ATOMIC)))
                return 0;
        seen_count = 0;
 
-       bus = to_usb_bus(class_dev);
-       hcd = bus->hcpriv;
+       bus = class_get_devdata(class_dev);
+       hcd = bus_to_hcd(bus);
        ehci = hcd_to_ehci (hcd);
        next = buf;
        size = PAGE_SIZE;
@@ -527,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;
@@ -633,20 +633,22 @@ show_registers (struct class_device *class_dev, char *buf)
        static char             fmt [] = "%*s\n";
        static char             label [] = "";
 
-       bus = to_usb_bus(class_dev);
-       hcd = bus->hcpriv;
+       bus = class_get_devdata(class_dev);
+       hcd = bus_to_hcd(bus);
        ehci = hcd_to_ehci (hcd);
        next = buf;
        size = PAGE_SIZE;
 
        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;
        }
 
@@ -654,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,
+               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);
@@ -696,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) {
@@ -735,16 +784,17 @@ static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL);
 
 static inline void create_debug_files (struct ehci_hcd *ehci)
 {
-       struct class_device *cldev = &ehci_to_hcd(ehci)->self.class_dev;
+       struct class_device *cldev = ehci_to_hcd(ehci)->self.class_dev;
+       int retval;
 
-       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);
+       retval = class_device_create_file(cldev, &class_device_attr_async);
+       retval = class_device_create_file(cldev, &class_device_attr_periodic);
+       retval = class_device_create_file(cldev, &class_device_attr_registers);
 }
 
 static inline void remove_debug_files (struct ehci_hcd *ehci)
 {
-       struct class_device *cldev = &ehci_to_hcd(ehci)->self.class_dev;
+       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);