Lines Matching +full:tegra124 +full:- +full:usb +full:- +full:phy
1 /*-
47 #include <dev/phy/phy.h>
50 #include <dev/usb/usb.h>
51 #include <dev/usb/usbdi.h>
52 #include <dev/usb/usb_busdma.h>
53 #include <dev/usb/usb_process.h>
54 #include <dev/usb/usb_controller.h>
55 #include <dev/usb/usb_bus.h>
56 #include <dev/usb/controller/ehci.h>
57 #include <dev/usb/controller/ehcireg.h>
68 {"nvidia,tegra124-ehci", (uintptr_t)TEGRA124_EHCI},
69 {"nvidia,tegra210-ehci", (uintptr_t)TEGRA210_EHCI},
80 phy_t phy; member
93 device_printf(ehci_softc->sc_bus.bdev, "set host controller mode\n"); in tegra_ehci_post_reset()
104 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data != 0) { in tegra_ehci_probe()
124 esc = &sc->ehci_softc; in tegra_ehci_detach()
125 if (sc->clk != NULL) in tegra_ehci_detach()
126 clk_release(sc->clk); in tegra_ehci_detach()
127 if (esc->sc_flags & EHCI_SCFLG_DONEINIT) in tegra_ehci_detach()
129 if (esc->sc_intr_hdl != NULL) in tegra_ehci_detach()
130 bus_teardown_intr(dev, esc->sc_irq_res, in tegra_ehci_detach()
131 esc->sc_intr_hdl); in tegra_ehci_detach()
132 if (sc->ehci_irq_res != NULL) in tegra_ehci_detach()
134 sc->ehci_irq_res); in tegra_ehci_detach()
135 if (sc->ehci_mem_res != NULL) in tegra_ehci_detach()
137 sc->ehci_mem_res); in tegra_ehci_detach()
138 if (sc->usb_alloc_called) in tegra_ehci_detach()
139 usb_bus_mem_free_all(&esc->sc_bus, &ehci_iterate_hw_softc); in tegra_ehci_detach()
153 sc->dev = dev; in tegra_ehci_attach()
154 esc = &sc->ehci_softc; in tegra_ehci_attach()
158 sc->ehci_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, in tegra_ehci_attach()
160 if (sc->ehci_mem_res == NULL) { in tegra_ehci_attach()
167 sc->ehci_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, in tegra_ehci_attach()
169 if (sc->ehci_irq_res == NULL) { in tegra_ehci_attach()
175 rv = hwreset_get_by_ofw_name(dev, 0, "usb", &sc->reset); in tegra_ehci_attach()
182 rv = phy_get_by_ofw_property(sc->dev, 0, "nvidia,phy", &sc->phy); in tegra_ehci_attach()
184 device_printf(sc->dev, "Cannot get 'nvidia,phy' phy\n"); in tegra_ehci_attach()
189 rv = clk_get_by_ofw_index(sc->dev, 0, 0, &sc->clk); in tegra_ehci_attach()
195 rv = clk_enable(sc->clk); in tegra_ehci_attach()
202 rv = clk_get_freq(sc->clk, &freq); in tegra_ehci_attach()
208 rv = hwreset_deassert(sc->reset); in tegra_ehci_attach()
215 rv = phy_enable(sc->phy); in tegra_ehci_attach()
217 device_printf(dev, "Cannot enable phy: %d\n", rv); in tegra_ehci_attach()
222 esc->sc_vendor_get_port_speed = ehci_get_port_speed_hostc; in tegra_ehci_attach()
223 esc->sc_vendor_post_reset = tegra_ehci_post_reset; in tegra_ehci_attach()
224 esc->sc_io_tag = rman_get_bustag(sc->ehci_mem_res); in tegra_ehci_attach()
225 esc->sc_bus.parent = dev; in tegra_ehci_attach()
226 esc->sc_bus.devices = esc->sc_devices; in tegra_ehci_attach()
227 esc->sc_bus.devices_max = EHCI_MAX_DEVICES; in tegra_ehci_attach()
228 esc->sc_bus.dma_bits = 32; in tegra_ehci_attach()
231 rv = usb_bus_mem_alloc_all(&esc->sc_bus, USB_GET_DMA_TAG(dev), in tegra_ehci_attach()
233 sc->usb_alloc_called = 1; in tegra_ehci_attach()
241 * Set handle to USB related registers subregion used by in tegra_ehci_attach()
244 rv = bus_space_subregion(esc->sc_io_tag, in tegra_ehci_attach()
245 rman_get_bushandle(sc->ehci_mem_res), in tegra_ehci_attach()
246 TEGRA_EHCI_REG_OFF, TEGRA_EHCI_REG_SIZE, &esc->sc_io_hdl); in tegra_ehci_attach()
248 device_printf(dev, "Could not create USB memory subregion\n"); in tegra_ehci_attach()
254 rv = bus_setup_intr(dev, sc->ehci_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, in tegra_ehci_attach()
255 NULL, (driver_intr_t *)ehci_interrupt, esc, &esc->sc_intr_hdl); in tegra_ehci_attach()
261 /* Add USB bus device. */ in tegra_ehci_attach()
262 esc->sc_bus.bdev = device_add_child(dev, "usbus", DEVICE_UNIT_ANY); in tegra_ehci_attach()
263 if (esc->sc_bus.bdev == NULL) { in tegra_ehci_attach()
264 device_printf(dev, "Could not add USB device\n"); in tegra_ehci_attach()
267 device_set_ivars(esc->sc_bus.bdev, &esc->sc_bus); in tegra_ehci_attach()
269 esc->sc_id_vendor = USB_VENDOR_FREESCALE; in tegra_ehci_attach()
270 strlcpy(esc->sc_vendor, "Nvidia", sizeof(esc->sc_vendor)); in tegra_ehci_attach()
273 esc->sc_flags |= EHCI_SCFLG_TT; in tegra_ehci_attach()
274 esc->sc_flags |= EHCI_SCFLG_NORESTERM; in tegra_ehci_attach()
277 device_printf(dev, "USB init failed: %d\n", in tegra_ehci_attach()
281 esc->sc_flags |= EHCI_SCFLG_DONEINIT; in tegra_ehci_attach()
284 rv = device_probe_and_attach(esc->sc_bus.bdev); in tegra_ehci_attach()
315 MODULE_DEPEND(tegra_ehci, usb, 1, 1, 1);