summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/man/man4/man4.sparc64/Makefile4
-rw-r--r--share/man/man4/man4.sparc64/intro.46
-rw-r--r--share/man/man4/man4.sparc64/xbox.450
-rw-r--r--share/man/man4/sbus.46
-rw-r--r--sys/arch/sparc64/conf/GENERIC6
-rw-r--r--sys/arch/sparc64/conf/RAMDISK6
-rw-r--r--sys/arch/sparc64/conf/RAMDISKU16
-rw-r--r--sys/arch/sparc64/conf/files.sparc645
-rw-r--r--sys/arch/sparc64/dev/sbus.c170
-rw-r--r--sys/arch/sparc64/dev/sbusvar.h3
-rw-r--r--sys/dev/sbus/files.sbus6
-rw-r--r--sys/dev/sbus/sbusvar.h5
-rw-r--r--sys/dev/sbus/xbox.c171
-rw-r--r--sys/dev/sbus/xboxreg.h72
-rw-r--r--sys/dev/sbus/xboxvar.h44
15 files changed, 492 insertions, 68 deletions
diff --git a/share/man/man4/man4.sparc64/Makefile b/share/man/man4/man4.sparc64/Makefile
index 4741e8c45e7..21520f8c202 100644
--- a/share/man/man4/man4.sparc64/Makefile
+++ b/share/man/man4/man4.sparc64/Makefile
@@ -1,11 +1,11 @@
-# $OpenBSD: Makefile,v 1.41 2004/11/29 18:12:50 miod Exp $
+# $OpenBSD: Makefile,v 1.42 2005/03/05 01:44:50 miod Exp $
MAN= agten.4 apio.4 asio.4 audioce.4 audiocs.4 autoconf.4 auxio.4 \
be.4 beeper.4 bwtwo.4 \
central.4 cgsix.4 cgthree.4 clkbrd.4 clock.4 comkbd.4 creator.4 \
ebus.4 esp.4 fhc.4 intro.4 le.4 magma.4 mem.4 mgx.4 openprom.4 \
pcons.4 psycho.4 qe.4 qec.4 rfx.4 sab.4 schizo.4 spif.4 \
- timer.4 tvtwo.4 upa.4 uperf.4 vgafb.4 vigra.4 zs.4 zx.4
+ timer.4 tvtwo.4 upa.4 uperf.4 vgafb.4 vigra.4 xbox.4 zs.4 zx.4
MLINKS= clock.4 rtc.4 \
le.4 lebuffer.4 le.4 ledma.4 \
mem.4 kmem.4 \
diff --git a/share/man/man4/man4.sparc64/intro.4 b/share/man/man4/man4.sparc64/intro.4
index 22aa36172ed..961c3930b9b 100644
--- a/share/man/man4/man4.sparc64/intro.4
+++ b/share/man/man4/man4.sparc64/intro.4
@@ -1,9 +1,9 @@
-.\" $OpenBSD: intro.4,v 1.42 2004/11/29 18:12:50 miod Exp $
+.\" $OpenBSD: intro.4,v 1.43 2005/03/05 01:44:50 miod Exp $
.\"
.\" Copyright (c) 2001-2002 The OpenBSD Project
.\" All Rights Reserved.
.\"
-.Dd November 29, 2004
+.Dd March 4, 2005
.Dt INTRO 4 sparc64
.Os
.Sh NAME
@@ -190,6 +190,8 @@ PCI graphics frame buffer.
8 bit SBus color framebuffer with VGA-compatible modes and connector.
.It Xr wi 4
WaveLAN/IEEE, PRISM 2-3 and Spectrum24 802.11B wireless network adapters.
+.It Xr xbox 4
+SBus Expansion subsystem.
.It Xr xl 4
xl 3Com EtherLink XL and Fast EtherLink XL Ethernet driver.
.It Xr zs/zstty/zskbd 4
diff --git a/share/man/man4/man4.sparc64/xbox.4 b/share/man/man4/man4.sparc64/xbox.4
new file mode 100644
index 00000000000..85ee4cd78a3
--- /dev/null
+++ b/share/man/man4/man4.sparc64/xbox.4
@@ -0,0 +1,50 @@
+.\" $OpenBSD: xbox.4,v 1.1 2005/03/05 01:44:50 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.
+.\"
+.Dd March 4, 2005
+.Dt XBOX 4 sparc64
+.Os
+.Sh NAME
+.Nm xbox
+.Nd SPARC SBus Expansion Subsystem
+.Sh SYNOPSIS
+.Cd "xbox* at sbus?"
+.Cd "sbus* at xbox?"
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for the Sun SBus Expansion Subsystem.
+This device consists of an SBus card and a chassis which has
+three additional SBus slots.
+.Sh SEE ALSO
+.Xr intro 4 ,
+.Xr sbus 4
+.Sh BUGS
+DMA support through
+.Nm
+is currently not implemented.
+This means that SBus devices using DMA (such as SCSI and some Ethernet
+controllers) will not attach correctly, and will not work.
diff --git a/share/man/man4/sbus.4 b/share/man/man4/sbus.4
index c3476b6e79a..9291f4b5570 100644
--- a/share/man/man4/sbus.4
+++ b/share/man/man4/sbus.4
@@ -1,4 +1,4 @@
-.\" $OpenBSD: sbus.4,v 1.26 2004/09/23 18:28:50 jason Exp $
+.\" $OpenBSD: sbus.4,v 1.27 2005/03/05 01:44:48 miod Exp $
.\" $NetBSD: sbus.4,v 1.5 2002/01/21 17:54:10 wiz Exp $
.\"
.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd February 29, 2004
+.Dd March 4, 2005
.Dt SBUS 4
.Os
.Sh NAME
@@ -171,6 +171,8 @@ Realtime clock.
Prestoserve battery-backed memory.
.It Xr uperf 4
Performance counters on the host bridge.
+.It Xr xbox 4
+SBus Expansion subsystem.
.El
.Sh SEE ALSO
.Xr agten 4 ,
diff --git a/sys/arch/sparc64/conf/GENERIC b/sys/arch/sparc64/conf/GENERIC
index a79896f2052..96ef6a23b6f 100644
--- a/sys/arch/sparc64/conf/GENERIC
+++ b/sys/arch/sparc64/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.117 2005/02/15 11:03:46 jsg Exp $
+# $OpenBSD: GENERIC,v 1.118 2005/03/05 01:44:52 miod Exp $
# $NetBSD: GENERIC32,v 1.18 2001/07/20 00:07:12 eeh Exp $
machine sparc64
@@ -315,6 +315,10 @@ pcmcia* at stp?
wi* at pci? # WaveLAN IEEE 802.11DS
wi* at pcmcia? # WaveLAN IEEE 802.11DS
+# ``XBox'' SBus Expansion
+xbox* at sbus?
+sbus* at xbox?
+
#pseudo-device hotplug 1 # devices hot plugging
# mouse & keyboard multiplexor pseudo-devices
diff --git a/sys/arch/sparc64/conf/RAMDISK b/sys/arch/sparc64/conf/RAMDISK
index 6b0ed05a48d..be612cd7bf8 100644
--- a/sys/arch/sparc64/conf/RAMDISK
+++ b/sys/arch/sparc64/conf/RAMDISK
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISK,v 1.38 2005/02/15 11:03:46 jsg Exp $
+# $OpenBSD: RAMDISK,v 1.39 2005/03/05 01:44:52 miod Exp $
# Machine architecture; required by config(8)
machine sparc64
@@ -191,6 +191,10 @@ creator* at mainbus0
creator* at upa0
wsdisplay* at creator?
+# ``XBox'' SBus Expansion
+xbox* at sbus?
+sbus* at xbox?
+
## PROM console driver -- if all else fails
pcons0 at mainbus0 # PROM console
diff --git a/sys/arch/sparc64/conf/RAMDISKU1 b/sys/arch/sparc64/conf/RAMDISKU1
index 8af407452c0..ec0fdaed2cf 100644
--- a/sys/arch/sparc64/conf/RAMDISKU1
+++ b/sys/arch/sparc64/conf/RAMDISKU1
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISKU1,v 1.12 2004/11/29 18:12:50 miod Exp $
+# $OpenBSD: RAMDISKU1,v 1.13 2005/03/05 01:44:52 miod Exp $
# Machine architecture; required by config(8)
machine sparc64
@@ -103,6 +103,10 @@ wsdisplay* at vigra?
creator* at mainbus0
wsdisplay* at creator?
+# ``XBox'' SBus Expansion
+xbox* at sbus?
+sbus* at xbox?
+
## PROM console driver -- if all else fails
pcons0 at mainbus0 # PROM console
diff --git a/sys/arch/sparc64/conf/files.sparc64 b/sys/arch/sparc64/conf/files.sparc64
index ebc7f74b786..fba2af7a805 100644
--- a/sys/arch/sparc64/conf/files.sparc64
+++ b/sys/arch/sparc64/conf/files.sparc64
@@ -1,4 +1,4 @@
-# $OpenBSD: files.sparc64,v 1.55 2004/10/08 13:04:36 grange Exp $
+# $OpenBSD: files.sparc64,v 1.56 2005/03/05 01:44:52 miod Exp $
# $NetBSD: files.sparc64,v 1.50 2001/08/10 20:53:50 eeh Exp $
# maxpartitions must be first item in files.${ARCH}
@@ -67,7 +67,8 @@ file arch/sparc64/sparc64/netbsd_machdep.c compat_netbsd
# Sun specific files
include "../../../dev/sun/files.sun"
-attach sbus at mainbus
+attach sbus at mainbus with sbus_mb
+attach sbus at xbox with sbus_xbox
file arch/sparc64/dev/sbus.c sbus
device creator: wsemuldisplaydev, rasops8, rasops16, rasops24, rasops32, wsemul_sun
diff --git a/sys/arch/sparc64/dev/sbus.c b/sys/arch/sparc64/dev/sbus.c
index df871d30ff6..18c1932ca65 100644
--- a/sys/arch/sparc64/dev/sbus.c
+++ b/sys/arch/sparc64/dev/sbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sbus.c,v 1.21 2005/01/27 21:17:50 miod Exp $ */
+/* $OpenBSD: sbus.c,v 1.22 2005/03/05 01:44:52 miod Exp $ */
/* $NetBSD: sbus.c,v 1.46 2001/10/07 20:30:41 eeh Exp $ */
/*-
@@ -118,6 +118,7 @@
#include <sparc64/dev/iommuvar.h>
#include <sparc64/dev/sbusreg.h>
#include <dev/sbus/sbusvar.h>
+#include <dev/sbus/xboxvar.h>
#include <uvm/uvm_extern.h>
@@ -136,32 +137,37 @@ int sbus_debug = 0;
void sbusreset(int);
-static bus_space_tag_t sbus_alloc_bustag(struct sbus_softc *);
-static bus_dma_tag_t sbus_alloc_dmatag(struct sbus_softc *);
-static int sbus_get_intr(struct sbus_softc *, int,
+bus_space_tag_t sbus_alloc_bustag(struct sbus_softc *, int);
+bus_dma_tag_t sbus_alloc_dmatag(struct sbus_softc *, bus_dma_tag_t);
+int sbus_get_intr(struct sbus_softc *, int,
struct sbus_intr **, int *, int);
-static int sbus_overtemp(void *);
-static int _sbus_bus_map(bus_space_tag_t, bus_space_tag_t,
+int sbus_overtemp(void *);
+int _sbus_bus_map(bus_space_tag_t, bus_space_tag_t,
bus_addr_t, /*offset*/
bus_size_t, /*size*/
int, /*flags*/
bus_space_handle_t *);
-static void *sbus_intr_establish(bus_space_tag_t, bus_space_tag_t,
+void *sbus_intr_establish(bus_space_tag_t, bus_space_tag_t,
int, /*Sbus interrupt level*/
int, /*`device class' priority*/
int, /*flags*/
int (*)(void *), /*handler*/
void *, /*handler arg*/
const char *); /*what*/
-
+void sbus_attach_common(struct sbus_softc *, int, int);
/* autoconfiguration driver */
-int sbus_match(struct device *, void *, void *);
-void sbus_attach(struct device *, struct device *, void *);
+void sbus_mb_attach(struct device *, struct device *, void *);
+void sbus_xbox_attach(struct device *, struct device *, void *);
+int sbus_mb_match(struct device *, void *, void *);
+int sbus_xbox_match(struct device *, void *, void *);
+struct cfattach sbus_mb_ca = {
+ sizeof(struct sbus_softc), sbus_mb_match, sbus_mb_attach
+};
-struct cfattach sbus_ca = {
- sizeof(struct sbus_softc), sbus_match, sbus_attach
+struct cfattach sbus_xbox_ca = {
+ sizeof(struct sbus_softc), sbus_xbox_match, sbus_xbox_attach
};
struct cfdriver sbus_cd = {
@@ -232,7 +238,7 @@ sbus_print(void *args, const char *busname)
}
int
-sbus_match(struct device *parent, void *vcf, void *aux)
+sbus_mb_match(struct device *parent, void *vcf, void *aux)
{
struct cfdata *cf = vcf;
struct mainbus_attach_args *ma = aux;
@@ -240,35 +246,39 @@ sbus_match(struct device *parent, void *vcf, void *aux)
return (strcmp(cf->cf_driver->cd_name, ma->ma_name) == 0);
}
-/*
- * Attach an Sbus.
- */
+int
+sbus_xbox_match(struct device *parent, void *vcf, void *aux)
+{
+ struct xbox_softc *xsc = (struct xbox_softc *)parent;
+
+ /* Prevent multiple attachments */
+ if (xsc->sc_attached == 0) {
+ xsc->sc_attached = 1;
+ return (1);
+ }
+
+ return (0);
+}
+
void
-sbus_attach(struct device *parent, struct device *self, void *aux)
+sbus_xbox_attach(struct device *parent, struct device *self, void *aux)
{
struct sbus_softc *sc = (struct sbus_softc *)self;
- struct mainbus_attach_args *ma = aux;
- struct intrhand *ih;
- struct sysioreg *sysio;
- int ipl;
- char *name;
- int node = ma->ma_node;
- int node0, error;
- bus_space_tag_t sbt;
- struct sbus_attach_args sa;
+ struct xbox_softc *xsc = (struct xbox_softc *)parent;
+ struct sbus_softc *sbus = (struct sbus_softc *)parent->dv_parent;
+ struct xbox_attach_args *xa = aux;
+ int node = xa->xa_node;
- sc->sc_bustag = ma->ma_bustag;
- sc->sc_dmatag = ma->ma_dmatag;
- /* Find interrupt group no */
- sc->sc_ign = ma->ma_interrupts[0] & INTMAP_IGN;
+ sc->sc_master = sbus->sc_master;
- bus_space_map(sc->sc_bustag,
- ma->ma_address[0], sizeof(struct sysioreg),
- BUS_SPACE_MAP_PROMADDRESS, &sc->sc_bh);
- sysio = bus_space_vaddr(sc->sc_bustag, sc->sc_bh);
+ sc->sc_bustag = xa->xa_bustag;
+ sc->sc_dmatag = sbus_alloc_dmatag(sc, xa->xa_dmatag);
- /* Setup interrupt translation tables */
- sc->sc_intr2ipl = intr_sbus2ipl_4u;
+ /*
+ * Parent has already done the address translation computations.
+ */
+ sc->sc_nrange = xsc->sc_nrange;
+ sc->sc_range = xsc->sc_range;
/*
* Record clock frequency for synchronous SCSI.
@@ -277,13 +287,26 @@ sbus_attach(struct device *parent, struct device *self, void *aux)
sc->sc_clockfreq = getpropint(node, "clock-frequency", 25*1000*1000);
printf(": clock = %s MHz\n", clockfreq(sc->sc_clockfreq));
- sbt = sbus_alloc_bustag(sc);
- sc->sc_dmatag = sbus_alloc_dmatag(sc);
+ sbus_attach_common(sc, node, 1);
+}
- /*
- * Get the SBus burst transfer size if burst transfers are supported
- */
- sc->sc_burst = getpropint(node, "burst-sizes", 0);
+void
+sbus_mb_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct sbus_softc *sc = (struct sbus_softc *)self;
+ struct mainbus_attach_args *ma = aux;
+ int node = ma->ma_node;
+ struct intrhand *ih;
+ int ipl, error;
+ struct sysioreg *sysio;
+ char *name;
+
+ sc->sc_master = sc;
+
+ sc->sc_bustag = ma->ma_bustag;
+
+ /* Find interrupt group no */
+ sc->sc_ign = ma->ma_interrupts[0] & INTMAP_IGN;
/*
* Collect address translations from the OBP.
@@ -293,6 +316,18 @@ sbus_attach(struct device *parent, struct device *self, void *aux)
if (error)
panic("%s: error getting ranges property", sc->sc_dev.dv_xname);
+ /*
+ * Record clock frequency for synchronous SCSI.
+ * IS THIS THE CORRECT DEFAULT??
+ */
+ sc->sc_clockfreq = getpropint(node, "clock-frequency", 25*1000*1000);
+ printf(": clock = %s MHz\n", clockfreq(sc->sc_clockfreq));
+
+ bus_space_map(sc->sc_bustag,
+ ma->ma_address[0], sizeof(struct sysioreg),
+ BUS_SPACE_MAP_PROMADDRESS, &sc->sc_bh);
+ sysio = bus_space_vaddr(sc->sc_bustag, sc->sc_bh);
+
/* initialize the IOMMU */
/* punch in our copies */
@@ -351,6 +386,31 @@ sbus_attach(struct device *parent, struct device *self, void *aux)
panic("sbus iommu: can't toss first dvma page");
}
+ sc->sc_dmatag = sbus_alloc_dmatag(sc, ma->ma_dmatag);
+
+ sbus_attach_common(sc, node, 0);
+}
+
+/*
+ * Attach an Sbus (main part).
+ */
+void
+sbus_attach_common(struct sbus_softc *sc, int node, int indirect)
+{
+ bus_space_tag_t sbt;
+ struct sbus_attach_args sa;
+ int node0;
+
+ /* Setup interrupt translation tables */
+ sc->sc_intr2ipl = intr_sbus2ipl_4u;
+
+ sbt = sbus_alloc_bustag(sc, indirect);
+
+ /*
+ * Get the SBus burst transfer size if burst transfers are supported
+ */
+ sc->sc_burst = getpropint(node, "burst-sizes", 0);
+
/*
* Loop through ROM children, fixing any relative addresses
* and then configuring each device.
@@ -512,7 +572,7 @@ sbus_establish(struct sbusdev *sd, struct device *dev)
* We have to look for the sbus by name, since it is not necessarily
* our immediate parent (i.e. sun4m /iommu/sbus/espdma/esp)
* We don't just use the device structure of the above-attached
- * sbus, since we might (in the future) support multiple sbus's.
+ * sbus, since we support multiple sbus's.
*/
for (curdev = dev->dv_parent; ; curdev = curdev->dv_parent) {
if (!curdev || !curdev->dv_xname)
@@ -657,6 +717,9 @@ sbus_intr_establish(bus_space_tag_t t, bus_space_tag_t t0, int pri, int level,
int ipl;
long vec = pri;
+ /* Pick the master SBus as all do not have IOMMU registers */
+ sc = sc->sc_master;
+
sysio = bus_space_vaddr(sc->sc_bustag, sc->sc_bh);
if ((flags & BUS_INTR_ESTABLISH_SOFTINTR) != 0)
@@ -760,8 +823,8 @@ sbus_intr_establish(bus_space_tag_t t, bus_space_tag_t t0, int pri, int level,
return (ih);
}
-static bus_space_tag_t
-sbus_alloc_bustag(struct sbus_softc *sc)
+bus_space_tag_t
+sbus_alloc_bustag(struct sbus_softc *sc, int indirect)
{
struct sparc_bus_space_tag *sbt;
@@ -773,7 +836,10 @@ sbus_alloc_bustag(struct sbus_softc *sc)
snprintf(sbt->name, sizeof(sbt->name), "%s",
sc->sc_dev.dv_xname);
sbt->cookie = sc;
- sbt->parent = sc->sc_bustag;
+ if (indirect)
+ sbt->parent = sc->sc_bustag->parent;
+ else
+ sbt->parent = sc->sc_bustag;
sbt->default_type = SBUS_BUS_SPACE;
sbt->asi = ASI_PRIMARY;
sbt->sasi = ASI_PRIMARY;
@@ -784,10 +850,10 @@ sbus_alloc_bustag(struct sbus_softc *sc)
}
-static bus_dma_tag_t
-sbus_alloc_dmatag(struct sbus_softc *sc)
+bus_dma_tag_t
+sbus_alloc_dmatag(struct sbus_softc *sc, bus_dma_tag_t psdt)
{
- bus_dma_tag_t sdt, psdt = sc->sc_dmatag;
+ bus_dma_tag_t sdt;
sdt = (bus_dma_tag_t)
malloc(sizeof(struct sparc_bus_dma_tag), M_DEVBUF, M_NOWAIT);
@@ -807,7 +873,6 @@ sbus_alloc_dmatag(struct sbus_softc *sc)
sdt->_dmamem_free = iommu_dvmamem_free;
sdt->_dmamem_map = iommu_dvmamem_map;
sdt->_dmamem_unmap = iommu_dvmamem_unmap;
- sc->sc_dmatag = sdt;
return (sdt);
}
@@ -818,7 +883,10 @@ sbus_dmamap_create(bus_dma_tag_t t, bus_dma_tag_t t0, bus_size_t size,
{
struct sbus_softc *sc = t->_cookie;
+ /* Disallow DMA on secondary SBuses for now */
+ if (sc != sc->sc_master)
+ return (EINVAL);
+
return (iommu_dvmamap_create(t, t0, &sc->sc_sb, size, nsegments,
maxsegsz, boundary, flags, dmamp));
}
-
diff --git a/sys/arch/sparc64/dev/sbusvar.h b/sys/arch/sparc64/dev/sbusvar.h
index f05ea6d05eb..cb3715c76a6 100644
--- a/sys/arch/sparc64/dev/sbusvar.h
+++ b/sys/arch/sparc64/dev/sbusvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sbusvar.h,v 1.6 2003/06/02 23:27:55 millert Exp $ */
+/* $OpenBSD: sbusvar.h,v 1.7 2005/03/05 01:44:52 miod Exp $ */
/* $NetBSD: sbusvar.h,v 1.7 1999/06/05 05:30:43 mrg Exp $ */
/*-
@@ -111,6 +111,7 @@ struct sbus_softc {
struct iommu_state sc_is; /* IOMMU state, see iommureg.h */
struct strbuf_ctl sc_sb; /* Streaming buffer control */
int64_t sc_flush; /* Streaming buffer flush */
+ struct sbus_softc *sc_master; /* main SBus */
};
bus_addr_t sbus_bus_addr(bus_space_tag_t, u_int, u_int);
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 */
+};