diff options
Diffstat (limited to 'sys/dev/dec/mcclock.c')
-rw-r--r-- | sys/dev/dec/mcclock.c | 54 |
1 files changed, 13 insertions, 41 deletions
diff --git a/sys/dev/dec/mcclock.c b/sys/dev/dec/mcclock.c index 76e3805..3aada8b 100644 --- a/sys/dev/dec/mcclock.c +++ b/sys/dev/dec/mcclock.c @@ -1,4 +1,4 @@ -/* $Id$ */ +/* $Id: mcclock.c,v 1.1 1998/06/10 10:56:23 dfr Exp $ */ /* $NetBSD: mcclock.c,v 1.11 1998/04/19 07:50:25 jonathan Exp $ */ /* @@ -33,7 +33,7 @@ #include <sys/systm.h> #include <sys/bus.h> -#include <dev/dec/clockvar.h> +#include <machine/clockvar.h> #include <dev/dec/mcclockvar.h> #include <dev/dec/mc146818reg.h> @@ -47,41 +47,20 @@ #define MC_DEFAULTRATE MC_RATE_256_Hz #endif - -void mcclock_init __P((struct device *)); -void mcclock_get __P((struct device *, time_t, struct clocktime *)); -void mcclock_set __P((struct device *, struct clocktime *)); - -const struct clockfns mcclock_clockfns = { - mcclock_init, mcclock_get, mcclock_set, -}; - -#define mc146818_write(dev, reg, datum) \ - (*(dev)->sc_busfns->mc_bf_write)(dev, reg, datum) -#define mc146818_read(dev, reg) \ - (*(dev)->sc_busfns->mc_bf_read)(dev, reg) - void -mcclock_attach(sc, busfns) - struct mcclock_softc *sc; - const struct mcclock_busfns *busfns; +mcclock_attach(device_t dev) { - sc->sc_busfns = busfns; - /* Turn interrupts off, just in case. */ - mc146818_write(sc, MC_REGB, MC_REGB_BINARY | MC_REGB_24HR); + MCCLOCK_WRITE(dev, MC_REGB, MC_REGB_BINARY | MC_REGB_24HR); - clockattach(sc->sc_dev, &mcclock_clockfns); + clockattach(dev); } void -mcclock_init(dev) - device_t dev; +mcclock_init(device_t dev) { - struct mcclock_softc *sc = device_get_softc(dev); - - mc146818_write(sc, MC_REGA, MC_BASE_32_KHz | MC_DEFAULTRATE); - mc146818_write(sc, MC_REGB, + MCCLOCK_WRITE(dev, MC_REGA, MC_BASE_32_KHz | MC_DEFAULTRATE); + MCCLOCK_WRITE(dev, MC_REGB, MC_REGB_PIE | MC_REGB_SQWE | MC_REGB_BINARY | MC_REGB_24HR); } @@ -89,17 +68,13 @@ mcclock_init(dev) * Get the time of day, based on the clock's value and/or the base value. */ void -mcclock_get(dev, base, ct) - struct device *dev; - time_t base; - struct clocktime *ct; +mcclock_get(device_t dev, time_t base, struct clocktime *ct) { - struct mcclock_softc *sc = device_get_softc(dev); mc_todregs regs; int s; s = splclock(); - MC146818_GETTOD(sc, ®s) + MC146818_GETTOD(dev, ®s) splx(s); ct->sec = regs[MC_SEC]; @@ -115,16 +90,13 @@ mcclock_get(dev, base, ct) * Reset the TODR based on the time value. */ void -mcclock_set(dev, ct) - struct device *dev; - struct clocktime *ct; +mcclock_set(device_t dev, struct clocktime *ct) { - struct mcclock_softc *sc = device_get_softc(dev); mc_todregs regs; int s; s = splclock(); - MC146818_GETTOD(sc, ®s); + MC146818_GETTOD(dev, ®s); splx(s); regs[MC_SEC] = ct->sec; @@ -136,6 +108,6 @@ mcclock_set(dev, ct) regs[MC_YEAR] = ct->year; s = splclock(); - MC146818_PUTTOD(sc, ®s); + MC146818_PUTTOD(dev, ®s); splx(s); } |