Subject: mvme68k todr changes
To: None <port-mvme68k@netbsd.org>
From: Garrett D'Amore <garrett_damore@tadpole.com>
List: port-mvme68k
Date: 09/09/2006 15:19:04
This is a multi-part message in MIME format.
--------------090603090607020406080506
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

The following changes add support for generic-todr on mvme68.  Mostly
this is just removing MD implementation and adding __HAVE_GENERIC_TODR
to pull in the MI version.  Any objections to me just committing?  I've
not _tested_, but it at least compiles. :-)

-- 
Garrett D'Amore, Principal Software Engineer
Tadpole Computer / Computing Technologies Division,
General Dynamics C4 Systems
http://www.tadpolecomputer.com/
Phone: 951 325-2134  Fax: 951 325-2191


--------------090603090607020406080506
Content-Type: text/x-patch;
 name="mvme68k.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="mvme68k.diff"

Index: sys/arch/mvme68k/include/types.h
===================================================================
RCS file: /cvsroot/src/sys/arch/mvme68k/include/types.h,v
retrieving revision 1.9
diff -d -p -u -r1.9 types.h
--- sys/arch/mvme68k/include/types.h	28 Feb 2002 03:17:34 -0000	1.9
+++ sys/arch/mvme68k/include/types.h	9 Sep 2006 22:12:28 -0000
@@ -7,5 +7,6 @@
 
 #define	__HAVE_DEVICE_REGISTER
 #define	__HAVE_GENERIC_SOFT_INTERRUPTS
+#define	__HAVE_GENERIC_TODR
 
 #endif
Index: sys/arch/mvme68k/mvme68k/clock.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mvme68k/mvme68k/clock.c,v
retrieving revision 1.23
diff -d -p -u -r1.23 clock.c
--- sys/arch/mvme68k/mvme68k/clock.c	11 Dec 2005 12:18:17 -0000	1.23
+++ sys/arch/mvme68k/mvme68k/clock.c	9 Sep 2006 22:12:28 -0000
@@ -54,7 +54,6 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.
 #include <dev/mvme/clockvar.h>
 
 static	struct clock_attach_args *clock_args;
-static	todr_chip_handle_t todr_handle;
 
 struct	evcnt clock_profcnt;
 struct	evcnt clock_statcnt;
@@ -95,17 +94,6 @@ clock_config(dev, ca, ev)
 	printf(": delay_divisor %d\n", delay_divisor);
 }
 
-void
-todr_attach(todr)
-	todr_chip_handle_t todr;
-{
-
-	if (todr_handle)
-		panic("todr_attach: clock already configured");
-
-	todr_handle = todr;
-}
-
 /*
  * Set up the real-time and statistics clocks.  Leave stathz 0 only
  * if no alternative timer is available.
@@ -187,67 +175,3 @@ microtime(tvp)
 	splx(s);
 }
 
-/*
- * Set up the system's time, given a `reasonable' time value.
- */
-void
-inittodr(base)
-        time_t base;
-{
-        int badbase = 0, waszero = (base == 0);
-
-	if (todr_handle == NULL)
-		panic("todr not configured");
-
-        if (base < 5 * SECYR) {
-                /*
-                 * If base is 0, assume filesystem time is just unknown
-                 * in stead of preposterous. Don't bark.
-                 */
-                if (base != 0)
-                        printf("WARNING: preposterous time in file system\n");
-                /* not going to use it anyway, if the chip is readable */
-                base = 21*SECYR + 186*SECDAY + SECDAY/2;
-                badbase = 1;
-        }
-
-        if (todr_gettime(todr_handle, &time) != 0 ||
-            time.tv_sec == 0) {
-                printf("WARNING: bad date in battery clock");
-                /*
-                 * Believe the time in the file system for lack of
-                 * anything better, resetting the clock.
-                 */
-                time.tv_sec = base;
-                if (!badbase)
-                        resettodr();
-        } else {
-                int deltat = time.tv_sec - base;
-
-                if (deltat < 0)
-                        deltat = -deltat;
-                if (waszero || deltat < 2 * SECDAY)
-                        return;
-                printf("WARNING: clock %s %d days",
-                    time.tv_sec < base ? "lost" : "gained", deltat / SECDAY);
-        }
-        printf(" -- CHECK AND RESET THE DATE!\n");
-}
-
-
-/*
- * Reset the clock based on the current time.
- * Used when the current clock is preposterous, when the time is changed,
- * and when rebooting.  Do nothing if the time is not yet known, e.g.,
- * when crashing during autoconfig.
- */
-void
-resettodr()
-{
-
-        if (!time.tv_sec)
-                return;
-
-        if (todr_settime(todr_handle, &time) != 0)
-                printf("resettodr: failed to set time\n");
-}

--------------090603090607020406080506--