diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/sbus/files.sbus | 6 | ||||
-rw-r--r-- | sys/dev/sbus/sbusvar.h | 5 | ||||
-rw-r--r-- | sys/dev/sbus/xbox.c | 171 | ||||
-rw-r--r-- | sys/dev/sbus/xboxreg.h | 72 | ||||
-rw-r--r-- | sys/dev/sbus/xboxvar.h | 44 |
5 files changed, 293 insertions, 5 deletions
diff --git a/sys/dev/sbus/files.sbus b/sys/dev/sbus/files.sbus index 08b89e1415e..67572e5d9f9 100644 --- a/sys/dev/sbus/files.sbus +++ b/sys/dev/sbus/files.sbus @@ -1,4 +1,4 @@ -# $OpenBSD: files.sbus,v 1.28 2004/11/29 18:12:51 miod Exp $ +# $OpenBSD: files.sbus,v 1.29 2005/03/05 01:44:52 miod Exp $ # $NetBSD: files.sbus,v 1.16 2000/12/08 17:29:12 martin Exp $ # # Config file and device description for machine-independent SBUS code. @@ -122,3 +122,7 @@ device stp: pcmciabus attach stp at sbus with stp_sbus file dev/sbus/stp4020.c stp +# ``XBox'' SBus Expansion +device xbox {} +attach xbox at sbus +file dev/sbus/xbox.c xbox diff --git a/sys/dev/sbus/sbusvar.h b/sys/dev/sbus/sbusvar.h index 712e958c1d1..b7a8525a181 100644 --- a/sys/dev/sbus/sbusvar.h +++ b/sys/dev/sbus/sbusvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sbusvar.h,v 1.7 2003/02/17 01:29:21 henric Exp $ */ +/* $OpenBSD: sbusvar.h,v 1.8 2005/03/05 01:44:52 miod Exp $ */ /* $NetBSD: sbusvar.h,v 1.11 2000/11/01 06:18:45 eeh Exp $ */ /*- @@ -99,9 +99,6 @@ struct sbus_attach_args { int sa_frequency; /* SBus clockrate */ }; -/* sbus_attach_internal() is also used from obio.c */ -void sbus_attach_common(struct sbus_softc *, char *, int, - const char * const *); int sbus_print(void *, const char *); void sbus_establish(struct sbusdev *, struct device *); diff --git a/sys/dev/sbus/xbox.c b/sys/dev/sbus/xbox.c new file mode 100644 index 00000000000..4b23dd15b79 --- /dev/null +++ b/sys/dev/sbus/xbox.c @@ -0,0 +1,171 @@ +/* $OpenBSD: xbox.c,v 1.1 2005/03/05 01:44:52 miod Exp $ */ + +/* + * Copyright (c) 1999 Jason L. Wright (jason@thought.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT 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. + */ + +/* + * Driver for the Sun SBus Expansion Subsystem + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/errno.h> +#include <sys/ioctl.h> +#include <sys/syslog.h> +#include <sys/device.h> +#include <sys/malloc.h> + +#include <machine/autoconf.h> +#include <machine/bus.h> +#include <machine/cpu.h> +#include <dev/sbus/sbusvar.h> + +#include <dev/sbus/xboxreg.h> +#include <dev/sbus/xboxvar.h> + +int xboxmatch(struct device *, void *, void *); +void xboxattach(struct device *, struct device *, void *); +int xboxprint(void *, const char *); +int xbox_fix_range(struct xbox_softc *sc, struct sbus_softc *sbp); + +struct cfattach xbox_ca = { + sizeof (struct xbox_softc), xboxmatch, xboxattach +}; + +struct cfdriver xbox_cd = { + NULL, "xbox", DV_IFNET +}; + +int +xboxmatch(struct device *parent, void *cf, void *aux) +{ + struct sbus_attach_args *sa = aux; + + if (strcmp("SUNW,xbox", sa->sa_name)) + return (0); + + return (1); +} + +void +xboxattach(struct device *parent, struct device *self, void *aux) +{ + struct xbox_softc *sc = (struct xbox_softc *)self; + struct sbus_attach_args *sa = aux; + int node = sa->sa_node; + struct xbox_attach_args xa; + bus_space_handle_t write0; + char *s; + + s = getpropstring(node, "model"); + printf(": model %s", s); + + s = getpropstring(node, "child-present"); + if (strcmp(s, "false") == 0) { + printf(": no devices\n"); + return; + } + + sc->sc_key = getpropint(node, "write0-key", -1); + sc->sc_node = node; + + /* + * Setup transparent access + */ + + if (sbus_bus_map(sa->sa_bustag, sa->sa_reg[0].sbr_slot, + sa->sa_reg[0].sbr_offset, sa->sa_reg[0].sbr_size, 0, 0, + &write0) != 0) { + printf(": couldn't map write 0 register\n"); + return; + } + + bus_space_write_4(sa->sa_bustag, write0, 0, + (sc->sc_key << 24) | XAC_CTL1_OFFSET | + XBOX_CTL1_CSIE | XBOX_CTL1_TRANSPARENT); + bus_space_write_4(sa->sa_bustag, write0, 0, + (sc->sc_key << 24) | XBC_CTL1_OFFSET | + XBOX_CTL1_XSIE | XBOX_CTL1_XSBRE | XBOX_CTL1_XSSE); + DELAY(100); + + bus_space_unmap(sa->sa_bustag, write0, sa->sa_reg[0].sbr_size); + + sbus_establish(&sc->sc_sd, &sc->sc_dev); + + printf("\n"); + + if (xbox_fix_range(sc, (struct sbus_softc *)parent) != 0) + return; + + bzero(&xa, sizeof xa); + xa.xa_name = "sbus"; + xa.xa_node = node; + xa.xa_bustag = sa->sa_bustag; + xa.xa_dmatag = sa->sa_dmatag; + + (void)config_found(&sc->sc_dev, (void *)&xa, xboxprint); +} + +/* + * Fix up our address ranges based on parent address spaces. + */ +int +xbox_fix_range(struct xbox_softc *sc, struct sbus_softc *sbp) +{ + int error, i, j; + + error = getprop(sc->sc_node, "ranges", sizeof(struct sbus_range), + &sc->sc_nrange, (void **)&sc->sc_range); + if (error != 0) { + printf("%s: PROM ranges too large\n", sc->sc_dev.dv_xname); + return (error); + } + + for (i = 0; i < sc->sc_nrange; i++) { + for (j = 0; j < sbp->sc_nrange; j++) { + if (sc->sc_range[i].pspace == sbp->sc_range[j].cspace) { + sc->sc_range[i].poffset += + sbp->sc_range[j].poffset; + sc->sc_range[i].pspace = + sbp->sc_range[j].pspace; + break; + } + } + } + + return (0); +} + +int +xboxprint(void *args, const char *bus) +{ + struct xbox_attach_args *xa = args; + + if (bus != NULL) + printf("%s at %s", xa->xa_name, bus); + return (UNCONF); +} diff --git a/sys/dev/sbus/xboxreg.h b/sys/dev/sbus/xboxreg.h new file mode 100644 index 00000000000..6b02e1c8399 --- /dev/null +++ b/sys/dev/sbus/xboxreg.h @@ -0,0 +1,72 @@ +/* $OpenBSD: xboxreg.h,v 1.1 2005/03/05 01:44:52 miod Exp $ */ + +/* + * Copyright (c) 1999 Jason L. Wright (jason@thought.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT 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. + */ + +#define X_WRITE0_OFFSET 0 + +#define XAC_ERR_OFFSET 0x2000 +#define XAC_CTL0_OFFSET 0x100000 /* control reg 0 */ +#define XAC_CTL1_OFFSET 0x110000 /* control reg 1 */ +#define XAC_ELUA_OFFSET 0x120000 +#define XAC_ELLA_OFFSET 0x130000 +#define XAC_ERR_EN_OFFSET 0x140000 /* error enable */ + +#define XBC_ERR_OFFSET 0x420000 +#define XBC_CTL0_OFFSET 0x500000 /* control reg 0 */ +#define XBC_CTL1_OFFSET 0x510000 /* control reg 1 */ +#define XBC_ELUA_OFFSET 0x520000 +#define XBC_ELLA_OFFSET 0x530000 +#define XBC_ERR_EN_OFFSET 0x540000 /* error enable */ + +/* + * Error registers + */ + +#define XERR_DESCR 0 /* error descriptor */ +#define XERR_VA 4 /* error virtual addr */ +#define XERR_STAT 8 /* error status */ + +/* + * Control register 1 + */ +#define XBOX_CTL1_CDPTE1 0x8000 /* cable data parity test enb */ +#define XBOX_CTL1_CRTE 0x4000 /* cable rerun test enb */ +#define XBOX_CTL1_SRST 0x3000 /* software reset mask */ +#define XBOX_CTL1_SRST_XARS 0x1000 +#define XBOX_CTL1_SRST_CRES 0x2000 +#define XBOX_CTL1_SRST_HRES 0x3000 +#define XBOX_CTL1_DTE 0x0800 /* dvma test enb */ +#define XBOX_CTL1_CDPTE 0x0400 /* cable data parity test enb */ +#define XBOX_CTL1_ITE 0x0200 /* interrupt test enb */ +#define XBOX_CTL1_CDPTE0 0x0100 /* cable data parity test enb, dpr0 */ +#define XBOX_CTL1_ELDS 0x00c0 /* error log dvma size */ +#define XBOX_CTL1_XSSE 0x0020 /* expansion sbus slot select enb */ +#define XBOX_CTL1_XSBRE 0x0010 /* expansion sbus bus request enb */ +#define XBOX_CTL1_XSIE 0x0008 /* expansion sbus interrupt enb */ +#define XBOX_CTL1_ELDE 0x0004 /* error log dvma enable */ +#define XBOX_CTL1_CSIE 0x0002 /* cable serial interrupt enb */ +#define XBOX_CTL1_TRANSPARENT 0x0001 /* transparent mode enb */ diff --git a/sys/dev/sbus/xboxvar.h b/sys/dev/sbus/xboxvar.h new file mode 100644 index 00000000000..dc2ec0a8cf2 --- /dev/null +++ b/sys/dev/sbus/xboxvar.h @@ -0,0 +1,44 @@ +/* $OpenBSD: xboxvar.h,v 1.1 2005/03/05 01:44:52 miod Exp $ */ + +/* + * Copyright (c) 1999 Jason L. Wright (jason@thought.net) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT 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. + */ + +struct xbox_attach_args { + bus_space_tag_t xa_bustag; + bus_dma_tag_t xa_dmatag; + char *xa_name; + int xa_node; +}; + +struct xbox_softc { + struct device sc_dev; /* base device */ + struct sbusdev sc_sd; /* sbus device */ + u_int32_t sc_key; /* device key */ + int sc_node; /* sbus node */ + int sc_attached; /* has sbus attached? */ + int sc_nrange; /* number of ranges */ + struct sbus_range *sc_range; /* address ranges */ +}; |