[PATCH v2 5/7] rockchip: spl-boot-order: Add SPI NAND support

Jonas Karlman jonas at kwiboo.se
Mon Feb 9 10:56:27 CET 2026


Hi Fabio,

On 2/8/2026 10:26 PM, Fabio Estevam wrote:
> From: Fabio Estevam <festevam at nabladev.com>
> 
> Make spl-boot-order to accept boot from SPI NAND as well.
> 
> With this change, it is possible to specify spi_nand
> as the boot medium like this:
> 
> u-boot,spl-boot-order = &spi_nand;

You should probably include something like following (after DT has been
updated as per DT review) in rv1103b.c to also allow "same-as-spl" to
work.

const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
	[BROM_BOOTSOURCE_EMMC] = "/soc/mmc at 20d30000",
	[BROM_BOOTSOURCE_SPINOR] = "/soc/spi at 20d40000/flash at 0",
	[BROM_BOOTSOURCE_SD] = "/soc/mmc at 20d20000",
};

> Signed-off-by: Fabio Estevam <festevam at nabladev.com>
> ---
> Changes since v1:
> - None.
> 
>  arch/arm/mach-rockchip/spl-boot-order.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-rockchip/spl-boot-order.c b/arch/arm/mach-rockchip/spl-boot-order.c
> index 6572dde29f65..e5897536934a 100644
> --- a/arch/arm/mach-rockchip/spl-boot-order.c
> +++ b/arch/arm/mach-rockchip/spl-boot-order.c
> @@ -4,6 +4,7 @@
>   */
>  
>  #include <dm.h>
> +#include <dm/device_compat.h>
>  #include <fdt_support.h>
>  #include <log.h>
>  #include <mmc.h>
> @@ -75,6 +76,8 @@ static int spl_node_to_boot_device(int node)
>  	 */
>  	if (!uclass_find_device_by_of_offset(UCLASS_SPI_FLASH, node, &parent))
>  		return BOOT_DEVICE_SPI;
> +	if (fdt_node_check_compatible(gd->fdt_blob, node, "spi-nand") == 0)
> +		return BOOT_DEVICE_SPI;

I think something like following will be better:

	if (!uclass_find_device_by_of_offset(UCLASS_MTD, node, &parent))
		return BOOT_DEVICE_MTD;

And possible also with a protect check (should probably be fixed for
MMC/SPI_FLASH in a separate future patch/series).

	if (CONFIG_IS_ENABLED(MTD_LOAD_SUPPORT) &&
	    !uclass_find_device_by_of_offset(UCLASS_MTD, node, &parent))
		return BOOT_DEVICE_MTD;

Or whatever Kconfig option is used to ensure both UCLASS and SPL loader
is supported in the build. To avoid error messages about missing UCLASS
like following (from a different rk soc/board):

  board_spl_was_booted_from: brom_bootdevice_id 3 maps to '/soc/spi at ffac0000/flash at 0'
  Cannot find uclass for id 119: please add the UCLASS_DRIVER() declaration for this UCLASS_... id
  board_boot_order: could not map node /soc/spi at ffac0000/flash at 0 to a boot-device
  Cannot find uclass for id 119: please add the UCLASS_DRIVER() declaration for this UCLASS_... id

>  
>  	return -1;
>  }
> @@ -221,8 +224,12 @@ int spl_decode_boot_device(u32 boot_device, char *buf, size_t buflen)
>  
>  			ret = uclass_find_device_by_of_offset(UCLASS_SPI_FLASH, node, &dev);
>  			if (ret) {
> -				debug("%s: could not find udevice for %s\n", __func__, conf);
> -				continue;
> +				ret = uclass_find_device_by_of_offset(UCLASS_MTD, node, &dev);
> +				if (ret || !device_is_compatible(dev, "spi-nand")) {

I do not think we need to check for spi-nand compatible here, make it
generic and only check for UCLASS_MTD. If the node binds to a UCLASS_MTD
driver it is likely we could use a generic SPL MTD loader that used mtd
read ops to load next stage.

With that we could possible also support SPI_FLASH_MTD and consolidate
and/or simplify SPL code, something that can be looked at in future once
we have a more generic SPL MTD loader in place.

Regards,
Jonas

> +					debug("%s: could not find udevice for %s\n",
> +					      __func__, conf);
> +					continue;
> +				}
>  			}
>  
>  			return ofnode_get_path(dev_ofnode(dev), buf, buflen);



More information about the U-Boot mailing list