diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2011-10-10 19:49:18 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2011-10-10 19:49:18 +0000 |
commit | 7365eaa981a257d0f603424ed53e4cd189ee7ecd (patch) | |
tree | 5eb1cddffe1ec65b3df9c6c61fefe41aed53553b /sys/arch/sgi/pci | |
parent | 3cc4d3c11a835610eaf5ce6c13389352149848c1 (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/sgi/pci')
-rw-r--r-- | sys/arch/sgi/pci/ioc.c | 31 | ||||
-rw-r--r-- | sys/arch/sgi/pci/iof.c | 32 | ||||
-rw-r--r-- | sys/arch/sgi/pci/macepcibridge.c | 46 |
3 files changed, 29 insertions, 80 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 |