193836Stmm/*-
293836Stmm * Copyright (c) 2000 The NetBSD Foundation, Inc.
393836Stmm * All rights reserved.
493836Stmm *
593836Stmm * This code is derived from software contributed to The NetBSD Foundation
693836Stmm * by Paul Kranenburg.
793836Stmm *
893836Stmm * Redistribution and use in source and binary forms, with or without
993836Stmm * modification, are permitted provided that the following conditions
1093836Stmm * are met:
1193836Stmm * 1. Redistributions of source code must retain the above copyright
1293836Stmm *    notice, this list of conditions and the following disclaimer.
1393836Stmm * 2. Redistributions in binary form must reproduce the above copyright
1493836Stmm *    notice, this list of conditions and the following disclaimer in the
1593836Stmm *    documentation and/or other materials provided with the distribution.
1693836Stmm *
1793836Stmm * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1893836Stmm * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1993836Stmm * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2093836Stmm * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2193836Stmm * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2293836Stmm * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2393836Stmm * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2493836Stmm * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2593836Stmm * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2693836Stmm * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2793836Stmm * POSSIBILITY OF SUCH DAMAGE.
2893836Stmm *
29201004Smarius *	$NetBSD: mk48txxreg.h,v 1.10 2008/04/28 20:23:50 martin Exp $
3093836Stmm *
3193836Stmm * $FreeBSD: releng/10.2/sys/dev/mk48txx/mk48txxreg.h 221957 2011-05-15 13:17:08Z marius $
3293836Stmm */
3393836Stmm
3493836Stmm/*
3593836Stmm * Mostek MK48Txx clocks.
3693836Stmm *
3793836Stmm * The MK48T02 has 2KB of non-volatile memory. The time-of-day clock
3893836Stmm * registers start at offset 0x7f8.
3993836Stmm *
40137813Smarius * The MK48T08 and MK48T18 have 8KB of non-volatile memory
4193836Stmm *
4293836Stmm * The MK48T59 also has 8KB of non-volatile memory but in addition it
4393836Stmm * has a battery low detection bit and a power supply wakeup alarm for
4493836Stmm * power management.  It's at offset 0x1ff0 in the NVRAM.
4593836Stmm */
4693836Stmm
4793836Stmm/*
4893836Stmm * Mostek MK48TXX register definitions
4993836Stmm */
5093836Stmm
5193836Stmm/*
5293836Stmm * The first bank of eight registers at offset (nvramsz - 16) is
5393836Stmm * available only on recenter (which?) MK48Txx models.
5493836Stmm */
55201003Smarius#define	MK48TXX_FLAGS	0	/* flags register */
56201003Smarius#define	MK48TXX_UNUSED	1	/* unused */
57201003Smarius#define	MK48TXX_ASEC	2	/* alarm seconds (0..59; BCD) */
58201003Smarius#define	MK48TXX_AMIN	3	/* alarm minutes (0..59; BCD) */
59201003Smarius#define	MK48TXX_AHOUR	4	/* alarm hours (0..23; BCD) */
60201003Smarius#define	MK48TXX_ADAY	5	/* alarm day in month (1..31; BCD) */
61201003Smarius#define	MK48TXX_INTR	6	/* interrupts register */
62201003Smarius#define	MK48TXX_WDOG	7	/* watchdog register */
63135481Smarius
64201003Smarius#define	MK48TXX_ICSR	8	/* control register */
65201003Smarius#define	MK48TXX_ISEC	9	/* seconds (0..59; BCD) */
66201003Smarius#define	MK48TXX_IMIN	10	/* minutes (0..59; BCD) */
67201003Smarius#define	MK48TXX_IHOUR	11	/* hours (0..23; BCD) */
68201003Smarius#define	MK48TXX_IWDAY	12	/* weekday (1..7) */
69201003Smarius#define	MK48TXX_IDAY	13	/* day in month (1..31; BCD) */
70201003Smarius#define	MK48TXX_IMON	14	/* month (1..12; BCD) */
71201003Smarius#define	MK48TXX_IYEAR	15	/* year (0..99; BCD) */
7293836Stmm
73135481Smarius/*
74135481Smarius * Note that some of the bits below that are not in the first eight
75135481Smarius * registers are also only available on models with an extended
76135481Smarius * register set.
77135481Smarius */
78135481Smarius
79135481Smarius/* Bits in the flags register (extended only) */
80201003Smarius#define	MK48TXX_FLAGS_BL	0x10	/* battery low (read only) */
81201003Smarius#define	MK48TXX_FLAGS_AF	0x40	/* alarm flag (read only) */
82201003Smarius#define	MK48TXX_FLAGS_WDF	0x80	/* watchdog flag (read only) */
83135481Smarius
84135481Smarius/* Bits in the alarm seconds register (extended only) */
85201003Smarius#define	MK48TXX_ASEC_MASK	0x7f	/* mask for alarm seconds */
86201003Smarius#define	MK48TXX_ASEC_RPT1	0x80	/* alarm repeat mode bit 1 */
87135481Smarius
88135481Smarius/* Bits in the alarm minutes register (extended only) */
89201003Smarius#define	MK48TXX_AMIN_MASK	0x7f	/* mask for alarm minutes */
90201003Smarius#define	MK48TXX_AMIN_RPT2	0x80	/* alarm repeat mode bit 2 */
91135481Smarius
92135481Smarius/* Bits in the alarm hours register (extended only) */
93201003Smarius#define	MK48TXX_AHOUR_MASK	0x3f	/* mask for alarm hours */
94201003Smarius#define	MK48TXX_AHOUR_RPT3	0x80	/* alarm repeat mode bit 3 */
95135481Smarius
96135481Smarius/* Bits in the alarm day in month register (extended only) */
97201003Smarius#define	MK48TXX_ADAY_MASK	0x3f	/* mask for alarm day in month */
98201003Smarius#define	MK48TXX_ADAY_RPT4	0x80	/* alarm repeat mode bit 4 */
99135481Smarius
100135481Smarius/* Bits in the interrupts register (extended only) */
101201003Smarius#define	MK48TXX_INTR_ABE	0x20	/* alarm in battery back-up mode */
102201003Smarius#define	MK48TXX_INTR_AFE	0x80	/* alarm flag enable */
103135481Smarius
104135481Smarius/* Bits in the watchdog register (extended only) */
105201003Smarius#define	MK48TXX_WDOG_RB_1_16	0x00	/* watchdog resolution 1/16 second */
106201003Smarius#define	MK48TXX_WDOG_RB_1_4	0x01	/* watchdog resolution 1/4 second */
107201003Smarius#define	MK48TXX_WDOG_RB_1	0x02	/* watchdog resolution 1 second */
108201003Smarius#define	MK48TXX_WDOG_RB_4	0x03	/* watchdog resolution 4 seconds */
109201003Smarius#define	MK48TXX_WDOG_BMB_MASK	0x7c	/* mask for watchdog multiplier */
110201003Smarius#define	MK48TXX_WDOG_BMB_SHIFT	2	/* shift for watchdog multiplier */
111201003Smarius#define	MK48TXX_WDOG_WDS	0x80	/* watchdog steering bit */
112135481Smarius
11393836Stmm/* Bits in the control register */
114201003Smarius#define	MK48TXX_CSR_CALIB_MASK	0x1f	/* mask for calibration step width */
115201003Smarius#define	MK48TXX_CSR_SIGN	0x20	/* sign of above calibration witdh */
116201003Smarius#define	MK48TXX_CSR_READ	0x40	/* want to read (freeze clock) */
117201003Smarius#define	MK48TXX_CSR_WRITE	0x80	/* want to write */
11893836Stmm
119135481Smarius/* Bits in the seconds register */
120201003Smarius#define	MK48TXX_SEC_MASK	0x7f	/* mask for seconds */
121201003Smarius#define	MK48TXX_SEC_ST		0x80	/* stop oscillator */
122135481Smarius
123135481Smarius/* Bits in the minutes register */
124201003Smarius#define	MK48TXX_MIN_MASK	0x7f	/* mask for minutes */
125135481Smarius
126135481Smarius/* Bits in the hours register */
127201003Smarius#define	MK48TXX_HOUR_MASK	0x3f	/* mask for hours */
128135481Smarius
129135481Smarius/* Bits in the century/weekday register */
130201003Smarius#define	MK48TXX_WDAY_MASK	0x07	/* mask for weekday */
131201003Smarius#define	MK48TXX_WDAY_CB		0x10	/* century bit (extended only) */
132201003Smarius#define	MK48TXX_WDAY_CB_SHIFT	4	/* shift for century bit */
133201003Smarius#define	MK48TXX_WDAY_CEB	0x20	/* century enable bit (extended only) */
134201003Smarius#define	MK48TXX_WDAY_FT		0x40	/* frequency test */
135135481Smarius
136135481Smarius/* Bits in the day in month register */
137201003Smarius#define	MK48TXX_DAY_MASK	0x3f	/* mask for day in month */
138135481Smarius
139135481Smarius/* Bits in the month register */
140201003Smarius#define	MK48TXX_MON_MASK	0x1f	/* mask for month */
141135481Smarius
142135481Smarius/* Bits in the year register */
143201003Smarius#define	MK48TXX_YEAR_MASK	0xff	/* mask for year */
144135481Smarius
145135481Smarius/* Model specific NVRAM sizes and clock offsets */
146201003Smarius#define	MK48T02_CLKSZ		2048
147201003Smarius#define	MK48T02_CLKOFF		0x7f0
14893836Stmm
149201003Smarius#define	MK48T08_CLKSZ		8192
150201003Smarius#define	MK48T08_CLKOFF		0x1ff0
15193836Stmm
152201003Smarius#define	MK48T18_CLKSZ		8192
153201003Smarius#define	MK48T18_CLKOFF		0x1ff0
154137813Smarius
155221957Smarius#define	MK48T37_CLKSZ		32768
156221957Smarius#define	MK48T37_CLKOFF		0x1ff0
157221957Smarius
158201003Smarius#define	MK48T59_CLKSZ		8192
159201003Smarius#define	MK48T59_CLKOFF		0x1ff0
160