blob: 431d3c4306dd8da594f485dbb297830dc7f0293d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/m68k/sun3x/time.c
3 *
4 * Sun3x-specific time handling
5 */
6
7#include <linux/types.h>
8#include <linux/kd.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>
14#include <linux/bcd.h>
15
16#include <asm/irq.h>
17#include <asm/io.h>
Arnd Bergmann084b3602016-05-30 20:57:59 +020018#include <asm/machdep.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <asm/traps.h>
20#include <asm/sun3x.h>
21#include <asm/sun3ints.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
23#include "time.h"
24
25#define M_CONTROL 0xf8
26#define M_SEC 0xf9
27#define M_MIN 0xfa
28#define M_HOUR 0xfb
29#define M_DAY 0xfc
30#define M_DATE 0xfd
31#define M_MONTH 0xfe
32#define M_YEAR 0xff
33
34#define C_WRITE 0x80
35#define C_READ 0x40
36#define C_SIGN 0x20
37#define C_CALIB 0x1f
38
39int sun3x_hwclk(int set, struct rtc_time *t)
40{
41 volatile struct mostek_dt *h =
42 (struct mostek_dt *)(SUN3X_EEPROM+M_CONTROL);
43 unsigned long flags;
44
45 local_irq_save(flags);
46
47 if(set) {
48 h->csr |= C_WRITE;
Adrian Bunk5b1d5f92008-10-13 21:58:47 +020049 h->sec = bin2bcd(t->tm_sec);
50 h->min = bin2bcd(t->tm_min);
51 h->hour = bin2bcd(t->tm_hour);
52 h->wday = bin2bcd(t->tm_wday);
53 h->mday = bin2bcd(t->tm_mday);
54 h->month = bin2bcd(t->tm_mon);
55 h->year = bin2bcd(t->tm_year);
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 h->csr &= ~C_WRITE;
57 } else {
58 h->csr |= C_READ;
Adrian Bunk5b1d5f92008-10-13 21:58:47 +020059 t->tm_sec = bcd2bin(h->sec);
60 t->tm_min = bcd2bin(h->min);
61 t->tm_hour = bcd2bin(h->hour);
62 t->tm_wday = bcd2bin(h->wday);
63 t->tm_mday = bcd2bin(h->mday);
64 t->tm_mon = bcd2bin(h->month);
65 t->tm_year = bcd2bin(h->year);
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 h->csr &= ~C_READ;
67 }
68
69 local_irq_restore(flags);
70
71 return 0;
72}
73/* Not much we can do here */
Stephen Warrenc8d5ba12012-11-08 11:34:55 -070074u32 sun3x_gettimeoffset(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075{
76 return 0L;
77}
78
79#if 0
80static void sun3x_timer_tick(int irq, void *dev_id, struct pt_regs *regs)
81{
82 void (*vector)(int, void *, struct pt_regs *) = dev_id;
83
84 /* Clear the pending interrupt - pulse the enable line low */
85 disable_irq(5);
86 enable_irq(5);
87
88 vector(irq, NULL, regs);
89}
90#endif
91
David Howells40220c12006-10-09 12:19:47 +010092void __init sun3x_sched_init(irq_handler_t vector)
Linus Torvalds1da177e2005-04-16 15:20:36 -070093{
94
95 sun3_disable_interrupts();
96
97
98 /* Pulse enable low to get the clock started */
99 sun3_disable_irq(5);
100 sun3_enable_irq(5);
101 sun3_enable_interrupts();
102}