diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2009-10-26 18:34:54 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2009-10-26 18:34:54 +0000 |
commit | f756ec3c6b3d2cbefc3fc6c431706443bf69cf8f (patch) | |
tree | aeaf39482a9930e2781e7c78d8d280343d8610da /sys | |
parent | 8b5859933cfc55df939a3782f61ae73efa2a8c1e (diff) |
Remove DS1687 vs DS742 runtime detection code; we only attach dsrtc on the
onboard ioc(4) devices, and on Octane this is always a DS1687 wired to
IOC3 bytebus #1 and #2, while on Origin this is always a DS1742 wired to
IOC3 bytebus #0.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/sgi/dev/dsrtc.c | 63 |
1 files changed, 13 insertions, 50 deletions
diff --git a/sys/arch/sgi/dev/dsrtc.c b/sys/arch/sgi/dev/dsrtc.c index 2a9c482f788..2507ed6ed2d 100644 --- a/sys/arch/sgi/dev/dsrtc.c +++ b/sys/arch/sgi/dev/dsrtc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsrtc.c,v 1.8 2009/10/26 18:00:06 miod Exp $ */ +/* $OpenBSD: dsrtc.c,v 1.9 2009/10/26 18:34:53 miod Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -115,8 +115,6 @@ dsrtc_attach_ioc(struct device *parent, struct device *self, void *aux) struct dsrtc_softc *sc = (void *)self; struct ioc_attach_args *iaa = aux; bus_space_handle_t ih, ih2; - uint c, c2, c3; - int ds1687 = 0; /* * The IOC3 RTC is either a Dallas (now Maxim) DS1386 or compatible @@ -130,53 +128,17 @@ dsrtc_attach_ioc(struct device *parent, struct device *self, void *aux) * addresses in memory. */ - 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; + sc->sc_clkt = iaa->iaa_memt; - /* - * Check the low 4 bits of control register C. If any is set, - * or if the values written to them stick, then this is not - * a Dallas chip. - * - * Note that the value we read the next few times can't be - * compared to the first value read, as the upper four bits - * are cleared by reading them. And might get set again - * between two reads. - */ + if (iaa->iaa_base != IOC3_BYTEBUS_0) { + /* DS1687 */ - bus_space_write_1(iaa->iaa_memt, ih, 0, DS1687_CTRL_C); - c = bus_space_read_1(iaa->iaa_memt, ih2, 0); - if ((c & 0x0f) != 0) - goto done; - - bus_space_write_1(iaa->iaa_memt, ih, 0, DS1687_CTRL_C); - bus_space_write_1(iaa->iaa_memt, ih2, 0, c | 0x0f); - - bus_space_write_1(iaa->iaa_memt, ih, 0, DS1687_CTRL_C); - c2 = bus_space_read_1(iaa->iaa_memt, ih2, 0); - if ((c2 & 0x0f) == 0) - ds1687 = 1; /* maybe... */ - - bus_space_write_1(iaa->iaa_memt, ih, 0, DS1687_CTRL_C); - bus_space_write_1(iaa->iaa_memt, ih2, 0, c2 | 0x0f); - - bus_space_write_1(iaa->iaa_memt, ih, 0, DS1687_CTRL_C); - c3 = bus_space_read_1(iaa->iaa_memt, ih2, 0); - if ((c3 & 0x0f) != 0) - ds1687 = 0; /* ...well, no. */ - - /* write back first value read in case this is not a DS1687 */ - if (ds1687 == 0) { - bus_space_write_1(iaa->iaa_memt, ih, 0, DS1687_CTRL_C); - bus_space_write_1(iaa->iaa_memt, ih2, 0, c); - } - -done: - sc->sc_clkt = iaa->iaa_memt; + 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; - if (ds1687) { printf(": DS1687\n"); sc->sc_clkh = ih; @@ -185,15 +147,16 @@ done: sc->read = ioc_ds1687_dsrtc_read; sc->write = ioc_ds1687_dsrtc_write; - sys_tod.tod_cookie = self; sys_tod.tod_get = ds1687_get; sys_tod.tod_set = ds1687_set; } else { + /* DS1742W */ + bus_space_unmap(iaa->iaa_memt, ih, 1); bus_space_unmap(iaa->iaa_memt, ih2, 1); if (bus_space_subregion(iaa->iaa_memt, iaa->iaa_memh, - IOC3_BYTEBUS_0 + MK48T35_CLKOFF, + iaa->iaa_base + MK48T35_CLKOFF, MK48T35_CLKSZ - MK48T35_CLKOFF, &ih) != 0) goto fail; @@ -210,10 +173,10 @@ done: /* mips64 clock code expects year relative to 1900 */ sc->sc_yrbase -= 1900; - sys_tod.tod_cookie = self; sys_tod.tod_get = ds1742_get; sys_tod.tod_set = ds1742_set; } + sys_tod.tod_cookie = self; return; |