Lines Matching +full:usb +full:- +full:controller
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2010-2022 Hans Petter Selasky
47 #include <dev/usb/usb.h>
48 #include <dev/usb/usbdi.h>
50 #include <dev/usb/usb_core.h>
51 #include <dev/usb/usb_busdma.h>
52 #include <dev/usb/usb_process.h>
53 #include <dev/usb/usb_util.h>
55 #include <dev/usb/usb_controller.h>
56 #include <dev/usb/usb_bus.h>
57 #include <dev/usb/usb_pci.h>
58 #include <dev/usb/controller/xhci.h>
59 #include <dev/usb/controller/xhcireg.h>
88 MODULE_DEPEND(xhci, usb, 1, 1, 1);
97 return ("AMD KERNCZ USB 3.0 controller"); in xhci_pci_match()
99 return ("AMD Starship USB 3.0 controller"); in xhci_pci_match()
101 return ("AMD Matisse USB 3.0 controller"); in xhci_pci_match()
104 return ("AMD Raven USB 3.1 controller"); in xhci_pci_match()
106 return ("AMD X399 USB 3.0 controller"); in xhci_pci_match()
109 return ("AMD 300 Series USB 3.1 controller"); in xhci_pci_match()
111 return ("AMD 400 Series USB 3.1 controller"); in xhci_pci_match()
115 return ("AMD FCH USB 3.0 controller"); in xhci_pci_match()
119 return ("VMware USB 3.0 controller"); in xhci_pci_match()
122 return ("Hygon USB 3.0 controller"); in xhci_pci_match()
125 return ("NEC uPD720200 USB 3.0 controller"); in xhci_pci_match()
127 return ("NEC uPD720202 USB 3.0 controller"); in xhci_pci_match()
130 return ("Fresco Logic FL1000G USB 3.0 controller"); in xhci_pci_match()
132 return ("Fresco Logic FL1009 USB 3.0 controller"); in xhci_pci_match()
134 return ("Fresco Logic FL1100 USB 3.0 controller"); in xhci_pci_match()
137 return ("ASMedia ASM1042 USB 3.0 controller"); in xhci_pci_match()
139 return ("ASMedia ASM1042A USB 3.0 controller"); in xhci_pci_match()
141 return ("ASMedia ASM1143 USB 3.1 controller"); in xhci_pci_match()
143 return ("ASMedia ASM3242 USB 3.2 controller"); in xhci_pci_match()
146 return ("Intel Goshen Ridge Thunderbolt 4 USB controller"); in xhci_pci_match()
148 return ("Intel BayTrail USB 3.0 controller"); in xhci_pci_match()
150 return ("Intel Maple Ridge Thunderbolt 4 USB controller"); in xhci_pci_match()
154 return ("Intel Alpine Ridge Thunderbolt 3 USB controller"); in xhci_pci_match()
158 return ("Intel Titan Ridge Thunderbolt 3 USB controller"); in xhci_pci_match()
160 return ("Intel Denverton USB 3.0 controller"); in xhci_pci_match()
163 return ("Intel Panther Point USB 3.0 controller"); in xhci_pci_match()
165 return ("Intel Braswell USB 3.0 controller"); in xhci_pci_match()
167 return ("Intel Gemini Lake USB 3.0 controller"); in xhci_pci_match()
169 return ("Intel Ice Lake-LP USB 3.1 controller"); in xhci_pci_match()
171 return ("Intel Tiger Lake-H USB 3.2 controller"); in xhci_pci_match()
173 return ("Intel Alder Lake-P Thunderbolt 4 USB controller"); in xhci_pci_match()
175 return ("Intel Alder Lake USB 3.2 controller"); in xhci_pci_match()
177 return ("Intel Apollo Lake USB 3.0 controller"); in xhci_pci_match()
179 return ("Intel Alder Lake USB 3.2 controller"); in xhci_pci_match()
181 return ("Intel Ice Lake Thunderbolt 3 USB controller"); in xhci_pci_match()
183 return ("Intel Lynx Point USB 3.0 controller"); in xhci_pci_match()
185 return ("Intel Wildcat Point USB 3.0 controller"); in xhci_pci_match()
187 return ("Intel Wellsburg USB 3.0 controller"); in xhci_pci_match()
189 return ("Intel Tiger Lake-LP Thunderbolt 4 USB controller"); in xhci_pci_match()
191 return ("Intel Tiger Lake-H Thunderbolt 4 USB controller"); in xhci_pci_match()
193 return ("Broadwell Integrated PCH-LP chipset USB 3.0 controller"); in xhci_pci_match()
195 return ("Intel Sunrise Point-LP USB 3.0 controller"); in xhci_pci_match()
197 return ("Intel Tiger Lake-LP USB 3.2 controller"); in xhci_pci_match()
199 return ("Intel Sunrise Point USB 3.0 controller"); in xhci_pci_match()
201 return ("Intel Lewisburg USB 3.0 controller"); in xhci_pci_match()
203 return ("Intel Union Point USB 3.0 controller"); in xhci_pci_match()
205 return ("Intel Cannon Lake USB 3.1 controller"); in xhci_pci_match()
208 return ("Cavium ThunderX USB 3.0 controller"); in xhci_pci_match()
211 return ("NVIDIA TU106 USB 3.1 controller"); in xhci_pci_match()
214 return ("Zhaoxin ZX-100 USB 3.0 controller"); in xhci_pci_match()
216 return ("Zhaoxin ZX-200 USB 3.0 controller"); in xhci_pci_match()
218 return ("Zhaoxin ZX-E USB 3.0 controller"); in xhci_pci_match()
227 return ("XHCI (generic) USB 3.0 controller"); in xhci_pci_match()
246 TUNABLE_INT("hw.usb.xhci.msi", &xhci_use_msi);
248 TUNABLE_INT("hw.usb.xhci.msix", &xhci_use_msix);
254 USB_BUS_UNLOCK(&sc->sc_bus); in xhci_interrupt_poll()
256 USB_BUS_LOCK(&sc->sc_bus); in xhci_interrupt_poll()
257 usb_callout_reset(&sc->sc_callout, 1, (void *)&xhci_interrupt_poll, sc); in xhci_interrupt_poll()
294 sc->sc_io_res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, in xhci_pci_attach()
296 if (!sc->sc_io_res) { in xhci_pci_attach()
300 sc->sc_io_tag = rman_get_bustag(sc->sc_io_res); in xhci_pci_attach()
301 sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res); in xhci_pci_attach()
302 sc->sc_io_size = rman_get_size(sc->sc_io_res); in xhci_pci_attach()
305 case 0x10091b73: /* Fresco Logic FL1009 USB3.0 xHCI Controller */ in xhci_pci_attach()
306 case 0x8241104c: /* TUSB73x0 USB3.0 xHCI Controller */ in xhci_pci_attach()
307 sc->sc_no_deconfigure = 1; in xhci_pci_attach()
309 case 0x01941033: /* NEC uPD720200 USB 3.0 controller */ in xhci_pci_attach()
310 case 0x00141912: /* NEC uPD720201 USB 3.0 controller */ in xhci_pci_attach()
311 /* Don't use 64-bit DMA on these controllers. */ in xhci_pci_attach()
326 * controller and use a different IMOD value. in xhci_pci_attach()
328 sc->sc_port_route = &xhci_pci_port_route; in xhci_pci_attach()
329 sc->sc_imod_default = XHCI_IMOD_DEFAULT_LP; in xhci_pci_attach()
330 sc->sc_ctlstep = 1; in xhci_pci_attach()
339 sc->sc_io_res); in xhci_pci_attach()
345 usb_callout_init_mtx(&sc->sc_callout, &sc->sc_bus.bus_mtx, 0); in xhci_pci_attach()
350 sc->sc_msix_res = sc->sc_io_res; in xhci_pci_attach()
352 sc->sc_msix_res = bus_alloc_resource_any(self, in xhci_pci_attach()
354 if (sc->sc_msix_res == NULL) { in xhci_pci_attach()
357 "Unable to map MSI-X table\n"); in xhci_pci_attach()
360 if (sc->sc_msix_res != NULL) { in xhci_pci_attach()
364 device_printf(self, "MSI-X enabled\n"); in xhci_pci_attach()
367 if (sc->sc_msix_res != sc->sc_io_res) { in xhci_pci_attach()
370 msix_table, sc->sc_msix_res); in xhci_pci_attach()
372 sc->sc_msix_res = NULL; in xhci_pci_attach()
384 sc->sc_irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid, in xhci_pci_attach()
386 if (sc->sc_irq_res == NULL) { in xhci_pci_attach()
389 /* goto error; FALLTHROUGH - use polling */ in xhci_pci_attach()
391 sc->sc_bus.bdev = device_add_child(self, "usbus", DEVICE_UNIT_ANY); in xhci_pci_attach()
392 if (sc->sc_bus.bdev == NULL) { in xhci_pci_attach()
393 device_printf(self, "Could not add USB device\n"); in xhci_pci_attach()
396 device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); in xhci_pci_attach()
400 strlcpy(sc->sc_vendor, "AMD", sizeof(sc->sc_vendor)); in xhci_pci_attach()
403 strlcpy(sc->sc_vendor, "Intel", sizeof(sc->sc_vendor)); in xhci_pci_attach()
406 strlcpy(sc->sc_vendor, "VMware", sizeof(sc->sc_vendor)); in xhci_pci_attach()
409 strlcpy(sc->sc_vendor, "Zhaoxin", sizeof(sc->sc_vendor)); in xhci_pci_attach()
415 snprintf(sc->sc_vendor, sizeof(sc->sc_vendor), in xhci_pci_attach()
420 if (sc->sc_irq_res != NULL && xhci_use_polling() == 0) { in xhci_pci_attach()
421 err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, in xhci_pci_attach()
422 NULL, (driver_intr_t *)xhci_interrupt, sc, &sc->sc_intr_hdl); in xhci_pci_attach()
425 rman_get_rid(sc->sc_irq_res), sc->sc_irq_res); in xhci_pci_attach()
426 sc->sc_irq_res = NULL; in xhci_pci_attach()
429 sc->sc_intr_hdl = NULL; in xhci_pci_attach()
432 if (sc->sc_irq_res == NULL || sc->sc_intr_hdl == NULL) { in xhci_pci_attach()
435 USB_BUS_LOCK(&sc->sc_bus); in xhci_pci_attach()
437 USB_BUS_UNLOCK(&sc->sc_bus); in xhci_pci_attach()
450 err = device_probe_and_attach(sc->sc_bus.bdev); in xhci_pci_attach()
474 usb_callout_drain(&sc->sc_callout); in xhci_pci_detach()
480 if (sc->sc_irq_res && sc->sc_intr_hdl) { in xhci_pci_detach()
481 bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl); in xhci_pci_detach()
482 sc->sc_intr_hdl = NULL; in xhci_pci_detach()
484 if (sc->sc_irq_res) { in xhci_pci_detach()
486 rman_get_rid(sc->sc_irq_res), sc->sc_irq_res); in xhci_pci_detach()
487 sc->sc_irq_res = NULL; in xhci_pci_detach()
490 if (sc->sc_msix_res != NULL && sc->sc_msix_res != sc->sc_io_res) { in xhci_pci_detach()
492 rman_get_rid(sc->sc_msix_res), sc->sc_msix_res); in xhci_pci_detach()
493 sc->sc_msix_res = NULL; in xhci_pci_detach()
495 if (sc->sc_io_res) { in xhci_pci_detach()
497 sc->sc_io_res); in xhci_pci_detach()
498 sc->sc_io_res = NULL; in xhci_pci_detach()
518 eec = -1; in xhci_pci_take_controller()
520 /* Synchronise with the BIOS if it owns the controller. */ in xhci_pci_take_controller()
531 device_printf(sc->sc_bus.bdev, "waiting for BIOS " in xhci_pci_take_controller()
542 if (--to == 0) { in xhci_pci_take_controller()
543 device_printf(sc->sc_bus.bdev, in xhci_pci_take_controller()