xref: /titanic_44/usr/src/uts/sun4u/sys/todds1287.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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) 1999-2001 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_TODDS1287_H
28*7c478bd9Sstevel@tonic-gate #define	_TODDS1287_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  char    *v_rtc_addr_reg;
37*7c478bd9Sstevel@tonic-gate extern  volatile uint8_t *v_rtc_data_reg;
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate #ifdef	DEBUG
40*7c478bd9Sstevel@tonic-gate #include <sys/promif.h>
41*7c478bd9Sstevel@tonic-gate #define	DPRINTF if (ds1287_debug_flags) prom_printf
42*7c478bd9Sstevel@tonic-gate #else
43*7c478bd9Sstevel@tonic-gate #define	DPRINTF
44*7c478bd9Sstevel@tonic-gate #endif	/* DEBUG */
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate #define	DS1287_ADDR_REG		*(volatile uint8_t *)v_rtc_addr_reg
47*7c478bd9Sstevel@tonic-gate #define	DS1287_DATA_REG		*(volatile uint8_t *)v_rtc_data_reg
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate /*
50*7c478bd9Sstevel@tonic-gate  * Maximum number of clones
51*7c478bd9Sstevel@tonic-gate  */
52*7c478bd9Sstevel@tonic-gate #define	DS1287_MAX_CLONE	256
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate /*
55*7c478bd9Sstevel@tonic-gate  * Minor number is instance << 8 + clone minor from range 1-255; clone 0 is
56*7c478bd9Sstevel@tonic-gate  * reserved for the "original".
57*7c478bd9Sstevel@tonic-gate  */
58*7c478bd9Sstevel@tonic-gate #define	DS1287_MINOR_TO_CLONE(minor) ((minor) & (DS1287_MAX_CLONE - 1))
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate struct ds1287 {
61*7c478bd9Sstevel@tonic-gate 	dev_info_t	*dip;		/* device info pointer */
62*7c478bd9Sstevel@tonic-gate 	kmutex_t	ds1287_mutex;	/* mutex lock */
63*7c478bd9Sstevel@tonic-gate 	uchar_t		clones[DS1287_MAX_CLONE]; /* array of clones */
64*7c478bd9Sstevel@tonic-gate 	int		monitor_on;	/* clone monitoring the button event */
65*7c478bd9Sstevel@tonic-gate 					/* clone 0 is used to indicate no one */
66*7c478bd9Sstevel@tonic-gate 					/* is monitoring the button event */
67*7c478bd9Sstevel@tonic-gate 	pollhead_t	pollhd;		/* poll head struct */
68*7c478bd9Sstevel@tonic-gate 	int		events;		/* bit map of occured events */
69*7c478bd9Sstevel@tonic-gate 	int		shutdown_pending; /* system shutdown in progress */
70*7c478bd9Sstevel@tonic-gate };
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate /*
74*7c478bd9Sstevel@tonic-gate  * Definitions for Real Time Clock driver (Dallas DS1287 chip).
75*7c478bd9Sstevel@tonic-gate  */
76*7c478bd9Sstevel@tonic-gate 
77*7c478bd9Sstevel@tonic-gate /*
78*7c478bd9Sstevel@tonic-gate  * Common registers between Banks 0, 1, and 2.
79*7c478bd9Sstevel@tonic-gate  */
80*7c478bd9Sstevel@tonic-gate #define	RTC_SEC		0x0	/* Seconds */
81*7c478bd9Sstevel@tonic-gate #define	RTC_ASEC	0x1	/* Seconds Alarm */
82*7c478bd9Sstevel@tonic-gate #define	RTC_MIN		0x2	/* Minutes */
83*7c478bd9Sstevel@tonic-gate #define	RTC_AMIN	0x3	/* Minutes Alarm */
84*7c478bd9Sstevel@tonic-gate #define	RTC_HRS		0x4	/* Hours */
85*7c478bd9Sstevel@tonic-gate #define	RTC_AHRS	0x5	/* Hours Alarm */
86*7c478bd9Sstevel@tonic-gate #define	RTC_DOW		0x6	/* Day-of-Week */
87*7c478bd9Sstevel@tonic-gate #define	RTC_DOM		0x7	/* Day-of-Month */
88*7c478bd9Sstevel@tonic-gate #define	RTC_MON		0x8	/* Month */
89*7c478bd9Sstevel@tonic-gate #define	RTC_YEAR	0x9	/* Year */
90*7c478bd9Sstevel@tonic-gate #define	RTC_A		0xa	/* Control Register A */
91*7c478bd9Sstevel@tonic-gate #define	RTC_B		0xb	/* Control Register B */
92*7c478bd9Sstevel@tonic-gate #define	RTC_C		0xc	/* Control Register C */
93*7c478bd9Sstevel@tonic-gate #define	RTC_D		0xd	/* Control Register D */
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate /*
96*7c478bd9Sstevel@tonic-gate  * Control register A definitions
97*7c478bd9Sstevel@tonic-gate  */
98*7c478bd9Sstevel@tonic-gate #define	RTC_DIV0	0x10	/* Bank Select */
99*7c478bd9Sstevel@tonic-gate #define	RTC_DIV1	0x20	/* Oscillator enable */
100*7c478bd9Sstevel@tonic-gate #define	RTC_DIV2	0x40	/* Countdown chain */
101*7c478bd9Sstevel@tonic-gate #define	RTC_UIP		0x80	/* Update in progress bit */
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate /*
104*7c478bd9Sstevel@tonic-gate  * Control register B definitions
105*7c478bd9Sstevel@tonic-gate  */
106*7c478bd9Sstevel@tonic-gate #define	RTC_DSE		0x01	/* Daylight Savings Enable */
107*7c478bd9Sstevel@tonic-gate #define	RTC_HM		0x02	/* Hour mode, 1 = 24 hour, 0 = 12 hour */
108*7c478bd9Sstevel@tonic-gate #define	RTC_DM		0x04	/* Date mode, 1 = binary, 0 = BCD */
109*7c478bd9Sstevel@tonic-gate #define	RTC_UIE		0x10	/* Update-ended Interrupt Enable */
110*7c478bd9Sstevel@tonic-gate #define	RTC_AIE		0x20	/* Alarm Interrupt Enable */
111*7c478bd9Sstevel@tonic-gate #define	RTC_PIE		0x40	/* Periodic Interrupt Enable */
112*7c478bd9Sstevel@tonic-gate #define	RTC_SET		0x80	/* Stop updates for time set */
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate /*
115*7c478bd9Sstevel@tonic-gate  * Control Register C definitions
116*7c478bd9Sstevel@tonic-gate  */
117*7c478bd9Sstevel@tonic-gate #define	RTC_UF		0x10	/* UF flag bit */
118*7c478bd9Sstevel@tonic-gate #define	RTC_AF		0x20	/* AF flag bit */
119*7c478bd9Sstevel@tonic-gate #define	RTC_PF		0x40	/* PF flag bit */
120*7c478bd9Sstevel@tonic-gate #define	RTC_IRQF	0x80	/* IRQ flag */
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate /*
123*7c478bd9Sstevel@tonic-gate  * Control Register D definitions
124*7c478bd9Sstevel@tonic-gate  */
125*7c478bd9Sstevel@tonic-gate #define	RTC_VRT		0x80	/* Valid RAM and time bit */
126*7c478bd9Sstevel@tonic-gate 
127*7c478bd9Sstevel@tonic-gate /*
128*7c478bd9Sstevel@tonic-gate  * Bank 1 Registers
129*7c478bd9Sstevel@tonic-gate  */
130*7c478bd9Sstevel@tonic-gate #define	RTC_CENTURY	0x48	/* Century */
131*7c478bd9Sstevel@tonic-gate #define	RTC_ADOM	0x49	/* Date of Month Alarm */
132*7c478bd9Sstevel@tonic-gate #define	RTC_AMON	0x4a	/* Month Alarm */
133*7c478bd9Sstevel@tonic-gate 
134*7c478bd9Sstevel@tonic-gate /*
135*7c478bd9Sstevel@tonic-gate  * Bank 2 Registers
136*7c478bd9Sstevel@tonic-gate  */
137*7c478bd9Sstevel@tonic-gate #define	APC_APCR1	0x40	/* APC Control Register 1 */
138*7c478bd9Sstevel@tonic-gate #define	APC_APCR2	0x41	/* APC Control Register 2 */
139*7c478bd9Sstevel@tonic-gate #define	APC_APSR	0x42	/* APC Status Register */
140*7c478bd9Sstevel@tonic-gate #define	APC_WDWR	0x43	/* Wake up Day of Week */
141*7c478bd9Sstevel@tonic-gate #define	APC_WDMR	0x44	/* Wake up Date of Month */
142*7c478bd9Sstevel@tonic-gate #define	APC_WMR		0x45	/* Wake up Month */
143*7c478bd9Sstevel@tonic-gate #define	APC_WYR		0x46	/* Wake up Year */
144*7c478bd9Sstevel@tonic-gate #define	APC_WCR		0x48	/* Wake up Century */
145*7c478bd9Sstevel@tonic-gate 
146*7c478bd9Sstevel@tonic-gate #define	RTC_CADDR	0x51	/* Century address register */
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate /*
149*7c478bd9Sstevel@tonic-gate  * APC Control Register 1 (APCR1) definitions
150*7c478bd9Sstevel@tonic-gate  */
151*7c478bd9Sstevel@tonic-gate #define	APC_FSTRC	0x40	/* Fail-safe Timer Reset Command */
152*7c478bd9Sstevel@tonic-gate 
153*7c478bd9Sstevel@tonic-gate /*
154*7c478bd9Sstevel@tonic-gate  * APC Control Register 2 (APCR2) definitions
155*7c478bd9Sstevel@tonic-gate  */
156*7c478bd9Sstevel@tonic-gate #define	APC_TME		0x01	/* Timer Match Enable */
157*7c478bd9Sstevel@tonic-gate 
158*7c478bd9Sstevel@tonic-gate struct	rtc_t {
159*7c478bd9Sstevel@tonic-gate 	uint8_t	rtc_sec;	/* seconds */
160*7c478bd9Sstevel@tonic-gate 	uint8_t	rtc_asec;	/* alarm seconds */
161*7c478bd9Sstevel@tonic-gate 	uint8_t	rtc_min;	/* mins */
162*7c478bd9Sstevel@tonic-gate 	uint8_t	rtc_amin;	/* alarm mins */
163*7c478bd9Sstevel@tonic-gate 	uint8_t	rtc_hrs;	/* hours */
164*7c478bd9Sstevel@tonic-gate 	uint8_t	rtc_ahrs;	/* alarm hours */
165*7c478bd9Sstevel@tonic-gate 	uint8_t	rtc_dow;	/* day of the week */
166*7c478bd9Sstevel@tonic-gate 	uint8_t	rtc_dom;	/* day of the month */
167*7c478bd9Sstevel@tonic-gate 	uint8_t	rtc_mon;	/* month */
168*7c478bd9Sstevel@tonic-gate 	uint8_t	rtc_year;	/* year */
169*7c478bd9Sstevel@tonic-gate 	uint8_t	rtc_rega;	/* REG A */
170*7c478bd9Sstevel@tonic-gate 	uint8_t	rtc_regb;	/* REG B */
171*7c478bd9Sstevel@tonic-gate 	uint8_t	rtc_regc;	/* REG C */
172*7c478bd9Sstevel@tonic-gate 	uint8_t	rtc_regd;	/* REG D */
173*7c478bd9Sstevel@tonic-gate 	uint8_t	rtc_century;	/* century */
174*7c478bd9Sstevel@tonic-gate 	uint8_t	rtc_adom;	/* alarm  day */
175*7c478bd9Sstevel@tonic-gate 	uint8_t	rtc_amon;	/* alarm  mon */
176*7c478bd9Sstevel@tonic-gate 	uint8_t	apc_apcr1;	/* APC Control register 1 */
177*7c478bd9Sstevel@tonic-gate 	uint8_t	apc_apcr2;	/* APC Control register 2 */
178*7c478bd9Sstevel@tonic-gate 	uint8_t	apc_apsr;	/* APC Status register */
179*7c478bd9Sstevel@tonic-gate 	uint8_t	apc_wdwr;	/* Wakeup date of the month */
180*7c478bd9Sstevel@tonic-gate 	uint8_t	apc_wdmr;	/* Wakeup day of month */
181*7c478bd9Sstevel@tonic-gate 	uint8_t	apc_wmr;	/* Wakeup month register */
182*7c478bd9Sstevel@tonic-gate 	uint8_t	apc_wyr;	/* Wakeup year register */
183*7c478bd9Sstevel@tonic-gate 	uint8_t	apc_wcr;	/* Wakeup Century reg. */
184*7c478bd9Sstevel@tonic-gate };
185*7c478bd9Sstevel@tonic-gate 
186*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
187*7c478bd9Sstevel@tonic-gate }
188*7c478bd9Sstevel@tonic-gate #endif
189*7c478bd9Sstevel@tonic-gate 
190*7c478bd9Sstevel@tonic-gate #endif	/* _TODDS1287_H */
191