blob: 30af4d572df7e3b64d5d71e5bdf98830ba4d5c32 [file] [log] [blame]
Soren Brinkmann76fcae32016-03-06 20:16:27 -08001/*
Venkatesh Yadav Abbarapu50dbb082022-04-12 09:21:32 +05302 * Copyright (c) 2013-2022, ARM Limited and Contributors. All rights reserved.
Akshay Belsarebdffd362023-01-18 17:04:22 +05303 * Copyright (C) 2022-2023, Advanced Micro Devices, Inc. All rights reserved.
Soren Brinkmann76fcae32016-03-06 20:16:27 -08004 *
dp-armfa3cf0b2017-05-03 09:38:09 +01005 * SPDX-License-Identifier: BSD-3-Clause
Soren Brinkmann76fcae32016-03-06 20:16:27 -08006 */
7
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +05308#include <stdbool.h>
9#include <string.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010
11#include <common/debug.h>
12#include <drivers/generic_delay_timer.h>
13#include <lib/mmio.h>
14#include <lib/xlat_tables/xlat_tables.h>
Jolly Shah6a903472019-08-27 11:23:08 -070015#include <plat_ipi.h>
Jolly Shah0bfd7002019-01-08 11:10:47 -080016#include <plat_private.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000017#include <plat/common/platform.h>
18
Siva Durga Prasad Paladugu00ae6c52017-02-20 17:55:50 +053019#include "pm_api_sys.h"
Soren Brinkmann76fcae32016-03-06 20:16:27 -080020
21/*
22 * Table of regions to map using the MMU.
23 * This doesn't include TZRAM as the 'mem_layout' argument passed to
24 * configure_mmu_elx() will give the available subset of that,
25 */
26const mmap_region_t plat_arm_mmap[] = {
27 { DEVICE0_BASE, DEVICE0_BASE, DEVICE0_SIZE, MT_DEVICE | MT_RW | MT_SECURE },
28 { DEVICE1_BASE, DEVICE1_BASE, DEVICE1_SIZE, MT_DEVICE | MT_RW | MT_SECURE },
29 { CRF_APB_BASE, CRF_APB_BASE, CRF_APB_SIZE, MT_DEVICE | MT_RW | MT_SECURE },
30 {0}
31};
32
Venkatesh Yadav Abbarapue7c45382022-05-19 14:49:49 +053033static uint32_t zynqmp_get_silicon_ver(void)
Soren Brinkmann76fcae32016-03-06 20:16:27 -080034{
Soren Brinkmann85863992016-09-16 10:34:47 -070035 static unsigned int ver;
Soren Brinkmann76fcae32016-03-06 20:16:27 -080036
Soren Brinkmann85863992016-09-16 10:34:47 -070037 if (!ver) {
38 ver = mmio_read_32(ZYNQMP_CSU_BASEADDR +
39 ZYNQMP_CSU_VERSION_OFFSET);
40 ver &= ZYNQMP_SILICON_VER_MASK;
41 ver >>= ZYNQMP_SILICON_VER_SHIFT;
42 }
Soren Brinkmann76fcae32016-03-06 20:16:27 -080043
44 return ver;
45}
46
Venkatesh Yadav Abbarapue7c45382022-05-19 14:49:49 +053047uint32_t zynqmp_get_uart_clk(void)
Soren Brinkmann76fcae32016-03-06 20:16:27 -080048{
49 unsigned int ver = zynqmp_get_silicon_ver();
50
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +053051 if (ver == ZYNQMP_CSU_VERSION_QEMU) {
Soren Brinkmann76fcae32016-03-06 20:16:27 -080052 return 133000000;
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +053053 } else {
Siva Durga Prasad Paladugudff07122018-09-04 18:02:25 +053054 return 100000000;
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +053055 }
Soren Brinkmann76fcae32016-03-06 20:16:27 -080056}
57
Soren Brinkmann76fcae32016-03-06 20:16:27 -080058#if LOG_LEVEL >= LOG_LEVEL_NOTICE
59static const struct {
Venkatesh Yadav Abbarapue7c45382022-05-19 14:49:49 +053060 uint32_t id;
61 uint32_t ver;
Soren Brinkmann76fcae32016-03-06 20:16:27 -080062 char *name;
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +053063 bool evexists;
Soren Brinkmann76fcae32016-03-06 20:16:27 -080064} zynqmp_devices[] = {
65 {
66 .id = 0x10,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -060067 .name = "XCZU3EG",
Soren Brinkmann76fcae32016-03-06 20:16:27 -080068 },
69 {
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +053070 .id = 0x10,
71 .ver = 0x2c,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -060072 .name = "XCZU3CG",
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +053073 },
74 {
Soren Brinkmann76fcae32016-03-06 20:16:27 -080075 .id = 0x11,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -060076 .name = "XCZU2EG",
Soren Brinkmann76fcae32016-03-06 20:16:27 -080077 },
78 {
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +053079 .id = 0x11,
80 .ver = 0x2c,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -060081 .name = "XCZU2CG",
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +053082 },
83 {
Soren Brinkmann76fcae32016-03-06 20:16:27 -080084 .id = 0x20,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -060085 .name = "XCZU5EV",
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +053086 .evexists = true,
Soren Brinkmann76fcae32016-03-06 20:16:27 -080087 },
88 {
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +053089 .id = 0x20,
90 .ver = 0x100,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -060091 .name = "XCZU5EG",
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +053092 .evexists = true,
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +053093 },
94 {
95 .id = 0x20,
96 .ver = 0x12c,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -060097 .name = "XCZU5CG",
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +053098 },
99 {
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800100 .id = 0x21,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600101 .name = "XCZU4EV",
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +0530102 .evexists = true,
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800103 },
104 {
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +0530105 .id = 0x21,
106 .ver = 0x100,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600107 .name = "XCZU4EG",
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +0530108 .evexists = true,
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +0530109 },
110 {
111 .id = 0x21,
112 .ver = 0x12c,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600113 .name = "XCZU4CG",
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +0530114 },
115 {
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800116 .id = 0x30,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600117 .name = "XCZU7EV",
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +0530118 .evexists = true,
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800119 },
120 {
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +0530121 .id = 0x30,
122 .ver = 0x100,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600123 .name = "XCZU7EG",
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +0530124 .evexists = true,
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +0530125 },
126 {
127 .id = 0x30,
128 .ver = 0x12c,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600129 .name = "XCZU7CG",
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +0530130 },
131 {
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800132 .id = 0x38,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600133 .name = "XCZU9EG",
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800134 },
135 {
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +0530136 .id = 0x38,
137 .ver = 0x2c,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600138 .name = "XCZU9CG",
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +0530139 },
140 {
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800141 .id = 0x39,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600142 .name = "XCZU6EG",
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800143 },
144 {
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +0530145 .id = 0x39,
146 .ver = 0x2c,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600147 .name = "XCZU6CG",
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +0530148 },
149 {
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800150 .id = 0x40,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600151 .name = "XCZU11EG",
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800152 },
153 {
154 .id = 0x50,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600155 .name = "XCZU15EG",
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800156 },
157 {
158 .id = 0x58,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600159 .name = "XCZU19EG",
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800160 },
161 {
162 .id = 0x59,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600163 .name = "XCZU17EG",
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800164 },
Siva Durga Prasad Paladugu19d69c02017-06-06 12:54:52 +0530165 {
166 .id = 0x60,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600167 .name = "XCZU28DR",
Siva Durga Prasad Paladugu19d69c02017-06-06 12:54:52 +0530168 },
169 {
170 .id = 0x61,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600171 .name = "XCZU21DR",
Siva Durga Prasad Paladugu19d69c02017-06-06 12:54:52 +0530172 },
173 {
174 .id = 0x62,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600175 .name = "XCZU29DR",
Siva Durga Prasad Paladugu19d69c02017-06-06 12:54:52 +0530176 },
177 {
178 .id = 0x63,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600179 .name = "XCZU23DR",
Siva Durga Prasad Paladugu19d69c02017-06-06 12:54:52 +0530180 },
181 {
182 .id = 0x64,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600183 .name = "XCZU27DR",
Siva Durga Prasad Paladugu19d69c02017-06-06 12:54:52 +0530184 },
185 {
186 .id = 0x65,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600187 .name = "XCZU25DR",
Siva Durga Prasad Paladugu19d69c02017-06-06 12:54:52 +0530188 },
Siva Durga Prasad Paladugu32267282019-03-23 15:26:31 +0530189 {
190 .id = 0x66,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600191 .name = "XCZU39DR",
Siva Durga Prasad Paladugu32267282019-03-23 15:26:31 +0530192 },
Venkatesh Yadav Abbarapu927c2b92019-07-30 11:12:55 +0530193 {
Venkatesh Yadav Abbarapu5a3226c2021-03-03 00:43:16 -0700194 .id = 0x7d,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600195 .name = "XCZU43DR",
Venkatesh Yadav Abbarapu5a3226c2021-03-03 00:43:16 -0700196 },
197 {
198 .id = 0x78,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600199 .name = "XCZU46DR",
Venkatesh Yadav Abbarapu5a3226c2021-03-03 00:43:16 -0700200 },
201 {
202 .id = 0x7f,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600203 .name = "XCZU47DR",
Venkatesh Yadav Abbarapu5a3226c2021-03-03 00:43:16 -0700204 },
205 {
Venkatesh Yadav Abbarapu927c2b92019-07-30 11:12:55 +0530206 .id = 0x7b,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600207 .name = "XCZU48DR",
Venkatesh Yadav Abbarapu927c2b92019-07-30 11:12:55 +0530208 },
209 {
210 .id = 0x7e,
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600211 .name = "XCZU49DR",
Venkatesh Yadav Abbarapu927c2b92019-07-30 11:12:55 +0530212 },
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800213};
214
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +0530215#define ZYNQMP_PL_STATUS_BIT 9
216#define ZYNQMP_PL_STATUS_MASK BIT(ZYNQMP_PL_STATUS_BIT)
217#define ZYNQMP_CSU_VERSION_MASK ~(ZYNQMP_PL_STATUS_MASK)
218
Michal Simekdfe452d2023-01-18 08:55:20 +0100219#define SILICON_ID_XCK24 0x4712093U
Venkatesh Yadav Abbarapua2ca35d2022-07-04 11:40:27 +0530220#define SILICON_ID_XCK26 0x4724093U
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600221
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +0530222static char *zynqmp_get_silicon_idcode_name(void)
Soren Brinkmanncb366812016-09-22 12:21:11 -0700223{
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +0530224 uint32_t id, ver, chipid[2];
225 size_t i, j, len;
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +0530226 const char *name = "EG/EV";
Soren Brinkmanncb366812016-09-22 12:21:11 -0700227
Siva Durga Prasad Paladugu6a8933c2018-06-20 17:03:57 +0530228#ifdef IMAGE_BL32
229 /*
230 * For BL32, get the chip id info directly by reading corresponding
231 * registers instead of making pm call. This has limitation
232 * that these registers should be configured to have access
233 * from APU which is default case.
234 */
235 chipid[0] = mmio_read_32(ZYNQMP_CSU_BASEADDR + ZYNQMP_CSU_IDCODE_OFFSET);
236 chipid[1] = mmio_read_32(EFUSE_BASEADDR + EFUSE_IPDISABLE_OFFSET);
237#else
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530238 if (pm_get_chipid(chipid) != PM_RET_SUCCESS) {
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600239 return "XCZUUNKN";
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530240 }
Siva Durga Prasad Paladugu6a8933c2018-06-20 17:03:57 +0530241#endif
Soren Brinkmanncb366812016-09-22 12:21:11 -0700242
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +0530243 id = chipid[0] & (ZYNQMP_CSU_IDCODE_DEVICE_CODE_MASK |
244 ZYNQMP_CSU_IDCODE_SVD_MASK);
Soren Brinkmanncb366812016-09-22 12:21:11 -0700245 id >>= ZYNQMP_CSU_IDCODE_SVD_SHIFT;
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +0530246 ver = chipid[1] >> ZYNQMP_EFUSE_IPDISABLE_SHIFT;
Soren Brinkmanncb366812016-09-22 12:21:11 -0700247
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +0530248 for (i = 0; i < ARRAY_SIZE(zynqmp_devices); i++) {
249 if (zynqmp_devices[i].id == id &&
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530250 zynqmp_devices[i].ver == (ver & ZYNQMP_CSU_VERSION_MASK)) {
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +0530251 break;
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530252 }
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +0530253 }
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +0530254
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600255 if (i >= ARRAY_SIZE(zynqmp_devices)) {
Venkatesh Yadav Abbarapue88671e2022-05-17 09:39:30 +0530256 switch (chipid[0]) {
257 case SILICON_ID_XCK24:
258 return "XCK24";
259 case SILICON_ID_XCK26:
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600260 return "XCK26";
Venkatesh Yadav Abbarapue88671e2022-05-17 09:39:30 +0530261 default:
Venkatesh Yadav Abbarapufcfdaf02021-04-21 21:54:48 -0600262 return "XCZUUNKN";
263 }
264 }
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +0530265
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530266 if (!zynqmp_devices[i].evexists) {
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +0530267 return zynqmp_devices[i].name;
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530268 }
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800269
Venkatesh Yadav Abbarapu3a33f932022-05-04 14:27:56 +0530270 if ((ver & ZYNQMP_PL_STATUS_MASK) != 0U) {
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +0530271 return zynqmp_devices[i].name;
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530272 }
Siva Durga Prasad Paladugu83e37252018-05-01 11:10:25 +0530273
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +0530274 len = strlen(zynqmp_devices[i].name) - 2;
275 for (j = 0; j < strlen(name); j++) {
276 zynqmp_devices[i].name[len] = name[j];
277 len++;
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800278 }
Siva Durga Prasad Paladugub76656d2018-03-05 18:47:15 +0530279 zynqmp_devices[i].name[len] = '\0';
280
281 return zynqmp_devices[i].name;
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800282}
283
284static unsigned int zynqmp_get_rtl_ver(void)
285{
286 uint32_t ver;
287
288 ver = mmio_read_32(ZYNQMP_CSU_BASEADDR + ZYNQMP_CSU_VERSION_OFFSET);
289 ver &= ZYNQMP_RTL_VER_MASK;
290 ver >>= ZYNQMP_RTL_VER_SHIFT;
291
292 return ver;
293}
294
295static char *zynqmp_print_silicon_idcode(void)
296{
297 uint32_t id, maskid, tmp;
298
299 id = mmio_read_32(ZYNQMP_CSU_BASEADDR + ZYNQMP_CSU_IDCODE_OFFSET);
300
301 tmp = id;
302 tmp &= ZYNQMP_CSU_IDCODE_XILINX_ID_MASK |
Soren Brinkmann31114132016-05-20 07:05:00 -0700303 ZYNQMP_CSU_IDCODE_FAMILY_MASK;
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800304 maskid = ZYNQMP_CSU_IDCODE_XILINX_ID << ZYNQMP_CSU_IDCODE_XILINX_ID_SHIFT |
Soren Brinkmann31114132016-05-20 07:05:00 -0700305 ZYNQMP_CSU_IDCODE_FAMILY << ZYNQMP_CSU_IDCODE_FAMILY_SHIFT;
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800306 if (tmp != maskid) {
Akshay Belsarebdffd362023-01-18 17:04:22 +0530307 ERROR("Incorrect IDCODE 0x%x, maskid 0x%x\n", id, maskid);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800308 return "UNKN";
309 }
Akshay Belsarebdffd362023-01-18 17:04:22 +0530310 VERBOSE("IDCODE 0x%x\n", id);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800311 return zynqmp_get_silicon_idcode_name();
312}
313
Venkatesh Yadav Abbarapue7c45382022-05-19 14:49:49 +0530314static uint32_t zynqmp_get_ps_ver(void)
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800315{
316 uint32_t ver = mmio_read_32(ZYNQMP_CSU_BASEADDR + ZYNQMP_CSU_VERSION_OFFSET);
317
318 ver &= ZYNQMP_PS_VER_MASK;
319 ver >>= ZYNQMP_PS_VER_SHIFT;
320
Venkatesh Yadav Abbarapua2ca35d2022-07-04 11:40:27 +0530321 return ver + 1U;
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800322}
323
324static void zynqmp_print_platform_name(void)
325{
Venkatesh Yadav Abbarapue7c45382022-05-19 14:49:49 +0530326 uint32_t ver = zynqmp_get_silicon_ver();
327 uint32_t rtl = zynqmp_get_rtl_ver();
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800328 char *label = "Unknown";
329
330 switch (ver) {
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800331 case ZYNQMP_CSU_VERSION_QEMU:
332 label = "QEMU";
333 break;
334 case ZYNQMP_CSU_VERSION_SILICON:
335 label = "silicon";
336 break;
Jonathan Wrightff957ed2018-03-14 15:24:00 +0000337 default:
338 /* Do nothing in default case */
339 break;
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800340 }
341
Venkatesh Yadav Abbarapu50dbb082022-04-12 09:21:32 +0530342 VERBOSE("TF-A running on %s/%s at 0x%x\n",
343 zynqmp_print_silicon_idcode(), label, BL31_BASE);
Venkatesh Yadav Abbarapud4740e42021-06-17 00:23:52 -0600344 VERBOSE("TF-A running on v%d/RTL%d.%d\n",
345 zynqmp_get_ps_ver(), (rtl & 0xf0) >> 4, rtl & 0xf);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800346}
347#else
348static inline void zynqmp_print_platform_name(void) { }
349#endif
350
Venkatesh Yadav Abbarapue7c45382022-05-19 14:49:49 +0530351uint32_t zynqmp_get_bootmode(void)
Soren Brinkmannb43d9432016-04-18 11:49:42 -0700352{
Siva Durga Prasad Paladugu00ae6c52017-02-20 17:55:50 +0530353 uint32_t r;
Siva Durga Prasad Paladugu40808bc2018-04-30 19:43:03 +0530354 unsigned int ret;
Siva Durga Prasad Paladugu00ae6c52017-02-20 17:55:50 +0530355
Siva Durga Prasad Paladugu40808bc2018-04-30 19:43:03 +0530356 ret = pm_mmio_read(CRL_APB_BOOT_MODE_USER, &r);
357
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530358 if (ret != PM_RET_SUCCESS) {
Siva Durga Prasad Paladugu00ae6c52017-02-20 17:55:50 +0530359 r = mmio_read_32(CRL_APB_BOOT_MODE_USER);
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530360 }
Soren Brinkmannb43d9432016-04-18 11:49:42 -0700361
362 return r & CRL_APB_BOOT_MODE_MASK;
363}
364
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800365void zynqmp_config_setup(void)
366{
Rajan Vaja12be18b2021-03-26 04:16:36 -0700367 uint64_t counter_freq;
368
Jolly Shah6a903472019-08-27 11:23:08 -0700369 /* Configure IPI data for ZynqMP */
370 zynqmp_ipi_config_table_init();
371
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800372 zynqmp_print_platform_name();
Rajan Vaja12be18b2021-03-26 04:16:36 -0700373
374 /* Configure counter frequency */
375 counter_freq = read_cntfrq_el0();
376 if (counter_freq == ZYNQMP_DEFAULT_COUNTER_FREQ) {
377 write_cntfrq_el0(plat_get_syscnt_freq2());
378 }
379
Soren Brinkmanne5bdcaa2016-06-22 09:02:56 -0700380 generic_delay_timer_init();
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800381}
382
Venkatesh Yadav Abbarapue7c45382022-05-19 14:49:49 +0530383uint32_t plat_get_syscnt_freq2(void)
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800384{
Venkatesh Yadav Abbarapue7c45382022-05-19 14:49:49 +0530385 uint32_t ver = zynqmp_get_silicon_ver();
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800386
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530387 if (ver == ZYNQMP_CSU_VERSION_QEMU) {
Edgar E. Iglesias481d2c22019-04-17 15:21:28 +0200388 return 65000000;
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530389 } else {
Siva Durga Prasad Paladugudff07122018-09-04 18:02:25 +0530390 return mmio_read_32(IOU_SCNTRS_BASEFREQ);
Venkatesh Yadav Abbarapu987fad32022-04-29 13:52:00 +0530391 }
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800392}