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