Prasad Kummari | 2038bd6 | 2023-12-14 10:52:24 +0530 | [diff] [blame] | 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> |
Prasad Kummari | af63618 | 2023-12-20 11:01:24 +0530 | [diff] [blame] | 7 | #include <lib/mmio.h> |
Prasad Kummari | 2038bd6 | 2023-12-14 10:52:24 +0530 | [diff] [blame] | 8 | #include <plat/common/platform.h> |
| 9 | |
| 10 | #include <platform_def.h> |
| 11 | #include <plat_private.h> |
| 12 | |
Prasad Kummari | af63618 | 2023-12-20 11:01:24 +0530 | [diff] [blame] | 13 | uint32_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 Kummari | 2038bd6 | 2023-12-14 10:52:24 +0530 | [diff] [blame] | 31 | void 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 | } |