clocksource: starfive: Update timer names
authorLey Foon Tan <leyfoon.tan@linux.starfivetech.com>
Thu, 7 Jul 2022 09:53:08 +0000 (09:53 +0000)
committerxingyu.wu <xingyu.wu@starfivetech.com>
Tue, 12 Jul 2022 03:29:43 +0000 (11:29 +0800)
The existing implementation uses DT clock-names 'timer0', 'timer1' and etc
as timer names.  This will have issue if there are two timer instance IPs
in the system.

This patch update timer names to format below, example:
timer@13050000.ch0
timer@13050000.ch1
timer@13050000.ch2
timer@13050000.ch3

Signed-off-by: Ley Foon Tan <leyfoon.tan@linux.starfivetech.com>
drivers/clocksource/timer-starfive.c
drivers/clocksource/timer-starfive.h

index b7b7e36..9802874 100755 (executable)
@@ -410,14 +410,17 @@ static int __init do_starfive_timer_of_init(struct device_node *np,
                        goto irq_err;
                }
 
-               ret = starfive_clockevents_register(clkevt, irq, np, name);
+               snprintf(clkevt->name, sizeof(clkevt->name), "%s.ch%d",
+                                       np->full_name, index);
+
+               ret = starfive_clockevents_register(clkevt, irq, np, clkevt->name);
                if (ret) {
-                       pr_err("%s: init clockevents failed.\n", name);
+                       pr_err("%s: init clockevents failed.\n", clkevt->name);
                        goto register_err;
                }
                clkevt->irq = irq;
 
-               ret = starfive_clocksource_init(clkevt, name, np);
+               ret = starfive_clocksource_init(clkevt, clkevt->name, np);
                if (ret)
                        goto init_err;
        }
index 940b7b9..a7fadfa 100755 (executable)
@@ -85,6 +85,7 @@ struct starfive_clkevt {
        struct clock_event_device evt;
        struct clk *clk;
        struct reset_control *rst;
+       char name[20];
        int irq;
        u64 periodic;
        u64 rate;