blob: 8a8ea7e8e7c0ed5fe2a48ee65e50c4e7fd1be25b [file] [log] [blame]
Prasad Kummari2038bd62023-12-14 10:52:24 +05301/*
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>
Prasad Kummariaf636182023-12-20 11:01:24 +05307#include <lib/mmio.h>
Prasad Kummari2038bd62023-12-14 10:52:24 +05308#include <plat/common/platform.h>
9
10#include <platform_def.h>
11#include <plat_private.h>
12
Prasad Kummariaf636182023-12-20 11:01:24 +053013uint32_t plat_get_syscnt_freq2(void)
14{
15 uint32_t counter_freq = 0;
16 uint32_t ret = 0;
17
18 counter_freq = mmio_read_32(IOU_SCNTRS_BASE +
19 IOU_SCNTRS_BASE_FREQ_OFFSET);
20 if (counter_freq != 0U) {
21 ret = counter_freq;
22 } else {
23 INFO("Indicates counter frequency %dHz setting to %dHz\n",
24 counter_freq, cpu_clock);
25 ret = cpu_clock;
26 }
27
28 return ret;
29}
30
Prasad Kummari2038bd62023-12-14 10:52:24 +053031void set_cnt_freq(void)
32{
33 uint64_t counter_freq;
34
35 /* Configure counter frequency */
36 counter_freq = read_cntfrq_el0();
37 if (counter_freq == 0U) {
38 write_cntfrq_el0(plat_get_syscnt_freq2());
39 }
40}