time.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (C) 2012 Regents of the University of California
  3. * 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.
  13. */
  14. #include <linux/of_clk.h>
  15. #include <linux/clocksource.h>
  16. #include <linux/delay.h>
  17. #include <asm/sbi.h>
  18. unsigned long riscv_timebase;
  19. void __init time_init(void)
  20. {
  21. struct device_node *cpu;
  22. u32 prop;
  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. riscv_timebase = prop;
  27. lpj_fine = riscv_timebase / HZ;
  28. of_clk_init(NULL);
  29. timer_probe();
  30. }