Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2014 - 2015 Xilinx, Inc. |
| 4 | * Michal Simek <michal.simek@xilinx.com> |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 8 | #include <command.h> |
Simon Glass | 370382c | 2019-11-14 12:57:35 -0700 | [diff] [blame] | 9 | #include <cpu_func.h> |
Michal Simek | 09a7d7d | 2020-01-07 09:02:52 +0100 | [diff] [blame] | 10 | #include <debug_uart.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 11 | #include <env.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 12 | #include <init.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 13 | #include <log.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 14 | #include <net.h> |
Michal Simek | d54b1af | 2015-09-30 17:26:55 +0200 | [diff] [blame] | 15 | #include <sata.h> |
Michal Simek | b216cc1 | 2015-07-23 13:27:40 +0200 | [diff] [blame] | 16 | #include <ahci.h> |
| 17 | #include <scsi.h> |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 18 | #include <malloc.h> |
Michal Simek | bf0f9ca | 2018-04-19 15:43:38 +0200 | [diff] [blame] | 19 | #include <wdt.h> |
Michal Simek | c23d3f8 | 2015-11-05 08:34:35 +0100 | [diff] [blame] | 20 | #include <asm/arch/clk.h> |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 21 | #include <asm/arch/hardware.h> |
| 22 | #include <asm/arch/sys_proto.h> |
Michal Simek | f2f0864 | 2018-01-10 09:36:09 +0100 | [diff] [blame] | 23 | #include <asm/arch/psu_init_gpl.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 24 | #include <asm/cache.h> |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 25 | #include <asm/io.h> |
Simon Glass | 6b9f010 | 2020-05-10 11:40:06 -0600 | [diff] [blame] | 26 | #include <asm/ptrace.h> |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 27 | #include <dm/device.h> |
Michal Simek | bf0f9ca | 2018-04-19 15:43:38 +0200 | [diff] [blame] | 28 | #include <dm/uclass.h> |
Siva Durga Prasad Paladugu | ba1f68e | 2015-08-04 13:03:26 +0530 | [diff] [blame] | 29 | #include <usb.h> |
| 30 | #include <dwc3-uboot.h> |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 31 | #include <zynqmppl.h> |
Ibai Erkiaga | c8a3efa | 2019-09-27 11:37:01 +0100 | [diff] [blame] | 32 | #include <zynqmp_firmware.h> |
Michal Simek | 76d0a77 | 2016-09-01 11:16:40 +0200 | [diff] [blame] | 33 | #include <g_dnl.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 34 | #include <linux/bitops.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 35 | #include <linux/delay.h> |
| 36 | #include <linux/sizes.h> |
Michal Simek | 705d44a | 2020-03-31 12:39:37 +0200 | [diff] [blame] | 37 | #include "../common/board.h" |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 38 | |
Luca Ceresoli | 23e6500 | 2019-05-21 18:06:43 +0200 | [diff] [blame] | 39 | #include "pm_cfg_obj.h" |
| 40 | |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 41 | DECLARE_GLOBAL_DATA_PTR; |
| 42 | |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 43 | #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \ |
| 44 | !defined(CONFIG_SPL_BUILD) |
| 45 | static xilinx_desc zynqmppl = XILINX_ZYNQMP_DESC; |
| 46 | |
| 47 | static const struct { |
Michal Simek | 6908b86 | 2017-11-06 12:55:59 +0100 | [diff] [blame] | 48 | u32 id; |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 49 | u32 ver; |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 50 | char *name; |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 51 | bool evexists; |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 52 | } zynqmp_devices[] = { |
| 53 | { |
| 54 | .id = 0x10, |
| 55 | .name = "3eg", |
| 56 | }, |
| 57 | { |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 58 | .id = 0x10, |
| 59 | .ver = 0x2c, |
| 60 | .name = "3cg", |
| 61 | }, |
| 62 | { |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 63 | .id = 0x11, |
| 64 | .name = "2eg", |
| 65 | }, |
| 66 | { |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 67 | .id = 0x11, |
| 68 | .ver = 0x2c, |
| 69 | .name = "2cg", |
| 70 | }, |
| 71 | { |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 72 | .id = 0x20, |
| 73 | .name = "5ev", |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 74 | .evexists = 1, |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 75 | }, |
| 76 | { |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 77 | .id = 0x20, |
| 78 | .ver = 0x100, |
| 79 | .name = "5eg", |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 80 | .evexists = 1, |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 81 | }, |
| 82 | { |
| 83 | .id = 0x20, |
| 84 | .ver = 0x12c, |
| 85 | .name = "5cg", |
Siva Durga Prasad Paladugu | 951c019 | 2018-10-26 17:47:55 +0530 | [diff] [blame] | 86 | .evexists = 1, |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 87 | }, |
| 88 | { |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 89 | .id = 0x21, |
| 90 | .name = "4ev", |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 91 | .evexists = 1, |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 92 | }, |
| 93 | { |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 94 | .id = 0x21, |
| 95 | .ver = 0x100, |
| 96 | .name = "4eg", |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 97 | .evexists = 1, |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 98 | }, |
| 99 | { |
| 100 | .id = 0x21, |
| 101 | .ver = 0x12c, |
| 102 | .name = "4cg", |
Siva Durga Prasad Paladugu | 951c019 | 2018-10-26 17:47:55 +0530 | [diff] [blame] | 103 | .evexists = 1, |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 104 | }, |
| 105 | { |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 106 | .id = 0x30, |
| 107 | .name = "7ev", |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 108 | .evexists = 1, |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 109 | }, |
| 110 | { |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 111 | .id = 0x30, |
| 112 | .ver = 0x100, |
| 113 | .name = "7eg", |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 114 | .evexists = 1, |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 115 | }, |
| 116 | { |
| 117 | .id = 0x30, |
| 118 | .ver = 0x12c, |
| 119 | .name = "7cg", |
Siva Durga Prasad Paladugu | 951c019 | 2018-10-26 17:47:55 +0530 | [diff] [blame] | 120 | .evexists = 1, |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 121 | }, |
| 122 | { |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 123 | .id = 0x38, |
| 124 | .name = "9eg", |
| 125 | }, |
| 126 | { |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 127 | .id = 0x38, |
| 128 | .ver = 0x2c, |
| 129 | .name = "9cg", |
| 130 | }, |
| 131 | { |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 132 | .id = 0x39, |
| 133 | .name = "6eg", |
| 134 | }, |
| 135 | { |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 136 | .id = 0x39, |
| 137 | .ver = 0x2c, |
| 138 | .name = "6cg", |
| 139 | }, |
| 140 | { |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 141 | .id = 0x40, |
| 142 | .name = "11eg", |
| 143 | }, |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 144 | { /* For testing purpose only */ |
| 145 | .id = 0x50, |
| 146 | .ver = 0x2c, |
| 147 | .name = "15cg", |
| 148 | }, |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 149 | { |
| 150 | .id = 0x50, |
| 151 | .name = "15eg", |
| 152 | }, |
| 153 | { |
| 154 | .id = 0x58, |
| 155 | .name = "19eg", |
| 156 | }, |
| 157 | { |
| 158 | .id = 0x59, |
| 159 | .name = "17eg", |
| 160 | }, |
Michal Simek | b510e53 | 2017-06-02 08:08:59 +0200 | [diff] [blame] | 161 | { |
| 162 | .id = 0x61, |
| 163 | .name = "21dr", |
| 164 | }, |
| 165 | { |
| 166 | .id = 0x63, |
| 167 | .name = "23dr", |
| 168 | }, |
| 169 | { |
| 170 | .id = 0x65, |
| 171 | .name = "25dr", |
| 172 | }, |
| 173 | { |
| 174 | .id = 0x64, |
| 175 | .name = "27dr", |
| 176 | }, |
| 177 | { |
| 178 | .id = 0x60, |
| 179 | .name = "28dr", |
| 180 | }, |
| 181 | { |
| 182 | .id = 0x62, |
| 183 | .name = "29dr", |
| 184 | }, |
Siva Durga Prasad Paladugu | 70866b4 | 2019-03-23 15:00:06 +0530 | [diff] [blame] | 185 | { |
| 186 | .id = 0x66, |
| 187 | .name = "39dr", |
| 188 | }, |
Siva Durga Prasad Paladugu | 85f61a8 | 2019-07-23 11:56:17 +0530 | [diff] [blame] | 189 | { |
| 190 | .id = 0x7b, |
| 191 | .name = "48dr", |
| 192 | }, |
| 193 | { |
| 194 | .id = 0x7e, |
| 195 | .name = "49dr", |
| 196 | }, |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 197 | }; |
Siva Durga Prasad Paladugu | 8d52653 | 2017-07-25 11:51:37 +0530 | [diff] [blame] | 198 | #endif |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 199 | |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 200 | #define ZYNQMP_VERSION_SIZE 9 |
| 201 | #define ZYNQMP_PL_STATUS_BIT 9 |
Siva Durga Prasad Paladugu | 951c019 | 2018-10-26 17:47:55 +0530 | [diff] [blame] | 202 | #define ZYNQMP_IPDIS_VCU_BIT 8 |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 203 | #define ZYNQMP_PL_STATUS_MASK BIT(ZYNQMP_PL_STATUS_BIT) |
| 204 | #define ZYNQMP_CSU_VERSION_MASK ~(ZYNQMP_PL_STATUS_MASK) |
Siva Durga Prasad Paladugu | 951c019 | 2018-10-26 17:47:55 +0530 | [diff] [blame] | 205 | #define ZYNQMP_CSU_VCUDIS_VER_MASK ZYNQMP_CSU_VERSION_MASK & \ |
| 206 | ~BIT(ZYNQMP_IPDIS_VCU_BIT) |
| 207 | #define MAX_VARIANTS_EV 3 |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 208 | |
Siva Durga Prasad Paladugu | 8d52653 | 2017-07-25 11:51:37 +0530 | [diff] [blame] | 209 | #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \ |
| 210 | !defined(CONFIG_SPL_BUILD) |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 211 | static char *zynqmp_get_silicon_idcode_name(void) |
| 212 | { |
Siva Durga Prasad Paladugu | 951c019 | 2018-10-26 17:47:55 +0530 | [diff] [blame] | 213 | u32 i, id, ver, j; |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 214 | char *buf; |
| 215 | static char name[ZYNQMP_VERSION_SIZE]; |
Ibai Erkiaga | c318ecb | 2020-08-04 23:17:30 +0100 | [diff] [blame] | 216 | u32 ret_payload[PAYLOAD_ARG_CNT]; |
| 217 | |
| 218 | xilinx_pm_request(PM_GET_CHIPID, 0, 0, 0, 0, ret_payload); |
| 219 | |
| 220 | /* |
| 221 | * Firmware returns: |
| 222 | * payload[0][31:0] = status of the operation |
| 223 | * payload[1]] = IDCODE |
| 224 | * payload[2][19:0] = Version |
| 225 | * payload[2][28:20] = EXTENDED_IDCODE |
| 226 | * payload[2][29] = PL_INIT |
| 227 | */ |
| 228 | |
| 229 | /* Get IDCODE field */ |
| 230 | id = ret_payload[1]; |
| 231 | id &= ZYNQMP_CSU_IDCODE_DEVICE_CODE_MASK | ZYNQMP_CSU_IDCODE_SVD_MASK; |
| 232 | id >>= ZYNQMP_CSU_IDCODE_SVD_SHIFT; |
| 233 | |
| 234 | /* Shift silicon version info */ |
| 235 | ver = ret_payload[2] >> ZYNQMP_CSU_VERSION_EMPTY_SHIFT; |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 236 | |
Ibai Erkiaga | f44eda4 | 2020-08-04 23:17:28 +0100 | [diff] [blame] | 237 | debug("%s, ID: 0x%0X, Ver: 0x%0X\r\n", __func__, id, ver); |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 238 | |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 239 | for (i = 0; i < ARRAY_SIZE(zynqmp_devices); i++) { |
Siva Durga Prasad Paladugu | 951c019 | 2018-10-26 17:47:55 +0530 | [diff] [blame] | 240 | if (zynqmp_devices[i].id == id) { |
| 241 | if (zynqmp_devices[i].evexists && |
| 242 | !(ver & ZYNQMP_PL_STATUS_MASK)) |
| 243 | break; |
| 244 | if (zynqmp_devices[i].ver == (ver & |
| 245 | ZYNQMP_CSU_VERSION_MASK)) |
| 246 | break; |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 247 | } |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 248 | } |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 249 | |
| 250 | if (i >= ARRAY_SIZE(zynqmp_devices)) |
| 251 | return "unknown"; |
| 252 | |
Siva Durga Prasad Paladugu | 951c019 | 2018-10-26 17:47:55 +0530 | [diff] [blame] | 253 | strncat(name, "zu", 2); |
| 254 | if (!zynqmp_devices[i].evexists || |
| 255 | (ver & ZYNQMP_PL_STATUS_MASK)) { |
| 256 | strncat(name, zynqmp_devices[i].name, |
| 257 | ZYNQMP_VERSION_SIZE - 3); |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 258 | return name; |
Siva Durga Prasad Paladugu | 951c019 | 2018-10-26 17:47:55 +0530 | [diff] [blame] | 259 | } |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 260 | |
Siva Durga Prasad Paladugu | 951c019 | 2018-10-26 17:47:55 +0530 | [diff] [blame] | 261 | /* |
| 262 | * Here we are means, PL not powered up and ev variant |
| 263 | * exists. So, we need to ignore VCU disable bit(8) in |
| 264 | * version and findout if its CG or EG/EV variant. |
| 265 | */ |
| 266 | for (j = 0; j < MAX_VARIANTS_EV; j++, i++) { |
| 267 | if ((zynqmp_devices[i].ver & ~BIT(ZYNQMP_IPDIS_VCU_BIT)) == |
| 268 | (ver & ZYNQMP_CSU_VCUDIS_VER_MASK)) { |
| 269 | strncat(name, zynqmp_devices[i].name, |
| 270 | ZYNQMP_VERSION_SIZE - 3); |
| 271 | break; |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | if (j >= MAX_VARIANTS_EV) |
| 276 | return "unknown"; |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 277 | |
| 278 | if (strstr(name, "eg") || strstr(name, "ev")) { |
| 279 | buf = strstr(name, "e"); |
| 280 | *buf = '\0'; |
| 281 | } |
| 282 | |
| 283 | return name; |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 284 | } |
| 285 | #endif |
| 286 | |
Michal Simek | 8b35330 | 2017-02-07 14:32:26 +0100 | [diff] [blame] | 287 | int board_early_init_f(void) |
| 288 | { |
Michal Simek | 1a1ab5a | 2018-01-15 12:52:59 +0100 | [diff] [blame] | 289 | #if defined(CONFIG_ZYNQMP_PSU_INIT_ENABLED) |
Michal Simek | 09a7d7d | 2020-01-07 09:02:52 +0100 | [diff] [blame] | 290 | int ret; |
| 291 | |
Michal Simek | c8785f2 | 2018-01-10 11:48:48 +0100 | [diff] [blame] | 292 | ret = psu_init(); |
Michal Simek | 09a7d7d | 2020-01-07 09:02:52 +0100 | [diff] [blame] | 293 | if (ret) |
| 294 | return ret; |
Michal Simek | 1f55e57 | 2020-03-20 08:59:02 +0100 | [diff] [blame] | 295 | |
| 296 | /* Delay is required for clocks to be propagated */ |
| 297 | udelay(1000000); |
Michal Simek | e0f3610 | 2017-07-12 13:08:41 +0200 | [diff] [blame] | 298 | #endif |
| 299 | |
Michal Simek | 09a7d7d | 2020-01-07 09:02:52 +0100 | [diff] [blame] | 300 | #ifdef CONFIG_DEBUG_UART |
| 301 | /* Uart debug for sure */ |
| 302 | debug_uart_init(); |
| 303 | puts("Debug uart enabled\n"); /* or printch() */ |
| 304 | #endif |
| 305 | |
| 306 | return 0; |
Michal Simek | 8b35330 | 2017-02-07 14:32:26 +0100 | [diff] [blame] | 307 | } |
| 308 | |
Michal Simek | 4690046 | 2020-02-11 12:43:14 +0100 | [diff] [blame] | 309 | static int multi_boot(void) |
| 310 | { |
| 311 | u32 multiboot; |
| 312 | |
| 313 | multiboot = readl(&csu_base->multi_boot); |
| 314 | |
Michal Simek | c55f2d5 | 2020-05-27 12:50:33 +0200 | [diff] [blame] | 315 | printf("Multiboot:\t%d\n", multiboot); |
Michal Simek | 4690046 | 2020-02-11 12:43:14 +0100 | [diff] [blame] | 316 | |
| 317 | return 0; |
| 318 | } |
| 319 | |
Mike Looijmans | 9863e2f | 2019-10-18 07:34:13 +0200 | [diff] [blame] | 320 | #define PS_SYSMON_ANALOG_BUS_VAL 0x3210 |
| 321 | #define PS_SYSMON_ANALOG_BUS_REG 0xFFA50914 |
| 322 | |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 323 | int board_init(void) |
| 324 | { |
Michal Simek | 826d7eca | 2020-03-04 08:48:16 +0100 | [diff] [blame] | 325 | #if defined(CONFIG_ZYNQMP_FIRMWARE) |
Ibai Erkiaga | 2d9b95b | 2019-09-27 11:37:04 +0100 | [diff] [blame] | 326 | struct udevice *dev; |
| 327 | |
| 328 | uclass_get_device_by_name(UCLASS_FIRMWARE, "zynqmp-power", &dev); |
| 329 | if (!dev) |
| 330 | panic("PMU Firmware device not found - Enable it"); |
Michal Simek | 826d7eca | 2020-03-04 08:48:16 +0100 | [diff] [blame] | 331 | #endif |
Ibai Erkiaga | 2d9b95b | 2019-09-27 11:37:04 +0100 | [diff] [blame] | 332 | |
Luca Ceresoli | 23e6500 | 2019-05-21 18:06:43 +0200 | [diff] [blame] | 333 | #if defined(CONFIG_SPL_BUILD) |
| 334 | /* Check *at build time* if the filename is an non-empty string */ |
| 335 | if (sizeof(CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE) > 1) |
| 336 | zynqmp_pmufw_load_config_object(zynqmp_pm_cfg_obj, |
| 337 | zynqmp_pm_cfg_obj_size); |
| 338 | #endif |
| 339 | |
Michal Simek | fb7242d | 2015-06-22 14:31:06 +0200 | [diff] [blame] | 340 | printf("EL Level:\tEL%d\n", current_el()); |
| 341 | |
Mike Looijmans | 9863e2f | 2019-10-18 07:34:13 +0200 | [diff] [blame] | 342 | /* Bug in ROM sets wrong value in this register */ |
| 343 | writel(PS_SYSMON_ANALOG_BUS_VAL, PS_SYSMON_ANALOG_BUS_REG); |
| 344 | |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 345 | #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \ |
| 346 | !defined(CONFIG_SPL_BUILD) || (defined(CONFIG_SPL_FPGA_SUPPORT) && \ |
| 347 | defined(CONFIG_SPL_BUILD)) |
Ibai Erkiaga | e91ca7c | 2020-08-04 23:17:29 +0100 | [diff] [blame] | 348 | zynqmppl.name = zynqmp_get_silicon_idcode_name(); |
| 349 | printf("Chip ID:\t%s\n", zynqmppl.name); |
| 350 | fpga_init(); |
| 351 | fpga_add(fpga_xilinx, &zynqmppl); |
Michal Simek | bf0f9ca | 2018-04-19 15:43:38 +0200 | [diff] [blame] | 352 | #endif |
| 353 | |
Michal Simek | 4690046 | 2020-02-11 12:43:14 +0100 | [diff] [blame] | 354 | if (current_el() == 3) |
| 355 | multi_boot(); |
| 356 | |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 357 | return 0; |
| 358 | } |
| 359 | |
| 360 | int board_early_init_r(void) |
| 361 | { |
| 362 | u32 val; |
| 363 | |
Siva Durga Prasad Paladugu | 64d9000 | 2017-12-07 15:05:30 +0530 | [diff] [blame] | 364 | if (current_el() != 3) |
| 365 | return 0; |
| 366 | |
Michal Simek | 245d528 | 2017-07-12 10:32:18 +0200 | [diff] [blame] | 367 | val = readl(&crlapb_base->timestamp_ref_ctrl); |
| 368 | val &= ZYNQMP_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT; |
| 369 | |
Siva Durga Prasad Paladugu | 64d9000 | 2017-12-07 15:05:30 +0530 | [diff] [blame] | 370 | if (!val) { |
Michal Simek | c23d3f8 | 2015-11-05 08:34:35 +0100 | [diff] [blame] | 371 | val = readl(&crlapb_base->timestamp_ref_ctrl); |
| 372 | val |= ZYNQMP_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT; |
| 373 | writel(val, &crlapb_base->timestamp_ref_ctrl); |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 374 | |
Michal Simek | c23d3f8 | 2015-11-05 08:34:35 +0100 | [diff] [blame] | 375 | /* Program freq register in System counter */ |
| 376 | writel(zynqmp_get_system_timer_freq(), |
| 377 | &iou_scntr_secure->base_frequency_id_register); |
| 378 | /* And enable system counter */ |
| 379 | writel(ZYNQMP_IOU_SCNTR_COUNTER_CONTROL_REGISTER_EN, |
| 380 | &iou_scntr_secure->counter_control_register); |
| 381 | } |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 382 | return 0; |
| 383 | } |
| 384 | |
Nitin Jain | b2eb59b | 2018-02-16 12:56:17 +0530 | [diff] [blame] | 385 | unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc, |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 386 | char *const argv[]) |
Nitin Jain | b2eb59b | 2018-02-16 12:56:17 +0530 | [diff] [blame] | 387 | { |
| 388 | int ret = 0; |
| 389 | |
| 390 | if (current_el() > 1) { |
| 391 | smp_kick_all_cpus(); |
| 392 | dcache_disable(); |
| 393 | armv8_switch_to_el1(0x0, 0, 0, 0, (unsigned long)entry, |
| 394 | ES_TO_AARCH64); |
| 395 | } else { |
| 396 | printf("FAIL: current EL is not above EL1\n"); |
| 397 | ret = EINVAL; |
| 398 | } |
| 399 | return ret; |
| 400 | } |
| 401 | |
Michal Simek | 8faa66a | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 402 | #if !defined(CONFIG_SYS_SDRAM_BASE) && !defined(CONFIG_SYS_SDRAM_SIZE) |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 403 | int dram_init_banksize(void) |
Michal Simek | 8faa66a | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 404 | { |
Nitin Jain | 9bcc76f | 2018-04-20 12:30:40 +0530 | [diff] [blame] | 405 | int ret; |
| 406 | |
| 407 | ret = fdtdec_setup_memory_banksize(); |
| 408 | if (ret) |
| 409 | return ret; |
| 410 | |
| 411 | mem_map_fill(); |
| 412 | |
| 413 | return 0; |
Tom Rini | edcfdbd | 2016-12-09 07:56:54 -0500 | [diff] [blame] | 414 | } |
Michal Simek | 8faa66a | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 415 | |
Tom Rini | edcfdbd | 2016-12-09 07:56:54 -0500 | [diff] [blame] | 416 | int dram_init(void) |
| 417 | { |
Siva Durga Prasad Paladugu | b3d55ea | 2018-07-16 15:56:11 +0530 | [diff] [blame] | 418 | if (fdtdec_setup_mem_size_base() != 0) |
Nathan Rossi | ac04bfa | 2016-12-19 00:03:34 +1000 | [diff] [blame] | 419 | return -EINVAL; |
Tom Rini | edcfdbd | 2016-12-09 07:56:54 -0500 | [diff] [blame] | 420 | |
| 421 | return 0; |
Michal Simek | 8faa66a | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 422 | } |
| 423 | #else |
Nitin Jain | 9bcc76f | 2018-04-20 12:30:40 +0530 | [diff] [blame] | 424 | int dram_init_banksize(void) |
| 425 | { |
| 426 | #if defined(CONFIG_NR_DRAM_BANKS) |
| 427 | gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE; |
| 428 | gd->bd->bi_dram[0].size = get_effective_memsize(); |
| 429 | #endif |
| 430 | |
| 431 | mem_map_fill(); |
| 432 | |
| 433 | return 0; |
| 434 | } |
| 435 | |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 436 | int dram_init(void) |
| 437 | { |
Michal Simek | 1b84621 | 2018-04-11 16:12:28 +0200 | [diff] [blame] | 438 | gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE, |
| 439 | CONFIG_SYS_SDRAM_SIZE); |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 440 | |
| 441 | return 0; |
| 442 | } |
Michal Simek | 8faa66a | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 443 | #endif |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 444 | |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 445 | void reset_cpu(ulong addr) |
| 446 | { |
| 447 | } |
| 448 | |
Michal Simek | 342edfe | 2018-12-20 09:33:38 +0100 | [diff] [blame] | 449 | #if defined(CONFIG_BOARD_LATE_INIT) |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 450 | static const struct { |
| 451 | u32 bit; |
| 452 | const char *name; |
| 453 | } reset_reasons[] = { |
| 454 | { RESET_REASON_DEBUG_SYS, "DEBUG" }, |
| 455 | { RESET_REASON_SOFT, "SOFT" }, |
| 456 | { RESET_REASON_SRST, "SRST" }, |
| 457 | { RESET_REASON_PSONLY, "PS-ONLY" }, |
| 458 | { RESET_REASON_PMU, "PMU" }, |
| 459 | { RESET_REASON_INTERNAL, "INTERNAL" }, |
| 460 | { RESET_REASON_EXTERNAL, "EXTERNAL" }, |
| 461 | {} |
| 462 | }; |
| 463 | |
T Karthik Reddy | 09b6def | 2019-03-13 20:24:18 +0530 | [diff] [blame] | 464 | static int reset_reason(void) |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 465 | { |
T Karthik Reddy | 09b6def | 2019-03-13 20:24:18 +0530 | [diff] [blame] | 466 | u32 reg; |
| 467 | int i, ret; |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 468 | const char *reason = NULL; |
| 469 | |
T Karthik Reddy | 09b6def | 2019-03-13 20:24:18 +0530 | [diff] [blame] | 470 | ret = zynqmp_mmio_read((ulong)&crlapb_base->reset_reason, ®); |
| 471 | if (ret) |
| 472 | return -EINVAL; |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 473 | |
| 474 | puts("Reset reason:\t"); |
| 475 | |
| 476 | for (i = 0; i < ARRAY_SIZE(reset_reasons); i++) { |
T Karthik Reddy | 09b6def | 2019-03-13 20:24:18 +0530 | [diff] [blame] | 477 | if (reg & reset_reasons[i].bit) { |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 478 | reason = reset_reasons[i].name; |
| 479 | printf("%s ", reset_reasons[i].name); |
| 480 | break; |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | puts("\n"); |
| 485 | |
| 486 | env_set("reset_reason", reason); |
| 487 | |
Michal Simek | 4c4efde | 2020-03-23 14:02:01 +0100 | [diff] [blame] | 488 | ret = zynqmp_mmio_write((ulong)&crlapb_base->reset_reason, ~0, ~0); |
T Karthik Reddy | 09b6def | 2019-03-13 20:24:18 +0530 | [diff] [blame] | 489 | if (ret) |
| 490 | return -EINVAL; |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 491 | |
| 492 | return ret; |
| 493 | } |
| 494 | |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 495 | static int set_fdtfile(void) |
| 496 | { |
| 497 | char *compatible, *fdtfile; |
| 498 | const char *suffix = ".dtb"; |
| 499 | const char *vendor = "xilinx/"; |
Igor Lantsman | e167bac | 2020-06-24 14:33:46 +0200 | [diff] [blame] | 500 | int fdt_compat_len; |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 501 | |
| 502 | if (env_get("fdtfile")) |
| 503 | return 0; |
| 504 | |
Igor Lantsman | e167bac | 2020-06-24 14:33:46 +0200 | [diff] [blame] | 505 | compatible = (char *)fdt_getprop(gd->fdt_blob, 0, "compatible", |
| 506 | &fdt_compat_len); |
| 507 | if (compatible && fdt_compat_len) { |
| 508 | char *name; |
| 509 | |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 510 | debug("Compatible: %s\n", compatible); |
| 511 | |
Igor Lantsman | e167bac | 2020-06-24 14:33:46 +0200 | [diff] [blame] | 512 | name = strchr(compatible, ','); |
| 513 | if (!name) |
| 514 | return -EINVAL; |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 515 | |
Igor Lantsman | e167bac | 2020-06-24 14:33:46 +0200 | [diff] [blame] | 516 | name++; |
| 517 | |
| 518 | fdtfile = calloc(1, strlen(vendor) + strlen(name) + |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 519 | strlen(suffix) + 1); |
| 520 | if (!fdtfile) |
| 521 | return -ENOMEM; |
| 522 | |
Igor Lantsman | e167bac | 2020-06-24 14:33:46 +0200 | [diff] [blame] | 523 | sprintf(fdtfile, "%s%s%s", vendor, name, suffix); |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 524 | |
| 525 | env_set("fdtfile", fdtfile); |
| 526 | free(fdtfile); |
| 527 | } |
| 528 | |
| 529 | return 0; |
| 530 | } |
| 531 | |
Michal Simek | 9c91e61 | 2020-04-08 11:04:41 +0200 | [diff] [blame] | 532 | static u8 zynqmp_get_bootmode(void) |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 533 | { |
Michal Simek | 9c91e61 | 2020-04-08 11:04:41 +0200 | [diff] [blame] | 534 | u8 bootmode; |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 535 | u32 reg = 0; |
Michal Simek | 9c91e61 | 2020-04-08 11:04:41 +0200 | [diff] [blame] | 536 | int ret; |
| 537 | |
| 538 | ret = zynqmp_mmio_read((ulong)&crlapb_base->boot_mode, ®); |
| 539 | if (ret) |
| 540 | return -EINVAL; |
| 541 | |
| 542 | if (reg >> BOOT_MODE_ALT_SHIFT) |
| 543 | reg >>= BOOT_MODE_ALT_SHIFT; |
| 544 | |
| 545 | bootmode = reg & BOOT_MODES_MASK; |
| 546 | |
| 547 | return bootmode; |
| 548 | } |
| 549 | |
| 550 | int board_late_init(void) |
| 551 | { |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 552 | u8 bootmode; |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 553 | struct udevice *dev; |
| 554 | int bootseq = -1; |
| 555 | int bootseq_len = 0; |
Michal Simek | 7410b14 | 2018-04-25 11:10:34 +0200 | [diff] [blame] | 556 | int env_targets_len = 0; |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 557 | const char *mode; |
| 558 | char *new_targets; |
Siva Durga Prasad Paladugu | 245c556 | 2017-12-20 16:35:06 +0530 | [diff] [blame] | 559 | char *env_targets; |
Siva Durga Prasad Paladugu | e6fd3bb | 2017-02-21 17:58:28 +0530 | [diff] [blame] | 560 | int ret; |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 561 | |
Michal Simek | 482f549 | 2018-10-05 08:55:16 +0200 | [diff] [blame] | 562 | #if defined(CONFIG_USB_ETHER) && !defined(CONFIG_USB_GADGET_DOWNLOAD) |
| 563 | usb_ether_init(); |
| 564 | #endif |
| 565 | |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 566 | if (!(gd->flags & GD_FLG_ENV_DEFAULT)) { |
| 567 | debug("Saved variables - Skipping\n"); |
| 568 | return 0; |
| 569 | } |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 570 | |
Michal Simek | bab07b6 | 2020-07-28 12:45:47 +0200 | [diff] [blame] | 571 | if (!CONFIG_IS_ENABLED(ENV_VARS_UBOOT_RUNTIME_CONFIG)) |
| 572 | return 0; |
| 573 | |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 574 | ret = set_fdtfile(); |
| 575 | if (ret) |
| 576 | return ret; |
| 577 | |
Michal Simek | 9c91e61 | 2020-04-08 11:04:41 +0200 | [diff] [blame] | 578 | bootmode = zynqmp_get_bootmode(); |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 579 | |
Michal Simek | c5d9523 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 580 | puts("Bootmode: "); |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 581 | switch (bootmode) { |
Michal Simek | 12398ea | 2016-08-19 14:14:52 +0200 | [diff] [blame] | 582 | case USB_MODE: |
| 583 | puts("USB_MODE\n"); |
| 584 | mode = "usb"; |
Michal Simek | 4338035 | 2017-12-01 15:18:24 +0100 | [diff] [blame] | 585 | env_set("modeboot", "usb_dfu_spl"); |
Michal Simek | 12398ea | 2016-08-19 14:14:52 +0200 | [diff] [blame] | 586 | break; |
Siva Durga Prasad Paladugu | 30f0fc7 | 2015-03-13 11:10:26 +0530 | [diff] [blame] | 587 | case JTAG_MODE: |
Michal Simek | c5d9523 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 588 | puts("JTAG_MODE\n"); |
Siva Durga Prasad Paladugu | 9c44170 | 2019-06-25 17:41:09 +0530 | [diff] [blame] | 589 | mode = "jtag pxe dhcp"; |
Michal Simek | 4338035 | 2017-12-01 15:18:24 +0100 | [diff] [blame] | 590 | env_set("modeboot", "jtagboot"); |
Siva Durga Prasad Paladugu | 30f0fc7 | 2015-03-13 11:10:26 +0530 | [diff] [blame] | 591 | break; |
| 592 | case QSPI_MODE_24BIT: |
| 593 | case QSPI_MODE_32BIT: |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 594 | mode = "qspi0"; |
Michal Simek | c5d9523 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 595 | puts("QSPI_MODE\n"); |
Michal Simek | 4338035 | 2017-12-01 15:18:24 +0100 | [diff] [blame] | 596 | env_set("modeboot", "qspiboot"); |
Siva Durga Prasad Paladugu | 30f0fc7 | 2015-03-13 11:10:26 +0530 | [diff] [blame] | 597 | break; |
Michal Simek | 02d66cd | 2015-04-15 15:02:28 +0200 | [diff] [blame] | 598 | case EMMC_MODE: |
Michal Simek | df7ff0a | 2015-10-05 15:59:38 +0200 | [diff] [blame] | 599 | puts("EMMC_MODE\n"); |
T Karthik Reddy | 19735c3 | 2019-12-17 06:41:42 -0700 | [diff] [blame] | 600 | if (uclass_get_device_by_name(UCLASS_MMC, |
| 601 | "mmc@ff160000", &dev) && |
| 602 | uclass_get_device_by_name(UCLASS_MMC, |
| 603 | "sdhci@ff160000", &dev)) { |
| 604 | puts("Boot from EMMC but without SD0 enabled!\n"); |
| 605 | return -1; |
| 606 | } |
| 607 | debug("mmc0 device found at %p, seq %d\n", dev, dev->seq); |
| 608 | |
| 609 | mode = "mmc"; |
| 610 | bootseq = dev->seq; |
Michal Simek | df7ff0a | 2015-10-05 15:59:38 +0200 | [diff] [blame] | 611 | break; |
| 612 | case SD_MODE: |
Michal Simek | c5d9523 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 613 | puts("SD_MODE\n"); |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 614 | if (uclass_get_device_by_name(UCLASS_MMC, |
Siva Durga Prasad Paladugu | e91778d | 2019-01-03 15:44:24 +0530 | [diff] [blame] | 615 | "mmc@ff160000", &dev) && |
| 616 | uclass_get_device_by_name(UCLASS_MMC, |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 617 | "sdhci@ff160000", &dev)) { |
| 618 | puts("Boot from SD0 but without SD0 enabled!\n"); |
| 619 | return -1; |
| 620 | } |
| 621 | debug("mmc0 device found at %p, seq %d\n", dev, dev->seq); |
| 622 | |
| 623 | mode = "mmc"; |
| 624 | bootseq = dev->seq; |
Michal Simek | 4338035 | 2017-12-01 15:18:24 +0100 | [diff] [blame] | 625 | env_set("modeboot", "sdboot"); |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 626 | break; |
Siva Durga Prasad Paladugu | 29a77d2 | 2016-09-21 11:45:05 +0530 | [diff] [blame] | 627 | case SD1_LSHFT_MODE: |
| 628 | puts("LVL_SHFT_"); |
| 629 | /* fall through */ |
Michal Simek | 108e184 | 2015-10-05 10:51:12 +0200 | [diff] [blame] | 630 | case SD_MODE1: |
Michal Simek | c5d9523 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 631 | puts("SD_MODE1\n"); |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 632 | if (uclass_get_device_by_name(UCLASS_MMC, |
Siva Durga Prasad Paladugu | e91778d | 2019-01-03 15:44:24 +0530 | [diff] [blame] | 633 | "mmc@ff170000", &dev) && |
| 634 | uclass_get_device_by_name(UCLASS_MMC, |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 635 | "sdhci@ff170000", &dev)) { |
| 636 | puts("Boot from SD1 but without SD1 enabled!\n"); |
| 637 | return -1; |
| 638 | } |
| 639 | debug("mmc1 device found at %p, seq %d\n", dev, dev->seq); |
| 640 | |
| 641 | mode = "mmc"; |
| 642 | bootseq = dev->seq; |
Michal Simek | 4338035 | 2017-12-01 15:18:24 +0100 | [diff] [blame] | 643 | env_set("modeboot", "sdboot"); |
Michal Simek | 108e184 | 2015-10-05 10:51:12 +0200 | [diff] [blame] | 644 | break; |
| 645 | case NAND_MODE: |
Michal Simek | c5d9523 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 646 | puts("NAND_MODE\n"); |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 647 | mode = "nand0"; |
Michal Simek | 4338035 | 2017-12-01 15:18:24 +0100 | [diff] [blame] | 648 | env_set("modeboot", "nandboot"); |
Michal Simek | 108e184 | 2015-10-05 10:51:12 +0200 | [diff] [blame] | 649 | break; |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 650 | default: |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 651 | mode = ""; |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 652 | printf("Invalid Boot Mode:0x%x\n", bootmode); |
| 653 | break; |
| 654 | } |
| 655 | |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 656 | if (bootseq >= 0) { |
| 657 | bootseq_len = snprintf(NULL, 0, "%i", bootseq); |
| 658 | debug("Bootseq len: %x\n", bootseq_len); |
| 659 | } |
| 660 | |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 661 | /* |
| 662 | * One terminating char + one byte for space between mode |
| 663 | * and default boot_targets |
| 664 | */ |
Siva Durga Prasad Paladugu | 245c556 | 2017-12-20 16:35:06 +0530 | [diff] [blame] | 665 | env_targets = env_get("boot_targets"); |
Michal Simek | 7410b14 | 2018-04-25 11:10:34 +0200 | [diff] [blame] | 666 | if (env_targets) |
| 667 | env_targets_len = strlen(env_targets); |
| 668 | |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 669 | new_targets = calloc(1, strlen(mode) + env_targets_len + 2 + |
| 670 | bootseq_len); |
Michal Simek | 089b84d | 2018-06-13 09:42:41 +0200 | [diff] [blame] | 671 | if (!new_targets) |
| 672 | return -ENOMEM; |
Michal Simek | 7410b14 | 2018-04-25 11:10:34 +0200 | [diff] [blame] | 673 | |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 674 | if (bootseq >= 0) |
| 675 | sprintf(new_targets, "%s%x %s", mode, bootseq, |
| 676 | env_targets ? env_targets : ""); |
| 677 | else |
| 678 | sprintf(new_targets, "%s %s", mode, |
| 679 | env_targets ? env_targets : ""); |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 680 | |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 681 | env_set("boot_targets", new_targets); |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 682 | |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 683 | reset_reason(); |
| 684 | |
Michal Simek | 705d44a | 2020-03-31 12:39:37 +0200 | [diff] [blame] | 685 | return board_late_init_xilinx(); |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 686 | } |
Michal Simek | 342edfe | 2018-12-20 09:33:38 +0100 | [diff] [blame] | 687 | #endif |
Siva Durga Prasad Paladugu | 650e0a3 | 2015-08-04 13:01:05 +0530 | [diff] [blame] | 688 | |
| 689 | int checkboard(void) |
| 690 | { |
Michal Simek | 47ce936 | 2016-01-25 11:04:21 +0100 | [diff] [blame] | 691 | puts("Board: Xilinx ZynqMP\n"); |
Siva Durga Prasad Paladugu | 650e0a3 | 2015-08-04 13:01:05 +0530 | [diff] [blame] | 692 | return 0; |
| 693 | } |