Lines Matching +full:generic +full:- +full:ehci

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2010-2012 Semihalf
53 #include <dev/usb/controller/ehci.h>
88 "ehci",
93 DRIVER_MODULE(ehci, simplebus, ehci_driver, 0, 0);
94 MODULE_DEPEND(ehci, usb, 1, 1, 1);
104 * Offsets from 0x000 ehci dev space, big-endian access.
131 * Offsets from USBCMD register, little-endian access.
156 tmp = bus_space_read_4(sc->sc_io_tag, sc->sc_io_hdl, USBMODE); in set_to_host_mode()
157 bus_space_write_4(sc->sc_io_tag, sc->sc_io_hdl, USBMODE, tmp | HOST_MODE); in set_to_host_mode()
200 tmp = bus_space_read_4(sc->sc_io_tag, sc->sc_io_hdl, PORTSC); in clear_port_power()
201 bus_space_write_4(sc->sc_io_tag, sc->sc_io_hdl, PORTSC, tmp & ~PORT_POWER_MASK); in clear_port_power()
214 if (((ofw_bus_is_compatible(dev, "fsl-usb2-dr")) == 0) && in fsl_ehci_probe()
215 ((ofw_bus_is_compatible(dev, "fsl-usb2-mph")) == 0)) in fsl_ehci_probe()
218 device_set_desc(dev, "Freescale integrated EHCI controller"); in fsl_ehci_probe()
235 sc->sc_bus.parent = self; in fsl_ehci_attach()
236 sc->sc_bus.devices = sc->sc_devices; in fsl_ehci_attach()
237 sc->sc_bus.devices_max = EHCI_MAX_DEVICES; in fsl_ehci_attach()
238 sc->sc_bus.dma_bits = 32; in fsl_ehci_attach()
240 if (usb_bus_mem_alloc_all(&sc->sc_bus, in fsl_ehci_attach()
244 /* Allocate io resource for EHCI */ in fsl_ehci_attach()
245 sc->sc_io_res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, in fsl_ehci_attach()
247 if (sc->sc_io_res == NULL) { in fsl_ehci_attach()
256 iot = rman_get_bustag(sc->sc_io_res); in fsl_ehci_attach()
259 * Set handle to USB related registers subregion used by generic in fsl_ehci_attach()
260 * EHCI driver in fsl_ehci_attach()
262 ioh = rman_get_bushandle(sc->sc_io_res); in fsl_ehci_attach()
265 &sc->sc_io_hdl); in fsl_ehci_attach()
276 /* Set little-endian tag for use by the generic EHCI driver */ in fsl_ehci_attach()
277 sc->sc_io_tag = &bs_le_tag; in fsl_ehci_attach()
280 sc->sc_irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid, in fsl_ehci_attach()
282 if (sc->sc_irq_res == NULL) { in fsl_ehci_attach()
293 err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, in fsl_ehci_attach()
294 NULL, (driver_intr_t *)ehci_interrupt, sc, &sc->sc_intr_hdl); in fsl_ehci_attach()
297 sc->sc_intr_hdl = NULL; in fsl_ehci_attach()
308 sc->sc_bus.bdev = device_add_child(self, "usbus", DEVICE_UNIT_ANY); in fsl_ehci_attach()
309 if (!sc->sc_bus.bdev) { in fsl_ehci_attach()
319 device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); in fsl_ehci_attach()
321 sc->sc_id_vendor = 0x1234; in fsl_ehci_attach()
322 strlcpy(sc->sc_vendor, "Freescale", sizeof(sc->sc_vendor)); in fsl_ehci_attach()
343 * If usb subsystem is enabled in U-Boot, port power has to be turned in fsl_ehci_attach()
349 sc->sc_flags |= EHCI_SCFLG_DONTRESET | EHCI_SCFLG_NORESTERM; in fsl_ehci_attach()
353 sc->sc_flags |= EHCI_SCFLG_DONEINIT; in fsl_ehci_attach()
354 err = device_probe_and_attach(sc->sc_bus.bdev); in fsl_ehci_attach()
386 if (sc->sc_flags & EHCI_SCFLG_DONEINIT) { in fsl_ehci_detach()
388 sc->sc_flags &= ~EHCI_SCFLG_DONEINIT; in fsl_ehci_detach()
392 if (sc->sc_io_tag && sc->sc_io_hdl) in fsl_ehci_detach()
393 bus_space_write_4(sc->sc_io_tag, sc->sc_io_hdl, EHCI_USBINTR, 0); in fsl_ehci_detach()
395 if (sc->sc_irq_res && sc->sc_intr_hdl) { in fsl_ehci_detach()
396 err = bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl); in fsl_ehci_detach()
402 sc->sc_intr_hdl = NULL; in fsl_ehci_detach()
405 if (sc->sc_irq_res) { in fsl_ehci_detach()
406 bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res); in fsl_ehci_detach()
407 sc->sc_irq_res = NULL; in fsl_ehci_detach()
410 if (sc->sc_io_res) { in fsl_ehci_detach()
411 bus_release_resource(self, SYS_RES_MEMORY, 0, sc->sc_io_res); in fsl_ehci_detach()
412 sc->sc_io_res = NULL; in fsl_ehci_detach()
413 sc->sc_io_tag = 0; in fsl_ehci_detach()
414 sc->sc_io_hdl = 0; in fsl_ehci_detach()