Index: arch/arm/ep93xx/epclk.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/ep93xx/epclk.c,v
retrieving revision 1.9
diff -d -p -u -r1.9 epclk.c
--- arch/arm/ep93xx/epclk.c	10 Sep 2006 22:04:18 -0000	1.9
+++ arch/arm/ep93xx/epclk.c	19 Sep 2006 18:17:53 -0000
@@ -324,93 +324,3 @@ delay(unsigned int len)
 		ticks = TIMER4VAL();
 	}
 }
-
-#ifndef __HAVE_GENERIC_TODR
-
-todr_chip_handle_t todr_handle;
-
-/*
- * todr_attach:
- *
- *	Set the specified time-of-day register as the system real-time clock.
- */
-void
-todr_attach(todr_chip_handle_t todr)
-{
-
-	if (todr_handle)
-		panic("todr_attach: rtc already configured");
-	todr_handle = todr;
-}
-
-/*
- * inittodr:
- *
- *	Initialize time from the time-of-day register.
- */
-#define	MINYEAR		2003	/* minimum plausible year */
-void
-inittodr(time_t base)
-{
-	time_t deltat;
-	int badbase;
-
-	if (base < (MINYEAR - 1970) * SECYR) {
-		printf("WARNING: preposterous time in file system\n");
-		/* read the system clock anyway */
-		base = (MINYEAR - 1970) * SECYR;
-		badbase = 1;
-	} else
-		badbase = 0;
-
-	if (todr_handle == NULL ||
-	    todr_gettime(todr_handle, &time) != 0 ||
-	    time.tv_sec == 0) {
-		/*
-		 * Believe the time in the file system for lack of
-		 * anything better, resetting the TODR.
-		 */
-		time.tv_sec = base;
-		time.tv_usec = 0;
-		if (todr_handle != NULL && !badbase) {
-			printf("WARNING: preposterous clock chip time\n");
-			resettodr();
-		}
-		goto bad;
-	}
-
-	if (!badbase) {
-		/*
-		 * See if we gained/lost two or more days; if
-		 * so, assume something is amiss.
-		 */
-		deltat = time.tv_sec - base;
-		if (deltat < 0)
-			deltat = -deltat;
-		if (deltat < 2 * SECDAY)
-			return;		/* all is well */
-		printf("WARNING: clock %s %ld days\n",
-		    time.tv_sec < base ? "lost" : "gained",
-		    (long)deltat / SECDAY);
-	}
- bad:
-	printf("WARNING: CHECK AND RESET THE DATE!\n");
-}
-
-/*
- * resettodr:
- *
- *	Reset the time-of-day register with the current time.
- */
-void
-resettodr(void)
-{
-
-	if (time.tv_sec == 0)
-		return;
-
-	if (todr_handle != NULL &&
-	    todr_settime(todr_handle, &time) != 0)
-		printf("resettodr: failed to set time\n");
-}
-#endif
Index: arch/arm/footbridge/footbridge.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/footbridge/footbridge.c,v
retrieving revision 1.16
diff -d -p -u -r1.16 footbridge.c
--- arch/arm/footbridge/footbridge.c	11 Dec 2005 12:16:45 -0000	1.16
+++ arch/arm/footbridge/footbridge.c	19 Sep 2006 18:17:53 -0000
@@ -216,14 +216,6 @@ footbridge_attach(parent, self, aux)
 	fba.fba_pba.pba_bridgetag = NULL;
 	config_found_ia(self, "pcibus", &fba.fba_pba, pcibusprint);
 
-	/* Attach a time-of-day clock device */
-	fba.fba_tca.ta_name = "todclock";
-	fba.fba_tca.ta_rtc_arg = NULL;
-	fba.fba_tca.ta_rtc_write = NULL;
-	fba.fba_tca.ta_rtc_read = NULL;
-	fba.fba_tca.ta_flags = TODCLOCK_FLAG_FAKE;
-	config_found_ia(self, "todservice", &fba.fba_tca, footbridge_print); 
-
 	/* Attach uart device */
 	fba.fba_fca.fca_name = "fcom";
 	fba.fba_fca.fca_iot = sc->sc_iot;
Index: arch/arm/footbridge/footbridgevar.h
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/footbridge/footbridgevar.h,v
retrieving revision 1.4
diff -d -p -u -r1.4 footbridgevar.h
--- arch/arm/footbridge/footbridgevar.h	11 Dec 2005 12:16:46 -0000	1.4
+++ arch/arm/footbridge/footbridgevar.h	19 Sep 2006 18:17:53 -0000
@@ -37,7 +37,6 @@
 #include <machine/bus.h>
 #include <machine/rtc.h>
 #include <dev/pci/pcivar.h>
-#include <arm/footbridge/todclockvar.h>
 
 /*
  * DC21285 softc structure.
@@ -77,7 +76,6 @@ union footbridge_attach_args {
 		bus_space_handle_t fba_ioh;	/* Bus handle */
 	} fba_fba;
 	struct pcibus_attach_args fba_pba;	/* pci attach args */
-	struct todclock_attach_args fba_tca;
 	struct fcom_attach_args {
 		const char *fca_name;
 		bus_space_tag_t fca_iot;
Index: arch/arm/footbridge/isa/dsrtc.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/footbridge/isa/dsrtc.c,v
retrieving revision 1.9
diff -d -p -u -r1.9 dsrtc.c
--- arch/arm/footbridge/isa/dsrtc.c	11 Sep 2006 19:14:57 -0000	1.9
+++ arch/arm/footbridge/isa/dsrtc.c	19 Sep 2006 18:17:53 -0000
@@ -45,9 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: dsrtc.c,v 1.
 #include <sys/conf.h>
 #include <sys/device.h>
 
-#include <machine/rtc.h>
-
-#include <arm/footbridge/todclockvar.h>
+#include <dev/clock_subr.h>
 #include <arm/footbridge/isa/ds1687reg.h>
 
 #include <dev/isa/isavar.h>
@@ -58,6 +56,7 @@ struct dsrtc_softc {
 	struct device	sc_dev;
 	bus_space_tag_t	sc_iot;
 	bus_space_handle_t sc_ioh;
+	struct todr_chip_handle sc_todr;
 };
 
 void dsrtcattach(struct device *parent, struct device *self, void *aux);
@@ -69,8 +68,8 @@ int ds1687_ram_read(struct dsrtc_softc *
 void ds1687_ram_write(struct dsrtc_softc *sc, int addr, int data);
 #endif
 static void ds1687_bank_select(struct dsrtc_softc *, int);
-static int dsrtc_write(void *, rtc_t *);
-static int dsrtc_read(void *, rtc_t *);
+static int dsrtc_write(todr_chip_handle_t, struct clock_ymdhms *);
+static int dsrtc_read(todr_chip_handle_t, struct clock_ymdhms *);
 
 int
 ds1687_read(struct dsrtc_softc *sc, int addr)
@@ -146,40 +145,38 @@ ds1687_ram_write(struct dsrtc_softc *sc,
 #endif
 
 static int
-dsrtc_write(void *arg, rtc_t *rtc)
+dsrtc_write(todr_chip_handle_t tc, struct clock_ymdhms *dt)
 {
-	struct dsrtc_softc *sc = arg;
+	struct dsrtc_softc *sc = tc->cookie;
 
-	ds1687_write(sc, RTC_SECONDS, rtc->rtc_sec);
-	ds1687_write(sc, RTC_MINUTES, rtc->rtc_min);
-	ds1687_write(sc, RTC_HOURS, rtc->rtc_hour);
-	ds1687_write(sc, RTC_DAYOFMONTH, rtc->rtc_day);
-	ds1687_write(sc, RTC_MONTH, rtc->rtc_mon);
-	ds1687_write(sc, RTC_YEAR, rtc->rtc_year);
+	ds1687_write(sc, RTC_SECONDS, dt->dt_sec);
+	ds1687_write(sc, RTC_MINUTES, dt->dt_min);
+	ds1687_write(sc, RTC_HOURS, dt->dt_hour);
+	ds1687_write(sc, RTC_DAYOFMONTH, dt->dt_day);
+	ds1687_write(sc, RTC_MONTH, dt->dt_mon);
+	ds1687_write(sc, RTC_YEAR, dt->dt_year % 100);
 	ds1687_bank_select(sc, 1);
-	ds1687_write(sc, RTC_CENTURY, rtc->rtc_cen);
+	ds1687_write(sc, RTC_CENTURY, dt->dt_year / 100);
 	ds1687_bank_select(sc, 0);
-	return(1);
+	return(0);
 }
 
 static int
-dsrtc_read(void *arg, rtc_t *rtc)
+dsrtc_read(todr_chip_handle_t tc, struct clock_ymdhms *dt)
 {
-	struct dsrtc_softc *sc = arg;
+	struct dsrtc_softc *sc = tc->cookie;
 
-	rtc->rtc_micro = 0;
-	rtc->rtc_centi = 0;
-	rtc->rtc_sec   = ds1687_read(sc, RTC_SECONDS);
-	rtc->rtc_min   = ds1687_read(sc, RTC_MINUTES);
-	rtc->rtc_hour  = ds1687_read(sc, RTC_HOURS);
-	rtc->rtc_day   = ds1687_read(sc, RTC_DAYOFMONTH);
-	rtc->rtc_mon   = ds1687_read(sc, RTC_MONTH);
-	rtc->rtc_year  = ds1687_read(sc, RTC_YEAR);
+	dt->dt_sec   = ds1687_read(sc, RTC_SECONDS);
+	dt->dt_min   = ds1687_read(sc, RTC_MINUTES);
+	dt->dt_hour  = ds1687_read(sc, RTC_HOURS);
+	dt->dt_day   = ds1687_read(sc, RTC_DAYOFMONTH);
+	dt->dt_mon   = ds1687_read(sc, RTC_MONTH);
+	dt->dt_year  = ds1687_read(sc, RTC_YEAR);
 	ds1687_bank_select(sc, 1);
-	rtc->rtc_cen   = ds1687_read(sc, RTC_CENTURY); 
+	dt->dt_year  += ds1687_read(sc, RTC_CENTURY) * 100;
 	ds1687_bank_select(sc, 0);
 
-	return(1);
+	return(0);
 }
 
 /* device and attach structures */
@@ -222,7 +219,6 @@ dsrtcattach(struct device *parent, struc
 {
 	struct dsrtc_softc *sc = (struct dsrtc_softc *)self;
 	struct isa_attach_args *ia = aux;
-	struct todclock_attach_args ta;
 	
 	sc->sc_iot = ia->ia_iot;
 	if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr,
@@ -238,12 +234,10 @@ dsrtcattach(struct device *parent, struc
 		printf(": lithium cell is dead, RTC unreliable");
 	printf("\n");
 
-	ta.ta_name = "todclock";
-	ta.ta_rtc_arg = sc;
-	ta.ta_rtc_write = dsrtc_write; 
-	ta.ta_rtc_read = dsrtc_read;
-	ta.ta_flags = 0;
-	config_found(self, &ta, NULL);
+	sc->sc_todr.todr_gettime_ymdhms = dsrtc_read;
+	sc->sc_todr.todr_settime_ymdhms = dsrtc_write;
+	sc->sc_todr.cookie = sc;
+	todr_attach(&sc->sc_todr);
 }
 
 /* End of dsrtc.c */
Index: arch/arm/ixp12x0/ixp12x0_clk.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/ixp12x0/ixp12x0_clk.c,v
retrieving revision 1.10
diff -d -p -u -r1.10 ixp12x0_clk.c
--- arch/arm/ixp12x0/ixp12x0_clk.c	11 Dec 2005 12:16:50 -0000	1.10
+++ arch/arm/ixp12x0/ixp12x0_clk.c	19 Sep 2006 18:17:53 -0000
@@ -365,16 +365,3 @@ delay(unsigned int usecs)
 		otick = ticks;
 	}
 }
-
-void
-resettodr(void)
-{
-}
-
-void
-inittodr(time_t base)
-{
-
-	time.tv_sec = base;
-	time.tv_usec = 0;
-}
Index: arch/arm/s3c2xx0/s3c24x0_clk.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/s3c2xx0/s3c24x0_clk.c,v
retrieving revision 1.6
diff -d -p -u -r1.6 s3c24x0_clk.c
--- arch/arm/s3c2xx0/s3c24x0_clk.c	24 Dec 2005 20:06:52 -0000	1.6
+++ arch/arm/s3c2xx0/s3c24x0_clk.c	19 Sep 2006 18:17:53 -0000
@@ -230,29 +230,6 @@ delay(u_int n)
 	/*NOTREACHED*/
 }
 
-/*
- * inittodr:
- *
- *	Initialize time from the time-of-day register.
- */
-void
-inittodr(time_t base)
-{
-
-	time.tv_sec = base;
-	time.tv_usec = 0;
-}
-
-/*
- * resettodr:
- *
- *	Reset the time-of-day register with the current time.
- */
-void
-resettodr(void)
-{
-}
-
 void
 setstatclockrate(int newhz)
 {
Index: arch/arm/s3c2xx0/s3c2800_clk.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/s3c2xx0/s3c2800_clk.c,v
retrieving revision 1.9
diff -d -p -u -r1.9 s3c2800_clk.c
--- arch/arm/s3c2xx0/s3c2800_clk.c	24 Dec 2005 20:06:52 -0000	1.9
+++ arch/arm/s3c2xx0/s3c2800_clk.c	19 Sep 2006 18:17:53 -0000
@@ -238,29 +238,6 @@ delay(u_int n)
 	/*NOTREACHED*/
 }
 
-/*
- * inittodr:
- *
- *	Initialize time from the time-of-day register.
- */
-void
-inittodr(time_t base)
-{
-
-	time.tv_sec = base;
-	time.tv_usec = 0;
-}
-
-/*
- * resettodr:
- *
- *	Reset the time-of-day register with the current time.
- */
-void
-resettodr(void)
-{
-}
-
 void
 setstatclockrate(int newhz)
 {
Index: arch/arm/sa11x0/sa11x0_ost.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/sa11x0/sa11x0_ost.c,v
retrieving revision 1.18
diff -d -p -u -r1.18 sa11x0_ost.c
--- arch/arm/sa11x0/sa11x0_ost.c	27 Jun 2006 13:58:08 -0000	1.18
+++ arch/arm/sa11x0/sa11x0_ost.c	19 Sep 2006 18:17:53 -0000
@@ -334,15 +334,3 @@ delay(u_int usecs)
 		otick = xtick;
 	}
 }
-
-void
-resettodr(void)
-{
-}
-
-void
-inittodr(time_t base)
-{
-	time.tv_sec = base;
-	time.tv_usec = 0;
-}
Index: arch/arm/xscale/becc_timer.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/xscale/becc_timer.c,v
retrieving revision 1.10
diff -d -p -u -r1.10 becc_timer.c
--- arch/arm/xscale/becc_timer.c	10 Sep 2006 22:04:18 -0000	1.10
+++ arch/arm/xscale/becc_timer.c	19 Sep 2006 18:17:54 -0000
@@ -266,95 +266,6 @@ delay(u_int n)
 	}
 }
 
-#ifndef __HAVE_GENERIC_TODR
-
-todr_chip_handle_t todr_handle;
-
-/*
- * todr_attach:
- *
- *	Set the specified time-of-day register as the system real-time clock.
- */
-void
-todr_attach(todr_chip_handle_t todr)
-{
-
-	if (todr_handle)
-		panic("todr_attach: rtc already configured");
-	todr_handle = todr;
-}
-
-/*
- * inittodr:
- *
- *	Initialize time from the time-of-day register.
- */
-#define	MINYEAR		2003	/* minimum plausible year */
-void
-inittodr(time_t base)
-{
-	time_t deltat;
-	int badbase;
-
-	if (base < (MINYEAR - 1970) * SECYR) {
-		printf("WARNING: preposterous time in file system");
-		/* read the system clock anyway */
-		base = (MINYEAR - 1970) * SECYR;
-		badbase = 1;
-	} else
-		badbase = 0;
-
-	if (todr_handle == NULL ||
-	    todr_gettime(todr_handle, &time) != 0 || time.tv_sec == 0) {
-		/*
-		 * Believe the time in the file system for lack of
-		 * anything better, resetting the TODR.
-		 */
-		time.tv_sec = base;
-		time.tv_usec = 0;
-		if (todr_handle != NULL && !badbase) {
-			printf("WARNING: preposterous clock chip time\n");
-			resettodr();
-		}
-		goto bad;
-	}
-
-	if (!badbase) {
-		/*
-		 * See if we gained/lost two or more days; if
-		 * so, assume something is amiss.
-		 */
-		deltat = time.tv_sec - base;
-		if (deltat < 0)
-			deltat = -deltat;
-		if (deltat < 2 * SECDAY)
-			return;		/* all is well */
-		printf("WARNING: clock %s %ld days\n",
-		    time.tv_sec < base ? "lost" : "gained",
-		    (long)deltat / SECDAY);
-	}
- bad:
-	printf("WARNING: CHECK AND RESET THE DATE!\n");
-}
-
-/*
- * resettodr:
- *
- *	Reset the time-of-day register with the current time.
- */
-void
-resettodr(void)
-{
-
-	if (time.tv_sec == 0)
-		return;
-
-	if (todr_handle != NULL &&
-	    todr_settime(todr_handle, &time) != 0)
-		printf("resettodr: failed to set time\n");
-}
-#endif	/* __HAVE_GENERIC_TODR */
-
 /*
  * clockhandler:
  *
Index: arch/arm/xscale/i80321_timer.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/xscale/i80321_timer.c,v
retrieving revision 1.15
diff -d -p -u -r1.15 i80321_timer.c
--- arch/arm/xscale/i80321_timer.c	10 Sep 2006 23:13:59 -0000	1.15
+++ arch/arm/xscale/i80321_timer.c	19 Sep 2006 18:17:54 -0000
@@ -416,95 +416,6 @@ delay(u_int n)
 	}
 }
 
-#ifndef __HAVE_GENERIC_TODR
-todr_chip_handle_t todr_handle;
-
-/*
- * todr_attach:
- *
- *	Set the specified time-of-day register as the system real-time clock.
- */
-void
-todr_attach(todr_chip_handle_t todr)
-{
-
-	if (todr_handle)
-		panic("todr_attach: rtc already configured");
-	todr_handle = todr;
-}
-
-/*
- * inittodr:
- *
- *	Initialize time from the time-of-day register.
- */
-#define	MINYEAR		2003	/* minimum plausible year */
-void
-inittodr(time_t base)
-{
-	time_t deltat;
-	int badbase;
-
-	if (base < (MINYEAR - 1970) * SECYR) {
-		printf("WARNING: preposterous time in file system");
-		/* read the system clock anyway */
-		base = (MINYEAR - 1970) * SECYR;
-		badbase = 1;
-	} else
-		badbase = 0;
-
-	if (todr_handle == NULL ||
-	    todr_gettime(todr_handle, &time) != 0 ||
-	    time.tv_sec == 0) {
-		/*
-		 * Believe the time in the file system for lack of
-		 * anything better, resetting the TODR.
-		 */
-		time.tv_sec = base;
-		time.tv_usec = 0;
-		if (todr_handle != NULL && !badbase) {
-			printf("WARNING: preposterous clock chip time\n");
-			resettodr();
-		}
-		goto bad;
-	}
-
-	if (!badbase) {
-		/*
-		 * See if we gained/lost two or more days; if
-		 * so, assume something is amiss.
-		 */
-		deltat = time.tv_sec - base;
-		if (deltat < 0)
-			deltat = -deltat;
-		if (deltat < 2 * SECDAY)
-			return;		/* all is well */
-		printf("WARNING: clock %s %ld days\n",
-		    time.tv_sec < base ? "lost" : "gained",
-		    (long)deltat / SECDAY);
-	}
- bad:
-	printf("WARNING: CHECK AND RESET THE DATE!\n");
-}
-
-/*
- * resettodr:
- *
- *	Reset the time-of-day register with the current time.
- */
-void
-resettodr(void)
-{
-
-	if (time.tv_sec == 0)
-		return;
-
-	if (todr_handle != NULL &&
-	    todr_settime(todr_handle, &time) != 0)
-		printf("resettodr: failed to set time\n");
-}
-#endif
-
 /*
  * clockhandler:
  *
Index: arch/arm/xscale/ixp425_timer.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/xscale/ixp425_timer.c,v
retrieving revision 1.12
diff -d -p -u -r1.12 ixp425_timer.c
--- arch/arm/xscale/ixp425_timer.c	10 Sep 2006 22:04:18 -0000	1.12
+++ arch/arm/xscale/ixp425_timer.c	19 Sep 2006 18:17:54 -0000
@@ -290,98 +290,6 @@ delay(u_int n)
 	}
 }
 
-
-#ifndef __HAVE_GENERIC_TODR
-
-todr_chip_handle_t todr_handle;
-
-/*
- * todr_attach:
- *
- *	Set the specified time-of-day register as the system real-time clock.
- */
-void
-todr_attach(todr_chip_handle_t todr)
-{
-
-	if (todr_handle)
-		panic("todr_attach: rtc already configured");
-	todr_handle = todr;
-}
-
-/*
- * inittodr:
- *
- *	Initialize time from the time-of-day register.
- */
-#define	MINYEAR		2003	/* minimum plausible year */
-void
-inittodr(time_t base)
-{
-	time_t deltat;
-	int badbase;
-
-	if (base < (MINYEAR - 1970) * SECYR) {
-		printf("WARNING: preposterous time in file system");
-		/* read the system clock anyway */
-		base = (MINYEAR - 1970) * SECYR;
-		badbase = 1;
-	} else
-		badbase = 0;
-
-	if (todr_handle == NULL ||
-	    todr_gettime(todr_handle, &time) != 0 ||
-	    time.tv_sec == 0) {
-		/*
-		 * Believe the time in the file system for lack of
-		 * anything better, resetting the TODR.
-		 */
-		time.tv_sec = base;
-		time.tv_usec = 0;
-		if (todr_handle != NULL && !badbase) {
-			printf("WARNING: preposterous clock chip time\n");
-			resettodr();
-		}
-		goto bad;
-	}
-
-	if (!badbase) {
-		/*
-		 * See if we gained/lost two or more days; if
-		 * so, assume something is amiss.
-		 */
-		deltat = time.tv_sec - base;
-		if (deltat < 0)
-			deltat = -deltat;
-		if (deltat < 2 * SECDAY)
-			return;		/* all is well */
-		printf("WARNING: clock %s %ld days\n",
-		    time.tv_sec < base ? "lost" : "gained",
-		    (long)deltat / SECDAY);
-	}
- bad:
-	printf("WARNING: CHECK AND RESET THE DATE!\n");
-}
-
-/*
- * resettodr:
- *
- *	Reset the time-of-day register with the current time.
- */
-void
-resettodr(void)
-{
-
-	if (time.tv_sec == 0)
-		return;
-
-	if (todr_handle != NULL &&
-	    todr_settime(todr_handle, &time) != 0)
-		printf("resettodr: failed to set time\n");
-}
-
-#endif
-
 /*
  * ixpclk_intr:
  *
Index: arch/evbarm/ifpga/pl030_rtc.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/ifpga/pl030_rtc.c,v
retrieving revision 1.7
diff -d -p -u -r1.7 pl030_rtc.c
--- arch/evbarm/ifpga/pl030_rtc.c	11 Dec 2005 12:17:09 -0000	1.7
+++ arch/evbarm/ifpga/pl030_rtc.c	19 Sep 2006 18:17:54 -0000
@@ -40,6 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: pl030_rtc.c,
 #include <sys/kernel.h>
 #include <sys/time.h>
 #include <sys/device.h>
+#include <dev/clock_subr.h>
 
 #include <arm/cpufunc.h>
 #include <machine/intr.h>
@@ -53,20 +54,17 @@ struct plrtc_softc {
 	struct device		    sc_dev;
 	bus_space_tag_t		    sc_iot;
 	bus_space_handle_t	    sc_ioh;
+	struct todr_chip_handle	    sc_todr;
 };
 
 static int  plrtc_probe  (struct device *, struct cfdata *, void *);
 static void plrtc_attach (struct device *, struct device *, void *);
+static int plrtc_gettime(todr_chip_handle_t, volatile struct timeval *);
+static int plrtc_settime(todr_chip_handle_t, volatile struct timeval *);
 
 CFATTACH_DECL(plrtc, sizeof(struct plrtc_softc),
     plrtc_probe, plrtc_attach, NULL, NULL);
 
-/* Remember our handle, since it isn't passed in by inittodr and
-   resettodr.  */
-static struct plrtc_softc *plrtc_sc;
-
-static int timeset = 0;
-
 static int
 plrtc_probe(struct device *parent, struct cfdata *cf, void *aux)
 {
@@ -86,46 +84,28 @@ plrtc_attach(struct device *parent, stru
 		return;
 	}
 
-	plrtc_sc = sc;
+	sc->sc_todr.cookie = sc;
+	sc->sc_todr.todr_gettime = plrtc_gettime;
+	sc->sc_todr.todr_settime = plrtc_settime;
 
 	printf("\n");
 }
 
-void
-inittodr(time_t base)
+static int
+plrtc_gettime(todr_chip_handle_t tch, volatile struct timeval *tvp)
 {
-	time_t rtc_time;
-	struct plrtc_softc *sc = plrtc_sc;
-
-	if (sc == NULL)
-		panic("RTC not attached");
-
-	/* Default to the suggested time, but replace that with one from the
-	   RTC if it seems more sensible.  */
-	rtc_time = bus_space_read_4(sc->sc_iot, sc->sc_ioh, IFPGA_RTC_DR);
-	
-	time.tv_usec = 0;
-	time.tv_sec = rtc_time;
-
-	timeset = 1;
+	struct plrtc_softc *sc = tch->cookie;
 
-	if (base > rtc_time) {
-		printf("inittodr: rtc value suspect, ignoring it.\n");
-		time.tv_usec = 0;
-		time.tv_sec = base;
-		return;
-	}
+	tvp->tv_sec = bus_space_read_4(sc->sc_iot, sc->sc_ioh, IFPGA_RTC_DR);
+	tvp->tv_usec = 0;
+	return 0;
 }
 
-void
-resettodr()
+static int
+plrtc_settime(todr_chip_handle_t tch, volatile struct timeval *tvp)
 {
-	struct plrtc_softc *sc = plrtc_sc;
-
-	/* The time hasn't been set yet, so avoid writing a dubious value
-	   to the RTC.  */
-	if (!timeset)
-		return;
+	struct plrtc_softc *sc = tch->cookie;
 
-	bus_space_write_4(sc->sc_iot, sc->sc_ioh, IFPGA_RTC_LR, time.tv_sec);
+	bus_space_write_4(sc->sc_iot, sc->sc_ioh, IFPGA_RTC_LR, tvp->tv_sec);
+	return 0;
 }
Index: arch/evbarm/include/types.h
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/include/types.h,v
retrieving revision 1.6
diff -d -p -u -r1.6 types.h
--- arch/evbarm/include/types.h	3 Sep 2006 13:51:23 -0000	1.6
+++ arch/evbarm/include/types.h	19 Sep 2006 18:17:54 -0000
@@ -9,5 +9,6 @@
 #define	__HAVE_GENERIC_SOFT_INTERRUPTS
 #endif
 #define	__HAVE_DEVICE_REGISTER
+#define	__HAVE_GENERIC_TODR
 
 #endif
Index: arch/evbarm/iq80310/iq80310_timer.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbarm/iq80310/iq80310_timer.c,v
retrieving revision 1.19
diff -d -p -u -r1.19 iq80310_timer.c
--- arch/evbarm/iq80310/iq80310_timer.c	24 Dec 2005 20:06:59 -0000	1.19
+++ arch/evbarm/iq80310/iq80310_timer.c	19 Sep 2006 18:17:54 -0000
@@ -319,93 +319,6 @@ delay(u_int n)
 	}
 }
 
-todr_chip_handle_t todr_handle;
-
-/*
- * todr_attach:
- *
- *	Set the specified time-of-day register as the system real-time clock.
- */
-void
-todr_attach(todr_chip_handle_t todr)
-{
-
-	if (todr_handle)
-		panic("todr_attach: rtc already configured");
-	todr_handle = todr;
-}
-
-/*
- * inittodr:
- *
- *	Initialize time from the time-of-day register.
- */
-#define	MINYEAR		2003	/* minimum plausible year */
-void
-inittodr(time_t base)
-{
-	time_t deltat;
-	int badbase;
-
-	if (base < (MINYEAR - 1970) * SECYR) {
-		printf("WARNING: preposterous time in file system");
-		/* read the system clock anyway */
-		base = (MINYEAR - 1970) * SECYR;
-		badbase = 1;
-	} else
-		badbase = 0;
-
-	if (todr_handle == NULL ||
-	    todr_gettime(todr_handle, &time) != 0 ||
-	    time.tv_sec == 0) {
-		/*
-		 * Believe the time in the file system for lack of
-		 * anything better, resetting the TODR.
-		 */
-		time.tv_sec = base;
-		time.tv_usec = 0;
-		if (todr_handle != NULL && !badbase) {
-			printf("WARNING: preposterous clock chip time\n");
-			resettodr();
-		}
-		goto bad;
-	}
-
-	if (!badbase) {
-		/*
-		 * See if we gained/lost two or more days; if
-		 * so, assume something is amiss.
-		 */
-		deltat = time.tv_sec - base;
-		if (deltat < 0)
-			deltat = -deltat;
-		if (deltat < 2 * SECDAY)
-			return;		/* all is well */
-		printf("WARNING: clock %s %ld days\n",
-		    time.tv_sec < base ? "lost" : "gained",
-		    (long)deltat / SECDAY);
-	}
- bad:
-	printf("WARNING: CHECK AND RESET THE DATE!\n");
-}
-
-/*
- * resettodr:
- *
- *	Reset the time-of-day register with the current time.
- */
-void
-resettodr(void)
-{
-
-	if (time.tv_sec == 0)
-		return;
-
-	if (todr_handle != NULL &&
-	    todr_settime(todr_handle, &time) != 0)
-		printf("resettodr: failed to set time\n");
-}
-
 /*
  * clockhandler:
  *
Index: arch/hpcarm/include/types.h
===================================================================
RCS file: /cvsroot/src/sys/arch/hpcarm/include/types.h,v
retrieving revision 1.9
diff -d -p -u -r1.9 types.h
--- arch/hpcarm/include/types.h	3 Sep 2006 13:51:23 -0000	1.9
+++ arch/hpcarm/include/types.h	19 Sep 2006 18:17:54 -0000
@@ -8,5 +8,6 @@
 #define	__HAVE_DEVICE_REGISTER
 #define	__HAVE_GENERIC_SOFT_INTERRUPTS
 #define	__GENERIC_SOFT_INTERRUPTS_ALL_LEVELS
+#define	__HAVE_GENERIC_TODR
 
 #endif
