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