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