plat_clkfunc.c 853 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2023-2024, Advanced Micro Devices, Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <common/debug.h>
  7. #include <lib/mmio.h>
  8. #include <plat/common/platform.h>
  9. #include <platform_def.h>
  10. #include <plat_clkfunc.h>
  11. #include <plat_private.h>
  12. uint32_t plat_get_syscnt_freq2(void)
  13. {
  14. uint32_t counter_freq = 0;
  15. uint32_t ret = 0;
  16. counter_freq = mmio_read_32(IOU_SCNTRS_BASE +
  17. IOU_SCNTRS_BASE_FREQ_OFFSET);
  18. if (counter_freq != 0U) {
  19. ret = counter_freq;
  20. } else {
  21. INFO("Indicates counter frequency %dHz setting to %dHz\n",
  22. counter_freq, cpu_clock);
  23. ret = cpu_clock;
  24. }
  25. return ret;
  26. }
  27. void set_cnt_freq(void)
  28. {
  29. uint64_t counter_freq;
  30. /* Configure counter frequency */
  31. counter_freq = read_cntfrq_el0();
  32. if (counter_freq == 0U) {
  33. write_cntfrq_el0(plat_get_syscnt_freq2());
  34. }
  35. }