xref: /titanic_52/usr/src/uts/sun4u/snowbird/sys/todds1307.h (revision 9acbbeaf2a1ffe5c14b244867d427714fab43c5c)
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 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_TODDS1307_H
28 #define	_TODDS1307_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/cyclic.h>
37 #include <sys/i2c/clients/i2c_client.h>
38 
39 extern char	*v_rtc_addr_reg;
40 extern volatile uint8_t	*v_rtc_data_reg;
41 
42 #define	DS1307_ADDR_REG		*(volatile uint8_t *)v_rtc_addr_reg
43 #define	DS1307_DATA_REG		*(volatile uint8_t *)v_rtc_data_reg
44 #define	DS1307_NODE_TYPE	"ddi_i2c:tod"
45 
46 struct rtc_t {
47 	uint8_t		rtc_sec;	/* Seconds[0-60] */
48 	uint8_t		rtc_min;	/* Minutes[0-60] */
49 	uint8_t		rtc_hrs;	/* Hours[(1-12)/(0-23)] */
50 	uint8_t		rtc_dow;	/* Day of week[1-7] */
51 	uint8_t		rtc_dom;	/* Day of month[(1-28/29/30/31)] */
52 	uint8_t		rtc_mon;	/* Month[1-12] */
53 	uint8_t		rtc_year;	/* Year[00-99] */
54 	uint8_t		rtc_ctl;	/* DS1307 Control register */
55 };
56 
57 
58 /*
59  * Register definitions for RTC driver (DS1307 chip)
60  */
61 
62 #define	RTC_SEC		0x00	/* 00h Second */
63 #define	RTC_MIN		0x01	/* 01h Minutes */
64 #define	RTC_HRS		0x02	/* 02h Hours */
65 #define	RTC_DOW		0x03	/* 03h Day-of-week */
66 #define	RTC_DOM		0x04	/* 04h Day-of-month */
67 #define	RTC_MON		0x05	/* 05h Month */
68 #define	RTC_YEAR	0x06	/* 06h Year */
69 #define	RTC_CTL		0x07	/* 07h Control reg. */
70 
71 /* Oscillator */
72 
73 #define	OSCILLATOR_REG		0x00	/* Oscillator Reg Addr */
74 #define	OSCILLATOR_DISABLE	0x80
75 
76 /* per instance based */
77 
78 #define	TOD_DETACHED		0x00	/* TOD detached */
79 #define	TOD_ATTACHED		0x01	/* TOD attached */
80 
81 typedef struct ds1307_state {
82 	i2c_client_hdl_t	ds1307_i2c_hdl;
83 	char			i2ctod_name[MAXNAMELEN];  /* node name */
84 	kmutex_t		i2ctod_mutex;   /* protects soft state */
85 	int			instance;
86 	dev_info_t		*dip;
87 	uint32_t		state;
88 	cyclic_id_t		cycid;
89 	struct rtc_t		rtc;
90 	i2c_transfer_t		*i2c_tp;
91 	ddi_softintr_t   	soft_intr_id;
92 	uint32_t		progress;
93 }ds1307_state_t;
94 
95 #ifdef	__cplusplus
96 }
97 #endif
98 
99 #endif	/* _TODDS1307_H */
100