Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / arch / m68k / sun3 / intersil.c
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/errno.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? */
26 u32 sun3_gettimeoffset(void)
27 {
28   return 1000;
29 }
30
31
32 /* get/set hwclock */
33
34 int sun3_hwclk(int set, struct rtc_time *t)
35 {
36         volatile struct intersil_dt *todintersil;
37         unsigned long flags;
38
39         todintersil = (struct intersil_dt *) &intersil_clock->counter;
40
41         local_irq_save(flags);
42
43         intersil_clock->cmd_reg = STOP_VAL;
44
45         /* set or read the clock */
46         if(set) {
47                 todintersil->csec = 0;
48                 todintersil->hour = t->tm_hour;
49                 todintersil->minute = t->tm_min;
50                 todintersil->second = t->tm_sec;
51                 todintersil->month = t->tm_mon;
52                 todintersil->day = t->tm_mday;
53                 todintersil->year = t->tm_year - 68;
54                 todintersil->weekday = t->tm_wday;
55         } else {
56                 /* read clock */
57                 t->tm_sec = todintersil->csec;
58                 t->tm_hour = todintersil->hour;
59                 t->tm_min = todintersil->minute;
60                 t->tm_sec = todintersil->second;
61                 t->tm_mon = todintersil->month;
62                 t->tm_mday = todintersil->day;
63                 t->tm_year = todintersil->year + 68;
64                 t->tm_wday = todintersil->weekday;
65         }
66
67         intersil_clock->cmd_reg = START_VAL;
68
69         local_irq_restore(flags);
70
71         return 0;
72
73 }
74