Merge tag 'v3.14.26' into backport/v3.14.24-ltsi-rc1+v3.14.26/snapshot-merge.wip
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / usb / host / xhci-pci.c
index 04f986d..309fe45 100644 (file)
@@ -40,6 +40,8 @@
 
 static const char hcd_name[] = "xhci_hcd";
 
+static struct hc_driver __read_mostly xhci_pci_hc_driver;
+
 /* called after powerup, by probe or system-pm "wakeup" */
 static int xhci_pci_reinit(struct xhci_hcd *xhci, struct pci_dev *pdev)
 {
@@ -101,6 +103,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
        /* AMD PLL quirk */
        if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info())
                xhci->quirks |= XHCI_AMD_PLL_FIX;
+
+       if (pdev->vendor == PCI_VENDOR_ID_AMD)
+               xhci->quirks |= XHCI_TRUST_TX_LENGTH;
+
        if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
                xhci->quirks |= XHCI_LPM_SUPPORT;
                xhci->quirks |= XHCI_INTEL_HOST;
@@ -134,6 +140,8 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
                 */
                if (pdev->subsystem_vendor == PCI_VENDOR_ID_HP)
                        xhci->quirks |= XHCI_SPURIOUS_WAKEUP;
+
+               xhci->quirks |= XHCI_SPURIOUS_REBOOT;
        }
        if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
                        pdev->device == PCI_DEVICE_ID_ASROCK_P67) {
@@ -143,9 +151,7 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
                xhci->quirks |= XHCI_TRUST_TX_LENGTH;
        }
        if (pdev->vendor == PCI_VENDOR_ID_RENESAS &&
-                       pdev->device == 0x0015 &&
-                       pdev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG &&
-                       pdev->subsystem_device == 0xc0cd)
+                       pdev->device == 0x0015)
                xhci->quirks |= XHCI_RESET_ON_RESUME;
        if (pdev->vendor == PCI_VENDOR_ID_VIA)
                xhci->quirks |= XHCI_RESET_ON_RESUME;
@@ -190,6 +196,10 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
        struct usb_hcd *hcd;
 
        driver = (struct hc_driver *)id->driver_data;
+
+       /* Prevent runtime suspending between USB-2 and USB-3 initialization */
+       pm_runtime_get_noresume(&dev->dev);
+
        /* Register the USB 2.0 roothub.
         * FIXME: USB core must know to register the USB 2.0 roothub first.
         * This is sort of silly, because we could just set the HCD driver flags
@@ -199,7 +209,7 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
        retval = usb_hcd_pci_probe(dev, id);
 
        if (retval)
-               return retval;
+               goto put_runtime_pm;
 
        /* USB 2.0 roothub is stored in the PCI device now. */
        hcd = dev_get_drvdata(&dev->dev);
@@ -228,12 +238,17 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
        if (xhci->quirks & XHCI_LPM_SUPPORT)
                hcd_to_bus(xhci->shared_hcd)->root_hub->lpm_capable = 1;
 
+       /* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */
+       pm_runtime_put_noidle(&dev->dev);
+
        return 0;
 
 put_usb3_hcd:
        usb_put_hcd(xhci->shared_hcd);
 dealloc_usb2_hcd:
        usb_hcd_pci_remove(dev);
+put_runtime_pm:
+       pm_runtime_put_noidle(&dev->dev);
        return retval;
 }
 
@@ -268,7 +283,7 @@ static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
        if (xhci_compliance_mode_recovery_timer_quirk_check())
                pdev->no_d3cold = true;
 
-       return xhci_suspend(xhci);
+       return xhci_suspend(xhci, do_wakeup);
 }
 
 static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
@@ -303,68 +318,6 @@ static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
 }
 #endif /* CONFIG_PM */
 
-static const struct hc_driver xhci_pci_hc_driver = {
-       .description =          hcd_name,
-       .product_desc =         "xHCI Host Controller",
-       .hcd_priv_size =        sizeof(struct xhci_hcd *),
-
-       /*
-        * generic hardware linkage
-        */
-       .irq =                  xhci_irq,
-       .flags =                HCD_MEMORY | HCD_USB3 | HCD_SHARED,
-
-       /*
-        * basic lifecycle operations
-        */
-       .reset =                xhci_pci_setup,
-       .start =                xhci_run,
-#ifdef CONFIG_PM
-       .pci_suspend =          xhci_pci_suspend,
-       .pci_resume =           xhci_pci_resume,
-#endif
-       .stop =                 xhci_stop,
-       .shutdown =             xhci_shutdown,
-
-       /*
-        * managing i/o requests and associated device resources
-        */
-       .urb_enqueue =          xhci_urb_enqueue,
-       .urb_dequeue =          xhci_urb_dequeue,
-       .alloc_dev =            xhci_alloc_dev,
-       .free_dev =             xhci_free_dev,
-       .alloc_streams =        xhci_alloc_streams,
-       .free_streams =         xhci_free_streams,
-       .add_endpoint =         xhci_add_endpoint,
-       .drop_endpoint =        xhci_drop_endpoint,
-       .endpoint_reset =       xhci_endpoint_reset,
-       .check_bandwidth =      xhci_check_bandwidth,
-       .reset_bandwidth =      xhci_reset_bandwidth,
-       .address_device =       xhci_address_device,
-       .enable_device =        xhci_enable_device,
-       .update_hub_device =    xhci_update_hub_device,
-       .reset_device =         xhci_discover_or_reset_device,
-
-       /*
-        * scheduling support
-        */
-       .get_frame_number =     xhci_get_frame,
-
-       /* Root hub support */
-       .hub_control =          xhci_hub_control,
-       .hub_status_data =      xhci_hub_status_data,
-       .bus_suspend =          xhci_bus_suspend,
-       .bus_resume =           xhci_bus_resume,
-       /*
-        * call back when device connected and addressed
-        */
-       .update_device =        xhci_update_device,
-       .set_usb2_hw_lpm =      xhci_set_usb2_hardware_lpm,
-       .enable_usb3_lpm_timeout =      xhci_enable_usb3_lpm_timeout,
-       .disable_usb3_lpm_timeout =     xhci_disable_usb3_lpm_timeout,
-       .find_raw_port_number = xhci_find_raw_port_number,
-};
-
 /*-------------------------------------------------------------------------*/
 
 /* PCI driver selection metadata; PCI hotplugging uses this */
@@ -396,6 +349,11 @@ static struct pci_driver xhci_pci_driver = {
 
 int __init xhci_register_pci(void)
 {
+       xhci_init_driver(&xhci_pci_hc_driver, xhci_pci_setup);
+#ifdef CONFIG_PM
+       xhci_pci_hc_driver.pci_suspend = xhci_pci_suspend;
+       xhci_pci_hc_driver.pci_resume = xhci_pci_resume;
+#endif
        return pci_register_driver(&xhci_pci_driver);
 }