From 5932d6e6e2eff29a468cbf532d61611a5fe6dd69 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Sun, 26 Jul 2009 19:58:52 +0000 Subject: Rework ioc children attachment: instead of having ioc build a semi-bogus bus_space_handle_t, pass them ioc's own bus_space_handle and bus_space_tag, and have the children use bus_space_subregion() on it. --- sys/arch/sgi/dev/com_ioc.c | 36 +++++++++++++++++++++++++----------- sys/arch/sgi/dev/dsrtc.c | 24 ++++++++++++------------ sys/arch/sgi/pci/ioc.c | 11 ++++------- sys/arch/sgi/pci/iocvar.h | 15 ++++++++------- 4 files changed, 49 insertions(+), 37 deletions(-) diff --git a/sys/arch/sgi/dev/com_ioc.c b/sys/arch/sgi/dev/com_ioc.c index fdbd0743e74..8f69a8c6573 100644 --- a/sys/arch/sgi/dev/com_ioc.c +++ b/sys/arch/sgi/dev/com_ioc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com_ioc.c,v 1.4 2009/04/12 17:56:58 miod Exp $ */ +/* $OpenBSD: com_ioc.c,v 1.5 2009/07/26 19:58:49 miod Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -49,6 +49,8 @@ struct cfattach com_ioc_ca = { sizeof(struct com_softc), com_ioc_probe, com_ioc_attach }; +extern struct cfdriver com_cd; + int com_ioc_probe(struct device *parent, void *match, void *aux) { @@ -57,14 +59,17 @@ com_ioc_probe(struct device *parent, void *match, void *aux) bus_space_handle_t ioh; int rv = 0, console; - console = iot->bus_base + iaa->iaa_base == + if (strcmp(iaa->iaa_name, com_cd.cd_name) != 0) + return 0; + + console = iaa->iaa_memh + iaa->iaa_base == comconsiot->bus_base + comconsaddr; /* if it's in use as console, it's there. */ if (!(console && !comconsattached)) { - bus_space_map(iot, iaa->iaa_base, COM_NPORTS, 0, &ioh); - rv = comprobe1(iot, ioh); - bus_space_unmap(iot, ioh, COM_NPORTS); + if (bus_space_subregion(iot, iaa->iaa_memh, + iaa->iaa_base, COM_NPORTS, &ioh) == 0) + rv = comprobe1(iot, ioh); } else rv = 1; @@ -79,27 +84,36 @@ com_ioc_attach(struct device *parent, struct device *self, void *aux) bus_space_handle_t ioh; int console; - console = iaa->iaa_memt->bus_base + iaa->iaa_base == + console = iaa->iaa_memh + iaa->iaa_base == comconsiot->bus_base + comconsaddr; sc->sc_hwflags = 0; sc->sc_swflags = 0; - sc->sc_iobase = iaa->iaa_base; sc->sc_frequency = 22000000 / 3; - sc->sc_iot = iaa->iaa_memt; /* if it's in use as console, it's there. */ if (!(console && !comconsattached)) { - if (bus_space_map(sc->sc_iot, sc->sc_iobase, COM_NPORTS, 0, - &ioh)) { + sc->sc_iot = iaa->iaa_memt; + sc->sc_iobase = iaa->iaa_base; + + if (bus_space_subregion(iaa->iaa_memt, iaa->iaa_memh, + iaa->iaa_base, COM_NPORTS, &ioh) != 0) { printf(": can't map registers\n"); return; } } else { - ioh = comconsioh; + /* + * If we are the console, reuse the existing bus_space + * information, so that comcnattach() invokes bus_space_map() + * with correct parameters. + */ + sc->sc_iot = comconsiot; + sc->sc_iobase = comconsaddr; + if (comcnattach(sc->sc_iot, sc->sc_iobase, TTYDEF_SPEED, sc->sc_frequency, (TTYDEF_CFLAG & ~(CSIZE | PARENB)) | CS8)) panic("can't setup serial console"); + ioh = comconsioh; } sc->sc_ioh = ioh; diff --git a/sys/arch/sgi/dev/dsrtc.c b/sys/arch/sgi/dev/dsrtc.c index ace92d15148..3aeb43f8942 100644 --- a/sys/arch/sgi/dev/dsrtc.c +++ b/sys/arch/sgi/dev/dsrtc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsrtc.c,v 1.5 2009/05/15 23:02:23 miod Exp $ */ +/* $OpenBSD: dsrtc.c,v 1.6 2009/07/26 19:58:49 miod Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -98,7 +98,9 @@ tobcd(int x, int binary) int dsrtc_match(struct device *parent, void *match, void *aux) { - return 1; + struct confargs *ca = (struct confargs *)aux; + + return strcmp(ca->ca_name, dsrtc_cd.cd_name) == 0; } void @@ -122,10 +124,10 @@ dsrtc_attach_ioc(struct device *parent, struct device *self, void *aux) * addresses in memory. */ - if (bus_space_map(iaa->iaa_memt, IOC3_BYTEBUS_1, 1, 0, &ih) != 0) - goto fail0; - if (bus_space_map(iaa->iaa_memt, IOC3_BYTEBUS_2, 1, 0, &ih2) != 0) - goto fail1; + if (bus_space_subregion(iaa->iaa_memt, iaa->iaa_memh, IOC3_BYTEBUS_1, + 1, &ih) != 0 || bus_space_subregion(iaa->iaa_memt, iaa->iaa_memh, + IOC3_BYTEBUS_2, 1, &ih2) != 0) + goto fail; /* * Check the low 4 bits of control register C. If any is set, @@ -184,10 +186,10 @@ done: bus_space_unmap(iaa->iaa_memt, ih, 1); bus_space_unmap(iaa->iaa_memt, ih2, 1); - if (bus_space_map(iaa->iaa_memt, + if (bus_space_subregion(iaa->iaa_memt, iaa->iaa_memh, IOC3_BYTEBUS_0 + MK48T35_CLKOFF, - MK48T35_CLKSZ - MK48T35_CLKOFF, 0, &ih) != 0) - goto fail0; + MK48T35_CLKSZ - MK48T35_CLKOFF, &ih) != 0) + goto fail; printf(": DS1742W\n"); @@ -209,9 +211,7 @@ done: return; -fail1: - bus_space_unmap(iaa->iaa_memt, ih, 1); -fail0: +fail: printf(": can't map registers\n"); } diff --git a/sys/arch/sgi/pci/ioc.c b/sys/arch/sgi/pci/ioc.c index a19240806f4..f4d9dcf083e 100644 --- a/sys/arch/sgi/pci/ioc.c +++ b/sys/arch/sgi/pci/ioc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ioc.c,v 1.18 2009/07/01 21:56:37 miod Exp $ */ +/* $OpenBSD: ioc.c,v 1.19 2009/07/26 19:58:51 miod Exp $ */ /* * Copyright (c) 2008 Joel Sing. @@ -158,13 +158,13 @@ ioc_attach(struct device *parent, struct device *self, void *aux) data = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); data |= PCI_COMMAND_MEM_ENABLE | PCI_COMMAND_PARITY_ENABLE | PCI_COMMAND_SERR_ENABLE; + data &= ~PCI_COMMAND_INTERRUPT_DISABLE; pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, data); printf("\n"); /* - * Build a suitable bus_space_handle by rebasing the xbridge - * inherited one to our BAR, and restoring the original + * 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 @@ -179,7 +179,6 @@ ioc_attach(struct device *parent, struct device *self, void *aux) } bcopy(memt, sc->sc_mem_bus_space, sizeof(*sc->sc_mem_bus_space)); - sc->sc_mem_bus_space->bus_base = memh; 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; @@ -187,9 +186,6 @@ ioc_attach(struct device *parent, struct device *self, void *aux) sc->sc_mem_bus_space->_space_write_2 = xbow_write_2; sc->sc_mem_bus_space->_space_write_raw_2 = xbow_write_raw_2; - /* XXX undo xbridge mapping games */ - sc->sc_mem_bus_space->_space_map = xbow_space_map; - sc->sc_memt = sc->sc_mem_bus_space; sc->sc_memh = memh; @@ -407,6 +403,7 @@ ioc_attach_child(struct device *ioc, const char *name, bus_addr_t base, int dev) iaa.iaa_name = name; iaa.iaa_memt = sc->sc_memt; + iaa.iaa_memh = sc->sc_memh; iaa.iaa_dmat = sc->sc_dmat; iaa.iaa_base = base; iaa.iaa_dev = dev; diff --git a/sys/arch/sgi/pci/iocvar.h b/sys/arch/sgi/pci/iocvar.h index e59a2ac783d..a5c314f6084 100644 --- a/sys/arch/sgi/pci/iocvar.h +++ b/sys/arch/sgi/pci/iocvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: iocvar.h,v 1.2 2009/04/12 17:56:58 miod Exp $ */ +/* $OpenBSD: iocvar.h,v 1.3 2009/07/26 19:58:51 miod Exp $ */ /* * Copyright (c) 2008 Miodrag Vallat. @@ -17,15 +17,16 @@ */ struct ioc_attach_args { - const char *iaa_name; + const char *iaa_name; - bus_space_tag_t iaa_memt; - bus_dma_tag_t iaa_dmat; + bus_space_tag_t iaa_memt; + bus_space_handle_t iaa_memh; + bus_dma_tag_t iaa_dmat; - bus_addr_t iaa_base; - int iaa_dev; + bus_addr_t iaa_base; + int iaa_dev; - uint8_t iaa_enaddr[6]; + uint8_t iaa_enaddr[6]; }; void *ioc_intr_establish(void *, u_long, int, int (*)(void *), -- cgit v1.2.3