Merge branch 'drm-patches' of master.kernel.org:/pub/scm/linux/kernel/git/airlied...
[linux-drm-fsl-dcu.git] / arch / mips / sgi-ip22 / ip22-time.c
index b7300cc5c5ad0769e9062495f25cc4b4c97dd560..8e88a442b22a9bb37237bb025bd22af5e24065fe 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>
@@ -76,7 +77,7 @@ static int indy_rtc_set_time(unsigned long tim)
        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);
@@ -93,7 +94,7 @@ static int indy_rtc_set_time(unsigned long tim)
 static unsigned long dosample(void)
 {
        u32 ct0, ct1;
-       volatile u8 msb, lsb;
+       u8 msb, lsb;
 
        /* Start the counter. */
        sgint->tcword = (SGINT_TCWORD_CNT2 | SGINT_TCWORD_CALL |
@@ -106,21 +107,21 @@ static unsigned long dosample(void)
 
        /* Latch and spin until top byte of counter2 is zero */
        do {
-               sgint->tcword = SGINT_TCWORD_CNT2 | SGINT_TCWORD_CLAT;
-               lsb = sgint->tcnt2;
-               msb = sgint->tcnt2;
+               writeb(SGINT_TCWORD_CNT2 | SGINT_TCWORD_CLAT, &sgint->tcword);
+               lsb = readb(&sgint->tcnt2);
+               msb = readb(&sgint->tcnt2);
                ct1 = read_c0_count();
        } while (msb);
 
        /* Stop the counter. */
-       sgint->tcword = (SGINT_TCWORD_CNT2 | SGINT_TCWORD_CALL |
-                        SGINT_TCWORD_MSWST);
+       writeb(sgint->tcword, (SGINT_TCWORD_CNT2 | SGINT_TCWORD_CALL |
+                              SGINT_TCWORD_MSWST));
        /*
         * Return the difference, this is how far the r4k counter increments
         * for every 1/HZ seconds. We round off the nearest 1 MHz of master
         * clock (= 1000000 / HZ / 2).
         */
-       /*return (ct1 - ct0 + (500000/HZ/2)) / (500000/HZ) * (500000/HZ);*/
+
        return (ct1 - ct0) / (500000/HZ) * (500000/HZ);
 }
 
@@ -174,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;
@@ -188,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;
@@ -212,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;
 }