time.c 896 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Xilfpga clocksource/timer setup
  3. *
  4. * Copyright (C) 2015 Imagination Technologies
  5. * Author: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms and conditions of the GNU General Public License,
  9. * version 2, as published by the Free Software Foundation.
  10. */
  11. #include <linux/clk.h>
  12. #include <linux/clk-provider.h>
  13. #include <linux/clocksource.h>
  14. #include <linux/of.h>
  15. #include <asm/time.h>
  16. void __init plat_time_init(void)
  17. {
  18. struct device_node *np;
  19. struct clk *clk;
  20. of_clk_init(NULL);
  21. clocksource_probe();
  22. np = of_get_cpu_node(0, NULL);
  23. if (!np) {
  24. pr_err("Failed to get CPU node\n");
  25. return;
  26. }
  27. clk = of_clk_get(np, 0);
  28. if (IS_ERR(clk)) {
  29. pr_err("Failed to get CPU clock: %ld\n", PTR_ERR(clk));
  30. return;
  31. }
  32. mips_hpt_frequency = clk_get_rate(clk) / 2;
  33. clk_put(clk);
  34. }