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