1 /*
2 * arch/m68k/sun3/intersil.c
3 *
4 * basic routines for accessing the intersil clock within the sun3 machines
5 *
6 * started 11/12/1999 Sam Creasey
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive
10 * for more details.
11 */
12
13 #include <linux/kernel.h>
14 #include <linux/rtc.h>
15
16 #include <asm/system.h>
17 #include <asm/rtc.h>
18 #include <asm/intersil.h>
19
20
21 /* bits to set for start/run of the intersil */
22 #define STOP_VAL (INTERSIL_STOP | INTERSIL_INT_ENABLE | INTERSIL_24H_MODE)
23 #define START_VAL (INTERSIL_RUN | INTERSIL_INT_ENABLE | INTERSIL_24H_MODE)
24
25 /* does this need to be implemented? */
sun3_gettimeoffset(void)26 unsigned long sun3_gettimeoffset(void)
27 {
28 return 1;
29 }
30
sun3_gettod(int * yearp,int * monp,int * dayp,int * hourp,int * minp,int * secp)31 void sun3_gettod (int *yearp, int *monp, int *dayp,
32 int *hourp, int *minp, int *secp)
33 {
34 unsigned char wday;
35 volatile struct intersil_dt* todintersil;
36 unsigned long flags;
37
38 todintersil = (struct intersil_dt *) &intersil_clock->counter;
39
40 save_and_cli(flags);
41
42 intersil_clock->cmd_reg = STOP_VAL;
43
44 *secp = todintersil->csec;
45 *hourp = todintersil->hour;
46 *minp = todintersil->minute;
47 *secp = todintersil->second;
48 *monp = todintersil->month;
49 *dayp = todintersil->day;
50 *yearp = todintersil->year+68; /* The base year for sun3 is 1968 */
51 wday = todintersil->weekday;
52
53 intersil_clock->cmd_reg = START_VAL;
54
55 restore_flags(flags);
56 }
57
58
59 /* get/set hwclock */
60
sun3_hwclk(int set,struct rtc_time * t)61 int sun3_hwclk(int set, struct rtc_time *t)
62 {
63 volatile struct intersil_dt *todintersil;
64 unsigned long flags;
65
66 todintersil = (struct intersil_dt *) &intersil_clock->counter;
67
68 save_and_cli(flags);
69
70 intersil_clock->cmd_reg = STOP_VAL;
71
72 /* set or read the clock */
73 if(set) {
74 todintersil->csec = 0;
75 todintersil->hour = t->tm_hour;
76 todintersil->minute = t->tm_min;
77 todintersil->second = t->tm_sec;
78 todintersil->month = t->tm_mon;
79 todintersil->day = t->tm_mday;
80 todintersil->year = t->tm_year - 68;
81 todintersil->weekday = t->tm_wday;
82 } else {
83 /* read clock */
84 t->tm_sec = todintersil->csec;
85 t->tm_hour = todintersil->hour;
86 t->tm_min = todintersil->minute;
87 t->tm_sec = todintersil->second;
88 t->tm_mon = todintersil->month;
89 t->tm_mday = todintersil->day;
90 t->tm_year = todintersil->year + 68;
91 t->tm_wday = todintersil->weekday;
92 }
93
94 intersil_clock->cmd_reg = START_VAL;
95
96 restore_flags(flags);
97
98 return 0;
99
100 }
101
102