2 * linux/arch/m68k/sun3x/time.c
4 * Sun3x-specific time handling
7 #include <linux/types.h>
9 #include <linux/init.h>
10 #include <linux/sched.h>
11 #include <linux/kernel_stat.h>
12 #include <linux/interrupt.h>
13 #include <linux/rtc.h>
17 #include <asm/system.h>
18 #include <asm/traps.h>
19 #include <asm/sun3x.h>
20 #include <asm/sun3ints.h>
25 #define M_CONTROL 0xf8
39 #define BCD_TO_BIN(val) (((val)&15) + ((val)>>4)*10)
40 #define BIN_TO_BCD(val) (((val/10) << 4) | (val % 10))
43 void sun3x_gettod (int *yearp, int *monp, int *dayp,
44 int *hourp, int *minp, int *secp)
46 volatile unsigned char *eeprom = (unsigned char *)SUN3X_EEPROM;
49 *(eeprom + M_CONTROL) |= C_READ;
52 *yearp = BCD_TO_BIN(*(eeprom + M_YEAR));
53 *monp = BCD_TO_BIN(*(eeprom + M_MONTH)) +1;
54 *dayp = BCD_TO_BIN(*(eeprom + M_DATE));
55 *hourp = BCD_TO_BIN(*(eeprom + M_HOUR));
56 *minp = BCD_TO_BIN(*(eeprom + M_MIN));
57 *secp = BCD_TO_BIN(*(eeprom + M_SEC));
60 *(eeprom + M_CONTROL) &= ~C_READ;
63 int sun3x_hwclk(int set, struct rtc_time *t)
65 volatile struct mostek_dt *h =
66 (struct mostek_dt *)(SUN3X_EEPROM+M_CONTROL);
73 h->sec = BIN_TO_BCD(t->tm_sec);
74 h->min = BIN_TO_BCD(t->tm_min);
75 h->hour = BIN_TO_BCD(t->tm_hour);
76 h->wday = BIN_TO_BCD(t->tm_wday);
77 h->mday = BIN_TO_BCD(t->tm_mday);
78 h->month = BIN_TO_BCD(t->tm_mon);
79 h->year = BIN_TO_BCD(t->tm_year);
83 t->tm_sec = BCD_TO_BIN(h->sec);
84 t->tm_min = BCD_TO_BIN(h->min);
85 t->tm_hour = BCD_TO_BIN(h->hour);
86 t->tm_wday = BCD_TO_BIN(h->wday);
87 t->tm_mday = BCD_TO_BIN(h->mday);
88 t->tm_mon = BCD_TO_BIN(h->month);
89 t->tm_year = BCD_TO_BIN(h->year);
97 /* Not much we can do here */
98 unsigned long sun3x_gettimeoffset (void)
104 static void sun3x_timer_tick(int irq, void *dev_id, struct pt_regs *regs)
106 void (*vector)(int, void *, struct pt_regs *) = dev_id;
108 /* Clear the pending interrupt - pulse the enable line low */
112 vector(irq, NULL, regs);
116 void __init sun3x_sched_init(void (*vector)(int, void *, struct pt_regs *))
119 sun3_disable_interrupts();
122 /* Pulse enable low to get the clock started */
125 sun3_enable_interrupts();