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