Loading...
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/intersil.h>
18#include <asm/machdep.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/* get/set hwclock */
26
27int sun3_hwclk(int set, struct rtc_time *t)
28{
29 volatile struct intersil_dt *todintersil;
30 unsigned long flags;
31
32 todintersil = (struct intersil_dt *) &intersil_clock->counter;
33
34 local_irq_save(flags);
35
36 intersil_clock->cmd_reg = STOP_VAL;
37
38 /* set or read the clock */
39 if(set) {
40 todintersil->csec = 0;
41 todintersil->hour = t->tm_hour;
42 todintersil->minute = t->tm_min;
43 todintersil->second = t->tm_sec;
44 todintersil->month = t->tm_mon + 1;
45 todintersil->day = t->tm_mday;
46 todintersil->year = (t->tm_year - 68) % 100;
47 todintersil->weekday = t->tm_wday;
48 } else {
49 /* read clock */
50 t->tm_sec = todintersil->csec;
51 t->tm_hour = todintersil->hour;
52 t->tm_min = todintersil->minute;
53 t->tm_sec = todintersil->second;
54 t->tm_mon = todintersil->month - 1;
55 t->tm_mday = todintersil->day;
56 t->tm_year = todintersil->year + 68;
57 t->tm_wday = todintersil->weekday;
58 if (t->tm_year < 70)
59 t->tm_year += 100;
60 }
61
62 intersil_clock->cmd_reg = START_VAL;
63
64 local_irq_restore(flags);
65
66 return 0;
67
68}
69
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/system.h>
18#include <asm/rtc.h>
19#include <asm/intersil.h>
20
21
22/* bits to set for start/run of the intersil */
23#define STOP_VAL (INTERSIL_STOP | INTERSIL_INT_ENABLE | INTERSIL_24H_MODE)
24#define START_VAL (INTERSIL_RUN | INTERSIL_INT_ENABLE | INTERSIL_24H_MODE)
25
26/* does this need to be implemented? */
27unsigned long sun3_gettimeoffset(void)
28{
29 return 1;
30}
31
32
33/* get/set hwclock */
34
35int sun3_hwclk(int set, struct rtc_time *t)
36{
37 volatile struct intersil_dt *todintersil;
38 unsigned long flags;
39
40 todintersil = (struct intersil_dt *) &intersil_clock->counter;
41
42 local_irq_save(flags);
43
44 intersil_clock->cmd_reg = STOP_VAL;
45
46 /* set or read the clock */
47 if(set) {
48 todintersil->csec = 0;
49 todintersil->hour = t->tm_hour;
50 todintersil->minute = t->tm_min;
51 todintersil->second = t->tm_sec;
52 todintersil->month = t->tm_mon;
53 todintersil->day = t->tm_mday;
54 todintersil->year = t->tm_year - 68;
55 todintersil->weekday = t->tm_wday;
56 } else {
57 /* read clock */
58 t->tm_sec = todintersil->csec;
59 t->tm_hour = todintersil->hour;
60 t->tm_min = todintersil->minute;
61 t->tm_sec = todintersil->second;
62 t->tm_mon = todintersil->month;
63 t->tm_mday = todintersil->day;
64 t->tm_year = todintersil->year + 68;
65 t->tm_wday = todintersil->weekday;
66 }
67
68 intersil_clock->cmd_reg = START_VAL;
69
70 local_irq_restore(flags);
71
72 return 0;
73
74}
75