hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/riscv/kernel/time.c
....@@ -1,23 +1,17 @@
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>
168 #include <linux/clocksource.h>
179 #include <linux/delay.h>
1810 #include <asm/sbi.h>
11
+#include <asm/processor.h>
1912
2013 unsigned long riscv_timebase;
14
+EXPORT_SYMBOL_GPL(riscv_timebase);
2115
2216 void __init time_init(void)
2317 {
....@@ -27,6 +21,7 @@
2721 cpu = of_find_node_by_path("/cpus");
2822 if (!cpu || of_property_read_u32(cpu, "timebase-frequency", &prop))
2923 panic(KERN_WARNING "RISC-V system with no 'timebase-frequency' in DTS\n");
24
+ of_node_put(cpu);
3025 riscv_timebase = prop;
3126
3227 lpj_fine = riscv_timebase / HZ;
....@@ -34,3 +29,12 @@
3429 of_clk_init(NULL);
3530 timer_probe();
3631 }
32
+
33
+void clocksource_arch_init(struct clocksource *cs)
34
+{
35
+#ifdef CONFIG_GENERIC_GETTIMEOFDAY
36
+ cs->vdso_clock_mode = VDSO_CLOCKMODE_ARCHTIMER;
37
+#else
38
+ cs->vdso_clock_mode = VDSO_CLOCKMODE_NONE;
39
+#endif
40
+}