Merge tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[firefly-linux-kernel-4.4.55.git] / drivers / usb / dwc3 / dwc3-pci.c
index a36cf66302fbe56e06f6ed20451b8c008479b0d2..7c4faf738747bdab2bf5a73e39297f8ae437aeb7 100644 (file)
@@ -25,6 +25,8 @@
 #include <linux/usb/otg.h>
 #include <linux/usb/usb_phy_generic.h>
 
+#include "platform_data.h"
+
 /* FIXME define these in <linux/pci_ids.h> */
 #define PCI_VENDOR_ID_SYNOPSYS         0x16c3
 #define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3        0xabcd
@@ -102,6 +104,9 @@ static int dwc3_pci_probe(struct pci_dev *pci,
        struct dwc3_pci         *glue;
        int                     ret;
        struct device           *dev = &pci->dev;
+       struct dwc3_platform_data dwc3_pdata;
+
+       memset(&dwc3_pdata, 0x00, sizeof(dwc3_pdata));
 
        glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL);
        if (!glue)
@@ -140,6 +145,31 @@ static int dwc3_pci_probe(struct pci_dev *pci,
        res[1].name     = "dwc_usb3";
        res[1].flags    = IORESOURCE_IRQ;
 
+       if (pci->vendor == PCI_VENDOR_ID_AMD &&
+                       pci->device == PCI_DEVICE_ID_AMD_NL_USB) {
+               dwc3_pdata.has_lpm_erratum = true;
+               dwc3_pdata.lpm_nyet_threshold = 0xf;
+
+               dwc3_pdata.u2exit_lfps_quirk = true;
+               dwc3_pdata.u2ss_inp3_quirk = true;
+               dwc3_pdata.req_p1p2p3_quirk = true;
+               dwc3_pdata.del_p1p2p3_quirk = true;
+               dwc3_pdata.del_phy_power_chg_quirk = true;
+               dwc3_pdata.lfps_filter_quirk = true;
+               dwc3_pdata.rx_detect_poll_quirk = true;
+
+               dwc3_pdata.tx_de_emphasis_quirk = true;
+               dwc3_pdata.tx_de_emphasis = 1;
+
+               /*
+                * FIXME these quirks should be removed when AMD NL
+                * taps out
+                */
+               dwc3_pdata.disable_scramble_quirk = true;
+               dwc3_pdata.dis_u3_susphy_quirk = true;
+               dwc3_pdata.dis_u2_susphy_quirk = true;
+       }
+
        ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
        if (ret) {
                dev_err(dev, "couldn't add resources to dwc3 device\n");
@@ -148,6 +178,10 @@ static int dwc3_pci_probe(struct pci_dev *pci,
 
        pci_set_drvdata(pci, glue);
 
+       ret = platform_device_add_data(dwc3, &dwc3_pdata, sizeof(dwc3_pdata));
+       if (ret)
+               goto err3;
+
        dma_set_coherent_mask(&dwc3->dev, dev->coherent_dma_mask);
 
        dwc3->dev.dma_mask = dev->dma_mask;
@@ -185,6 +219,7 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BSW), },
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT), },
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MRFLD), },
+       { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), },
        {  }    /* Terminating Entry */
 };
 MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table);