blob: 72c3ba0824f703d7377a4f4329e353b10f08d92d [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/*
2 * xHCI host controller driver PCI Bus Glue.
3 *
4 * Copyright (C) 2008 Intel Corp.
5 *
6 * Author: Sarah Sharp
7 * Some code borrowed from the Linux EHCI driver.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include <linux/pci.h>
24#include <linux/slab.h>
25#include <linux/module.h>
26#include <linux/acpi.h>
27
28#include "xhci.h"
29#include "xhci-trace.h"
30
31#define SSIC_PORT_NUM 2
32#define SSIC_PORT_CFG2 0x880c
33#define SSIC_PORT_CFG2_OFFSET 0x30
34#define PROG_DONE (1 << 30)
35#define SSIC_PORT_UNUSED (1 << 31)
36
37/* Device for a quirk */
38#define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73
39#define PCI_DEVICE_ID_FRESCO_LOGIC_PDK 0x1000
40#define PCI_DEVICE_ID_FRESCO_LOGIC_FL1009 0x1009
41#define PCI_DEVICE_ID_FRESCO_LOGIC_FL1400 0x1400
42
43#define PCI_VENDOR_ID_ETRON 0x1b6f
44#define PCI_DEVICE_ID_EJ168 0x7023
45
46#define PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI 0x8c31
47#define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31
48#define PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_XHCI 0x9cb1
49#define PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI 0x22b5
50#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI 0xa12f
51#define PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI 0x9d2f
52#define PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI 0x0aa8
53#define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8
54#define PCI_DEVICE_ID_INTEL_APL_XHCI 0x5aa8
55#define PCI_DEVICE_ID_INTEL_DNV_XHCI 0x19d0
56#define PCI_DEVICE_ID_INTEL_CML_XHCI 0xa3af
57
58#define PCI_DEVICE_ID_AMD_PROMONTORYA_4 0x43b9
59#define PCI_DEVICE_ID_AMD_PROMONTORYA_3 0x43ba
60#define PCI_DEVICE_ID_AMD_PROMONTORYA_2 0x43bb
61#define PCI_DEVICE_ID_AMD_PROMONTORYA_1 0x43bc
62#define PCI_DEVICE_ID_ASMEDIA_1042_XHCI 0x1042
63#define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI 0x1142
64#define PCI_DEVICE_ID_ASMEDIA_1142_XHCI 0x1242
65#define PCI_DEVICE_ID_ASMEDIA_2142_XHCI 0x2142
66
67static const char hcd_name[] = "xhci_hcd";
68
69static struct hc_driver __read_mostly xhci_pci_hc_driver;
70
71static int xhci_pci_setup(struct usb_hcd *hcd);
72
73static const struct xhci_driver_overrides xhci_pci_overrides __initconst = {
74 .reset = xhci_pci_setup,
75};
76
77/* called after powerup, by probe or system-pm "wakeup" */
78static int xhci_pci_reinit(struct xhci_hcd *xhci, struct pci_dev *pdev)
79{
80 /*
81 * TODO: Implement finding debug ports later.
82 * TODO: see if there are any quirks that need to be added to handle
83 * new extended capabilities.
84 */
85
86 /* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */
87 if (!pci_set_mwi(pdev))
88 xhci_dbg(xhci, "MWI active\n");
89
90 xhci_dbg(xhci, "Finished xhci_pci_reinit\n");
91 return 0;
92}
93
94static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
95{
96 struct pci_dev *pdev = to_pci_dev(dev);
97
98 /* Look for vendor-specific quirks */
99 if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC &&
100 (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK ||
101 pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_FL1400)) {
102 if (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK &&
103 pdev->revision == 0x0) {
104 xhci->quirks |= XHCI_RESET_EP_QUIRK;
105 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
106 "QUIRK: Fresco Logic xHC needs configure"
107 " endpoint cmd after reset endpoint");
108 }
109 if (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK &&
110 pdev->revision == 0x4) {
111 xhci->quirks |= XHCI_SLOW_SUSPEND;
112 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
113 "QUIRK: Fresco Logic xHC revision %u"
114 "must be suspended extra slowly",
115 pdev->revision);
116 }
117 if (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK)
118 xhci->quirks |= XHCI_BROKEN_STREAMS;
119 /* Fresco Logic confirms: all revisions of this chip do not
120 * support MSI, even though some of them claim to in their PCI
121 * capabilities.
122 */
123 xhci->quirks |= XHCI_BROKEN_MSI;
124 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
125 "QUIRK: Fresco Logic revision %u "
126 "has broken MSI implementation",
127 pdev->revision);
128 xhci->quirks |= XHCI_TRUST_TX_LENGTH;
129 }
130
131 if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC &&
132 pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_FL1009)
133 xhci->quirks |= XHCI_BROKEN_STREAMS;
134
135 if (pdev->vendor == PCI_VENDOR_ID_NEC)
136 xhci->quirks |= XHCI_NEC_HOST;
137
138 if (pdev->vendor == PCI_VENDOR_ID_AMD && xhci->hci_version == 0x96)
139 xhci->quirks |= XHCI_AMD_0x96_HOST;
140
141 /* AMD PLL quirk */
142 if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info())
143 xhci->quirks |= XHCI_AMD_PLL_FIX;
144
145 if (pdev->vendor == PCI_VENDOR_ID_AMD &&
146 (pdev->device == 0x145c ||
147 pdev->device == 0x15e0 ||
148 pdev->device == 0x15e1 ||
149 pdev->device == 0x43bb))
150 xhci->quirks |= XHCI_SUSPEND_DELAY;
151
152 if (pdev->vendor == PCI_VENDOR_ID_AMD &&
153 (pdev->device == 0x15e0 || pdev->device == 0x15e1))
154 xhci->quirks |= XHCI_SNPS_BROKEN_SUSPEND;
155
156 if (pdev->vendor == PCI_VENDOR_ID_AMD)
157 xhci->quirks |= XHCI_TRUST_TX_LENGTH;
158
159 if ((pdev->vendor == PCI_VENDOR_ID_AMD) &&
160 ((pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_4) ||
161 (pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_3) ||
162 (pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_2) ||
163 (pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_1)))
164 xhci->quirks |= XHCI_U2_DISABLE_WAKE;
165
166 if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
167 xhci->quirks |= XHCI_LPM_SUPPORT;
168 xhci->quirks |= XHCI_INTEL_HOST;
169 xhci->quirks |= XHCI_AVOID_BEI;
170 }
171 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
172 pdev->device == PCI_DEVICE_ID_INTEL_PANTHERPOINT_XHCI) {
173 xhci->quirks |= XHCI_EP_LIMIT_QUIRK;
174 xhci->limit_active_eps = 64;
175 xhci->quirks |= XHCI_SW_BW_CHECKING;
176 /*
177 * PPT desktop boards DH77EB and DH77DF will power back on after
178 * a few seconds of being shutdown. The fix for this is to
179 * switch the ports from xHCI to EHCI on shutdown. We can't use
180 * DMI information to find those particular boards (since each
181 * vendor will change the board name), so we have to key off all
182 * PPT chipsets.
183 */
184 xhci->quirks |= XHCI_SPURIOUS_REBOOT;
185 }
186 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
187 (pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI ||
188 pdev->device == PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_XHCI)) {
189 xhci->quirks |= XHCI_SPURIOUS_REBOOT;
190 xhci->quirks |= XHCI_SPURIOUS_WAKEUP;
191 }
192 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
193 (pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_XHCI ||
194 pdev->device == PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_XHCI ||
195 pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI ||
196 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI ||
197 pdev->device == PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI ||
198 pdev->device == PCI_DEVICE_ID_INTEL_APL_XHCI ||
199 pdev->device == PCI_DEVICE_ID_INTEL_DNV_XHCI ||
200 pdev->device == PCI_DEVICE_ID_INTEL_CML_XHCI)) {
201 xhci->quirks |= XHCI_PME_STUCK_QUIRK;
202 }
203 if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
204 pdev->device == PCI_DEVICE_ID_INTEL_CHERRYVIEW_XHCI) {
205 xhci->quirks |= XHCI_SSIC_PORT_UNUSED;
206 }
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;
214
215 if (pdev->vendor == PCI_VENDOR_ID_ETRON &&
216 pdev->device == PCI_DEVICE_ID_EJ168) {
217 xhci->quirks |= XHCI_RESET_ON_RESUME;
218 xhci->quirks |= XHCI_TRUST_TX_LENGTH;
219 xhci->quirks |= XHCI_BROKEN_STREAMS;
220 }
221 if (pdev->vendor == PCI_VENDOR_ID_RENESAS &&
222 pdev->device == 0x0014)
223 xhci->quirks |= XHCI_TRUST_TX_LENGTH;
224 if (pdev->vendor == PCI_VENDOR_ID_RENESAS &&
225 pdev->device == 0x0015)
226 xhci->quirks |= XHCI_RESET_ON_RESUME;
227 if (pdev->vendor == PCI_VENDOR_ID_VIA)
228 xhci->quirks |= XHCI_RESET_ON_RESUME;
229
230 /* See https://bugzilla.kernel.org/show_bug.cgi?id=79511 */
231 if (pdev->vendor == PCI_VENDOR_ID_VIA &&
232 pdev->device == 0x3432)
233 xhci->quirks |= XHCI_BROKEN_STREAMS;
234
235 if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
236 pdev->device == PCI_DEVICE_ID_ASMEDIA_1042_XHCI)
237 xhci->quirks |= XHCI_BROKEN_STREAMS;
238 if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
239 pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI)
240 xhci->quirks |= XHCI_TRUST_TX_LENGTH;
241 if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
242 (pdev->device == PCI_DEVICE_ID_ASMEDIA_1142_XHCI ||
243 pdev->device == PCI_DEVICE_ID_ASMEDIA_2142_XHCI))
244 xhci->quirks |= XHCI_NO_64BIT_SUPPORT;
245
246 if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA &&
247 pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI)
248 xhci->quirks |= XHCI_ASMEDIA_MODIFY_FLOWCONTROL;
249
250 if (pdev->vendor == PCI_VENDOR_ID_TI && pdev->device == 0x8241)
251 xhci->quirks |= XHCI_LIMIT_ENDPOINT_INTERVAL_7;
252
253 if ((pdev->vendor == PCI_VENDOR_ID_BROADCOM ||
254 pdev->vendor == PCI_VENDOR_ID_CAVIUM) &&
255 pdev->device == 0x9026)
256 xhci->quirks |= XHCI_RESET_PLL_ON_DISCONNECT;
257
258 if (xhci->quirks & XHCI_RESET_ON_RESUME)
259 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
260 "QUIRK: Resetting on resume");
261}
262
263#ifdef CONFIG_ACPI
264static void xhci_pme_acpi_rtd3_enable(struct pci_dev *dev)
265{
266 static const guid_t intel_dsm_guid =
267 GUID_INIT(0xac340cb7, 0xe901, 0x45bf,
268 0xb7, 0xe6, 0x2b, 0x34, 0xec, 0x93, 0x1e, 0x23);
269 union acpi_object *obj;
270
271 obj = acpi_evaluate_dsm(ACPI_HANDLE(&dev->dev), &intel_dsm_guid, 3, 1,
272 NULL);
273 ACPI_FREE(obj);
274}
275#else
276static void xhci_pme_acpi_rtd3_enable(struct pci_dev *dev) { }
277#endif /* CONFIG_ACPI */
278
279/* called during probe() after chip reset completes */
280static int xhci_pci_setup(struct usb_hcd *hcd)
281{
282 struct xhci_hcd *xhci;
283 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
284 int retval;
285
286 xhci = hcd_to_xhci(hcd);
287 if (!xhci->sbrn)
288 pci_read_config_byte(pdev, XHCI_SBRN_OFFSET, &xhci->sbrn);
289
290 retval = xhci_gen_setup(hcd, xhci_pci_quirks);
291 if (retval)
292 return retval;
293
294 if (!usb_hcd_is_primary_hcd(hcd))
295 return 0;
296
297 if (xhci->quirks & XHCI_PME_STUCK_QUIRK)
298 xhci_pme_acpi_rtd3_enable(pdev);
299
300 xhci_dbg(xhci, "Got SBRN %u\n", (unsigned int) xhci->sbrn);
301
302 /* Find any debug ports */
303 return xhci_pci_reinit(xhci, pdev);
304}
305
306/*
307 * We need to register our own PCI probe function (instead of the USB core's
308 * function) in order to create a second roothub under xHCI.
309 */
310static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
311{
312 int retval;
313 struct xhci_hcd *xhci;
314 struct hc_driver *driver;
315 struct usb_hcd *hcd;
316
317 driver = (struct hc_driver *)id->driver_data;
318
319 /* For some HW implementation, a XHCI reset is just not enough... */
320 if (usb_xhci_needs_pci_reset(dev)) {
321 dev_info(&dev->dev, "Resetting\n");
322 if (pci_reset_function_locked(dev))
323 dev_warn(&dev->dev, "Reset failed");
324 }
325
326 /* Prevent runtime suspending between USB-2 and USB-3 initialization */
327 pm_runtime_get_noresume(&dev->dev);
328
329 /* Register the USB 2.0 roothub.
330 * FIXME: USB core must know to register the USB 2.0 roothub first.
331 * This is sort of silly, because we could just set the HCD driver flags
332 * to say USB 2.0, but I'm not sure what the implications would be in
333 * the other parts of the HCD code.
334 */
335 retval = usb_hcd_pci_probe(dev, id);
336
337 if (retval)
338 goto put_runtime_pm;
339
340 /* USB 2.0 roothub is stored in the PCI device now. */
341 hcd = dev_get_drvdata(&dev->dev);
342 xhci = hcd_to_xhci(hcd);
343 xhci->shared_hcd = usb_create_shared_hcd(driver, &dev->dev,
344 pci_name(dev), hcd);
345 if (!xhci->shared_hcd) {
346 retval = -ENOMEM;
347 goto dealloc_usb2_hcd;
348 }
349
350 retval = usb_add_hcd(xhci->shared_hcd, dev->irq,
351 IRQF_SHARED);
352 if (retval)
353 goto put_usb3_hcd;
354 /* Roothub already marked as USB 3.0 speed */
355
356 if (!(xhci->quirks & XHCI_BROKEN_STREAMS) &&
357 HCC_MAX_PSA(xhci->hcc_params) >= 4)
358 xhci->shared_hcd->can_do_streams = 1;
359
360 /* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */
361 pm_runtime_put_noidle(&dev->dev);
362
363 return 0;
364
365put_usb3_hcd:
366 usb_put_hcd(xhci->shared_hcd);
367dealloc_usb2_hcd:
368 usb_hcd_pci_remove(dev);
369put_runtime_pm:
370 pm_runtime_put_noidle(&dev->dev);
371 return retval;
372}
373
374static void xhci_pci_remove(struct pci_dev *dev)
375{
376 struct xhci_hcd *xhci;
377
378 xhci = hcd_to_xhci(pci_get_drvdata(dev));
379 xhci->xhc_state |= XHCI_STATE_REMOVING;
380 if (xhci->shared_hcd) {
381 usb_remove_hcd(xhci->shared_hcd);
382 usb_put_hcd(xhci->shared_hcd);
383 xhci->shared_hcd = NULL;
384 }
385
386 /* Workaround for spurious wakeups at shutdown with HSW */
387 if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
388 pci_set_power_state(dev, PCI_D3hot);
389
390 usb_hcd_pci_remove(dev);
391}
392
393#ifdef CONFIG_PM
394/*
395 * In some Intel xHCI controllers, in order to get D3 working,
396 * through a vendor specific SSIC CONFIG register at offset 0x883c,
397 * SSIC PORT need to be marked as "unused" before putting xHCI
398 * into D3. After D3 exit, the SSIC port need to be marked as "used".
399 * Without this change, xHCI might not enter D3 state.
400 */
401static void xhci_ssic_port_unused_quirk(struct usb_hcd *hcd, bool suspend)
402{
403 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
404 u32 val;
405 void __iomem *reg;
406 int i;
407
408 for (i = 0; i < SSIC_PORT_NUM; i++) {
409 reg = (void __iomem *) xhci->cap_regs +
410 SSIC_PORT_CFG2 +
411 i * SSIC_PORT_CFG2_OFFSET;
412
413 /* Notify SSIC that SSIC profile programming is not done. */
414 val = readl(reg) & ~PROG_DONE;
415 writel(val, reg);
416
417 /* Mark SSIC port as unused(suspend) or used(resume) */
418 val = readl(reg);
419 if (suspend)
420 val |= SSIC_PORT_UNUSED;
421 else
422 val &= ~SSIC_PORT_UNUSED;
423 writel(val, reg);
424
425 /* Notify SSIC that SSIC profile programming is done */
426 val = readl(reg) | PROG_DONE;
427 writel(val, reg);
428 readl(reg);
429 }
430}
431
432/*
433 * Make sure PME works on some Intel xHCI controllers by writing 1 to clear
434 * the Internal PME flag bit in vendor specific PMCTRL register at offset 0x80a4
435 */
436static void xhci_pme_quirk(struct usb_hcd *hcd)
437{
438 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
439 void __iomem *reg;
440 u32 val;
441
442 reg = (void __iomem *) xhci->cap_regs + 0x80a4;
443 val = readl(reg);
444 writel(val | BIT(28), reg);
445 readl(reg);
446}
447
448static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
449{
450 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
451 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
452 int ret;
453
454 /*
455 * Systems with the TI redriver that loses port status change events
456 * need to have the registers polled during D3, so avoid D3cold.
457 */
458 if (xhci->quirks & XHCI_COMP_MODE_QUIRK)
459 pci_d3cold_disable(pdev);
460
461 if (xhci->quirks & XHCI_PME_STUCK_QUIRK)
462 xhci_pme_quirk(hcd);
463
464 if (xhci->quirks & XHCI_SSIC_PORT_UNUSED)
465 xhci_ssic_port_unused_quirk(hcd, true);
466
467 ret = xhci_suspend(xhci, do_wakeup);
468 if (ret && (xhci->quirks & XHCI_SSIC_PORT_UNUSED))
469 xhci_ssic_port_unused_quirk(hcd, false);
470
471 return ret;
472}
473
474static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
475{
476 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
477 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
478 int retval = 0;
479
480 /* The BIOS on systems with the Intel Panther Point chipset may or may
481 * not support xHCI natively. That means that during system resume, it
482 * may switch the ports back to EHCI so that users can use their
483 * keyboard to select a kernel from GRUB after resume from hibernate.
484 *
485 * The BIOS is supposed to remember whether the OS had xHCI ports
486 * enabled before resume, and switch the ports back to xHCI when the
487 * BIOS/OS semaphore is written, but we all know we can't trust BIOS
488 * writers.
489 *
490 * Unconditionally switch the ports back to xHCI after a system resume.
491 * It should not matter whether the EHCI or xHCI controller is
492 * resumed first. It's enough to do the switchover in xHCI because
493 * USB core won't notice anything as the hub driver doesn't start
494 * running again until after all the devices (including both EHCI and
495 * xHCI host controllers) have been resumed.
496 */
497
498 if (pdev->vendor == PCI_VENDOR_ID_INTEL)
499 usb_enable_intel_xhci_ports(pdev);
500
501 if (xhci->quirks & XHCI_SSIC_PORT_UNUSED)
502 xhci_ssic_port_unused_quirk(hcd, false);
503
504 if (xhci->quirks & XHCI_PME_STUCK_QUIRK)
505 xhci_pme_quirk(hcd);
506
507 retval = xhci_resume(xhci, hibernated);
508 return retval;
509}
510
511static void xhci_pci_shutdown(struct usb_hcd *hcd)
512{
513 struct xhci_hcd *xhci = hcd_to_xhci(hcd);
514 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
515
516 xhci_shutdown(hcd);
517
518 /* Yet another workaround for spurious wakeups at shutdown with HSW */
519 if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
520 pci_set_power_state(pdev, PCI_D3hot);
521}
522#endif /* CONFIG_PM */
523
524/*-------------------------------------------------------------------------*/
525
526/* PCI driver selection metadata; PCI hotplugging uses this */
527static const struct pci_device_id pci_ids[] = { {
528 /* handle any USB 3.0 xHCI controller */
529 PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_XHCI, ~0),
530 .driver_data = (unsigned long) &xhci_pci_hc_driver,
531 },
532 { /* end: all zeroes */ }
533};
534MODULE_DEVICE_TABLE(pci, pci_ids);
535
536/* pci driver glue; this is a "new style" PCI driver module */
537static struct pci_driver xhci_pci_driver = {
538 .name = (char *) hcd_name,
539 .id_table = pci_ids,
540
541 .probe = xhci_pci_probe,
542 .remove = xhci_pci_remove,
543 /* suspend and resume implemented later */
544
545 .shutdown = usb_hcd_pci_shutdown,
546#ifdef CONFIG_PM
547 .driver = {
548 .pm = &usb_hcd_pci_pm_ops
549 },
550#endif
551};
552
553static int __init xhci_pci_init(void)
554{
555 xhci_init_driver(&xhci_pci_hc_driver, &xhci_pci_overrides);
556#ifdef CONFIG_PM
557 xhci_pci_hc_driver.pci_suspend = xhci_pci_suspend;
558 xhci_pci_hc_driver.pci_resume = xhci_pci_resume;
559 xhci_pci_hc_driver.shutdown = xhci_pci_shutdown;
560#endif
561 return pci_register_driver(&xhci_pci_driver);
562}
563module_init(xhci_pci_init);
564
565static void __exit xhci_pci_exit(void)
566{
567 pci_unregister_driver(&xhci_pci_driver);
568}
569module_exit(xhci_pci_exit);
570
571MODULE_DESCRIPTION("xHCI PCI Host Controller Driver");
572MODULE_LICENSE("GPL");