Index: sys/arch/powerpc/conf/files.ibm405gp
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/conf/files.ibm405gp,v
retrieving revision 1.4
diff -d -p -u -r1.4 files.ibm405gp
--- sys/arch/powerpc/conf/files.ibm405gp	11 Dec 2005 12:18:42 -0000	1.4
+++ sys/arch/powerpc/conf/files.ibm405gp	17 Sep 2006 04:49:55 -0000
@@ -20,5 +20,3 @@ device	gpiic: i2cbus, i2c_bitbang
 attach	gpiic at opb
 file	arch/powerpc/ibm4xx/dev/gpiic_opb.c	gpiic
 
-# Real time clock support
-file	arch/powerpc/ibm4xx/dev/rtc.c
Index: sys/arch/powerpc/ibm4xx/dev/rtc.c
===================================================================
RCS file: sys/arch/powerpc/ibm4xx/dev/rtc.c
diff -N sys/arch/powerpc/ibm4xx/dev/rtc.c
--- sys/arch/powerpc/ibm4xx/dev/rtc.c	11 Dec 2005 12:18:42 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,107 +0,0 @@
-/*	$NetBSD: rtc.c,v 1.4 2005/12/11 12:18:42 christos Exp $	*/
-/*	Original:	src/sys/arch/acorn26/ioc/rtc.c	*/
-/*	Original Tag:	rtc.c,v 1.7 2003/09/30 00:35:30 thorpej Exp	*/
-
-/*
- * Copyright (c) 2000 Ben Harris
- * Copyright (c) 1994-1996 Mark Brinicombe.
- * Copyright (c) 1994 Brini.
- * All rights reserved.
- *
- * This code is derived from software written for Brini by Mark Brinicombe
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by Brini.
- * 4. The name of the company nor the name of the author may be used to
- *    endorse or promote products derived from this software without specific
- *    prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.4 2005/12/11 12:18:42 christos Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/malloc.h>
-
-#include <dev/clock_subr.h>
-
-todr_chip_handle_t todr_handle;
-
-void
-todr_attach(todr_chip_handle_t todr)
-{
-
-	if (todr_handle)
-		panic("todr_attach: rtc already configured");
-	todr_handle = todr;
-}
-
-void
-inittodr(time_t base)
-{
-	int check;
-	struct timeval todrtime;
-
-	check = 0;
-	if (todr_handle == NULL) {
-		printf("inittodr: rtc not present");
-		time.tv_sec = base;
-		time.tv_usec = 0;
-		check = 1;
-	} else {
-		if (todr_gettime(todr_handle, &todrtime) != 0) {
-			printf("inittodr: Error reading clock");
-			time.tv_sec = base;
-			time.tv_usec = 0;
-			check = 1;
-		} else {
-			time = todrtime;
-			if (time.tv_sec > base + 3 * SECDAY) {
-				printf("inittodr: Clock has gained %ld days",
-				       (time.tv_sec - base) / SECDAY);
-				check = 1;
-			} else if (time.tv_sec + SECDAY < base) {
-				printf("inittodr: Clock has lost %ld day(s)",
-				       (base - time.tv_sec) / SECDAY);
-				check = 1;
-			}
-		}
-	}
-	if (check)
-		printf(" - CHECK AND RESET THE DATE.\n");
-}
-
-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");
-}
Index: sys/arch/evbppc/conf/WALNUT
===================================================================
RCS file: /cvsroot/src/sys/arch/evbppc/conf/WALNUT,v
retrieving revision 1.33
diff -d -p -u -r1.33 WALNUT
--- sys/arch/evbppc/conf/WALNUT	26 Aug 2006 20:26:44 -0000	1.33
+++ sys/arch/evbppc/conf/WALNUT	17 Sep 2006 04:49:55 -0000
@@ -242,7 +242,6 @@ uk*	at atapibus? drive ? flags 0x0000	# 
 pbus*	at plb?				# off-chip Peripheral BUS
 
 ds1743rtc0	at pbus? addr ?			# RTC
-todclock0 at ds1743rtc?			# time-of-day device via rtc device
 
 #pckbc0	at pbus?
 #pckbd*	at pckbc?
Index: sys/arch/evbppc/conf/files.walnut
===================================================================
RCS file: /cvsroot/src/sys/arch/evbppc/conf/files.walnut,v
retrieving revision 1.10
diff -d -p -u -r1.10 files.walnut
--- sys/arch/evbppc/conf/files.walnut	30 Jun 2006 17:54:50 -0000	1.10
+++ sys/arch/evbppc/conf/files.walnut	17 Sep 2006 04:49:55 -0000
@@ -47,13 +47,7 @@ device	pbus {[addr=-1], [irq=-1]}
 attach	pbus at plb
 file	arch/evbppc/walnut/dev/pbus.c		pbus
 
-define	todservice {}
-
-device	todclock
-attach	todclock at todservice
-file	arch/evbppc/walnut/dev/todclock.c	todclock	needs-count
-
-device	ds1743rtc: todservice
+device	ds1743rtc
 attach	ds1743rtc at pbus
 file	arch/evbppc/walnut/dev/ds1743.c		ds1743rtc
 
Index: sys/arch/evbppc/ev64260/clock.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbppc/ev64260/clock.c,v
retrieving revision 1.8
diff -d -p -u -r1.8 clock.c
--- sys/arch/evbppc/ev64260/clock.c	24 Dec 2005 20:07:03 -0000	1.8
+++ sys/arch/evbppc/ev64260/clock.c	17 Sep 2006 04:49:56 -0000
@@ -88,130 +88,6 @@ yeartoday(int year)
 #define SECPER4YEARS	(4*SECPERNYEAR+SECPERDAY)
 #define EPOCHYEAR	1970
 
-/*
- * Initialze the time of day register, based on the time base which is, e.g.
- * from a filesystem.  Base provides the time to within six months,
- * and the time of year clock (if any) provides the rest.
- */
-#define MINYEAR			2002	/* minimum plausible year */
-void
-inittodr(base)
-	time_t base;
-{
-#if NRTC > 0
-	rtc_t rtc;
-	int year;
-	struct clock_ymdhms dt;
-	time_t deltat;
-	int badbase;
-	int s;
-
-	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;
-
-	s = splclock();
-	rtc_read(&rtc);
-	(void)splx(s);
-
-#if defined(DEBUG) && 0
-	printf("inittodr: %02d%02d/%02d/%02d %02d:%02d:%02d\n",
-		rtc.rtc_century, rtc.rtc_year, rtc.rtc_month, rtc.rtc_day,
-		rtc.rtc_hour, rtc.rtc_minute, rtc.rtc_second);
-#endif
-	clockinitted = 1;
-
-	year = (rtc.rtc_century * 100) + rtc.rtc_year;
-
-	/* simple sanity checks (2037 = time_t overflow) */
-	if (year < MINYEAR || year > 2037 ||
-	    rtc.rtc_month < 1 || rtc.rtc_month > 12 || rtc.rtc_day < 1 ||
-	    rtc.rtc_day > 31 || rtc.rtc_hour > 23 || rtc.rtc_minute > 59 ||
-	    rtc.rtc_second > 59) {
-		/*
-		 * Believe the time in the file system for lack of
-		 * anything better, resetting the TODR.
-		 */
-		time.tv_sec = base;
-		if (!badbase) {
-			printf("WARNING: preposterous clock chip time\n");
-			resettodr();
-		}
-		goto bad;
-	}
-
-	dt.dt_year = year;
-	dt.dt_mon = rtc.rtc_month;
-	dt.dt_day = rtc.rtc_day;
-	dt.dt_hour = rtc.rtc_hour;
-	dt.dt_min = rtc.rtc_minute;
-	dt.dt_sec = rtc.rtc_second;
-	time.tv_sec = clock_ymdhms_to_secs(&dt);
-
-	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");
-#else	/* NRTC */
-	time.tv_sec = base;
-#endif /* NRTC */
-}
-
-/*
- * Reset the TODR based on the time value; used when the TODR
- * has a preposterous value and also when the time is reset
- * by the stime system call.  Also called when the TODR goes past
- * TODRZERO + 100*(SECYEAR+2*SECDAY) (e.g. on Jan 2 just after midnight)
- * to wrap the TODR around.
- */
-void
-resettodr()
-{
-#if NRTC > 0
-	struct clock_ymdhms dt;
-	rtc_t rtc;
-	int s;
-
-	if (!clockinitted)
-		return;
-
-	clock_secs_to_ymdhms(time.tv_sec, &dt);
-
-	rtc.rtc_century = dt.dt_year / 100;
-	rtc.rtc_year = dt.dt_year % 100;
-	rtc.rtc_month = dt.dt_mon;
-	rtc.rtc_day = dt.dt_day;
-	rtc.rtc_hour = dt.dt_hour;
-	rtc.rtc_minute = dt.dt_min;
-	rtc.rtc_second = dt.dt_sec;
-#if defined(DEBUG) && 0
-	printf("resettodr: %02d%02d/%02d/%02d %02d:%02d:%02d\n",
-		rtc.rtc_century, rtc.rtc_year, rtc.rtc_month, rtc.rtc_day,
-		rtc.rtc_hour, rtc.rtc_minute, rtc.rtc_second);
-#endif
-
-	s = splclock();
-	rtc_write(&rtc);
-	(void)splx(s);
-#endif /* NRTC */
-}
-
 #ifdef DEBUG
 struct clockframe *clockframe = 0;
 #endif
Index: sys/arch/evbppc/explora/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbppc/explora/machdep.c,v
retrieving revision 1.12
diff -d -p -u -r1.12 machdep.c
--- sys/arch/evbppc/explora/machdep.c	30 Jun 2006 17:54:50 -0000	1.12
+++ sys/arch/evbppc/explora/machdep.c	17 Sep 2006 04:49:56 -0000
@@ -443,18 +443,6 @@ cpu_reboot(int howto, char *what)
 }
 
 void
-inittodr(time_t base)
-{
-	if (base > 365*24*60*60 && time.tv_sec < 365*24*60*60)
-		time.tv_sec = base;
-}
-
-void
-resettodr(void)
-{
-}
-
-void
 mem_regions(struct mem_region **mem, struct mem_region **avail)
 {
 	*mem = phys_mem;
Index: sys/arch/evbppc/include/types.h
===================================================================
RCS file: /cvsroot/src/sys/arch/evbppc/include/types.h,v
retrieving revision 1.5
diff -d -p -u -r1.5 types.h
--- sys/arch/evbppc/include/types.h	3 Sep 2006 13:51:23 -0000	1.5
+++ sys/arch/evbppc/include/types.h	17 Sep 2006 04:49:56 -0000
@@ -4,3 +4,4 @@
 
 #define	__HAVE_DEVICE_REGISTER
 #define	__HAVE_GENERIC_SOFT_INTERRUPTS
+#define	__HAVE_GENERIC_TODR
Index: sys/arch/evbppc/walnut/dev/ds1743.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbppc/walnut/dev/ds1743.c,v
retrieving revision 1.6
diff -d -p -u -r1.6 ds1743.c
--- sys/arch/evbppc/walnut/dev/ds1743.c	11 Dec 2005 12:17:13 -0000	1.6
+++ sys/arch/evbppc/walnut/dev/ds1743.c	17 Sep 2006 04:49:56 -0000
@@ -43,18 +43,19 @@ __KERNEL_RCSID(0, "$NetBSD: ds1743.c,v 1
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
+#include <dev/clock_subr.h>
 
 #include <machine/rtc.h>
 #include <machine/bus.h>
 
 #include <evbppc/walnut/dev/ds1743reg.h>
-#include <evbppc/walnut/dev/todclockvar.h>
 #include <evbppc/walnut/dev/pbusvar.h>
 
 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;
 };
 
 static void dsrtcattach(struct device *, struct device *, void *);
@@ -64,8 +65,8 @@ static int ds1743_ram_read(struct dsrtc_
 static void ds1743_ram_write(struct dsrtc_softc *, int, int);
 #endif
 
-static int dsrtc_read(void *, rtc_t *);
-static int dsrtc_write(void *, rtc_t *);
+static int dsrtc_read(todr_chip_handle_t, struct clock_ymdhms *);
+static int dsrtc_write(todr_chip_handle_t, struct clock_ymdhms *);
 static inline u_char ds1743_read(struct dsrtc_softc *, int);
 static inline void ds1743_write(struct dsrtc_softc *, int, u_char);
 static u_char ds1743_lock(struct dsrtc_softc *, u_char);
@@ -134,7 +135,6 @@ dsrtcattach(struct device *parent, struc
 {
 	struct dsrtc_softc *sc = (struct dsrtc_softc *)self;
 	struct pbus_attach_args *paa = aux;
-	struct todclock_attach_args ta;
 
 	ds1743found = 1;
 	
@@ -159,13 +159,10 @@ dsrtcattach(struct device *parent, struc
 	}
 #endif
 
-
-	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);
 }
 
 static inline u_char
@@ -228,44 +225,42 @@ ds1743_unlock(struct dsrtc_softc *sc, u_
 }
 
 static int
-dsrtc_write(void * arg, rtc_t * rtc)
+dsrtc_write(todr_chip_handle_t tch, struct clock_ymdhms *dt)
 {
-	struct dsrtc_softc *sc = arg;
+	struct dsrtc_softc *sc = tch->cookie;
 	u_char key;
 
 	key = ds1743_lock(sc, DS_CTL_W);
 	
-	ds1743_write(sc, DS_SECONDS, BCD(rtc->rtc_sec) & 0x7f);
-	ds1743_write(sc, DS_MINUTES, BCD(rtc->rtc_min) & 0x7f);
-	ds1743_write(sc, DS_HOURS, BCD(rtc->rtc_hour)  & 0x3f);
-	ds1743_write(sc, DS_DATE, BCD(rtc->rtc_day)    & 0x3f);
-	ds1743_write(sc, DS_MONTH, BCD(rtc->rtc_mon)   & 0x1f);
-	ds1743_write(sc, DS_YEAR, BCD(rtc->rtc_year));
+	ds1743_write(sc, DS_SECONDS, TOBCD(dt->dt_sec) & 0x7f);
+	ds1743_write(sc, DS_MINUTES, TOBCD(dt->dt_min) & 0x7f);
+	ds1743_write(sc, DS_HOURS, TOBCD(dt->dt_hour)  & 0x3f);
+	ds1743_write(sc, DS_DATE, TOBCD(dt->dt_day)    & 0x3f);
+	ds1743_write(sc, DS_MONTH, TOBCD(dt->dt_mon)   & 0x1f);
+	ds1743_write(sc, DS_YEAR, TOBCD(dt->dt_year % 100));
 	ds1743_write(sc, DS_CENTURY, ((ds1743_read(sc, DS_CENTURY) & DS_CTL_RW)
-				      | BCD(rtc->rtc_cen)));
+				      | TOBCD(dt->dt_year / 100)));
 
 	ds1743_unlock(sc, key);
-	dsrtc_read(arg, rtc);
-	return(1);
+	return(0);
 }
 
 static int
-dsrtc_read(void *arg, rtc_t *rtc)
+dsrtc_read(todr_chip_handle_t tch, struct clock_ymdhms *dt)
 {
-	struct dsrtc_softc *sc = arg;
+	struct dsrtc_softc *sc = tch->cookie;
 	u_char key;
 	
 	key = ds1743_lock(sc, DS_CTL_R);
-	rtc->rtc_micro = 0;
-	rtc->rtc_centi = 0;
-	unBCD(rtc->rtc_sec, ds1743_read(sc, DS_SECONDS) & 0x7f);
-	unBCD(rtc->rtc_min, ds1743_read(sc, DS_MINUTES) & 0x7f);
-	unBCD(rtc->rtc_hour, ds1743_read(sc, DS_HOURS) & 0x3f);
-	unBCD(rtc->rtc_day, ds1743_read(sc, DS_DATE)   & 0x3f);
-	unBCD(rtc->rtc_mon, ds1743_read(sc, DS_MONTH)   & 0x1f);
-	unBCD(rtc->rtc_year, ds1743_read(sc, DS_YEAR));
-	unBCD(rtc->rtc_cen, ds1743_read(sc, DS_CENTURY) & ~DS_CTL_RW); 
+	dt->dt_sec = FROMBCD(ds1743_read(sc, DS_SECONDS) & 0x7f);
+	dt->dt_min = FROMBCD(ds1743_read(sc, DS_MINUTES) & 0x7f);
+	dt->dt_hour = FROMBCD(ds1743_read(sc, DS_HOURS) & 0x3f);
+	dt->dt_day = FROMBCD(ds1743_read(sc, DS_DATE)   & 0x3f);
+	dt->dt_mon = FROMBCD(ds1743_read(sc, DS_MONTH)   & 0x1f);
+	dt->dt_year =
+	    FROMBCD(ds1743_read(sc, DS_YEAR)) +
+	    FROMBCD(ds1743_read(sc, DS_CENTURY) & ~DS_CTL_RW) * 100; 
 
 	ds1743_unlock(sc, key);
-	return(1);
+	return(0);
 }
Index: sys/arch/evbppc/walnut/dev/todclock.c
===================================================================
RCS file: sys/arch/evbppc/walnut/dev/todclock.c
diff -N sys/arch/evbppc/walnut/dev/todclock.c
--- sys/arch/evbppc/walnut/dev/todclock.c	11 Dec 2005 12:17:13 -0000	1.5
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,319 +0,0 @@
-/*	$NetBSD: todclock.c,v 1.5 2005/12/11 12:17:13 christos Exp $	*/
-
-/*
- * Copyright (c) 1994-1997 Mark Brinicombe.
- * Copyright (c) 1994 Brini.
- * All rights reserved.
- *
- * This code is derived from software written for Brini by Mark Brinicombe
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by Mark Brinicombe.
- * 4. The name of the company nor the name of the author may be used to
- *    endorse or promote products derived from this software without specific
- *    prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * RiscBSD kernel project
- *
- * clock.c
- *
- * Timer related machine specific code
- *
- * Created      : 29/09/94
- */
-
-/* Include header files */
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: todclock.c,v 1.5 2005/12/11 12:17:13 christos Exp $");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/device.h>
-
-#include <machine/rtc.h>
-#include <evbppc/walnut/dev/todclockvar.h>
-
-#include "todclock.h"
-
-#if NTODCLOCK > 1
-#error "Can only had 1 todclock device"
-#endif
-
-/*
- * softc structure for the todclock device
- */
-
-struct todclock_softc {
-	struct device	sc_dev;			/* device node */
-	void	*sc_rtc_arg;			/* arg to read/write */
-	int	(*sc_rtc_write)(void *, rtc_t *); /* rtc write function */
-	int	(*sc_rtc_read)(void *, rtc_t *); /* rtc read function */
-};
-
-/* prototypes for functions */
-
-static void todclockattach(struct device *parent, struct device *self,
-			   void *aux);
-static int  todclockmatch(struct device *parent, struct cfdata *cf, void *aux);
-static inline int yeartoday(int);
-
-/*
- * We need to remember our softc for functions like inittodr()
- * and resettodr()
- * since we only ever have one time-of-day device we can just store
- * the direct pointer to softc.
- */
-
-static struct todclock_softc *todclock_sc = NULL;
-
-/* driver and attach structures */
-
-CFATTACH_DECL(todclock, sizeof(struct todclock_softc),
-    todclockmatch, todclockattach, NULL, NULL);
-
-/*
- * int todclockmatch(struct device *parent, struct cfdata *cf, void *aux)
- *
- * todclock device probe function.
- * just validate the attach args
- */
-
-int
-todclockmatch(struct device *parent, struct cfdata *cf, void *aux)
-{
-	struct todclock_attach_args *ta = aux;
-
-	if (todclock_sc != NULL)
-		return(0);
-	if (strcmp(ta->ta_name, "todclock") != 0)
-		return(0);
-
-	if (ta->ta_flags & TODCLOCK_FLAG_FAKE)
-		return(1);
-	return(2);
-}
-
-/*
- * void todclockattach(struct device *parent, struct device *self, void *aux)
- *
- * todclock device attach function.
- * Initialise the softc structure and do a search for children
- */
-
-void
-todclockattach(struct device *parent, struct device *self, void *aux)
-{
-	struct todclock_softc *sc = (void *)self;
-	struct todclock_attach_args *ta = aux;
-
-	/* set up our softc */
-	todclock_sc = sc;
-	todclock_sc->sc_rtc_arg = ta->ta_rtc_arg;
-	todclock_sc->sc_rtc_write = ta->ta_rtc_write;
-	todclock_sc->sc_rtc_read = ta->ta_rtc_read;
-
-	printf("\n");
-}
-
-static inline int
-yeartoday(int year)
-{
-	return((year % 4) ? 365 : 366);
-}
-
-                 
-static int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
-static int timeset = 0;
-
-#define SECPERDAY	(24*60*60)
-#define SECPERNYEAR	(365*SECPERDAY)
-#define SECPER4YEARS	(4*SECPERNYEAR+SECPERDAY)
-#define EPOCHYEAR	1970
-
-/*
- * Globally visable functions
- *
- * These functions are used from other parts of the kernel.
- * These functions use the functions defined in the tod_sc
- * to actually read and write the rtc.
- *
- * The first todclock to be attached will be used for handling
- * the time of day.
- */
-
-/*
- * Write back the time of day to the rtc
- */
-
-void
-resettodr(void)
-{
-	int s;
-	time_t year, mon, day, hour, minute, sec;
-	rtc_t rtc;
-
-	/* Have we set the system time in inittodr() */
-	if (!timeset)
-		return;
-
-	/* We need a todclock device and should always have one */
-	if (!todclock_sc)
-		panic("resettodr: No todclock device attached");
-
-	/* Abort early if there is not actually an RTC write routine */
-	if (todclock_sc->sc_rtc_write == NULL)
-		return;
-
-	sec = time.tv_sec;
-	sec -= rtc_offset * 60;
-	year = (sec / SECPER4YEARS) * 4;
-	sec %= SECPER4YEARS;
-
-	/* year now hold the number of years rounded down 4 */
-
-	while (sec > (yeartoday(EPOCHYEAR+year) * SECPERDAY)) {
-		sec -= yeartoday(EPOCHYEAR+year)*SECPERDAY;
-		year++;
-	}
-
-	/* year is now a correct offset from the EPOCHYEAR */
-
-	year+=EPOCHYEAR;
-	mon=0;
-	if (yeartoday(year) == 366)
-		month[1]=29;
-	else
-		month[1]=28;
-	while (sec >= month[mon]*SECPERDAY) {
-		sec -= month[mon]*SECPERDAY;
-		mon++;
-	}
-
-	day = sec / SECPERDAY;
-	sec %= SECPERDAY;
-	hour = sec / 3600;
-	sec %= 3600;
-	minute = sec / 60;
-	sec %= 60;
-	rtc.rtc_cen = year / 100;
-	rtc.rtc_year = year % 100;
-	rtc.rtc_mon = mon+1;
-	rtc.rtc_day = day+1;
-	rtc.rtc_hour = hour;
-	rtc.rtc_min = minute;
-	rtc.rtc_sec = sec;
-	rtc.rtc_centi =
-	rtc.rtc_micro = 0;
-
-	printf("resettod: %02d/%02d/%02d%02d %02d:%02d:%02d\n", rtc.rtc_day,
-	    rtc.rtc_mon, rtc.rtc_cen, rtc.rtc_year, rtc.rtc_hour,
-	    rtc.rtc_min, rtc.rtc_sec);
-
-	s = splclock();
-	todclock_sc->sc_rtc_write(todclock_sc->sc_rtc_arg, &rtc);
-	(void)splx(s);
-}
-
-/*
- * Initialise the time of day register, based on the time base which is, e.g.
- * from a filesystem.
- */
-
-void
-inittodr(time_t base)
-{
-	time_t n;
-	int i, days = 0;
-	int s;
-	int year;
-	rtc_t rtc;
-
-	/*
-	 * Default to the suggested time but replace that we one from an
-	 * RTC is we can.
-	 */
-
-	/* We expect a todclock device */
-	if (!todclock_sc)
-		panic("inittodr: No todclock device attached");
-
-	/* Use the suggested time as a fall back */
-	time.tv_sec = base;
-	time.tv_usec = 0;
-
-	/* Can we read an RTC ? */
-	if (todclock_sc->sc_rtc_read) {
-		s = splclock();
-		if (todclock_sc->sc_rtc_read(todclock_sc->sc_rtc_arg, &rtc) == 0) {
-			(void)splx(s);
-			return;
-		}
-		(void)splx(s);
-	} else
-		return;
-			
-	/* Convert the rtc time into seconds */
-
-	n = rtc.rtc_sec + 60 * rtc.rtc_min + 3600 * rtc.rtc_hour;
-	n += (rtc.rtc_day - 1) * 3600 * 24;
-	year = (rtc.rtc_year + rtc.rtc_cen * 100) - 1900;
-
-	if (yeartoday(year) == 366)
-		month[1] = 29;
-	for (i = rtc.rtc_mon - 2; i >= 0; i--)
-		days += month[i];
-	month[1] = 28;
-
-	for (i = 70; i < year; i++)
-		days += yeartoday(i);
-
-	n += days * 3600 * 24;
-
-	n += rtc_offset * 60;
-
-	time.tv_sec = n;
-	time.tv_usec = 0;
-
-	/* timeset is used to ensure the time is valid before a resettodr() */
-
-	timeset = 1;
-
-	/* If the base was 0 then keep quiet */
-
-	if (base) {
-		printf("inittodr: %02d:%02d:%02d.%02d%02d %02d/%02d/%02d%02d\n",
-		    rtc.rtc_hour, rtc.rtc_min, rtc.rtc_sec, rtc.rtc_centi,
-		    rtc.rtc_micro, rtc.rtc_day, rtc.rtc_mon, rtc.rtc_cen,
-		    rtc.rtc_year);
-
-		if (n > base + 60) {
-			days = (n - base) / SECPERDAY;
-			printf("Clock has gained %d day%c %ld hours %ld minutes %ld secs\n",
-			    days, ((days == 1) ? 0 : 's'), ((n - base)  / 3600) % 24,
-			    ((n - base) / 60) % 60, (n - base) % 60);
-		}
-	}
-}  
Index: sys/arch/evbppc/walnut/dev/todclockvar.h
===================================================================
RCS file: sys/arch/evbppc/walnut/dev/todclockvar.h
diff -N sys/arch/evbppc/walnut/dev/todclockvar.h
--- sys/arch/evbppc/walnut/dev/todclockvar.h	9 Dec 2002 12:16:25 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,55 +0,0 @@
-/*	$NetBSD: todclockvar.h,v 1.1 2002/12/09 12:16:25 scw Exp $	*/
-
-/*
- * Copyright (c) 1997 Mark Brinicombe.
- * Copyright (c) 1997 Causality Limited
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by Mark Brinicombe
- * 4. The name of the company nor the name of the author may be used to
- *    endorse or promote products derived from this software without specific
- *    prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * todclockvar.h
- *
- * structures and variables for the todclock device
- *
- * Created      : 12/02/97
- */
-
-/*
- * Attach args for todclock device
- */
-
-struct todclock_attach_args {
-	const char	*ta_name;			/* device name */
-	void	*ta_rtc_arg;				/* arg to read/write */
-	int	(*ta_rtc_write)(void *, rtc_t *);	/* function to write rtc */
-	int	(*ta_rtc_read)(void *, rtc_t *);	/* function to read rtc */
-	int	ta_flags;				/* flags */
-#define TODCLOCK_FLAG_FAKE	0x01			/* tod service is faked */
-};
-
-/* End of todclockvar.h */
