Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2014 - 2015 Xilinx, Inc. |
| 4 | * Michal Simek <michal.simek@xilinx.com> |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 8 | #include <command.h> |
Simon Glass | 370382c | 2019-11-14 12:57:35 -0700 | [diff] [blame] | 9 | #include <cpu_func.h> |
Michal Simek | 09a7d7d | 2020-01-07 09:02:52 +0100 | [diff] [blame] | 10 | #include <debug_uart.h> |
Michal Simek | cfb3760 | 2021-07-27 16:19:18 +0200 | [diff] [blame] | 11 | #include <dfu.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 12 | #include <env.h> |
Michal Simek | 8d4a8d4 | 2020-07-30 13:37:49 +0200 | [diff] [blame] | 13 | #include <env_internal.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 14 | #include <init.h> |
Michal Simek | 97ab961 | 2021-05-31 11:03:19 +0200 | [diff] [blame] | 15 | #include <image.h> |
| 16 | #include <lmb.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 17 | #include <log.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 18 | #include <net.h> |
Michal Simek | d54b1af | 2015-09-30 17:26:55 +0200 | [diff] [blame] | 19 | #include <sata.h> |
Michal Simek | b216cc1 | 2015-07-23 13:27:40 +0200 | [diff] [blame] | 20 | #include <ahci.h> |
| 21 | #include <scsi.h> |
Stefan Herbrechtsmeier | 3ff3bd4 | 2022-06-20 18:36:43 +0200 | [diff] [blame] | 22 | #include <soc.h> |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 23 | #include <malloc.h> |
Michal Simek | cfb3760 | 2021-07-27 16:19:18 +0200 | [diff] [blame] | 24 | #include <memalign.h> |
Michal Simek | bf0f9ca | 2018-04-19 15:43:38 +0200 | [diff] [blame] | 25 | #include <wdt.h> |
Michal Simek | c23d3f8 | 2015-11-05 08:34:35 +0100 | [diff] [blame] | 26 | #include <asm/arch/clk.h> |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 27 | #include <asm/arch/hardware.h> |
| 28 | #include <asm/arch/sys_proto.h> |
Michal Simek | f2f0864 | 2018-01-10 09:36:09 +0100 | [diff] [blame] | 29 | #include <asm/arch/psu_init_gpl.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 30 | #include <asm/cache.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 31 | #include <asm/global_data.h> |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 32 | #include <asm/io.h> |
Simon Glass | 6b9f010 | 2020-05-10 11:40:06 -0600 | [diff] [blame] | 33 | #include <asm/ptrace.h> |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 34 | #include <dm/device.h> |
Michal Simek | bf0f9ca | 2018-04-19 15:43:38 +0200 | [diff] [blame] | 35 | #include <dm/uclass.h> |
Siva Durga Prasad Paladugu | ba1f68e | 2015-08-04 13:03:26 +0530 | [diff] [blame] | 36 | #include <usb.h> |
| 37 | #include <dwc3-uboot.h> |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 38 | #include <zynqmppl.h> |
Ibai Erkiaga | c8a3efa | 2019-09-27 11:37:01 +0100 | [diff] [blame] | 39 | #include <zynqmp_firmware.h> |
Michal Simek | 76d0a77 | 2016-09-01 11:16:40 +0200 | [diff] [blame] | 40 | #include <g_dnl.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 41 | #include <linux/bitops.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 42 | #include <linux/delay.h> |
| 43 | #include <linux/sizes.h> |
Michal Simek | 705d44a | 2020-03-31 12:39:37 +0200 | [diff] [blame] | 44 | #include "../common/board.h" |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 45 | |
Luca Ceresoli | 23e6500 | 2019-05-21 18:06:43 +0200 | [diff] [blame] | 46 | #include "pm_cfg_obj.h" |
| 47 | |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 48 | DECLARE_GLOBAL_DATA_PTR; |
| 49 | |
Michal Simek | 1aab114 | 2020-09-09 14:41:56 +0200 | [diff] [blame] | 50 | #if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 51 | static xilinx_desc zynqmppl = XILINX_ZYNQMP_DESC; |
Michal Simek | 8111aff | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 52 | #endif |
| 53 | |
Michal Simek | e5710e3 | 2022-02-17 14:28:42 +0100 | [diff] [blame] | 54 | int __maybe_unused psu_uboot_init(void) |
Michal Simek | 8b35330 | 2017-02-07 14:32:26 +0100 | [diff] [blame] | 55 | { |
Michal Simek | 09a7d7d | 2020-01-07 09:02:52 +0100 | [diff] [blame] | 56 | int ret; |
| 57 | |
Michal Simek | c8785f2 | 2018-01-10 11:48:48 +0100 | [diff] [blame] | 58 | ret = psu_init(); |
Michal Simek | 09a7d7d | 2020-01-07 09:02:52 +0100 | [diff] [blame] | 59 | if (ret) |
| 60 | return ret; |
Michal Simek | 1f55e57 | 2020-03-20 08:59:02 +0100 | [diff] [blame] | 61 | |
Adrian Fiergolski | 8e87ecf | 2021-06-08 12:37:23 +0200 | [diff] [blame] | 62 | /* |
| 63 | * PS_SYSMON_ANALOG_BUS register determines mapping between SysMon |
| 64 | * supply sense channel to SysMon supply registers inside the IP. |
| 65 | * This register must be programmed to complete SysMon IP |
| 66 | * configuration. The default register configuration after |
| 67 | * power-up is incorrect. Hence, fix this by writing the |
| 68 | * correct value - 0x3210. |
| 69 | */ |
| 70 | writel(ZYNQMP_PS_SYSMON_ANALOG_BUS_VAL, |
| 71 | ZYNQMP_AMS_PS_SYSMON_ANALOG_BUS); |
| 72 | |
Michal Simek | 1f55e57 | 2020-03-20 08:59:02 +0100 | [diff] [blame] | 73 | /* Delay is required for clocks to be propagated */ |
| 74 | udelay(1000000); |
Michal Simek | e5710e3 | 2022-02-17 14:28:42 +0100 | [diff] [blame] | 75 | |
| 76 | return 0; |
| 77 | } |
Michal Simek | e0f3610 | 2017-07-12 13:08:41 +0200 | [diff] [blame] | 78 | |
Michal Simek | e5710e3 | 2022-02-17 14:28:42 +0100 | [diff] [blame] | 79 | #if !defined(CONFIG_SPL_BUILD) |
| 80 | # if defined(CONFIG_DEBUG_UART_BOARD_INIT) |
| 81 | void board_debug_uart_init(void) |
| 82 | { |
| 83 | # if defined(CONFIG_ZYNQMP_PSU_INIT_ENABLED) |
| 84 | psu_uboot_init(); |
| 85 | # endif |
| 86 | } |
| 87 | # endif |
Michal Simek | 09a7d7d | 2020-01-07 09:02:52 +0100 | [diff] [blame] | 88 | |
Michal Simek | e5710e3 | 2022-02-17 14:28:42 +0100 | [diff] [blame] | 89 | # if defined(CONFIG_BOARD_EARLY_INIT_F) |
| 90 | int board_early_init_f(void) |
| 91 | { |
| 92 | int ret = 0; |
| 93 | # if defined(CONFIG_ZYNQMP_PSU_INIT_ENABLED) && !defined(CONFIG_DEBUG_UART_BOARD_INIT) |
| 94 | ret = psu_uboot_init(); |
| 95 | # endif |
| 96 | return ret; |
Michal Simek | 8b35330 | 2017-02-07 14:32:26 +0100 | [diff] [blame] | 97 | } |
Michal Simek | e5710e3 | 2022-02-17 14:28:42 +0100 | [diff] [blame] | 98 | # endif |
Michal Simek | ba6fb83 | 2022-02-17 14:28:40 +0100 | [diff] [blame] | 99 | #endif |
Michal Simek | 8b35330 | 2017-02-07 14:32:26 +0100 | [diff] [blame] | 100 | |
Michal Simek | 4690046 | 2020-02-11 12:43:14 +0100 | [diff] [blame] | 101 | static int multi_boot(void) |
| 102 | { |
Michal Simek | 6aca283 | 2021-07-27 16:17:31 +0200 | [diff] [blame] | 103 | u32 multiboot = 0; |
| 104 | int ret; |
Michal Simek | 4690046 | 2020-02-11 12:43:14 +0100 | [diff] [blame] | 105 | |
Michal Simek | 6aca283 | 2021-07-27 16:17:31 +0200 | [diff] [blame] | 106 | ret = zynqmp_mmio_read((ulong)&csu_base->multi_boot, &multiboot); |
| 107 | if (ret) |
| 108 | return -EINVAL; |
Michal Simek | 4690046 | 2020-02-11 12:43:14 +0100 | [diff] [blame] | 109 | |
Michal Simek | 21e5c32 | 2021-07-27 14:05:27 +0200 | [diff] [blame] | 110 | return multiboot; |
Michal Simek | 4690046 | 2020-02-11 12:43:14 +0100 | [diff] [blame] | 111 | } |
| 112 | |
Jorge Ramirez-Ortiz | 34deca5 | 2021-10-13 15:48:00 +0200 | [diff] [blame] | 113 | #if defined(CONFIG_SPL_BUILD) |
| 114 | static void restore_jtag(void) |
| 115 | { |
| 116 | if (current_el() != 3) |
| 117 | return; |
| 118 | |
| 119 | writel(CSU_JTAG_SEC_GATE_DISABLE, &csu_base->jtag_sec); |
| 120 | writel(CSU_JTAG_DAP_ENABLE_DEBUG, &csu_base->jtag_dap_cfg); |
| 121 | writel(CSU_JTAG_CHAIN_WR_SETUP, &csu_base->jtag_chain_status_wr); |
| 122 | writel(CRLAPB_DBG_LPD_CTRL_SETUP_CLK, &crlapb_base->dbg_lpd_ctrl); |
| 123 | writel(CRLAPB_RST_LPD_DBG_RESET, &crlapb_base->rst_lpd_dbg); |
| 124 | writel(CSU_PCAP_PROG_RELEASE_PL, &csu_base->pcap_prog); |
| 125 | } |
| 126 | #endif |
| 127 | |
Jorge Ramirez-Ortiz | b0e388a | 2021-10-13 19:04:47 +0200 | [diff] [blame] | 128 | static void print_secure_boot(void) |
| 129 | { |
| 130 | u32 status = 0; |
| 131 | |
| 132 | if (zynqmp_mmio_read((ulong)&csu_base->status, &status)) |
| 133 | return; |
| 134 | |
| 135 | printf("Secure Boot:\t%sauthenticated, %sencrypted\n", |
| 136 | status & ZYNQMP_CSU_STATUS_AUTHENTICATED ? "" : "not ", |
| 137 | status & ZYNQMP_CSU_STATUS_ENCRYPTED ? "" : "not "); |
| 138 | } |
| 139 | |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 140 | int board_init(void) |
| 141 | { |
Stefan Herbrechtsmeier | 3ff3bd4 | 2022-06-20 18:36:43 +0200 | [diff] [blame] | 142 | #if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) |
| 143 | struct udevice *soc; |
| 144 | char name[SOC_MAX_STR_SIZE]; |
| 145 | int ret; |
| 146 | #endif |
Michal Simek | 826d7eca | 2020-03-04 08:48:16 +0100 | [diff] [blame] | 147 | #if defined(CONFIG_ZYNQMP_FIRMWARE) |
Ibai Erkiaga | 2d9b95b | 2019-09-27 11:37:04 +0100 | [diff] [blame] | 148 | struct udevice *dev; |
| 149 | |
| 150 | uclass_get_device_by_name(UCLASS_FIRMWARE, "zynqmp-power", &dev); |
| 151 | if (!dev) |
| 152 | panic("PMU Firmware device not found - Enable it"); |
Michal Simek | 826d7eca | 2020-03-04 08:48:16 +0100 | [diff] [blame] | 153 | #endif |
Ibai Erkiaga | 2d9b95b | 2019-09-27 11:37:04 +0100 | [diff] [blame] | 154 | |
Luca Ceresoli | 23e6500 | 2019-05-21 18:06:43 +0200 | [diff] [blame] | 155 | #if defined(CONFIG_SPL_BUILD) |
| 156 | /* Check *at build time* if the filename is an non-empty string */ |
| 157 | if (sizeof(CONFIG_ZYNQMP_SPL_PM_CFG_OBJ_FILE) > 1) |
| 158 | zynqmp_pmufw_load_config_object(zynqmp_pm_cfg_obj, |
| 159 | zynqmp_pm_cfg_obj_size); |
Michal Simek | ae9dc11 | 2021-02-02 16:34:48 +0100 | [diff] [blame] | 160 | printf("Silicon version:\t%d\n", zynqmp_get_silicon_version()); |
Jorge Ramirez-Ortiz | 34deca5 | 2021-10-13 15:48:00 +0200 | [diff] [blame] | 161 | |
| 162 | /* the CSU disables the JTAG interface when secure boot is enabled */ |
Ricardo Salveti | 5b774f0 | 2021-11-04 16:28:02 -0300 | [diff] [blame] | 163 | if (CONFIG_IS_ENABLED(ZYNQMP_RESTORE_JTAG)) |
Jorge Ramirez-Ortiz | 34deca5 | 2021-10-13 15:48:00 +0200 | [diff] [blame] | 164 | restore_jtag(); |
Michal Simek | 394ee24 | 2020-08-03 13:01:45 +0200 | [diff] [blame] | 165 | #else |
| 166 | if (CONFIG_IS_ENABLED(DM_I2C) && CONFIG_IS_ENABLED(I2C_EEPROM)) |
| 167 | xilinx_read_eeprom(); |
Luca Ceresoli | 23e6500 | 2019-05-21 18:06:43 +0200 | [diff] [blame] | 168 | #endif |
| 169 | |
Michal Simek | fb7242d | 2015-06-22 14:31:06 +0200 | [diff] [blame] | 170 | printf("EL Level:\tEL%d\n", current_el()); |
| 171 | |
Michal Simek | 1aab114 | 2020-09-09 14:41:56 +0200 | [diff] [blame] | 172 | #if CONFIG_IS_ENABLED(FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) |
Stefan Herbrechtsmeier | 3ff3bd4 | 2022-06-20 18:36:43 +0200 | [diff] [blame] | 173 | ret = soc_get(&soc); |
| 174 | if (!ret) { |
| 175 | ret = soc_get_machine(soc, name, sizeof(name)); |
| 176 | if (ret >= 0) { |
| 177 | zynqmppl.name = strdup(name); |
| 178 | fpga_init(); |
| 179 | fpga_add(fpga_xilinx, &zynqmppl); |
| 180 | } |
| 181 | } |
Michal Simek | bf0f9ca | 2018-04-19 15:43:38 +0200 | [diff] [blame] | 182 | #endif |
| 183 | |
Jorge Ramirez-Ortiz | b0e388a | 2021-10-13 19:04:47 +0200 | [diff] [blame] | 184 | /* display secure boot information */ |
| 185 | print_secure_boot(); |
Michal Simek | 4690046 | 2020-02-11 12:43:14 +0100 | [diff] [blame] | 186 | if (current_el() == 3) |
Michal Simek | 21e5c32 | 2021-07-27 14:05:27 +0200 | [diff] [blame] | 187 | printf("Multiboot:\t%d\n", multi_boot()); |
Michal Simek | 4690046 | 2020-02-11 12:43:14 +0100 | [diff] [blame] | 188 | |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 189 | return 0; |
| 190 | } |
| 191 | |
| 192 | int board_early_init_r(void) |
| 193 | { |
| 194 | u32 val; |
| 195 | |
Siva Durga Prasad Paladugu | 64d9000 | 2017-12-07 15:05:30 +0530 | [diff] [blame] | 196 | if (current_el() != 3) |
| 197 | return 0; |
| 198 | |
Michal Simek | 245d528 | 2017-07-12 10:32:18 +0200 | [diff] [blame] | 199 | val = readl(&crlapb_base->timestamp_ref_ctrl); |
| 200 | val &= ZYNQMP_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT; |
| 201 | |
Siva Durga Prasad Paladugu | 64d9000 | 2017-12-07 15:05:30 +0530 | [diff] [blame] | 202 | if (!val) { |
Michal Simek | c23d3f8 | 2015-11-05 08:34:35 +0100 | [diff] [blame] | 203 | val = readl(&crlapb_base->timestamp_ref_ctrl); |
| 204 | val |= ZYNQMP_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT; |
| 205 | writel(val, &crlapb_base->timestamp_ref_ctrl); |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 206 | |
Michal Simek | c23d3f8 | 2015-11-05 08:34:35 +0100 | [diff] [blame] | 207 | /* Program freq register in System counter */ |
| 208 | writel(zynqmp_get_system_timer_freq(), |
| 209 | &iou_scntr_secure->base_frequency_id_register); |
| 210 | /* And enable system counter */ |
| 211 | writel(ZYNQMP_IOU_SCNTR_COUNTER_CONTROL_REGISTER_EN, |
| 212 | &iou_scntr_secure->counter_control_register); |
| 213 | } |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 214 | return 0; |
| 215 | } |
| 216 | |
Nitin Jain | b2eb59b | 2018-02-16 12:56:17 +0530 | [diff] [blame] | 217 | unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc, |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 218 | char *const argv[]) |
Nitin Jain | b2eb59b | 2018-02-16 12:56:17 +0530 | [diff] [blame] | 219 | { |
| 220 | int ret = 0; |
| 221 | |
| 222 | if (current_el() > 1) { |
| 223 | smp_kick_all_cpus(); |
| 224 | dcache_disable(); |
| 225 | armv8_switch_to_el1(0x0, 0, 0, 0, (unsigned long)entry, |
| 226 | ES_TO_AARCH64); |
| 227 | } else { |
| 228 | printf("FAIL: current EL is not above EL1\n"); |
| 229 | ret = EINVAL; |
| 230 | } |
| 231 | return ret; |
| 232 | } |
| 233 | |
Michal Simek | 8faa66a | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 234 | #if !defined(CONFIG_SYS_SDRAM_BASE) && !defined(CONFIG_SYS_SDRAM_SIZE) |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 235 | int dram_init_banksize(void) |
Michal Simek | 8faa66a | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 236 | { |
Nitin Jain | 9bcc76f | 2018-04-20 12:30:40 +0530 | [diff] [blame] | 237 | int ret; |
| 238 | |
| 239 | ret = fdtdec_setup_memory_banksize(); |
| 240 | if (ret) |
| 241 | return ret; |
| 242 | |
| 243 | mem_map_fill(); |
| 244 | |
| 245 | return 0; |
Tom Rini | edcfdbd | 2016-12-09 07:56:54 -0500 | [diff] [blame] | 246 | } |
Michal Simek | 8faa66a | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 247 | |
Tom Rini | edcfdbd | 2016-12-09 07:56:54 -0500 | [diff] [blame] | 248 | int dram_init(void) |
| 249 | { |
Siva Durga Prasad Paladugu | b3d55ea | 2018-07-16 15:56:11 +0530 | [diff] [blame] | 250 | if (fdtdec_setup_mem_size_base() != 0) |
Nathan Rossi | ac04bfa | 2016-12-19 00:03:34 +1000 | [diff] [blame] | 251 | return -EINVAL; |
Tom Rini | edcfdbd | 2016-12-09 07:56:54 -0500 | [diff] [blame] | 252 | |
| 253 | return 0; |
Michal Simek | 8faa66a | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 254 | } |
Michal Simek | 97ab961 | 2021-05-31 11:03:19 +0200 | [diff] [blame] | 255 | |
Ashok Reddy Soma | 8aaae3d | 2022-07-07 10:45:37 +0200 | [diff] [blame^] | 256 | #if defined(CONFIG_LMB) |
Michal Simek | 97ab961 | 2021-05-31 11:03:19 +0200 | [diff] [blame] | 257 | ulong board_get_usable_ram_top(ulong total_size) |
| 258 | { |
| 259 | phys_size_t size; |
| 260 | phys_addr_t reg; |
| 261 | struct lmb lmb; |
| 262 | |
Michal Simek | 1b8da4a | 2022-04-29 11:52:27 +0200 | [diff] [blame] | 263 | if (!total_size) |
| 264 | return gd->ram_top; |
| 265 | |
Michal Simek | f14a4f2 | 2021-08-19 11:07:59 +0200 | [diff] [blame] | 266 | if (!IS_ALIGNED((ulong)gd->fdt_blob, 0x8)) |
| 267 | panic("Not 64bit aligned DT location: %p\n", gd->fdt_blob); |
| 268 | |
Michal Simek | 97ab961 | 2021-05-31 11:03:19 +0200 | [diff] [blame] | 269 | /* found enough not-reserved memory to relocated U-Boot */ |
| 270 | lmb_init(&lmb); |
| 271 | lmb_add(&lmb, gd->ram_base, gd->ram_size); |
| 272 | boot_fdt_add_mem_rsv_regions(&lmb, (void *)gd->fdt_blob); |
Michal Simek | 770264e | 2021-10-21 08:58:50 +0200 | [diff] [blame] | 273 | size = ALIGN(CONFIG_SYS_MALLOC_LEN + total_size, MMU_SECTION_SIZE); |
Michal Simek | 97ab961 | 2021-05-31 11:03:19 +0200 | [diff] [blame] | 274 | reg = lmb_alloc(&lmb, size, MMU_SECTION_SIZE); |
| 275 | |
| 276 | if (!reg) |
| 277 | reg = gd->ram_top - size; |
| 278 | |
| 279 | return reg + size; |
| 280 | } |
Ashok Reddy Soma | 8aaae3d | 2022-07-07 10:45:37 +0200 | [diff] [blame^] | 281 | #endif |
| 282 | |
Michal Simek | 8faa66a | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 283 | #else |
Nitin Jain | 9bcc76f | 2018-04-20 12:30:40 +0530 | [diff] [blame] | 284 | int dram_init_banksize(void) |
| 285 | { |
Nitin Jain | 9bcc76f | 2018-04-20 12:30:40 +0530 | [diff] [blame] | 286 | gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE; |
| 287 | gd->bd->bi_dram[0].size = get_effective_memsize(); |
Nitin Jain | 9bcc76f | 2018-04-20 12:30:40 +0530 | [diff] [blame] | 288 | |
| 289 | mem_map_fill(); |
| 290 | |
| 291 | return 0; |
| 292 | } |
| 293 | |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 294 | int dram_init(void) |
| 295 | { |
Michal Simek | 1b84621 | 2018-04-11 16:12:28 +0200 | [diff] [blame] | 296 | gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE, |
| 297 | CONFIG_SYS_SDRAM_SIZE); |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 298 | |
| 299 | return 0; |
| 300 | } |
Michal Simek | 8faa66a | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 301 | #endif |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 302 | |
Michal Simek | 2a22033 | 2021-07-13 16:39:26 +0200 | [diff] [blame] | 303 | #if !CONFIG_IS_ENABLED(SYSRESET) |
Harald Seiler | 6f14d5f | 2020-12-15 16:47:52 +0100 | [diff] [blame] | 304 | void reset_cpu(void) |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 305 | { |
| 306 | } |
Michal Simek | 2a22033 | 2021-07-13 16:39:26 +0200 | [diff] [blame] | 307 | #endif |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 308 | |
Michal Simek | 8ec3004 | 2020-08-20 10:54:45 +0200 | [diff] [blame] | 309 | static u8 __maybe_unused zynqmp_get_bootmode(void) |
| 310 | { |
| 311 | u8 bootmode; |
| 312 | u32 reg = 0; |
| 313 | int ret; |
| 314 | |
| 315 | ret = zynqmp_mmio_read((ulong)&crlapb_base->boot_mode, ®); |
| 316 | if (ret) |
| 317 | return -EINVAL; |
| 318 | |
Michal Simek | 58cc08c | 2021-07-28 12:25:49 +0200 | [diff] [blame] | 319 | debug("HW boot mode: %x\n", reg & BOOT_MODES_MASK); |
| 320 | debug("ALT boot mode: %x\n", reg >> BOOT_MODE_ALT_SHIFT); |
| 321 | |
Michal Simek | 8ec3004 | 2020-08-20 10:54:45 +0200 | [diff] [blame] | 322 | if (reg >> BOOT_MODE_ALT_SHIFT) |
| 323 | reg >>= BOOT_MODE_ALT_SHIFT; |
| 324 | |
| 325 | bootmode = reg & BOOT_MODES_MASK; |
| 326 | |
| 327 | return bootmode; |
| 328 | } |
| 329 | |
Michal Simek | 342edfe | 2018-12-20 09:33:38 +0100 | [diff] [blame] | 330 | #if defined(CONFIG_BOARD_LATE_INIT) |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 331 | static const struct { |
| 332 | u32 bit; |
| 333 | const char *name; |
| 334 | } reset_reasons[] = { |
| 335 | { RESET_REASON_DEBUG_SYS, "DEBUG" }, |
| 336 | { RESET_REASON_SOFT, "SOFT" }, |
| 337 | { RESET_REASON_SRST, "SRST" }, |
| 338 | { RESET_REASON_PSONLY, "PS-ONLY" }, |
| 339 | { RESET_REASON_PMU, "PMU" }, |
| 340 | { RESET_REASON_INTERNAL, "INTERNAL" }, |
| 341 | { RESET_REASON_EXTERNAL, "EXTERNAL" }, |
| 342 | {} |
| 343 | }; |
| 344 | |
T Karthik Reddy | 09b6def | 2019-03-13 20:24:18 +0530 | [diff] [blame] | 345 | static int reset_reason(void) |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 346 | { |
T Karthik Reddy | 09b6def | 2019-03-13 20:24:18 +0530 | [diff] [blame] | 347 | u32 reg; |
| 348 | int i, ret; |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 349 | const char *reason = NULL; |
| 350 | |
T Karthik Reddy | 09b6def | 2019-03-13 20:24:18 +0530 | [diff] [blame] | 351 | ret = zynqmp_mmio_read((ulong)&crlapb_base->reset_reason, ®); |
| 352 | if (ret) |
| 353 | return -EINVAL; |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 354 | |
| 355 | puts("Reset reason:\t"); |
| 356 | |
| 357 | for (i = 0; i < ARRAY_SIZE(reset_reasons); i++) { |
T Karthik Reddy | 09b6def | 2019-03-13 20:24:18 +0530 | [diff] [blame] | 358 | if (reg & reset_reasons[i].bit) { |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 359 | reason = reset_reasons[i].name; |
| 360 | printf("%s ", reset_reasons[i].name); |
| 361 | break; |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | puts("\n"); |
| 366 | |
| 367 | env_set("reset_reason", reason); |
| 368 | |
Michal Simek | 0954c8c | 2021-02-09 08:50:22 +0100 | [diff] [blame] | 369 | return 0; |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 370 | } |
| 371 | |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 372 | static int set_fdtfile(void) |
| 373 | { |
| 374 | char *compatible, *fdtfile; |
| 375 | const char *suffix = ".dtb"; |
| 376 | const char *vendor = "xilinx/"; |
Igor Lantsman | e167bac | 2020-06-24 14:33:46 +0200 | [diff] [blame] | 377 | int fdt_compat_len; |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 378 | |
| 379 | if (env_get("fdtfile")) |
| 380 | return 0; |
| 381 | |
Igor Lantsman | e167bac | 2020-06-24 14:33:46 +0200 | [diff] [blame] | 382 | compatible = (char *)fdt_getprop(gd->fdt_blob, 0, "compatible", |
| 383 | &fdt_compat_len); |
| 384 | if (compatible && fdt_compat_len) { |
| 385 | char *name; |
| 386 | |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 387 | debug("Compatible: %s\n", compatible); |
| 388 | |
Igor Lantsman | e167bac | 2020-06-24 14:33:46 +0200 | [diff] [blame] | 389 | name = strchr(compatible, ','); |
| 390 | if (!name) |
| 391 | return -EINVAL; |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 392 | |
Igor Lantsman | e167bac | 2020-06-24 14:33:46 +0200 | [diff] [blame] | 393 | name++; |
| 394 | |
| 395 | fdtfile = calloc(1, strlen(vendor) + strlen(name) + |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 396 | strlen(suffix) + 1); |
| 397 | if (!fdtfile) |
| 398 | return -ENOMEM; |
| 399 | |
Igor Lantsman | e167bac | 2020-06-24 14:33:46 +0200 | [diff] [blame] | 400 | sprintf(fdtfile, "%s%s%s", vendor, name, suffix); |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 401 | |
| 402 | env_set("fdtfile", fdtfile); |
| 403 | free(fdtfile); |
| 404 | } |
| 405 | |
| 406 | return 0; |
| 407 | } |
| 408 | |
Michal Simek | 9c91e61 | 2020-04-08 11:04:41 +0200 | [diff] [blame] | 409 | int board_late_init(void) |
| 410 | { |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 411 | u8 bootmode; |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 412 | struct udevice *dev; |
| 413 | int bootseq = -1; |
| 414 | int bootseq_len = 0; |
Michal Simek | 7410b14 | 2018-04-25 11:10:34 +0200 | [diff] [blame] | 415 | int env_targets_len = 0; |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 416 | const char *mode; |
| 417 | char *new_targets; |
Siva Durga Prasad Paladugu | 245c556 | 2017-12-20 16:35:06 +0530 | [diff] [blame] | 418 | char *env_targets; |
Michal Simek | 7cb4cca | 2021-10-25 10:10:52 +0200 | [diff] [blame] | 419 | int ret, multiboot; |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 420 | |
Michal Simek | 482f549 | 2018-10-05 08:55:16 +0200 | [diff] [blame] | 421 | #if defined(CONFIG_USB_ETHER) && !defined(CONFIG_USB_GADGET_DOWNLOAD) |
| 422 | usb_ether_init(); |
| 423 | #endif |
| 424 | |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 425 | if (!(gd->flags & GD_FLG_ENV_DEFAULT)) { |
| 426 | debug("Saved variables - Skipping\n"); |
| 427 | return 0; |
| 428 | } |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 429 | |
Michal Simek | bab07b6 | 2020-07-28 12:45:47 +0200 | [diff] [blame] | 430 | if (!CONFIG_IS_ENABLED(ENV_VARS_UBOOT_RUNTIME_CONFIG)) |
| 431 | return 0; |
| 432 | |
Michal Simek | 1ca66d7 | 2019-02-14 13:14:30 +0100 | [diff] [blame] | 433 | ret = set_fdtfile(); |
| 434 | if (ret) |
| 435 | return ret; |
| 436 | |
Michal Simek | 7cb4cca | 2021-10-25 10:10:52 +0200 | [diff] [blame] | 437 | multiboot = multi_boot(); |
| 438 | if (multiboot >= 0) |
| 439 | env_set_hex("multiboot", multiboot); |
| 440 | |
Michal Simek | 9c91e61 | 2020-04-08 11:04:41 +0200 | [diff] [blame] | 441 | bootmode = zynqmp_get_bootmode(); |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 442 | |
Michal Simek | c5d9523 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 443 | puts("Bootmode: "); |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 444 | switch (bootmode) { |
Michal Simek | 12398ea | 2016-08-19 14:14:52 +0200 | [diff] [blame] | 445 | case USB_MODE: |
| 446 | puts("USB_MODE\n"); |
T Karthik Reddy | 9eee8e3 | 2021-03-24 23:37:57 -0600 | [diff] [blame] | 447 | mode = "usb_dfu0 usb_dfu1"; |
Michal Simek | 4338035 | 2017-12-01 15:18:24 +0100 | [diff] [blame] | 448 | env_set("modeboot", "usb_dfu_spl"); |
Michal Simek | 12398ea | 2016-08-19 14:14:52 +0200 | [diff] [blame] | 449 | break; |
Siva Durga Prasad Paladugu | 30f0fc7 | 2015-03-13 11:10:26 +0530 | [diff] [blame] | 450 | case JTAG_MODE: |
Michal Simek | c5d9523 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 451 | puts("JTAG_MODE\n"); |
Siva Durga Prasad Paladugu | 9c44170 | 2019-06-25 17:41:09 +0530 | [diff] [blame] | 452 | mode = "jtag pxe dhcp"; |
Michal Simek | 4338035 | 2017-12-01 15:18:24 +0100 | [diff] [blame] | 453 | env_set("modeboot", "jtagboot"); |
Siva Durga Prasad Paladugu | 30f0fc7 | 2015-03-13 11:10:26 +0530 | [diff] [blame] | 454 | break; |
| 455 | case QSPI_MODE_24BIT: |
| 456 | case QSPI_MODE_32BIT: |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 457 | mode = "qspi0"; |
Michal Simek | c5d9523 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 458 | puts("QSPI_MODE\n"); |
Michal Simek | 4338035 | 2017-12-01 15:18:24 +0100 | [diff] [blame] | 459 | env_set("modeboot", "qspiboot"); |
Siva Durga Prasad Paladugu | 30f0fc7 | 2015-03-13 11:10:26 +0530 | [diff] [blame] | 460 | break; |
Michal Simek | 02d66cd | 2015-04-15 15:02:28 +0200 | [diff] [blame] | 461 | case EMMC_MODE: |
Michal Simek | df7ff0a | 2015-10-05 15:59:38 +0200 | [diff] [blame] | 462 | puts("EMMC_MODE\n"); |
T Karthik Reddy | 19735c3 | 2019-12-17 06:41:42 -0700 | [diff] [blame] | 463 | if (uclass_get_device_by_name(UCLASS_MMC, |
| 464 | "mmc@ff160000", &dev) && |
| 465 | uclass_get_device_by_name(UCLASS_MMC, |
| 466 | "sdhci@ff160000", &dev)) { |
| 467 | puts("Boot from EMMC but without SD0 enabled!\n"); |
| 468 | return -1; |
| 469 | } |
Simon Glass | 75e534b | 2020-12-16 21:20:07 -0700 | [diff] [blame] | 470 | debug("mmc0 device found at %p, seq %d\n", dev, dev_seq(dev)); |
T Karthik Reddy | 19735c3 | 2019-12-17 06:41:42 -0700 | [diff] [blame] | 471 | |
| 472 | mode = "mmc"; |
Simon Glass | 75e534b | 2020-12-16 21:20:07 -0700 | [diff] [blame] | 473 | bootseq = dev_seq(dev); |
Ashok Reddy Soma | a10be05 | 2021-09-15 08:52:17 +0200 | [diff] [blame] | 474 | env_set("modeboot", "emmcboot"); |
Michal Simek | df7ff0a | 2015-10-05 15:59:38 +0200 | [diff] [blame] | 475 | break; |
| 476 | case SD_MODE: |
Michal Simek | c5d9523 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 477 | puts("SD_MODE\n"); |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 478 | if (uclass_get_device_by_name(UCLASS_MMC, |
Siva Durga Prasad Paladugu | e91778d | 2019-01-03 15:44:24 +0530 | [diff] [blame] | 479 | "mmc@ff160000", &dev) && |
| 480 | uclass_get_device_by_name(UCLASS_MMC, |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 481 | "sdhci@ff160000", &dev)) { |
| 482 | puts("Boot from SD0 but without SD0 enabled!\n"); |
| 483 | return -1; |
| 484 | } |
Simon Glass | 75e534b | 2020-12-16 21:20:07 -0700 | [diff] [blame] | 485 | debug("mmc0 device found at %p, seq %d\n", dev, dev_seq(dev)); |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 486 | |
| 487 | mode = "mmc"; |
Simon Glass | 75e534b | 2020-12-16 21:20:07 -0700 | [diff] [blame] | 488 | bootseq = dev_seq(dev); |
Michal Simek | 4338035 | 2017-12-01 15:18:24 +0100 | [diff] [blame] | 489 | env_set("modeboot", "sdboot"); |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 490 | break; |
Siva Durga Prasad Paladugu | 29a77d2 | 2016-09-21 11:45:05 +0530 | [diff] [blame] | 491 | case SD1_LSHFT_MODE: |
| 492 | puts("LVL_SHFT_"); |
Michal Simek | 293f47b | 2021-10-18 13:30:04 +0200 | [diff] [blame] | 493 | fallthrough; |
Michal Simek | 108e184 | 2015-10-05 10:51:12 +0200 | [diff] [blame] | 494 | case SD_MODE1: |
Michal Simek | c5d9523 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 495 | puts("SD_MODE1\n"); |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 496 | if (uclass_get_device_by_name(UCLASS_MMC, |
Siva Durga Prasad Paladugu | e91778d | 2019-01-03 15:44:24 +0530 | [diff] [blame] | 497 | "mmc@ff170000", &dev) && |
| 498 | uclass_get_device_by_name(UCLASS_MMC, |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 499 | "sdhci@ff170000", &dev)) { |
| 500 | puts("Boot from SD1 but without SD1 enabled!\n"); |
| 501 | return -1; |
| 502 | } |
Simon Glass | 75e534b | 2020-12-16 21:20:07 -0700 | [diff] [blame] | 503 | debug("mmc1 device found at %p, seq %d\n", dev, dev_seq(dev)); |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 504 | |
| 505 | mode = "mmc"; |
Simon Glass | 75e534b | 2020-12-16 21:20:07 -0700 | [diff] [blame] | 506 | bootseq = dev_seq(dev); |
Michal Simek | 4338035 | 2017-12-01 15:18:24 +0100 | [diff] [blame] | 507 | env_set("modeboot", "sdboot"); |
Michal Simek | 108e184 | 2015-10-05 10:51:12 +0200 | [diff] [blame] | 508 | break; |
| 509 | case NAND_MODE: |
Michal Simek | c5d9523 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 510 | puts("NAND_MODE\n"); |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 511 | mode = "nand0"; |
Michal Simek | 4338035 | 2017-12-01 15:18:24 +0100 | [diff] [blame] | 512 | env_set("modeboot", "nandboot"); |
Michal Simek | 108e184 | 2015-10-05 10:51:12 +0200 | [diff] [blame] | 513 | break; |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 514 | default: |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 515 | mode = ""; |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 516 | printf("Invalid Boot Mode:0x%x\n", bootmode); |
| 517 | break; |
| 518 | } |
| 519 | |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 520 | if (bootseq >= 0) { |
| 521 | bootseq_len = snprintf(NULL, 0, "%i", bootseq); |
| 522 | debug("Bootseq len: %x\n", bootseq_len); |
Michal Simek | 7a117c7 | 2021-01-11 13:46:58 +0100 | [diff] [blame] | 523 | env_set_hex("bootseq", bootseq); |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 524 | } |
| 525 | |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 526 | /* |
| 527 | * One terminating char + one byte for space between mode |
| 528 | * and default boot_targets |
| 529 | */ |
Siva Durga Prasad Paladugu | 245c556 | 2017-12-20 16:35:06 +0530 | [diff] [blame] | 530 | env_targets = env_get("boot_targets"); |
Michal Simek | 7410b14 | 2018-04-25 11:10:34 +0200 | [diff] [blame] | 531 | if (env_targets) |
| 532 | env_targets_len = strlen(env_targets); |
| 533 | |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 534 | new_targets = calloc(1, strlen(mode) + env_targets_len + 2 + |
| 535 | bootseq_len); |
Michal Simek | 089b84d | 2018-06-13 09:42:41 +0200 | [diff] [blame] | 536 | if (!new_targets) |
| 537 | return -ENOMEM; |
Michal Simek | 7410b14 | 2018-04-25 11:10:34 +0200 | [diff] [blame] | 538 | |
Michal Simek | f183a98 | 2018-04-25 11:20:43 +0200 | [diff] [blame] | 539 | if (bootseq >= 0) |
| 540 | sprintf(new_targets, "%s%x %s", mode, bootseq, |
| 541 | env_targets ? env_targets : ""); |
| 542 | else |
| 543 | sprintf(new_targets, "%s %s", mode, |
| 544 | env_targets ? env_targets : ""); |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 545 | |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 546 | env_set("boot_targets", new_targets); |
Michal Simek | 7748823 | 2021-07-28 12:46:39 +0200 | [diff] [blame] | 547 | free(new_targets); |
Michal Simek | ecfb6dc | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 548 | |
Michal Simek | 29b9b71 | 2018-05-17 14:06:06 +0200 | [diff] [blame] | 549 | reset_reason(); |
| 550 | |
Michal Simek | 705d44a | 2020-03-31 12:39:37 +0200 | [diff] [blame] | 551 | return board_late_init_xilinx(); |
Michal Simek | 04b7e62 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 552 | } |
Michal Simek | 342edfe | 2018-12-20 09:33:38 +0100 | [diff] [blame] | 553 | #endif |
Siva Durga Prasad Paladugu | 650e0a3 | 2015-08-04 13:01:05 +0530 | [diff] [blame] | 554 | |
| 555 | int checkboard(void) |
| 556 | { |
Michal Simek | 47ce936 | 2016-01-25 11:04:21 +0100 | [diff] [blame] | 557 | puts("Board: Xilinx ZynqMP\n"); |
Siva Durga Prasad Paladugu | 650e0a3 | 2015-08-04 13:01:05 +0530 | [diff] [blame] | 558 | return 0; |
| 559 | } |
Michal Simek | 8d4a8d4 | 2020-07-30 13:37:49 +0200 | [diff] [blame] | 560 | |
Michal Simek | e0026bf | 2021-05-19 15:16:19 +0200 | [diff] [blame] | 561 | int mmc_get_env_dev(void) |
| 562 | { |
| 563 | struct udevice *dev; |
| 564 | int bootseq = 0; |
| 565 | |
| 566 | switch (zynqmp_get_bootmode()) { |
| 567 | case EMMC_MODE: |
| 568 | case SD_MODE: |
| 569 | if (uclass_get_device_by_name(UCLASS_MMC, |
| 570 | "mmc@ff160000", &dev) && |
| 571 | uclass_get_device_by_name(UCLASS_MMC, |
| 572 | "sdhci@ff160000", &dev)) { |
| 573 | return -1; |
| 574 | } |
| 575 | bootseq = dev_seq(dev); |
| 576 | break; |
| 577 | case SD1_LSHFT_MODE: |
| 578 | case SD_MODE1: |
| 579 | if (uclass_get_device_by_name(UCLASS_MMC, |
| 580 | "mmc@ff170000", &dev) && |
| 581 | uclass_get_device_by_name(UCLASS_MMC, |
| 582 | "sdhci@ff170000", &dev)) { |
| 583 | return -1; |
| 584 | } |
| 585 | bootseq = dev_seq(dev); |
| 586 | break; |
| 587 | default: |
| 588 | break; |
| 589 | } |
| 590 | |
| 591 | debug("bootseq %d\n", bootseq); |
| 592 | |
| 593 | return bootseq; |
| 594 | } |
| 595 | |
Michal Simek | 8d4a8d4 | 2020-07-30 13:37:49 +0200 | [diff] [blame] | 596 | enum env_location env_get_location(enum env_operation op, int prio) |
| 597 | { |
| 598 | u32 bootmode = zynqmp_get_bootmode(); |
| 599 | |
| 600 | if (prio) |
| 601 | return ENVL_UNKNOWN; |
| 602 | |
| 603 | switch (bootmode) { |
| 604 | case EMMC_MODE: |
| 605 | case SD_MODE: |
| 606 | case SD1_LSHFT_MODE: |
| 607 | case SD_MODE1: |
| 608 | if (IS_ENABLED(CONFIG_ENV_IS_IN_FAT)) |
| 609 | return ENVL_FAT; |
| 610 | if (IS_ENABLED(CONFIG_ENV_IS_IN_EXT4)) |
| 611 | return ENVL_EXT4; |
Mike Looijmans | 682cf08 | 2021-07-02 10:28:36 +0200 | [diff] [blame] | 612 | return ENVL_NOWHERE; |
Michal Simek | 8d4a8d4 | 2020-07-30 13:37:49 +0200 | [diff] [blame] | 613 | case NAND_MODE: |
| 614 | if (IS_ENABLED(CONFIG_ENV_IS_IN_NAND)) |
| 615 | return ENVL_NAND; |
| 616 | if (IS_ENABLED(CONFIG_ENV_IS_IN_UBI)) |
| 617 | return ENVL_UBI; |
Mike Looijmans | 682cf08 | 2021-07-02 10:28:36 +0200 | [diff] [blame] | 618 | return ENVL_NOWHERE; |
Michal Simek | 8d4a8d4 | 2020-07-30 13:37:49 +0200 | [diff] [blame] | 619 | case QSPI_MODE_24BIT: |
| 620 | case QSPI_MODE_32BIT: |
| 621 | if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH)) |
| 622 | return ENVL_SPI_FLASH; |
Mike Looijmans | 682cf08 | 2021-07-02 10:28:36 +0200 | [diff] [blame] | 623 | return ENVL_NOWHERE; |
Michal Simek | 8d4a8d4 | 2020-07-30 13:37:49 +0200 | [diff] [blame] | 624 | case JTAG_MODE: |
| 625 | default: |
| 626 | return ENVL_NOWHERE; |
| 627 | } |
| 628 | } |
Michal Simek | cfb3760 | 2021-07-27 16:19:18 +0200 | [diff] [blame] | 629 | |
| 630 | #if defined(CONFIG_SET_DFU_ALT_INFO) |
| 631 | |
| 632 | #define DFU_ALT_BUF_LEN SZ_1K |
| 633 | |
| 634 | void set_dfu_alt_info(char *interface, char *devstr) |
| 635 | { |
| 636 | u8 multiboot; |
| 637 | int bootseq = 0; |
| 638 | |
| 639 | ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN); |
| 640 | |
Sughosh Ganu | ccb3646 | 2022-04-15 11:29:34 +0530 | [diff] [blame] | 641 | if (!CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) && |
| 642 | env_get("dfu_alt_info")) |
Michal Simek | cfb3760 | 2021-07-27 16:19:18 +0200 | [diff] [blame] | 643 | return; |
| 644 | |
| 645 | memset(buf, 0, sizeof(buf)); |
| 646 | |
| 647 | multiboot = multi_boot(); |
Michal Simek | 7cb4cca | 2021-10-25 10:10:52 +0200 | [diff] [blame] | 648 | if (multiboot < 0) |
| 649 | multiboot = 0; |
| 650 | |
| 651 | multiboot = env_get_hex("multiboot", multiboot); |
Michal Simek | cfb3760 | 2021-07-27 16:19:18 +0200 | [diff] [blame] | 652 | debug("Multiboot: %d\n", multiboot); |
| 653 | |
| 654 | switch (zynqmp_get_bootmode()) { |
| 655 | case EMMC_MODE: |
| 656 | case SD_MODE: |
| 657 | case SD1_LSHFT_MODE: |
| 658 | case SD_MODE1: |
| 659 | bootseq = mmc_get_env_dev(); |
| 660 | if (!multiboot) |
| 661 | snprintf(buf, DFU_ALT_BUF_LEN, |
| 662 | "mmc %d:1=boot.bin fat %d 1;" |
Michal Simek | 6910319 | 2021-10-18 14:02:15 +0200 | [diff] [blame] | 663 | "%s fat %d 1", |
| 664 | bootseq, bootseq, |
| 665 | CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, bootseq); |
Michal Simek | cfb3760 | 2021-07-27 16:19:18 +0200 | [diff] [blame] | 666 | else |
| 667 | snprintf(buf, DFU_ALT_BUF_LEN, |
| 668 | "mmc %d:1=boot%04d.bin fat %d 1;" |
Michal Simek | 6910319 | 2021-10-18 14:02:15 +0200 | [diff] [blame] | 669 | "%s fat %d 1", |
| 670 | bootseq, multiboot, bootseq, |
| 671 | CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, bootseq); |
Michal Simek | cfb3760 | 2021-07-27 16:19:18 +0200 | [diff] [blame] | 672 | break; |
Stefan Herbrechtsmeier | fb027cd | 2022-06-20 18:36:46 +0200 | [diff] [blame] | 673 | #if defined(CONFIG_SYS_SPI_U_BOOT_OFFS) |
Michal Simek | cfb3760 | 2021-07-27 16:19:18 +0200 | [diff] [blame] | 674 | case QSPI_MODE_24BIT: |
| 675 | case QSPI_MODE_32BIT: |
| 676 | snprintf(buf, DFU_ALT_BUF_LEN, |
| 677 | "sf 0:0=boot.bin raw %x 0x1500000;" |
Michal Simek | 6910319 | 2021-10-18 14:02:15 +0200 | [diff] [blame] | 678 | "%s raw 0x%x 0x500000", |
| 679 | multiboot * SZ_32K, CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, |
| 680 | CONFIG_SYS_SPI_U_BOOT_OFFS); |
Michal Simek | cfb3760 | 2021-07-27 16:19:18 +0200 | [diff] [blame] | 681 | break; |
Stefan Herbrechtsmeier | fb027cd | 2022-06-20 18:36:46 +0200 | [diff] [blame] | 682 | #endif |
Michal Simek | cfb3760 | 2021-07-27 16:19:18 +0200 | [diff] [blame] | 683 | default: |
| 684 | return; |
| 685 | } |
| 686 | |
| 687 | env_set("dfu_alt_info", buf); |
| 688 | puts("DFU alt info setting: done\n"); |
| 689 | } |
| 690 | #endif |