todm5823.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"
/*
* tod driver module for ALI M5823 part
*/
#include <sys/todm5823.h>
#include <sys/machsystm.h>
#if 0
#endif
static timestruc_t todm5823_get(void);
static void todm5823_set(timestruc_t);
static uint_t todm5823_clear_watchdog_timer(void);
static void todm5823_set_power_alarm(timestruc_t);
static void todm5823_clear_power_alarm(void);
static uint64_t todm5823_get_cpufrequency(void);
/*
* External variables
*/
extern int watchdog_enable;
extern int watchdog_available;
extern int boothowto;
/*
* Global variables
*/
int m5823_debug_flags;
uint_t m5823_uip_count = 0;
/*
* Module linkage information for the kernel.
*/
&mod_miscops, "tod module for ALI M5823"
};
static struct modlinkage modlinkage = {
};
static void write_rtc_time(struct rtc_t *);
static void write_rtc_alarm(struct rtc_t *);
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);
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
todm5823_get(void)
{
/*
* We could not read from the tod
*/
return (hrestime);
}
DPRINTF("todm5823_get: century=%d year=%d dom=%d hrs=%d\n",
/*
* tod_year is base 1900 so this code needs to adjust the true
* year retrieved from the rtc's century and year fields.
*/
return (ts);
}
static uint_t
{
int i;
unsigned int spl_old;
uint_t rtc_readable = 0;
for (i = 0; i < TODM5823_UIP_RETRY_THRESH; i++) {
/* Read register A */
/* Read date alarm */
/* Read month and week alarm */
rtc_readable = 1;
break;
}
}
if (i > 0)
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("todm5823_set: year=%d dom=%d hrs=%d min=%d sec=%d\n",
}
void
{
/*
* Freeze
*/
/*
* Unfreeze
*/
}
void
{
int i;
unsigned int spl_old;
for (i = 0; i < TODM5823_UIP_RETRY_THRESH; i++) {
/* Read register A */
break;
}
}
if (i >= TODM5823_UIP_RETRY_THRESH)
}
/*
* program the rtc registers for alarm to go off at the specified time
*/
static void
{
/*
* disable alarms and clear AF flag by reading reg C
*/
(void) M5823_DATA_BANK0_REG;
DPRINTF("todm5823_set_alarm: mon=%d dom=%d hrs=%d min=%d sec=%d\n",
/*
* Write alarm values and 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);
}