time.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Joshua Henderson <[email protected]>
  4. * Copyright (C) 2015 Microchip Technology Inc. All rights reserved.
  5. */
  6. #include <linux/clocksource.h>
  7. #include <linux/init.h>
  8. #include <linux/irqdomain.h>
  9. #include <linux/of.h>
  10. #include <linux/of_clk.h>
  11. #include <linux/of_irq.h>
  12. #include <asm/time.h>
  13. #include "pic32mzda.h"
  14. static const struct of_device_id pic32_infra_match[] = {
  15. { .compatible = "microchip,pic32mzda-infra", },
  16. { },
  17. };
  18. #define DEFAULT_CORE_TIMER_INTERRUPT 0
  19. static unsigned int pic32_xlate_core_timer_irq(void)
  20. {
  21. struct device_node *node;
  22. unsigned int irq;
  23. node = of_find_matching_node(NULL, pic32_infra_match);
  24. if (WARN_ON(!node))
  25. goto default_map;
  26. irq = irq_of_parse_and_map(node, 0);
  27. of_node_put(node);
  28. if (!irq)
  29. goto default_map;
  30. return irq;
  31. default_map:
  32. return irq_create_mapping(NULL, DEFAULT_CORE_TIMER_INTERRUPT);
  33. }
  34. unsigned int get_c0_compare_int(void)
  35. {
  36. return pic32_xlate_core_timer_irq();
  37. }
  38. void __init plat_time_init(void)
  39. {
  40. unsigned long rate = pic32_get_pbclk(7);
  41. of_clk_init(NULL);
  42. pr_info("CPU Clock: %ldMHz\n", rate / 1000000);
  43. mips_hpt_frequency = rate / 2;
  44. timer_probe();
  45. }