Skip to content

Commit 714aa1d

Browse files
vlsunilpalmer-dabbelt
authored andcommitted
RISC-V: time.c: Add ACPI support for time_init()
On ACPI based platforms, timer related information is available in RHCT. Add ACPI based probe support to the timer initialization. Signed-off-by: Sunil V L <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 21f4f92 commit 714aa1d

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

arch/riscv/kernel/time.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Copyright (C) 2017 SiFive
55
*/
66

7+
#include <linux/acpi.h>
78
#include <linux/of_clk.h>
89
#include <linux/clockchips.h>
910
#include <linux/clocksource.h>
@@ -18,17 +19,29 @@ EXPORT_SYMBOL_GPL(riscv_timebase);
1819
void __init time_init(void)
1920
{
2021
struct device_node *cpu;
22+
struct acpi_table_rhct *rhct;
23+
acpi_status status;
2124
u32 prop;
2225

23-
cpu = of_find_node_by_path("/cpus");
24-
if (!cpu || of_property_read_u32(cpu, "timebase-frequency", &prop))
25-
panic(KERN_WARNING "RISC-V system with no 'timebase-frequency' in DTS\n");
26-
of_node_put(cpu);
27-
riscv_timebase = prop;
26+
if (acpi_disabled) {
27+
cpu = of_find_node_by_path("/cpus");
28+
if (!cpu || of_property_read_u32(cpu, "timebase-frequency", &prop))
29+
panic("RISC-V system with no 'timebase-frequency' in DTS\n");
30+
31+
of_node_put(cpu);
32+
riscv_timebase = prop;
33+
of_clk_init(NULL);
34+
} else {
35+
status = acpi_get_table(ACPI_SIG_RHCT, 0, (struct acpi_table_header **)&rhct);
36+
if (ACPI_FAILURE(status))
37+
panic("RISC-V ACPI system with no RHCT table\n");
38+
39+
riscv_timebase = rhct->time_base_freq;
40+
acpi_put_table((struct acpi_table_header *)rhct);
41+
}
2842

2943
lpj_fine = riscv_timebase / HZ;
3044

31-
of_clk_init(NULL);
3245
timer_probe();
3346

3447
tick_setup_hrtimer_broadcast();

0 commit comments

Comments
 (0)