]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/usb/core/hcd-pci.c
[PATCH] USB: remove usbcore-specific wakeup flags
[karo-tx-linux.git] / drivers / usb / core / hcd-pci.c
index 7feb829362d63212d5383e6aba652373036e5150..e0afb5ad29e54ea31e2bb2ea27530e7095434dec 100644 (file)
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/usb.h>
+
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <linux/usb.h>
+
+#ifdef CONFIG_PPC_PMAC
+#include <asm/machdep.h>
+#include <asm/pmac_feature.h>
+#include <asm/pci-bridge.h>
+#include <asm/prom.h>
+#endif
 
 #include "usb.h"
 #include "hcd.h"
@@ -211,6 +219,7 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message)
                        goto done;
                }
        }
+       synchronize_irq(dev->irq);
 
        /* FIXME until the generic PM interfaces change a lot more, this
         * can't use PCI D1 and D2 states.  For example, the confusion
@@ -255,14 +264,19 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message)
                 */
                retval = pci_set_power_state (dev, PCI_D3hot);
                if (retval == 0) {
-                       dev_dbg (hcd->self.controller, "--> PCI D3\n");
+                       int wake = device_can_wakeup(&hcd->self.root_hub->dev);
+
+                       wake = wake && device_may_wakeup(hcd->self.controller);
+
+                       dev_dbg (hcd->self.controller, "--> PCI D3%s\n",
+                                       wake ? "/wakeup" : "");
 
                        /* Ignore these return values.  We rely on pci code to
                         * reject requests the hardware can't implement, rather
                         * than coding the same thing.
                         */
-                       (void) pci_enable_wake (dev, PCI_D3hot, hcd->remote_wakeup);
-                       (void) pci_enable_wake (dev, PCI_D3cold, hcd->remote_wakeup);
+                       (void) pci_enable_wake (dev, PCI_D3hot, wake);
+                       (void) pci_enable_wake (dev, PCI_D3cold, wake);
                } else {
                        dev_dbg (&dev->dev, "PCI D3 suspend fail, %d\n",
                                        retval);
@@ -277,8 +291,22 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message)
        }
 
 done:
-       if (retval == 0)
+       if (retval == 0) {
                dev->dev.power.power_state = PMSG_SUSPEND;
+
+#ifdef CONFIG_PPC_PMAC
+               /* Disable ASIC clocks for USB */
+               if (_machine == _MACH_Pmac) {
+                       struct device_node      *of_node;
+
+                       of_node = pci_device_to_OF_node (dev);
+                       if (of_node)
+                               pmac_call_feature(PMAC_FTR_USB_ENABLE,
+                                                       of_node, 0, 0);
+               }
+#endif
+       }
+
        return retval;
 }
 EXPORT_SYMBOL (usb_hcd_pci_suspend);
@@ -301,6 +329,18 @@ int usb_hcd_pci_resume (struct pci_dev *dev)
                return 0;
        }
 
+#ifdef CONFIG_PPC_PMAC
+       /* Reenable ASIC clocks for USB */
+       if (_machine == _MACH_Pmac) {
+               struct device_node *of_node;
+
+               of_node = pci_device_to_OF_node (dev);
+               if (of_node)
+                       pmac_call_feature (PMAC_FTR_USB_ENABLE,
+                                               of_node, 0, 1);
+       }
+#endif
+
        /* NOTE:  chip docs cover clean "real suspend" cases (what Linux
         * calls "standby", "suspend to RAM", and so on).  There are also
         * dirty cases when swsusp fakes a suspend in "shutdown" mode.
@@ -358,7 +398,7 @@ int usb_hcd_pci_resume (struct pci_dev *dev)
 
        dev->dev.power.power_state = PMSG_ON;
 
-       hcd->saw_irq = 0;
+       clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
 
        if (hcd->driver->resume) {
                retval = hcd->driver->resume(hcd);