Lines Matching +full:ssc +full:- +full:controller
1 /*-
62 #include <dev/usb/controller/musb_otg.h>
99 bus_write_4((sc)->sc_mem_res[idx], (reg), (val)); \
102 #define USB_READ4(sc, idx, reg) bus_read_4((sc)->sc_mem_res[idx], (reg))
112 { -1, 0, 0 }
141 if (sc->sc_otg.sc_mode == MUSB2_DEVICE_MODE) in musbotg_vbus_poll()
142 musbotg_vbus_interrupt(&sc->sc_otg, 1); in musbotg_vbus_poll()
145 musbotg_vbus_interrupt(&sc->sc_otg, stat & 1); in musbotg_vbus_poll()
159 struct musbotg_super_softc *ssc; in musbotg_clocks_on() local
163 ssc = sc->sc_platform_data; in musbotg_clocks_on()
165 reg = SYSCON_READ_4(ssc->syscon, USB_CTRL[sc->sc_id]); in musbotg_clocks_on()
170 SYSCON_WRITE_4(ssc->syscon, USB_CTRL[sc->sc_id], reg); in musbotg_clocks_on()
177 struct musbotg_super_softc *ssc; in musbotg_clocks_off() local
181 ssc = sc->sc_platform_data; in musbotg_clocks_off()
184 reg = SYSCON_READ_4(ssc->syscon, USB_CTRL[sc->sc_id]); in musbotg_clocks_off()
185 SYSCON_WRITE_4(ssc->syscon, USB_CTRL[sc->sc_id], reg | 3); in musbotg_clocks_off()
191 struct musbotg_super_softc *ssc = sc->sc_platform_data; in musbotg_ep_int_set() local
197 USBCTRL_WRITE4(ssc, USBCTRL_INTEN_SET0, epmask); in musbotg_ep_int_set()
199 USBCTRL_WRITE4(ssc, USBCTRL_INTEN_CLR0, epmask); in musbotg_ep_int_set()
206 struct musbotg_super_softc *ssc = sc->sc_platform_data; in musbotg_wrapper_interrupt() local
209 stat = USBCTRL_READ4(ssc, USBCTRL_STAT); in musbotg_wrapper_interrupt()
210 stat0 = USBCTRL_READ4(ssc, USBCTRL_IRQ_STAT0); in musbotg_wrapper_interrupt()
211 stat1 = USBCTRL_READ4(ssc, USBCTRL_IRQ_STAT1); in musbotg_wrapper_interrupt()
213 USBCTRL_WRITE4(ssc, USBCTRL_IRQ_STAT0, stat0); in musbotg_wrapper_interrupt()
215 USBCTRL_WRITE4(ssc, USBCTRL_IRQ_STAT1, stat1); in musbotg_wrapper_interrupt()
218 sc->sc_id, stat0, stat1, stat); in musbotg_wrapper_interrupt()
233 if (!ofw_bus_is_compatible(dev, "ti,musb-am33xx")) in musbotg_probe()
236 device_set_desc(dev, "TI AM33xx integrated USB OTG controller"); in musbotg_probe()
251 sc->sc_otg.sc_id = device_get_unit(dev); in musbotg_attach()
268 /* FIXME: For now; Go and kidnap syscon from opp-table */ in musbotg_attach()
269 opp_table = OF_finddevice("/opp-table"); in musbotg_attach()
270 if (opp_table == -1) { in musbotg_attach()
271 device_printf(dev, "Cant find /opp-table\n"); in musbotg_attach()
275 device_printf(dev, "/opp-table missing syscon property\n"); in musbotg_attach()
278 err = syscon_get_by_ofw_property(dev, opp_table, "syscon", &sc->syscon); in musbotg_attach()
286 sc->sc_mem_res); in musbotg_attach()
294 sc->sc_otg.sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, in musbotg_attach()
295 &sc->sc_irq_rid, RF_ACTIVE); in musbotg_attach()
296 if (sc->sc_otg.sc_irq_res == NULL) { in musbotg_attach()
302 /* setup MUSB OTG USB controller interface softc */ in musbotg_attach()
303 sc->sc_otg.sc_clocks_on = &musbotg_clocks_on; in musbotg_attach()
304 sc->sc_otg.sc_clocks_off = &musbotg_clocks_off; in musbotg_attach()
305 sc->sc_otg.sc_clocks_arg = &sc->sc_otg; in musbotg_attach()
307 sc->sc_otg.sc_ep_int_set = musbotg_ep_int_set; in musbotg_attach()
310 sc->sc_otg.sc_bus.parent = dev; in musbotg_attach()
311 sc->sc_otg.sc_bus.devices = sc->sc_otg.sc_devices; in musbotg_attach()
312 sc->sc_otg.sc_bus.devices_max = MUSB2_MAX_DEVICES; in musbotg_attach()
313 sc->sc_otg.sc_bus.dma_bits = 32; in musbotg_attach()
316 if (usb_bus_mem_alloc_all(&sc->sc_otg.sc_bus, in musbotg_attach()
322 sc->sc_otg.sc_io_res = sc->sc_mem_res[RES_USBCORE]; in musbotg_attach()
323 sc->sc_otg.sc_io_tag = in musbotg_attach()
324 rman_get_bustag(sc->sc_otg.sc_io_res); in musbotg_attach()
325 sc->sc_otg.sc_io_hdl = in musbotg_attach()
326 rman_get_bushandle(sc->sc_otg.sc_io_res); in musbotg_attach()
327 sc->sc_otg.sc_io_size = in musbotg_attach()
328 rman_get_size(sc->sc_otg.sc_io_res); in musbotg_attach()
330 sc->sc_otg.sc_bus.bdev = device_add_child(dev, "usbus", DEVICE_UNIT_ANY); in musbotg_attach()
331 if (!(sc->sc_otg.sc_bus.bdev)) { in musbotg_attach()
335 device_set_ivars(sc->sc_otg.sc_bus.bdev, in musbotg_attach()
336 &sc->sc_otg.sc_bus); in musbotg_attach()
338 err = bus_setup_intr(dev, sc->sc_otg.sc_irq_res, in musbotg_attach()
341 &sc->sc_otg, &sc->sc_otg.sc_intr_hdl); in musbotg_attach()
343 sc->sc_otg.sc_intr_hdl = NULL; in musbotg_attach()
349 sc->sc_otg.sc_platform_data = sc; in musbotg_attach()
353 sc->sc_otg.sc_mode = MUSB2_HOST_MODE; in musbotg_attach()
355 sc->sc_otg.sc_mode = MUSB2_DEVICE_MODE; in musbotg_attach()
358 if (sc->sc_otg.sc_id == 0) in musbotg_attach()
359 sc->sc_otg.sc_mode = MUSB2_DEVICE_MODE; in musbotg_attach()
361 sc->sc_otg.sc_mode = MUSB2_HOST_MODE; in musbotg_attach()
365 * software-controlled function in musbotg_attach()
368 if (sc->sc_otg.sc_mode == MUSB2_HOST_MODE) { in musbotg_attach()
386 err = musbotg_init(&sc->sc_otg); in musbotg_attach()
388 err = device_probe_and_attach(sc->sc_otg.sc_bus.bdev); in musbotg_attach()
414 if (sc->sc_otg.sc_irq_res && sc->sc_otg.sc_intr_hdl) { in musbotg_detach()
418 musbotg_uninit(&sc->sc_otg); in musbotg_detach()
420 bus_teardown_intr(dev, sc->sc_otg.sc_irq_res, in musbotg_detach()
421 sc->sc_otg.sc_intr_hdl); in musbotg_detach()
422 sc->sc_otg.sc_intr_hdl = NULL; in musbotg_detach()
425 usb_bus_mem_free_all(&sc->sc_otg.sc_bus, NULL); in musbotg_detach()
428 if (sc->sc_mem_res[0]) in musbotg_detach()
430 sc->sc_mem_res); in musbotg_detach()
432 if (sc->sc_otg.sc_irq_res) in musbotg_detach()
433 bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irq_rid, in musbotg_detach()
434 sc->sc_otg.sc_irq_res); in musbotg_detach()