14Srgrimes/*-
24Srgrimes * Copyright (c) 1990 The Regents of the University of California.
34Srgrimes * All rights reserved.
44Srgrimes *
54Srgrimes * This code is derived from software contributed to Berkeley by
64Srgrimes * William Jolitz.
74Srgrimes *
84Srgrimes * Redistribution and use in source and binary forms, with or without
94Srgrimes * modification, are permitted provided that the following conditions
104Srgrimes * are met:
114Srgrimes * 1. Redistributions of source code must retain the above copyright
124Srgrimes *    notice, this list of conditions and the following disclaimer.
134Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
144Srgrimes *    notice, this list of conditions and the following disclaimer in the
154Srgrimes *    documentation and/or other materials provided with the distribution.
164Srgrimes * 4. Neither the name of the University nor the names of its contributors
174Srgrimes *    may be used to endorse or promote products derived from this software
184Srgrimes *    without specific prior written permission.
194Srgrimes *
204Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
214Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
224Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
234Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
244Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
254Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
264Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
274Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
284Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
294Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
304Srgrimes * SUCH DAMAGE.
314Srgrimes *
32619Srgrimes *	from: @(#)rtc.h	7.1 (Berkeley) 5/12/91
3350477Speter * $FreeBSD$
344Srgrimes */
354Srgrimes
36720Swollman#ifndef _I386_ISA_RTC_H_
37720Swollman#define _I386_ISA_RTC_H_ 1
38720Swollman
394Srgrimes/*
4037556Sphk * MC146818 RTC Register locations
414Srgrimes */
424Srgrimes
434Srgrimes#define RTC_SEC		0x00	/* seconds */
444Srgrimes#define RTC_SECALRM	0x01	/* seconds alarm */
454Srgrimes#define RTC_MIN		0x02	/* minutes */
464Srgrimes#define RTC_MINALRM	0x03	/* minutes alarm */
474Srgrimes#define RTC_HRS		0x04	/* hours */
484Srgrimes#define RTC_HRSALRM	0x05	/* hours alarm */
494Srgrimes#define RTC_WDAY	0x06	/* week day */
504Srgrimes#define RTC_DAY		0x07	/* day of month */
514Srgrimes#define RTC_MONTH	0x08	/* month of year */
524Srgrimes#define RTC_YEAR	0x09	/* month of year */
532074Swollman
544Srgrimes#define RTC_STATUSA	0x0a	/* status register A */
554Srgrimes#define  RTCSA_TUP	 0x80	/* time update, don't look now */
5637556Sphk#define  RTCSA_RESET	 0x70	/* reset divider */
572074Swollman#define  RTCSA_DIVIDER   0x20   /* divider correct for 32768 Hz */
5837556Sphk#define  RTCSA_8192      0x03	/* 8192 Hz interrupt */
592074Swollman#define  RTCSA_4096      0x04
602074Swollman#define  RTCSA_2048      0x05
612074Swollman#define  RTCSA_1024      0x06	/* default for profiling */
622074Swollman#define  RTCSA_PROF      RTCSA_1024
632074Swollman#define  RTC_PROFRATE    1024
642074Swollman#define  RTCSA_512       0x07
652074Swollman#define  RTCSA_256       0x08
662074Swollman#define  RTCSA_128       0x09
672074Swollman#define  RTCSA_NOPROF	 RTCSA_128
682074Swollman#define  RTC_NOPROFRATE  128
692074Swollman#define  RTCSA_64        0x0a
7037556Sphk#define  RTCSA_32        0x0b	/* 32 Hz interrupt */
714Srgrimes
724Srgrimes#define RTC_STATUSB	0x0b	/* status register B */
7337556Sphk#define	 RTCSB_DST	 0x01	/* USA Daylight Savings Time enable */
742913Sache#define	 RTCSB_24HR	 0x02	/* 0 = 12 hours, 1 = 24	hours */
752913Sache#define	 RTCSB_BCD	 0x04	/* 0 = BCD, 1 =	Binary coded time */
762913Sache#define	 RTCSB_SQWE	 0x08	/* 1 = output sqare wave at SQW	pin */
772913Sache#define	 RTCSB_UINTR	 0x10	/* 1 = enable update-ended interrupt */
782913Sache#define	 RTCSB_AINTR	 0x20	/* 1 = enable alarm interrupt */
792913Sache#define	 RTCSB_PINTR	 0x40	/* 1 = enable periodic clock interrupt */
802074Swollman#define  RTCSB_HALT      0x80	/* stop clock updates */
814Srgrimes
824Srgrimes#define RTC_INTR	0x0c	/* status register C (R) interrupt source */
834Srgrimes#define  RTCIR_UPDATE	 0x10	/* update intr */
844Srgrimes#define  RTCIR_ALARM	 0x20	/* alarm intr */
854Srgrimes#define  RTCIR_PERIOD	 0x40	/* periodic intr */
864Srgrimes#define  RTCIR_INT	 0x80	/* interrupt output signal */
874Srgrimes
884Srgrimes#define RTC_STATUSD	0x0d	/* status register D (R) Lost Power */
8937556Sphk#define  RTCSD_PWR	 0x80	/* clock power OK */
904Srgrimes
914Srgrimes#define RTC_DIAG	0x0e	/* status register E - bios diagnostic */
924Srgrimes#define RTCDG_BITS	"\020\010clock_battery\007ROM_cksum\006config_unit\005memory_size\004fixed_disk\003invalid_time"
934Srgrimes
944Srgrimes#define RTC_RESET	0x0f	/* status register F - reset code byte */
954Srgrimes#define	 RTCRS_RST	 0x00		/* normal reset */
964Srgrimes#define	 RTCRS_LOAD	 0x04		/* load system */
974Srgrimes
984Srgrimes#define RTC_FDISKETTE	0x10	/* diskette drive type in upper/lower nibble */
994Srgrimes#define	 RTCFDT_NONE	 0		/* none present */
1004Srgrimes#define	 RTCFDT_360K	 0x10		/* 360K */
1014Srgrimes#define	 RTCFDT_12M	 0x20		/* 1.2M */
102873Sache#define  RTCFDT_720K     0x30           /* 720K */
1034Srgrimes#define	 RTCFDT_144M	 0x40		/* 1.44M */
10411375Sjoerg#define  RTCFDT_288M_1   0x50		/* 2.88M, some BIOSes */
1054968Sjoerg#define	 RTCFDT_288M	 0x60		/* 2.88M */
1064Srgrimes
1074Srgrimes#define RTC_BASELO	0x15	/* low byte of basemem size */
1084Srgrimes#define RTC_BASEHI	0x16	/* high byte of basemem size */
1094Srgrimes#define RTC_EXTLO	0x17	/* low byte of extended mem size */
1104Srgrimes#define RTC_EXTHI	0x18	/* low byte of extended mem size */
1114Srgrimes
1122913Sache#define	RTC_CENTURY	0x32	/* current century */
113178192Sphk
114178192Sphk#ifdef _KERNEL
115178192Sphkextern  struct mtx clock_lock;
116191766Smavextern	int atrtcclock_disable;
117178192Sphkint	rtcin(int reg);
118178192Sphkvoid	atrtc_restore(void);
119178192Sphkvoid	writertc(int reg, u_char val);
120178192Sphk#endif
121178192Sphk
122720Swollman#endif /* _I386_ISA_RTC_H_ */
123