1 // SPDX-License-Identifier: GPL-2.0
3 * xHCI host controller driver PCI Bus Glue.
5 * Copyright (C) 2008 Intel Corp.
8 * Some code borrowed from the Linux EHCI driver.
11 #include <linux/pci.h>
12 #include <linux/slab.h>
13 #include <linux/module.h>
14 #include <linux/acpi.h>
15 #include <linux/reset.h>
18 #include "xhci-trace.h"
21 #define SSIC_PORT_NUM 2
22 #define SSIC_PORT_CFG2 0x880c
23 #define SSIC_PORT_CFG2_OFFSET 0x30
24 #define PROG_DONE (1 << 30)
25 #define SSIC_PORT_UNUSED (1 << 31)
27 /* Device for a quirk */
28 #define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73
29 #define PCI_DEVICE_ID_FRESCO_LOGIC_PDK 0x1000
30 #define PCI_DEVICE_ID_FRESCO_LOGIC_FL1009 0x1009
31 #define PCI_DEVICE_ID_FRESCO_LOGIC_FL1400 0x1400
33 #define PCI_VENDOR_ID_ETRON 0x1b6f
34 #define PCI_DEVICE_ID_EJ168 0x7023
36 #define PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI 0x8c31
37 #define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31
38 #define PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_XHCI 0x9cb1
39 #define PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI 0x22b5
40 #define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI 0xa12f
41 #define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f
42 #define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8
43 #define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8
44 #define PCI_DEVICE_ID_INTEL_APL_XHCI 0x5aa8
45 #define PCI_DEVICE_ID_INTEL_DNV_XHCI 0x19d0
46 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_XHCI 0x15b5
47 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_4C_XHCI 0x15b6
48 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_2C_XHCI 0x15db
49 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_4C_XHCI 0x15d4
50 #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_XHCI 0x15e9
51 #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_XHCI 0x15ec
52 #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_XHCI 0x15f0
53 #define PCI_DEVICE_ID_INTEL_ICE_LAKE_XHCI 0x8a13
54 #define PCI_DEVICE_ID_INTEL_CML_XHCI 0xa3af
55 #define PCI_DEVICE_ID_INTEL_TIGER_LAKE_XHCI 0x9a13
57 #define PCI_DEVICE_ID_AMD_PROMONTORYA_4 0x43b9
58 #define PCI_DEVICE_ID_AMD_PROMONTORYA_3 0x43ba
59 #define PCI_DEVICE_ID_AMD_PROMONTORYA_2 0x43bb
60 #define PCI_DEVICE_ID_AMD_PROMONTORYA_1 0x43bc
61 #define PCI_DEVICE_ID_ASMEDIA_1042_XHCI 0x1042
62 #define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI 0x1142
63 #define PCI_DEVICE_ID_ASMEDIA_1142_XHCI 0x1242
64 #define PCI_DEVICE_ID_ASMEDIA_2142_XHCI 0x2142
66 static const char hcd_name[] = "xhci_hcd";
68 static struct hc_driver __read_mostly xhci_pci_hc_driver;
70 static int xhci_pci_setup(struct usb_hcd *hcd);
72 static const struct xhci_driver_overrides xhci_pci_overrides __initconst = {
73 .reset = xhci_pci_setup,
76 /* called after powerup, by probe or system-pm "wakeup" */
77 static int xhci_pci_reinit(struct xhci_hcd *xhci, struct pci_dev *pdev)
80 * TODO: Implement finding debug ports later.
81 * TODO: see if there are any quirks that need to be added to handle
82 * new extended capabilities.
85 /* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */
86 if (!pci_set_mwi(pdev))
87 xhci_dbg(xhci, "MWI active\n");
89 xhci_dbg(xhci, "Finished xhci_pci_reinit\n");
93 static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
95 struct pci_dev *pdev = to_pci_dev(dev);
96 struct xhci_driver_data *driver_data;
97 const struct pci_device_id *id;
99 id = pci_match_id(pdev->driver->id_table, pdev);
101 if (id && id->driver_data) {
102 driver_data = (struct xhci_driver_data *)id->driver_data;
103 xhci->quirks |= driver_data->quirks;
106 /* Look for vendor-specific quirks */
107 if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC &&
108 (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK ||
109 pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_FL1400)) {
110 if (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK &&
111 pdev->revision == 0x0) {
112 xhci->quirks |= XHCI_RESET_EP_QUIRK;
113 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
114 "QUIRK: Fresco Logic xHC needs configure"
115 " endpoint cmd after reset endpoint");
117 if (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK &&
118 pdev->revision == 0x4) {
119 xhci->quirks |= XHCI_SLOW_SUSPEND;
120 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
121 "QUIRK: Fresco Logic xHC revision %u"
122 "must be suspended extra slowly",
125 if (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK)
126 xhci->quirks |= XHCI_BROKEN_STREAMS;
127 /* Fresco Logic confirms: all revisions of this chip do not
128 * support MSI, even though some of them claim to in their PCI
131 xhci->quirks |= XHCI_BROKEN_MSI;
132 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
133 "QUIRK: Fresco Logic revision %u "
134 "has broken MSI implementation",
136 xhci->quirks |= XHCI_TRUST_TX_LENGTH;
139 if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC &&
140 pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_FL1009)
141 xhci->quirks |= XHCI_BROKEN_STREAMS;
143 if (pdev->vendor == PCI_VENDOR_ID_NEC)
144 xhci->quirks |= XHCI_NEC_HOST;
146 if (pdev->vendor == PCI_VENDOR_ID_AMD && xhci->hci_version == 0x96)
147 xhci->quirks |= XHCI_AMD_0x96_HOST;
150 if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_quirk_pll_check())
151 xhci->quirks |= XHCI_AMD_PLL_FIX;
153 if (pdev->vendor == PCI_VENDOR_ID_AMD &&
154 (pdev->device == 0x145c ||
155 pdev->device == 0x15e0 ||
156 pdev->device == 0x15e1 ||
157 pdev->device == 0x43bb))
158 xhci->quirks |= XHCI_SUSPEND_DELAY;
160 if (pdev->vendor == PCI_VENDOR_ID_AMD &&
161 (pdev->device == 0x15e0 || pdev->device == 0x15e1))
162 xhci->quirks |= XHCI_SNPS_BROKEN_SUSPEND;
164 if (pdev->vendor == PCI_VENDOR_ID_AMD)
165 xhci->quirks |= XHCI_TRUST_TX_LENGTH;
167 if ((pdev->vendor == PCI_VENDOR_ID_AMD) &&
168 ((pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_4) ||
169 (pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_3) ||
170 (pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_2) ||
171 (pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_1)))
172 xhci->quirks |= XHCI_U2_DISABLE_WAKE;
174 if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
175 xhci->quirks |= XHCI_LPM_SUPPORT;
176 xhci->quirks |= XHCI_INTEL_HOST;
177 xhci->quirks |= XHCI_AVOID_BEI;
179 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
180 pdev->device == PCI_DEVICE_ID_INTEL_PANTHERPOINT_XHCI) {
181 xhci->quirks |= XHCI_EP_LIMIT_QUIRK;
182 xhci->limit_active_eps = 64;
183 xhci->quirks |= XHCI_SW_BW_CHECKING;
185 * PPT desktop boards DH77EB and DH77DF will power back on after
186 * a few seconds of being shutdown. The fix for this is to
187 * switch the ports from xHCI to EHCI on shutdown. We can't use
188 * DMI information to find those particular boards (since each
189 * vendor will change the board name), so we have to key off all
192 xhci->quirks |= XHCI_SPURIOUS_REBOOT;
194 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
195 (pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI ||
196 pdev->device == PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_XHCI)) {
197 xhci->quirks |= XHCI_SPURIOUS_REBOOT;
198 xhci->quirks |= XHCI_SPURIOUS_WAKEUP;
200 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
201 (pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI ||
202 pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI ||
203 pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
204 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI ||
205 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI ||
206 pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI ||
207 pdev->device == PCI_DEVICE_ID_INTEL_DNV_XHCI ||
208 pdev->device == PCI_DEVICE_ID_INTEL_CML_XHCI)) {
209 xhci->quirks |= XHCI_PME_STUCK_QUIRK;
211 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
212 pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI)
213 xhci->quirks |= XHCI_SSIC_PORT_UNUSED;
214 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
215 (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
216 pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI ||
217 pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI))
218 xhci->quirks |= XHCI_INTEL_USB_ROLE_SW;
219 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
220 (pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
221 pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI ||
222 pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI ||
223 pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI ||
224 pdev->device == PCI_DEVICE_ID_INTEL_DNV_XHCI))
225 xhci->quirks |= XHCI_MISSING_CAS;
227 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
228 (pdev->device == PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_XHCI ||
229 pdev->device == PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_4C_XHCI ||
230 pdev->device == PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_2C_XHCI ||
231 pdev->device == PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_4C_XHCI ||
232 pdev->device == PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_XHCI ||
233 pdev->device == PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_XHCI ||
234 pdev->device == PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_XHCI ||
235 pdev->device == PCI_DEVICE_ID_INTEL_ICE_LAKE_XHCI ||
236 pdev->device == PCI_DEVICE_ID_INTEL_TIGER_LAKE_XHCI))
237 xhci->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW;
239 if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
240 pdev->device == PCI_DEVICE_ID_EJ168) {
241 xhci->quirks |= XHCI_RESET_ON_RESUME;
242 xhci->quirks |= XHCI_TRUST_TX_LENGTH;
243 xhci->quirks |= XHCI_BROKEN_STREAMS;
245 if (pdev->vendor == PCI_VENDOR_ID_RENESAS &&
246 pdev->device == 0x0014) {
247 xhci->quirks |= XHCI_TRUST_TX_LENGTH;
248 xhci->quirks |= XHCI_ZERO_64B_REGS;
250 if (pdev->vendor == PCI_VENDOR_ID_RENESAS &&
251 pdev->device == 0x0015) {
252 xhci->quirks |= XHCI_RESET_ON_RESUME;
253 xhci->quirks |= XHCI_ZERO_64B_REGS;
255 if (pdev->vendor == PCI_VENDOR_ID_VIA)
256 xhci->quirks |= XHCI_RESET_ON_RESUME;
258 /* See https://bugzilla.kernel.org/show_bug.cgi?id=79511 */
259 if (pdev->vendor == PCI_VENDOR_ID_VIA &&
260 pdev->device == 0x3432)
261 xhci->quirks |= XHCI_BROKEN_STREAMS;
263 if (pdev->vendor == PCI_VENDOR_ID_VIA && pdev->device == 0x3483)
264 xhci->quirks |= XHCI_LPM_SUPPORT;
266 if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
267 pdev->device == PCI_DEVICE_ID_ASMEDIA_1042_XHCI)
268 xhci->quirks |= XHCI_BROKEN_STREAMS;
269 if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
270 pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI)
271 xhci->quirks |= XHCI_TRUST_TX_LENGTH;
272 if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
273 (pdev->device == PCI_DEVICE_ID_ASMEDIA_1142_XHCI ||
274 pdev->device == PCI_DEVICE_ID_ASMEDIA_2142_XHCI))
275 xhci->quirks |= XHCI_NO_64BIT_SUPPORT;
277 if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
278 pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI)
279 xhci->quirks |= XHCI_ASMEDIA_MODIFY_FLOWCONTROL;
281 if (pdev->vendor == PCI_VENDOR_ID_TI && pdev->device == 0x8241)
282 xhci->quirks |= XHCI_LIMIT_ENDPOINT_INTERVAL_7;
284 if ((pdev->vendor == PCI_VENDOR_ID_BROADCOM ||
285 pdev->vendor == PCI_VENDOR_ID_CAVIUM) &&
286 pdev->device == 0x9026)
287 xhci->quirks |= XHCI_RESET_PLL_ON_DISCONNECT;
289 if (xhci->quirks & XHCI_RESET_ON_RESUME)
290 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
291 "QUIRK: Resetting on resume");
295 static void xhci_pme_acpi_rtd3_enable(struct pci_dev *dev)
297 static const guid_t intel_dsm_guid =
298 GUID_INIT(0xac340cb7, 0xe901, 0x45bf,
299 0xb7, 0xe6, 0x2b, 0x34, 0xec, 0x93, 0x1e, 0x23);
300 union acpi_object *obj;
302 obj = acpi_evaluate_dsm(ACPI_HANDLE(&dev->dev), &intel_dsm_guid, 3, 1,
307 static void xhci_pme_acpi_rtd3_enable(struct pci_dev *dev) { }
308 #endif /* CONFIG_ACPI */
310 /* called during probe() after chip reset completes */
311 static int xhci_pci_setup(struct usb_hcd *hcd)
313 struct xhci_hcd *xhci;
314 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
317 xhci = hcd_to_xhci(hcd);
319 pci_read_config_byte(pdev, XHCI_SBRN_OFFSET, &xhci->sbrn);
321 /* imod_interval is the interrupt moderation value in nanoseconds. */
322 xhci->imod_interval = 40000;
324 retval = xhci_gen_setup(hcd, xhci_pci_quirks);
328 if (!usb_hcd_is_primary_hcd(hcd))
331 if (xhci->quirks & XHCI_PME_STUCK_QUIRK)
332 xhci_pme_acpi_rtd3_enable(pdev);
334 xhci_dbg(xhci, "Got SBRN %u\n", (unsigned int) xhci->sbrn);
336 /* Find any debug ports */
337 return xhci_pci_reinit(xhci, pdev);
341 * We need to register our own PCI probe function (instead of the USB core's
342 * function) in order to create a second roothub under xHCI.
344 static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
347 struct xhci_hcd *xhci;
349 struct xhci_driver_data *driver_data;
350 struct reset_control *reset;
352 driver_data = (struct xhci_driver_data *)id->driver_data;
353 if (driver_data && driver_data->quirks & XHCI_RENESAS_FW_QUIRK) {
354 retval = renesas_xhci_check_request_fw(dev, id);
359 reset = devm_reset_control_get_optional_exclusive(&dev->dev, NULL);
361 return PTR_ERR(reset);
362 reset_control_reset(reset);
364 /* Prevent runtime suspending between USB-2 and USB-3 initialization */
365 pm_runtime_get_noresume(&dev->dev);
367 /* Register the USB 2.0 roothub.
368 * FIXME: USB core must know to register the USB 2.0 roothub first.
369 * This is sort of silly, because we could just set the HCD driver flags
370 * to say USB 2.0, but I'm not sure what the implications would be in
371 * the other parts of the HCD code.
373 retval = usb_hcd_pci_probe(dev, id, &xhci_pci_hc_driver);
378 /* USB 2.0 roothub is stored in the PCI device now. */
379 hcd = dev_get_drvdata(&dev->dev);
380 xhci = hcd_to_xhci(hcd);
382 xhci->shared_hcd = usb_create_shared_hcd(&xhci_pci_hc_driver, &dev->dev,
384 if (!xhci->shared_hcd) {
386 goto dealloc_usb2_hcd;
389 retval = xhci_ext_cap_init(xhci);
393 retval = usb_add_hcd(xhci->shared_hcd, dev->irq,
397 /* Roothub already marked as USB 3.0 speed */
399 if (!(xhci->quirks & XHCI_BROKEN_STREAMS) &&
400 HCC_MAX_PSA(xhci->hcc_params) >= 4)
401 xhci->shared_hcd->can_do_streams = 1;
403 /* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */
404 pm_runtime_put_noidle(&dev->dev);
406 if (xhci->quirks & XHCI_DEFAULT_PM_RUNTIME_ALLOW)
407 pm_runtime_allow(&dev->dev);
412 usb_put_hcd(xhci->shared_hcd);
414 usb_hcd_pci_remove(dev);
416 pm_runtime_put_noidle(&dev->dev);
420 static void xhci_pci_remove(struct pci_dev *dev)
422 struct xhci_hcd *xhci;
424 xhci = hcd_to_xhci(pci_get_drvdata(dev));
425 if (xhci->quirks & XHCI_RENESAS_FW_QUIRK)
426 renesas_xhci_pci_exit(dev);
428 xhci->xhc_state |= XHCI_STATE_REMOVING;
430 if (xhci->quirks & XHCI_DEFAULT_PM_RUNTIME_ALLOW)
431 pm_runtime_forbid(&dev->dev);
433 if (xhci->shared_hcd) {
434 usb_remove_hcd(xhci->shared_hcd);
435 usb_put_hcd(xhci->shared_hcd);
436 xhci->shared_hcd = NULL;
439 /* Workaround for spurious wakeups at shutdown with HSW */
440 if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
441 pci_set_power_state(dev, PCI_D3hot);
443 usb_hcd_pci_remove(dev);
448 * In some Intel xHCI controllers, in order to get D3 working,
449 * through a vendor specific SSIC CONFIG register at offset 0x883c,
450 * SSIC PORT need to be marked as "unused" before putting xHCI
451 * into D3. After D3 exit, the SSIC port need to be marked as "used".
452 * Without this change, xHCI might not enter D3 state.
454 static void xhci_ssic_port_unused_quirk(struct usb_hcd *hcd, bool suspend)
456 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
461 for (i = 0; i < SSIC_PORT_NUM; i++) {
462 reg = (void __iomem *) xhci->cap_regs +
464 i * SSIC_PORT_CFG2_OFFSET;
466 /* Notify SSIC that SSIC profile programming is not done. */
467 val = readl(reg) & ~PROG_DONE;
470 /* Mark SSIC port as unused(suspend) or used(resume) */
473 val |= SSIC_PORT_UNUSED;
475 val &= ~SSIC_PORT_UNUSED;
478 /* Notify SSIC that SSIC profile programming is done */
479 val = readl(reg) | PROG_DONE;
486 * Make sure PME works on some Intel xHCI controllers by writing 1 to clear
487 * the Internal PME flag bit in vendor specific PMCTRL register at offset 0x80a4
489 static void xhci_pme_quirk(struct usb_hcd *hcd)
491 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
495 reg = (void __iomem *) xhci->cap_regs + 0x80a4;
497 writel(val | BIT(28), reg);
501 static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
503 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
504 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
508 * Systems with the TI redriver that loses port status change events
509 * need to have the registers polled during D3, so avoid D3cold.
511 if (xhci->quirks & XHCI_COMP_MODE_QUIRK)
512 pci_d3cold_disable(pdev);
514 if (xhci->quirks & XHCI_PME_STUCK_QUIRK)
517 if (xhci->quirks & XHCI_SSIC_PORT_UNUSED)
518 xhci_ssic_port_unused_quirk(hcd, true);
520 ret = xhci_suspend(xhci, do_wakeup);
521 if (ret && (xhci->quirks & XHCI_SSIC_PORT_UNUSED))
522 xhci_ssic_port_unused_quirk(hcd, false);
527 static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
529 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
530 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
533 reset_control_reset(xhci->reset);
535 /* The BIOS on systems with the Intel Panther Point chipset may or may
536 * not support xHCI natively. That means that during system resume, it
537 * may switch the ports back to EHCI so that users can use their
538 * keyboard to select a kernel from GRUB after resume from hibernate.
540 * The BIOS is supposed to remember whether the OS had xHCI ports
541 * enabled before resume, and switch the ports back to xHCI when the
542 * BIOS/OS semaphore is written, but we all know we can't trust BIOS
545 * Unconditionally switch the ports back to xHCI after a system resume.
546 * It should not matter whether the EHCI or xHCI controller is
547 * resumed first. It's enough to do the switchover in xHCI because
548 * USB core won't notice anything as the hub driver doesn't start
549 * running again until after all the devices (including both EHCI and
550 * xHCI host controllers) have been resumed.
553 if (pdev->vendor == PCI_VENDOR_ID_INTEL)
554 usb_enable_intel_xhci_ports(pdev);
556 if (xhci->quirks & XHCI_SSIC_PORT_UNUSED)
557 xhci_ssic_port_unused_quirk(hcd, false);
559 if (xhci->quirks & XHCI_PME_STUCK_QUIRK)
562 retval = xhci_resume(xhci, hibernated);
566 static void xhci_pci_shutdown(struct usb_hcd *hcd)
568 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
569 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
573 /* Yet another workaround for spurious wakeups at shutdown with HSW */
574 if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
575 pci_set_power_state(pdev, PCI_D3hot);
577 #endif /* CONFIG_PM */
579 /*-------------------------------------------------------------------------*/
581 static const struct xhci_driver_data reneses_data = {
582 .quirks = XHCI_RENESAS_FW_QUIRK,
583 .firmware = "renesas_usb_fw.mem",
586 /* PCI driver selection metadata; PCI hotplugging uses this */
587 static const struct pci_device_id pci_ids[] = {
588 { PCI_DEVICE(0x1912, 0x0014),
589 .driver_data = (unsigned long)&reneses_data,
591 { PCI_DEVICE(0x1912, 0x0015),
592 .driver_data = (unsigned long)&reneses_data,
594 /* handle any USB 3.0 xHCI controller */
595 { PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_XHCI, ~0),
597 { /* end: all zeroes */ }
599 MODULE_DEVICE_TABLE(pci, pci_ids);
600 MODULE_FIRMWARE("renesas_usb_fw.mem");
602 /* pci driver glue; this is a "new style" PCI driver module */
603 static struct pci_driver xhci_pci_driver = {
607 .probe = xhci_pci_probe,
608 .remove = xhci_pci_remove,
609 /* suspend and resume implemented later */
611 .shutdown = usb_hcd_pci_shutdown,
614 .pm = &usb_hcd_pci_pm_ops
619 static int __init xhci_pci_init(void)
621 xhci_init_driver(&xhci_pci_hc_driver, &xhci_pci_overrides);
623 xhci_pci_hc_driver.pci_suspend = xhci_pci_suspend;
624 xhci_pci_hc_driver.pci_resume = xhci_pci_resume;
625 xhci_pci_hc_driver.shutdown = xhci_pci_shutdown;
627 return pci_register_driver(&xhci_pci_driver);
629 module_init(xhci_pci_init);
631 static void __exit xhci_pci_exit(void)
633 pci_unregister_driver(&xhci_pci_driver);
635 module_exit(xhci_pci_exit);
637 MODULE_DESCRIPTION("xHCI PCI Host Controller Driver");
638 MODULE_LICENSE("GPL");