X-Git-Url: https://uglyman.kremlin.cc/gitweb/gitweb.cgi?p=bbb-usb.git;a=blobdiff_plain;f=src%2Fsys%2Farch%2Farmv7%2Fomap%2Famusbss.c;h=53b16c2cfbe41d269510a62a3891af946c119105;hp=9d5abe665c3a06de380b5d97771bfc22f1bf8d6d;hb=22caf3ce3cdfe77a11086492ccd12b933a675ae8;hpb=efe0ef7bfeab92bb4b5e6df74cafd09debfb145e diff --git a/src/sys/arch/armv7/omap/amusbss.c b/src/sys/arch/armv7/omap/amusbss.c index 9d5abe6..53b16c2 100644 --- a/src/sys/arch/armv7/omap/amusbss.c +++ b/src/sys/arch/armv7/omap/amusbss.c @@ -22,6 +22,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * USB subsystem driver for am335x. Derived from FreeBSD version. */ #include @@ -84,22 +86,36 @@ int amusbss_debug = 20; struct amusbss_softc { struct device sc_dev; -// struct simplebus_softc sc_dev; +// struct simplebus_softc sc_sbus; bus_space_tag_t sc_iot; + void *sc_ih; + bus_dma_tag_t sc_dmat; bus_space_handle_t sc_ioh; + bus_size_t sc_ios; + bus_space_handle_t sc_ioh_dma_ctl; + bus_size_t sc_ios_dma_ctl; + bus_space_handle_t sc_ioh_dma_sched; + bus_size_t sc_ios_dma_sched; + bus_space_handle_t sc_ioh_queue; + bus_size_t sc_ios_queue; }; -/* core decl */ +/* XXX figure out what to do instead of this XXX */ +extern void simplebus_attach_node(struct device *, int); + +/* core decl */ int amusbss_match(struct device *, void *, void *); void amusbss_attach(struct device *, struct device *, void *); int amusbss_detach(struct device *, int); void amusbss_reset(struct amusbss_softc *); -/* debug decl */ +void amusbss_map_dma(int); + +/* debug decl */ void amusbss_preg(uint32_t, char *, struct amusbss_softc *); void amusbss_dumpregs(struct amusbss_softc *); -/* core/iomux.c def */ +/* core/iomux.c defs */ struct cfattach amusbss_ca = { sizeof (struct amusbss_softc), amusbss_match, amusbss_attach, amusbss_detach }; @@ -112,7 +128,6 @@ int amusbss_match(struct device *parent, void *v, void *aux) { struct fdt_attach_args *faa = aux; -panic("its openbsd"); return OF_is_compatible(faa->fa_node, "ti,am33xx-usb"); } @@ -121,18 +136,15 @@ amusbss_attach(struct device *parent, struct device *self, void *args) { struct amusbss_softc *sc = (struct amusbss_softc *) self; struct fdt_attach_args *faa = args; - int i, node; uint32_t rev; -// struct fdt_attach_args -// char *name - sc->sc_iot = faa->fa_iot; if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, faa->fa_reg[0].size, 0, &sc->sc_ioh)) panic("%s: bus_space_map failed!", __func__); + sc->sc_ios = faa->fa_reg[0].size; /* Enable device clocks */ prcm_enablemodule(PRCM_USB); @@ -152,15 +164,38 @@ amusbss_attach(struct device *parent, struct device *self, void *args) rev = HREAD4(sc, USBSS_REVREG); printf(": rev %d.%d\n", rev >> 4 &0xf, rev & 0xf); - /* Walk the OFW tree and attach top-level devices */ + //faa->fa_node = node; + //simplebus_attach(parent, &sc->sc_sbus.sc_dev, faa); + + /* Walk FDT child nodes to attach ammusb devices, map DMA controllers */ for (node = OF_child(faa->fa_node); node > 0; node = OF_peer(node)) { - + if (OF_is_compatible(node, "ti,am3359-cppi41")) { + amusbss_map_dma(node); + } else { + simplebus_attach_node(parent, node); + } } } int amusbss_detach(struct device *self, int flags) { - return 0; /* XXX */ + struct amusbss_softc *sc = (struct amusbss_softc *) self; + + bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios); + + if (sc->sc_ioh_dma_ctl) + bus_space_unmap(sc->sc_iot, sc->sc_ioh_dma_ctl, sc->sc_ios_dma_ctl); + if (sc->sc_ioh_dma_sched) + bus_space_unmap(sc->sc_iot, sc->sc_ioh_dma_sched, sc->sc_ios_dma_sched); + if (sc->sc_ioh_queue) + bus_space_unmap(sc->sc_iot, sc->sc_ioh_queue, sc->sc_ios_queue); + + return 0; } +void +amusbss_map_dma(int node) +{ + /* XXX TODO */ +}