fdt_timer_plmt.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * SPDX-License-Identifier: BSD-2-Clause
  3. *
  4. * Copyright (c) 2022 Andes Technology Corporation
  5. *
  6. * Authors:
  7. * Yu Chien Peter Lin <peterlin@andestech.com>
  8. */
  9. #include <sbi_utils/fdt/fdt_helper.h>
  10. #include <sbi_utils/timer/fdt_timer.h>
  11. #include <sbi_utils/timer/andes_plmt.h>
  12. extern struct plmt_data plmt;
  13. static int fdt_plmt_cold_timer_init(void *fdt, int nodeoff,
  14. const struct fdt_match *match)
  15. {
  16. int rc;
  17. unsigned long plmt_base;
  18. rc = fdt_parse_plmt_node(fdt, nodeoff, &plmt_base, &plmt.size,
  19. &plmt.hart_count);
  20. if (rc)
  21. return rc;
  22. plmt.time_val = (u64 *)plmt_base;
  23. plmt.time_cmp = (u64 *)(plmt_base + 0x8);
  24. rc = fdt_parse_timebase_frequency(fdt, &plmt.timer_freq);
  25. if (rc)
  26. return rc;
  27. rc = plmt_cold_timer_init(&plmt);
  28. if (rc)
  29. return rc;
  30. return 0;
  31. }
  32. static const struct fdt_match timer_plmt_match[] = {
  33. { .compatible = "andestech,plmt0" },
  34. {},
  35. };
  36. struct fdt_timer fdt_timer_plmt = {
  37. .match_table = timer_plmt_match,
  38. .cold_init = fdt_plmt_cold_timer_init,
  39. .warm_init = plmt_warm_timer_init,
  40. .exit = NULL,
  41. };