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