time.c 929 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology
  4. * Author: Fuxin Zhang, [email protected]
  5. *
  6. * Copyright (C) 2009 Lemote Inc.
  7. * Author: Wu Zhangjin, [email protected]
  8. */
  9. #include <asm/time.h>
  10. #include <asm/hpet.h>
  11. #include <loongson.h>
  12. #include <linux/clk.h>
  13. #include <linux/of_clk.h>
  14. void __init plat_time_init(void)
  15. {
  16. struct clk *clk;
  17. struct device_node *np;
  18. if (loongson_sysconf.fw_interface == LOONGSON_DTB) {
  19. of_clk_init(NULL);
  20. np = of_get_cpu_node(0, NULL);
  21. if (!np) {
  22. pr_err("Failed to get CPU node\n");
  23. return;
  24. }
  25. clk = of_clk_get(np, 0);
  26. if (IS_ERR(clk)) {
  27. pr_err("Failed to get CPU clock: %ld\n", PTR_ERR(clk));
  28. return;
  29. }
  30. cpu_clock_freq = clk_get_rate(clk);
  31. clk_put(clk);
  32. }
  33. /* setup mips r4k timer */
  34. mips_hpt_frequency = cpu_clock_freq / 2;
  35. #ifdef CONFIG_RS780_HPET
  36. setup_hpet_timer();
  37. #endif
  38. }