* added 0.99 linux version
[mascara-docs.git] / i386 / linux / linux-2.3.21 / arch / m68k / sun3x / time.c
blobc6aa51b8a91d8f8e94b3665e4a34d714d3359ec1
1 /*
2 * linux/arch/m68k/sun3x/time.c
4 * Sun3x-specific time handling
5 */
7 #include <linux/types.h>
8 #include <linux/init.h>
9 #include <linux/sched.h>
10 #include <linux/kernel_stat.h>
11 #include <linux/interrupt.h>
13 #include <asm/irq.h>
14 #include <asm/io.h>
15 #include <asm/system.h>
16 #include <asm/traps.h>
17 #include <asm/sun3x.h>
19 #include "time.h"
21 #define M_CONTROL 0xf8
22 #define M_SEC 0xf9
23 #define M_MIN 0xfa
24 #define M_HOUR 0xfb
25 #define M_DAY 0xfc
26 #define M_DATE 0xfd
27 #define M_MONTH 0xfe
28 #define M_YEAR 0xff
30 #define C_WRITE 0x80
31 #define C_READ 0x40
32 #define C_SIGN 0x20
33 #define C_CALIB 0x1f
35 #define BCD_TO_BIN(val) (((val)&15) + ((val)>>4)*10)
37 /* Read the Mostek */
38 void sun3x_gettod (int *yearp, int *monp, int *dayp,
39 int *hourp, int *minp, int *secp)
41 volatile unsigned char *eeprom = (unsigned char *)SUN3X_EEPROM;
43 /* Stop updates */
44 *(eeprom + M_CONTROL) |= C_READ;
46 /* Read values */
47 *yearp = BCD_TO_BIN(*(eeprom + M_YEAR));
48 *monp = BCD_TO_BIN(*(eeprom + M_MONTH));
49 *dayp = BCD_TO_BIN(*(eeprom + M_DATE));
50 *hourp = BCD_TO_BIN(*(eeprom + M_HOUR));
51 *minp = BCD_TO_BIN(*(eeprom + M_MIN));
52 *secp = BCD_TO_BIN(*(eeprom + M_SEC));
54 /* Restart updates */
55 *(eeprom + M_CONTROL) &= ~C_READ;
58 /* Not much we can do here */
59 unsigned long sun3x_gettimeoffset (void)
61 return 0L;
64 static void sun3x_timer_tick(int irq, void *dev_id, struct pt_regs *regs)
66 void (*vector)(int, void *, struct pt_regs *) = dev_id;
68 /* Clear the pending interrupt - pulse the enable line low */
69 disable_irq(5);
70 enable_irq(5);
72 vector(irq, NULL, regs);
75 void __init sun3x_sched_init(void (*vector)(int, void *, struct pt_regs *))
77 sys_request_irq(5, sun3x_timer_tick, IRQ_FLG_STD, "timer tick", vector);
79 /* Pulse enable low to get the clock started */
80 disable_irq(5);
81 enable_irq(5);