rk_timer: version 1.3, make it consistent with arm twd
author黄涛 <huangtao@rock-chips.com>
Mon, 8 Jul 2013 11:48:10 +0000 (19:48 +0800)
committer黄涛 <huangtao@rock-chips.com>
Mon, 8 Jul 2013 11:48:38 +0000 (19:48 +0800)
arch/arm/plat-rk/rk_timer.c

index aad8777c866dba49a7944e2ba83b38d94bd7e95c..6032db23b89b414e44ea630cfb4a3541915696f5 100644 (file)
@@ -144,6 +144,9 @@ static __cpuinit int rk_timer_init_clockevent(struct clock_event_device *ce, uns
        struct irqaction *irq = &timer.ce_irq[cpu];
        void __iomem *base = timer.ce_base[cpu];
 
+       if (!base)
+               return 0;
+
        ce->name = timer.ce_name[cpu];
        ce->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
        ce->set_next_event = rk_timer_set_next_event;
@@ -227,7 +230,7 @@ static void __init rk_timer_init_sched_clock(void)
        init_fixed_sched_clock(&cd, rk_timer_update_sched_clock, 32, 24000000, MULT, SHIFT);
 }
 
-#ifndef CONFIG_LOCAL_TIMERS
+#if !defined(CONFIG_LOCAL_TIMERS) || defined(CONFIG_HAVE_ARM_TWD)
 static struct clock_event_device rk_timer_clockevent;
 #endif
 
@@ -247,16 +250,18 @@ static int __init rk_timer_probe(struct platform_device *pdev)
 
                snprintf(timer.ce_name[cpu], sizeof(timer.ce_name[cpu]), TIMER_NAME "%d", cpu);
 
+               snprintf(name, sizeof(name), "ce_base%d", cpu);
+               res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
+               if (!res)
+                       continue;
+               timer.ce_base[cpu] = (void *)res->start;
+
                snprintf(name, sizeof(name), "ce_clk%d", cpu);
                timer.ce_clk[cpu] = clk_get(NULL, platform_get_string_byname(pdev, name));
 
                snprintf(name, sizeof(name), "ce_pclk%d", cpu);
                timer.ce_pclk[cpu] = clk_get(NULL, platform_get_string_byname(pdev, name));
 
-               snprintf(name, sizeof(name), "ce_base%d", cpu);
-               res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name);
-               timer.ce_base[cpu] = (void *)res->start;
-
                snprintf(name, sizeof(name), "ce_irq%d", cpu);
                irq->irq = platform_get_irq_byname(pdev, name);
                irq->name = timer.ce_name[cpu];
@@ -268,13 +273,13 @@ static int __init rk_timer_probe(struct platform_device *pdev)
        }
 
        rk_timer_init_clocksource();
-#ifndef CONFIG_LOCAL_TIMERS
-       rk_timer_clockevent.rating = 200;
+#if !defined(CONFIG_LOCAL_TIMERS) || defined(CONFIG_HAVE_ARM_TWD)
+       rk_timer_clockevent.rating = 400;
        rk_timer_init_clockevent(&rk_timer_clockevent, 0);
 #endif
        rk_timer_init_sched_clock();
 
-       printk("rk_timer: version 1.2\n");
+       printk("rk_timer: version 1.3\n");
        return 0;
 }
 
@@ -287,7 +292,7 @@ static struct platform_driver rk_timer_driver __initdata = {
 
 early_platform_init(TIMER_NAME, &rk_timer_driver);
 
-#ifdef CONFIG_LOCAL_TIMERS
+#if defined(CONFIG_LOCAL_TIMERS) && !defined(CONFIG_HAVE_ARM_TWD)
 /*
  * Setup the local clock events for a CPU.
  */