]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/usb/host/uhci-hub.c
Merge branch 'misc' of master.kernel.org:/pub/scm/linux/kernel/git/galak/powerpc...
[linux-2.6-omap-h63xx.git] / drivers / usb / host / uhci-hub.c
index 4eace2b19ddb830602b339059e7a953633a73d39..c8451d9578f16ebd96df6501f058efbca031f24a 100644 (file)
@@ -85,11 +85,10 @@ static void uhci_finish_suspend(struct uhci_hcd *uhci, int port,
 {
        int status;
 
-       if (test_bit(port, &uhci->suspended_ports)) {
+       if (inw(port_addr) & (USBPORTSC_SUSP | USBPORTSC_RD)) {
                CLR_RH_PORTSTAT(USBPORTSC_SUSP | USBPORTSC_RD);
-               clear_bit(port, &uhci->suspended_ports);
-               clear_bit(port, &uhci->resuming_ports);
-               set_bit(port, &uhci->port_c_suspend);
+               if (test_bit(port, &uhci->resuming_ports))
+                       set_bit(port, &uhci->port_c_suspend);
 
                /* The controller won't actually turn off the RD bit until
                 * it has had a chance to send a low-speed EOP sequence,
@@ -97,6 +96,22 @@ static void uhci_finish_suspend(struct uhci_hcd *uhci, int port,
                 * slightly longer for good luck. */
                udelay(4);
        }
+       clear_bit(port, &uhci->resuming_ports);
+}
+
+/* Wait for the UHCI controller in HP's iLO2 server management chip.
+ * It can take up to 250 us to finish a reset and set the CSC bit.
+ */
+static void wait_for_HP(unsigned long port_addr)
+{
+       int i;
+
+       for (i = 10; i < 250; i += 10) {
+               if (inw(port_addr) & USBPORTSC_CSC)
+                       return;
+               udelay(10);
+       }
+       /* Log a warning? */
 }
 
 static void uhci_check_ports(struct uhci_hcd *uhci)
@@ -113,6 +128,12 @@ static void uhci_check_ports(struct uhci_hcd *uhci)
                                CLR_RH_PORTSTAT(USBPORTSC_PR);
                                udelay(10);
 
+                               /* HP's server management chip requires
+                                * a longer delay. */
+                               if (to_pci_dev(uhci_dev(uhci))->vendor ==
+                                               PCI_VENDOR_ID_HP)
+                                       wait_for_HP(port_addr);
+
                                /* If the port was enabled before, turning
                                 * reset on caused a port enable change.
                                 * Turning reset off causes a port connect
@@ -145,15 +166,16 @@ static int uhci_hub_status_data(struct usb_hcd *hcd, char *buf)
 {
        struct uhci_hcd *uhci = hcd_to_uhci(hcd);
        unsigned long flags;
-       int status;
+       int status = 0;
 
        spin_lock_irqsave(&uhci->lock, flags);
-       if (uhci->hc_inaccessible) {
-               status = 0;
-               goto done;
-       }
 
+       uhci_scan_schedule(uhci, NULL);
+       if (uhci->hc_inaccessible)
+               goto done;
+       check_fsbr(uhci);
        uhci_check_ports(uhci);
+
        status = get_hub_status_data(uhci, buf);
 
        switch (uhci->rh_state) {
@@ -243,8 +265,6 @@ static int uhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                        wPortChange |= USB_PORT_STAT_C_SUSPEND;
                        lstatus |= 1;
                }
-               if (test_bit(port, &uhci->suspended_ports))
-                       lstatus |= 2;
                if (test_bit(port, &uhci->resuming_ports))
                        lstatus |= 4;
 
@@ -287,7 +307,6 @@ static int uhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 
                switch (wValue) {
                case USB_PORT_FEAT_SUSPEND:
-                       set_bit(port, &uhci->suspended_ports);
                        SET_RH_PORTSTAT(USBPORTSC_SUSP);
                        OK(0);
                case USB_PORT_FEAT_RESET:
@@ -321,8 +340,11 @@ static int uhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                        CLR_RH_PORTSTAT(USBPORTSC_PEC);
                        OK(0);
                case USB_PORT_FEAT_SUSPEND:
-                       if (test_bit(port, &uhci->suspended_ports) &&
-                                       !test_and_set_bit(port,
+                       if (!(inw(port_addr) & USBPORTSC_SUSP)) {
+
+                               /* Make certain the port isn't suspended */
+                               uhci_finish_suspend(uhci, port, port_addr);
+                       } else if (!test_and_set_bit(port,
                                                &uhci->resuming_ports)) {
                                SET_RH_PORTSTAT(USBPORTSC_RD);