diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2005-01-04 03:47:01 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2005-01-04 03:47:01 +0000 |
commit | cea5f0848d694d341141486d49ecd38b8df23906 (patch) | |
tree | 4e901a1c57d83942d24ed553963ffb142806083d /sys/arch/arm | |
parent | 6aa828eec10dfc8e0ad231b12cf7bfc3363d5dd6 (diff) |
USB support for C3000, much thanks to dlg@ for pxa2x0_ohci.c
Diffstat (limited to 'sys/arch/arm')
-rw-r--r-- | sys/arch/arm/xscale/files.pxa2x0 | 10 | ||||
-rw-r--r-- | sys/arch/arm/xscale/pxa2x0_ohci.c | 145 |
2 files changed, 150 insertions, 5 deletions
diff --git a/sys/arch/arm/xscale/files.pxa2x0 b/sys/arch/arm/xscale/files.pxa2x0 index d7fff50047a..08f9ada7fa5 100644 --- a/sys/arch/arm/xscale/files.pxa2x0 +++ b/sys/arch/arm/xscale/files.pxa2x0 @@ -1,4 +1,4 @@ -# $OpenBSD: files.pxa2x0,v 1.3 2005/01/03 12:05:24 miod Exp $ +# $OpenBSD: files.pxa2x0,v 1.4 2005/01/04 03:47:00 drahn Exp $ # $NetBSD: files.pxa2x0,v 1.6 2004/05/01 19:09:14 thorpej Exp $ # # Configuration info for Intel PXA2[51]0 CPU support @@ -43,6 +43,10 @@ file arch/arm/xscale/pxa2x0_a4x_space.c pxauart | obio file arch/arm/xscale/pxa2x0_a4x_io.S pxauart | obio #defflag opt_com.h FFUARTCONSOLE STUARTCONSOLE BTUARTCONSOLE +# OHCI USB Controller +attach ohci at pxaip with pxaohci +file arch/arm/xscale/pxa2x0_ohci.c pxaohci + # LCD controller device lcd: wsemuldisplaydev, rasops16, rasops8, rasops4 file arch/arm/xscale/pxa2x0_lcd.c lcd needs-flag @@ -54,10 +58,6 @@ device pxapcic: pcmciabus attach pxapcic at pxaip file arch/arm/xscale/pxa2x0_pcic.c pxapcic -# onboard USB -attach ohci at pxaip with ohci_pxa -file arch/arm/xscale/pxa2x0_ohci.c ohci - # XXX this is a hack to use dev/pcmcia without fdc.c device fdc diff --git a/sys/arch/arm/xscale/pxa2x0_ohci.c b/sys/arch/arm/xscale/pxa2x0_ohci.c new file mode 100644 index 00000000000..ab6b115d111 --- /dev/null +++ b/sys/arch/arm/xscale/pxa2x0_ohci.c @@ -0,0 +1,145 @@ +/* $OpenBSD: pxa2x0_ohci.c,v 1.1 2005/01/04 03:47:00 drahn Exp $ */ + +/* + * Copyright (c) 2005 David Gwynne <dlg@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/cdefs.h> + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/device.h> +#include <sys/termios.h> + +#include <machine/intr.h> +#include <machine/bus.h> + +#include <arm/xscale/pxa2x0reg.h> +#include <arm/xscale/pxa2x0var.h> + +#include <dev/usb/usb.h> +#include <dev/usb/usbdi.h> +#include <dev/usb/usbdivar.h> +#include <dev/usb/usb_mem.h> + +#include <dev/usb/ohcireg.h> +#include <dev/usb/ohcivar.h> + +int pxaohci_match(struct device *, void *, void *); +void pxaohci_attach(struct device *, struct device *, void *); +int pxaohci_detach(device_ptr_t, int); + +struct pxaohci_softc { + ohci_softc_t sc; + void *sc_ih; + void *sc_ih1; + int sc_intr; +}; + +struct cfattach pxaohci_ca = { + sizeof (struct pxaohci_softc), pxaohci_match, pxaohci_attach, + pxaohci_detach, ohci_activate +}; + +int +pxaohci_match(struct device *parent, void *match, void *aux) +{ + struct pxaip_attach_args *pxa = aux; + + /* XXX if pxa revision != 270 return 0 */ + + if ((pxa->pxa_addr != PXA2X0_USBHC_BASE) || + (pxa->pxa_intr != PXA2X0_INT_USBH1)) + return (0); + + pxa->pxa_size = PXA2X0_USBHC_SIZE; /* XXX wtf? */ + + return (1); +} + +void +pxaohci_attach(struct device *parent, struct device *self, void *aux) +{ + struct pxaohci_softc *sc = (struct pxaohci_softc *)self; + struct pxaip_attach_args *pxa = aux; + usbd_status r; + + sc->sc.iot = pxa->pxa_iot; + sc->sc.sc_bus.dmatag = pxa->pxa_dmat; + sc->sc_intr = pxa->pxa_intr; + sc->sc_ih = NULL; + sc->sc_ih1 = NULL; + sc->sc.sc_size = 0; + + /* Map I/O space */ + if (bus_space_map(sc->sc.iot, pxa->pxa_addr, pxa->pxa_size, 0, + &sc->sc.ioh)) { + printf(": cannot map mem space\n"); + return; + } + sc->sc.sc_size = pxa->pxa_size; + + /* XXX copied from ohci_pci.c. needed? */ + bus_space_barrier(sc->sc.iot, sc->sc.ioh, 0, sc->sc.sc_size, + BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE); + /* Disable interrupts, so we don't get any spurious ones. */ + bus_space_write_4(sc->sc.iot, sc->sc.ioh, OHCI_INTERRUPT_DISABLE, + OHCI_MIE); + + /* XXX splusb? */ + sc->sc_ih = pxa2x0_intr_establish(sc->sc_intr, IPL_USB, ohci_intr, sc, + sc->sc.sc_bus.bdev.dv_xname); + sc->sc_ih1 = pxa2x0_intr_establish(2, IPL_USB, ohci_intr, sc, + sc->sc.sc_bus.bdev.dv_xname); + + strlcpy(sc->sc.sc_vendor, "Vendor String", sizeof(sc->sc.sc_vendor)); + + r = ohci_init(&sc->sc); + if (r != USBD_NORMAL_COMPLETION) { + printf("%s: init failed, error=%d\n", + sc->sc.sc_bus.bdev.dv_xname, r); + bus_space_unmap(sc->sc.iot, sc->sc.ioh, sc->sc.sc_size); + sc->sc.sc_size = 0; + /* XXX disestablish */ + return; + } + /* XXX splx(s) usb? */ + + sc->sc.sc_child = config_found((void *) sc, &sc->sc.sc_bus, + usbctlprint); +} + +int +pxaohci_detach(device_ptr_t self, int flags) +{ + struct pxaohci_softc *sc = (struct pxaohci_softc *)self; + int rv; + + rv = ohci_detach(&sc->sc, flags); + if (rv) + return (rv); +#ifdef notdef + if (sc->sc_ih != NULL) { + /* XXX disestablish */ + sc->sc_ih = NULL; + } +#endif + if (sc->sc.sc_size) { + bus_space_unmap(sc->sc.iot, sc->sc.ioh, sc->sc.sc_size); + sc->sc.sc_size = 0; + } + + return (0); +} |