Changeset View
Changeset View
Standalone View
Standalone View
head/sys/mips/mediatek/mtk_dotg.c
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | dotg_fdt_attach(device_t dev) | ||||
struct dwc_otg_softc *sc = device_get_softc(dev); | struct dwc_otg_softc *sc = device_get_softc(dev); | ||||
int err, rid; | int err, rid; | ||||
/* setup controller interface softc */ | /* setup controller interface softc */ | ||||
/* initialise some bus fields */ | /* initialise some bus fields */ | ||||
sc->sc_mode = DWC_MODE_HOST; | sc->sc_mode = DWC_MODE_HOST; | ||||
sc->sc_bus.parent = dev; | sc->sc_bus.parent = dev; | ||||
sc->sc_bus.devices = sc->sc_devices; | |||||
sc->sc_bus.devices_max = DWC_OTG_MAX_DEVICES; | |||||
sc->sc_bus.dma_bits = 32; | |||||
/* get all DMA memory */ | |||||
if (usb_bus_mem_alloc_all(&sc->sc_bus, | |||||
USB_GET_DMA_TAG(dev), NULL)) { | |||||
printf("No mem\n"); | |||||
return (ENOMEM); | |||||
} | |||||
rid = 0; | rid = 0; | ||||
sc->sc_io_res = | sc->sc_io_res = | ||||
bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); | bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); | ||||
if (!(sc->sc_io_res)) { | if (!(sc->sc_io_res)) { | ||||
printf("Can`t alloc MEM\n"); | printf("Can`t alloc MEM\n"); | ||||
goto error; | goto error; | ||||
} | } | ||||
sc->sc_io_tag = rman_get_bustag(sc->sc_io_res); | |||||
sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res); | |||||
sc->sc_io_size = rman_get_size(sc->sc_io_res); | |||||
rid = 0; | rid = 0; | ||||
sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, | sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, | ||||
&rid, RF_ACTIVE); | &rid, RF_ACTIVE); | ||||
if (!(sc->sc_irq_res)) { | if (!(sc->sc_irq_res)) { | ||||
printf("Can`t alloc IRQ\n"); | printf("Can`t alloc IRQ\n"); | ||||
goto error; | goto error; | ||||
} | } | ||||
sc->sc_bus.bdev = device_add_child(dev, "usbus", -1); | sc->sc_bus.bdev = device_add_child(dev, "usbus", -1); | ||||
if (!(sc->sc_bus.bdev)) { | if (!(sc->sc_bus.bdev)) { | ||||
printf("Can`t add usbus\n"); | printf("Can`t add usbus\n"); | ||||
goto error; | goto error; | ||||
} | } | ||||
device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); | device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); | ||||
err = bus_setup_intr(dev, sc->sc_irq_res, | |||||
INTR_TYPE_TTY | INTR_MPSAFE, dwc_otg_filter_interrupt, | |||||
dwc_otg_interrupt, sc, &sc->sc_intr_hdl); | |||||
if (err) { | |||||
sc->sc_intr_hdl = NULL; | |||||
printf("Can`t set IRQ handle\n"); | |||||
goto error; | |||||
} | |||||
err = dwc_otg_init(sc); | err = dwc_otg_init(sc); | ||||
if (err) printf("dotg_init fail\n"); | if (err) printf("dotg_init fail\n"); | ||||
if (!err) { | if (!err) { | ||||
err = device_probe_and_attach(sc->sc_bus.bdev); | err = device_probe_and_attach(sc->sc_bus.bdev); | ||||
if (err) printf("device_probe_and_attach fail %d\n", err); | if (err) printf("device_probe_and_attach fail %d\n", err); | ||||
} | } | ||||
if (err) { | if (err) { | ||||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |