Deleted Added
full compact
mc146818reg.h (59868) mc146818reg.h (137821)
1/* $FreeBSD: head/sys/dev/mc146818/mc146818reg.h 59868 2000-05-01 19:54:26Z peter $ */
2/* $NetBSD: mc146818reg.h,v 1.2 1997/03/12 06:53:42 cgd Exp $ */
3
4/*
5 * Copyright (c) 1995 Carnegie-Mellon University.
6 * All rights reserved.
7 *
8 * Permission to use, copy, modify and distribute this software and
9 * its documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions

--- 7 unchanged lines hidden (view full) ---

19 *
20 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
21 * School of Computer Science
22 * Carnegie Mellon University
23 * Pittsburgh PA 15213-3890
24 *
25 * any improvements or extensions that they make and grant Carnegie the
26 * rights to redistribute these changes.
1/*
2 * Copyright (c) 1995 Carnegie-Mellon University.
3 * All rights reserved.
4 *
5 * Permission to use, copy, modify and distribute this software and
6 * its documentation is hereby granted, provided that both the copyright
7 * notice and this permission notice appear in all copies of the
8 * software, derivative works or modified versions, and any portions

--- 7 unchanged lines hidden (view full) ---

16 *
17 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
18 * School of Computer Science
19 * Carnegie Mellon University
20 * Pittsburgh PA 15213-3890
21 *
22 * any improvements or extensions that they make and grant Carnegie the
23 * rights to redistribute these changes.
24 *
25 * from: NetBSD: mc146818reg.h,v 1.5 2003/11/02 11:07:45 wiz Exp
26 *
27 * $FreeBSD: head/sys/dev/mc146818/mc146818reg.h 137821 2004-11-17 16:37:25Z marius $
27 */
28
29/*
30 * Definitions for the Motorola MC146818A Real Time Clock.
28 */
29
30/*
31 * Definitions for the Motorola MC146818A Real Time Clock.
31 * They also apply for the (compatible) Dallas Semicontuctor DS1287A RTC.
32 * They also apply for the (compatible) Dallas Semiconductor DS1287A RTC.
32 *
33 * Though there are undoubtedly other (better) sources, this material was
34 * culled from the DEC "KN121 System Module Programmer's Reference
35 * Information."
36 *
37 * The MC146818A has 16 registers. The first 10 contain time-of-year
38 * and alarm data. The rest contain various control and status bits.
39 *

--- 97 unchanged lines hidden (view full) ---

137/*
138 * Time base (divisor select) constants (Control register A)
139 */
140#define MC_BASE_4_MHz 0x00 /* 4MHz crystal */
141#define MC_BASE_1_MHz 0x10 /* 1MHz crystal */
142#define MC_BASE_32_KHz 0x20 /* 32KHz crystal */
143#define MC_BASE_NONE 0x60 /* actually, both of these reset */
144#define MC_BASE_RESET 0x70
33 *
34 * Though there are undoubtedly other (better) sources, this material was
35 * culled from the DEC "KN121 System Module Programmer's Reference
36 * Information."
37 *
38 * The MC146818A has 16 registers. The first 10 contain time-of-year
39 * and alarm data. The rest contain various control and status bits.
40 *

--- 97 unchanged lines hidden (view full) ---

138/*
139 * Time base (divisor select) constants (Control register A)
140 */
141#define MC_BASE_4_MHz 0x00 /* 4MHz crystal */
142#define MC_BASE_1_MHz 0x10 /* 1MHz crystal */
143#define MC_BASE_32_KHz 0x20 /* 32KHz crystal */
144#define MC_BASE_NONE 0x60 /* actually, both of these reset */
145#define MC_BASE_RESET 0x70
145
146/*
147 * A collection of TOD/Alarm registers.
148 */
149typedef u_int mc_todregs[MC_NTODREGS];
150
151/*
152 * Get all of the TOD/Alarm registers
153 * Must be called at splhigh(), and with the RTC properly set up.
154 */
155#define MC146818_GETTOD(dev, regs) \
156 do { \
157 int i; \
158 \
159 /* update in progress; spin loop */ \
160 while (MCCLOCK_READ(dev, MC_REGA) & MC_REGA_UIP) \
161 ; \
162 \
163 /* read all of the tod/alarm regs */ \
164 for (i = 0; i < MC_NTODREGS; i++) \
165 (*regs)[i] = MCCLOCK_READ(dev, i); \
166 } while (0);
167
168/*
169 * Set all of the TOD/Alarm registers
170 * Must be called at splhigh(), and with the RTC properly set up.
171 */
172#define MC146818_PUTTOD(dev, regs) \
173 do { \
174 int i; \
175 \
176 /* stop updates while setting */ \
177 MCCLOCK_WRITE(dev, MC_REGB, \
178 MCCLOCK_READ(dev, MC_REGB) | MC_REGB_SET); \
179 \
180 /* write all of the tod/alarm regs */ \
181 for (i = 0; i < MC_NTODREGS; i++) \
182 MCCLOCK_WRITE(dev, i, (*regs)[i]); \
183 \
184 /* reenable updates */ \
185 MCCLOCK_WRITE(dev, MC_REGB, \
186 MCCLOCK_READ(dev, MC_REGB) & ~MC_REGB_SET); \
187 } while (0);