summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2011-10-10 19:49:18 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2011-10-10 19:49:18 +0000
commit7365eaa981a257d0f603424ed53e4cd189ee7ecd (patch)
tree5eb1cddffe1ec65b3df9c6c61fefe41aed53553b /sys/arch
parent3cc4d3c11a835610eaf5ce6c13389352149848c1 (diff)
Extend pci_probe_device_hook() on sgi xbridge(4) to return either the straight
accessors or the byte-swapped accessors, depending upon the byteswap setting of the device we are trying to attach. This allows for the removal of byteswap knowledge from ioc(4) and iof(4) drivers. While there, build pci_chipset_t md structs by bcopy'ing a template and filling the few runtime fields, instead of assigning every field of them.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/sgi/pci/ioc.c31
-rw-r--r--sys/arch/sgi/pci/iof.c32
-rw-r--r--sys/arch/sgi/pci/macepcibridge.c46
-rw-r--r--sys/arch/sgi/xbow/xbridge.c172
4 files changed, 142 insertions, 139 deletions
diff --git a/sys/arch/sgi/pci/ioc.c b/sys/arch/sgi/pci/ioc.c
index 2fea8b271c8..675a6a74f41 100644
--- a/sys/arch/sgi/pci/ioc.c
+++ b/sys/arch/sgi/pci/ioc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ioc.c,v 1.36 2010/09/20 06:33:47 matthew Exp $ */
+/* $OpenBSD: ioc.c,v 1.37 2011/10/10 19:49:16 miod Exp $ */
/*
* Copyright (c) 2008 Joel Sing.
@@ -49,8 +49,6 @@
#include <sgi/dev/owmacvar.h>
#include <sgi/dev/owserialvar.h>
-#include <sgi/xbow/xbow.h>
-
int ioc_match(struct device *, void *, void *);
void ioc_attach(struct device *, struct device *, void *);
@@ -67,8 +65,6 @@ struct ioc_intr {
struct ioc_softc {
struct device sc_dev;
- struct mips_bus_space *sc_mem_bus_space;
-
bus_space_tag_t sc_memt;
bus_space_handle_t sc_memh;
bus_dma_tag_t sc_dmat;
@@ -185,30 +181,7 @@ ioc_attach(struct device *parent, struct device *self, void *aux)
printf("\n");
- /*
- * Build a suitable bus_space_handle by restoring the original
- * non-swapped subword access methods.
- *
- * XXX This is horrible and will need to be rethought if
- * XXX we ever support ioc3 cards not plugged to xbridges.
- */
-
- sc->sc_mem_bus_space = malloc(sizeof (*sc->sc_mem_bus_space),
- M_DEVBUF, M_NOWAIT);
- if (sc->sc_mem_bus_space == NULL) {
- printf("%s: can't allocate bus_space\n", self->dv_xname);
- goto unmap;
- }
-
- bcopy(memt, sc->sc_mem_bus_space, sizeof(*sc->sc_mem_bus_space));
- sc->sc_mem_bus_space->_space_read_1 = xbow_read_1;
- sc->sc_mem_bus_space->_space_read_2 = xbow_read_2;
- sc->sc_mem_bus_space->_space_read_raw_2 = xbow_read_raw_2;
- sc->sc_mem_bus_space->_space_write_1 = xbow_write_1;
- sc->sc_mem_bus_space->_space_write_2 = xbow_write_2;
- sc->sc_mem_bus_space->_space_write_raw_2 = xbow_write_raw_2;
-
- sc->sc_memt = sc->sc_mem_bus_space;
+ sc->sc_memt = memt;
sc->sc_memh = memh;
/*
diff --git a/sys/arch/sgi/pci/iof.c b/sys/arch/sgi/pci/iof.c
index cf1b7bbf7ce..08ed7742842 100644
--- a/sys/arch/sgi/pci/iof.c
+++ b/sys/arch/sgi/pci/iof.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iof.c,v 1.7 2010/09/20 06:33:47 matthew Exp $ */
+/* $OpenBSD: iof.c,v 1.8 2011/10/10 19:49:16 miod Exp $ */
/*
* Copyright (c) 2009 Miodrag Vallat.
@@ -36,8 +36,6 @@
#include <sgi/pci/iofreg.h>
#include <sgi/pci/iofvar.h>
-#include <sgi/xbow/xbow.h>
-
int iof_match(struct device *, void *, void *);
void iof_attach(struct device *, struct device *, void *);
void iof_attach_child(struct device *, const char *, bus_addr_t, uint);
@@ -57,8 +55,6 @@ struct iof_intr {
struct iof_softc {
struct device sc_dev;
- struct mips_bus_space *sc_mem_bus_space;
-
bus_space_tag_t sc_memt;
bus_space_handle_t sc_memh;
bus_dma_tag_t sc_dmat;
@@ -130,31 +126,7 @@ iof_attach(struct device *parent, struct device *self, void *aux)
sc->sc_tag = pa->pa_tag;
sc->sc_dmat = pa->pa_dmat;
- /*
- * Build a suitable bus_space_handle by restoring the original
- * non-swapped subword access methods.
- *
- * XXX This is horrible and will need to be rethought if
- * XXX IOC4 exist as real, removable PCI cards and
- * XXX we ever support them cards not plugged to xbridges.
- */
-
- sc->sc_mem_bus_space = malloc(sizeof (*sc->sc_mem_bus_space),
- M_DEVBUF, M_NOWAIT);
- if (sc->sc_mem_bus_space == NULL) {
- printf("can't allocate bus_space\n");
- goto unmap;
- }
-
- bcopy(memt, sc->sc_mem_bus_space, sizeof(*sc->sc_mem_bus_space));
- sc->sc_mem_bus_space->_space_read_1 = xbow_read_1;
- sc->sc_mem_bus_space->_space_read_2 = xbow_read_2;
- sc->sc_mem_bus_space->_space_read_raw_2 = xbow_read_raw_2;
- sc->sc_mem_bus_space->_space_write_1 = xbow_write_1;
- sc->sc_mem_bus_space->_space_write_2 = xbow_write_2;
- sc->sc_mem_bus_space->_space_write_raw_2 = xbow_write_raw_2;
-
- sc->sc_memt = sc->sc_mem_bus_space;
+ sc->sc_memt = memt;
sc->sc_memh = memh;
sc->sc_mcr = bus_space_read_4(sc->sc_memt, sc->sc_memh, IOC4_MCR);
diff --git a/sys/arch/sgi/pci/macepcibridge.c b/sys/arch/sgi/pci/macepcibridge.c
index 99ac177f89c..fa9a1db45b0 100644
--- a/sys/arch/sgi/pci/macepcibridge.c
+++ b/sys/arch/sgi/pci/macepcibridge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: macepcibridge.c,v 1.42 2011/10/10 19:42:36 miod Exp $ */
+/* $OpenBSD: macepcibridge.c,v 1.43 2011/10/10 19:49:16 miod Exp $ */
/*
* Copyright (c) 2009 Miodrag Vallat.
@@ -152,6 +152,29 @@ bus_space_t mace_pcibbus_io_tag = {
NULL
};
+static const struct mips_pci_chipset mace_pci_chipset = {
+ .pc_attach_hook = mace_pcibr_attach_hook,
+ .pc_bus_maxdevs = mace_pcibr_bus_maxdevs,
+ .pc_make_tag = mace_pcibr_make_tag,
+ .pc_decompose_tag = mace_pcibr_decompose_tag,
+ .pc_conf_size = mace_pcibr_conf_size,
+ .pc_conf_read = mace_pcibr_conf_read,
+ .pc_conf_write = mace_pcibr_conf_write,
+ .pc_probe_device_hook = mace_pcibr_probe_device_hook,
+ .pc_get_widget = mace_pcibr_get_widget,
+ .pc_get_dl = mace_pcibr_get_dl,
+ .pc_intr_map = mace_pcibr_intr_map,
+ .pc_intr_string = mace_pcibr_intr_string,
+ .pc_intr_establish = mace_pcibr_intr_establish,
+ .pc_intr_disestablish = mace_pcibr_intr_disestablish,
+ .pc_intr_line = mace_pcibr_intr_line,
+ .pc_ppb_setup = mace_pcibr_ppb_setup,
+#if NCARDBUS > 0
+ .pc_rbus_parent_io = mace_pcibr_rbus_parent_io,
+ .pc_rbus_parent_mem = mace_pcibr_rbus_parent_mem
+#endif
+};
+
/*
* PCI doesn't have any special needs; just use the generic versions
* of these functions.
@@ -236,28 +259,9 @@ mace_pcibrattach(struct device *parent, struct device *self, void *aux)
macebus_intr_establish(maa->maa_intr, maa->maa_mace_intr,
IST_LEVEL, IPL_HIGH, mace_pcibr_errintr, sc, sc->sc_dev.dv_xname);
+ bcopy(&mace_pci_chipset, &sc->sc_pc, sizeof(mace_pci_chipset));
sc->sc_pc.pc_conf_v = sc;
- sc->sc_pc.pc_attach_hook = mace_pcibr_attach_hook;
- sc->sc_pc.pc_make_tag = mace_pcibr_make_tag;
- sc->sc_pc.pc_decompose_tag = mace_pcibr_decompose_tag;
- sc->sc_pc.pc_bus_maxdevs = mace_pcibr_bus_maxdevs;
- sc->sc_pc.pc_conf_size = mace_pcibr_conf_size;
- sc->sc_pc.pc_conf_read = mace_pcibr_conf_read;
- sc->sc_pc.pc_conf_write = mace_pcibr_conf_write;
- sc->sc_pc.pc_get_widget = mace_pcibr_get_widget;
- sc->sc_pc.pc_probe_device_hook = mace_pcibr_probe_device_hook;
- sc->sc_pc.pc_get_dl = mace_pcibr_get_dl;
sc->sc_pc.pc_intr_v = NULL;
- sc->sc_pc.pc_intr_map = mace_pcibr_intr_map;
- sc->sc_pc.pc_intr_string = mace_pcibr_intr_string;
- sc->sc_pc.pc_intr_establish = mace_pcibr_intr_establish;
- sc->sc_pc.pc_intr_disestablish = mace_pcibr_intr_disestablish;
- sc->sc_pc.pc_intr_line = mace_pcibr_intr_line;
- sc->sc_pc.pc_ppb_setup = mace_pcibr_ppb_setup;
-#if NCARDBUS > 0
- sc->sc_pc.pc_rbus_parent_io = mace_pcibr_rbus_parent_io;
- sc->sc_pc.pc_rbus_parent_mem = mace_pcibr_rbus_parent_mem;
-#endif
/*
* The O2 firmware sucks. It makes a mess of I/O BARs and
diff --git a/sys/arch/sgi/xbow/xbridge.c b/sys/arch/sgi/xbow/xbridge.c
index e072c40e29e..010c01a3f94 100644
--- a/sys/arch/sgi/xbow/xbridge.c
+++ b/sys/arch/sgi/xbow/xbridge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xbridge.c,v 1.83 2011/10/10 19:42:36 miod Exp $ */
+/* $OpenBSD: xbridge.c,v 1.84 2011/10/10 19:49:17 miod Exp $ */
/*
* Copyright (c) 2008, 2009, 2011 Miodrag Vallat.
@@ -124,7 +124,9 @@ struct xbpci_softc {
bus_space_handle_t xb_regh;
struct mips_bus_space *xb_mem_bus_space;
+ struct mips_bus_space *xb_mem_bus_space_sw;
struct mips_bus_space *xb_io_bus_space;
+ struct mips_bus_space *xb_io_bus_space_sw;
struct machine_bus_dma_tag *xb_dmat;
struct xbridge_intr *xb_intr[BRIDGE_NINTRS];
@@ -307,7 +309,7 @@ xbridge_wbflush(struct xbpci_softc *xb, uint d)
while (xbridge_read_reg(xb, BRIDGE_DEVICE_WBFLUSH(d)) != 0) ;
}
-const struct machine_bus_dma_tag xbridge_dma_tag = {
+static const struct machine_bus_dma_tag xbridge_dma_tag = {
NULL, /* _cookie */
_dmamap_create,
_dmamap_destroy,
@@ -328,6 +330,29 @@ const struct machine_bus_dma_tag xbridge_dma_tag = {
BRIDGE_DMA_DIRECT_LENGTH - 1
};
+static const struct mips_pci_chipset xbridge_pci_chipset = {
+ .pc_attach_hook = xbridge_attach_hook,
+ .pc_bus_maxdevs = xbridge_bus_maxdevs,
+ .pc_make_tag = xbridge_make_tag,
+ .pc_decompose_tag = xbridge_decompose_tag,
+ .pc_conf_size = xbridge_conf_size,
+ .pc_conf_read = xbridge_conf_read,
+ .pc_conf_write = xbridge_conf_write,
+ .pc_probe_device_hook = xbridge_probe_device_hook,
+ .pc_get_widget = xbridge_get_widget,
+ .pc_get_dl = xbridge_get_dl,
+ .pc_intr_map = xbridge_intr_map,
+ .pc_intr_string = xbridge_intr_string,
+ .pc_intr_establish = xbridge_intr_establish,
+ .pc_intr_disestablish = xbridge_intr_disestablish,
+ .pc_intr_line = xbridge_intr_line,
+ .pc_ppb_setup = xbridge_ppb_setup,
+#if NCARDBUS > 0
+ .pc_rbus_parent_io = xbridge_rbus_parent_io,
+ .pc_rbus_parent_mem = xbridge_rbus_parent_mem
+#endif
+};
+
/*
********************* Autoconf glue.
*/
@@ -507,54 +532,63 @@ xbpci_attach(struct device *parent, struct device *self, void *aux)
/*
* Create bus_space accessors... we inherit them from xbow, but
- * it is necessary to perform endianness conversion for the
- * low-order address bits.
+ * need to overwrite mapping routines, and set up byteswapping
+ * versions.
*/
xb->xb_mem_bus_space = malloc(sizeof (*xb->xb_mem_bus_space),
M_DEVBUF, M_NOWAIT);
- if (xb->xb_mem_bus_space == NULL)
- goto fail1;
+ xb->xb_mem_bus_space_sw = malloc(sizeof (*xb->xb_mem_bus_space_sw),
+ M_DEVBUF, M_NOWAIT);
xb->xb_io_bus_space = malloc(sizeof (*xb->xb_io_bus_space),
M_DEVBUF, M_NOWAIT);
- if (xb->xb_io_bus_space == NULL)
- goto fail2;
+ xb->xb_io_bus_space_sw = malloc(sizeof (*xb->xb_io_bus_space_sw),
+ M_DEVBUF, M_NOWAIT);
+ if (xb->xb_mem_bus_space == NULL || xb->xb_mem_bus_space_sw == NULL ||
+ xb->xb_io_bus_space == NULL || xb->xb_io_bus_space_sw == NULL)
+ goto fail1;
bcopy(xb->xb_regt, xb->xb_mem_bus_space, sizeof(*xb->xb_mem_bus_space));
xb->xb_mem_bus_space->bus_private = xb;
xb->xb_mem_bus_space->_space_map = xbridge_space_map_devio;
xb->xb_mem_bus_space->_space_subregion = xbridge_space_region_devio;
- xb->xb_mem_bus_space->_space_read_1 = xbridge_read_1;
- xb->xb_mem_bus_space->_space_write_1 = xbridge_write_1;
- xb->xb_mem_bus_space->_space_read_2 = xbridge_read_2;
- xb->xb_mem_bus_space->_space_write_2 = xbridge_write_2;
- xb->xb_mem_bus_space->_space_read_raw_2 = xbridge_read_raw_2;
- xb->xb_mem_bus_space->_space_write_raw_2 = xbridge_write_raw_2;
- xb->xb_mem_bus_space->_space_read_raw_4 = xbridge_read_raw_4;
- xb->xb_mem_bus_space->_space_write_raw_4 = xbridge_write_raw_4;
- xb->xb_mem_bus_space->_space_read_raw_8 = xbridge_read_raw_8;
- xb->xb_mem_bus_space->_space_write_raw_8 = xbridge_write_raw_8;
xb->xb_mem_bus_space->_space_barrier = xbridge_space_barrier;
+ bcopy(xb->xb_mem_bus_space, xb->xb_mem_bus_space_sw,
+ sizeof(*xb->xb_mem_bus_space));
+ xb->xb_mem_bus_space_sw->_space_read_1 = xbridge_read_1;
+ xb->xb_mem_bus_space_sw->_space_write_1 = xbridge_write_1;
+ xb->xb_mem_bus_space_sw->_space_read_2 = xbridge_read_2;
+ xb->xb_mem_bus_space_sw->_space_write_2 = xbridge_write_2;
+ xb->xb_mem_bus_space_sw->_space_read_raw_2 = xbridge_read_raw_2;
+ xb->xb_mem_bus_space_sw->_space_write_raw_2 = xbridge_write_raw_2;
+ xb->xb_mem_bus_space_sw->_space_read_raw_4 = xbridge_read_raw_4;
+ xb->xb_mem_bus_space_sw->_space_write_raw_4 = xbridge_write_raw_4;
+ xb->xb_mem_bus_space_sw->_space_read_raw_8 = xbridge_read_raw_8;
+ xb->xb_mem_bus_space_sw->_space_write_raw_8 = xbridge_write_raw_8;
+
bcopy(xb->xb_regt, xb->xb_io_bus_space, sizeof(*xb->xb_io_bus_space));
xb->xb_io_bus_space->bus_private = xb;
xb->xb_io_bus_space->_space_map = xbridge_space_map_devio;
xb->xb_io_bus_space->_space_subregion = xbridge_space_region_devio;
- xb->xb_io_bus_space->_space_read_1 = xbridge_read_1;
- xb->xb_io_bus_space->_space_write_1 = xbridge_write_1;
- xb->xb_io_bus_space->_space_read_2 = xbridge_read_2;
- xb->xb_io_bus_space->_space_write_2 = xbridge_write_2;
- xb->xb_io_bus_space->_space_read_raw_2 = xbridge_read_raw_2;
- xb->xb_io_bus_space->_space_write_raw_2 = xbridge_write_raw_2;
- xb->xb_io_bus_space->_space_read_raw_4 = xbridge_read_raw_4;
- xb->xb_io_bus_space->_space_write_raw_4 = xbridge_write_raw_4;
- xb->xb_io_bus_space->_space_read_raw_8 = xbridge_read_raw_8;
- xb->xb_io_bus_space->_space_write_raw_8 = xbridge_write_raw_8;
xb->xb_io_bus_space->_space_barrier = xbridge_space_barrier;
+ bcopy(xb->xb_io_bus_space, xb->xb_io_bus_space_sw,
+ sizeof(*xb->xb_io_bus_space));
+ xb->xb_io_bus_space_sw->_space_read_1 = xbridge_read_1;
+ xb->xb_io_bus_space_sw->_space_write_1 = xbridge_write_1;
+ xb->xb_io_bus_space_sw->_space_read_2 = xbridge_read_2;
+ xb->xb_io_bus_space_sw->_space_write_2 = xbridge_write_2;
+ xb->xb_io_bus_space_sw->_space_read_raw_2 = xbridge_read_raw_2;
+ xb->xb_io_bus_space_sw->_space_write_raw_2 = xbridge_write_raw_2;
+ xb->xb_io_bus_space_sw->_space_read_raw_4 = xbridge_read_raw_4;
+ xb->xb_io_bus_space_sw->_space_write_raw_4 = xbridge_write_raw_4;
+ xb->xb_io_bus_space_sw->_space_read_raw_8 = xbridge_read_raw_8;
+ xb->xb_io_bus_space_sw->_space_write_raw_8 = xbridge_write_raw_8;
+
xb->xb_dmat = malloc(sizeof (*xb->xb_dmat), M_DEVBUF, M_NOWAIT);
if (xb->xb_dmat == NULL)
- goto fail3;
+ goto fail1;
memcpy(xb->xb_dmat, &xbridge_dma_tag, sizeof(*xb->xb_dmat));
xb->xb_dmat->_cookie = xb;
@@ -562,28 +596,9 @@ xbpci_attach(struct device *parent, struct device *self, void *aux)
* Initialize PCI methods.
*/
+ bcopy(&xbridge_pci_chipset, &xb->xb_pc, sizeof(xbridge_pci_chipset));
xb->xb_pc.pc_conf_v = xb;
- xb->xb_pc.pc_attach_hook = xbridge_attach_hook;
- xb->xb_pc.pc_make_tag = xbridge_make_tag;
- xb->xb_pc.pc_decompose_tag = xbridge_decompose_tag;
- xb->xb_pc.pc_bus_maxdevs = xbridge_bus_maxdevs;
- xb->xb_pc.pc_conf_size = xbridge_conf_size;
- xb->xb_pc.pc_conf_read = xbridge_conf_read;
- xb->xb_pc.pc_conf_write = xbridge_conf_write;
- xb->xb_pc.pc_probe_device_hook = xbridge_probe_device_hook;
- xb->xb_pc.pc_get_widget = xbridge_get_widget;
- xb->xb_pc.pc_get_dl = xbridge_get_dl;
xb->xb_pc.pc_intr_v = xb;
- xb->xb_pc.pc_intr_map = xbridge_intr_map;
- xb->xb_pc.pc_intr_string = xbridge_intr_string;
- xb->xb_pc.pc_intr_establish = xbridge_intr_establish;
- xb->xb_pc.pc_intr_disestablish = xbridge_intr_disestablish;
- xb->xb_pc.pc_intr_line = xbridge_intr_line;
- xb->xb_pc.pc_ppb_setup = xbridge_ppb_setup;
-#if NCARDBUS > 0
- xb->xb_pc.pc_rbus_parent_io = xbridge_rbus_parent_io;
- xb->xb_pc.pc_rbus_parent_mem = xbridge_rbus_parent_mem;
-#endif
/*
* Configure Bridge for proper operation (DMA, I/O mappings,
@@ -591,7 +606,7 @@ xbpci_attach(struct device *parent, struct device *self, void *aux)
*/
if ((errmsg = xbridge_setup(xb)) != NULL)
- goto fail4;
+ goto fail2;
printf("\n");
/*
@@ -602,8 +617,18 @@ xbpci_attach(struct device *parent, struct device *self, void *aux)
bzero(&pba, sizeof(pba));
pba.pba_busname = "pci";
- pba.pba_iot = xb->xb_io_bus_space;
- pba.pba_memt = xb->xb_mem_bus_space;
+ /*
+ * XXX pba_iot and pba_memt ought to be irrelevant, since we
+ * XXX return the tags a device needs in probe_device_hook();
+ * XXX however the pci(4) device needs a valid pba_memt for the
+ * XXX PCIOCGETROM* ioctls.
+ * XXX
+ * XXX Since most devices will need the byteswap tags, and those
+ * XXX which don't do not have PCI roms, let's pass the byteswap
+ * XXX versions by default.
+ */
+ pba.pba_iot = xb->xb_io_bus_space_sw;
+ pba.pba_memt = xb->xb_mem_bus_space_sw;
pba.pba_dmat = xb->xb_dmat;
pba.pba_ioex = xb->xb_ioex;
pba.pba_memex = xb->xb_memex;
@@ -620,13 +645,17 @@ xbpci_attach(struct device *parent, struct device *self, void *aux)
config_found(self, &pba, xbpci_print);
return;
-fail4:
- free(xb->xb_dmat, M_DEVBUF);
-fail3:
- free(xb->xb_io_bus_space, M_DEVBUF);
fail2:
- free(xb->xb_mem_bus_space, M_DEVBUF);
+ free(xb->xb_dmat, M_DEVBUF);
fail1:
+ if (xb->xb_io_bus_space_sw != NULL)
+ free(xb->xb_io_bus_space_sw, M_DEVBUF);
+ if (xb->xb_io_bus_space != NULL)
+ free(xb->xb_io_bus_space, M_DEVBUF);
+ if (xb->xb_mem_bus_space_sw != NULL)
+ free(xb->xb_mem_bus_space_sw, M_DEVBUF);
+ if (xb->xb_mem_bus_space != NULL)
+ free(xb->xb_mem_bus_space, M_DEVBUF);
if (errmsg == NULL)
errmsg = "not enough memory to build bus access structures";
printf("%s\n", errmsg);
@@ -872,9 +901,22 @@ xbridge_conf_write(void *cookie, pcitag_t tag, int offset, pcireg_t data)
int
xbridge_probe_device_hook(void *cookie, struct pci_attach_args *pa)
{
-#if 0
struct xbpci_softc *xb = cookie;
-#endif
+
+ /*
+ * Check for the hardware byteswap setting of the device we are
+ * interested in, and pick bus_space_tag accordingly.
+ * Note that the device list here must match xbridge_resource_setup().
+ */
+ if (pa->pa_id == PCI_ID_CODE(PCI_VENDOR_SGI, PCI_PRODUCT_SGI_IOC3) ||
+ pa->pa_id == PCI_ID_CODE(PCI_VENDOR_SGI, PCI_PRODUCT_SGI_IOC4) ||
+ pa->pa_id == PCI_ID_CODE(PCI_VENDOR_SGI, PCI_PRODUCT_SGI_RAD1)) {
+ pa->pa_iot = xb->xb_io_bus_space;
+ pa->pa_memt = xb->xb_mem_bus_space;
+ } else {
+ pa->pa_iot = xb->xb_io_bus_space_sw;
+ pa->pa_memt = xb->xb_mem_bus_space_sw;
+ }
return 0;
}
@@ -2605,6 +2647,12 @@ xbridge_mapping_setup(struct xbpci_softc *xb, int io)
xb->xb_io_bus_space->_space_subregion =
xbridge_space_region_io;
+ xb->xb_io_bus_space_sw->bus_base = base - offs;
+ xb->xb_io_bus_space_sw->_space_map =
+ xbridge_space_map_io;
+ xb->xb_io_bus_space_sw->_space_subregion =
+ xbridge_space_region_io;
+
xb->xb_iostart = offs;
xb->xb_ioend = offs + len - 1;
}
@@ -2655,6 +2703,12 @@ xbridge_mapping_setup(struct xbpci_softc *xb, int io)
xb->xb_mem_bus_space->_space_subregion =
xbridge_space_region_mem;
+ xb->xb_mem_bus_space_sw->bus_base = base - offs;
+ xb->xb_mem_bus_space_sw->_space_map =
+ xbridge_space_map_mem;
+ xb->xb_mem_bus_space_sw->_space_subregion =
+ xbridge_space_region_mem;
+
xb->xb_memstart = offs;
xb->xb_memend = offs + len - 1;
}