]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/usb/host/ohci-au1xxx.c
Merge branch 'linus' into x86/urgent
[linux-2.6-omap-h63xx.git] / drivers / usb / host / ohci-au1xxx.c
index 29c970ad487a6cda5af6c53f1938a60f1b9b15c0..2ac4e022a13f6fc68c6ea32702f1bab05713b88a 100644 (file)
@@ -163,7 +163,6 @@ static const struct hc_driver ohci_au1xxx_hc_driver = {
         */
        .hub_status_data =      ohci_hub_status_data,
        .hub_control =          ohci_hub_control,
-       .hub_irq_enable =       ohci_rhsc_enable,
 #ifdef CONFIG_PM
        .bus_suspend =          ohci_bus_suspend,
        .bus_resume =           ohci_bus_resume,
@@ -248,27 +247,68 @@ static int ohci_hcd_au1xxx_drv_remove(struct platform_device *pdev)
        return 0;
 }
 
-       /*TBD*/
-/*static int ohci_hcd_au1xxx_drv_suspend(struct platform_device *dev)
+#ifdef CONFIG_PM
+static int ohci_hcd_au1xxx_drv_suspend(struct platform_device *pdev,
+                                       pm_message_t message)
 {
-       struct usb_hcd *hcd = platform_get_drvdata(dev);
+       struct usb_hcd *hcd = platform_get_drvdata(pdev);
+       struct ohci_hcd *ohci = hcd_to_ohci(hcd);
+       unsigned long flags;
+       int rc;
+
+       rc = 0;
+
+       /* Root hub was already suspended. Disable irq emission and
+        * mark HW unaccessible, bail out if RH has been resumed. Use
+        * the spinlock to properly synchronize with possible pending
+        * RH suspend or resume activity.
+        *
+        * This is still racy as hcd->state is manipulated outside of
+        * any locks =P But that will be a different fix.
+        */
+       spin_lock_irqsave(&ohci->lock, flags);
+       if (hcd->state != HC_STATE_SUSPENDED) {
+               rc = -EINVAL;
+               goto bail;
+       }
+       ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
+       (void)ohci_readl(ohci, &ohci->regs->intrdisable);
 
-       return 0;
+       /* make sure snapshot being resumed re-enumerates everything */
+       if (message.event == PM_EVENT_PRETHAW)
+               ohci_usb_reset(ohci);
+
+       clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
+
+       au1xxx_stop_ohc();
+bail:
+       spin_unlock_irqrestore(&ohci->lock, flags);
+
+       return rc;
 }
-static int ohci_hcd_au1xxx_drv_resume(struct platform_device *dev)
+
+static int ohci_hcd_au1xxx_drv_resume(struct platform_device *pdev)
 {
-       struct usb_hcd *hcd = platform_get_drvdata(dev);
+       struct usb_hcd *hcd = platform_get_drvdata(pdev);
+
+       au1xxx_start_ohc();
+
+       set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
+       ohci_finish_controller_resume(hcd);
 
        return 0;
 }
-*/
+#else
+#define ohci_hcd_au1xxx_drv_suspend NULL
+#define ohci_hcd_au1xxx_drv_resume NULL
+#endif
 
 static struct platform_driver ohci_hcd_au1xxx_driver = {
        .probe          = ohci_hcd_au1xxx_drv_probe,
        .remove         = ohci_hcd_au1xxx_drv_remove,
        .shutdown       = usb_hcd_platform_shutdown,
-       /*.suspend      = ohci_hcd_au1xxx_drv_suspend, */
-       /*.resume       = ohci_hcd_au1xxx_drv_resume, */
+       .suspend        = ohci_hcd_au1xxx_drv_suspend,
+       .resume         = ohci_hcd_au1xxx_drv_resume,
        .driver         = {
                .name   = "au1xxx-ohci",
                .owner  = THIS_MODULE,