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