todm5819.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*/
#include <sys/todm5819.h>
#include <sys/machsystm.h>
static timestruc_t todm5819_get(void);
static void todm5819_set(timestruc_t);
static uint_t todm5819_clear_watchdog_timer(void);
static void todm5819_set_power_alarm(timestruc_t);
static void todm5819_clear_power_alarm(void);
static uint64_t todm5819_get_cpufrequency(void);
/*
* External variables
*/
extern int watchdog_enable;
extern int watchdog_available;
extern int boothowto;
/*
* Global variables
*/
int m5819_debug_flags;
static void write_rtc_time(struct rtc_t *);
static void write_rtc_alarm(struct rtc_t *);
&mod_miscops, "tod module for ALI M5819",
};
static struct modlinkage modlinkage = {
};
int
_init(void)
{
/*
* check if hardware watchdog timer is available and user
* enabled it.
*/
if (watchdog_enable) {
if (!watchdog_available) {
"unavailable");
"disabled [debugger]");
}
}
}
return (mod_install(&modlinkage));
}
int
_fini(void)
{
return (EBUSY);
} else {
return (mod_remove(&modlinkage));
}
}
/*
* The loadable-module _info(9E) entry point
*/
int
{
}
/*
* Read the current time from the clock chip and convert to UNIX form.
* Assumes that the year in the clock chip is valid.
* Must be called with tod_lock held.
*/
static timestruc_t
todm5819_get(void)
{
int i;
/*
* Read from the tod, and if it isnt accessible wait
* before retrying.
*/
for (i = 0; i < TODM5819_UIP_RETRY_THRESH; i++) {
break;
}
if (i == TODM5819_UIP_RETRY_THRESH) {
/*
* We couldnt read from the tod
*/
return (hrestime);
}
DPRINTF("todm5819_get: century=%d year=%d dom=%d hrs=%d\n",
return (ts);
}
static todinfo_t
{
/*
* tod_year is base 1900 so this code needs to adjust the true
* year retrieved from the rtc's century and year fields.
*/
return (tod);
}
{
int s;
uint_t rtc_readable = 0;
s = splhi();
/*
* If UIP bit is not set we have at least 274us
* to read the values. Otherwise we have up to
* 336us to wait before we can read it
*/
rtc_readable = 1;
/* Clear wakeup data */
}
splx(s);
return (rtc_readable);
}
/*
* Write the specified time into the clock chip.
* Must be called with tod_lock held.
*/
static void
{
int year;
/* tod_year is base 1900 so this code needs to adjust */
DPRINTF("todm5819_set: century=%d year=%d dom=%d hrs=%d\n",
}
void
{
/*
* Freeze
*/
/*
* Unfreeze
*/
}
void
{
}
/*
* program the rtc registers for alarm to go off at the specified time
*/
static void
{
/*
* disable alarms
*/
/*
* Enable alarm.
*/
}
/*
* clear alarm interrupt
*/
static void
{
}
/*
* Determine the cpu frequency by watching the TOD chip rollover twice.
* Cpu clock rate is determined by computing the ticks added (in tick register)
* during one second interval on TOD.
*/
{
return (find_cpufrequency(v_rtc_data_reg));
}
/*ARGSUSED*/
static uint_t
{
return (0);
}
static uint_t
{
return (0);
}