blob: 6a53c02e9c734c6db04e6236580ace56f0d27b19 [file] [log] [blame]
David Brazdil0f672f62019-12-10 10:32:29 +00001// SPDX-License-Identifier: GPL-2.0-only
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00002/*
3 * Copyright (C) 2012 Regents of the University of California
4 * Copyright (C) 2017 SiFive
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00005 */
6
7#include <linux/clocksource.h>
8#include <linux/delay.h>
9#include <asm/sbi.h>
David Brazdil0f672f62019-12-10 10:32:29 +000010#include <asm/processor.h>
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000011
12unsigned long riscv_timebase;
David Brazdil0f672f62019-12-10 10:32:29 +000013EXPORT_SYMBOL_GPL(riscv_timebase);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000014
15void __init time_init(void)
16{
17 struct device_node *cpu;
18 u32 prop;
19
20 cpu = of_find_node_by_path("/cpus");
21 if (!cpu || of_property_read_u32(cpu, "timebase-frequency", &prop))
22 panic(KERN_WARNING "RISC-V system with no 'timebase-frequency' in DTS\n");
David Brazdil0f672f62019-12-10 10:32:29 +000023 of_node_put(cpu);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000024 riscv_timebase = prop;
25
26 lpj_fine = riscv_timebase / HZ;
27 timer_probe();
28}