dwc3-pci.c (87d852de94d606010faf283bf1df70e3e825e6d0) dwc3-pci.c (1a7b12f69a9434a766e77c43d113826f0413b032)
1// SPDX-License-Identifier: GPL-2.0
2/**
3 * dwc3-pci.c - PCI Specific glue layer
4 *
5 * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
6 *
7 * Authors: Felipe Balbi <balbi@ti.com>,
8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>

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

96 writel(value, reg + GP_RWREG1);
97 /* This comes from the Intel Android x86 tree w/o any explanation */
98 msleep(100);
99unmap:
100 pcim_iounmap(pci, reg);
101 return 0;
102}
103
1// SPDX-License-Identifier: GPL-2.0
2/**
3 * dwc3-pci.c - PCI Specific glue layer
4 *
5 * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com
6 *
7 * Authors: Felipe Balbi <balbi@ti.com>,
8 * Sebastian Andrzej Siewior <bigeasy@linutronix.de>

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

96 writel(value, reg + GP_RWREG1);
97 /* This comes from the Intel Android x86 tree w/o any explanation */
98 msleep(100);
99unmap:
100 pcim_iounmap(pci, reg);
101 return 0;
102}
103
104static const struct property_entry dwc3_pci_intel_properties[] = {
105 PROPERTY_ENTRY_STRING("dr_mode", "peripheral"),
106 PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"),
107 {}
108};
109
110static const struct property_entry dwc3_pci_amd_properties[] = {
111 PROPERTY_ENTRY_BOOL("snps,has-lpm-erratum"),
112 PROPERTY_ENTRY_U8("snps,lpm-nyet-threshold", 0xf),
113 PROPERTY_ENTRY_BOOL("snps,u2exit_lfps_quirk"),
114 PROPERTY_ENTRY_BOOL("snps,u2ss_inp3_quirk"),
115 PROPERTY_ENTRY_BOOL("snps,req_p1p2p3_quirk"),
116 PROPERTY_ENTRY_BOOL("snps,del_p1p2p3_quirk"),
117 PROPERTY_ENTRY_BOOL("snps,del_phy_power_chg_quirk"),
118 PROPERTY_ENTRY_BOOL("snps,lfps_filter_quirk"),
119 PROPERTY_ENTRY_BOOL("snps,rx_detect_poll_quirk"),
120 PROPERTY_ENTRY_BOOL("snps,tx_de_emphasis_quirk"),
121 PROPERTY_ENTRY_U8("snps,tx_de_emphasis", 1),
122 /* FIXME these quirks should be removed when AMD NL tapes out */
123 PROPERTY_ENTRY_BOOL("snps,disable_scramble_quirk"),
124 PROPERTY_ENTRY_BOOL("snps,dis_u3_susphy_quirk"),
125 PROPERTY_ENTRY_BOOL("snps,dis_u2_susphy_quirk"),
126 PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"),
127 {}
128};
129
104static int dwc3_pci_quirks(struct dwc3_pci *dwc)
105{
130static int dwc3_pci_quirks(struct dwc3_pci *dwc)
131{
106 struct platform_device *dwc3 = dwc->dwc3;
107 struct pci_dev *pdev = dwc->pci;
108
132 struct pci_dev *pdev = dwc->pci;
133
109 if (pdev->vendor == PCI_VENDOR_ID_AMD &&
110 pdev->device == PCI_DEVICE_ID_AMD_NL_USB) {
111 struct property_entry properties[] = {
112 PROPERTY_ENTRY_BOOL("snps,has-lpm-erratum"),
113 PROPERTY_ENTRY_U8("snps,lpm-nyet-threshold", 0xf),
114 PROPERTY_ENTRY_BOOL("snps,u2exit_lfps_quirk"),
115 PROPERTY_ENTRY_BOOL("snps,u2ss_inp3_quirk"),
116 PROPERTY_ENTRY_BOOL("snps,req_p1p2p3_quirk"),
117 PROPERTY_ENTRY_BOOL("snps,del_p1p2p3_quirk"),
118 PROPERTY_ENTRY_BOOL("snps,del_phy_power_chg_quirk"),
119 PROPERTY_ENTRY_BOOL("snps,lfps_filter_quirk"),
120 PROPERTY_ENTRY_BOOL("snps,rx_detect_poll_quirk"),
121 PROPERTY_ENTRY_BOOL("snps,tx_de_emphasis_quirk"),
122 PROPERTY_ENTRY_U8("snps,tx_de_emphasis", 1),
123 /*
124 * FIXME these quirks should be removed when AMD NL
125 * tapes out
126 */
127 PROPERTY_ENTRY_BOOL("snps,disable_scramble_quirk"),
128 PROPERTY_ENTRY_BOOL("snps,dis_u3_susphy_quirk"),
129 PROPERTY_ENTRY_BOOL("snps,dis_u2_susphy_quirk"),
130 PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"),
131 { },
132 };
133
134 return platform_device_add_properties(dwc3, properties);
135 }
136
137 if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
134 if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
138 int ret;
139
140 struct property_entry properties[] = {
141 PROPERTY_ENTRY_STRING("dr_mode", "peripheral"),
142 PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"),
143 { }
144 };
145
146 ret = platform_device_add_properties(dwc3, properties);
147 if (ret < 0)
148 return ret;
149
150 if (pdev->device == PCI_DEVICE_ID_INTEL_BXT ||
151 pdev->device == PCI_DEVICE_ID_INTEL_BXT_M) {
152 guid_parse(PCI_INTEL_BXT_DSM_GUID, &dwc->guid);
153 dwc->has_dsm_for_pm = true;
154 }
155
156 if (pdev->device == PCI_DEVICE_ID_INTEL_BYT) {
157 struct gpio_desc *gpio;
135 if (pdev->device == PCI_DEVICE_ID_INTEL_BXT ||
136 pdev->device == PCI_DEVICE_ID_INTEL_BXT_M) {
137 guid_parse(PCI_INTEL_BXT_DSM_GUID, &dwc->guid);
138 dwc->has_dsm_for_pm = true;
139 }
140
141 if (pdev->device == PCI_DEVICE_ID_INTEL_BYT) {
142 struct gpio_desc *gpio;
143 int ret;
158
159 /* On BYT the FW does not always enable the refclock */
160 ret = dwc3_byt_enable_ulpi_refclock(pdev);
161 if (ret)
162 return ret;
163
164 ret = devm_acpi_dev_add_driver_gpios(&pdev->dev,
165 acpi_dwc3_byt_gpios);

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

211 if (ret)
212 return;
213
214 pm_runtime_mark_last_busy(&dwc3->dev);
215 pm_runtime_put_sync_autosuspend(&dwc3->dev);
216}
217#endif
218
144
145 /* On BYT the FW does not always enable the refclock */
146 ret = dwc3_byt_enable_ulpi_refclock(pdev);
147 if (ret)
148 return ret;
149
150 ret = devm_acpi_dev_add_driver_gpios(&pdev->dev,
151 acpi_dwc3_byt_gpios);

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

197 if (ret)
198 return;
199
200 pm_runtime_mark_last_busy(&dwc3->dev);
201 pm_runtime_put_sync_autosuspend(&dwc3->dev);
202}
203#endif
204
219static int dwc3_pci_probe(struct pci_dev *pci,
220 const struct pci_device_id *id)
205static int dwc3_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
221{
206{
207 struct property_entry *p = (struct property_entry *)id->driver_data;
222 struct dwc3_pci *dwc;
223 struct resource res[2];
224 int ret;
225 struct device *dev = &pci->dev;
226
227 ret = pcim_enable_device(pci);
228 if (ret) {
229 dev_err(dev, "failed to enable pci device\n");

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

256 dev_err(dev, "couldn't add resources to dwc3 device\n");
257 goto err;
258 }
259
260 dwc->pci = pci;
261 dwc->dwc3->dev.parent = dev;
262 ACPI_COMPANION_SET(&dwc->dwc3->dev, ACPI_COMPANION(dev));
263
208 struct dwc3_pci *dwc;
209 struct resource res[2];
210 int ret;
211 struct device *dev = &pci->dev;
212
213 ret = pcim_enable_device(pci);
214 if (ret) {
215 dev_err(dev, "failed to enable pci device\n");

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

242 dev_err(dev, "couldn't add resources to dwc3 device\n");
243 goto err;
244 }
245
246 dwc->pci = pci;
247 dwc->dwc3->dev.parent = dev;
248 ACPI_COMPANION_SET(&dwc->dwc3->dev, ACPI_COMPANION(dev));
249
250 ret = platform_device_add_properties(dwc->dwc3, p);
251 if (ret < 0)
252 return ret;
253
264 ret = dwc3_pci_quirks(dwc);
265 if (ret)
266 goto err;
267
268 ret = platform_device_add(dwc->dwc3);
269 if (ret) {
270 dev_err(dev, "failed to register dwc3 device\n");
271 goto err;

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

293 cancel_work_sync(&dwc->wakeup_work);
294#endif
295 device_init_wakeup(&pci->dev, false);
296 pm_runtime_get(&pci->dev);
297 platform_device_unregister(dwc->dwc3);
298}
299
300static const struct pci_device_id dwc3_pci_id_table[] = {
254 ret = dwc3_pci_quirks(dwc);
255 if (ret)
256 goto err;
257
258 ret = platform_device_add(dwc->dwc3);
259 if (ret) {
260 dev_err(dev, "failed to register dwc3 device\n");
261 goto err;

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

283 cancel_work_sync(&dwc->wakeup_work);
284#endif
285 device_init_wakeup(&pci->dev, false);
286 pm_runtime_get(&pci->dev);
287 platform_device_unregister(dwc->dwc3);
288}
289
290static const struct pci_device_id dwc3_pci_id_table[] = {
301 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BSW), },
302 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT), },
303 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MRFLD), },
304 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SPTLP), },
305 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SPTH), },
306 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT), },
307 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BXT_M), },
308 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_APL), },
309 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KBP), },
310 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GLK), },
311 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CNPLP), },
312 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CNPH), },
313 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICLLP), },
314 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB), },
291 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BSW),
292 (kernel_ulong_t) &dwc3_pci_intel_properties },
293
294 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BYT),
295 (kernel_ulong_t) &dwc3_pci_intel_properties, },
296
297 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_MRFLD),
298 (kernel_ulong_t) &dwc3_pci_intel_properties, },
299
300 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_SPTLP),
301 (kernel_ulong_t) &dwc3_pci_intel_properties, },
302
303 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_SPTH),
304 (kernel_ulong_t) &dwc3_pci_intel_properties, },
305
306 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BXT),
307 (kernel_ulong_t) &dwc3_pci_intel_properties, },
308
309 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BXT_M),
310 (kernel_ulong_t) &dwc3_pci_intel_properties, },
311
312 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_APL),
313 (kernel_ulong_t) &dwc3_pci_intel_properties, },
314
315 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_KBP),
316 (kernel_ulong_t) &dwc3_pci_intel_properties, },
317
318 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_GLK),
319 (kernel_ulong_t) &dwc3_pci_intel_properties, },
320
321 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_CNPLP),
322 (kernel_ulong_t) &dwc3_pci_intel_properties, },
323
324 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_CNPH),
325 (kernel_ulong_t) &dwc3_pci_intel_properties, },
326
327 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICLLP),
328 (kernel_ulong_t) &dwc3_pci_intel_properties, },
329
330 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_NL_USB),
331 (kernel_ulong_t) &dwc3_pci_amd_properties, },
315 { } /* Terminating Entry */
316};
317MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table);
318
319#if defined(CONFIG_PM) || defined(CONFIG_PM_SLEEP)
320static int dwc3_pci_dsm(struct dwc3_pci *dwc, int param)
321{
322 union acpi_object *obj;

--- 85 unchanged lines hidden ---
332 { } /* Terminating Entry */
333};
334MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table);
335
336#if defined(CONFIG_PM) || defined(CONFIG_PM_SLEEP)
337static int dwc3_pci_dsm(struct dwc3_pci *dwc, int param)
338{
339 union acpi_object *obj;

--- 85 unchanged lines hidden ---