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>
17 #include "xhci-trace.h"
19 #define SSIC_PORT_NUM 2
20 #define SSIC_PORT_CFG2 0x880c
21 #define SSIC_PORT_CFG2_OFFSET 0x30
22 #define PROG_DONE (1 << 30)
23 #define SSIC_PORT_UNUSED (1 << 31)
25 /* Device for a quirk */
26 #define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73
27 #define PCI_DEVICE_ID_FRESCO_LOGIC_PDK 0x1000
28 #define PCI_DEVICE_ID_FRESCO_LOGIC_FL1009 0x1009
29 #define PCI_DEVICE_ID_FRESCO_LOGIC_FL1400 0x1400
31 #define PCI_VENDOR_ID_ETRON 0x1b6f
32 #define PCI_DEVICE_ID_EJ168 0x7023
34 #define PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI 0x8c31
35 #define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31
36 #define PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_XHCI 0x9cb1
37 #define PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI 0x22b5
38 #define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI 0xa12f
39 #define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f
40 #define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8
41 #define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8
42 #define PCI_DEVICE_ID_INTEL_APL_XHCI 0x5aa8
43 #define PCI_DEVICE_ID_INTEL_DNV_XHCI 0x19d0
44 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_XHCI 0x15b5
45 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_4C_XHCI 0x15b6
46 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_2C_XHCI 0x15db
47 #define PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_4C_XHCI 0x15d4
48 #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_XHCI 0x15e9
49 #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_XHCI 0x15ec
50 #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_XHCI 0x15f0
51 #define PCI_DEVICE_ID_INTEL_ICE_LAKE_XHCI 0x8a13
52 #define PCI_DEVICE_ID_INTEL_CML_XHCI 0xa3af
54 #define PCI_DEVICE_ID_AMD_PROMONTORYA_4 0x43b9
55 #define PCI_DEVICE_ID_AMD_PROMONTORYA_3 0x43ba
56 #define PCI_DEVICE_ID_AMD_PROMONTORYA_2 0x43bb
57 #define PCI_DEVICE_ID_AMD_PROMONTORYA_1 0x43bc
58 #define PCI_DEVICE_ID_ASMEDIA_1042_XHCI 0x1042
59 #define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI 0x1142
60 #define PCI_DEVICE_ID_ASMEDIA_1142_XHCI 0x1242
61 #define PCI_DEVICE_ID_ASMEDIA_2142_XHCI 0x2142
63 static const char hcd_name
[] = "xhci_hcd";
65 static struct hc_driver __read_mostly xhci_pci_hc_driver
;
67 static int xhci_pci_setup(struct usb_hcd
*hcd
);
69 static const struct xhci_driver_overrides xhci_pci_overrides __initconst
= {
70 .reset
= xhci_pci_setup
,
73 /* called after powerup, by probe or system-pm "wakeup" */
74 static int xhci_pci_reinit(struct xhci_hcd
*xhci
, struct pci_dev
*pdev
)
77 * TODO: Implement finding debug ports later.
78 * TODO: see if there are any quirks that need to be added to handle
79 * new extended capabilities.
82 /* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */
83 if (!pci_set_mwi(pdev
))
84 xhci_dbg(xhci
, "MWI active\n");
86 xhci_dbg(xhci
, "Finished xhci_pci_reinit\n");
90 static void xhci_pci_quirks(struct device
*dev
, struct xhci_hcd
*xhci
)
92 struct pci_dev
*pdev
= to_pci_dev(dev
);
94 /* Look for vendor-specific quirks */
95 if (pdev
->vendor
== PCI_VENDOR_ID_FRESCO_LOGIC
&&
96 (pdev
->device
== PCI_DEVICE_ID_FRESCO_LOGIC_PDK
||
97 pdev
->device
== PCI_DEVICE_ID_FRESCO_LOGIC_FL1400
)) {
98 if (pdev
->device
== PCI_DEVICE_ID_FRESCO_LOGIC_PDK
&&
99 pdev
->revision
== 0x0) {
100 xhci
->quirks
|= XHCI_RESET_EP_QUIRK
;
101 xhci_dbg_trace(xhci
, trace_xhci_dbg_quirks
,
102 "QUIRK: Fresco Logic xHC needs configure"
103 " endpoint cmd after reset endpoint");
105 if (pdev
->device
== PCI_DEVICE_ID_FRESCO_LOGIC_PDK
&&
106 pdev
->revision
== 0x4) {
107 xhci
->quirks
|= XHCI_SLOW_SUSPEND
;
108 xhci_dbg_trace(xhci
, trace_xhci_dbg_quirks
,
109 "QUIRK: Fresco Logic xHC revision %u"
110 "must be suspended extra slowly",
113 if (pdev
->device
== PCI_DEVICE_ID_FRESCO_LOGIC_PDK
)
114 xhci
->quirks
|= XHCI_BROKEN_STREAMS
;
115 /* Fresco Logic confirms: all revisions of this chip do not
116 * support MSI, even though some of them claim to in their PCI
119 xhci
->quirks
|= XHCI_BROKEN_MSI
;
120 xhci_dbg_trace(xhci
, trace_xhci_dbg_quirks
,
121 "QUIRK: Fresco Logic revision %u "
122 "has broken MSI implementation",
124 xhci
->quirks
|= XHCI_TRUST_TX_LENGTH
;
127 if (pdev
->vendor
== PCI_VENDOR_ID_FRESCO_LOGIC
&&
128 pdev
->device
== PCI_DEVICE_ID_FRESCO_LOGIC_FL1009
)
129 xhci
->quirks
|= XHCI_BROKEN_STREAMS
;
131 if (pdev
->vendor
== PCI_VENDOR_ID_NEC
)
132 xhci
->quirks
|= XHCI_NEC_HOST
;
134 if (pdev
->vendor
== PCI_VENDOR_ID_AMD
&& xhci
->hci_version
== 0x96)
135 xhci
->quirks
|= XHCI_AMD_0x96_HOST
;
138 if (pdev
->vendor
== PCI_VENDOR_ID_AMD
&& usb_amd_quirk_pll_check())
139 xhci
->quirks
|= XHCI_AMD_PLL_FIX
;
141 if (pdev
->vendor
== PCI_VENDOR_ID_AMD
&&
142 (pdev
->device
== 0x145c ||
143 pdev
->device
== 0x15e0 ||
144 pdev
->device
== 0x15e1 ||
145 pdev
->device
== 0x43bb))
146 xhci
->quirks
|= XHCI_SUSPEND_DELAY
;
148 if (pdev
->vendor
== PCI_VENDOR_ID_AMD
&&
149 (pdev
->device
== 0x15e0 || pdev
->device
== 0x15e1))
150 xhci
->quirks
|= XHCI_SNPS_BROKEN_SUSPEND
;
152 if (pdev
->vendor
== PCI_VENDOR_ID_AMD
)
153 xhci
->quirks
|= XHCI_TRUST_TX_LENGTH
;
155 if ((pdev
->vendor
== PCI_VENDOR_ID_AMD
) &&
156 ((pdev
->device
== PCI_DEVICE_ID_AMD_PROMONTORYA_4
) ||
157 (pdev
->device
== PCI_DEVICE_ID_AMD_PROMONTORYA_3
) ||
158 (pdev
->device
== PCI_DEVICE_ID_AMD_PROMONTORYA_2
) ||
159 (pdev
->device
== PCI_DEVICE_ID_AMD_PROMONTORYA_1
)))
160 xhci
->quirks
|= XHCI_U2_DISABLE_WAKE
;
162 if (pdev
->vendor
== PCI_VENDOR_ID_INTEL
) {
163 xhci
->quirks
|= XHCI_LPM_SUPPORT
;
164 xhci
->quirks
|= XHCI_INTEL_HOST
;
165 xhci
->quirks
|= XHCI_AVOID_BEI
;
167 if (pdev
->vendor
== PCI_VENDOR_ID_INTEL
&&
168 pdev
->device
== PCI_DEVICE_ID_INTEL_PANTHERPOINT_XHCI
) {
169 xhci
->quirks
|= XHCI_EP_LIMIT_QUIRK
;
170 xhci
->limit_active_eps
= 64;
171 xhci
->quirks
|= XHCI_SW_BW_CHECKING
;
173 * PPT desktop boards DH77EB and DH77DF will power back on after
174 * a few seconds of being shutdown. The fix for this is to
175 * switch the ports from xHCI to EHCI on shutdown. We can't use
176 * DMI information to find those particular boards (since each
177 * vendor will change the board name), so we have to key off all
180 xhci
->quirks
|= XHCI_SPURIOUS_REBOOT
;
182 if (pdev
->vendor
== PCI_VENDOR_ID_INTEL
&&
183 (pdev
->device
== PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI
||
184 pdev
->device
== PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_XHCI
)) {
185 xhci
->quirks
|= XHCI_SPURIOUS_REBOOT
;
186 xhci
->quirks
|= XHCI_SPURIOUS_WAKEUP
;
188 if (pdev
->vendor
== PCI_VENDOR_ID_INTEL
&&
189 (pdev
->device
== PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI
||
190 pdev
->device
== PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI
||
191 pdev
->device
== PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI
||
192 pdev
->device
== PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI
||
193 pdev
->device
== PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI
||
194 pdev
->device
== PCI_DEVICE_ID_INTEL_APL_XHCI
||
195 pdev
->device
== PCI_DEVICE_ID_INTEL_DNV_XHCI
||
196 pdev
->device
== PCI_DEVICE_ID_INTEL_CML_XHCI
)) {
197 xhci
->quirks
|= XHCI_PME_STUCK_QUIRK
;
199 if (pdev
->vendor
== PCI_VENDOR_ID_INTEL
&&
200 pdev
->device
== PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI
)
201 xhci
->quirks
|= XHCI_SSIC_PORT_UNUSED
;
202 if (pdev
->vendor
== PCI_VENDOR_ID_INTEL
&&
203 (pdev
->device
== PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI
||
204 pdev
->device
== PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI
||
205 pdev
->device
== PCI_DEVICE_ID_INTEL_APL_XHCI
))
206 xhci
->quirks
|= XHCI_INTEL_USB_ROLE_SW
;
207 if (pdev
->vendor
== PCI_VENDOR_ID_INTEL
&&
208 (pdev
->device
== PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI
||
209 pdev
->device
== PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI
||
210 pdev
->device
== PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI
||
211 pdev
->device
== PCI_DEVICE_ID_INTEL_APL_XHCI
||
212 pdev
->device
== PCI_DEVICE_ID_INTEL_DNV_XHCI
))
213 xhci
->quirks
|= XHCI_MISSING_CAS
;
215 if (pdev
->vendor
== PCI_VENDOR_ID_INTEL
&&
216 (pdev
->device
== PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_2C_XHCI
||
217 pdev
->device
== PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_4C_XHCI
||
218 pdev
->device
== PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_2C_XHCI
||
219 pdev
->device
== PCI_DEVICE_ID_INTEL_ALPINE_RIDGE_C_4C_XHCI
||
220 pdev
->device
== PCI_DEVICE_ID_INTEL_TITAN_RIDGE_2C_XHCI
||
221 pdev
->device
== PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_XHCI
||
222 pdev
->device
== PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_XHCI
||
223 pdev
->device
== PCI_DEVICE_ID_INTEL_ICE_LAKE_XHCI
))
224 xhci
->quirks
|= XHCI_DEFAULT_PM_RUNTIME_ALLOW
;
226 if (pdev
->vendor
== PCI_VENDOR_ID_ETRON
&&
227 pdev
->device
== PCI_DEVICE_ID_EJ168
) {
228 xhci
->quirks
|= XHCI_RESET_ON_RESUME
;
229 xhci
->quirks
|= XHCI_TRUST_TX_LENGTH
;
230 xhci
->quirks
|= XHCI_BROKEN_STREAMS
;
232 if (pdev
->vendor
== PCI_VENDOR_ID_RENESAS
&&
233 pdev
->device
== 0x0014) {
234 xhci
->quirks
|= XHCI_TRUST_TX_LENGTH
;
235 xhci
->quirks
|= XHCI_ZERO_64B_REGS
;
237 if (pdev
->vendor
== PCI_VENDOR_ID_RENESAS
&&
238 pdev
->device
== 0x0015) {
239 xhci
->quirks
|= XHCI_RESET_ON_RESUME
;
240 xhci
->quirks
|= XHCI_ZERO_64B_REGS
;
242 if (pdev
->vendor
== PCI_VENDOR_ID_VIA
)
243 xhci
->quirks
|= XHCI_RESET_ON_RESUME
;
245 /* See https://bugzilla.kernel.org/show_bug.cgi?id=79511 */
246 if (pdev
->vendor
== PCI_VENDOR_ID_VIA
&&
247 pdev
->device
== 0x3432)
248 xhci
->quirks
|= XHCI_BROKEN_STREAMS
;
250 if (pdev
->vendor
== PCI_VENDOR_ID_ASMEDIA
&&
251 pdev
->device
== PCI_DEVICE_ID_ASMEDIA_1042_XHCI
)
252 xhci
->quirks
|= XHCI_BROKEN_STREAMS
;
253 if (pdev
->vendor
== PCI_VENDOR_ID_ASMEDIA
&&
254 pdev
->device
== PCI_DEVICE_ID_ASMEDIA_1042A_XHCI
)
255 xhci
->quirks
|= XHCI_TRUST_TX_LENGTH
;
256 if (pdev
->vendor
== PCI_VENDOR_ID_ASMEDIA
&&
257 (pdev
->device
== PCI_DEVICE_ID_ASMEDIA_1142_XHCI
||
258 pdev
->device
== PCI_DEVICE_ID_ASMEDIA_2142_XHCI
))
259 xhci
->quirks
|= XHCI_NO_64BIT_SUPPORT
;
261 if (pdev
->vendor
== PCI_VENDOR_ID_ASMEDIA
&&
262 pdev
->device
== PCI_DEVICE_ID_ASMEDIA_1042A_XHCI
)
263 xhci
->quirks
|= XHCI_ASMEDIA_MODIFY_FLOWCONTROL
;
265 if (pdev
->vendor
== PCI_VENDOR_ID_TI
&& pdev
->device
== 0x8241)
266 xhci
->quirks
|= XHCI_LIMIT_ENDPOINT_INTERVAL_7
;
268 if ((pdev
->vendor
== PCI_VENDOR_ID_BROADCOM
||
269 pdev
->vendor
== PCI_VENDOR_ID_CAVIUM
) &&
270 pdev
->device
== 0x9026)
271 xhci
->quirks
|= XHCI_RESET_PLL_ON_DISCONNECT
;
273 if (xhci
->quirks
& XHCI_RESET_ON_RESUME
)
274 xhci_dbg_trace(xhci
, trace_xhci_dbg_quirks
,
275 "QUIRK: Resetting on resume");
279 static void xhci_pme_acpi_rtd3_enable(struct pci_dev
*dev
)
281 static const guid_t intel_dsm_guid
=
282 GUID_INIT(0xac340cb7, 0xe901, 0x45bf,
283 0xb7, 0xe6, 0x2b, 0x34, 0xec, 0x93, 0x1e, 0x23);
284 union acpi_object
*obj
;
286 obj
= acpi_evaluate_dsm(ACPI_HANDLE(&dev
->dev
), &intel_dsm_guid
, 3, 1,
291 static void xhci_pme_acpi_rtd3_enable(struct pci_dev
*dev
) { }
292 #endif /* CONFIG_ACPI */
294 /* called during probe() after chip reset completes */
295 static int xhci_pci_setup(struct usb_hcd
*hcd
)
297 struct xhci_hcd
*xhci
;
298 struct pci_dev
*pdev
= to_pci_dev(hcd
->self
.controller
);
301 xhci
= hcd_to_xhci(hcd
);
303 pci_read_config_byte(pdev
, XHCI_SBRN_OFFSET
, &xhci
->sbrn
);
305 /* imod_interval is the interrupt moderation value in nanoseconds. */
306 xhci
->imod_interval
= 40000;
308 retval
= xhci_gen_setup(hcd
, xhci_pci_quirks
);
312 if (!usb_hcd_is_primary_hcd(hcd
))
315 if (xhci
->quirks
& XHCI_PME_STUCK_QUIRK
)
316 xhci_pme_acpi_rtd3_enable(pdev
);
318 xhci_dbg(xhci
, "Got SBRN %u\n", (unsigned int) xhci
->sbrn
);
320 /* Find any debug ports */
321 return xhci_pci_reinit(xhci
, pdev
);
325 * We need to register our own PCI probe function (instead of the USB core's
326 * function) in order to create a second roothub under xHCI.
328 static int xhci_pci_probe(struct pci_dev
*dev
, const struct pci_device_id
*id
)
331 struct xhci_hcd
*xhci
;
332 struct hc_driver
*driver
;
335 driver
= (struct hc_driver
*)id
->driver_data
;
337 /* Prevent runtime suspending between USB-2 and USB-3 initialization */
338 pm_runtime_get_noresume(&dev
->dev
);
340 /* Register the USB 2.0 roothub.
341 * FIXME: USB core must know to register the USB 2.0 roothub first.
342 * This is sort of silly, because we could just set the HCD driver flags
343 * to say USB 2.0, but I'm not sure what the implications would be in
344 * the other parts of the HCD code.
346 retval
= usb_hcd_pci_probe(dev
, id
);
351 /* USB 2.0 roothub is stored in the PCI device now. */
352 hcd
= dev_get_drvdata(&dev
->dev
);
353 xhci
= hcd_to_xhci(hcd
);
354 xhci
->shared_hcd
= usb_create_shared_hcd(driver
, &dev
->dev
,
356 if (!xhci
->shared_hcd
) {
358 goto dealloc_usb2_hcd
;
361 retval
= xhci_ext_cap_init(xhci
);
365 retval
= usb_add_hcd(xhci
->shared_hcd
, dev
->irq
,
369 /* Roothub already marked as USB 3.0 speed */
371 if (!(xhci
->quirks
& XHCI_BROKEN_STREAMS
) &&
372 HCC_MAX_PSA(xhci
->hcc_params
) >= 4)
373 xhci
->shared_hcd
->can_do_streams
= 1;
375 /* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */
376 pm_runtime_put_noidle(&dev
->dev
);
378 if (xhci
->quirks
& XHCI_DEFAULT_PM_RUNTIME_ALLOW
)
379 pm_runtime_allow(&dev
->dev
);
384 usb_put_hcd(xhci
->shared_hcd
);
386 usb_hcd_pci_remove(dev
);
388 pm_runtime_put_noidle(&dev
->dev
);
392 static void xhci_pci_remove(struct pci_dev
*dev
)
394 struct xhci_hcd
*xhci
;
396 xhci
= hcd_to_xhci(pci_get_drvdata(dev
));
397 xhci
->xhc_state
|= XHCI_STATE_REMOVING
;
399 if (xhci
->quirks
& XHCI_DEFAULT_PM_RUNTIME_ALLOW
)
400 pm_runtime_forbid(&dev
->dev
);
402 if (xhci
->shared_hcd
) {
403 usb_remove_hcd(xhci
->shared_hcd
);
404 usb_put_hcd(xhci
->shared_hcd
);
405 xhci
->shared_hcd
= NULL
;
408 /* Workaround for spurious wakeups at shutdown with HSW */
409 if (xhci
->quirks
& XHCI_SPURIOUS_WAKEUP
)
410 pci_set_power_state(dev
, PCI_D3hot
);
412 usb_hcd_pci_remove(dev
);
417 * In some Intel xHCI controllers, in order to get D3 working,
418 * through a vendor specific SSIC CONFIG register at offset 0x883c,
419 * SSIC PORT need to be marked as "unused" before putting xHCI
420 * into D3. After D3 exit, the SSIC port need to be marked as "used".
421 * Without this change, xHCI might not enter D3 state.
423 static void xhci_ssic_port_unused_quirk(struct usb_hcd
*hcd
, bool suspend
)
425 struct xhci_hcd
*xhci
= hcd_to_xhci(hcd
);
430 for (i
= 0; i
< SSIC_PORT_NUM
; i
++) {
431 reg
= (void __iomem
*) xhci
->cap_regs
+
433 i
* SSIC_PORT_CFG2_OFFSET
;
435 /* Notify SSIC that SSIC profile programming is not done. */
436 val
= readl(reg
) & ~PROG_DONE
;
439 /* Mark SSIC port as unused(suspend) or used(resume) */
442 val
|= SSIC_PORT_UNUSED
;
444 val
&= ~SSIC_PORT_UNUSED
;
447 /* Notify SSIC that SSIC profile programming is done */
448 val
= readl(reg
) | PROG_DONE
;
455 * Make sure PME works on some Intel xHCI controllers by writing 1 to clear
456 * the Internal PME flag bit in vendor specific PMCTRL register at offset 0x80a4
458 static void xhci_pme_quirk(struct usb_hcd
*hcd
)
460 struct xhci_hcd
*xhci
= hcd_to_xhci(hcd
);
464 reg
= (void __iomem
*) xhci
->cap_regs
+ 0x80a4;
466 writel(val
| BIT(28), reg
);
470 static int xhci_pci_suspend(struct usb_hcd
*hcd
, bool do_wakeup
)
472 struct xhci_hcd
*xhci
= hcd_to_xhci(hcd
);
473 struct pci_dev
*pdev
= to_pci_dev(hcd
->self
.controller
);
477 * Systems with the TI redriver that loses port status change events
478 * need to have the registers polled during D3, so avoid D3cold.
480 if (xhci
->quirks
& XHCI_COMP_MODE_QUIRK
)
481 pci_d3cold_disable(pdev
);
483 if (xhci
->quirks
& XHCI_PME_STUCK_QUIRK
)
486 if (xhci
->quirks
& XHCI_SSIC_PORT_UNUSED
)
487 xhci_ssic_port_unused_quirk(hcd
, true);
489 ret
= xhci_suspend(xhci
, do_wakeup
);
490 if (ret
&& (xhci
->quirks
& XHCI_SSIC_PORT_UNUSED
))
491 xhci_ssic_port_unused_quirk(hcd
, false);
496 static int xhci_pci_resume(struct usb_hcd
*hcd
, bool hibernated
)
498 struct xhci_hcd
*xhci
= hcd_to_xhci(hcd
);
499 struct pci_dev
*pdev
= to_pci_dev(hcd
->self
.controller
);
502 /* The BIOS on systems with the Intel Panther Point chipset may or may
503 * not support xHCI natively. That means that during system resume, it
504 * may switch the ports back to EHCI so that users can use their
505 * keyboard to select a kernel from GRUB after resume from hibernate.
507 * The BIOS is supposed to remember whether the OS had xHCI ports
508 * enabled before resume, and switch the ports back to xHCI when the
509 * BIOS/OS semaphore is written, but we all know we can't trust BIOS
512 * Unconditionally switch the ports back to xHCI after a system resume.
513 * It should not matter whether the EHCI or xHCI controller is
514 * resumed first. It's enough to do the switchover in xHCI because
515 * USB core won't notice anything as the hub driver doesn't start
516 * running again until after all the devices (including both EHCI and
517 * xHCI host controllers) have been resumed.
520 if (pdev
->vendor
== PCI_VENDOR_ID_INTEL
)
521 usb_enable_intel_xhci_ports(pdev
);
523 if (xhci
->quirks
& XHCI_SSIC_PORT_UNUSED
)
524 xhci_ssic_port_unused_quirk(hcd
, false);
526 if (xhci
->quirks
& XHCI_PME_STUCK_QUIRK
)
529 retval
= xhci_resume(xhci
, hibernated
);
533 static void xhci_pci_shutdown(struct usb_hcd
*hcd
)
535 struct xhci_hcd
*xhci
= hcd_to_xhci(hcd
);
536 struct pci_dev
*pdev
= to_pci_dev(hcd
->self
.controller
);
540 /* Yet another workaround for spurious wakeups at shutdown with HSW */
541 if (xhci
->quirks
& XHCI_SPURIOUS_WAKEUP
)
542 pci_set_power_state(pdev
, PCI_D3hot
);
544 #endif /* CONFIG_PM */
546 /*-------------------------------------------------------------------------*/
548 /* PCI driver selection metadata; PCI hotplugging uses this */
549 static const struct pci_device_id pci_ids
[] = { {
550 /* handle any USB 3.0 xHCI controller */
551 PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_XHCI
, ~0),
552 .driver_data
= (unsigned long) &xhci_pci_hc_driver
,
554 { /* end: all zeroes */ }
556 MODULE_DEVICE_TABLE(pci
, pci_ids
);
558 /* pci driver glue; this is a "new style" PCI driver module */
559 static struct pci_driver xhci_pci_driver
= {
560 .name
= (char *) hcd_name
,
563 .probe
= xhci_pci_probe
,
564 .remove
= xhci_pci_remove
,
565 /* suspend and resume implemented later */
567 .shutdown
= usb_hcd_pci_shutdown
,
570 .pm
= &usb_hcd_pci_pm_ops
575 static int __init
xhci_pci_init(void)
577 xhci_init_driver(&xhci_pci_hc_driver
, &xhci_pci_overrides
);
579 xhci_pci_hc_driver
.pci_suspend
= xhci_pci_suspend
;
580 xhci_pci_hc_driver
.pci_resume
= xhci_pci_resume
;
581 xhci_pci_hc_driver
.shutdown
= xhci_pci_shutdown
;
583 return pci_register_driver(&xhci_pci_driver
);
585 module_init(xhci_pci_init
);
587 static void __exit
xhci_pci_exit(void)
589 pci_unregister_driver(&xhci_pci_driver
);
591 module_exit(xhci_pci_exit
);
593 MODULE_DESCRIPTION("xHCI PCI Host Controller Driver");
594 MODULE_LICENSE("GPL");