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