1 /* 2 * Copyright (c) 2018-2020, Arm Limited and Contributors. All rights reserved. 3 * Copyright (c) 2022-2023, Advanced Micro Devices, Inc. All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 #include <common/debug.h> 9 #include <drivers/generic_delay_timer.h> 10 #include <lib/mmio.h> 11 #include <lib/xlat_tables/xlat_tables_v2.h> 12 #include <plat/common/platform.h> 13 14 #include <plat_common.h> 15 #include <plat_ipi.h> 16 #include <plat_private.h> 17 #include <pm_api_sys.h> 18 #include <versal_def.h> 19 20 uint32_t platform_id, platform_version; 21 uint32_t cpu_clock = VERSAL_CPU_CLOCK; 22 23 /* 24 * Table of regions to map using the MMU. 25 * This doesn't include TZRAM as the 'mem_layout' argument passed to 26 * configure_mmu_elx() will give the available subset of that, 27 */ 28 const mmap_region_t plat_versal_mmap[] = { 29 MAP_REGION_FLAT(DEVICE0_BASE, DEVICE0_SIZE, MT_DEVICE | MT_RW | MT_SECURE), 30 MAP_REGION_FLAT(DEVICE1_BASE, DEVICE1_SIZE, MT_DEVICE | MT_RW | MT_SECURE), 31 MAP_REGION_FLAT(CRF_BASE, CRF_SIZE, MT_DEVICE | MT_RW | MT_SECURE), 32 MAP_REGION_FLAT(PLAT_ARM_CCI_BASE, PLAT_ARM_CCI_SIZE, MT_DEVICE | MT_RW | 33 MT_SECURE), 34 { 0 } 35 }; 36 37 const mmap_region_t *plat_get_mmap(void) 38 { 39 return plat_versal_mmap; 40 } 41 42 static void versal_print_platform_name(void) 43 { 44 NOTICE("TF-A running on %s\n", PLATFORM_NAME); 45 } 46 47 void versal_config_setup(void) 48 { 49 /* Configure IPI data for versal */ 50 versal_ipi_config_table_init(); 51 52 versal_print_platform_name(); 53 54 generic_delay_timer_init(); 55 } 56 57 uint32_t plat_get_syscnt_freq2(void) 58 { 59 uint32_t counter_freq = 0; 60 uint32_t ret = 0; 61 62 counter_freq = mmio_read_32(IOU_SCNTRS_BASE 63 + IOU_SCNTRS_BASE_FREQ_OFFSET); 64 65 if (counter_freq != 0U) { 66 ret = counter_freq; 67 } else { 68 INFO("Indicates counter frequency %dHz setting to %dHz\n", 69 counter_freq, cpu_clock); 70 ret = cpu_clock; 71 } 72 73 return ret; 74 } 75 76 void board_detection(void) 77 { 78 uint32_t plat_info[2]; 79 80 if (pm_get_chipid(plat_info) != PM_RET_SUCCESS) { 81 /* If the call is failed we cannot proceed with further 82 * setup. TF-A to panic in this situation. 83 */ 84 NOTICE("Failed to read the chip information"); 85 panic(); 86 } 87 88 platform_id = FIELD_GET(PLATFORM_MASK, plat_info[1]); 89 platform_version = FIELD_GET(PLATFORM_VERSION_MASK, plat_info[1]); 90 } 91 92 uint32_t get_uart_clk(void) 93 { 94 return UART_CLOCK; 95 } 96