board: xilinx: Generate FWU capsule dfu_alt_info from fwu_platform_hook()
Commit371a6c1744("board: xilinx: Add capsule and FWU support") and commit818c06faa1("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 <michal.simek@amd.com> Link: https://patch.msgid.link/33c118b8177f8d0dc182a6f4c5cffedca4e02448.1782986903.git.michal.simek@amd.com
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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 <michal.simek@amd.com>
|
||||
*/
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user