diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2009-10-07 20:39:46 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2009-10-07 20:39:46 +0000 |
commit | 4021e2f6b72e9d0358f5d30e4ab199f739f75f52 (patch) | |
tree | c841fb0e0e55dac3bea16434cd9d42b4ac640ff0 /sys/arch/sgi/dev | |
parent | 6b7b099709e35bdc1103c2dbd35b58c5eb3a7ef0 (diff) |
Attach DS1742 style dsrtc to iof (IOC4) too.
Diffstat (limited to 'sys/arch/sgi/dev')
-rw-r--r-- | sys/arch/sgi/dev/dsrtc.c | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/sys/arch/sgi/dev/dsrtc.c b/sys/arch/sgi/dev/dsrtc.c index 3aeb43f8942..fb26b20ab09 100644 --- a/sys/arch/sgi/dev/dsrtc.c +++ b/sys/arch/sgi/dev/dsrtc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsrtc.c,v 1.6 2009/07/26 19:58:49 miod Exp $ */ +/* $OpenBSD: dsrtc.c,v 1.7 2009/10/07 20:39:45 miod Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -45,6 +45,7 @@ #include <sgi/localbus/macebus.h> #include <sgi/pci/iocreg.h> #include <sgi/pci/iocvar.h> +#include <sgi/pci/iofvar.h> struct dsrtc_softc { struct device sc_dev; @@ -58,6 +59,7 @@ struct dsrtc_softc { int dsrtc_match(struct device *, void *, void *); void dsrtc_attach_ioc(struct device *, struct device *, void *); +void dsrtc_attach_iof(struct device *, struct device *, void *); void dsrtc_attach_macebus(struct device *, struct device *, void *); struct cfdriver dsrtc_cd = { @@ -72,6 +74,10 @@ struct cfattach dsrtc_ioc_ca = { sizeof(struct dsrtc_softc), dsrtc_match, dsrtc_attach_ioc }; +struct cfattach dsrtc_iof_ca = { + sizeof(struct dsrtc_softc), dsrtc_match, dsrtc_attach_ioc +}; + int ip32_dsrtc_read(struct dsrtc_softc *, int); void ip32_dsrtc_write(struct dsrtc_softc *, int, int); int ioc_ds1687_dsrtc_read(struct dsrtc_softc *, int); @@ -216,6 +222,46 @@ fail: } void +dsrtc_attach_iof(struct device *parent, struct device *self, void *aux) +{ + struct dsrtc_softc *sc = (void *)self; + struct iof_attach_args *iaa = aux; + bus_space_handle_t ih; + + /* + * The IOC4 RTC is a DS1747 or compatible (itself being a Mostek + * MK48T35 clone). + */ + + if (bus_space_subregion(iaa->iaa_memt, iaa->iaa_memh, + iaa->iaa_base + MK48T35_CLKOFF, + MK48T35_CLKSZ - MK48T35_CLKOFF, &ih) != 0) + goto fail; + + printf(": DS1742W\n"); + + sc->sc_clkh = ih; + + /* + * For some reason, the base year differs between IP27 + * and IP35. + */ + sc->sc_yrbase = sys_config.system_type == SGI_O300 ? + POSIX_BASE_YEAR - 2 : POSIX_BASE_YEAR; + /* 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; + + return; + +fail: + printf(": can't map registers\n"); +} + +void dsrtc_attach_macebus(struct device *parent, struct device *self, void *aux) { struct dsrtc_softc *sc = (void *)self; |