Switch cobalt to MI todr.
This commit is contained in:
parent
1719403bf2
commit
087695a56b
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: clock.c,v 1.13 2006/07/18 12:51:01 tsutsui Exp $ */
|
||||
/* $NetBSD: clock.c,v 1.14 2006/09/04 20:30:40 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 Soren S. Jorvang. All rights reserved.
|
||||
@ -26,7 +26,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.13 2006/07/18 12:51:01 tsutsui Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.14 2006/09/04 20:30:40 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/proc.h>
|
||||
@ -34,14 +34,10 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.13 2006/07/18 12:51:01 tsutsui Exp $");
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <dev/clock_subr.h>
|
||||
|
||||
#include <mips/locore.h>
|
||||
|
||||
#include <cobalt/cobalt/clockvar.h>
|
||||
|
||||
static todr_chip_handle_t todr_handle;
|
||||
|
||||
void (*timer_start)(void *);
|
||||
long (*timer_read)(void *);
|
||||
void *timer_cookie;
|
||||
@ -62,19 +58,6 @@ static uint32_t statprev;/* last value of we set statclock to */
|
||||
static u_int statcountperusec; /* number of ticks per usec at current stathz */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Common parts of todclock autoconfiguration.
|
||||
*/
|
||||
void
|
||||
todr_attach(todr_chip_handle_t handle)
|
||||
{
|
||||
|
||||
if (todr_handle)
|
||||
panic("todr_attach: too many todclocks configured");
|
||||
|
||||
todr_handle = handle;
|
||||
}
|
||||
|
||||
void
|
||||
cpu_initclocks(void)
|
||||
{
|
||||
@ -100,73 +83,6 @@ cpu_initclocks(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up the system's time, given a `reasonable' time value.
|
||||
*/
|
||||
void
|
||||
inittodr(time_t base)
|
||||
{
|
||||
int badbase, waszero;
|
||||
|
||||
if (todr_handle == NULL)
|
||||
panic("inittodr: no todclock configured");
|
||||
|
||||
badbase = 0;
|
||||
waszero = (base == 0);
|
||||
|
||||
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 */
|
||||
/* 2006/4/1 12:00:00 */
|
||||
base = 36 * SECYR + 91 * 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(void)
|
||||
{
|
||||
|
||||
if (time.tv_sec == 0)
|
||||
return;
|
||||
|
||||
if (todr_settime(todr_handle, &time) != 0)
|
||||
printf("resettodr: cannot set time in time-of-day clock\n");
|
||||
}
|
||||
|
||||
void
|
||||
setstatclockrate(int newhz)
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* $NetBSD: types.h,v 1.5 2005/12/11 12:17:06 christos Exp $ */
|
||||
/* $NetBSD: types.h,v 1.6 2006/09/04 20:30:40 tsutsui Exp $ */
|
||||
|
||||
#include <mips/types.h>
|
||||
|
||||
#define __HAVE_DEVICE_REGISTER
|
||||
#define __HAVE_GENERIC_SOFT_INTERRUPTS
|
||||
#define __HAVE_GENERIC_TODR
|
||||
|
Loading…
Reference in New Issue
Block a user