Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 1 | /* |
Michal Simek | 2a47faa | 2023-04-14 08:43:51 +0200 | [diff] [blame] | 2 | * Copyright (c) 2013-2022, Arm Limited and Contributors. All rights reserved. |
Jay Buddhabhatti | 26e138a | 2022-12-21 23:03:35 -0800 | [diff] [blame] | 3 | * Copyright (c) 2022-2023, Advanced Micro Devices, Inc. All rights reserved. |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 4 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 5 | * SPDX-License-Identifier: BSD-3-Clause |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 6 | */ |
| 7 | |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 8 | #include <stdbool.h> |
| 9 | #include <string.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | |
| 11 | #include <common/debug.h> |
| 12 | #include <drivers/generic_delay_timer.h> |
| 13 | #include <lib/mmio.h> |
Michal Simek | c98da1c | 2023-02-09 10:28:58 +0100 | [diff] [blame] | 14 | #include <lib/smccc.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 15 | #include <lib/xlat_tables/xlat_tables.h> |
Prasad Kummari | 536e110 | 2023-06-22 10:50:02 +0530 | [diff] [blame^] | 16 | #include <plat/common/platform.h> |
| 17 | #include <services/arm_arch_svc.h> |
| 18 | |
Jolly Shah | 6a90347 | 2019-08-27 11:23:08 -0700 | [diff] [blame] | 19 | #include <plat_ipi.h> |
Jolly Shah | 0bfd700 | 2019-01-08 11:10:47 -0800 | [diff] [blame] | 20 | #include <plat_private.h> |
Michal Simek | c98da1c | 2023-02-09 10:28:58 +0100 | [diff] [blame] | 21 | #include <plat_startup.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 22 | |
Jay Buddhabhatti | 26e138a | 2022-12-21 23:03:35 -0800 | [diff] [blame] | 23 | #include "zynqmp_pm_api_sys.h" |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 24 | |
| 25 | /* |
| 26 | * Table of regions to map using the MMU. |
| 27 | * This doesn't include TZRAM as the 'mem_layout' argument passed to |
| 28 | * configure_mmu_elx() will give the available subset of that, |
| 29 | */ |
| 30 | const mmap_region_t plat_arm_mmap[] = { |
| 31 | { DEVICE0_BASE, DEVICE0_BASE, DEVICE0_SIZE, MT_DEVICE | MT_RW | MT_SECURE }, |
| 32 | { DEVICE1_BASE, DEVICE1_BASE, DEVICE1_SIZE, MT_DEVICE | MT_RW | MT_SECURE }, |
| 33 | { CRF_APB_BASE, CRF_APB_BASE, CRF_APB_SIZE, MT_DEVICE | MT_RW | MT_SECURE }, |
| 34 | {0} |
| 35 | }; |
| 36 | |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 37 | static uint32_t zynqmp_get_silicon_ver(void) |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 38 | { |
Soren Brinkmann | 8586399 | 2016-09-16 10:34:47 -0700 | [diff] [blame] | 39 | static unsigned int ver; |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 40 | |
Soren Brinkmann | 8586399 | 2016-09-16 10:34:47 -0700 | [diff] [blame] | 41 | if (!ver) { |
| 42 | ver = mmio_read_32(ZYNQMP_CSU_BASEADDR + |
| 43 | ZYNQMP_CSU_VERSION_OFFSET); |
| 44 | ver &= ZYNQMP_SILICON_VER_MASK; |
| 45 | ver >>= ZYNQMP_SILICON_VER_SHIFT; |
| 46 | } |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 47 | |
| 48 | return ver; |
| 49 | } |
| 50 | |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 51 | uint32_t zynqmp_get_uart_clk(void) |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 52 | { |
| 53 | unsigned int ver = zynqmp_get_silicon_ver(); |
| 54 | |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 55 | if (ver == ZYNQMP_CSU_VERSION_QEMU) { |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 56 | return 133000000; |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 57 | } else { |
Siva Durga Prasad Paladugu | dff0712 | 2018-09-04 18:02:25 +0530 | [diff] [blame] | 58 | return 100000000; |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 59 | } |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 60 | } |
| 61 | |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 62 | #if LOG_LEVEL >= LOG_LEVEL_NOTICE |
| 63 | static const struct { |
Michal Simek | 918a0dd | 2023-04-27 14:54:45 +0200 | [diff] [blame] | 64 | uint8_t id; |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 65 | bool evexists; |
Michal Simek | 918a0dd | 2023-04-27 14:54:45 +0200 | [diff] [blame] | 66 | uint16_t ver; |
| 67 | char *name; |
| 68 | } __packed zynqmp_devices[] = { |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 69 | { |
| 70 | .id = 0x10, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 71 | .name = "XCZU3EG", |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 72 | }, |
| 73 | { |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 74 | .id = 0x10, |
| 75 | .ver = 0x2c, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 76 | .name = "XCZU3CG", |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 77 | }, |
| 78 | { |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 79 | .id = 0x11, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 80 | .name = "XCZU2EG", |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 81 | }, |
| 82 | { |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 83 | .id = 0x11, |
| 84 | .ver = 0x2c, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 85 | .name = "XCZU2CG", |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 86 | }, |
| 87 | { |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 88 | .id = 0x20, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 89 | .name = "XCZU5EV", |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 90 | .evexists = true, |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 91 | }, |
| 92 | { |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 93 | .id = 0x20, |
| 94 | .ver = 0x100, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 95 | .name = "XCZU5EG", |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 96 | .evexists = true, |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 97 | }, |
| 98 | { |
| 99 | .id = 0x20, |
| 100 | .ver = 0x12c, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 101 | .name = "XCZU5CG", |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 102 | }, |
| 103 | { |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 104 | .id = 0x21, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 105 | .name = "XCZU4EV", |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 106 | .evexists = true, |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 107 | }, |
| 108 | { |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 109 | .id = 0x21, |
| 110 | .ver = 0x100, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 111 | .name = "XCZU4EG", |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 112 | .evexists = true, |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 113 | }, |
| 114 | { |
| 115 | .id = 0x21, |
| 116 | .ver = 0x12c, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 117 | .name = "XCZU4CG", |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 118 | }, |
| 119 | { |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 120 | .id = 0x30, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 121 | .name = "XCZU7EV", |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 122 | .evexists = true, |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 123 | }, |
| 124 | { |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 125 | .id = 0x30, |
| 126 | .ver = 0x100, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 127 | .name = "XCZU7EG", |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 128 | .evexists = true, |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 129 | }, |
| 130 | { |
| 131 | .id = 0x30, |
| 132 | .ver = 0x12c, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 133 | .name = "XCZU7CG", |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 134 | }, |
| 135 | { |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 136 | .id = 0x38, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 137 | .name = "XCZU9EG", |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 138 | }, |
| 139 | { |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 140 | .id = 0x38, |
| 141 | .ver = 0x2c, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 142 | .name = "XCZU9CG", |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 143 | }, |
| 144 | { |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 145 | .id = 0x39, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 146 | .name = "XCZU6EG", |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 147 | }, |
| 148 | { |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 149 | .id = 0x39, |
| 150 | .ver = 0x2c, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 151 | .name = "XCZU6CG", |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 152 | }, |
| 153 | { |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 154 | .id = 0x40, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 155 | .name = "XCZU11EG", |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 156 | }, |
| 157 | { |
| 158 | .id = 0x50, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 159 | .name = "XCZU15EG", |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 160 | }, |
| 161 | { |
| 162 | .id = 0x58, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 163 | .name = "XCZU19EG", |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 164 | }, |
| 165 | { |
| 166 | .id = 0x59, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 167 | .name = "XCZU17EG", |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 168 | }, |
Siva Durga Prasad Paladugu | 19d69c0 | 2017-06-06 12:54:52 +0530 | [diff] [blame] | 169 | { |
| 170 | .id = 0x60, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 171 | .name = "XCZU28DR", |
Siva Durga Prasad Paladugu | 19d69c0 | 2017-06-06 12:54:52 +0530 | [diff] [blame] | 172 | }, |
| 173 | { |
| 174 | .id = 0x61, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 175 | .name = "XCZU21DR", |
Siva Durga Prasad Paladugu | 19d69c0 | 2017-06-06 12:54:52 +0530 | [diff] [blame] | 176 | }, |
| 177 | { |
| 178 | .id = 0x62, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 179 | .name = "XCZU29DR", |
Siva Durga Prasad Paladugu | 19d69c0 | 2017-06-06 12:54:52 +0530 | [diff] [blame] | 180 | }, |
| 181 | { |
| 182 | .id = 0x63, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 183 | .name = "XCZU23DR", |
Siva Durga Prasad Paladugu | 19d69c0 | 2017-06-06 12:54:52 +0530 | [diff] [blame] | 184 | }, |
| 185 | { |
| 186 | .id = 0x64, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 187 | .name = "XCZU27DR", |
Siva Durga Prasad Paladugu | 19d69c0 | 2017-06-06 12:54:52 +0530 | [diff] [blame] | 188 | }, |
| 189 | { |
| 190 | .id = 0x65, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 191 | .name = "XCZU25DR", |
Siva Durga Prasad Paladugu | 19d69c0 | 2017-06-06 12:54:52 +0530 | [diff] [blame] | 192 | }, |
Siva Durga Prasad Paladugu | 3226728 | 2019-03-23 15:26:31 +0530 | [diff] [blame] | 193 | { |
| 194 | .id = 0x66, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 195 | .name = "XCZU39DR", |
Siva Durga Prasad Paladugu | 3226728 | 2019-03-23 15:26:31 +0530 | [diff] [blame] | 196 | }, |
Venkatesh Yadav Abbarapu | 927c2b9 | 2019-07-30 11:12:55 +0530 | [diff] [blame] | 197 | { |
Venkatesh Yadav Abbarapu | 5a3226c | 2021-03-03 00:43:16 -0700 | [diff] [blame] | 198 | .id = 0x7d, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 199 | .name = "XCZU43DR", |
Venkatesh Yadav Abbarapu | 5a3226c | 2021-03-03 00:43:16 -0700 | [diff] [blame] | 200 | }, |
| 201 | { |
| 202 | .id = 0x78, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 203 | .name = "XCZU46DR", |
Venkatesh Yadav Abbarapu | 5a3226c | 2021-03-03 00:43:16 -0700 | [diff] [blame] | 204 | }, |
| 205 | { |
| 206 | .id = 0x7f, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 207 | .name = "XCZU47DR", |
Venkatesh Yadav Abbarapu | 5a3226c | 2021-03-03 00:43:16 -0700 | [diff] [blame] | 208 | }, |
| 209 | { |
Venkatesh Yadav Abbarapu | 927c2b9 | 2019-07-30 11:12:55 +0530 | [diff] [blame] | 210 | .id = 0x7b, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 211 | .name = "XCZU48DR", |
Venkatesh Yadav Abbarapu | 927c2b9 | 2019-07-30 11:12:55 +0530 | [diff] [blame] | 212 | }, |
| 213 | { |
| 214 | .id = 0x7e, |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 215 | .name = "XCZU49DR", |
Venkatesh Yadav Abbarapu | 927c2b9 | 2019-07-30 11:12:55 +0530 | [diff] [blame] | 216 | }, |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 217 | }; |
| 218 | |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 219 | #define ZYNQMP_PL_STATUS_BIT 9 |
| 220 | #define ZYNQMP_PL_STATUS_MASK BIT(ZYNQMP_PL_STATUS_BIT) |
| 221 | #define ZYNQMP_CSU_VERSION_MASK ~(ZYNQMP_PL_STATUS_MASK) |
| 222 | |
Michal Simek | dfe452d | 2023-01-18 08:55:20 +0100 | [diff] [blame] | 223 | #define SILICON_ID_XCK24 0x4712093U |
Venkatesh Yadav Abbarapu | a2ca35d | 2022-07-04 11:40:27 +0530 | [diff] [blame] | 224 | #define SILICON_ID_XCK26 0x4724093U |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 225 | |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 226 | static char *zynqmp_get_silicon_idcode_name(void) |
Soren Brinkmann | cb36681 | 2016-09-22 12:21:11 -0700 | [diff] [blame] | 227 | { |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 228 | uint32_t id, ver, chipid[2]; |
| 229 | size_t i, j, len; |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 230 | const char *name = "EG/EV"; |
Soren Brinkmann | cb36681 | 2016-09-22 12:21:11 -0700 | [diff] [blame] | 231 | |
Siva Durga Prasad Paladugu | 6a8933c | 2018-06-20 17:03:57 +0530 | [diff] [blame] | 232 | #ifdef IMAGE_BL32 |
| 233 | /* |
| 234 | * For BL32, get the chip id info directly by reading corresponding |
| 235 | * registers instead of making pm call. This has limitation |
| 236 | * that these registers should be configured to have access |
| 237 | * from APU which is default case. |
| 238 | */ |
| 239 | chipid[0] = mmio_read_32(ZYNQMP_CSU_BASEADDR + ZYNQMP_CSU_IDCODE_OFFSET); |
| 240 | chipid[1] = mmio_read_32(EFUSE_BASEADDR + EFUSE_IPDISABLE_OFFSET); |
| 241 | #else |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 242 | if (pm_get_chipid(chipid) != PM_RET_SUCCESS) { |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 243 | return "XCZUUNKN"; |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 244 | } |
Siva Durga Prasad Paladugu | 6a8933c | 2018-06-20 17:03:57 +0530 | [diff] [blame] | 245 | #endif |
Soren Brinkmann | cb36681 | 2016-09-22 12:21:11 -0700 | [diff] [blame] | 246 | |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 247 | id = chipid[0] & (ZYNQMP_CSU_IDCODE_DEVICE_CODE_MASK | |
| 248 | ZYNQMP_CSU_IDCODE_SVD_MASK); |
Soren Brinkmann | cb36681 | 2016-09-22 12:21:11 -0700 | [diff] [blame] | 249 | id >>= ZYNQMP_CSU_IDCODE_SVD_SHIFT; |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 250 | ver = chipid[1] >> ZYNQMP_EFUSE_IPDISABLE_SHIFT; |
Soren Brinkmann | cb36681 | 2016-09-22 12:21:11 -0700 | [diff] [blame] | 251 | |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 252 | for (i = 0; i < ARRAY_SIZE(zynqmp_devices); i++) { |
| 253 | if (zynqmp_devices[i].id == id && |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 254 | zynqmp_devices[i].ver == (ver & ZYNQMP_CSU_VERSION_MASK)) { |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 255 | break; |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 256 | } |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 257 | } |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 258 | |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 259 | if (i >= ARRAY_SIZE(zynqmp_devices)) { |
Venkatesh Yadav Abbarapu | e88671e | 2022-05-17 09:39:30 +0530 | [diff] [blame] | 260 | switch (chipid[0]) { |
| 261 | case SILICON_ID_XCK24: |
| 262 | return "XCK24"; |
| 263 | case SILICON_ID_XCK26: |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 264 | return "XCK26"; |
Venkatesh Yadav Abbarapu | e88671e | 2022-05-17 09:39:30 +0530 | [diff] [blame] | 265 | default: |
Venkatesh Yadav Abbarapu | fcfdaf0 | 2021-04-21 21:54:48 -0600 | [diff] [blame] | 266 | return "XCZUUNKN"; |
| 267 | } |
| 268 | } |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 269 | |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 270 | if (!zynqmp_devices[i].evexists) { |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 271 | return zynqmp_devices[i].name; |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 272 | } |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 273 | |
Venkatesh Yadav Abbarapu | 3a33f93 | 2022-05-04 14:27:56 +0530 | [diff] [blame] | 274 | if ((ver & ZYNQMP_PL_STATUS_MASK) != 0U) { |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 275 | return zynqmp_devices[i].name; |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 276 | } |
Siva Durga Prasad Paladugu | 83e3725 | 2018-05-01 11:10:25 +0530 | [diff] [blame] | 277 | |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 278 | len = strlen(zynqmp_devices[i].name) - 2; |
| 279 | for (j = 0; j < strlen(name); j++) { |
| 280 | zynqmp_devices[i].name[len] = name[j]; |
| 281 | len++; |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 282 | } |
Siva Durga Prasad Paladugu | b76656d | 2018-03-05 18:47:15 +0530 | [diff] [blame] | 283 | zynqmp_devices[i].name[len] = '\0'; |
| 284 | |
| 285 | return zynqmp_devices[i].name; |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | static unsigned int zynqmp_get_rtl_ver(void) |
| 289 | { |
| 290 | uint32_t ver; |
| 291 | |
| 292 | ver = mmio_read_32(ZYNQMP_CSU_BASEADDR + ZYNQMP_CSU_VERSION_OFFSET); |
| 293 | ver &= ZYNQMP_RTL_VER_MASK; |
| 294 | ver >>= ZYNQMP_RTL_VER_SHIFT; |
| 295 | |
| 296 | return ver; |
| 297 | } |
| 298 | |
| 299 | static char *zynqmp_print_silicon_idcode(void) |
| 300 | { |
| 301 | uint32_t id, maskid, tmp; |
| 302 | |
| 303 | id = mmio_read_32(ZYNQMP_CSU_BASEADDR + ZYNQMP_CSU_IDCODE_OFFSET); |
| 304 | |
| 305 | tmp = id; |
| 306 | tmp &= ZYNQMP_CSU_IDCODE_XILINX_ID_MASK | |
Soren Brinkmann | 3111413 | 2016-05-20 07:05:00 -0700 | [diff] [blame] | 307 | ZYNQMP_CSU_IDCODE_FAMILY_MASK; |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 308 | maskid = ZYNQMP_CSU_IDCODE_XILINX_ID << ZYNQMP_CSU_IDCODE_XILINX_ID_SHIFT | |
Soren Brinkmann | 3111413 | 2016-05-20 07:05:00 -0700 | [diff] [blame] | 309 | ZYNQMP_CSU_IDCODE_FAMILY << ZYNQMP_CSU_IDCODE_FAMILY_SHIFT; |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 310 | if (tmp != maskid) { |
Akshay Belsare | bdffd36 | 2023-01-18 17:04:22 +0530 | [diff] [blame] | 311 | ERROR("Incorrect IDCODE 0x%x, maskid 0x%x\n", id, maskid); |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 312 | return "UNKN"; |
| 313 | } |
Akshay Belsare | bdffd36 | 2023-01-18 17:04:22 +0530 | [diff] [blame] | 314 | VERBOSE("IDCODE 0x%x\n", id); |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 315 | return zynqmp_get_silicon_idcode_name(); |
| 316 | } |
| 317 | |
Michal Simek | c98da1c | 2023-02-09 10:28:58 +0100 | [diff] [blame] | 318 | int32_t plat_is_smccc_feature_available(u_register_t fid) |
| 319 | { |
| 320 | switch (fid) { |
| 321 | case SMCCC_ARCH_SOC_ID: |
| 322 | return SMC_ARCH_CALL_SUCCESS; |
| 323 | default: |
| 324 | return SMC_ARCH_CALL_NOT_SUPPORTED; |
| 325 | } |
| 326 | |
| 327 | return SMC_ARCH_CALL_NOT_SUPPORTED; |
| 328 | } |
| 329 | |
| 330 | int32_t plat_get_soc_version(void) |
| 331 | { |
| 332 | uint32_t chip_id = zynqmp_get_silicon_ver(); |
| 333 | uint32_t manfid = SOC_ID_SET_JEP_106(JEDEC_XILINX_BKID, JEDEC_XILINX_MFID); |
| 334 | |
| 335 | return (int32_t)(manfid | (chip_id & 0xFFFF)); |
| 336 | } |
| 337 | |
| 338 | int32_t plat_get_soc_revision(void) |
| 339 | { |
| 340 | return mmio_read_32(ZYNQMP_CSU_BASEADDR + ZYNQMP_CSU_IDCODE_OFFSET); |
| 341 | } |
| 342 | |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 343 | static uint32_t zynqmp_get_ps_ver(void) |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 344 | { |
| 345 | uint32_t ver = mmio_read_32(ZYNQMP_CSU_BASEADDR + ZYNQMP_CSU_VERSION_OFFSET); |
| 346 | |
| 347 | ver &= ZYNQMP_PS_VER_MASK; |
| 348 | ver >>= ZYNQMP_PS_VER_SHIFT; |
| 349 | |
Venkatesh Yadav Abbarapu | a2ca35d | 2022-07-04 11:40:27 +0530 | [diff] [blame] | 350 | return ver + 1U; |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | static void zynqmp_print_platform_name(void) |
| 354 | { |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 355 | uint32_t ver = zynqmp_get_silicon_ver(); |
| 356 | uint32_t rtl = zynqmp_get_rtl_ver(); |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 357 | char *label = "Unknown"; |
| 358 | |
| 359 | switch (ver) { |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 360 | case ZYNQMP_CSU_VERSION_QEMU: |
| 361 | label = "QEMU"; |
| 362 | break; |
| 363 | case ZYNQMP_CSU_VERSION_SILICON: |
| 364 | label = "silicon"; |
| 365 | break; |
Jonathan Wright | ff957ed | 2018-03-14 15:24:00 +0000 | [diff] [blame] | 366 | default: |
| 367 | /* Do nothing in default case */ |
| 368 | break; |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 369 | } |
| 370 | |
Venkatesh Yadav Abbarapu | 50dbb08 | 2022-04-12 09:21:32 +0530 | [diff] [blame] | 371 | VERBOSE("TF-A running on %s/%s at 0x%x\n", |
| 372 | zynqmp_print_silicon_idcode(), label, BL31_BASE); |
Venkatesh Yadav Abbarapu | d4740e4 | 2021-06-17 00:23:52 -0600 | [diff] [blame] | 373 | VERBOSE("TF-A running on v%d/RTL%d.%d\n", |
| 374 | zynqmp_get_ps_ver(), (rtl & 0xf0) >> 4, rtl & 0xf); |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 375 | } |
| 376 | #else |
| 377 | static inline void zynqmp_print_platform_name(void) { } |
| 378 | #endif |
| 379 | |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 380 | uint32_t zynqmp_get_bootmode(void) |
Soren Brinkmann | b43d943 | 2016-04-18 11:49:42 -0700 | [diff] [blame] | 381 | { |
Siva Durga Prasad Paladugu | 00ae6c5 | 2017-02-20 17:55:50 +0530 | [diff] [blame] | 382 | uint32_t r; |
Siva Durga Prasad Paladugu | 40808bc | 2018-04-30 19:43:03 +0530 | [diff] [blame] | 383 | unsigned int ret; |
Siva Durga Prasad Paladugu | 00ae6c5 | 2017-02-20 17:55:50 +0530 | [diff] [blame] | 384 | |
Siva Durga Prasad Paladugu | 40808bc | 2018-04-30 19:43:03 +0530 | [diff] [blame] | 385 | ret = pm_mmio_read(CRL_APB_BOOT_MODE_USER, &r); |
| 386 | |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 387 | if (ret != PM_RET_SUCCESS) { |
Siva Durga Prasad Paladugu | 00ae6c5 | 2017-02-20 17:55:50 +0530 | [diff] [blame] | 388 | r = mmio_read_32(CRL_APB_BOOT_MODE_USER); |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 389 | } |
Soren Brinkmann | b43d943 | 2016-04-18 11:49:42 -0700 | [diff] [blame] | 390 | |
| 391 | return r & CRL_APB_BOOT_MODE_MASK; |
| 392 | } |
| 393 | |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 394 | void zynqmp_config_setup(void) |
| 395 | { |
Rajan Vaja | 12be18b | 2021-03-26 04:16:36 -0700 | [diff] [blame] | 396 | uint64_t counter_freq; |
| 397 | |
Jolly Shah | 6a90347 | 2019-08-27 11:23:08 -0700 | [diff] [blame] | 398 | /* Configure IPI data for ZynqMP */ |
| 399 | zynqmp_ipi_config_table_init(); |
| 400 | |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 401 | zynqmp_print_platform_name(); |
Rajan Vaja | 12be18b | 2021-03-26 04:16:36 -0700 | [diff] [blame] | 402 | |
| 403 | /* Configure counter frequency */ |
| 404 | counter_freq = read_cntfrq_el0(); |
| 405 | if (counter_freq == ZYNQMP_DEFAULT_COUNTER_FREQ) { |
| 406 | write_cntfrq_el0(plat_get_syscnt_freq2()); |
| 407 | } |
| 408 | |
Soren Brinkmann | e5bdcaa | 2016-06-22 09:02:56 -0700 | [diff] [blame] | 409 | generic_delay_timer_init(); |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 410 | } |
| 411 | |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 412 | uint32_t plat_get_syscnt_freq2(void) |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 413 | { |
Venkatesh Yadav Abbarapu | e7c4538 | 2022-05-19 14:49:49 +0530 | [diff] [blame] | 414 | uint32_t ver = zynqmp_get_silicon_ver(); |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 415 | |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 416 | if (ver == ZYNQMP_CSU_VERSION_QEMU) { |
Edgar E. Iglesias | 481d2c2 | 2019-04-17 15:21:28 +0200 | [diff] [blame] | 417 | return 65000000; |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 418 | } else { |
Siva Durga Prasad Paladugu | dff0712 | 2018-09-04 18:02:25 +0530 | [diff] [blame] | 419 | return mmio_read_32(IOU_SCNTRS_BASEFREQ); |
Venkatesh Yadav Abbarapu | 987fad3 | 2022-04-29 13:52:00 +0530 | [diff] [blame] | 420 | } |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 421 | } |