Subject: Re: HEADSUP--evbarm switching to __HAVE_GENERIC_TODR
To: None <port-arm@netbsd.org>
From: Bucky Katz <bucky@picovex.com>
List: port-arm
Date: 02/18/2007 18:15:51
--=-=-=

Allen Briggs <briggs@netbsd.org> writes:

> I don't think this will cause any problems, but in case it does...
>
> I'm switching evbarm to define __HAVE_GENERIC_TODR.  This looks
> to mainly affect INTEGRATOR and IQ80310 (and IOP310-based) boards
> more than the others.  This removes the need for ports to define
> their own inittodr() and resettodr(), and is safe for ports that
> define no time-of-day clock at all.
>
> If you have an evbarm port that defines inittodr() and resettodr(),
> the changes are fairly minimal--see the imminent change to
> evbarm/ifpga/pl030_rtc.c for an example of what needs to be done.
>
> Please let me know if you have any questions or concerns about the
> change.
>

Ugh.  I believe you'll find that things don't compile and it's my
fault.  When Christos checked in the OMAP port I sent him a bunch of
follow up patches, including one for generic TODR that I seem to have
botched. I haven't gotten back to it to figure out what went wrong
yet.  
--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline; filename=patch.rtc
Content-Description: the busted patch

src/sys/arch/arm/ep93xx/epclk.c
--- ../cvs/src/sys/arch/arm/ep93xx/epclk.c	2006-09-10 20:02:18.000000000 -0700
+++ src/sys/arch/arm/ep93xx/epclk.c	2007-01-05 18:46:58.000000000 -0800
@@ -324,93 +324,3 @@
 		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
src/sys/arch/arm/footbridge/footbridge.c
--- ../cvs/src/sys/arch/arm/footbridge/footbridge.c	2005-12-11 19:03:24.000000000 -0800
+++ src/sys/arch/arm/footbridge/footbridge.c	2007-01-05 18:46:58.000000000 -0800
@@ -216,14 +216,6 @@
 	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;
src/sys/arch/arm/footbridge/footbridgevar.h
--- ../cvs/src/sys/arch/arm/footbridge/footbridgevar.h	2005-12-11 19:03:24.000000000 -0800
+++ src/sys/arch/arm/footbridge/footbridgevar.h	2007-01-05 18:46:58.000000000 -0800
@@ -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 @@
 		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;
src/sys/arch/arm/footbridge/isa/dsrtc.c
--- ../cvs/src/sys/arch/arm/footbridge/isa/dsrtc.c	2006-09-11 20:02:05.000000000 -0700
+++ src/sys/arch/arm/footbridge/isa/dsrtc.c	2007-01-05 18:46:58.000000000 -0800
@@ -45,9 +45,7 @@
 #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 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 @@
 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 @@
 #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 @@
 {
 	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 @@
 		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 */
src/sys/arch/arm/ixp12x0/ixp12x0_clk.c
--- ../cvs/src/sys/arch/arm/ixp12x0/ixp12x0_clk.c	2005-12-11 19:03:25.000000000 -0800
+++ src/sys/arch/arm/ixp12x0/ixp12x0_clk.c	2007-01-05 18:46:58.000000000 -0800
@@ -365,16 +365,3 @@
 		otick = ticks;
 	}
 }
-
-void
-resettodr(void)
-{
-}
-
-void
-inittodr(time_t base)
-{
-
-	time.tv_sec = base;
-	time.tv_usec = 0;
-}
src/sys/arch/arm/s3c2xx0/s3c24x0_clk.c
--- ../cvs/src/sys/arch/arm/s3c2xx0/s3c24x0_clk.c	2005-12-24 19:05:14.000000000 -0800
+++ src/sys/arch/arm/s3c2xx0/s3c24x0_clk.c	2007-01-05 18:46:58.000000000 -0800
@@ -230,29 +230,6 @@
 	/*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)
 {
src/sys/arch/arm/s3c2xx0/s3c2800_clk.c
--- ../cvs/src/sys/arch/arm/s3c2xx0/s3c2800_clk.c	2005-12-24 19:05:14.000000000 -0800
+++ src/sys/arch/arm/s3c2xx0/s3c2800_clk.c	2007-01-05 18:46:58.000000000 -0800
@@ -238,29 +238,6 @@
 	/*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)
 {
src/sys/arch/arm/xscale/becc_timer.c
--- ../cvs/src/sys/arch/arm/xscale/becc_timer.c	2006-09-10 20:02:18.000000000 -0700
+++ src/sys/arch/arm/xscale/becc_timer.c	2007-01-05 18:46:58.000000000 -0800
@@ -266,95 +266,6 @@
 	}
 }
 
-#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:
  *
src/sys/arch/arm/xscale/i80321_timer.c
--- ../cvs/src/sys/arch/arm/xscale/i80321_timer.c	2006-09-10 20:02:18.000000000 -0700
+++ src/sys/arch/arm/xscale/i80321_timer.c	2007-01-05 18:46:58.000000000 -0800
@@ -416,95 +416,6 @@
 	}
 }
 
-#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:
  *
src/sys/arch/arm/xscale/ixp425_timer.c
--- ../cvs/src/sys/arch/arm/xscale/ixp425_timer.c	2006-09-10 20:02:18.000000000 -0700
+++ src/sys/arch/arm/xscale/ixp425_timer.c	2007-01-05 18:46:58.000000000 -0800
@@ -290,98 +290,6 @@
 	}
 }
 
-
-#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:
  *
src/sys/arch/evbarm/ifpga/pl030_rtc.c
--- ../cvs/src/sys/arch/evbarm/ifpga/pl030_rtc.c	2005-12-11 19:03:30.000000000 -0800
+++ src/sys/arch/evbarm/ifpga/pl030_rtc.c	2007-01-05 18:46:58.000000000 -0800
@@ -40,6 +40,7 @@
 #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 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 @@
 		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;
 }
src/sys/arch/evbarm/include/types.h
--- ../cvs/src/sys/arch/evbarm/include/types.h	2006-09-03 20:01:14.000000000 -0700
+++ src/sys/arch/evbarm/include/types.h	2007-01-05 18:46:58.000000000 -0800
@@ -9,5 +9,6 @@
 #define	__HAVE_GENERIC_SOFT_INTERRUPTS
 #endif
 #define	__HAVE_DEVICE_REGISTER
+#define	__HAVE_GENERIC_TODR
 
 #endif
src/sys/arch/evbarm/iq80310/iq80310_timer.c
--- ../cvs/src/sys/arch/evbarm/iq80310/iq80310_timer.c	2005-12-24 19:05:20.000000000 -0800
+++ src/sys/arch/evbarm/iq80310/iq80310_timer.c	2007-01-05 18:46:58.000000000 -0800
@@ -319,93 +319,6 @@
 	}
 }
 
-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:
  *

--=-=-=

 is the offending patch and the problem is with the change to
arch/arm/ep93xx/epclk.c



--=-=-=--