intersil7170reg.h revision 1.1.8.2 1 1.1.8.2 yamt /* $NetBSD: intersil7170reg.h,v 1.1.8.2 2006/12/30 20:48:03 yamt Exp $ */
2 1.1.8.2 yamt
3 1.1.8.2 yamt /*-
4 1.1.8.2 yamt * Copyright (c) 1996 The NetBSD Foundation, Inc.
5 1.1.8.2 yamt * All rights reserved.
6 1.1.8.2 yamt *
7 1.1.8.2 yamt * This code is derived from software contributed to The NetBSD Foundation
8 1.1.8.2 yamt * by Adam Glass.
9 1.1.8.2 yamt *
10 1.1.8.2 yamt * Redistribution and use in source and binary forms, with or without
11 1.1.8.2 yamt * modification, are permitted provided that the following conditions
12 1.1.8.2 yamt * are met:
13 1.1.8.2 yamt * 1. Redistributions of source code must retain the above copyright
14 1.1.8.2 yamt * notice, this list of conditions and the following disclaimer.
15 1.1.8.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.8.2 yamt * notice, this list of conditions and the following disclaimer in the
17 1.1.8.2 yamt * documentation and/or other materials provided with the distribution.
18 1.1.8.2 yamt * 3. All advertising materials mentioning features or use of this software
19 1.1.8.2 yamt * must display the following acknowledgement:
20 1.1.8.2 yamt * This product includes software developed by the NetBSD
21 1.1.8.2 yamt * Foundation, Inc. and its contributors.
22 1.1.8.2 yamt * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1.8.2 yamt * contributors may be used to endorse or promote products derived
24 1.1.8.2 yamt * from this software without specific prior written permission.
25 1.1.8.2 yamt *
26 1.1.8.2 yamt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1.8.2 yamt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1.8.2 yamt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1.8.2 yamt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1.8.2 yamt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1.8.2 yamt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1.8.2 yamt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1.8.2 yamt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1.8.2 yamt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1.8.2 yamt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1.8.2 yamt * POSSIBILITY OF SUCH DAMAGE.
37 1.1.8.2 yamt */
38 1.1.8.2 yamt
39 1.1.8.2 yamt #ifndef _INTERSIL7170REG_H_
40 1.1.8.2 yamt #define _INTERSIL7170REG_H_
41 1.1.8.2 yamt
42 1.1.8.2 yamt /*
43 1.1.8.2 yamt * Driver support for the intersil7170 used in sun[34]s to provide
44 1.1.8.2 yamt * real time clock and time-of-day support.
45 1.1.8.2 yamt *
46 1.1.8.2 yamt * Derived from: datasheet "ICM7170 a uP-Compatible Real-Time Clock"
47 1.1.8.2 yamt * document #301680-005, Dec 85
48 1.1.8.2 yamt *
49 1.1.8.2 yamt * Note that this device provides both time-of-day and interval timer
50 1.1.8.2 yamt * functionality. Both functions use the same control registers. On top
51 1.1.8.2 yamt * of that, the command control register is write-only. Currently, this
52 1.1.8.2 yamt * driver assumes that the interval timer is to be enabled, and hence
53 1.1.8.2 yamt * always sets/restores the INTERSIL_CMD_IENABLE control bit when
54 1.1.8.2 yamt * manipulating the TOD.
55 1.1.8.2 yamt */
56 1.1.8.2 yamt
57 1.1.8.2 yamt struct intersil_dt { /* from p. 7 of 10 */
58 1.1.8.2 yamt uint8_t dt_csec;
59 1.1.8.2 yamt uint8_t dt_hour;
60 1.1.8.2 yamt uint8_t dt_min;
61 1.1.8.2 yamt uint8_t dt_sec;
62 1.1.8.2 yamt uint8_t dt_month;
63 1.1.8.2 yamt uint8_t dt_day;
64 1.1.8.2 yamt uint8_t dt_year;
65 1.1.8.2 yamt uint8_t dt_dow;
66 1.1.8.2 yamt };
67 1.1.8.2 yamt
68 1.1.8.2 yamt struct intersil7170 {
69 1.1.8.2 yamt struct intersil_dt counters;
70 1.1.8.2 yamt struct intersil_dt clk_ram; /* should be ok as both are word aligned */
71 1.1.8.2 yamt uint8_t clk_intr_reg;
72 1.1.8.2 yamt uint8_t clk_cmd_reg;
73 1.1.8.2 yamt };
74 1.1.8.2 yamt
75 1.1.8.2 yamt /* Indices to time-of-day clock registers */
76 1.1.8.2 yamt #define INTERSIL_ICSEC 0
77 1.1.8.2 yamt #define INTERSIL_IHOUR 1
78 1.1.8.2 yamt #define INTERSIL_IMIN 2
79 1.1.8.2 yamt #define INTERSIL_ISEC 3
80 1.1.8.2 yamt #define INTERSIL_IMON 4
81 1.1.8.2 yamt #define INTERSIL_IDAY 5
82 1.1.8.2 yamt #define INTERSIL_IYEAR 6
83 1.1.8.2 yamt #define INTERSIL_IDOW 7
84 1.1.8.2 yamt
85 1.1.8.2 yamt #define INTERSIL_IINTR 16
86 1.1.8.2 yamt #define INTERSIL_ICMD 17
87 1.1.8.2 yamt
88 1.1.8.2 yamt /* bit assignments for command register, p. 6 of 10, write-only */
89 1.1.8.2 yamt #define INTERSIL_CMD_FREQ_32K 0x0
90 1.1.8.2 yamt #define INTERSIL_CMD_FREQ_1M 0x1
91 1.1.8.2 yamt #define INTERSIL_CMD_FREQ_2M 0x2
92 1.1.8.2 yamt #define INTERSIL_CMD_FREQ_4M 0x3
93 1.1.8.2 yamt
94 1.1.8.2 yamt #define INTERSIL_CMD_12HR_MODE 0x0
95 1.1.8.2 yamt #define INTERSIL_CMD_24HR_MODE 0x4
96 1.1.8.2 yamt
97 1.1.8.2 yamt #define INTERSIL_CMD_STOP 0x0
98 1.1.8.2 yamt #define INTERSIL_CMD_RUN 0x8
99 1.1.8.2 yamt
100 1.1.8.2 yamt #define INTERSIL_CMD_IDISABLE 0x0
101 1.1.8.2 yamt #define INTERSIL_CMD_IENABLE 0x10
102 1.1.8.2 yamt
103 1.1.8.2 yamt #define INTERSIL_CMD_TEST_MODE 0x20
104 1.1.8.2 yamt #define INTERSIL_CMD_NORMAL_MODE 0x0
105 1.1.8.2 yamt
106 1.1.8.2 yamt #define INTERSIL_COMMAND(run, interrupt) \
107 1.1.8.2 yamt ((run) | (interrupt) | INTERSIL_CMD_FREQ_32K | \
108 1.1.8.2 yamt INTERSIL_CMD_24HR_MODE | INTERSIL_CMD_NORMAL_MODE)
109 1.1.8.2 yamt
110 1.1.8.2 yamt /* bit assignments for interrupt register r/w, p 7 of 10 */
111 1.1.8.2 yamt
112 1.1.8.2 yamt #define INTERSIL_INTER_ALARM 0x1 /* r/w */
113 1.1.8.2 yamt #define INTERSIL_INTER_CSECONDS 0x2 /* r/w */
114 1.1.8.2 yamt #define INTERSIL_INTER_DSECONDS 0x4 /* r/w */
115 1.1.8.2 yamt #define INTERSIL_INTER_SECONDS 0x8 /* r/w */
116 1.1.8.2 yamt #define INTERSIL_INTER_MINUTES 0x10 /* r/w */
117 1.1.8.2 yamt #define INTERSIL_INTER_HOURS 0x20 /* r/w */
118 1.1.8.2 yamt #define INTERSIL_INTER_DAYS 0x40 /* r/w */
119 1.1.8.2 yamt #define INTERSIL_INTER_PENDING 0x80 /* read-only */
120 1.1.8.2 yamt
121 1.1.8.2 yamt #define INTERSIL_INTER_BITS \
122 1.1.8.2 yamt "\20\10PENDING\7DAYS\6HRS\5MIN\4SCDS\3DSEC\2CSEC\1ALARM"
123 1.1.8.2 yamt
124 1.1.8.2 yamt #endif /* _INTERSIL7170REG_H_ */
125