Lines Matching +full:usb +full:- +full:host

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
35 * FDT attachment driver for the USB Enhanced Host Controller.
62 #include <dev/usb/usb.h>
63 #include <dev/usb/usbdi.h>
65 #include <dev/usb/usb_core.h>
66 #include <dev/usb/usb_busdma.h>
67 #include <dev/usb/usb_process.h>
68 #include <dev/usb/usb_util.h>
70 #include <dev/usb/usb_controller.h>
71 #include <dev/usb/usb_bus.h>
72 #include <dev/usb/controller/ehci.h>
73 #include <dev/usb/controller/ehcireg.h>
81 #define EHCI_HC_DEVSTR "Marvell Integrated USB 2.0 controller"
91 /* EHCI HC regs start at this offset within USB range */
110 {"mrvl,usb-ehci", HWTYPE_MV_EHCI_V1},
111 {"marvell,orion-ehci", HWTYPE_MV_EHCI_V2},
112 {"marvell,armada-3700-ehci", HWTYPE_MV_EHCI_V2},
121 /* Force HOST mode */ in mv_ehci_post_reset()
135 if (!ofw_bus_search_compatible(self, compat_data)->ocd_data) in mv_ehci_probe()
153 sc->sc_bus.parent = self; in mv_ehci_attach()
154 sc->sc_bus.devices = sc->sc_devices; in mv_ehci_attach()
155 sc->sc_bus.devices_max = EHCI_MAX_DEVICES; in mv_ehci_attach()
156 sc->sc_bus.dma_bits = 32; in mv_ehci_attach()
158 hwtype = ofw_bus_search_compatible(self, compat_data)->ocd_data; in mv_ehci_attach()
165 if (usb_bus_mem_alloc_all(&sc->sc_bus, in mv_ehci_attach()
171 sc->sc_io_res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, RF_ACTIVE); in mv_ehci_attach()
172 if (!sc->sc_io_res) { in mv_ehci_attach()
176 sc->sc_io_tag = rman_get_bustag(sc->sc_io_res); in mv_ehci_attach()
177 bsh = rman_get_bushandle(sc->sc_io_res); in mv_ehci_attach()
178 sc->sc_io_size = rman_get_size(sc->sc_io_res) - MV_USB_HOST_OFST; in mv_ehci_attach()
181 * Marvell EHCI host controller registers start at certain offset in mv_ehci_attach()
182 * within the whole USB registers range, so create a subregion for the in mv_ehci_attach()
183 * host mode configuration purposes. in mv_ehci_attach()
186 if (bus_space_subregion(sc->sc_io_tag, bsh, MV_USB_HOST_OFST, in mv_ehci_attach()
187 sc->sc_io_size, &sc->sc_io_hdl) != 0) in mv_ehci_attach()
188 panic("%s: unable to subregion USB host registers", in mv_ehci_attach()
206 * -- refer to DTS for the right resource number to use here. in mv_ehci_attach()
208 sc->sc_irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid, in mv_ehci_attach()
210 if (sc->sc_irq_res == NULL) { in mv_ehci_attach()
215 sc->sc_bus.bdev = device_add_child(self, "usbus", DEVICE_UNIT_ANY); in mv_ehci_attach()
216 if (!sc->sc_bus.bdev) { in mv_ehci_attach()
217 device_printf(self, "Could not add USB device\n"); in mv_ehci_attach()
220 device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); in mv_ehci_attach()
221 device_set_desc(sc->sc_bus.bdev, EHCI_HC_DEVSTR); in mv_ehci_attach()
223 sprintf(sc->sc_vendor, "Marvell"); in mv_ehci_attach()
239 err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, in mv_ehci_attach()
240 NULL, (driver_intr_t *)ehci_interrupt, sc, &sc->sc_intr_hdl); in mv_ehci_attach()
243 sc->sc_intr_hdl = NULL; in mv_ehci_attach()
250 * an undefined state (neither host nor agent), so it needs to be set in mv_ehci_attach()
253 * Refer to errata document MV-S500832-00D.pdf (p. 5.24 GL USB-2) for in mv_ehci_attach()
256 sc->sc_vendor_post_reset = mv_ehci_post_reset; in mv_ehci_attach()
258 device_printf(self, "5.24 GL USB-2 workaround enabled\n"); in mv_ehci_attach()
261 sc->sc_flags |= EHCI_SCFLG_TT | EHCI_SCFLG_NORESTERM; in mv_ehci_attach()
262 sc->sc_vendor_get_port_speed = ehci_get_port_speed_portsc; in mv_ehci_attach()
265 err = device_probe_and_attach(sc->sc_bus.bdev); in mv_ehci_attach()
268 device_printf(self, "USB init failed err=%d\n", err); in mv_ehci_attach()
292 if (sc->sc_io_res) { in mv_ehci_detach()
295 if (sc->sc_irq_res && sc->sc_intr_hdl) { in mv_ehci_detach()
301 err = bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl); in mv_ehci_detach()
307 sc->sc_intr_hdl = NULL; in mv_ehci_detach()
321 if (sc->sc_irq_res) { in mv_ehci_detach()
322 bus_release_resource(self, SYS_RES_IRQ, 1, sc->sc_irq_res); in mv_ehci_detach()
323 sc->sc_irq_res = NULL; in mv_ehci_detach()
325 if (sc->sc_io_res) { in mv_ehci_detach()
327 sc->sc_io_res); in mv_ehci_detach()
328 sc->sc_io_res = NULL; in mv_ehci_detach()
330 usb_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc); in mv_ehci_detach()
343 printf("USB error: "); in err_intr()
351 printf("host underflow\n"); in err_intr()
353 printf("host overflow\n"); in err_intr()
384 MODULE_DEPEND(ehci_mv, usb, 1, 1, 1);