xref: /titanic_41/usr/src/uts/sun4u/sys/todm5819p.h (revision 56b2bdd1f04d465cfe4a95b88ae5cba5884154e4)
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 2002-2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_TODM5819P_H
28 #define	_TODM5819P_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 extern  char    *v_rtc_addr_reg;
37 extern  volatile uint8_t *v_rtc_data_reg;
38 
39 #ifdef	DEBUG
40 #include <sys/promif.h>
41 #define	DPRINTF if (m5819p_debug_flags) prom_printf
42 #else
43 #define	DPRINTF
44 #endif /* DEBUG */
45 
46 #define	M5819P_ADDR_REG		*(volatile uint8_t *)v_rtc_addr_reg
47 #define	M5819P_DATA_REG		*(volatile uint8_t *)v_rtc_data_reg
48 
49 /*
50  * Definitions for Real Time Clock driver (ALI M5819P chip).
51  */
52 #define	RTC_SEC		0x0	/* Seconds */
53 #define	RTC_ASEC	0x1	/* Seconds Alarm */
54 #define	RTC_MIN		0x2	/* Minutes */
55 #define	RTC_AMIN	0x3	/* Minutes Alarm */
56 #define	RTC_HRS		0x4	/* Hours */
57 #define	RTC_AHRS	0x5	/* Hours Alarm */
58 #define	RTC_DOW		0x6	/* Day-of-Week */
59 #define	RTC_DOM		0x7	/* Day-of-Month */
60 #define	RTC_MON		0x8	/* Month */
61 #define	RTC_YEAR	0x9	/* Year */
62 #define	RTC_CENTURY	0x32	/* Century */
63 
64 
65 #define	RTC_A		0xa	/* Control Register A */
66 #define	RTC_B		0xb	/* Control Register B */
67 #define	RTC_C		0xc	/* Control Register C */
68 #define	RTC_D		0xd	/* Control Register D */
69 
70 /*
71  * Control register A definitions
72  */
73 #define	RTC_RS		0x0f	/* Rate select for periodic interrupt */
74 #define	RTC_DIV		0x70	/* Divider control */
75 #define	RTC_UIP		0x80	/* Update in progress bit */
76 
77 #define	RTC_DIV_OPERATE	0x50	/* dividor value for operate mode */
78 
79 /*
80  * Control register B definitions
81  */
82 #define	RTC_DSE		0x01	/* Daylight Savings Enable */
83 #define	RTC_HM		0x02	/* Hour mode, 1 = 24 hour, 0 = 12 hour */
84 #define	RTC_DM		0x04	/* Date mode, 1 = binary, 0 = BCD */
85 #define	RTC_UIE		0x10	/* Update-ended Interrupt Enable */
86 #define	RTC_AIE		0x20	/* Alarm Interrupt Enable */
87 #define	RTC_PIE		0x40	/* Periodic Interrupt Enable */
88 #define	RTC_SET		0x80	/* Stop updates for time set */
89 
90 /*
91  * Control Register C definitions
92  */
93 #define	RTC_UF		0x10	/* UF flag bit */
94 #define	RTC_AF		0x20	/* AF flag bit */
95 #define	RTC_PF		0x40	/* PF flag bit */
96 #define	RTC_IRQF	0x80	/* IRQ flag */
97 
98 /*
99  * Control Register D definitions
100  */
101 #define	RTC_ADOM_REG	RTC_D
102 #define	RTC_ADOM	0x3f	/*  Day-of-Month Alarm */
103 
104 
105 /*
106  * The following two definitions are used in conjunction to wait
107  * for the UIP bit to clear.
108  */
109 #define	TODM5819_UIP_RETRY_THRESH	6
110 #define	TODM5819_UIP_WAIT_USEC		56
111 
112 
113 struct	rtc_t {
114 	uint8_t	rtc_sec;	/* seconds */
115 	uint8_t	rtc_asec;	/* alarm seconds */
116 	uint8_t	rtc_min;	/* mins */
117 	uint8_t	rtc_amin;	/* alarm mins */
118 	uint8_t	rtc_hrs;	/* hours */
119 	uint8_t	rtc_ahrs;	/* alarm hours */
120 	uint8_t	rtc_dow;	/* day of the week */
121 	uint8_t	rtc_dom;	/* day of the month */
122 	uint8_t	rtc_mon;	/* month */
123 	uint8_t	rtc_year;	/* year */
124 	uint8_t	rtc_rega;	/* REG A */
125 	uint8_t	rtc_regb;	/* REG B */
126 	uint8_t	rtc_regc;	/* REG C */
127 	uint8_t	rtc_regd;	/* REG D */
128 	uint8_t	rtc_century;	/* century */
129 	uint8_t	rtc_adom;	/* alarm  day */
130 };
131 
132 #ifdef	__cplusplus
133 }
134 #endif
135 
136 #endif	/* _TODM5819P_H */
137