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