diff options
author | Michal Simek <michal.simek@amd.com> | 2024-12-05 11:38:15 +0100 |
---|---|---|
committer | Michal Simek <michal.simek@amd.com> | 2025-01-14 08:23:47 +0100 |
commit | 5e3b8e5c49d405dd183bb9ce9dd61802f8cc40cc (patch) | |
tree | 155e1e46d783628b7502b063cca6afcc8182da80 | |
parent | 6a0db9ee030f634731b792d864fc7a9df6cc6b80 (diff) |
arm64: versal: Wire SPIs for dfu_alt_info variable generation
Enable automatic dfu_alt_info variable generation based on MTD partition.
Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/67ff88c8c7186138353c0b74ed37a318fb4b199e.1733395093.git.michal.simek@amd.com
-rw-r--r-- | board/xilinx/versal/board.c | 41 | ||||
-rw-r--r-- | configs/xilinx_versal_virt_defconfig | 1 |
2 files changed, 42 insertions, 0 deletions
diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c index fd5c6ced795..964a779b5f1 100644 --- a/board/xilinx/versal/board.c +++ b/board/xilinx/versal/board.c @@ -14,6 +14,7 @@ #include <malloc.h> #include <memalign.h> #include <mmc.h> +#include <mtd.h> #include <time.h> #include <asm/cache.h> #include <asm/global_data.h> @@ -346,6 +347,31 @@ enum env_location env_get_location(enum env_operation op, int prio) #define DFU_ALT_BUF_LEN SZ_1K +static void mtd_found_part(u32 *base, u32 *size) +{ + struct mtd_info *part, *mtd; + + mtd_probe_devices(); + + mtd = get_mtd_device_nm("nor0"); + if (!IS_ERR_OR_NULL(mtd)) { + list_for_each_entry(part, &mtd->partitions, node) { + debug("0x%012llx-0x%012llx : \"%s\"\n", + part->offset, part->offset + part->size, + part->name); + + if (*base >= part->offset && + *base < part->offset + part->size) { + debug("Found my partition: %d/%s\n", + part->index, part->name); + *base = part->offset; + *size = part->size; + break; + } + } + } +} + void set_dfu_alt_info(char *interface, char *devstr) { int bootseq = 0, len = 0; @@ -371,6 +397,21 @@ void set_dfu_alt_info(char *interface, char *devstr) len += snprintf(buf + len, DFU_ALT_BUF_LEN, ".bin fat %d 1", bootseq); break; + case QSPI_MODE_24BIT: + case QSPI_MODE_32BIT: + case OSPI_MODE: + { + u32 base = 0; + u32 size = 0x1500000; + u32 limit = size; + + mtd_found_part(&base, &limit); + + len += snprintf(buf + len, DFU_ALT_BUF_LEN, + "sf 0:0=boot.bin raw 0x%x 0x%x", + base, limit); + } + break; default: return; } diff --git a/configs/xilinx_versal_virt_defconfig b/configs/xilinx_versal_virt_defconfig index c8f166c1221..fb757c1067d 100644 --- a/configs/xilinx_versal_virt_defconfig +++ b/configs/xilinx_versal_virt_defconfig @@ -83,6 +83,7 @@ CONFIG_CLK_VERSAL=y CONFIG_DFU_TIMEOUT=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y +CONFIG_DFU_SF=y CONFIG_SYS_DFU_DATA_BUF_SIZE=0x1800000 CONFIG_ARM_FFA_TRANSPORT=y CONFIG_FPGA_XILINX=y |