]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
arm64: versal2: Read and show multiboot value
authorMichal Simek <michal.simek@amd.com>
Thu, 27 Nov 2025 08:28:46 +0000 (09:28 +0100)
committerMichal Simek <michal.simek@amd.com>
Fri, 19 Dec 2025 07:25:27 +0000 (08:25 +0100)
SOC can boot from different boot medias and also different offsets that's
why by default show multiboot value to be aware which image system is
booting out of. It is especially useful for systems with A/B update
enabled.
Also limit zynqmp_pm_get_pmc_multi_boot_reg() usage only for Versal and
Versal Gen 2.

Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/fd7564ce2f51d965c273e939e98de01beb92e6f5.1764232124.git.michal.simek@amd.com
arch/arm/mach-versal2/include/mach/hardware.h
board/amd/versal2/board.c
drivers/firmware/firmware-zynqmp.c

index 7ca2bbb7550fffb7d2b72569770309825557bf9b..81a0df893574cac2ec285c20785cd3cdc3c46a17 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Copyright (C) 2016 - 2022, Xilinx, Inc.
- * Copyright (C) 2022 - 2024, Advanced Micro Devices, Inc.
+ * Copyright (C) 2022 - 2025, Advanced Micro Devices, Inc.
  */
 
 #ifndef __ASSEMBLY__
@@ -73,6 +73,8 @@ struct crp_regs {
 #define JTAG_MODE      0x00000000
 #define BOOT_MODE_USE_ALT      0x100
 #define BOOT_MODE_ALT_SHIFT    12
+#define PMC_MULTI_BOOT_REG     0xF1110004
+#define PMC_MULTI_BOOT_MASK    0x1FFF
 
 enum versal2_platform {
        VERSAL2_SILICON = 0,
index 7d91d288d2edcd1aafd86524c541bb8493c3e761..1fd05a1157abf4a1ce3a21cb54d331cd73ed8be5 100644 (file)
@@ -21,6 +21,7 @@
 #include <dm/device.h>
 #include <dm/uclass.h>
 #include <versalpl.h>
+#include <zynqmp_firmware.h>
 #include "../../xilinx/common/board.h"
 
 #include <linux/bitfield.h>
@@ -180,6 +181,23 @@ static u8 versal2_get_bootmode(void)
        return bootmode;
 }
 
+static u32 versal2_multi_boot(void)
+{
+       u8 bootmode = versal2_get_bootmode();
+       u32 reg = 0;
+
+       /* Mostly workaround for QEMU CI pipeline */
+       if (bootmode == JTAG_MODE)
+               return 0;
+
+       if (IS_ENABLED(CONFIG_ZYNQMP_FIRMWARE) && current_el() != 3)
+               reg = zynqmp_pm_get_pmc_multi_boot_reg();
+       else
+               reg = readl(PMC_MULTI_BOOT_REG);
+
+       return reg & PMC_MULTI_BOOT_MASK;
+}
+
 static int boot_targets_setup(void)
 {
        u8 bootmode;
@@ -319,6 +337,7 @@ static int boot_targets_setup(void)
 int board_late_init(void)
 {
        int ret;
+       u32 multiboot;
 
        if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
                debug("Saved variables - Skipping\n");
@@ -328,6 +347,9 @@ int board_late_init(void)
        if (!IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG))
                return 0;
 
+       multiboot = versal2_multi_boot();
+       env_set_hex("multiboot", multiboot);
+
        if (IS_ENABLED(CONFIG_DISTRO_DEFAULTS)) {
                ret = boot_targets_setup();
                if (ret)
index 2ef499bf4084c1580b9c5c649c511a8411d1f55d..f8a9945c1daa092c5ca960a63814758d23dc0c90 100644 (file)
@@ -248,6 +248,7 @@ u32 zynqmp_pm_get_bootmode_reg(void)
        return ret_payload[1];
 }
 
+#if defined(CONFIG_ARCH_VERSAL) || defined(CONFIG_ARCH_VERSAL2)
 u32 zynqmp_pm_get_pmc_multi_boot_reg(void)
 {
        int ret;
@@ -271,6 +272,7 @@ u32 zynqmp_pm_get_pmc_multi_boot_reg(void)
 
        return ret_payload[1];
 }
+#endif
 
 int zynqmp_pm_feature(const u32 api_id)
 {