dwc3-pci.c (9902aa4728fe9128ea45f1a772e2238d64d8cdc5) dwc3-pci.c (0f817ae696b0485f7f83ba3e62f2f40fdde8f5c9)
1/**
2 * dwc3-pci.c - PCI Specific glue layer
3 *
4 * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
5 *
6 * Authors: Felipe Balbi <balbi@ti.com>,
7 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 *

--- 25 unchanged lines hidden (view full) ---

34#define PCI_DEVICE_ID_INTEL_BSW 0x22b7
35#define PCI_DEVICE_ID_INTEL_SPTLP 0x9d30
36#define PCI_DEVICE_ID_INTEL_SPTH 0xa130
37#define PCI_DEVICE_ID_INTEL_BXT 0x0aaa
38#define PCI_DEVICE_ID_INTEL_BXT_M 0x1aaa
39#define PCI_DEVICE_ID_INTEL_APL 0x5aaa
40#define PCI_DEVICE_ID_INTEL_KBP 0xa2b0
41
1/**
2 * dwc3-pci.c - PCI Specific glue layer
3 *
4 * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
5 *
6 * Authors: Felipe Balbi <balbi@ti.com>,
7 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>
8 *

--- 25 unchanged lines hidden (view full) ---

34#define PCI_DEVICE_ID_INTEL_BSW 0x22b7
35#define PCI_DEVICE_ID_INTEL_SPTLP 0x9d30
36#define PCI_DEVICE_ID_INTEL_SPTH 0xa130
37#define PCI_DEVICE_ID_INTEL_BXT 0x0aaa
38#define PCI_DEVICE_ID_INTEL_BXT_M 0x1aaa
39#define PCI_DEVICE_ID_INTEL_APL 0x5aaa
40#define PCI_DEVICE_ID_INTEL_KBP 0xa2b0
41
42/**
43 * struct dwc3_pci - Driver private structure
44 * @dwc3: child dwc3 platform_device
45 * @pci: our link to PCI bus
46 */
47struct dwc3_pci {
48 struct platform_device *dwc3;
49 struct pci_dev *pci;
50};
51
42static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
43static const struct acpi_gpio_params cs_gpios = { 1, 0, false };
44
45static const struct acpi_gpio_mapping acpi_dwc3_byt_gpios[] = {
46 { "reset-gpios", &reset_gpios, 1 },
47 { "cs-gpios", &cs_gpios, 1 },
48 { },
49};
50
52static const struct acpi_gpio_params reset_gpios = { 0, 0, false };
53static const struct acpi_gpio_params cs_gpios = { 1, 0, false };
54
55static const struct acpi_gpio_mapping acpi_dwc3_byt_gpios[] = {
56 { "reset-gpios", &reset_gpios, 1 },
57 { "cs-gpios", &cs_gpios, 1 },
58 { },
59};
60
51static int dwc3_pci_quirks(struct pci_dev *pdev, struct platform_device *dwc3)
61static int dwc3_pci_quirks(struct dwc3_pci *dwc)
52{
62{
63 struct platform_device *dwc3 = dwc->dwc3;
64 struct pci_dev *pdev = dwc->pci;
65
53 if (pdev->vendor == PCI_VENDOR_ID_AMD &&
54 pdev->device == PCI_DEVICE_ID_AMD_NL_USB) {
55 struct property_entry properties[] = {
56 PROPERTY_ENTRY_BOOL("snps,has-lpm-erratum"),
57 PROPERTY_ENTRY_U8("snps,lpm-nyet-threshold", 0xf),
58 PROPERTY_ENTRY_BOOL("snps,u2exit_lfps_quirk"),
59 PROPERTY_ENTRY_BOOL("snps,u2ss_inp3_quirk"),
60 PROPERTY_ENTRY_BOOL("snps,req_p1p2p3_quirk"),

--- 73 unchanged lines hidden (view full) ---

134 }
135
136 return 0;
137}
138
139static int dwc3_pci_probe(struct pci_dev *pci,
140 const struct pci_device_id *id)
141{
66 if (pdev->vendor == PCI_VENDOR_ID_AMD &&
67 pdev->device == PCI_DEVICE_ID_AMD_NL_USB) {
68 struct property_entry properties[] = {
69 PROPERTY_ENTRY_BOOL("snps,has-lpm-erratum"),
70 PROPERTY_ENTRY_U8("snps,lpm-nyet-threshold", 0xf),
71 PROPERTY_ENTRY_BOOL("snps,u2exit_lfps_quirk"),
72 PROPERTY_ENTRY_BOOL("snps,u2ss_inp3_quirk"),
73 PROPERTY_ENTRY_BOOL("snps,req_p1p2p3_quirk"),

--- 73 unchanged lines hidden (view full) ---

147 }
148
149 return 0;
150}
151
152static int dwc3_pci_probe(struct pci_dev *pci,
153 const struct pci_device_id *id)
154{
155 struct dwc3_pci *dwc;
142 struct resource res[2];
156 struct resource res[2];
143 struct platform_device *dwc3;
144 int ret;
145 struct device *dev = &pci->dev;
146
147 ret = pcim_enable_device(pci);
148 if (ret) {
149 dev_err(dev, "failed to enable pci device\n");
150 return -ENODEV;
151 }
152
153 pci_set_master(pci);
154
157 int ret;
158 struct device *dev = &pci->dev;
159
160 ret = pcim_enable_device(pci);
161 if (ret) {
162 dev_err(dev, "failed to enable pci device\n");
163 return -ENODEV;
164 }
165
166 pci_set_master(pci);
167
155 dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO);
156 if (!dwc3) {
157 dev_err(dev, "couldn't allocate dwc3 device\n");
168 dwc = devm_kzalloc(dev, sizeof(*dwc), GFP_KERNEL);
169 if (!dwc)
158 return -ENOMEM;
170 return -ENOMEM;
159 }
160
171
172 dwc->dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO);
173 if (!dwc->dwc3)
174 return -ENOMEM;
175
161 memset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res));
162
163 res[0].start = pci_resource_start(pci, 0);
164 res[0].end = pci_resource_end(pci, 0);
165 res[0].name = "dwc_usb3";
166 res[0].flags = IORESOURCE_MEM;
167
168 res[1].start = pci->irq;
169 res[1].name = "dwc_usb3";
170 res[1].flags = IORESOURCE_IRQ;
171
176 memset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res));
177
178 res[0].start = pci_resource_start(pci, 0);
179 res[0].end = pci_resource_end(pci, 0);
180 res[0].name = "dwc_usb3";
181 res[0].flags = IORESOURCE_MEM;
182
183 res[1].start = pci->irq;
184 res[1].name = "dwc_usb3";
185 res[1].flags = IORESOURCE_IRQ;
186
172 ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
187 ret = platform_device_add_resources(dwc->dwc3, res, ARRAY_SIZE(res));
173 if (ret) {
174 dev_err(dev, "couldn't add resources to dwc3 device\n");
175 return ret;
176 }
177
188 if (ret) {
189 dev_err(dev, "couldn't add resources to dwc3 device\n");
190 return ret;
191 }
192
178 dwc3->dev.parent = dev;
179 ACPI_COMPANION_SET(&dwc3->dev, ACPI_COMPANION(dev));
193 dwc->pci = pci;
194 dwc->dwc3->dev.parent = dev;
195 ACPI_COMPANION_SET(&dwc->dwc3->dev, ACPI_COMPANION(dev));
180
196
181 ret = dwc3_pci_quirks(pci, dwc3);
197 ret = dwc3_pci_quirks(dwc);
182 if (ret)
183 goto err;
184
198 if (ret)
199 goto err;
200
185 ret = platform_device_add(dwc3);
201 ret = platform_device_add(dwc->dwc3);
186 if (ret) {
187 dev_err(dev, "failed to register dwc3 device\n");
188 goto err;
189 }
190
191 device_init_wakeup(dev, true);
192 device_set_run_wake(dev, true);
202 if (ret) {
203 dev_err(dev, "failed to register dwc3 device\n");
204 goto err;
205 }
206
207 device_init_wakeup(dev, true);
208 device_set_run_wake(dev, true);
193 pci_set_drvdata(pci, dwc3);
209 pci_set_drvdata(pci, dwc);
194 pm_runtime_put(dev);
195
196 return 0;
197err:
210 pm_runtime_put(dev);
211
212 return 0;
213err:
198 platform_device_put(dwc3);
214 platform_device_put(dwc->dwc3);
199 return ret;
200}
201
202static void dwc3_pci_remove(struct pci_dev *pci)
203{
215 return ret;
216}
217
218static void dwc3_pci_remove(struct pci_dev *pci)
219{
220 struct dwc3_pci *dwc = pci_get_drvdata(pci);
221
204 device_init_wakeup(&pci->dev, false);
205 pm_runtime_get(&pci->dev);
206 acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pci->dev));
222 device_init_wakeup(&pci->dev, false);
223 pm_runtime_get(&pci->dev);
224 acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pci->dev));
207 platform_device_unregister(pci_get_drvdata(pci));
225 platform_device_unregister(dwc->dwc3);
208}
209
210static const struct pci_device_id dwc3_pci_id_table[] = {
211 {
212 PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS,
213 PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3),
214 },
215 {

--- 24 unchanged lines hidden (view full) ---

240 if (device_run_wake(dev))
241 return 0;
242
243 return -EBUSY;
244}
245
246static int dwc3_pci_runtime_resume(struct device *dev)
247{
226}
227
228static const struct pci_device_id dwc3_pci_id_table[] = {
229 {
230 PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS,
231 PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3),
232 },
233 {

--- 24 unchanged lines hidden (view full) ---

258 if (device_run_wake(dev))
259 return 0;
260
261 return -EBUSY;
262}
263
264static int dwc3_pci_runtime_resume(struct device *dev)
265{
248 struct platform_device *dwc3 = dev_get_drvdata(dev);
266 struct dwc3_pci *dwc = dev_get_drvdata(dev);
267 struct platform_device *dwc3 = dwc->dwc3;
249
250 return pm_runtime_get(&dwc3->dev);
251}
252#endif /* CONFIG_PM */
253
254#ifdef CONFIG_PM_SLEEP
255static int dwc3_pci_pm_dummy(struct device *dev)
256{

--- 33 unchanged lines hidden ---
268
269 return pm_runtime_get(&dwc3->dev);
270}
271#endif /* CONFIG_PM */
272
273#ifdef CONFIG_PM_SLEEP
274static int dwc3_pci_pm_dummy(struct device *dev)
275{

--- 33 unchanged lines hidden ---