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