Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-6]: src/sys/arch/sparc64/sparc64 Pull up revision 1.50 (request...



details:   https://anonhg.NetBSD.org/src/rev/e19f466ea409
branches:  netbsd-1-6
changeset: 529638:e19f466ea409
user:      he <he%NetBSD.org@localhost>
date:      Sun Dec 01 22:02:58 2002 +0000

description:
Pull up revision 1.50 (requested by martin in ticket #868):
  Fix the rtc clock on Netra X1 machines; fixes PR#15611
  and PR#16816.

diffstat:

 sys/arch/sparc64/sparc64/clock.c |  40 ++++++++++++++++++++--------------------
 1 files changed, 20 insertions(+), 20 deletions(-)

diffs (107 lines):

diff -r 5a51e2155f42 -r e19f466ea409 sys/arch/sparc64/sparc64/clock.c
--- a/sys/arch/sparc64/sparc64/clock.c  Sun Dec 01 21:41:05 2002 +0000
+++ b/sys/arch/sparc64/sparc64/clock.c  Sun Dec 01 22:02:58 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: clock.c,v 1.49 2002/03/20 18:54:49 eeh Exp $ */
+/*     $NetBSD: clock.c,v 1.49.6.1 2002/12/01 22:02:58 he Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -457,16 +457,15 @@
        handle->todr_settime = rtc_settime;
        handle->todr_getcal = rtc_getcal;
        handle->todr_setcal = rtc_setcal;
+       /*
+        * Apparently on some machines the TOD registers are on the same
+        * physical page as the COM registers.  So we won't protect them.
+        */
        handle->todr_setwen = NULL;
        rtc->rtc_bt = bt;
        rtc->rtc_bh = ci.ci_bh;
-       /* Our TOD clock year 0 is 1968 */
-       rtc->rtc_year0 = 1968;  /* XXX Really? */
-
-       /* Save info for the clock wenable call. */
-       ci.ci_bt = bt;
-       handle->bus_cookie = &ci;
-       handle->todr_setwen = clock_wenable;
+       /* Our TOD clock year 0 is 0 */
+       rtc->rtc_year0 = 0;
        todr_handle = handle;
 }
 
@@ -970,6 +969,9 @@
  * RTC todr routines.
  */
 
+/* Loooks like Sun stores the century info somewhere in CMOS RAM */
+#define MC_CENT 0x32
+
 /*
  * Get time-of-day and convert to a `struct timeval'
  * Return 0 on success; an error number otherwise.
@@ -983,7 +985,7 @@
        bus_space_tag_t bt = rtc->rtc_bt;
        bus_space_handle_t bh = rtc->rtc_bh;
        struct clock_ymdhms dt;
-       int year;
+       int year, cent;
        u_int8_t csr;
 
        todr_wenable(handle, 1);
@@ -1001,16 +1003,14 @@
        dt.dt_wday = rtc_read_reg(bt, bh, MC_DOW);
        dt.dt_mon = rtc_read_reg(bt, bh, MC_MONTH);
        year = rtc_read_reg(bt, bh, MC_YEAR);
-printf("rtc_gettime: read y %x/%d m %x/%d wd %d d %x/%d "
+       cent = rtc_read_reg(bt, bh, MC_CENT);
+printf("rtc_gettime: read c %x/%d y %x/%d m %x/%d wd %d d %x/%d "
        "h %x/%d m %x/%d s %x/%d\n",
-       year, year, dt.dt_mon, dt.dt_mon, dt.dt_wday,
+       cent, cent, year, year, dt.dt_mon, dt.dt_mon, dt.dt_wday,
        dt.dt_day, dt.dt_day, dt.dt_hour, dt.dt_hour,
        dt.dt_min, dt.dt_min, dt.dt_sec, dt.dt_sec);
 
-       year += rtc->rtc_year0;
-       if (year < POSIX_BASE_YEAR && rtc_auto_century_adjust != 0)
-               year += 100;
-
+       year += cent * 100;
        dt.dt_year = year;
 
        /* time wears on */
@@ -1020,7 +1020,7 @@
        todr_wenable(handle, 0);
 
        /* simple sanity checks */
-       if (dt.dt_mon > 12 || dt.dt_day > 31 ||
+       if (dt.dt_year < 1970 || dt.dt_mon > 12 || dt.dt_day > 31 ||
            dt.dt_hour >= 24 || dt.dt_min >= 60 || dt.dt_sec >= 60)
                return (1);
 
@@ -1043,14 +1043,13 @@
        bus_space_handle_t bh = rtc->rtc_bh;
        struct clock_ymdhms dt;
        u_int8_t csr;
-       int year;
+       int year, cent;
 
        /* Note: we ignore `tv_usec' */
        clock_secs_to_ymdhms(tv->tv_sec, &dt);
 
-       year = dt.dt_year - rtc->rtc_year0;
-       if (year > 99 && rtc_auto_century_adjust != 0)
-               year -= 100;
+       year = dt.dt_year % 100;
+       cent = dt.dt_year / 100;
 
        todr_wenable(handle, 1);
        /* enable write */
@@ -1065,6 +1064,7 @@
        rtc_write_reg(bt, bh, MC_DOM, dt.dt_day);
        rtc_write_reg(bt, bh, MC_MONTH, dt.dt_mon);
        rtc_write_reg(bt, bh, MC_YEAR, year);
+       rtc_write_reg(bt, bh, MC_CENT, cent);
 
        /* load them up */
        csr = rtc_read_reg(bt, bh, MC_REGB);



Home | Main Index | Thread Index | Old Index