diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2009-07-26 19:58:52 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2009-07-26 19:58:52 +0000 |
commit | 5932d6e6e2eff29a468cbf532d61611a5fe6dd69 (patch) | |
tree | 603fca9cb35e6a83557b2f567fece11acbf2cef4 /sys/arch/sgi/dev | |
parent | f039b21c5c4b8960cd07e82793c4127546646142 (diff) |
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.
Diffstat (limited to 'sys/arch/sgi/dev')
-rw-r--r-- | sys/arch/sgi/dev/com_ioc.c | 36 | ||||
-rw-r--r-- | sys/arch/sgi/dev/dsrtc.c | 24 |
2 files changed, 37 insertions, 23 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"); } |