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