xref: /original-bsd/sys/luna68k/luna68k/clockreg.h (revision 3705696b)
1 /*
2  * Copyright (c) 1988 University of Utah.
3  * Copyright (c) 1992 OMRON Corporation.
4  * Copyright (c) 1982, 1990, 1992, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * the Systems Programming Group of the University of Utah Computer
9  * Science Department.
10  *
11  * %sccs.include.redist.c%
12  *
13  * from: Utah $Hdr: clockreg.h 1.14 91/01/18$
14  * from: hp300/hp300/clockreg.h	7.4 (Berkeley) 12/27/92
15  *
16  *	@(#)clockreg.h	8.1 (Berkeley) 06/10/93
17  */
18 
19 /*
20  *  LUNA system clock defines
21  */
22 #define	CLOCK_REG	0x63000000	/* system clock address */
23 
24 #define	CLK_INT		0x7		/* system clock intr flag */
25 #define	CLK_CLR		0x1		/* system clock intr clear */
26 
27 /*
28  * LUNA battery-backed clock
29  */
30 
31 /* only use software */
32 struct bbc_tm {
33 	int	tm_sec;
34 	int	tm_min;
35 	int	tm_hour;
36 	int	tm_mday;
37 	int	tm_mon;
38 	int	tm_year;
39 };
40 
41 #define FEBRUARY	2
42 #define	STARTOFTIME	1970
43 #define SECDAY		86400L
44 #define SECYR		(SECDAY * 365)
45 
46 #define	leapyear(year)		((year) % 4 == 0)
47 #define	range_test(n, l, h)	if ((n) < (l) || (n) > (h)) return(0)
48 #define	days_in_year(a) 	(leapyear(a) ? 366 : 365)
49 #define	days_in_month(a) 	(month_days[(a) - 1])
50 
51 /*
52  * TIME KEEPER RAM -- (MK48T02/12(B)-12/15/20/25)
53  */
54 
55 #include <luna68k/dev/nvram.h>
56 
57 struct bbc {
58     struct nvram 	nvram;	       	/* non-volatile RAM area */
59     unsigned char    	cal_ctl;       	/* calender control resistor */
60     unsigned char	cal_sec;       	/* secons resistor */
61     unsigned char	cal_min;       	/* minutes resistor */
62     unsigned char	cal_hour;      	/* hours resitor */
63     unsigned char	cal_dow;       	/* day of the weeks */
64     unsigned char	cal_day;       	/* days resistor */
65     unsigned char	cal_mon;       	/* months resistor */
66     unsigned char	cal_year;      	/* years resistor */
67 };
68 
69 #define	BBC_ADDR	0x45000000	/* battery backuped clock address */
70 
71 #define	BBC_FRQ		0x40		/* Frequency test (in day) */
72 #define	BBC_KICK	0x80		/* Kick start (in hour) */
73 #define	BBC_STOP	0x80		/* Stop bit (in seconds) */
74 #define	BBC_WRT		0x80		/* Write bit (in control) */
75 #define	BBC_RD		0x40		/* Read bit (in control) */
76 #define	BBC_SGN		0x20		/* Sign bit (in control) */
77 #define	BBC_DELAY	180		/* delay time */
78 
79 #define	binary_to_bcd(i)	(((i) / 10) << 4 | ((i) % 10))
80 #define	bcd_to_binary(i)	(((i) >> 4) *10 + ((i) & 0x0F))
81 
82 #ifdef LUNA2
83 struct bbc2 {
84     unsigned char	cal_sec;	/* secons resistor */
85     unsigned char	cal_sec_alarm;	/* secons alarm resistor */
86     unsigned char	cal_min;	/* minutes resistor */
87     unsigned char	cal_min_alarm;	/* minutes alarm resistor */
88     unsigned char	cal_hour;	/* hours resitor */
89     unsigned char	cal_hour_alarm;	/* hours alarm resitor */
90     unsigned char	cal_dow;	/* day of the weeks */
91     unsigned char	cal_day;	/* days resistor */
92     unsigned char	cal_mon;	/* months resistor */
93     unsigned char	cal_year;	/* years resistor */
94     unsigned char    	cal_ctl_a;	/* calender control resistor */
95     unsigned char    	cal_ctl_b;	/* calender control resistor */
96     unsigned char    	cal_ctl_c;	/* calender control resistor */
97     unsigned char    	cal_ctl_d;	/* calender control resistor */
98     unsigned char    	nvram[50];	/* non-volatile RAM area */
99 };
100 #endif
101