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 | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 8 | #include <command.h> |
Simon Glass | 370382c | 2019-11-14 12:57:35 -0700 | [diff] [blame] | 9 | #include <cpu_func.h> |
Michal Simek | 09a7d7d | 2020-01-07 09:02:52 +0100 | [diff] [blame] | 10 | #include <debug_uart.h> |
Michal Simek | cfb3760 | 2021-07-27 16:19:18 +0200 | [diff] [blame] | 11 | #include <dfu.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 12 | #include <env.h> |
Michal Simek | 8d4a8d4 | 2020-07-30 13:37:49 +0200 | [diff] [blame] | 13 | #include <env_internal.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 14 | #include <init.h> |
Michal Simek | 97ab961 | 2021-05-31 11:03:19 +0200 | [diff] [blame] | 15 | #include <image.h> |
| 16 | #include <lmb.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 17 | #include <log.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 18 | #include <net.h> |
Michal Simek | d54b1af | 2015-09-30 17:26:55 +0200 | [diff] [blame] | 19 | #include <sata.h> |
Michal Simek | b216cc1 | 2015-07-23 13:27:40 +0200 | [diff] [blame] | 20 | #include <ahci.h> |
| 21 | #include <scsi.h> |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 22 | #include <malloc.h> |
Michal Simek | cfb3760 | 2021-07-27 16:19:18 +0200 | [diff] [blame] | 23 | #include <memalign.h> |
Michal Simek | bf0f9ca | 2018-04-19 15:43:38 +0200 | [diff] [blame] | 24 | #include <wdt.h> |
Michal Simek | c23d3f8 | 2015-11-05 08:34:35 +0100 | [diff] [blame] | 25 | #include <asm/arch/clk.h> |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 26 | #include <asm/arch/hardware.h> |
| 27 | #include <asm/arch/sys_proto.h> |
Michal Simek | f2f0864 | 2018-01-10 09:36:09 +0100 | [diff] [blame] | 28 | #include <asm/arch/psu_init_gpl.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 29 | #include <asm/cache.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 30 | #include <asm/global_data.h> |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 31 | #include <asm/io.h> |
Simon Glass | 6b9f010 | 2020-05-10 11:40:06 -0600 | [diff] [blame] | 32 | #include <asm/ptrace.h> |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 33 | #include <dm/device.h> |
Michal Simek | bf0f9ca | 2018-04-19 15:43:38 +0200 | [diff] [blame] | 34 | #include <dm/uclass.h> |
Siva Durga Prasad Paladugu | ba1f68e | 2015-08-04 13:03:26 +0530 | [diff] [blame] | 35 | #include <usb.h> |
| 36 | #include <dwc3-uboot.h> |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 37 | #include <zynqmppl.h> |
Ibai Erkiaga | c8a3efa | 2019-09-27 11:37:01 +0100 | [diff] [blame] | 38 | #include <zynqmp_firmware.h> |
Michal Simek | 76d0a77 | 2016-09-01 11:16:40 +0200 | [diff] [blame] | 39 | #include <g_dnl.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 40 | #include <linux/bitops.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 41 | #include <linux/delay.h> |
| 42 | #include <linux/sizes.h> |
Michal Simek | 705d44a | 2020-03-31 12:39:37 +0200 | [diff] [blame] | 43 | #include "../common/board.h" |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 44 | |
Luca Ceresoli | 23e6500 | 2019-05-21 18:06:43 +0200 | [diff] [blame] | 45 | #include "pm_cfg_obj.h" |
| 46 | |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 47 | #define ZYNQMP_VERSION_SIZE 7 |
Michal Simek | c702a74 | 2020-10-21 12:23:17 +0200 | [diff] [blame] | 48 | #define EFUSE_VCU_DIS_MASK 0x100 |
| 49 | #define EFUSE_VCU_DIS_SHIFT 8 |
| 50 | #define EFUSE_GPU_DIS_MASK 0x20 |
| 51 | #define EFUSE_GPU_DIS_SHIFT 5 |
| 52 | #define IDCODE2_PL_INIT_MASK 0x200 |
| 53 | #define IDCODE2_PL_INIT_SHIFT 9 |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 54 | |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 55 | DECLARE_GLOBAL_DATA_PTR; |
| 56 | |
Michal Simek | 1aab114 | 2020-09-09 14:41:56 +0200 | [diff] [blame] | 57 | #if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 58 | static xilinx_desc zynqmppl = XILINX_ZYNQMP_DESC; |
| 59 | |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 60 | enum { |
| 61 | ZYNQMP_VARIANT_EG = BIT(0U), |
| 62 | ZYNQMP_VARIANT_EV = BIT(1U), |
| 63 | ZYNQMP_VARIANT_CG = BIT(2U), |
| 64 | ZYNQMP_VARIANT_DR = BIT(3U), |
| 65 | }; |
| 66 | |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 67 | static const struct { |
Michal Simek | 6908b86 | 2017-11-06 12:55:59 +0100 | [diff] [blame] | 68 | u32 id; |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 69 | u8 device; |
| 70 | u8 variants; |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 71 | } zynqmp_devices[] = { |
| 72 | { |
Michal Simek | 40f56ad | 2022-03-30 07:51:58 +0200 | [diff] [blame] | 73 | .id = 0x04688093, |
| 74 | .device = 1, |
| 75 | .variants = ZYNQMP_VARIANT_EG, |
| 76 | }, |
| 77 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 78 | .id = 0x04711093, |
| 79 | .device = 2, |
| 80 | .variants = ZYNQMP_VARIANT_EG | ZYNQMP_VARIANT_CG, |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 81 | }, |
| 82 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 83 | .id = 0x04710093, |
| 84 | .device = 3, |
| 85 | .variants = ZYNQMP_VARIANT_EG | ZYNQMP_VARIANT_CG, |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 86 | }, |
| 87 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 88 | .id = 0x04721093, |
| 89 | .device = 4, |
| 90 | .variants = ZYNQMP_VARIANT_EG | ZYNQMP_VARIANT_CG | |
| 91 | ZYNQMP_VARIANT_EV, |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 92 | }, |
| 93 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 94 | .id = 0x04720093, |
| 95 | .device = 5, |
| 96 | .variants = ZYNQMP_VARIANT_EG | ZYNQMP_VARIANT_CG | |
| 97 | ZYNQMP_VARIANT_EV, |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 98 | }, |
| 99 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 100 | .id = 0x04739093, |
| 101 | .device = 6, |
| 102 | .variants = ZYNQMP_VARIANT_EG | ZYNQMP_VARIANT_CG, |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 103 | }, |
| 104 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 105 | .id = 0x04730093, |
| 106 | .device = 7, |
| 107 | .variants = ZYNQMP_VARIANT_EG | ZYNQMP_VARIANT_CG | |
| 108 | ZYNQMP_VARIANT_EV, |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 109 | }, |
| 110 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 111 | .id = 0x04738093, |
| 112 | .device = 9, |
Michal Simek | 3626f2c | 2020-10-02 14:42:05 +0200 | [diff] [blame] | 113 | .variants = ZYNQMP_VARIANT_EG | ZYNQMP_VARIANT_CG, |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 114 | }, |
| 115 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 116 | .id = 0x04740093, |
| 117 | .device = 11, |
| 118 | .variants = ZYNQMP_VARIANT_EG, |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 119 | }, |
| 120 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 121 | .id = 0x04750093, |
| 122 | .device = 15, |
| 123 | .variants = ZYNQMP_VARIANT_EG, |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 124 | }, |
| 125 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 126 | .id = 0x04759093, |
| 127 | .device = 17, |
| 128 | .variants = ZYNQMP_VARIANT_EG, |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 129 | }, |
| 130 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 131 | .id = 0x04758093, |
| 132 | .device = 19, |
| 133 | .variants = ZYNQMP_VARIANT_EG, |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 134 | }, |
| 135 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 136 | .id = 0x047E1093, |
| 137 | .device = 21, |
| 138 | .variants = ZYNQMP_VARIANT_DR, |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 139 | }, |
| 140 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 141 | .id = 0x047E3093, |
| 142 | .device = 23, |
| 143 | .variants = ZYNQMP_VARIANT_DR, |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 144 | }, |
| 145 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 146 | .id = 0x047E5093, |
| 147 | .device = 25, |
| 148 | .variants = ZYNQMP_VARIANT_DR, |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 149 | }, |
| 150 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 151 | .id = 0x047E4093, |
| 152 | .device = 27, |
| 153 | .variants = ZYNQMP_VARIANT_DR, |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 154 | }, |
| 155 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 156 | .id = 0x047E0093, |
| 157 | .device = 28, |
| 158 | .variants = ZYNQMP_VARIANT_DR, |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 159 | }, |
| 160 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 161 | .id = 0x047E2093, |
| 162 | .device = 29, |
| 163 | .variants = ZYNQMP_VARIANT_DR, |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 164 | }, |
Michal Simek | b510e53 | 2017-06-02 08:08:59 +0200 | [diff] [blame] | 165 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 166 | .id = 0x047E6093, |
| 167 | .device = 39, |
| 168 | .variants = ZYNQMP_VARIANT_DR, |
Michal Simek | b510e53 | 2017-06-02 08:08:59 +0200 | [diff] [blame] | 169 | }, |
| 170 | { |
Michal Simek | 3fd2ed3 | 2020-09-11 09:22:15 +0200 | [diff] [blame] | 171 | .id = 0x047FD093, |
| 172 | .device = 43, |
| 173 | .variants = ZYNQMP_VARIANT_DR, |
Michal Simek | b510e53 | 2017-06-02 08:08:59 +0200 | [diff] [blame] | 174 | }, |
| 175 | { |
Michal Simek | 3fd2ed3 | 2020-09-11 09:22:15 +0200 | [diff] [blame] | 176 | .id = 0x047F8093, |
| 177 | .device = 46, |
| 178 | .variants = ZYNQMP_VARIANT_DR, |
Michal Simek | b510e53 | 2017-06-02 08:08:59 +0200 | [diff] [blame] | 179 | }, |
| 180 | { |
Michal Simek | 3fd2ed3 | 2020-09-11 09:22:15 +0200 | [diff] [blame] | 181 | .id = 0x047FF093, |
| 182 | .device = 47, |
| 183 | .variants = ZYNQMP_VARIANT_DR, |
Michal Simek | b510e53 | 2017-06-02 08:08:59 +0200 | [diff] [blame] | 184 | }, |
| 185 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 186 | .id = 0x047FB093, |
| 187 | .device = 48, |
| 188 | .variants = ZYNQMP_VARIANT_DR, |
Michal Simek | b510e53 | 2017-06-02 08:08:59 +0200 | [diff] [blame] | 189 | }, |
| 190 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 191 | .id = 0x047FE093, |
| 192 | .device = 49, |
| 193 | .variants = ZYNQMP_VARIANT_DR, |
Siva Durga Prasad Paladugu | 85f61a8 | 2019-07-23 11:56:17 +0530 | [diff] [blame] | 194 | }, |
T Karthik Reddy | 83df2cb | 2021-05-13 07:13:25 -0600 | [diff] [blame] | 195 | { |
| 196 | .id = 0x046d0093, |
| 197 | .device = 67, |
| 198 | .variants = ZYNQMP_VARIANT_DR, |
| 199 | }, |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 200 | }; |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 201 | |
Michal Simek | 005cac0 | 2020-10-05 09:35:40 +0200 | [diff] [blame] | 202 | static const struct { |
| 203 | u32 id; |
| 204 | char *name; |
| 205 | } zynqmp_svd_devices[] = { |
| 206 | { |
| 207 | .id = 0x04714093, |
| 208 | .name = "xck24" |
| 209 | }, |
| 210 | { |
| 211 | .id = 0x04724093, |
| 212 | .name = "xck26", |
| 213 | }, |
| 214 | }; |
| 215 | |
| 216 | static char *zynqmp_detect_svd_name(u32 idcode) |
| 217 | { |
| 218 | u32 i; |
| 219 | |
| 220 | for (i = 0; i < ARRAY_SIZE(zynqmp_svd_devices); i++) { |
| 221 | if (zynqmp_svd_devices[i].id == (idcode & 0x0FFFFFFF)) |
| 222 | return zynqmp_svd_devices[i].name; |
| 223 | } |
| 224 | |
| 225 | return "unknown"; |
| 226 | } |
| 227 | |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 228 | static char *zynqmp_get_silicon_idcode_name(void) |
| 229 | { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 230 | u32 i; |
| 231 | u32 idcode, idcode2; |
Michal Simek | 051b8bc | 2020-08-05 12:41:35 +0200 | [diff] [blame] | 232 | char name[ZYNQMP_VERSION_SIZE]; |
Ibai Erkiaga | c318ecb | 2020-08-04 23:17:30 +0100 | [diff] [blame] | 233 | u32 ret_payload[PAYLOAD_ARG_CNT]; |
Michal Simek | b5c3b0d | 2020-10-07 15:13:17 +0200 | [diff] [blame] | 234 | int ret; |
Ibai Erkiaga | c318ecb | 2020-08-04 23:17:30 +0100 | [diff] [blame] | 235 | |
Michal Simek | 23c0def | 2020-10-21 12:16:02 +0200 | [diff] [blame] | 236 | ret = xilinx_pm_request(PM_GET_CHIPID, 0, 0, 0, 0, ret_payload); |
| 237 | if (ret) { |
| 238 | debug("%s: Getting chipid failed\n", __func__); |
| 239 | return "unknown"; |
| 240 | } |
Ibai Erkiaga | c318ecb | 2020-08-04 23:17:30 +0100 | [diff] [blame] | 241 | |
| 242 | /* |
| 243 | * Firmware returns: |
| 244 | * payload[0][31:0] = status of the operation |
| 245 | * payload[1]] = IDCODE |
| 246 | * payload[2][19:0] = Version |
| 247 | * payload[2][28:20] = EXTENDED_IDCODE |
| 248 | * payload[2][29] = PL_INIT |
| 249 | */ |
| 250 | |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 251 | idcode = ret_payload[1]; |
| 252 | idcode2 = ret_payload[2] >> ZYNQMP_CSU_VERSION_EMPTY_SHIFT; |
Michal Simek | c76c96f | 2020-10-21 12:16:50 +0200 | [diff] [blame] | 253 | debug("%s, IDCODE: 0x%0x, IDCODE2: 0x%0x\r\n", __func__, idcode, |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 254 | idcode2); |
Michal Simek | 50d8cef | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 255 | |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 256 | for (i = 0; i < ARRAY_SIZE(zynqmp_devices); i++) { |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 257 | if (zynqmp_devices[i].id == (idcode & 0x0FFFFFFF)) |
| 258 | break; |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 259 | } |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 260 | |
| 261 | if (i >= ARRAY_SIZE(zynqmp_devices)) |
Michal Simek | 005cac0 | 2020-10-05 09:35:40 +0200 | [diff] [blame] | 262 | return zynqmp_detect_svd_name(idcode); |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 263 | |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 264 | /* Add device prefix to the name */ |
Michal Simek | b5c3b0d | 2020-10-07 15:13:17 +0200 | [diff] [blame] | 265 | ret = snprintf(name, ZYNQMP_VERSION_SIZE, "zu%d", |
| 266 | zynqmp_devices[i].device); |
Michal Simek | d228167 | 2020-10-21 12:17:44 +0200 | [diff] [blame] | 267 | if (ret < 0) |
Michal Simek | b5c3b0d | 2020-10-07 15:13:17 +0200 | [diff] [blame] | 268 | return "unknown"; |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 269 | |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 270 | if (zynqmp_devices[i].variants & ZYNQMP_VARIANT_EV) { |
| 271 | /* Devices with EV variant might be EG/CG/EV family */ |
| 272 | if (idcode2 & IDCODE2_PL_INIT_MASK) { |
| 273 | u32 family = ((idcode2 & EFUSE_VCU_DIS_MASK) >> |
| 274 | EFUSE_VCU_DIS_SHIFT) << 1 | |
| 275 | ((idcode2 & EFUSE_GPU_DIS_MASK) >> |
| 276 | EFUSE_GPU_DIS_SHIFT); |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 277 | |
Ibai Erkiaga | 4f73618 | 2020-08-04 23:17:31 +0100 | [diff] [blame] | 278 | /* |
| 279 | * Get family name based on extended idcode values as |
| 280 | * determined on UG1087, EXTENDED_IDCODE register |
| 281 | * description |
| 282 | */ |
| 283 | switch (family) { |
| 284 | case 0x00: |
| 285 | strncat(name, "ev", 2); |
| 286 | break; |
| 287 | case 0x10: |
| 288 | strncat(name, "eg", 2); |
| 289 | break; |
| 290 | case 0x11: |
| 291 | strncat(name, "cg", 2); |
| 292 | break; |
| 293 | default: |
| 294 | /* Do not append family name*/ |
| 295 | break; |
| 296 | } |
| 297 | } else { |
| 298 | /* |
| 299 | * When PL powered down the VCU Disable efuse cannot be |
| 300 | * read. So, ignore the bit and just findout if it is CG |
| 301 | * or EG/EV variant. |
| 302 | */ |
| 303 | strncat(name, (idcode2 & EFUSE_GPU_DIS_MASK) ? "cg" : |
| 304 | "e", 2); |
| 305 | } |
| 306 | } else if (zynqmp_devices[i].variants & ZYNQMP_VARIANT_CG) { |
| 307 | /* Devices with CG variant might be EG or CG family */ |
| 308 | strncat(name, (idcode2 & EFUSE_GPU_DIS_MASK) ? "cg" : "eg", 2); |
| 309 | } else if (zynqmp_devices[i].variants & ZYNQMP_VARIANT_EG) { |
| 310 | strncat(name, "eg", 2); |
| 311 | } else if (zynqmp_devices[i].variants & ZYNQMP_VARIANT_DR) { |
| 312 | strncat(name, "dr", 2); |
| 313 | } else { |
| 314 | debug("Variant not identified\n"); |
Siva Durga Prasad Paladugu | ba2622d | 2018-03-02 16:20:10 +0530 | [diff] [blame] | 315 | } |
| 316 | |
Michal Simek | 051b8bc | 2020-08-05 12:41:35 +0200 | [diff] [blame] | 317 | return strdup(name); |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 318 | } |
| 319 | #endif |
| 320 | |
Michal Simek | e5710e3 | 2022-02-17 14:28:42 +0100 | [diff] [blame] | 321 | int __maybe_unused psu_uboot_init(void) |
Michal Simek | 8b35330 | 2017-02-07 14:32:26 +0100 | [diff] [blame] | 322 | { |
Michal Simek | 09a7d7d | 2020-01-07 09:02:52 +0100 | [diff] [blame] | 323 | int ret; |
| 324 | |
Michal Simek | c8785f2 | 2018-01-10 11:48:48 +0100 | [diff] [blame] | 325 | ret = psu_init(); |
Michal Simek | 09a7d7d | 2020-01-07 09:02:52 +0100 | [diff] [blame] | 326 | if (ret) |
| 327 | return ret; |
Michal Simek | 1f55e57 | 2020-03-20 08:59:02 +0100 | [diff] [blame] | 328 | |
Adrian Fiergolski | 8e87ecf | 2021-06-08 12:37:23 +0200 | [diff] [blame] | 329 | /* |
| 330 | * PS_SYSMON_ANALOG_BUS register determines mapping between SysMon |
| 331 | * supply sense channel to SysMon supply registers inside the IP. |
| 332 | * This register must be programmed to complete SysMon IP |
| 333 | * configuration. The default register configuration after |
| 334 | * power-up is incorrect. Hence, fix this by writing the |
| 335 | * correct value - 0x3210. |
| 336 | */ |
| 337 | writel(ZYNQMP_PS_SYSMON_ANALOG_BUS_VAL, |
| 338 | ZYNQMP_AMS_PS_SYSMON_ANALOG_BUS); |
| 339 | |
Michal Simek | 1f55e57 | 2020-03-20 08:59:02 +0100 | [diff] [blame] | 340 | /* Delay is required for clocks to be propagated */ |
| 341 | udelay(1000000); |
Michal Simek | e5710e3 | 2022-02-17 14:28:42 +0100 | [diff] [blame] | 342 | |
| 343 | return 0; |
| 344 | } |
Michal Simek | e0f3610 | 2017-07-12 13:08:41 +0200 | [diff] [blame] | 345 | |
Michal Simek | e5710e3 | 2022-02-17 14:28:42 +0100 | [diff] [blame] | 346 | #if !defined(CONFIG_SPL_BUILD) |
| 347 | # if defined(CONFIG_DEBUG_UART_BOARD_INIT) |
| 348 | void board_debug_uart_init(void) |
| 349 | { |
| 350 | # if defined(CONFIG_ZYNQMP_PSU_INIT_ENABLED) |
| 351 | psu_uboot_init(); |
| 352 | # endif |
| 353 | } |
| 354 | # endif |
Michal Simek | 09a7d7d | 2020-01-07 09:02:52 +0100 | [diff] [blame] | 355 | |
Michal Simek | e5710e3 | 2022-02-17 14:28:42 +0100 | [diff] [blame] | 356 | # if defined(CONFIG_BOARD_EARLY_INIT_F) |
| 357 | int board_early_init_f(void) |
| 358 | { |
| 359 | int ret = 0; |
| 360 | # if defined(CONFIG_ZYNQMP_PSU_INIT_ENABLED) && !defined(CONFIG_DEBUG_UART_BOARD_INIT) |
| 361 | ret = psu_uboot_init(); |
| 362 | # endif |
| 363 | return ret; |
Michal Simek | 8b35330 | 2017-02-07 14:32:26 +0100 | [diff] [blame] | 364 | } |
Michal Simek | e5710e3 | 2022-02-17 14:28:42 +0100 | [diff] [blame] | 365 | # endif |
Michal Simek | ba6fb83 | 2022-02-17 14:28:40 +0100 | [diff] [blame] | 366 | #endif |
Michal Simek | 8b35330 | 2017-02-07 14:32:26 +0100 | [diff] [blame] | 367 | |
Michal Simek | 4690046 | 2020-02-11 12:43:14 +0100 | [diff] [blame] | 368 | static int multi_boot(void) |
| 369 | { |
Michal Simek | 6aca283 | 2021-07-27 16:17:31 +0200 | [diff] [blame] | 370 | u32 multiboot = 0; |
| 371 | int ret; |
Michal Simek | 4690046 | 2020-02-11 12:43:14 +0100 | [diff] [blame] | 372 | |
Michal Simek | 6aca283 | 2021-07-27 16:17:31 +0200 | [diff] [blame] | 373 | ret = zynqmp_mmio_read((ulong)&csu_base->multi_boot, &multiboot); |
| 374 | if (ret) |
| 375 | return -EINVAL; |
Michal Simek | 4690046 | 2020-02-11 12:43:14 +0100 | [diff] [blame] | 376 | |
Michal Simek | 21e5c32 | 2021-07-27 14:05:27 +0200 | [diff] [blame] | 377 | return multiboot; |
Michal Simek | 4690046 | 2020-02-11 12:43:14 +0100 | [diff] [blame] | 378 | } |
| 379 | |
Jorge Ramirez-Ortiz | 34deca5 | 2021-10-13 15:48:00 +0200 | [diff] [blame] | 380 | #if defined(CONFIG_SPL_BUILD) |
| 381 | static void restore_jtag(void) |
| 382 | { |
| 383 | if (current_el() != 3) |
| 384 | return; |
| 385 | |
| 386 | writel(CSU_JTAG_SEC_GATE_DISABLE, &csu_base->jtag_sec); |
| 387 | writel(CSU_JTAG_DAP_ENABLE_DEBUG, &csu_base->jtag_dap_cfg); |
| 388 | writel(CSU_JTAG_CHAIN_WR_SETUP, &csu_base->jtag_chain_status_wr); |
| 389 | writel(CRLAPB_DBG_LPD_CTRL_SETUP_CLK, &crlapb_base->dbg_lpd_ctrl); |
| 390 | writel(CRLAPB_RST_LPD_DBG_RESET, &crlapb_base->rst_lpd_dbg); |
| 391 | writel(CSU_PCAP_PROG_RELEASE_PL, &csu_base->pcap_prog); |
| 392 | } |
| 393 | #endif |
| 394 | |
Jorge Ramirez-Ortiz | b0e388a | 2021-10-13 19:04:47 +0200 | [diff] [blame] | 395 | static void print_secure_boot(void) |
| 396 | { |
| 397 | u32 status = 0; |
| 398 | |
| 399 | if (zynqmp_mmio_read((ulong)&csu_base->status, &status)) |
| 400 | return; |
| 401 | |
| 402 | printf("Secure Boot:\t%sauthenticated, %sencrypted\n", |
| 403 | status & ZYNQMP_CSU_STATUS_AUTHENTICATED ? "" : "not ", |
| 404 | status & ZYNQMP_CSU_STATUS_ENCRYPTED ? "" : "not "); |
| 405 | } |
| 406 | |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 407 | int board_init(void) |
| 408 | { |
Michal Simek | 826d7eca | 2020-03-04 08:48:16 +0100 | [diff] [blame] | 409 | #if defined(CONFIG_ZYNQMP_FIRMWARE) |
Ibai Erkiaga | 2d9b95b | 2019-09-27 11:37:04 +0100 | [diff] [blame] | 410 | struct udevice *dev; |
| 411 | |
| 412 | uclass_get_device_by_name(UCLASS_FIRMWARE, "zynqmp-power", &dev); |
| 413 | if (!dev) |
| 414 | panic("PMU Firmware device not found - Enable it"); |
Michal Simek | 826d7eca | 2020-03-04 08:48:16 +0100 | [diff] [blame] | 415 | #endif |
Ibai Erkiaga | 2d9b95b | 2019-09-27 11:37:04 +0100 | [diff] [blame] | 416 | |
Luca Ceresoli | 23e6500 | 2019-05-21 18:06:43 +0200 | [diff] [blame] | 417 | #if defined(CONFIG_SPL_BUILD) |
| 418 | /* Check *at build time* if the filename is an non-empty string */ |
| 419 | if (sizeof(CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE) > 1) |
| 420 | zynqmp_pmufw_load_config_object(zynqmp_pm_cfg_obj, |
| 421 | zynqmp_pm_cfg_obj_size); |
Michal Simek | ae9dc11 | 2021-02-02 16:34:48 +0100 | [diff] [blame] | 422 | printf("Silicon version:\t%d\n", zynqmp_get_silicon_version()); |
Jorge Ramirez-Ortiz | 34deca5 | 2021-10-13 15:48:00 +0200 | [diff] [blame] | 423 | |
| 424 | /* the CSU disables the JTAG interface when secure boot is enabled */ |
Ricardo Salveti | 5b774f0 | 2021-11-04 16:28:02 -0300 | [diff] [blame] | 425 | if (CONFIG_IS_ENABLED(ZYNQMP_RESTORE_JTAG)) |
Jorge Ramirez-Ortiz | 34deca5 | 2021-10-13 15:48:00 +0200 | [diff] [blame] | 426 | restore_jtag(); |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 427 | #else |
| 428 | if (CONFIG_IS_ENABLED(DM_I2C) && CONFIG_IS_ENABLED(I2C_EEPROM)) |
| 429 | xilinx_read_eeprom(); |
Luca Ceresoli | 23e6500 | 2019-05-21 18:06:43 +0200 | [diff] [blame] | 430 | #endif |
| 431 | |
Michal Simek | fb7242d | 2015-06-22 14:31:06 +0200 | [diff] [blame] | 432 | printf("EL Level:\tEL%d\n", current_el()); |
| 433 | |
Michal Simek | 1aab114 | 2020-09-09 14:41:56 +0200 | [diff] [blame] | 434 | #if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) |
Ibai Erkiaga | e91ca7c | 2020-08-04 23:17:29 +0100 | [diff] [blame] | 435 | zynqmppl.name = zynqmp_get_silicon_idcode_name(); |
| 436 | printf("Chip ID:\t%s\n", zynqmppl.name); |
| 437 | fpga_init(); |
| 438 | fpga_add(fpga_xilinx, &zynqmppl); |
Michal Simek | bf0f9ca | 2018-04-19 15:43:38 +0200 | [diff] [blame] | 439 | #endif |
| 440 | |
Jorge Ramirez-Ortiz | b0e388a | 2021-10-13 19:04:47 +0200 | [diff] [blame] | 441 | /* display secure boot information */ |
| 442 | print_secure_boot(); |
Michal Simek | 4690046 | 2020-02-11 12:43:14 +0100 | [diff] [blame] | 443 | if (current_el() == 3) |
Michal Simek | 21e5c32 | 2021-07-27 14:05:27 +0200 | [diff] [blame] | 444 | printf("Multiboot:\t%d\n", multi_boot()); |
Michal Simek | 4690046 | 2020-02-11 12:43:14 +0100 | [diff] [blame] | 445 | |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 446 | return 0; |
| 447 | } |
| 448 | |
| 449 | int board_early_init_r(void) |
| 450 | { |
| 451 | u32 val; |
| 452 | |
Siva Durga Prasad Paladugu | 64d9000 | 2017-12-07 15:05:30 +0530 | [diff] [blame] | 453 | if (current_el() != 3) |
| 454 | return 0; |
| 455 | |
Michal Simek | 245d528 | 2017-07-12 10:32:18 +0200 | [diff] [blame] | 456 | val = readl(&crlapb_base->timestamp_ref_ctrl); |
| 457 | val &= ZYNQMP_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT; |
| 458 | |
Siva Durga Prasad Paladugu | 64d9000 | 2017-12-07 15:05:30 +0530 | [diff] [blame] | 459 | if (!val) { |
Michal Simek | c23d3f8 | 2015-11-05 08:34:35 +0100 | [diff] [blame] | 460 | val = readl(&crlapb_base->timestamp_ref_ctrl); |
| 461 | val |= ZYNQMP_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT; |
| 462 | writel(val, &crlapb_base->timestamp_ref_ctrl); |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 463 | |
Michal Simek | c23d3f8 | 2015-11-05 08:34:35 +0100 | [diff] [blame] | 464 | /* Program freq register in System counter */ |
| 465 | writel(zynqmp_get_system_timer_freq(), |
| 466 | &iou_scntr_secure->base_frequency_id_register); |
| 467 | /* And enable system counter */ |
| 468 | writel(ZYNQMP_IOU_SCNTR_COUNTER_CONTROL_REGISTER_EN, |
| 469 | &iou_scntr_secure->counter_control_register); |
| 470 | } |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 471 | return 0; |
| 472 | } |
| 473 | |
Nitin Jain | b2eb59b | 2018-02-16 12:56:17 +0530 | [diff] [blame] | 474 | unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc, |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 475 | char *const argv[]) |
Nitin Jain | b2eb59b | 2018-02-16 12:56:17 +0530 | [diff] [blame] | 476 | { |
| 477 | int ret = 0; |
| 478 | |
| 479 | if (current_el() > 1) { |
| 480 | smp_kick_all_cpus(); |
| 481 | dcache_disable(); |
| 482 | armv8_switch_to_el1(0x0, 0, 0, 0, (unsigned long)entry, |
| 483 | ES_TO_AARCH64); |
| 484 | } else { |
| 485 | printf("FAIL: current EL is not above EL1\n"); |
| 486 | ret = EINVAL; |
| 487 | } |
| 488 | return ret; |
| 489 | } |
| 490 | |
Michal Simek | 8faa66a | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 491 | #if !defined(CONFIG_SYS_SDRAM_BASE) && !defined(CONFIG_SYS_SDRAM_SIZE) |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 492 | int dram_init_banksize(void) |
Michal Simek | 8faa66a | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 493 | { |
Nitin Jain | 9bcc76f | 2018-04-20 12:30:40 +0530 | [diff] [blame] | 494 | int ret; |
| 495 | |
| 496 | ret = fdtdec_setup_memory_banksize(); |
| 497 | if (ret) |
| 498 | return ret; |
| 499 | |
| 500 | mem_map_fill(); |
| 501 | |
| 502 | return 0; |
Tom Rini | edcfdbd | 2016-12-09 07:56:54 -0500 | [diff] [blame] | 503 | } |
Michal Simek | 8faa66a | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 504 | |
Tom Rini | edcfdbd | 2016-12-09 07:56:54 -0500 | [diff] [blame] | 505 | int dram_init(void) |
| 506 | { |
Siva Durga Prasad Paladugu | b3d55ea | 2018-07-16 15:56:11 +0530 | [diff] [blame] | 507 | if (fdtdec_setup_mem_size_base() != 0) |
Nathan Rossi | ac04bfa | 2016-12-19 00:03:34 +1000 | [diff] [blame] | 508 | return -EINVAL; |
Tom Rini | edcfdbd | 2016-12-09 07:56:54 -0500 | [diff] [blame] | 509 | |
| 510 | return 0; |
Michal Simek | 8faa66a | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 511 | } |
Michal Simek | 97ab961 | 2021-05-31 11:03:19 +0200 | [diff] [blame] | 512 | |
| 513 | ulong board_get_usable_ram_top(ulong total_size) |
| 514 | { |
| 515 | phys_size_t size; |
| 516 | phys_addr_t reg; |
| 517 | struct lmb lmb; |
| 518 | |
Michal Simek | 1b8da4a | 2022-04-29 11:52:27 +0200 | [diff] [blame] | 519 | if (!total_size) |
| 520 | return gd->ram_top; |
| 521 | |
Michal Simek | f14a4f2 | 2021-08-19 11:07:59 +0200 | [diff] [blame] | 522 | if (!IS_ALIGNED((ulong)gd->fdt_blob, 0x8)) |
| 523 | panic("Not 64bit aligned DT location: %p\n", gd->fdt_blob); |
| 524 | |
Michal Simek | 97ab961 | 2021-05-31 11:03:19 +0200 | [diff] [blame] | 525 | /* found enough not-reserved memory to relocated U-Boot */ |
| 526 | lmb_init(&lmb); |
| 527 | lmb_add(&lmb, gd->ram_base, gd->ram_size); |
| 528 | boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob); |
Michal Simek | 770264e | 2021-10-21 08:58:50 +0200 | [diff] [blame] | 529 | size = ALIGN(CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE); |
Michal Simek | 97ab961 | 2021-05-31 11:03:19 +0200 | [diff] [blame] | 530 | reg = lmb_alloc(&lmb, size, MMU_SECTION_SIZE); |
| 531 | |
| 532 | if (!reg) |
| 533 | reg = gd->ram_top - size; |
| 534 | |
| 535 | return reg + size; |
| 536 | } |
Michal Simek | 8faa66a | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 537 | #else |
Nitin Jain | 9bcc76f | 2018-04-20 12:30:40 +0530 | [diff] [blame] | 538 | int dram_init_banksize(void) |
| 539 | { |
Nitin Jain | 9bcc76f | 2018-04-20 12:30:40 +0530 | [diff] [blame] | 540 | gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE; |
| 541 | gd->bd->bi_dram[0].size = get_effective_memsize(); |
Nitin Jain | 9bcc76f | 2018-04-20 12:30:40 +0530 | [diff] [blame] | 542 | |
| 543 | mem_map_fill(); |
| 544 | |
| 545 | return 0; |
| 546 | } |
| 547 | |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 548 | int dram_init(void) |
| 549 | { |
Michal Simek | 1b84621 | 2018-04-11 16:12:28 +0200 | [diff] [blame] | 550 | gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE, |
| 551 | CONFIG_SYS_SDRAM_SIZE); |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 552 | |
| 553 | return 0; |
| 554 | } |
Michal Simek | 8faa66a | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 555 | #endif |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 556 | |
Michal Simek | 2a22033 | 2021-07-13 16:39:26 +0200 | [diff] [blame] | 557 | #if !CONFIG_IS_ENABLED(SYSRESET) |
Harald Seiler | 6f14d5f | 2020-12-15 16:47:52 +0100 | [diff] [blame] | 558 | void reset_cpu(void) |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 559 | { |
| 560 | } |
Michal Simek | 2a22033 | 2021-07-13 16:39:26 +0200 | [diff] [blame] | 561 | #endif |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 562 | |
Michal Simek | 8ec3004 | 2020-08-20 10:54:45 +0200 | [diff] [blame] | 563 | static u8 __maybe_unused zynqmp_get_bootmode(void) |
| 564 | { |
| 565 | u8 bootmode; |
| 566 | u32 reg = 0; |
| 567 | int ret; |
| 568 | |
| 569 | ret = zynqmp_mmio_read((ulong)&crlapb_base->boot_mode, ®); |
| 570 | if (ret) |
| 571 | return -EINVAL; |
| 572 | |
Michal Simek | 58cc08c | 2021-07-28 12:25:49 +0200 | [diff] [blame] | 573 | debug("HW boot mode: %x\n", reg & BOOT_MODES_MASK); |
| 574 | debug("ALT boot mode: %x\n", reg >> BOOT_MODE_ALT_SHIFT); |
| 575 | |
Michal Simek | 8ec3004 | 2020-08-20 10:54:45 +0200 | [diff] [blame] | 576 | if (reg >> BOOT_MODE_ALT_SHIFT) |
| 577 | reg >>= BOOT_MODE_ALT_SHIFT; |
| 578 | |
| 579 | bootmode = reg & BOOT_MODES_MASK; |
| 580 | |
| 581 | return bootmode; |
| 582 | } |
| 583 | |
Michal Simek | 342edfe | 2018-12-20 09:33:38 +0100 | [diff] [blame] | 584 | #if defined(CONFIG_BOARD_LATE_INIT) |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 585 | static const struct { |
| 586 | u32 bit; |
| 587 | const char *name; |
| 588 | } reset_reasons[] = { |
| 589 | { RESET_REASON_DEBUG_SYS, "DEBUG" }, |
| 590 | { RESET_REASON_SOFT, "SOFT" }, |
| 591 | { RESET_REASON_SRST, "SRST" }, |
| 592 | { RESET_REASON_PSONLY, "PS-ONLY" }, |
| 593 | { RESET_REASON_PMU, "PMU" }, |
| 594 | { RESET_REASON_INTERNAL, "INTERNAL" }, |
| 595 | { RESET_REASON_EXTERNAL, "EXTERNAL" }, |
| 596 | {} |
| 597 | }; |
| 598 | |
T Karthik Reddy | 09b6def | 2019-03-13 20:24:18 +0530 | [diff] [blame] | 599 | static int reset_reason(void) |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 600 | { |
T Karthik Reddy | 09b6def | 2019-03-13 20:24:18 +0530 | [diff] [blame] | 601 | u32 reg; |
| 602 | int i, ret; |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 603 | const char *reason = NULL; |
| 604 | |
T Karthik Reddy | 09b6def | 2019-03-13 20:24:18 +0530 | [diff] [blame] | 605 | ret = zynqmp_mmio_read((ulong)&crlapb_base->reset_reason, ®); |
| 606 | if (ret) |
| 607 | return -EINVAL; |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 608 | |
| 609 | puts("Reset reason:\t"); |
| 610 | |
| 611 | for (i = 0; i < ARRAY_SIZE(reset_reasons); i++) { |
T Karthik Reddy | 09b6def | 2019-03-13 20:24:18 +0530 | [diff] [blame] | 612 | if (reg & reset_reasons[i].bit) { |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 613 | reason = reset_reasons[i].name; |
| 614 | printf("%s ", reset_reasons[i].name); |
| 615 | break; |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | puts("\n"); |
| 620 | |
| 621 | env_set("reset_reason", reason); |
| 622 | |
Michal Simek | 0954c8c | 2021-02-09 08:50:22 +0100 | [diff] [blame] | 623 | return 0; |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 624 | } |
| 625 | |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 626 | static int set_fdtfile(void) |
| 627 | { |
| 628 | char *compatible, *fdtfile; |
| 629 | const char *suffix = ".dtb"; |
| 630 | const char *vendor = "xilinx/"; |
Igor Lantsman | e167bac | 2020-06-24 14:33:46 +0200 | [diff] [blame] | 631 | int fdt_compat_len; |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 632 | |
| 633 | if (env_get("fdtfile")) |
| 634 | return 0; |
| 635 | |
Igor Lantsman | e167bac | 2020-06-24 14:33:46 +0200 | [diff] [blame] | 636 | compatible = (char *)fdt_getprop(gd->fdt_blob, 0, "compatible", |
| 637 | &fdt_compat_len); |
| 638 | if (compatible && fdt_compat_len) { |
| 639 | char *name; |
| 640 | |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 641 | debug("Compatible: %s\n", compatible); |
| 642 | |
Igor Lantsman | e167bac | 2020-06-24 14:33:46 +0200 | [diff] [blame] | 643 | name = strchr(compatible, ','); |
| 644 | if (!name) |
| 645 | return -EINVAL; |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 646 | |
Igor Lantsman | e167bac | 2020-06-24 14:33:46 +0200 | [diff] [blame] | 647 | name++; |
| 648 | |
| 649 | fdtfile = calloc(1, strlen(vendor) + strlen(name) + |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 650 | strlen(suffix) + 1); |
| 651 | if (!fdtfile) |
| 652 | return -ENOMEM; |
| 653 | |
Igor Lantsman | e167bac | 2020-06-24 14:33:46 +0200 | [diff] [blame] | 654 | sprintf(fdtfile, "%s%s%s", vendor, name, suffix); |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 655 | |
| 656 | env_set("fdtfile", fdtfile); |
| 657 | free(fdtfile); |
| 658 | } |
| 659 | |
| 660 | return 0; |
| 661 | } |
| 662 | |
Michal Simek | 9c91e61 | 2020-04-08 11:04:41 +0200 | [diff] [blame] | 663 | int board_late_init(void) |
| 664 | { |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 665 | u8 bootmode; |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 666 | struct udevice *dev; |
| 667 | int bootseq = -1; |
| 668 | int bootseq_len = 0; |
Michal Simek | 7410b14 | 2018-04-25 11:10:34 +0200 | [diff] [blame] | 669 | int env_targets_len = 0; |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 670 | const char *mode; |
| 671 | char *new_targets; |
Siva Durga Prasad Paladugu | 245c556 | 2017-12-20 16:35:06 +0530 | [diff] [blame] | 672 | char *env_targets; |
Michal Simek | 7cb4cca | 2021-10-25 10:10:52 +0200 | [diff] [blame] | 673 | int ret, multiboot; |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 674 | |
Michal Simek | 482f549 | 2018-10-05 08:55:16 +0200 | [diff] [blame] | 675 | #if defined(CONFIG_USB_ETHER) && !defined(CONFIG_USB_GADGET_DOWNLOAD) |
| 676 | usb_ether_init(); |
| 677 | #endif |
| 678 | |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 679 | if (!(gd->flags & GD_FLG_ENV_DEFAULT)) { |
| 680 | debug("Saved variables - Skipping\n"); |
| 681 | return 0; |
| 682 | } |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 683 | |
Michal Simek | bab07b6 | 2020-07-28 12:45:47 +0200 | [diff] [blame] | 684 | if (!CONFIG_IS_ENABLED(ENV_VARS_UBOOT_RUNTIME_CONFIG)) |
| 685 | return 0; |
| 686 | |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 687 | ret = set_fdtfile(); |
| 688 | if (ret) |
| 689 | return ret; |
| 690 | |
Michal Simek | 7cb4cca | 2021-10-25 10:10:52 +0200 | [diff] [blame] | 691 | multiboot = multi_boot(); |
| 692 | if (multiboot >= 0) |
| 693 | env_set_hex("multiboot", multiboot); |
| 694 | |
Michal Simek | 9c91e61 | 2020-04-08 11:04:41 +0200 | [diff] [blame] | 695 | bootmode = zynqmp_get_bootmode(); |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 696 | |
Michal Simek | c5d9523 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 697 | puts("Bootmode: "); |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 698 | switch (bootmode) { |
Michal Simek | 12398ea | 2016-08-19 14:14:52 +0200 | [diff] [blame] | 699 | case USB_MODE: |
| 700 | puts("USB_MODE\n"); |
T Karthik Reddy | 9eee8e3 | 2021-03-24 23:37:57 -0600 | [diff] [blame] | 701 | mode = "usb_dfu0 usb_dfu1"; |
Michal Simek | 4338035 | 2017-12-01 15:18:24 +0100 | [diff] [blame] | 702 | env_set("modeboot", "usb_dfu_spl"); |
Michal Simek | 12398ea | 2016-08-19 14:14:52 +0200 | [diff] [blame] | 703 | break; |
Siva Durga Prasad Paladugu | 30f0fc7 | 2015-03-13 11:10:26 +0530 | [diff] [blame] | 704 | case JTAG_MODE: |
Michal Simek | c5d9523 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 705 | puts("JTAG_MODE\n"); |
Siva Durga Prasad Paladugu | 9c44170 | 2019-06-25 17:41:09 +0530 | [diff] [blame] | 706 | mode = "jtag pxe dhcp"; |
Michal Simek | 4338035 | 2017-12-01 15:18:24 +0100 | [diff] [blame] | 707 | env_set("modeboot", "jtagboot"); |
Siva Durga Prasad Paladugu | 30f0fc7 | 2015-03-13 11:10:26 +0530 | [diff] [blame] | 708 | break; |
| 709 | case QSPI_MODE_24BIT: |
| 710 | case QSPI_MODE_32BIT: |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 711 | mode = "qspi0"; |
Michal Simek | c5d9523 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 712 | puts("QSPI_MODE\n"); |
Michal Simek | 4338035 | 2017-12-01 15:18:24 +0100 | [diff] [blame] | 713 | env_set("modeboot", "qspiboot"); |
Siva Durga Prasad Paladugu | 30f0fc7 | 2015-03-13 11:10:26 +0530 | [diff] [blame] | 714 | break; |
Michal Simek | 02d66cd | 2015-04-15 15:02:28 +0200 | [diff] [blame] | 715 | case EMMC_MODE: |
Michal Simek | df7ff0a | 2015-10-05 15:59:38 +0200 | [diff] [blame] | 716 | puts("EMMC_MODE\n"); |
T Karthik Reddy | 19735c3 | 2019-12-17 06:41:42 -0700 | [diff] [blame] | 717 | if (uclass_get_device_by_name(UCLASS_MMC, |
| 718 | "mmc@ff160000", &dev) && |
| 719 | uclass_get_device_by_name(UCLASS_MMC, |
| 720 | "sdhci@ff160000", &dev)) { |
| 721 | puts("Boot from EMMC but without SD0 enabled!\n"); |
| 722 | return -1; |
| 723 | } |
Simon Glass | 75e534b | 2020-12-16 21:20:07 -0700 | [diff] [blame] | 724 | debug("mmc0 device found at %p, seq %d\n", dev, dev_seq(dev)); |
T Karthik Reddy | 19735c3 | 2019-12-17 06:41:42 -0700 | [diff] [blame] | 725 | |
| 726 | mode = "mmc"; |
Simon Glass | 75e534b | 2020-12-16 21:20:07 -0700 | [diff] [blame] | 727 | bootseq = dev_seq(dev); |
Ashok Reddy Soma | a10be05 | 2021-09-15 08:52:17 +0200 | [diff] [blame] | 728 | env_set("modeboot", "emmcboot"); |
Michal Simek | df7ff0a | 2015-10-05 15:59:38 +0200 | [diff] [blame] | 729 | break; |
| 730 | case SD_MODE: |
Michal Simek | c5d9523 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 731 | puts("SD_MODE\n"); |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 732 | if (uclass_get_device_by_name(UCLASS_MMC, |
Siva Durga Prasad Paladugu | e91778d | 2019-01-03 15:44:24 +0530 | [diff] [blame] | 733 | "mmc@ff160000", &dev) && |
| 734 | uclass_get_device_by_name(UCLASS_MMC, |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 735 | "sdhci@ff160000", &dev)) { |
| 736 | puts("Boot from SD0 but without SD0 enabled!\n"); |
| 737 | return -1; |
| 738 | } |
Simon Glass | 75e534b | 2020-12-16 21:20:07 -0700 | [diff] [blame] | 739 | debug("mmc0 device found at %p, seq %d\n", dev, dev_seq(dev)); |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 740 | |
| 741 | mode = "mmc"; |
Simon Glass | 75e534b | 2020-12-16 21:20:07 -0700 | [diff] [blame] | 742 | bootseq = dev_seq(dev); |
Michal Simek | 4338035 | 2017-12-01 15:18:24 +0100 | [diff] [blame] | 743 | env_set("modeboot", "sdboot"); |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 744 | break; |
Siva Durga Prasad Paladugu | 29a77d2 | 2016-09-21 11:45:05 +0530 | [diff] [blame] | 745 | case SD1_LSHFT_MODE: |
| 746 | puts("LVL_SHFT_"); |
Michal Simek | 293f47b | 2021-10-18 13:30:04 +0200 | [diff] [blame] | 747 | fallthrough; |
Michal Simek | 108e184 | 2015-10-05 10:51:12 +0200 | [diff] [blame] | 748 | case SD_MODE1: |
Michal Simek | c5d9523 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 749 | puts("SD_MODE1\n"); |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 750 | if (uclass_get_device_by_name(UCLASS_MMC, |
Siva Durga Prasad Paladugu | e91778d | 2019-01-03 15:44:24 +0530 | [diff] [blame] | 751 | "mmc@ff170000", &dev) && |
| 752 | uclass_get_device_by_name(UCLASS_MMC, |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 753 | "sdhci@ff170000", &dev)) { |
| 754 | puts("Boot from SD1 but without SD1 enabled!\n"); |
| 755 | return -1; |
| 756 | } |
Simon Glass | 75e534b | 2020-12-16 21:20:07 -0700 | [diff] [blame] | 757 | debug("mmc1 device found at %p, seq %d\n", dev, dev_seq(dev)); |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 758 | |
| 759 | mode = "mmc"; |
Simon Glass | 75e534b | 2020-12-16 21:20:07 -0700 | [diff] [blame] | 760 | bootseq = dev_seq(dev); |
Michal Simek | 4338035 | 2017-12-01 15:18:24 +0100 | [diff] [blame] | 761 | env_set("modeboot", "sdboot"); |
Michal Simek | 108e184 | 2015-10-05 10:51:12 +0200 | [diff] [blame] | 762 | break; |
| 763 | case NAND_MODE: |
Michal Simek | c5d9523 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 764 | puts("NAND_MODE\n"); |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 765 | mode = "nand0"; |
Michal Simek | 4338035 | 2017-12-01 15:18:24 +0100 | [diff] [blame] | 766 | env_set("modeboot", "nandboot"); |
Michal Simek | 108e184 | 2015-10-05 10:51:12 +0200 | [diff] [blame] | 767 | break; |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 768 | default: |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 769 | mode = ""; |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 770 | printf("Invalid Boot Mode:0x%x\n", bootmode); |
| 771 | break; |
| 772 | } |
| 773 | |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 774 | if (bootseq >= 0) { |
| 775 | bootseq_len = snprintf(NULL, 0, "%i", bootseq); |
| 776 | debug("Bootseq len: %x\n", bootseq_len); |
Michal Simek | 7a117c7 | 2021-01-11 13:46:58 +0100 | [diff] [blame] | 777 | env_set_hex("bootseq", bootseq); |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 778 | } |
| 779 | |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 780 | /* |
| 781 | * One terminating char + one byte for space between mode |
| 782 | * and default boot_targets |
| 783 | */ |
Siva Durga Prasad Paladugu | 245c556 | 2017-12-20 16:35:06 +0530 | [diff] [blame] | 784 | env_targets = env_get("boot_targets"); |
Michal Simek | 7410b14 | 2018-04-25 11:10:34 +0200 | [diff] [blame] | 785 | if (env_targets) |
| 786 | env_targets_len = strlen(env_targets); |
| 787 | |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 788 | new_targets = calloc(1, strlen(mode) + env_targets_len + 2 + |
| 789 | bootseq_len); |
Michal Simek | 089b84d | 2018-06-13 09:42:41 +0200 | [diff] [blame] | 790 | if (!new_targets) |
| 791 | return -ENOMEM; |
Michal Simek | 7410b14 | 2018-04-25 11:10:34 +0200 | [diff] [blame] | 792 | |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 793 | if (bootseq >= 0) |
| 794 | sprintf(new_targets, "%s%x %s", mode, bootseq, |
| 795 | env_targets ? env_targets : ""); |
| 796 | else |
| 797 | sprintf(new_targets, "%s %s", mode, |
| 798 | env_targets ? env_targets : ""); |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 799 | |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 800 | env_set("boot_targets", new_targets); |
Michal Simek | 7748823 | 2021-07-28 12:46:39 +0200 | [diff] [blame] | 801 | free(new_targets); |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 802 | |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 803 | reset_reason(); |
| 804 | |
Michal Simek | 705d44a | 2020-03-31 12:39:37 +0200 | [diff] [blame] | 805 | return board_late_init_xilinx(); |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 806 | } |
Michal Simek | 342edfe | 2018-12-20 09:33:38 +0100 | [diff] [blame] | 807 | #endif |
Siva Durga Prasad Paladugu | 650e0a3 | 2015-08-04 13:01:05 +0530 | [diff] [blame] | 808 | |
| 809 | int checkboard(void) |
| 810 | { |
Michal Simek | 47ce936 | 2016-01-25 11:04:21 +0100 | [diff] [blame] | 811 | puts("Board: Xilinx ZynqMP\n"); |
Siva Durga Prasad Paladugu | 650e0a3 | 2015-08-04 13:01:05 +0530 | [diff] [blame] | 812 | return 0; |
| 813 | } |
Michal Simek | 8d4a8d4 | 2020-07-30 13:37:49 +0200 | [diff] [blame] | 814 | |
Michal Simek | e0026bf | 2021-05-19 15:16:19 +0200 | [diff] [blame] | 815 | int mmc_get_env_dev(void) |
| 816 | { |
| 817 | struct udevice *dev; |
| 818 | int bootseq = 0; |
| 819 | |
| 820 | switch (zynqmp_get_bootmode()) { |
| 821 | case EMMC_MODE: |
| 822 | case SD_MODE: |
| 823 | if (uclass_get_device_by_name(UCLASS_MMC, |
| 824 | "mmc@ff160000", &dev) && |
| 825 | uclass_get_device_by_name(UCLASS_MMC, |
| 826 | "sdhci@ff160000", &dev)) { |
| 827 | return -1; |
| 828 | } |
| 829 | bootseq = dev_seq(dev); |
| 830 | break; |
| 831 | case SD1_LSHFT_MODE: |
| 832 | case SD_MODE1: |
| 833 | if (uclass_get_device_by_name(UCLASS_MMC, |
| 834 | "mmc@ff170000", &dev) && |
| 835 | uclass_get_device_by_name(UCLASS_MMC, |
| 836 | "sdhci@ff170000", &dev)) { |
| 837 | return -1; |
| 838 | } |
| 839 | bootseq = dev_seq(dev); |
| 840 | break; |
| 841 | default: |
| 842 | break; |
| 843 | } |
| 844 | |
| 845 | debug("bootseq %d\n", bootseq); |
| 846 | |
| 847 | return bootseq; |
| 848 | } |
| 849 | |
Michal Simek | 8d4a8d4 | 2020-07-30 13:37:49 +0200 | [diff] [blame] | 850 | enum env_location env_get_location(enum env_operation op, int prio) |
| 851 | { |
| 852 | u32 bootmode = zynqmp_get_bootmode(); |
| 853 | |
| 854 | if (prio) |
| 855 | return ENVL_UNKNOWN; |
| 856 | |
| 857 | switch (bootmode) { |
| 858 | case EMMC_MODE: |
| 859 | case SD_MODE: |
| 860 | case SD1_LSHFT_MODE: |
| 861 | case SD_MODE1: |
| 862 | if (IS_ENABLED(CONFIG_ENV_IS_IN_FAT)) |
| 863 | return ENVL_FAT; |
| 864 | if (IS_ENABLED(CONFIG_ENV_IS_IN_EXT4)) |
| 865 | return ENVL_EXT4; |
Mike Looijmans | 682cf08 | 2021-07-02 10:28:36 +0200 | [diff] [blame] | 866 | return ENVL_NOWHERE; |
Michal Simek | 8d4a8d4 | 2020-07-30 13:37:49 +0200 | [diff] [blame] | 867 | case NAND_MODE: |
| 868 | if (IS_ENABLED(CONFIG_ENV_IS_IN_NAND)) |
| 869 | return ENVL_NAND; |
| 870 | if (IS_ENABLED(CONFIG_ENV_IS_IN_UBI)) |
| 871 | return ENVL_UBI; |
Mike Looijmans | 682cf08 | 2021-07-02 10:28:36 +0200 | [diff] [blame] | 872 | return ENVL_NOWHERE; |
Michal Simek | 8d4a8d4 | 2020-07-30 13:37:49 +0200 | [diff] [blame] | 873 | case QSPI_MODE_24BIT: |
| 874 | case QSPI_MODE_32BIT: |
| 875 | if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH)) |
| 876 | return ENVL_SPI_FLASH; |
Mike Looijmans | 682cf08 | 2021-07-02 10:28:36 +0200 | [diff] [blame] | 877 | return ENVL_NOWHERE; |
Michal Simek | 8d4a8d4 | 2020-07-30 13:37:49 +0200 | [diff] [blame] | 878 | case JTAG_MODE: |
| 879 | default: |
| 880 | return ENVL_NOWHERE; |
| 881 | } |
| 882 | } |
Michal Simek | cfb3760 | 2021-07-27 16:19:18 +0200 | [diff] [blame] | 883 | |
| 884 | #if defined(CONFIG_SET_DFU_ALT_INFO) |
| 885 | |
| 886 | #define DFU_ALT_BUF_LEN SZ_1K |
| 887 | |
| 888 | void set_dfu_alt_info(char *interface, char *devstr) |
| 889 | { |
| 890 | u8 multiboot; |
| 891 | int bootseq = 0; |
| 892 | |
| 893 | ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN); |
| 894 | |
Sughosh Ganu | ccb3646 | 2022-04-15 11:29:34 +0530 | [diff] [blame] | 895 | if (!CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) && |
| 896 | env_get("dfu_alt_info")) |
Michal Simek | cfb3760 | 2021-07-27 16:19:18 +0200 | [diff] [blame] | 897 | return; |
| 898 | |
| 899 | memset(buf, 0, sizeof(buf)); |
| 900 | |
| 901 | multiboot = multi_boot(); |
Michal Simek | 7cb4cca | 2021-10-25 10:10:52 +0200 | [diff] [blame] | 902 | if (multiboot < 0) |
| 903 | multiboot = 0; |
| 904 | |
| 905 | multiboot = env_get_hex("multiboot", multiboot); |
Michal Simek | cfb3760 | 2021-07-27 16:19:18 +0200 | [diff] [blame] | 906 | debug("Multiboot: %d\n", multiboot); |
| 907 | |
| 908 | switch (zynqmp_get_bootmode()) { |
| 909 | case EMMC_MODE: |
| 910 | case SD_MODE: |
| 911 | case SD1_LSHFT_MODE: |
| 912 | case SD_MODE1: |
| 913 | bootseq = mmc_get_env_dev(); |
| 914 | if (!multiboot) |
| 915 | snprintf(buf, DFU_ALT_BUF_LEN, |
| 916 | "mmc %d:1=boot.bin fat %d 1;" |
Michal Simek | 6910319 | 2021-10-18 14:02:15 +0200 | [diff] [blame] | 917 | "%s fat %d 1", |
| 918 | bootseq, bootseq, |
| 919 | CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, bootseq); |
Michal Simek | cfb3760 | 2021-07-27 16:19:18 +0200 | [diff] [blame] | 920 | else |
| 921 | snprintf(buf, DFU_ALT_BUF_LEN, |
| 922 | "mmc %d:1=boot%04d.bin fat %d 1;" |
Michal Simek | 6910319 | 2021-10-18 14:02:15 +0200 | [diff] [blame] | 923 | "%s fat %d 1", |
| 924 | bootseq, multiboot, bootseq, |
| 925 | CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, bootseq); |
Michal Simek | cfb3760 | 2021-07-27 16:19:18 +0200 | [diff] [blame] | 926 | break; |
| 927 | case QSPI_MODE_24BIT: |
| 928 | case QSPI_MODE_32BIT: |
| 929 | snprintf(buf, DFU_ALT_BUF_LEN, |
| 930 | "sf 0:0=boot.bin raw %x 0x1500000;" |
Michal Simek | 6910319 | 2021-10-18 14:02:15 +0200 | [diff] [blame] | 931 | "%s raw 0x%x 0x500000", |
| 932 | multiboot * SZ_32K, CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, |
| 933 | CONFIG_SYS_SPI_U_BOOT_OFFS); |
Michal Simek | cfb3760 | 2021-07-27 16:19:18 +0200 | [diff] [blame] | 934 | break; |
| 935 | default: |
| 936 | return; |
| 937 | } |
| 938 | |
| 939 | env_set("dfu_alt_info", buf); |
| 940 | puts("DFU alt info setting: done\n"); |
| 941 | } |
| 942 | #endif |