Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 93343
b: refs/heads/master
c: 43bbb7e
h: refs/heads/master
i:
  93341: cc3cfc5
  93339: 1f0d5d7
  93335: b729ace
  93327: 45d5b24
  93311: 7383a5f
v: v3
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Apr 25, 2008
1 parent 83aee2c commit 77c75e7
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 50 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7be7d7418776a41badce7ca00246e270d408e4b9
refs/heads/master: 43bbb7e015c4380064796c5868b536437b165615
1 change: 1 addition & 0 deletions trunk/drivers/usb/host/ohci-at91.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ static int ohci_hcd_at91_drv_resume(struct platform_device *pdev)
if (!clocked)
at91_start_clock();

ohci_finish_controller_resume(hcd);
return 0;
}
#else
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/usb/host/ohci-ep93xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ static int ohci_hcd_ep93xx_drv_resume(struct platform_device *pdev)
ohci->next_statechange = jiffies;

ep93xx_start_hc(&pdev->dev);
usb_hcd_resume_root_hub(hcd);

ohci_finish_controller_resume(hcd);
return 0;
}
#endif
Expand Down
43 changes: 43 additions & 0 deletions trunk/drivers/usb/host/ohci-hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,49 @@ static int ohci_bus_resume (struct usb_hcd *hcd)
return rc;
}

/* Carry out the final steps of resuming the controller device */
static void ohci_finish_controller_resume(struct usb_hcd *hcd)
{
struct ohci_hcd *ohci = hcd_to_ohci(hcd);
int port;
bool need_reinit = false;

/* See if the controller is already running or has been reset */
ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) {
need_reinit = true;
} else {
switch (ohci->hc_control & OHCI_CTRL_HCFS) {
case OHCI_USB_OPER:
case OHCI_USB_RESET:
need_reinit = true;
}
}

/* If needed, reinitialize and suspend the root hub */
if (need_reinit) {
spin_lock_irq(&ohci->lock);
hcd->state = HC_STATE_RESUMING;
ohci_rh_resume(ohci);
hcd->state = HC_STATE_QUIESCING;
ohci_rh_suspend(ohci, 0);
hcd->state = HC_STATE_SUSPENDED;
spin_unlock_irq(&ohci->lock);
}

/* Normally just turn on port power and enable interrupts */
else {
ohci_dbg(ohci, "powerup ports\n");
for (port = 0; port < ohci->num_ports; port++)
ohci_writel(ohci, RH_PS_PPS,
&ohci->regs->roothub.portstatus[port]);

ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrenable);
ohci_readl(ohci, &ohci->regs->intrenable);
msleep(20);
}
}

/* Carry out polling-, autostop-, and autoresume-related state changes */
static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
int any_connected)
Expand Down
5 changes: 3 additions & 2 deletions trunk/drivers/usb/host/ohci-omap.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,14 +510,15 @@ static int ohci_omap_suspend(struct platform_device *dev, pm_message_t message)

static int ohci_omap_resume(struct platform_device *dev)
{
struct ohci_hcd *ohci = hcd_to_ohci(platform_get_drvdata(dev));
struct usb_hcd *hcd = platform_get_drvdata(dev);
struct ohci_hcd *ohci = hcd_to_ohci(hcd);

if (time_before(jiffies, ohci->next_statechange))
msleep(5);
ohci->next_statechange = jiffies;

omap_ohci_clock_power(1);
usb_hcd_resume_root_hub(platform_get_drvdata(dev));
ohci_finish_controller_resume(hcd);
return 0;
}

Expand Down
43 changes: 1 addition & 42 deletions trunk/drivers/usb/host/ohci-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,42 +238,6 @@ static int __devinit ohci_pci_start (struct usb_hcd *hcd)
return ret;
}

#if defined(CONFIG_USB_PERSIST) && (defined(CONFIG_USB_EHCI_HCD) || \
defined(CONFIG_USB_EHCI_HCD_MODULE))

/* Following a power loss, we must prepare to regain control of the ports
* we used to own. This means turning on the port power before ehci-hcd
* tries to switch ownership.
*
* This isn't a 100% perfect solution. On most systems the OHCI controllers
* lie at lower PCI addresses than the EHCI controller, so they will be
* discovered (and hence resumed) first. But there is no guarantee things
* will always work this way. If the EHCI controller is resumed first and
* the OHCI ports are unpowered, then the handover will fail.
*/
static void prepare_for_handover(struct usb_hcd *hcd)
{
struct ohci_hcd *ohci = hcd_to_ohci(hcd);
int port;

/* Here we "know" root ports should always stay powered */
ohci_dbg(ohci, "powerup ports\n");
for (port = 0; port < ohci->num_ports; port++)
ohci_writel(ohci, RH_PS_PPS,
&ohci->regs->roothub.portstatus[port]);

/* Flush those writes */
ohci_readl(ohci, &ohci->regs->control);
msleep(20);
}

#else

static inline void prepare_for_handover(struct usb_hcd *hcd)
{ }

#endif /* CONFIG_USB_PERSIST etc. */

#ifdef CONFIG_PM

static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message)
Expand Down Expand Up @@ -312,13 +276,8 @@ static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message)

static int ohci_pci_resume (struct usb_hcd *hcd)
{
struct ohci_hcd *ohci = hcd_to_ohci(hcd);

set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);

/* FIXME: we should try to detect loss of VBUS power here */
prepare_for_handover(hcd);
ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrenable);
ohci_finish_controller_resume(hcd);
return 0;
}

Expand Down
3 changes: 1 addition & 2 deletions trunk/drivers/usb/host/ohci-pxa27x.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,7 @@ static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev)
if ((status = pxa27x_start_hc(&pdev->dev)) < 0)
return status;

usb_hcd_resume_root_hub(hcd);

ohci_finish_controller_resume(hcd);
return 0;
}
#endif
Expand Down
5 changes: 3 additions & 2 deletions trunk/drivers/usb/host/ohci-sm501.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,15 @@ static int ohci_sm501_suspend(struct platform_device *pdev, pm_message_t msg)
static int ohci_sm501_resume(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct ohci_hcd *ohci = hcd_to_ohci(platform_get_drvdata(pdev));
struct usb_hcd *hcd = platform_get_drvdata(pdev);
struct ohci_hcd *ohci = hcd_to_ohci(hcd);

if (time_before(jiffies, ohci->next_statechange))
msleep(5);
ohci->next_statechange = jiffies;

sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 1);
usb_hcd_resume_root_hub(platform_get_drvdata(pdev));
ohci_finish_controller_resume(hcd);
return 0;
}
#else
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/usb/host/ohci-ssb.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ static int ssb_ohci_resume(struct ssb_device *dev)

ssb_device_enable(dev, ohcidev->enable_flags);

ohci_finish_controller_resume(hcd);
return 0;
}

Expand Down

0 comments on commit 77c75e7

Please sign in to comment.