summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Simek <[email protected]>2026-07-02 12:08:25 +0200
committerMichal Simek <[email protected]>2026-08-12 06:54:37 +0200
commit40727c4f38d675ea833561c7188970696f012c6a (patch)
tree99d560eaf1b4cc076471dfe78ad8e1219e652da2
parent5bca08783b54ce325fb649749de16edede0581d0 (diff)
board: xilinx: Generate FWU capsule dfu_alt_info from fwu_platform_hook()
Commit 371a6c1744f3 ("board: xilinx: Add capsule and FWU support") and commit 818c06faa119 ("board: amd: Add capsule and FWU support") introduced a separate set_dfu_alt_info() for the FWU multi-bank case (Versal and Versal Gen 2 respectively) which set the dfu_alt_info environment variable directly, while configure_capsule_updates() handled the non-FWU case by filling update_info.dfu_string. Fold the FWU multi-bank generation (fwu_gen_alt_info_from_mtd() over the nor0 MTD partitions) into fwu_platform_hook() and drop the standalone set_dfu_alt_info(). Signed-off-by: Michal Simek <[email protected]> Link: https://patch.msgid.link/33c118b8177f8d0dc182a6f4c5cffedca4e02448.1782986903.git.michal.simek@amd.com
-rw-r--r--board/amd/versal2/board.c39
-rw-r--r--board/xilinx/common/board.c37
-rw-r--r--board/xilinx/versal/board.c39
3 files changed, 36 insertions, 79 deletions
diff --git a/board/amd/versal2/board.c b/board/amd/versal2/board.c
index 2afd283b8dd..15b79bbea69 100644
--- a/board/amd/versal2/board.c
+++ b/board/amd/versal2/board.c
@@ -11,7 +11,6 @@
#include <env.h>
#include <efi_loader.h>
#include <fdtdec.h>
-#include <fwu.h>
#include <init.h>
#include <env_internal.h>
#include <log.h>
@@ -362,8 +361,6 @@ enum env_location env_get_location(enum env_operation op, int prio)
#define DFU_ALT_BUF_LEN SZ_1K
-#if defined(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) && \
- !defined(CONFIG_FWU_MULTI_BANK_UPDATE)
static void mtd_found_part(u32 *base, u32 *size)
{
struct mtd_info *part, *mtd;
@@ -440,42 +437,6 @@ void configure_capsule_updates(void)
update_info.dfu_string = strdup(buf);
debug("Capsule DFU: %s\n", update_info.dfu_string);
}
-#endif
-
-#if defined(CONFIG_FWU_MULTI_BANK_UPDATE)
-
-/* Generate dfu_alt_info from partitions */
-void set_dfu_alt_info(char *interface, char *devstr)
-{
- int ret;
- struct mtd_info *mtd;
-
- /*
- * It is called multiple times for every image
- * per bank that's why enough to set it up once.
- */
- if (env_get("dfu_alt_info"))
- return;
-
- ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
- memset(buf, 0, DFU_ALT_BUF_LEN);
-
- mtd_probe_devices();
-
- mtd = get_mtd_device_nm("nor0");
- if (IS_ERR_OR_NULL(mtd))
- return;
-
- ret = fwu_gen_alt_info_from_mtd(buf, DFU_ALT_BUF_LEN, mtd);
- if (ret < 0) {
- log_err("Error: Failed to generate dfu_alt_info. (%d)\n", ret);
- return;
- }
- log_debug("Make dfu_alt_info: '%s'\n", buf);
-
- env_set("dfu_alt_info", buf);
-}
-#endif
int spi_get_env_dev(void)
{
diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index 52a2e8767d8..f45b879736e 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2014 - 2022, Xilinx, Inc.
- * (C) Copyright 2022 - 2025, Advanced Micro Devices, Inc.
+ * (C) Copyright 2022 - 2026, Advanced Micro Devices, Inc.
*
* Michal Simek <[email protected]>
*/
@@ -14,6 +14,8 @@
#include <init.h>
#include <jffs2/load_kernel.h>
#include <log.h>
+#include <memalign.h>
+#include <mtd.h>
#include <asm/io.h>
#include <asm/global_data.h>
#include <asm/sections.h>
@@ -22,6 +24,7 @@
#endif
#include <dm/uclass.h>
#include <i2c.h>
+#include <linux/err.h>
#include <linux/sizes.h>
#include <malloc.h>
#include <memtop.h>
@@ -65,6 +68,8 @@ struct efi_capsule_update_info update_info = {
.images = fw_images,
};
+#define DFU_ALT_BUF_LEN SZ_1K
+
#endif /* EFI_HAVE_CAPSULE_SUPPORT */
#define EEPROM_HEADER_MAGIC 0xdaaddeed
@@ -846,6 +851,36 @@ int fwu_platform_hook(struct udevice *dev, struct fwu_data *data)
/* Copy image type GUID */
memcpy(&fw_images[0].image_type_id, &img_entry->image_type_guid, 16);
+ /*
+ * Generate the capsule DFU string from the FWU metadata. This has to
+ * happen here, and not in configure_capsule_updates() called from
+ * board_late_init(), because the FWU data is only populated by
+ * fwu_boottime_checks() at EVT_POST_PREBOOT.
+ */
+ {
+ ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
+ struct mtd_info *mtd;
+ int ret;
+
+ memset(buf, 0, DFU_ALT_BUF_LEN);
+
+ mtd_probe_devices();
+
+ mtd = get_mtd_device_nm("nor0");
+ if (IS_ERR_OR_NULL(mtd))
+ return -ENODEV;
+
+ ret = fwu_gen_alt_info_from_mtd(buf, DFU_ALT_BUF_LEN, mtd);
+ if (ret < 0) {
+ log_err("Error: Failed to generate dfu_alt_info. (%d)\n", ret);
+ return ret;
+ }
+ log_debug("Make dfu_alt_info: '%s'\n", buf);
+
+ update_info.dfu_string = strdup(buf);
+ debug("Capsule DFU: %s\n", update_info.dfu_string);
+ }
+
if (IS_ENABLED(CONFIG_EFI_ESRT)) {
efi_status_t ret;
diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c
index 0537517b1b2..e3e1085fce7 100644
--- a/board/xilinx/versal/board.c
+++ b/board/xilinx/versal/board.c
@@ -10,7 +10,6 @@
#include <env.h>
#include <efi_loader.h>
#include <fdtdec.h>
-#include <fwu.h>
#include <init.h>
#include <env_internal.h>
#include <log.h>
@@ -314,8 +313,6 @@ enum env_location env_get_location(enum env_operation op, int prio)
#define DFU_ALT_BUF_LEN SZ_1K
-#if defined(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) && \
- !defined(CONFIG_FWU_MULTI_BANK_UPDATE)
static void mtd_found_part(u32 *base, u32 *size)
{
struct mtd_info *part, *mtd;
@@ -392,39 +389,3 @@ void configure_capsule_updates(void)
update_info.dfu_string = strdup(buf);
debug("Capsule DFU: %s\n", update_info.dfu_string);
}
-#endif
-
-#if defined(CONFIG_FWU_MULTI_BANK_UPDATE)
-
-/* Generate dfu_alt_info from partitions */
-void set_dfu_alt_info(char *interface, char *devstr)
-{
- int ret;
- struct mtd_info *mtd;
-
- /*
- * It is called multiple times for every image
- * per bank that's why enough to set it up once.
- */
- if (env_get("dfu_alt_info"))
- return;
-
- ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
- memset(buf, 0, DFU_ALT_BUF_LEN);
-
- mtd_probe_devices();
-
- mtd = get_mtd_device_nm("nor0");
- if (IS_ERR_OR_NULL(mtd))
- return;
-
- ret = fwu_gen_alt_info_from_mtd(buf, DFU_ALT_BUF_LEN, mtd);
- if (ret < 0) {
- log_err("Error: Failed to generate dfu_alt_info. (%d)\n", ret);
- return;
- }
- log_debug("Make dfu_alt_info: '%s'\n", buf);
-
- env_set("dfu_alt_info", buf);
-}
-#endif