- int ports;
- int i;
-
- ehci_dbg (ehci, "resume\n");
-
- ports = HCS_N_PORTS (ehci->hcs_params);
-
- // FIXME: if controller didn't retain state,
- // return and let generic code clean it up
- // test configured_flag ?
-
- /* resume HC and each port */
-// restore pci FLADJ value
- // khubd and drivers will set HC running, if needed;
- hcd->state = USB_STATE_RUNNING;
- // FIXME Philips/Intel/... etc don't really have a "READY"
- // state ... turn on CMD_RUN too
- for (i = 0; i < ports; i++) {
- int temp = readl (&ehci->regs->port_status [i]);
-
- if ((temp & PORT_PE) == 0
- || (temp & PORT_SUSPEND) != 0)
- continue;
- ehci_dbg (ehci, "resume port %d", i);
- temp |= PORT_RESUME;
- writel (temp, &ehci->regs->port_status [i]);
- readl (&ehci->regs->command); /* unblock posted writes */
-
- wait_ms (20);
- temp &= ~PORT_RESUME;
- writel (temp, &ehci->regs->port_status [i]);
- }
- readl (&ehci->regs->command); /* unblock posted writes */
- return 0;
+ int retval;
+
+ // maybe restore (PCI) FLADJ
+
+ while (time_before (jiffies, ehci->next_statechange))
+ msleep (100);
+
+#ifdef CONFIG_USB_SUSPEND
+ retval = usb_resume_device (hcd->self.root_hub);
+#else
+ /* FIXME lock root hub */
+ retval = ehci_hub_resume (hcd);
+#endif
+ if (retval == 0)
+ hcd->self.controller->power.power_state = 0;
+ return retval;