arm: socfpga: enable NAND boot support on Agilex platforms
Subsystems (5)
cover arm: socfpga: enable NAND boot support on Agilex platforms
From: Dinesh Maniyam <[email protected]>
This series enables NAND boot support on SoCFPGA Agilex platforms.
It adds support for loading U-Boot from NAND in SPL using the full NAND/MTD framework, cleans up controller-specific SPL helpers, and enables the required NAND configuration for Agilex boards.
No functional change is intended for platforms that do not enable SPL NAND MTD framework support.
Dinesh Maniyam (5):
mtd: nand: introduce SPL_NAND_FRAMEWORK_CAPABLE Kconfig option
mtd: nand: add generic SPL NAND MTD loader
mtd: nand: wire SPL NAND MTD loader into SPL build
arm: socfpga: imply SPL_NAND_FRAMEWORK_CAPABLE for Agilex platforms
arm: socfpga: enable NAND support for Agilex
arch/arm/mach-socfpga/Kconfig | 2 + configs/socfpga_agilex_defconfig | 11 +++++ drivers/mtd/nand/raw/Kconfig | 25 ++++++++++ drivers/mtd/nand/raw/Makefile | 1 + drivers/mtd/nand/raw/spl_nand_mtd.c | 76 +++++++++++++++++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 drivers/mtd/nand/raw/spl_nand_mtd.c
Signature · 1 line
2.43.7
PATCH 1/5 mtd: nand: introduce SPL_NAND_FRAMEWORK_CAPABLE Kconfig option
From: Dinesh Maniyam <[email protected]>
The SPL NAND MTD framework requires working driver model support and sufficient memory resources, which are not available on all platforms.
Introduce a SPL_NAND_FRAMEWORK_CAPABLE Kconfig option to allow platforms to explicitly advertise support for compiling the full NAND/MTD framework into SPL.
This avoids accidental enablement of the SPL NAND framework on platforms that cannot support it and provides a clear capability boundary for platform maintainers.
--- drivers/mtd/nand/raw/Kconfig | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/mtd/nand/raw/Kconfig +25 -0
@@ -809,6 +809,31 @@ config SYS_NAND_HW_ECC_OOBFIRST bool "In SPL, read the OOB first and then the data from NAND" depends on SPL_NAND_SIMPLE +config SPL_NAND_FRAMEWORK_CAPABLE + bool + depends on SPL_DM + depends on SPL_HAS_BSS_LINKER_SECTION + +config SPL_NAND_USE_NAND_FRAMEWORK + bool "Use NAND/MTD framework in SPL" + depends on SPL_NAND_SUPPORT && MTD + depends on SPL_NAND_FRAMEWORK_CAPABLE + depends on SPL_ENV_SUPPORT + depends on ENV_IS_IN_NAND + select SPL_SYS_NAND_SELF_INIT + select SPL_NAND_BASE + select SPL_NAND_DRIVERS + select SPL_NAND_IDENT + select SPL_NAND_INIT + select SPL_NAND_ECC + help + Enable loading U-Boot from NAND in SPL using the full + NAND/MTD framework instead of the minimal SPL NAND loaders. + This provides bad-block aware reads and flexible offset + handling via the common NAND/MTD infrastructure. + Platforms enabling this option must also provide working + driver model support and sufficient SPL memory resources. + endif # if SPL endif # if MTD_RAW_NAND
Signature · 1 line
2.43.7
Re: [PATCH 1/5] mtd: nand: introduce SPL_NAND_FRAMEWORK_CAPABLE Kconfig option
Quoted 45 lines · On Thu, Jan 29, 2026 at 01:04:42PM +0800, [email protected] wrote:
From: Dinesh Maniyam <[email protected]>
The SPL NAND MTD framework requires working driver model support and sufficient memory resources, which are not available on all platforms.
Introduce a
SPL_NAND_FRAMEWORK_CAPABLEKconfigoption to allow platforms to explicitly advertise support for compiling the full NAND/MTD framework into SPL.This avoids accidental enablement of the SPL NAND framework on platforms that cannot support it and provides a clear capability boundary for platform maintainers.
Signed-off-by Dinesh Maniyam <[email protected]>--- drivers/mtd/nand/raw/Kconfig | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)drivers/mtd/nand/raw/Kconfig +18
-0@@ -809,6 +809,31 @@ config SYS_NAND_HW_ECC_OOBFIRST bool "In SPL, read the OOB first and then the data from NAND" depends on SPL_NAND_SIMPLE +config SPL_NAND_FRAMEWORK_CAPABLE + bool + depends on SPL_DM + depends on SPL_HAS_BSS_LINKER_SECTION + +config SPL_NAND_USE_NAND_FRAMEWORK + bool "Use NAND/MTD framework in SPL" + depends on SPL_NAND_SUPPORT && MTD + depends on SPL_NAND_FRAMEWORK_CAPABLE + depends on SPL_ENV_SUPPORT + depends on ENV_IS_IN_NAND + select SPL_SYS_NAND_SELF_INIT + select SPL_NAND_BASE + select SPL_NAND_DRIVERS + select SPL_NAND_IDENT + select SPL_NAND_INIT + select SPL_NAND_ECC + help
drivers/mtd/nand/raw/Kconfig config SYS_NAND_HW_ECC_OOBFIRST · line 839
Quoted 10 lines
drivers/mtd/nand/raw/Kconfig +7
-0+ Enable loading U-Boot from NAND in SPL using the full + NAND/MTD framework instead of the minimal SPL NAND loaders. + This provides bad-block aware reads and flexible offset + handling via the common NAND/MTD infrastructure. + Platforms enabling this option must also provide working + driver model support and sufficient SPL memory resources. + endif # if SPL endif # if MTD_RAW_NAND
It sounds like dependencies are missing on existing symbols, and should be added there, from the description. It also sounds like these platforms have hard limits on SPL size, but aren't setting the appropriate options to enforce that at link time. Or am I totally misunderstanding?
Signature · 1 line
Tom
Re: [PATCH 1/5] mtd: nand: introduce SPL_NAND_FRAMEWORK_CAPABLE Kconfig option
Hi Tom,
Quoted 67 lines · Tom Rini
Quoted 45 lines · On Thu, Jan 29, 2026 at 01:04:42PM +0800,[email protected] wrote:
From: Dinesh Maniyam<[email protected]>
The SPL NAND MTD framework requires working driver model support and sufficient memory resources, which are not available on all platforms.
Introduce a
SPL_NAND_FRAMEWORK_CAPABLEKconfigoption to allow platforms to explicitly advertise support for compiling the full NAND/MTD framework into SPL.This avoids accidental enablement of the SPL NAND framework on platforms that cannot support it and provides a clear capability boundary for platform maintainers.
Signed-off-by Dinesh Maniyam<[email protected]>--- drivers/mtd/nand/raw/Kconfig | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)drivers/mtd/nand/raw/Kconfig +18
-0@@ -809,6 +809,31 @@ config SYS_NAND_HW_ECC_OOBFIRST bool "In SPL, read the OOB first and then the data from NAND" depends on SPL_NAND_SIMPLE +config SPL_NAND_FRAMEWORK_CAPABLE + bool + depends on SPL_DM + depends on SPL_HAS_BSS_LINKER_SECTION + +config SPL_NAND_USE_NAND_FRAMEWORK + bool "Use NAND/MTD framework in SPL" + depends on SPL_NAND_SUPPORT && MTD + depends on SPL_NAND_FRAMEWORK_CAPABLE + depends on SPL_ENV_SUPPORT + depends on ENV_IS_IN_NAND + select SPL_SYS_NAND_SELF_INIT + select SPL_NAND_BASE + select SPL_NAND_DRIVERS + select SPL_NAND_IDENT + select SPL_NAND_INIT + select SPL_NAND_ECC + helpdrivers/mtd/nand/raw/Kconfig config SYS_NAND_HW_ECC_OOBFIRST · line 839
Quoted 10 lines
drivers/mtd/nand/raw/Kconfig +7
-0+ Enable loading U-Boot from NAND in SPL using the full + NAND/MTD framework instead of the minimal SPL NAND loaders. + This provides bad-block aware reads and flexible offset + handling via the common NAND/MTD infrastructure. + Platforms enabling this option must also provide working + driver model support and sufficient SPL memory resources. + endif # if SPL endif # if MTD_RAW_NANDIt sounds like dependencies are missing on existing symbols, and should be added there, from the description. It also sounds like these platforms have hard limits on SPL size, but aren't setting the appropriate options to enforce that at link time. Or am I totally misunderstanding?
Spot on!
The SPL memory requirement was only documented in the help text. Add an explicit dependency on|SPL_MAX_SIZE| to ensure platforms enabling the full NAND/MTD framework in SPL declare sufficient SRAM.
PATCH 2/5 mtd: nand: add generic SPL NAND MTD loader
In reply to [email protected]From: Dinesh Maniyam <[email protected]>
Add a generic SPL NAND MTD loader providing nand_get_mtd() and nand_spl_load_image() helpers.
This allows SPL NAND MTD loading logic to be shared across NAND controllers instead of being embedded in individual drivers.
--- drivers/mtd/nand/raw/spl_nand_mtd.c | 76 +++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 drivers/mtd/nand/raw/spl_nand_mtd.c
drivers/mtd/nand/raw/spl_nand_mtd.c new file +76 -0
@@ -0,0 +1,76 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright Altera Corporation (C) 2026. All rights reserved. +*/ + +#include <dm.h> +#include <hang.h> +#include <malloc.h> +#include <memalign.h> +#include <nand.h> + +struct mtd_info *nand_get_mtd (void ) +{ +struct mtd_info *mtd; + + mtd =get_nand_dev_by_index (nand_curr_device); +if (!mtd) +hang (); + +return mtd; +} + +int nand_spl_load_image (u32 offset,u32 len,void *dst) +{ +size_t count = len, actual =0 , page_align_overhead =0 ; +u32 page_align_offset =0 ; +u8 *page_buffer =NULL ; +int err =0 ; +struct mtd_info *mtd; + +if (!len || !dst) +return -EINVAL ; + + mtd =nand_get_mtd (); + +if (offset & (mtd->writesize -1 )) { + page_buffer =malloc_cache_aligned (mtd->writesize); +if (!page_buffer) { +debug ("Error: allocating buffer\n" ); +return -ENOMEM ; + } + + page_align_overhead = offset % mtd->writesize; + page_align_offset = offset - page_align_overhead; + count = mtd->writesize; + + err =nand_read_skip_bad (mtd, page_align_offset, &count, + &actual, mtd->size, page_buffer); +if (err) + goto out; + + count -= page_align_overhead; + count =min ((size_t )len, count); + +memcpy (dst, page_buffer + page_align_overhead, count); + + len -= count; +if (!len) + goto out; + + offset += count; + dst += count; + count = len; + } + + err =nand_read_skip_bad (mtd, offset, &count, + &actual, mtd->size, dst); + +out: +if (page_buffer) +free (page_buffer); + +return err; +} + +void nand_deselect (void ) {}
Signature · 1 line
2.43.7
PATCH 3/5 mtd: nand: wire SPL NAND MTD loader into SPL build
In reply to [email protected]From: Dinesh Maniyam <[email protected]>
Wire the generic SPL NAND MTD loader into the NAND SPL build when SPL_NAND_USE_NAND_FRAMEWORK is enabled.
--- drivers/mtd/nand/raw/Makefile | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/nand/raw/Makefile +1 -0
@@ -12,6 +12,7 @@ endif obj-$(CONFIG_SPL_NAND_AM33XX_BCH) += am335x_spl_bch.o obj-$(CONFIG_SPL_NAND_CADENCE) += cadence_spl.o obj-$(CONFIG_SPL_NAND_DENALI) += denali_spl.o +obj-$(CONFIG_SPL_NAND_USE_NAND_FRAMEWORK) += spl_nand_mtd.o obj-$(CONFIG_SPL_NAND_SIMPLE) += nand_spl_simple.o obj-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o obj-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o
Signature · 1 line
2.43.7
PATCH 4/5 arm: socfpga: imply SPL_NAND_FRAMEWORK_CAPABLE for Agilex platforms
In reply to [email protected]From: Dinesh Maniyam <[email protected]>
Use imply instead of select for SPL_NAND_FRAMEWORK_CAPABLE on SoCFPGA Agilex and Agilex7M platforms.
SPL_NAND_FRAMEWORK_CAPABLE is a platform capability hint and should not be forced when its functional dependencies are not enabled. Using imply avoids Kconfig dependency warnings while allowing the feature to be enabled when appropriate.
--- arch/arm/mach-socfpga/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mach-socfpga/Kconfig +2 -0
@@ -59,6 +59,7 @@ config TARGET_SOCFPGA_AGILEX select NCORE_CACHE select SPL_CLK if SPL select TARGET_SOCFPGA_SOC64 + imply SPL_NAND_FRAMEWORK_CAPABLE config TARGET_SOCFPGA_AGILEX7M bool
@@ -71,6 +72,7 @@ config TARGET_SOCFPGA_AGILEX7M select NCORE_CACHE select SPL_CLK if SPL select TARGET_SOCFPGA_SOC64 + imply SPL_NAND_FRAMEWORK_CAPABLE config TARGET_SOCFPGA_AGILEX5 bool
Signature · 1 line
2.43.7
PATCH 5/5 arm: socfpga: enable NAND support for Agilex
In reply to [email protected]From: Dinesh Maniyam <[email protected]>
Enable NAND support for the SoCFPGA Agilex platform by enabling Denali NAND, SPL NAND support, and environment storage in NAND. This allows SPL and U-Boot to boot from NAND using the NAND/MTD infrastructure.
--- configs/socfpga_agilex_defconfig | 11 +++++++++++ 1 file changed, 11 insertions(+)
configs/socfpga_agilex_defconfig +11 -0
@@ -7,6 +7,7 @@ CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x300000 CONFIG_SF_DEFAULT_MODE=0x2003 CONFIG_ENV_SIZE=0x2000 +CONFIG_ENV_OFFSET=0x00200000 CONFIG_DM_GPIO=y CONFIG_DEFAULT_DEVICE_TREE="intel/socfpga_agilex_socdk" CONFIG_DM_RESET=y
@@ -25,6 +26,7 @@ CONFIG_SPL_FIT_SIGNATURE=y CONFIG_SPL_LOAD_FIT=y CONFIG_SPL_LOAD_FIT_ADDRESS=0x02000000 CONFIG_DISTRO_DEFAULTS=y +CONFIG_NAND_BOOT=y CONFIG_QSPI_BOOT=y CONFIG_BOOTDELAY=5 CONFIG_USE_BOOTARGS=y
@@ -39,7 +41,9 @@ CONFIG_SPL_HAS_CUSTOM_MALLOC_START=y CONFIG_SPL_CUSTOM_SYS_MALLOC_ADDR=0x3fa00000 CONFIG_SPL_SYS_MALLOC_SIZE=0x500000 CONFIG_SPL_CACHE=y +CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_MTD=y +CONFIG_SPL_NAND_SUPPORT=y CONFIG_SPL_SPI_FLASH_MTD=y CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x04000000
@@ -60,6 +64,7 @@ CONFIG_CMD_UBI=y CONFIG_OF_UPSTREAM=y CONFIG_OF_LIST="" CONFIG_ENV_IS_IN_FAT=y +CONFIG_ENV_IS_IN_NAND=y CONFIG_ENV_IS_IN_UBI=y CONFIG_ENV_FAT_DEVICE_AND_PART="0:1" CONFIG_ENV_UBI_PART="root"
@@ -74,6 +79,10 @@ CONFIG_MISC=y CONFIG_SYS_MMC_MAX_BLK_COUNT=256 CONFIG_MMC_DW=y CONFIG_DM_MTD=y +CONFIG_NAND_DENALI_DT=y +CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y +CONFIG_SYS_NAND_U_BOOT_OFFS=0x0 +CONFIG_SPL_NAND_USE_NAND_FRAMEWORK=y CONFIG_SPI_FLASH_SPANSION=y CONFIG_SPI_FLASH_STMICRO=y # CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
@@ -94,3 +103,5 @@ CONFIG_WDT=y CONFIG_PANIC_HANG=y CONFIG_SPL_CRC32=y # CONFIG_TOOLS_MKEFICAPSULE is not set +CONFIG_MTDIDS_DEFAULT="nand0=ffb90000.nand.0" +CONFIG_MTDPARTS_DEFAULT="mtdparts=ffb90000.nand.0:2m(u-boot),-(root)"
Signature · 1 line
2.43.7