mk48txxreg.h revision 331722
1/*-
2 * Copyright (c) 2000 The NetBSD Foundation, Inc.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Paul Kranenburg.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 *
29 *	$NetBSD: mk48txxreg.h,v 1.10 2008/04/28 20:23:50 martin Exp $
30 *
31 * $FreeBSD: stable/11/sys/dev/mk48txx/mk48txxreg.h 331722 2018-03-29 02:50:57Z eadler $
32 */
33
34/*
35 * Mostek MK48Txx clocks.
36 *
37 * The MK48T02 has 2KB of non-volatile memory. The time-of-day clock
38 * registers start at offset 0x7f8.
39 *
40 * The MK48T08 and MK48T18 have 8KB of non-volatile memory
41 *
42 * The MK48T59 also has 8KB of non-volatile memory but in addition it
43 * has a battery low detection bit and a power supply wakeup alarm for
44 * power management.  It's at offset 0x1ff0 in the NVRAM.
45 */
46
47/*
48 * Mostek MK48TXX register definitions
49 */
50
51/*
52 * The first bank of eight registers at offset (nvramsz - 16) is
53 * available only on recenter (which?) MK48Txx models.
54 */
55#define	MK48TXX_FLAGS	0	/* flags register */
56#define	MK48TXX_UNUSED	1	/* unused */
57#define	MK48TXX_ASEC	2	/* alarm seconds (0..59; BCD) */
58#define	MK48TXX_AMIN	3	/* alarm minutes (0..59; BCD) */
59#define	MK48TXX_AHOUR	4	/* alarm hours (0..23; BCD) */
60#define	MK48TXX_ADAY	5	/* alarm day in month (1..31; BCD) */
61#define	MK48TXX_INTR	6	/* interrupts register */
62#define	MK48TXX_WDOG	7	/* watchdog register */
63
64#define	MK48TXX_ICSR	8	/* control register */
65#define	MK48TXX_ISEC	9	/* seconds (0..59; BCD) */
66#define	MK48TXX_IMIN	10	/* minutes (0..59; BCD) */
67#define	MK48TXX_IHOUR	11	/* hours (0..23; BCD) */
68#define	MK48TXX_IWDAY	12	/* weekday (1..7) */
69#define	MK48TXX_IDAY	13	/* day in month (1..31; BCD) */
70#define	MK48TXX_IMON	14	/* month (1..12; BCD) */
71#define	MK48TXX_IYEAR	15	/* year (0..99; BCD) */
72
73/*
74 * Note that some of the bits below that are not in the first eight
75 * registers are also only available on models with an extended
76 * register set.
77 */
78
79/* Bits in the flags register (extended only) */
80#define	MK48TXX_FLAGS_BL	0x10	/* battery low (read only) */
81#define	MK48TXX_FLAGS_AF	0x40	/* alarm flag (read only) */
82#define	MK48TXX_FLAGS_WDF	0x80	/* watchdog flag (read only) */
83
84/* Bits in the alarm seconds register (extended only) */
85#define	MK48TXX_ASEC_MASK	0x7f	/* mask for alarm seconds */
86#define	MK48TXX_ASEC_RPT1	0x80	/* alarm repeat mode bit 1 */
87
88/* Bits in the alarm minutes register (extended only) */
89#define	MK48TXX_AMIN_MASK	0x7f	/* mask for alarm minutes */
90#define	MK48TXX_AMIN_RPT2	0x80	/* alarm repeat mode bit 2 */
91
92/* Bits in the alarm hours register (extended only) */
93#define	MK48TXX_AHOUR_MASK	0x3f	/* mask for alarm hours */
94#define	MK48TXX_AHOUR_RPT3	0x80	/* alarm repeat mode bit 3 */
95
96/* Bits in the alarm day in month register (extended only) */
97#define	MK48TXX_ADAY_MASK	0x3f	/* mask for alarm day in month */
98#define	MK48TXX_ADAY_RPT4	0x80	/* alarm repeat mode bit 4 */
99
100/* Bits in the interrupts register (extended only) */
101#define	MK48TXX_INTR_ABE	0x20	/* alarm in battery back-up mode */
102#define	MK48TXX_INTR_AFE	0x80	/* alarm flag enable */
103
104/* Bits in the watchdog register (extended only) */
105#define	MK48TXX_WDOG_RB_1_16	0x00	/* watchdog resolution 1/16 second */
106#define	MK48TXX_WDOG_RB_1_4	0x01	/* watchdog resolution 1/4 second */
107#define	MK48TXX_WDOG_RB_1	0x02	/* watchdog resolution 1 second */
108#define	MK48TXX_WDOG_RB_4	0x03	/* watchdog resolution 4 seconds */
109#define	MK48TXX_WDOG_BMB_MASK	0x7c	/* mask for watchdog multiplier */
110#define	MK48TXX_WDOG_BMB_SHIFT	2	/* shift for watchdog multiplier */
111#define	MK48TXX_WDOG_WDS	0x80	/* watchdog steering bit */
112
113/* Bits in the control register */
114#define	MK48TXX_CSR_CALIB_MASK	0x1f	/* mask for calibration step width */
115#define	MK48TXX_CSR_SIGN	0x20	/* sign of above calibration witdh */
116#define	MK48TXX_CSR_READ	0x40	/* want to read (freeze clock) */
117#define	MK48TXX_CSR_WRITE	0x80	/* want to write */
118
119/* Bits in the seconds register */
120#define	MK48TXX_SEC_MASK	0x7f	/* mask for seconds */
121#define	MK48TXX_SEC_ST		0x80	/* stop oscillator */
122
123/* Bits in the minutes register */
124#define	MK48TXX_MIN_MASK	0x7f	/* mask for minutes */
125
126/* Bits in the hours register */
127#define	MK48TXX_HOUR_MASK	0x3f	/* mask for hours */
128
129/* Bits in the century/weekday register */
130#define	MK48TXX_WDAY_MASK	0x07	/* mask for weekday */
131#define	MK48TXX_WDAY_CB		0x10	/* century bit (extended only) */
132#define	MK48TXX_WDAY_CB_SHIFT	4	/* shift for century bit */
133#define	MK48TXX_WDAY_CEB	0x20	/* century enable bit (extended only) */
134#define	MK48TXX_WDAY_FT		0x40	/* frequency test */
135
136/* Bits in the day in month register */
137#define	MK48TXX_DAY_MASK	0x3f	/* mask for day in month */
138
139/* Bits in the month register */
140#define	MK48TXX_MON_MASK	0x1f	/* mask for month */
141
142/* Bits in the year register */
143#define	MK48TXX_YEAR_MASK	0xff	/* mask for year */
144
145/* Model specific NVRAM sizes and clock offsets */
146#define	MK48T02_CLKSZ		2048
147#define	MK48T02_CLKOFF		0x7f0
148
149#define	MK48T08_CLKSZ		8192
150#define	MK48T08_CLKOFF		0x1ff0
151
152#define	MK48T18_CLKSZ		8192
153#define	MK48T18_CLKOFF		0x1ff0
154
155#define	MK48T37_CLKSZ		32768
156#define	MK48T37_CLKOFF		0x1ff0
157
158#define	MK48T59_CLKSZ		8192
159#define	MK48T59_CLKOFF		0x1ff0
160