aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc3
diff options
context:
space:
mode:
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>2015-01-12 07:20:14 -0500
committerFelipe Balbi <balbi@ti.com>2015-01-15 10:41:50 -0500
commit2cd9ddf77e0da465da4535b685587338260eca99 (patch)
treee9efebf5a5e819e6076e76b377745b8d68a1a6b9 /drivers/usb/dwc3
parent3b44ed90cdb26ce3a06a1b41c5fcbb01c7d63b3c (diff)
usb: dwc3: pci: code cleanup
Removing a few items that are not needed anymore and adding separate function for quirks. Acked-by: Huang Rui <ray.huang@amd.com> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/dwc3')
-rw-r--r--drivers/usb/dwc3/dwc3-pci.c96
1 files changed, 42 insertions, 54 deletions
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 5c471d2fe732..5f5fa98f399d 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -31,28 +31,50 @@
31#define PCI_DEVICE_ID_INTEL_MRFLD 0x119e 31#define PCI_DEVICE_ID_INTEL_MRFLD 0x119e
32#define PCI_DEVICE_ID_INTEL_BSW 0x22B7 32#define PCI_DEVICE_ID_INTEL_BSW 0x22B7
33 33
34struct dwc3_pci { 34static int dwc3_pci_quirks(struct pci_dev *pdev)
35 struct device *dev; 35{
36 struct platform_device *dwc3; 36 if (pdev->vendor == PCI_VENDOR_ID_AMD &&
37}; 37 pdev->device == PCI_DEVICE_ID_AMD_NL_USB) {
38 struct dwc3_platform_data pdata;
39
40 memset(&pdata, 0, sizeof(pdata));
41
42 pdata.has_lpm_erratum = true;
43 pdata.lpm_nyet_threshold = 0xf;
44
45 pdata.u2exit_lfps_quirk = true;
46 pdata.u2ss_inp3_quirk = true;
47 pdata.req_p1p2p3_quirk = true;
48 pdata.del_p1p2p3_quirk = true;
49 pdata.del_phy_power_chg_quirk = true;
50 pdata.lfps_filter_quirk = true;
51 pdata.rx_detect_poll_quirk = true;
52
53 pdata.tx_de_emphasis_quirk = true;
54 pdata.tx_de_emphasis = 1;
55
56 /*
57 * FIXME these quirks should be removed when AMD NL
58 * taps out
59 */
60 pdata.disable_scramble_quirk = true;
61 pdata.dis_u3_susphy_quirk = true;
62 pdata.dis_u2_susphy_quirk = true;
63
64 return platform_device_add_data(pci_get_drvdata(pdev), &pdata,
65 sizeof(pdata));
66 }
67
68 return 0;
69}
38 70
39static int dwc3_pci_probe(struct pci_dev *pci, 71static int dwc3_pci_probe(struct pci_dev *pci,
40 const struct pci_device_id *id) 72 const struct pci_device_id *id)
41{ 73{
42 struct resource res[2]; 74 struct resource res[2];
43 struct platform_device *dwc3; 75 struct platform_device *dwc3;
44 struct dwc3_pci *glue;
45 int ret; 76 int ret;
46 struct device *dev = &pci->dev; 77 struct device *dev = &pci->dev;
47 struct dwc3_platform_data dwc3_pdata;
48
49 memset(&dwc3_pdata, 0x00, sizeof(dwc3_pdata));
50
51 glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL);
52 if (!glue)
53 return -ENOMEM;
54
55 glue->dev = dev;
56 78
57 ret = pcim_enable_device(pci); 79 ret = pcim_enable_device(pci);
58 if (ret) { 80 if (ret) {
@@ -79,68 +101,34 @@ static int dwc3_pci_probe(struct pci_dev *pci,
79 res[1].name = "dwc_usb3"; 101 res[1].name = "dwc_usb3";
80 res[1].flags = IORESOURCE_IRQ; 102 res[1].flags = IORESOURCE_IRQ;
81 103
82 if (pci->vendor == PCI_VENDOR_ID_AMD &&
83 pci->device == PCI_DEVICE_ID_AMD_NL_USB) {
84 dwc3_pdata.has_lpm_erratum = true;
85 dwc3_pdata.lpm_nyet_threshold = 0xf;
86
87 dwc3_pdata.u2exit_lfps_quirk = true;
88 dwc3_pdata.u2ss_inp3_quirk = true;
89 dwc3_pdata.req_p1p2p3_quirk = true;
90 dwc3_pdata.del_p1p2p3_quirk = true;
91 dwc3_pdata.del_phy_power_chg_quirk = true;
92 dwc3_pdata.lfps_filter_quirk = true;
93 dwc3_pdata.rx_detect_poll_quirk = true;
94
95 dwc3_pdata.tx_de_emphasis_quirk = true;
96 dwc3_pdata.tx_de_emphasis = 1;
97
98 /*
99 * FIXME these quirks should be removed when AMD NL
100 * taps out
101 */
102 dwc3_pdata.disable_scramble_quirk = true;
103 dwc3_pdata.dis_u3_susphy_quirk = true;
104 dwc3_pdata.dis_u2_susphy_quirk = true;
105 }
106
107 ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res)); 104 ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
108 if (ret) { 105 if (ret) {
109 dev_err(dev, "couldn't add resources to dwc3 device\n"); 106 dev_err(dev, "couldn't add resources to dwc3 device\n");
110 return ret; 107 return ret;
111 } 108 }
112 109
113 pci_set_drvdata(pci, glue); 110 pci_set_drvdata(pci, dwc3);
114 111 ret = dwc3_pci_quirks(pci);
115 ret = platform_device_add_data(dwc3, &dwc3_pdata, sizeof(dwc3_pdata));
116 if (ret) 112 if (ret)
117 goto err3; 113 goto err;
118
119 dma_set_coherent_mask(&dwc3->dev, dev->coherent_dma_mask);
120 114
121 dwc3->dev.dma_mask = dev->dma_mask;
122 dwc3->dev.dma_parms = dev->dma_parms;
123 dwc3->dev.parent = dev; 115 dwc3->dev.parent = dev;
124 glue->dwc3 = dwc3;
125 116
126 ret = platform_device_add(dwc3); 117 ret = platform_device_add(dwc3);
127 if (ret) { 118 if (ret) {
128 dev_err(dev, "failed to register dwc3 device\n"); 119 dev_err(dev, "failed to register dwc3 device\n");
129 goto err3; 120 goto err;
130 } 121 }
131 122
132 return 0; 123 return 0;
133 124err:
134err3:
135 platform_device_put(dwc3); 125 platform_device_put(dwc3);
136 return ret; 126 return ret;
137} 127}
138 128
139static void dwc3_pci_remove(struct pci_dev *pci) 129static void dwc3_pci_remove(struct pci_dev *pci)
140{ 130{
141 struct dwc3_pci *glue = pci_get_drvdata(pci); 131 platform_device_unregister(pci_get_drvdata(pci));
142
143 platform_device_unregister(glue->dwc3);
144} 132}
145 133
146static const struct pci_device_id dwc3_pci_id_table[] = { 134static const struct pci_device_id dwc3_pci_id_table[] = {