dwc3-pci.c (6ea24cf79e055f0a62a64baa8587e2254a493c7b) dwc3-pci.c (e9af9229098d92145d0b894b78878bbc6ac7c910)
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 *

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

15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#include <linux/kernel.h>
20#include <linux/module.h>
21#include <linux/slab.h>
22#include <linux/pci.h>
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 *

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

15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#include <linux/kernel.h>
20#include <linux/module.h>
21#include <linux/slab.h>
22#include <linux/pci.h>
23#include <linux/pm_runtime.h>
23#include <linux/platform_device.h>
24#include <linux/gpio/consumer.h>
25#include <linux/acpi.h>
26
27#include "platform_data.h"
28
29#define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3 0xabcd
30#define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3_AXI 0xabce

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

42static const struct acpi_gpio_params cs_gpios = { 1, 0, false };
43
44static const struct acpi_gpio_mapping acpi_dwc3_byt_gpios[] = {
45 { "reset-gpios", &reset_gpios, 1 },
46 { "cs-gpios", &cs_gpios, 1 },
47 { },
48};
49
24#include <linux/platform_device.h>
25#include <linux/gpio/consumer.h>
26#include <linux/acpi.h>
27
28#include "platform_data.h"
29
30#define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3 0xabcd
31#define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3_AXI 0xabce

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

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
50static int dwc3_pci_quirks(struct pci_dev *pdev)
51static int dwc3_pci_quirks(struct pci_dev *pdev, struct platform_device *dwc3)
51{
52 if (pdev->vendor == PCI_VENDOR_ID_AMD &&
53 pdev->device == PCI_DEVICE_ID_AMD_NL_USB) {
54 struct dwc3_platform_data pdata;
55
56 memset(&pdata, 0, sizeof(pdata));
57
58 pdata.has_lpm_erratum = true;

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

72 /*
73 * FIXME these quirks should be removed when AMD NL
74 * taps out
75 */
76 pdata.disable_scramble_quirk = true;
77 pdata.dis_u3_susphy_quirk = true;
78 pdata.dis_u2_susphy_quirk = true;
79
52{
53 if (pdev->vendor == PCI_VENDOR_ID_AMD &&
54 pdev->device == PCI_DEVICE_ID_AMD_NL_USB) {
55 struct dwc3_platform_data pdata;
56
57 memset(&pdata, 0, sizeof(pdata));
58
59 pdata.has_lpm_erratum = true;

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

73 /*
74 * FIXME these quirks should be removed when AMD NL
75 * taps out
76 */
77 pdata.disable_scramble_quirk = true;
78 pdata.dis_u3_susphy_quirk = true;
79 pdata.dis_u2_susphy_quirk = true;
80
80 return platform_device_add_data(pci_get_drvdata(pdev), &pdata,
81 sizeof(pdata));
81 return platform_device_add_data(dwc3, &pdata, sizeof(pdata));
82 }
83
84 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
85 pdev->device == PCI_DEVICE_ID_INTEL_BYT) {
86 struct gpio_desc *gpio;
87
88 acpi_dev_add_driver_gpios(ACPI_COMPANION(&pdev->dev),
89 acpi_dwc3_byt_gpios);

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

118
119 struct dwc3_platform_data pdata;
120
121 memset(&pdata, 0, sizeof(pdata));
122 pdata.usb3_lpm_capable = true;
123 pdata.has_lpm_erratum = true;
124 pdata.dis_enblslpm_quirk = true;
125
82 }
83
84 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
85 pdev->device == PCI_DEVICE_ID_INTEL_BYT) {
86 struct gpio_desc *gpio;
87
88 acpi_dev_add_driver_gpios(ACPI_COMPANION(&pdev->dev),
89 acpi_dwc3_byt_gpios);

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

118
119 struct dwc3_platform_data pdata;
120
121 memset(&pdata, 0, sizeof(pdata));
122 pdata.usb3_lpm_capable = true;
123 pdata.has_lpm_erratum = true;
124 pdata.dis_enblslpm_quirk = true;
125
126 return platform_device_add_data(pci_get_drvdata(pdev), &pdata,
127 sizeof(pdata));
126 return platform_device_add_data(dwc3, &pdata, sizeof(pdata));
128 }
129
130 return 0;
131}
132
133static int dwc3_pci_probe(struct pci_dev *pci,
134 const struct pci_device_id *id)
135{

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

164 res[1].flags = IORESOURCE_IRQ;
165
166 ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
167 if (ret) {
168 dev_err(dev, "couldn't add resources to dwc3 device\n");
169 return ret;
170 }
171
127 }
128
129 return 0;
130}
131
132static int dwc3_pci_probe(struct pci_dev *pci,
133 const struct pci_device_id *id)
134{

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

163 res[1].flags = IORESOURCE_IRQ;
164
165 ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res));
166 if (ret) {
167 dev_err(dev, "couldn't add resources to dwc3 device\n");
168 return ret;
169 }
170
172 pci_set_drvdata(pci, dwc3);
173 ret = dwc3_pci_quirks(pci);
174 if (ret)
175 goto err;
176
177 dwc3->dev.parent = dev;
178 ACPI_COMPANION_SET(&dwc3->dev, ACPI_COMPANION(dev));
179
171 dwc3->dev.parent = dev;
172 ACPI_COMPANION_SET(&dwc3->dev, ACPI_COMPANION(dev));
173
174 ret = dwc3_pci_quirks(pci, dwc3);
175 if (ret)
176 goto err;
177
180 ret = platform_device_add(dwc3);
181 if (ret) {
182 dev_err(dev, "failed to register dwc3 device\n");
183 goto err;
184 }
185
178 ret = platform_device_add(dwc3);
179 if (ret) {
180 dev_err(dev, "failed to register dwc3 device\n");
181 goto err;
182 }
183
184 device_init_wakeup(dev, true);
185 device_set_run_wake(dev, true);
186 pci_set_drvdata(pci, dwc3);
187 pm_runtime_put(dev);
188
186 return 0;
187err:
188 platform_device_put(dwc3);
189 return ret;
190}
191
192static void dwc3_pci_remove(struct pci_dev *pci)
193{
189 return 0;
190err:
191 platform_device_put(dwc3);
192 return ret;
193}
194
195static void dwc3_pci_remove(struct pci_dev *pci)
196{
197 device_init_wakeup(&pci->dev, false);
198 pm_runtime_get(&pci->dev);
194 acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pci->dev));
195 platform_device_unregister(pci_get_drvdata(pci));
196}
197
198static const struct pci_device_id dwc3_pci_id_table[] = {
199 {
200 PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS,
201 PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3),

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

216 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT), },
217 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT_M), },
218 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), },
219 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), },
220 { } /* Terminating Entry */
221};
222MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table);
223
199 acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pci->dev));
200 platform_device_unregister(pci_get_drvdata(pci));
201}
202
203static const struct pci_device_id dwc3_pci_id_table[] = {
204 {
205 PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS,
206 PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3),

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

221 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT), },
222 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT_M), },
223 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), },
224 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), },
225 { } /* Terminating Entry */
226};
227MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table);
228
229#ifdef CONFIG_PM
230static int dwc3_pci_runtime_suspend(struct device *dev)
231{
232 if (device_run_wake(dev))
233 return 0;
234
235 return -EBUSY;
236}
237
238static int dwc3_pci_pm_dummy(struct device *dev)
239{
240 /*
241 * There's nothing to do here. No, seriously. Everything is either taken
242 * care either by PCI subsystem or dwc3/core.c, so we have nothing
243 * missing here.
244 *
245 * So you'd think we didn't need this at all, but PCI subsystem will
246 * bail out if we don't have a valid callback :-s
247 */
248 return 0;
249}
250#endif /* CONFIG_PM */
251
252static struct dev_pm_ops dwc3_pci_dev_pm_ops = {
253 SET_SYSTEM_SLEEP_PM_OPS(dwc3_pci_pm_dummy, dwc3_pci_pm_dummy)
254 SET_RUNTIME_PM_OPS(dwc3_pci_runtime_suspend, dwc3_pci_pm_dummy,
255 NULL)
256};
257
224static struct pci_driver dwc3_pci_driver = {
225 .name = "dwc3-pci",
226 .id_table = dwc3_pci_id_table,
227 .probe = dwc3_pci_probe,
228 .remove = dwc3_pci_remove,
258static struct pci_driver dwc3_pci_driver = {
259 .name = "dwc3-pci",
260 .id_table = dwc3_pci_id_table,
261 .probe = dwc3_pci_probe,
262 .remove = dwc3_pci_remove,
263 .driver = {
264 .pm = &dwc3_pci_dev_pm_ops,
265 }
229};
230
231MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
232MODULE_LICENSE("GPL v2");
233MODULE_DESCRIPTION("DesignWare USB3 PCI Glue Layer");
234
235module_pci_driver(dwc3_pci_driver);
266};
267
268MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>");
269MODULE_LICENSE("GPL v2");
270MODULE_DESCRIPTION("DesignWare USB3 PCI Glue Layer");
271
272module_pci_driver(dwc3_pci_driver);