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"
92 static void xhci_msix_sync_irqs(struct xhci_hcd *xhci) in xhci_msix_sync_irqs() argument
94 struct usb_hcd *hcd = xhci_to_hcd(xhci); in xhci_msix_sync_irqs()
100 for (i = 0; i < xhci->msix_count; i++) in xhci_msix_sync_irqs()
106 static void xhci_cleanup_msix(struct xhci_hcd *xhci) in xhci_cleanup_msix() argument
108 struct usb_hcd *hcd = xhci_to_hcd(xhci); in xhci_cleanup_msix()
118 for (i = 0; i < xhci->msix_count; i++) in xhci_cleanup_msix()
119 free_irq(pci_irq_vector(pdev, i), xhci_to_hcd(xhci)); in xhci_cleanup_msix()
121 free_irq(pci_irq_vector(pdev, 0), xhci_to_hcd(xhci)); in xhci_cleanup_msix()
131 static int xhci_setup_msi(struct xhci_hcd *xhci) in xhci_setup_msi() argument
137 struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); in xhci_setup_msi()
141 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_setup_msi()
147 0, "xhci_hcd", xhci_to_hcd(xhci)); in xhci_setup_msi()
149 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_setup_msi()
160 static int xhci_setup_msix(struct xhci_hcd *xhci) in xhci_setup_msix() argument
163 struct usb_hcd *hcd = xhci_to_hcd(xhci); in xhci_setup_msix()
169 * with max number of interrupters based on the xhci HCSPARAMS1. in xhci_setup_msix()
173 xhci->msix_count = min(num_online_cpus() + 1, in xhci_setup_msix()
174 HCS_MAX_INTRS(xhci->hcs_params1)); in xhci_setup_msix()
176 ret = pci_alloc_irq_vectors(pdev, xhci->msix_count, xhci->msix_count, in xhci_setup_msix()
179 xhci_dbg_trace(xhci, trace_xhci_dbg_init, in xhci_setup_msix()
184 for (i = 0; i < xhci->msix_count; i++) { in xhci_setup_msix()
186 "xhci_hcd", xhci_to_hcd(xhci)); in xhci_setup_msix()
195 xhci_dbg_trace(xhci, trace_xhci_dbg_init, "disable MSI-X interrupt"); in xhci_setup_msix()
197 free_irq(pci_irq_vector(pdev, i), xhci_to_hcd(xhci)); in xhci_setup_msix()
204 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_try_enable_msi() local
208 pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); in xhci_try_enable_msi()
213 if (xhci->quirks & XHCI_BROKEN_MSI) in xhci_try_enable_msi()
221 ret = xhci_setup_msix(xhci); in xhci_try_enable_msi()
224 ret = xhci_setup_msi(xhci); in xhci_try_enable_msi()
232 xhci_err(xhci, "No msi-x/msi found and no IRQ in BIOS\n"); in xhci_try_enable_msi()
245 xhci_err(xhci, "request interrupt %d failed\n", in xhci_try_enable_msi()
268 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_pci_stop() local
273 xhci_cleanup_msix(xhci); in xhci_pci_stop()
277 static int xhci_pci_reinit(struct xhci_hcd *xhci, struct pci_dev *pdev) in xhci_pci_reinit() argument
287 xhci_dbg(xhci, "MWI active\n"); in xhci_pci_reinit()
289 xhci_dbg(xhci, "Finished xhci_pci_reinit\n"); in xhci_pci_reinit()
293 static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) in xhci_pci_quirks() argument
303 xhci->quirks |= driver_data->quirks; in xhci_pci_quirks()
312 xhci->quirks |= XHCI_RESET_EP_QUIRK; in xhci_pci_quirks()
313 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_pci_quirks()
318 xhci->quirks |= XHCI_SLOW_SUSPEND; in xhci_pci_quirks()
319 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_pci_quirks()
325 xhci->quirks |= XHCI_BROKEN_STREAMS; in xhci_pci_quirks()
330 xhci->quirks |= XHCI_BROKEN_MSI; in xhci_pci_quirks()
331 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_pci_quirks()
335 xhci->quirks |= XHCI_TRUST_TX_LENGTH; in xhci_pci_quirks()
340 xhci->quirks |= XHCI_BROKEN_STREAMS; in xhci_pci_quirks()
344 xhci->quirks |= XHCI_TRUST_TX_LENGTH; in xhci_pci_quirks()
347 xhci->quirks |= XHCI_NEC_HOST; in xhci_pci_quirks()
349 if (pdev->vendor == PCI_VENDOR_ID_AMD && xhci->hci_version == 0x96) in xhci_pci_quirks()
350 xhci->quirks |= XHCI_AMD_0x96_HOST; in xhci_pci_quirks()
354 xhci->quirks |= XHCI_AMD_PLL_FIX; in xhci_pci_quirks()
361 xhci->quirks |= XHCI_SUSPEND_DELAY; in xhci_pci_quirks()
365 xhci->quirks |= XHCI_SNPS_BROKEN_SUSPEND; in xhci_pci_quirks()
368 xhci->quirks |= XHCI_DISABLE_SPARSE; in xhci_pci_quirks()
369 xhci->quirks |= XHCI_RESET_ON_RESUME; in xhci_pci_quirks()
373 xhci->quirks |= XHCI_TRUST_TX_LENGTH; in xhci_pci_quirks()
380 xhci->quirks |= XHCI_U2_DISABLE_WAKE; in xhci_pci_quirks()
384 xhci->quirks |= XHCI_BROKEN_D3COLD_S2I; in xhci_pci_quirks()
387 xhci->quirks |= XHCI_LPM_SUPPORT; in xhci_pci_quirks()
388 xhci->quirks |= XHCI_INTEL_HOST; in xhci_pci_quirks()
389 xhci->quirks |= XHCI_AVOID_BEI; in xhci_pci_quirks()
393 xhci->quirks |= XHCI_EP_LIMIT_QUIRK; in xhci_pci_quirks()
394 xhci->limit_active_eps = 64; in xhci_pci_quirks()
395 xhci->quirks |= XHCI_SW_BW_CHECKING; in xhci_pci_quirks()
399 * switch the ports from xHCI to EHCI on shutdown. We can't use in xhci_pci_quirks()
404 xhci->quirks |= XHCI_SPURIOUS_REBOOT; in xhci_pci_quirks()
409 xhci->quirks |= XHCI_SPURIOUS_REBOOT; in xhci_pci_quirks()
410 xhci->quirks |= XHCI_SPURIOUS_WAKEUP; in xhci_pci_quirks()
421 xhci->quirks |= XHCI_PME_STUCK_QUIRK; in xhci_pci_quirks()
425 xhci->quirks |= XHCI_SSIC_PORT_UNUSED; in xhci_pci_quirks()
430 xhci->quirks |= XHCI_INTEL_USB_ROLE_SW; in xhci_pci_quirks()
437 xhci->quirks |= XHCI_MISSING_CAS; in xhci_pci_quirks()
442 xhci->quirks |= XHCI_RESET_TO_DEFAULT; in xhci_pci_quirks()
456 xhci->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW; in xhci_pci_quirks()
460 xhci->quirks |= XHCI_RESET_ON_RESUME; in xhci_pci_quirks()
461 xhci->quirks |= XHCI_TRUST_TX_LENGTH; in xhci_pci_quirks()
462 xhci->quirks |= XHCI_BROKEN_STREAMS; in xhci_pci_quirks()
466 xhci->quirks |= XHCI_TRUST_TX_LENGTH; in xhci_pci_quirks()
467 xhci->quirks |= XHCI_ZERO_64B_REGS; in xhci_pci_quirks()
471 xhci->quirks |= XHCI_RESET_ON_RESUME; in xhci_pci_quirks()
472 xhci->quirks |= XHCI_ZERO_64B_REGS; in xhci_pci_quirks()
475 xhci->quirks |= XHCI_RESET_ON_RESUME; in xhci_pci_quirks()
480 xhci->quirks |= XHCI_BROKEN_STREAMS; in xhci_pci_quirks()
483 xhci->quirks |= XHCI_LPM_SUPPORT; in xhci_pci_quirks()
491 xhci->quirks |= XHCI_SPURIOUS_SUCCESS; in xhci_pci_quirks()
492 xhci->quirks |= XHCI_BROKEN_STREAMS; in xhci_pci_quirks()
496 xhci->quirks |= XHCI_TRUST_TX_LENGTH; in xhci_pci_quirks()
497 xhci->quirks |= XHCI_NO_64BIT_SUPPORT; in xhci_pci_quirks()
503 xhci->quirks |= XHCI_NO_64BIT_SUPPORT; in xhci_pci_quirks()
507 xhci->quirks |= XHCI_ASMEDIA_MODIFY_FLOWCONTROL; in xhci_pci_quirks()
510 xhci->quirks |= XHCI_LIMIT_ENDPOINT_INTERVAL_7; in xhci_pci_quirks()
515 xhci->quirks |= XHCI_RESET_PLL_ON_DISCONNECT; in xhci_pci_quirks()
520 xhci->quirks |= XHCI_NO_SOFT_RETRY; in xhci_pci_quirks()
523 xhci->quirks |= XHCI_ZHAOXIN_HOST; in xhci_pci_quirks()
524 xhci->quirks |= XHCI_LPM_SUPPORT; in xhci_pci_quirks()
527 xhci->quirks |= XHCI_RESET_ON_RESUME; in xhci_pci_quirks()
528 xhci->quirks |= XHCI_ZHAOXIN_TRB_FETCH; in xhci_pci_quirks()
532 xhci->quirks |= XHCI_ZHAOXIN_TRB_FETCH; in xhci_pci_quirks()
536 if (xhci->hci_version >= 0x120) in xhci_pci_quirks()
537 xhci->quirks |= XHCI_DEFAULT_PM_RUNTIME_ALLOW; in xhci_pci_quirks()
539 if (xhci->quirks & XHCI_RESET_ON_RESUME) in xhci_pci_quirks()
540 xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, in xhci_pci_quirks()
559 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_find_lpm_incapable_ports() local
560 struct xhci_hub *rhub = &xhci->usb3_rhub; in xhci_find_lpm_incapable_ports()
593 struct xhci_hcd *xhci; in xhci_pci_setup() local
597 xhci = hcd_to_xhci(hcd); in xhci_pci_setup()
598 if (!xhci->sbrn) in xhci_pci_setup()
599 pci_read_config_byte(pdev, XHCI_SBRN_OFFSET, &xhci->sbrn); in xhci_pci_setup()
602 xhci->imod_interval = 40000; in xhci_pci_setup()
611 if (xhci->quirks & XHCI_PME_STUCK_QUIRK) in xhci_pci_setup()
614 xhci_dbg(xhci, "Got SBRN %u\n", (unsigned int) xhci->sbrn); in xhci_pci_setup()
617 return xhci_pci_reinit(xhci, pdev); in xhci_pci_setup()
632 * function) in order to create a second roothub under xHCI.
637 struct xhci_hcd *xhci; in xhci_pci_probe() local
670 xhci = hcd_to_xhci(hcd); in xhci_pci_probe()
671 xhci->reset = reset; in xhci_pci_probe()
672 xhci->shared_hcd = usb_create_shared_hcd(&xhci_pci_hc_driver, &dev->dev, in xhci_pci_probe()
674 if (!xhci->shared_hcd) { in xhci_pci_probe()
679 retval = xhci_ext_cap_init(xhci); in xhci_pci_probe()
683 retval = usb_add_hcd(xhci->shared_hcd, dev->irq, in xhci_pci_probe()
689 if (!(xhci->quirks & XHCI_BROKEN_STREAMS) && in xhci_pci_probe()
690 HCC_MAX_PSA(xhci->hcc_params) >= 4) in xhci_pci_probe()
691 xhci->shared_hcd->can_do_streams = 1; in xhci_pci_probe()
698 else if (xhci->quirks & XHCI_DEFAULT_PM_RUNTIME_ALLOW) in xhci_pci_probe()
706 usb_put_hcd(xhci->shared_hcd); in xhci_pci_probe()
716 struct xhci_hcd *xhci; in xhci_pci_remove() local
718 xhci = hcd_to_xhci(pci_get_drvdata(dev)); in xhci_pci_remove()
720 xhci->xhc_state |= XHCI_STATE_REMOVING; in xhci_pci_remove()
722 if (xhci->quirks & XHCI_DEFAULT_PM_RUNTIME_ALLOW) in xhci_pci_remove()
725 if (xhci->shared_hcd) { in xhci_pci_remove()
726 usb_remove_hcd(xhci->shared_hcd); in xhci_pci_remove()
727 usb_put_hcd(xhci->shared_hcd); in xhci_pci_remove()
728 xhci->shared_hcd = NULL; in xhci_pci_remove()
732 if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) in xhci_pci_remove()
739 * In some Intel xHCI controllers, in order to get D3 working,
741 * SSIC PORT need to be marked as "unused" before putting xHCI
743 * Without this change, xHCI might not enter D3 state.
747 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_ssic_port_unused_quirk() local
753 reg = (void __iomem *) xhci->cap_regs + in xhci_ssic_port_unused_quirk()
777 * Make sure PME works on some Intel xHCI controllers by writing 1 to clear
782 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_pme_quirk() local
786 reg = (void __iomem *) xhci->cap_regs + 0x80a4; in xhci_pme_quirk()
803 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_pci_suspend() local
811 if (xhci->quirks & XHCI_COMP_MODE_QUIRK) in xhci_pci_suspend()
817 xhci->quirks & (XHCI_BROKEN_D3COLD_S2I)) in xhci_pci_suspend()
821 if (xhci->quirks & XHCI_PME_STUCK_QUIRK) in xhci_pci_suspend()
824 if (xhci->quirks & XHCI_SSIC_PORT_UNUSED) in xhci_pci_suspend()
827 if (xhci->quirks & XHCI_DISABLE_SPARSE) in xhci_pci_suspend()
830 ret = xhci_suspend(xhci, do_wakeup); in xhci_pci_suspend()
833 xhci_msix_sync_irqs(xhci); in xhci_pci_suspend()
835 if (ret && (xhci->quirks & XHCI_SSIC_PORT_UNUSED)) in xhci_pci_suspend()
843 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_pci_resume() local
847 reset_control_reset(xhci->reset); in xhci_pci_resume()
850 * not support xHCI natively. That means that during system resume, it in xhci_pci_resume()
854 * The BIOS is supposed to remember whether the OS had xHCI ports in xhci_pci_resume()
855 * enabled before resume, and switch the ports back to xHCI when the in xhci_pci_resume()
859 * Unconditionally switch the ports back to xHCI after a system resume. in xhci_pci_resume()
860 * It should not matter whether the EHCI or xHCI controller is in xhci_pci_resume()
861 * resumed first. It's enough to do the switchover in xHCI because in xhci_pci_resume()
864 * xHCI host controllers) have been resumed. in xhci_pci_resume()
870 if (xhci->quirks & XHCI_SSIC_PORT_UNUSED) in xhci_pci_resume()
873 if (xhci->quirks & XHCI_PME_STUCK_QUIRK) in xhci_pci_resume()
876 retval = xhci_resume(xhci, msg); in xhci_pci_resume()
882 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_pci_poweroff_late() local
898 if (!(xhci->quirks & XHCI_RESET_TO_DEFAULT)) in xhci_pci_poweroff_late()
901 for (i = 0; i < HCS_MAX_PORTS(xhci->hcs_params1); i++) { in xhci_pci_poweroff_late()
902 port = &xhci->hw_ports[i]; in xhci_pci_poweroff_late()
908 slot_id = xhci_find_slot_id_by_port(port->rhub->hcd, xhci, in xhci_pci_poweroff_late()
910 if (!slot_id || !xhci->devs[slot_id]) { in xhci_pci_poweroff_late()
911 xhci_err(xhci, "No dev for slot_id %d for port %d-%d in U3\n", in xhci_pci_poweroff_late()
916 udev = xhci->devs[slot_id]->udev; in xhci_pci_poweroff_late()
922 xhci_dbg(xhci, "port %d-%d in U3 without wakeup, disable it\n", in xhci_pci_poweroff_late()
933 struct xhci_hcd *xhci = hcd_to_xhci(hcd); in xhci_pci_shutdown() local
937 xhci_cleanup_msix(xhci); in xhci_pci_shutdown()
940 if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) in xhci_pci_shutdown()
959 /* handle any USB 3.0 xHCI controller */
968 * load firmware, so don't encumber the xhci-pci driver with it.
1007 MODULE_DESCRIPTION("xHCI PCI Host Controller Driver");