Lines Matching full:xhci
3 * xHCI host controller driver PCI Bus Glue.
18 #include "xhci.h"
19 #include "xhci-trace.h"
20 #include "xhci-pci.h"
106 static void xhci_msix_sync_irqs(struct xhci_hcd *xhci) in xhci_msix_sync_irqs() argument
108 struct usb_hcd *hcd = xhci_to_hcd(xhci); in xhci_msix_sync_irqs()
119 static void xhci_cleanup_msix(struct xhci_hcd *xhci) in xhci_cleanup_msix() argument
121 struct usb_hcd *hcd = xhci_to_hcd(xhci); in xhci_cleanup_msix()
127 free_irq(pci_irq_vector(pdev, 0), xhci_to_hcd(xhci)); in xhci_cleanup_msix()
136 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_try_enable_msi() local
143 if (xhci->quirks & XHCI_BROKEN_MSI) in xhci_try_enable_msi()
153 * - max_interrupters: the max number of interrupts requested, capped to xhci HCSPARAMS1. in xhci_try_enable_msi()
156 xhci->nvecs = min(num_online_cpus() + 1, xhci->max_interrupters); in xhci_try_enable_msi()
159 xhci->nvecs = pci_alloc_irq_vectors(pdev, 1, xhci->nvecs, in xhci_try_enable_msi()
161 if (xhci->nvecs < 0) { in xhci_try_enable_msi()
162 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_try_enable_msi()
168 xhci_to_hcd(xhci)); in xhci_try_enable_msi()
177 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "disable %s interrupt", in xhci_try_enable_msi()
183 xhci_err(xhci, "No msi-x/msi found and no IRQ in BIOS\n"); in xhci_try_enable_msi()
194 xhci_err(xhci, "request interrupt %d failed\n", pdev->irq); in xhci_try_enable_msi()
216 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_pci_stop() local
221 xhci_cleanup_msix(xhci); in xhci_pci_stop()
225 static int xhci_pci_reinit(struct xhci_hcd *xhci, struct pci_dev *pdev) in xhci_pci_reinit() argument
235 xhci_dbg(xhci, "MWI active\n"); in xhci_pci_reinit()
237 xhci_dbg(xhci, "Finished xhci_pci_reinit\n"); in xhci_pci_reinit()
241 static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) in xhci_pci_quirks() argument
251 xhci->quirks |= XHCI_RESET_EP_QUIRK; in xhci_pci_quirks()
252 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_pci_quirks()
257 xhci->quirks |= XHCI_SLOW_SUSPEND; in xhci_pci_quirks()
258 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_pci_quirks()
264 xhci->quirks |= XHCI_BROKEN_STREAMS; in xhci_pci_quirks()
269 xhci->quirks |= XHCI_BROKEN_MSI; in xhci_pci_quirks()
270 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_pci_quirks()
278 xhci->quirks |= XHCI_BROKEN_STREAMS; in xhci_pci_quirks()
281 xhci->quirks |= XHCI_NEC_HOST; in xhci_pci_quirks()
283 if (pdev->vendor == PCI_VENDOR_ID_AMD && xhci->hci_version == 0x96) in xhci_pci_quirks()
284 xhci->quirks |= XHCI_AMD_0x96_HOST; in xhci_pci_quirks()
288 xhci->quirks |= XHCI_AMD_PLL_FIX; in xhci_pci_quirks()
295 xhci->quirks |= XHCI_SUSPEND_DELAY; in xhci_pci_quirks()
299 xhci->quirks |= XHCI_SNPS_BROKEN_SUSPEND; in xhci_pci_quirks()
302 xhci->quirks |= XHCI_DISABLE_SPARSE; in xhci_pci_quirks()
303 xhci->quirks |= XHCI_RESET_ON_RESUME; in xhci_pci_quirks()
307 xhci->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW; in xhci_pci_quirks()
314 xhci->quirks |= XHCI_U2_DISABLE_WAKE; in xhci_pci_quirks()
318 xhci->quirks |= XHCI_BROKEN_D3COLD_S2I; in xhci_pci_quirks()
321 xhci->quirks |= XHCI_LPM_SUPPORT; in xhci_pci_quirks()
322 xhci->quirks |= XHCI_INTEL_HOST; in xhci_pci_quirks()
323 xhci->quirks |= XHCI_AVOID_BEI; in xhci_pci_quirks()
327 xhci->quirks |= XHCI_EP_LIMIT_QUIRK; in xhci_pci_quirks()
328 xhci->limit_active_eps = 64; in xhci_pci_quirks()
329 xhci->quirks |= XHCI_SW_BW_CHECKING; in xhci_pci_quirks()
333 * switch the ports from xHCI to EHCI on shutdown. We can't use in xhci_pci_quirks()
338 xhci->quirks |= XHCI_SPURIOUS_REBOOT; in xhci_pci_quirks()
343 xhci->quirks |= XHCI_SPURIOUS_REBOOT; in xhci_pci_quirks()
344 xhci->quirks |= XHCI_SPURIOUS_WAKEUP; in xhci_pci_quirks()
355 xhci->quirks |= XHCI_PME_STUCK_QUIRK; in xhci_pci_quirks()
359 xhci->quirks |= XHCI_SSIC_PORT_UNUSED; in xhci_pci_quirks()
364 xhci->quirks |= XHCI_INTEL_USB_ROLE_SW; in xhci_pci_quirks()
371 xhci->quirks |= XHCI_MISSING_CAS; in xhci_pci_quirks()
377 xhci->quirks |= XHCI_RESET_TO_DEFAULT; in xhci_pci_quirks()
391 xhci->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW; in xhci_pci_quirks()
396 xhci->quirks |= XHCI_ETRON_HOST; in xhci_pci_quirks()
397 xhci->quirks |= XHCI_RESET_ON_RESUME; in xhci_pci_quirks()
398 xhci->quirks |= XHCI_BROKEN_STREAMS; in xhci_pci_quirks()
399 xhci->quirks |= XHCI_NO_SOFT_RETRY; in xhci_pci_quirks()
404 xhci->quirks |= XHCI_ZERO_64B_REGS; in xhci_pci_quirks()
408 xhci->quirks |= XHCI_RESET_ON_RESUME; in xhci_pci_quirks()
409 xhci->quirks |= XHCI_ZERO_64B_REGS; in xhci_pci_quirks()
412 xhci->quirks |= XHCI_RESET_ON_RESUME; in xhci_pci_quirks()
416 xhci->quirks |= XHCI_RESET_ON_RESUME; in xhci_pci_quirks()
421 xhci->quirks |= XHCI_BROKEN_STREAMS; in xhci_pci_quirks()
424 xhci->quirks |= XHCI_LPM_SUPPORT; in xhci_pci_quirks()
425 xhci->quirks |= XHCI_TRB_OVERFETCH; in xhci_pci_quirks()
434 xhci->quirks |= XHCI_SPURIOUS_SUCCESS; in xhci_pci_quirks()
435 xhci->quirks |= XHCI_BROKEN_STREAMS; in xhci_pci_quirks()
439 xhci->quirks |= XHCI_NO_64BIT_SUPPORT; in xhci_pci_quirks()
445 xhci->quirks |= XHCI_NO_64BIT_SUPPORT; in xhci_pci_quirks()
449 xhci->quirks |= XHCI_ASMEDIA_MODIFY_FLOWCONTROL; in xhci_pci_quirks()
453 xhci->quirks |= XHCI_RESET_ON_RESUME; in xhci_pci_quirks()
456 xhci->quirks |= XHCI_LIMIT_ENDPOINT_INTERVAL_7; in xhci_pci_quirks()
461 xhci->quirks |= XHCI_RESET_PLL_ON_DISCONNECT; in xhci_pci_quirks()
466 xhci->quirks |= XHCI_NO_SOFT_RETRY; in xhci_pci_quirks()
469 xhci->quirks |= XHCI_ZHAOXIN_HOST; in xhci_pci_quirks()
470 xhci->quirks |= XHCI_LPM_SUPPORT; in xhci_pci_quirks()
473 xhci->quirks |= XHCI_RESET_ON_RESUME; in xhci_pci_quirks()
474 xhci->quirks |= XHCI_TRB_OVERFETCH; in xhci_pci_quirks()
478 xhci->quirks |= XHCI_TRB_OVERFETCH; in xhci_pci_quirks()
483 xhci->quirks |= XHCI_CDNS_SCTX_QUIRK; in xhci_pci_quirks()
486 if (xhci->hci_version >= 0x120) in xhci_pci_quirks()
487 xhci->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW; in xhci_pci_quirks()
489 if (xhci->quirks & XHCI_RESET_ON_RESUME) in xhci_pci_quirks()
490 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_pci_quirks()
509 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_find_lpm_incapable_ports() local
510 struct xhci_hub *rhub = &xhci->usb3_rhub; in xhci_find_lpm_incapable_ports()
543 struct xhci_hcd *xhci; in xhci_pci_setup() local
548 xhci = hcd_to_xhci(hcd); in xhci_pci_setup()
551 xhci->imod_interval = 40000; in xhci_pci_setup()
560 if (xhci->quirks & XHCI_PME_STUCK_QUIRK) in xhci_pci_setup()
564 xhci_dbg(xhci, "Got SBRN %u\n", (unsigned int)sbrn); in xhci_pci_setup()
567 return xhci_pci_reinit(xhci, pdev); in xhci_pci_setup()
582 * function) in order to create a second roothub under xHCI.
587 struct xhci_hcd *xhci; in xhci_pci_common_probe() local
612 xhci = hcd_to_xhci(hcd); in xhci_pci_common_probe()
613 xhci->reset = reset; in xhci_pci_common_probe()
614 xhci->shared_hcd = usb_create_shared_hcd(&xhci_pci_hc_driver, &dev->dev, in xhci_pci_common_probe()
616 if (!xhci->shared_hcd) { in xhci_pci_common_probe()
621 retval = xhci_ext_cap_init(xhci); in xhci_pci_common_probe()
625 retval = usb_add_hcd(xhci->shared_hcd, dev->irq, in xhci_pci_common_probe()
631 if (!(xhci->quirks & XHCI_BROKEN_STREAMS) && in xhci_pci_common_probe()
632 HCC_MAX_PSA(xhci->hcc_params) >= 4) in xhci_pci_common_probe()
633 xhci->shared_hcd->can_do_streams = 1; in xhci_pci_common_probe()
640 else if (xhci->quirks & XHCI_DEFAULT_PM_RUNTIME_ALLOW) in xhci_pci_common_probe()
651 usb_put_hcd(xhci->shared_hcd); in xhci_pci_common_probe()
658 EXPORT_SYMBOL_NS_GPL(xhci_pci_common_probe, "xhci");
660 /* handled by xhci-pci-renesas if enabled */
678 struct xhci_hcd *xhci; in xhci_pci_remove() local
681 xhci = hcd_to_xhci(pci_get_drvdata(dev)); in xhci_pci_remove()
682 set_power_d3 = xhci->quirks & XHCI_SPURIOUS_WAKEUP; in xhci_pci_remove()
684 xhci->xhc_state |= XHCI_STATE_REMOVING; in xhci_pci_remove()
688 else if (xhci->quirks & XHCI_DEFAULT_PM_RUNTIME_ALLOW) in xhci_pci_remove()
691 if (xhci->shared_hcd) { in xhci_pci_remove()
692 usb_remove_hcd(xhci->shared_hcd); in xhci_pci_remove()
693 usb_put_hcd(xhci->shared_hcd); in xhci_pci_remove()
694 xhci->shared_hcd = NULL; in xhci_pci_remove()
703 EXPORT_SYMBOL_NS_GPL(xhci_pci_remove, "xhci");
706 * In some Intel xHCI controllers, in order to get D3 working,
708 * SSIC PORT need to be marked as "unused" before putting xHCI
710 * Without this change, xHCI might not enter D3 state.
714 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_ssic_port_unused_quirk() local
720 reg = (void __iomem *) xhci->cap_regs + in xhci_ssic_port_unused_quirk()
744 * Make sure PME works on some Intel xHCI controllers by writing 1 to clear
749 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_pme_quirk() local
753 reg = (void __iomem *) xhci->cap_regs + 0x80a4; in xhci_pme_quirk()
770 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_pci_suspend() local
778 if (xhci->quirks & XHCI_COMP_MODE_QUIRK) in xhci_pci_suspend()
784 xhci->quirks & (XHCI_BROKEN_D3COLD_S2I)) in xhci_pci_suspend()
788 if (xhci->quirks & XHCI_PME_STUCK_QUIRK) in xhci_pci_suspend()
791 if (xhci->quirks & XHCI_SSIC_PORT_UNUSED) in xhci_pci_suspend()
794 if (xhci->quirks & XHCI_DISABLE_SPARSE) in xhci_pci_suspend()
797 ret = xhci_suspend(xhci, do_wakeup); in xhci_pci_suspend()
800 xhci_msix_sync_irqs(xhci); in xhci_pci_suspend()
802 if (ret && (xhci->quirks & XHCI_SSIC_PORT_UNUSED)) in xhci_pci_suspend()
810 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_pci_resume() local
813 reset_control_reset(xhci->reset); in xhci_pci_resume()
816 * not support xHCI natively. That means that during system resume, it in xhci_pci_resume()
820 * The BIOS is supposed to remember whether the OS had xHCI ports in xhci_pci_resume()
821 * enabled before resume, and switch the ports back to xHCI when the in xhci_pci_resume()
825 * Unconditionally switch the ports back to xHCI after a system resume. in xhci_pci_resume()
826 * It should not matter whether the EHCI or xHCI controller is in xhci_pci_resume()
827 * resumed first. It's enough to do the switchover in xHCI because in xhci_pci_resume()
830 * xHCI host controllers) have been resumed. in xhci_pci_resume()
836 if (xhci->quirks & XHCI_SSIC_PORT_UNUSED) in xhci_pci_resume()
839 if (xhci->quirks & XHCI_PME_STUCK_QUIRK) in xhci_pci_resume()
842 return xhci_resume(xhci, msg); in xhci_pci_resume()
847 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_pci_poweroff_late() local
862 if (!(xhci->quirks & XHCI_RESET_TO_DEFAULT)) in xhci_pci_poweroff_late()
865 for (i = 0; i < HCS_MAX_PORTS(xhci->hcs_params1); i++) { in xhci_pci_poweroff_late()
866 port = &xhci->hw_ports[i]; in xhci_pci_poweroff_late()
872 if (!port->slot_id || !xhci->devs[port->slot_id]) { in xhci_pci_poweroff_late()
873 xhci_err(xhci, "No dev for slot_id %d for port %d-%d in U3\n", in xhci_pci_poweroff_late()
879 udev = xhci->devs[port->slot_id]->udev; in xhci_pci_poweroff_late()
885 xhci_dbg(xhci, "port %d-%d in U3 without wakeup, disable it\n", in xhci_pci_poweroff_late()
896 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_pci_shutdown() local
900 xhci_cleanup_msix(xhci); in xhci_pci_shutdown()
903 if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) in xhci_pci_shutdown()
911 /* handle any USB 3.0 xHCI controller */
951 MODULE_DESCRIPTION("xHCI PCI Host Controller Driver");