hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/riscv/kernel/time.c
....@@ -1,23 +1,18 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2012 Regents of the University of California
34 * Copyright (C) 2017 SiFive
4
- *
5
- * This program is free software; you can redistribute it and/or
6
- * modify it under the terms of the GNU General Public License
7
- * as published by the Free Software Foundation, version 2.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
135 */
146
157 #include <linux/of_clk.h>
8
+#include <linux/clockchips.h>
169 #include <linux/clocksource.h>
1710 #include <linux/delay.h>
1811 #include <asm/sbi.h>
12
+#include <asm/processor.h>
1913
2014 unsigned long riscv_timebase;
15
+EXPORT_SYMBOL_GPL(riscv_timebase);
2116
2217 void __init time_init(void)
2318 {
....@@ -27,10 +22,22 @@
2722 cpu = of_find_node_by_path("/cpus");
2823 if (!cpu || of_property_read_u32(cpu, "timebase-frequency", &prop))
2924 panic(KERN_WARNING "RISC-V system with no 'timebase-frequency' in DTS\n");
25
+ of_node_put(cpu);
3026 riscv_timebase = prop;
3127
3228 lpj_fine = riscv_timebase / HZ;
3329
3430 of_clk_init(NULL);
3531 timer_probe();
32
+
33
+ tick_setup_hrtimer_broadcast();
34
+}
35
+
36
+void clocksource_arch_init(struct clocksource *cs)
37
+{
38
+#ifdef CONFIG_GENERIC_GETTIMEOFDAY
39
+ cs->vdso_clock_mode = VDSO_CLOCKMODE_ARCHTIMER;
40
+#else
41
+ cs->vdso_clock_mode = VDSO_CLOCKMODE_NONE;
42
+#endif
3643 }