1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright (c) 1997-1998 by Sun Microsystems, Inc. 24*0Sstevel@tonic-gate * All rights reserved. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _TODMOSTEK_H 28*0Sstevel@tonic-gate #define _TODMOSTEK_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #ifdef __cplusplus 33*0Sstevel@tonic-gate extern "C" { 34*0Sstevel@tonic-gate #endif 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate extern caddr_t v_eeprom_addr; 37*0Sstevel@tonic-gate extern caddr_t v_timecheck_addr; 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate #define V_TOD_OFFSET 0x1FF0 40*0Sstevel@tonic-gate #define V_TODCLKADDR (v_eeprom_addr+V_TOD_OFFSET) 41*0Sstevel@tonic-gate #define V_TIMECHECKADDR (v_timecheck_addr+V_TOD_OFFSET) 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate /* 44*0Sstevel@tonic-gate * Definitions for the Mostek 48T59 clock chip. We use this chip as 45*0Sstevel@tonic-gate * our TOD clock. Clock interrupts are generated by a separate timer 46*0Sstevel@tonic-gate * circuit. 47*0Sstevel@tonic-gate */ 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate #define YRBASE 68 /* 1968 - what year 0 in chip represents */ 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate #ifndef _ASM 52*0Sstevel@tonic-gate struct mostek48T59 { 53*0Sstevel@tonic-gate volatile uchar_t clk_flags; /* flags register */ 54*0Sstevel@tonic-gate volatile uchar_t clk_unused; /* unused */ 55*0Sstevel@tonic-gate volatile uchar_t clk_alm_secs; /* alarm - seconds 0-59 */ 56*0Sstevel@tonic-gate volatile uchar_t clk_alm_mins; /* alarm - minutes 0-59 */ 57*0Sstevel@tonic-gate volatile uchar_t clk_alm_hours; /* alarm - hours 0-23 */ 58*0Sstevel@tonic-gate volatile uchar_t clk_alm_day; /* alarm - day 1-31 */ 59*0Sstevel@tonic-gate volatile uchar_t clk_interrupts; /* interrupts register */ 60*0Sstevel@tonic-gate volatile uchar_t clk_watchdog; /* watchdog register */ 61*0Sstevel@tonic-gate volatile uchar_t clk_ctrl; /* ctrl register */ 62*0Sstevel@tonic-gate volatile uchar_t clk_sec; /* counter - seconds 0-59 */ 63*0Sstevel@tonic-gate volatile uchar_t clk_min; /* counter - minutes 0-59 */ 64*0Sstevel@tonic-gate volatile uchar_t clk_hour; /* counter - hours 0-23 */ 65*0Sstevel@tonic-gate volatile uchar_t clk_weekday; /* counter - weekday 1-7 */ 66*0Sstevel@tonic-gate volatile uchar_t clk_day; /* counter - day 1-31 */ 67*0Sstevel@tonic-gate volatile uchar_t clk_month; /* counter - month 1-12 */ 68*0Sstevel@tonic-gate volatile uchar_t clk_year; /* counter - year 0-99 */ 69*0Sstevel@tonic-gate }; 70*0Sstevel@tonic-gate 71*0Sstevel@tonic-gate #define CLOCK ((struct mostek48T59 *)(V_TODCLKADDR)) 72*0Sstevel@tonic-gate #define TIMECHECK_CLOCK ((struct mostek48T59 *)(V_TIMECHECKADDR)) 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate #endif /* _ASM */ 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gate /* 77*0Sstevel@tonic-gate * Bit masks for various operations and register limits. 78*0Sstevel@tonic-gate */ 79*0Sstevel@tonic-gate #define CLK_CTRL_WRITE 0x80 80*0Sstevel@tonic-gate #define CLK_CTRL_READ 0x40 81*0Sstevel@tonic-gate #define CLK_CTRL_SIGN 0x20 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate #define CLK_STOP 0x80 84*0Sstevel@tonic-gate #define CLK_KICK 0x80 85*0Sstevel@tonic-gate #define CLK_FREQT 0x40 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gate #define CLK_MONTH_MASK 0x1f 88*0Sstevel@tonic-gate #define CLK_DAY_MASK 0x3f 89*0Sstevel@tonic-gate #define CLK_WEEKDAY_MASK 0x07 90*0Sstevel@tonic-gate #define CLK_HOUR_MASK 0x3f 91*0Sstevel@tonic-gate #define CLK_MIN_MASK 0x7f 92*0Sstevel@tonic-gate #define CLK_SEC_MASK 0x7f 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gate #define CLK_ALARM_ENABLE 0xa0 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate /* 97*0Sstevel@tonic-gate * If the passed in time is non-zero, enable the watchdog and set the scale 98*0Sstevel@tonic-gate * to seconds 99*0Sstevel@tonic-gate */ 100*0Sstevel@tonic-gate #define CLK_WATCHDOG_ENABLE 0x80 101*0Sstevel@tonic-gate #define CLK_WATCHDOG_1SEC 0x02 102*0Sstevel@tonic-gate #define CLK_WATCHDOG_TMASK 0x1f 103*0Sstevel@tonic-gate #define CLK_WATCHDOG_BITS(n) (((n) & CLK_WATCHDOG_TMASK) ? \ 104*0Sstevel@tonic-gate ((((n) & CLK_WATCHDOG_TMASK) << 2) | \ 105*0Sstevel@tonic-gate CLK_WATCHDOG_ENABLE | CLK_WATCHDOG_1SEC) : 0) 106*0Sstevel@tonic-gate 107*0Sstevel@tonic-gate #ifdef __cplusplus 108*0Sstevel@tonic-gate } 109*0Sstevel@tonic-gate #endif 110*0Sstevel@tonic-gate 111*0Sstevel@tonic-gate #endif /* !_TODMOSTEK_H */ 112