ARC: timer: gfrc, rtc: Read BCR to detect whether hardware exists ...
authorVineet Gupta <vgupta@synopsys.com>
Mon, 31 Oct 2016 20:02:31 +0000 (13:02 -0700)
committerVineet Gupta <vgupta@synopsys.com>
Wed, 30 Nov 2016 19:54:25 +0000 (11:54 -0800)
... don't rely on cpuinfo populated in arc boot code. This paves way for
moving this code in drivers/clocksource/

And while at it, convert the WARN() to pr_warn() as sugested by Daniel

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
arch/arc/kernel/time.c

index 8d66bb4..d3f3750 100644 (file)
@@ -111,11 +111,14 @@ static struct clocksource arc_counter_gfrc = {
 
 static int __init arc_cs_setup_gfrc(struct device_node *node)
 {
 
 static int __init arc_cs_setup_gfrc(struct device_node *node)
 {
-       int exists = cpuinfo_arc700[0].extn.gfrc;
+       struct mcip_bcr mp;
        int ret;
 
        int ret;
 
-       if (WARN(!exists, "Global-64-bit-Ctr clocksource not detected"))
+       READ_BCR(ARC_REG_MCIP_BCR, mp);
+       if (!mp.gfrc) {
+               pr_warn("Global-64-bit-Ctr clocksource not detected");
                return -ENXIO;
                return -ENXIO;
+       }
 
        ret = arc_get_timer_clk(node);
        if (ret)
 
        ret = arc_get_timer_clk(node);
        if (ret)
@@ -163,15 +166,20 @@ static struct clocksource arc_counter_rtc = {
 
 static int __init arc_cs_setup_rtc(struct device_node *node)
 {
 
 static int __init arc_cs_setup_rtc(struct device_node *node)
 {
-       int exists = cpuinfo_arc700[smp_processor_id()].extn.rtc;
+       struct bcr_timer timer;
        int ret;
 
        int ret;
 
-       if (WARN(!exists, "Local-64-bit-Ctr clocksource not detected"))
+       READ_BCR(ARC_REG_TIMERS_BCR, timer);
+       if (!timer.rtc) {
+               pr_warn("Local-64-bit-Ctr clocksource not detected");
                return -ENXIO;
                return -ENXIO;
+       }
 
        /* Local to CPU hence not usable in SMP */
 
        /* Local to CPU hence not usable in SMP */
-       if (WARN(IS_ENABLED(CONFIG_SMP), "Local-64-bit-Ctr not usable in SMP"))
+       if (IS_ENABLED(CONFIG_SMP)) {
+               pr_warn("Local-64-bit-Ctr not usable in SMP");
                return -EINVAL;
                return -EINVAL;
+       }
 
        ret = arc_get_timer_clk(node);
        if (ret)
 
        ret = arc_get_timer_clk(node);
        if (ret)