]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/usb/host/pci-quirks.c
USB: ehci: qh/qtd cleanup comments
[linux-2.6-omap-h63xx.git] / drivers / usb / host / pci-quirks.c
index 1045f846fbe2c4cedb5d3ac498488b572246258a..0ee694f043cc9b84d0a6aef45980a97212da1fdc 100644 (file)
@@ -8,7 +8,6 @@
  *  (and others)
  */
 
-#include <linux/config.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
@@ -45,6 +44,7 @@
 #define EHCI_USBSTS            4               /* status register */
 #define EHCI_USBSTS_HALTED     (1 << 12)       /* HCHalted bit */
 #define EHCI_USBINTR           8               /* interrupt register */
+#define EHCI_CONFIGFLAG                0x40            /* configured flag register */
 #define EHCI_USBLEGSUP         0               /* legacy support register */
 #define EHCI_USBLEGSUP_BIOS    (1 << 16)       /* BIOS semaphore */
 #define EHCI_USBLEGSUP_OS      (1 << 24)       /* OS semaphore */
@@ -168,8 +168,6 @@ static int __devinit mmio_resource_enabled(struct pci_dev *pdev, int idx)
 static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
 {
        void __iomem *base;
-       int wait_time;
-       u32 control;
 
        if (!mmio_resource_enabled(pdev, 0))
                return;
@@ -180,9 +178,10 @@ static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
 
 /* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */
 #ifndef __hppa__
-       control = readl(base + OHCI_CONTROL);
+{
+       u32 control = readl(base + OHCI_CONTROL);
        if (control & OHCI_CTRL_IR) {
-               wait_time = 500; /* arbitrary; 5 seconds */
+               int wait_time = 500; /* arbitrary; 5 seconds */
                writel(OHCI_INTR_OC, base + OHCI_INTRENABLE);
                writel(OHCI_OCR, base + OHCI_CMDSTATUS);
                while (wait_time > 0 &&
@@ -191,14 +190,14 @@ static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
                        msleep(10);
                }
                if (wait_time <= 0)
-                       printk(KERN_WARNING "%s %s: BIOS handoff "
-                                       "failed (BIOS bug ?) %08x\n",
-                                       pdev->dev.bus_id, "OHCI",
+                       dev_warn(&pdev->dev, "OHCI: BIOS handoff failed"
+                                       " (BIOS bug?) %08x\n",
                                        readl(base + OHCI_CONTROL));
 
                /* reset controller, preserving RWC */
                writel(control & OHCI_CTRL_RWC, base + OHCI_CONTROL);
        }
+}
 #endif
 
        /*
@@ -217,6 +216,7 @@ static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev)
        u32     hcc_params, val;
        u8      offset, cap_length;
        int     count = 256/4;
+       int     tried_handoff = 0;
 
        if (!mmio_resource_enabled(pdev, 0))
                return;
@@ -242,8 +242,7 @@ static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev)
                switch (cap & 0xff) {
                case 1:                 /* BIOS/SMM/... handoff support */
                        if ((cap & EHCI_USBLEGSUP_BIOS)) {
-                               pr_debug("%s %s: BIOS handoff\n",
-                                               pdev->dev.bus_id, "EHCI");
+                               dev_dbg(&pdev->dev, "EHCI: BIOS handoff\n");
 
 #if 0
 /* aleksey_gorelov@phoenix.com reports that some systems need SMI forced on,
@@ -274,6 +273,7 @@ static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev)
                         */
                        msec = 5000;
                        while ((cap & EHCI_USBLEGSUP_BIOS) && (msec > 0)) {
+                               tried_handoff = 1;
                                msleep(10);
                                msec -= 10;
                                pci_read_config_dword(pdev, offset, &cap);
@@ -283,9 +283,8 @@ static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev)
                                /* well, possibly buggy BIOS... try to shut
                                 * it down, and hope nothing goes too wrong
                                 */
-                               printk(KERN_WARNING "%s %s: BIOS handoff "
-                                               "failed (BIOS bug ?) %08x\n",
-                                       pdev->dev.bus_id, "EHCI", cap);
+                               dev_warn(&pdev->dev, "EHCI: BIOS handoff failed"
+                                               " (BIOS bug?) %08x\n", cap);
                                pci_write_config_byte(pdev, offset + 2, 0);
                        }
 
@@ -293,22 +292,25 @@ static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev)
                        pci_write_config_dword(pdev,
                                        offset + EHCI_USBLEGCTLSTS,
                                        0);
+
+                       /* If the BIOS ever owned the controller then we
+                        * can't expect any power sessions to remain intact.
+                        */
+                       if (tried_handoff)
+                               writel(0, op_reg_base + EHCI_CONFIGFLAG);
                        break;
                case 0:                 /* illegal reserved capability */
                        cap = 0;
                        /* FALLTHROUGH */
                default:
-                       printk(KERN_WARNING "%s %s: unrecognized "
-                                       "capability %02x\n",
-                                       pdev->dev.bus_id, "EHCI",
-                                       cap & 0xff);
+                       dev_warn(&pdev->dev, "EHCI: unrecognized capability "
+                                       "%02x\n", cap & 0xff);
                        break;
                }
                offset = (cap >> 8) & 0xff;
        }
        if (!count)
-               printk(KERN_DEBUG "%s %s: capability loop?\n",
-                               pdev->dev.bus_id, "EHCI");
+               dev_printk(KERN_DEBUG, &pdev->dev, "EHCI: capability loop?\n");
 
        /*
         * halt EHCI & disable its interrupts in any case