[MIPS] IP27: Add clocksource drivers
[firefly-linux-kernel-4.4.55.git] / arch / mips / sgi-ip27 / ip27-timer.c
index c20e9899b34b49fba2d95cdfa5688ea242287080..b7b3479b6bce2deca63503654f473fe2d3b33924 100644 (file)
@@ -40,7 +40,6 @@
 #define TICK_SIZE (tick_nsec / 1000)
 
 static unsigned long ct_cur[NR_CPUS];  /* What counter should be at next timer irq */
-static long last_rtc_update;           /* Last time the rtc clock got updated */
 
 #if 0
 static int set_rtc_mmss(unsigned long nowtime)
@@ -113,23 +112,6 @@ again:
 
        update_process_times(user_mode(get_irq_regs()));
 
-       /*
-        * If we have an externally synchronized Linux clock, then update
-        * RTC clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
-        * called as close as possible to when a second starts.
-        */
-       if (ntp_synced() &&
-           xtime.tv_sec > last_rtc_update + 660 &&
-           (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 &&
-           (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2) {
-               if (rtc_mips_set_time(xtime.tv_sec) == 0) {
-                       last_rtc_update = xtime.tv_sec;
-               } else {
-                       last_rtc_update = xtime.tv_sec - 600;
-                       /* do it again in 60 s */
-               }
-       }
-
        write_sequnlock(&xtime_lock);
        irq_exit();
 }
@@ -141,7 +123,7 @@ again:
 #include <asm/sn/sn0/hubio.h>
 #include <asm/pci/bridge.h>
 
-static __init unsigned long get_m48t35_time(void)
+unsigned long read_persistent_clock(void)
 {
         unsigned int year, month, date, hour, min, sec;
        struct m48t35_rtc *rtc;
@@ -181,7 +163,7 @@ static void disable_rt_irq(unsigned int irq)
 }
 
 static struct irq_chip rt_irq_type = {
-       .typename       = "SN HUB RT timer",
+       .name           = "SN HUB RT timer",
        .ack            = disable_rt_irq,
        .mask           = disable_rt_irq,
        .mask_ack       = disable_rt_irq,
@@ -190,7 +172,7 @@ static struct irq_chip rt_irq_type = {
 };
 
 static struct irqaction rt_irqaction = {
-       .handler        = ip27_rt_timer_interrupt,
+       .handler        = (irq_handler_t) ip27_rt_timer_interrupt,
        .flags          = IRQF_DISABLED,
        .mask           = CPU_MASK_NONE,
        .name           = "timer"
@@ -218,17 +200,23 @@ void __init plat_timer_setup(struct irqaction *irq)
        setup_irq(irqno, &rt_irqaction);
 }
 
-static cycle_t ip27_hpt_read(void)
+static cycle_t hub_rt_read(void)
 {
        return REMOTE_HUB_L(cputonasid(0), PI_RT_COUNT);
 }
 
-void __init ip27_time_init(void)
+struct clocksource ht_rt_clocksource = {
+       .name   = "HUB",
+       .rating = 200,
+       .read   = hub_rt_read,
+       .mask   = CLOCKSOURCE_MASK(52),
+       .shift  = 32,
+       .flags  = CLOCK_SOURCE_IS_CONTINUOUS,
+};
+
+void __init plat_time_init(void)
 {
-       clocksource_mips.read = ip27_hpt_read;
-       mips_hpt_frequency = CYCLES_PER_SEC;
-       xtime.tv_sec = get_m48t35_time();
-       xtime.tv_nsec = 0;
+       clocksource_register(&ht_rt_clocksource);
 }
 
 void __init cpu_time_init(void)