fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / arch / mips / sgi-ip22 / ip22-time.c
index 173f768..2055547 100644 (file)
@@ -7,11 +7,12 @@
  * Ralf Baechle or David S. Miller (sorry guys, i'm really not sure)
  *
  * Copyright (C) 2001 by Ladislav Michl
- * Copyright (C) 2003 Ralf Baechle (ralf@linux-mips.org)
+ * Copyright (C) 2003, 06 Ralf Baechle (ralf@linux-mips.org)
  */
 #include <linux/bcd.h>
 #include <linux/ds1286.h>
 #include <linux/init.h>
+#include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/interrupt.h>
 #include <linux/kernel_stat.h>
@@ -35,7 +36,9 @@ static unsigned long indy_rtc_get_time(void)
 {
        unsigned int yrs, mon, day, hrs, min, sec;
        unsigned int save_control;
+       unsigned long flags;
 
+       spin_lock_irqsave(&rtc_lock, flags);
        save_control = hpc3c0->rtcregs[RTC_CMD] & 0xff;
        hpc3c0->rtcregs[RTC_CMD] = save_control | RTC_TE;
 
@@ -47,6 +50,7 @@ static unsigned long indy_rtc_get_time(void)
        yrs = BCD2BIN(hpc3c0->rtcregs[RTC_YEAR] & 0xff);
 
        hpc3c0->rtcregs[RTC_CMD] = save_control;
+       spin_unlock_irqrestore(&rtc_lock, flags);
 
        if (yrs < 45)
                yrs += 30;
@@ -60,6 +64,7 @@ static int indy_rtc_set_time(unsigned long tim)
 {
        struct rtc_time tm;
        unsigned int save_control;
+       unsigned long flags;
 
        to_tm(tim, &tm);
 
@@ -68,10 +73,11 @@ static int indy_rtc_set_time(unsigned long tim)
        if (tm.tm_year >= 100)
                tm.tm_year -= 100;
 
+       spin_lock_irqsave(&rtc_lock, flags);
        save_control = hpc3c0->rtcregs[RTC_CMD] & 0xff;
        hpc3c0->rtcregs[RTC_CMD] = save_control | RTC_TE;
 
-       hpc3c0->rtcregs[RTC_YEAR] = BIN2BCD(tm.tm_sec);
+       hpc3c0->rtcregs[RTC_YEAR] = BIN2BCD(tm.tm_year);
        hpc3c0->rtcregs[RTC_MONTH] = BIN2BCD(tm.tm_mon);
        hpc3c0->rtcregs[RTC_DATE] = BIN2BCD(tm.tm_mday);
        hpc3c0->rtcregs[RTC_HOURS] = BIN2BCD(tm.tm_hour);
@@ -80,6 +86,7 @@ static int indy_rtc_set_time(unsigned long tim)
        hpc3c0->rtcregs[RTC_HUNDREDTH_SECOND] = 0;
 
        hpc3c0->rtcregs[RTC_CMD] = save_control;
+       spin_unlock_irqrestore(&rtc_lock, flags);
 
        return 0;
 }
@@ -126,7 +133,7 @@ static __init void indy_time_init(void)
        unsigned long r4k_ticks[3];
        unsigned long r4k_tick;
 
-       /* 
+       /*
         * Figure out the r4k offset, the algorithm is very simple and works in
         * _all_ cases as long as the 8254 counter register itself works ok (as
         * an interrupt driving timer it does not because of bug, this is why
@@ -168,7 +175,7 @@ static __init void indy_time_init(void)
 }
 
 /* Generic SGI handler for (spurious) 8254 interrupts */
-void indy_8254timer_irq(struct pt_regs *regs)
+void indy_8254timer_irq(void)
 {
        int irq = SGI_8254_0_IRQ;
        ULONG cnt;
@@ -182,19 +189,17 @@ void indy_8254timer_irq(struct pt_regs *regs)
        irq_exit();
 }
 
-void indy_r4k_timer_interrupt(struct pt_regs *regs)
+void indy_r4k_timer_interrupt(void)
 {
        int irq = SGI_TIMER_IRQ;
 
        irq_enter();
        kstat_this_cpu.irqs[irq]++;
-       timer_interrupt(irq, NULL, regs);
+       timer_interrupt(irq, NULL);
        irq_exit();
 }
 
-extern int setup_irq(unsigned int irq, struct irqaction *irqaction);
-
-static void indy_timer_setup(struct irqaction *irq)
+void __init plat_timer_setup(struct irqaction *irq)
 {
        /* over-write the handler, we use our own way */
        irq->handler = no_action;
@@ -206,9 +211,8 @@ static void indy_timer_setup(struct irqaction *irq)
 void __init ip22_time_init(void)
 {
        /* setup hookup functions */
-       rtc_get_time = indy_rtc_get_time;
-       rtc_set_time = indy_rtc_set_time;
+       rtc_mips_get_time = indy_rtc_get_time;
+       rtc_mips_set_time = indy_rtc_set_time;
 
        board_time_init = indy_time_init;
-       board_timer_setup = indy_timer_setup;
 }