1 /*
2 * Copyright (c) 2018-2020, Arm Limited and Contributors. All rights reserved.
3 * Copyright (c) 2022-2024, Advanced Micro Devices, Inc. All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8 #include <common/debug.h>
9 #include <lib/mmio.h>
10 #include <lib/xlat_tables/xlat_tables_v2.h>
11 #include <plat/common/platform.h>
12
13 #include <plat_common.h>
14 #include <plat_ipi.h>
15 #include <plat_private.h>
16 #include <pm_api_sys.h>
17 #include <versal_def.h>
18
19 uint32_t platform_id, platform_version;
20 uint32_t cpu_clock;
21
22 /*
23 * Table of regions to map using the MMU.
24 * This doesn't include TZRAM as the 'mem_layout' argument passed to
25 * configure_mmu_elx() will give the available subset of that,
26 */
27 const mmap_region_t plat_versal_mmap[] = {
28 MAP_REGION_FLAT(DEVICE0_BASE, DEVICE0_SIZE, MT_DEVICE | MT_RW | MT_SECURE),
29 MAP_REGION_FLAT(DEVICE1_BASE, DEVICE1_SIZE, MT_DEVICE | MT_RW | MT_SECURE),
30 MAP_REGION_FLAT(CRF_BASE, CRF_SIZE, MT_DEVICE | MT_RW | MT_SECURE),
31 MAP_REGION_FLAT(PLAT_ARM_CCI_BASE, PLAT_ARM_CCI_SIZE, MT_DEVICE | MT_RW |
32 MT_SECURE),
33 { 0 }
34 };
35
plat_get_mmap(void)36 const mmap_region_t *plat_get_mmap(void)
37 {
38 return plat_versal_mmap;
39 }
40
versal_config_setup(void)41 void versal_config_setup(void)
42 {
43 /* Configure IPI data for versal */
44 versal_ipi_config_table_init();
45 }
46
board_detection(void)47 void board_detection(void)
48 {
49 uint32_t plat_info[2];
50
51 if (pm_get_chipid(plat_info) != PM_RET_SUCCESS) {
52 /* If the call is failed we cannot proceed with further
53 * setup. TF-A to panic in this situation.
54 */
55 NOTICE("Failed to read the chip information");
56 panic();
57 }
58
59 platform_id = FIELD_GET(PLATFORM_MASK, plat_info[1]);
60 platform_version = FIELD_GET(PLATFORM_VERSION_MASK, plat_info[1]);
61
62 if (platform_id == VERSAL_COSIM) {
63 platform_id = VERSAL_QEMU;
64 }
65 }
66
board_name_decode(void)67 const char *board_name_decode(void)
68 {
69 const char *platform;
70
71 switch (platform_id) {
72 case VERSAL_SPP:
73 platform = "IPP";
74 break;
75 case VERSAL_EMU:
76 platform = "EMU";
77 break;
78 case VERSAL_QEMU:
79 platform = "QEMU";
80 break;
81 case VERSAL_SILICON:
82 platform = "SILICON";
83 break;
84 default:
85 platform = "unknown";
86 }
87
88 return platform;
89 }
90
get_uart_clk(void)91 uint32_t get_uart_clk(void)
92 {
93 uint32_t uart_clock;
94
95 switch (platform_id) {
96 case VERSAL_SPP:
97 uart_clock = 25000000;
98 break;
99 case VERSAL_EMU:
100 uart_clock = 212000;
101 break;
102 case VERSAL_QEMU:
103 case VERSAL_SILICON:
104 uart_clock = 100000000;
105 break;
106 default:
107 panic();
108 }
109
110 return uart_clock;
111 }
112