[PATCH v4 2/5] rockchip: spl: Add a read_brom_bootsource_id() helper

Kever Yang kever.yang at rock-chips.com
Sun Oct 26 16:40:37 CET 2025


On 2025/10/19 23:47, Jonas Karlman wrote:
> The bootsource ids reported by BootROM of RK3528 and RK3576 for e.g.
> SPI NOR and USB differs slightly compared to prior SoCs:
>
> - Booting from sfc0 (ROCK 4D) report the normal bootsource id 0x3.
> - Booting from sfc1 M1 (NanoPi M5) report a new bootsource id 0x23.
> - Booting from sfc1 M0 has not been tested (no board using this config).
> - Booting from USB report a new bootsource id 0x81 on RK3528 and RK3576.
>
> Add a helper function to read the bootsource id. This helper function
> will be used to translate the new values to the common BROM_BOOTSOURCE
> enum values on RK3528 and RK3576.
>
> Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
Reviewed-by: Kever Yang <kever.yang at rock-chips.com>

Thanks,
- Kever
> ---
> v4: No change
> v3: Mention RK3528 in commit message
> v2: No change
> ---
>   arch/arm/include/asm/arch-rockchip/bootrom.h | 2 ++
>   arch/arm/mach-rockchip/spl.c                 | 7 ++++++-
>   2 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/include/asm/arch-rockchip/bootrom.h b/arch/arm/include/asm/arch-rockchip/bootrom.h
> index e736772fda75..b15938c021d6 100644
> --- a/arch/arm/include/asm/arch-rockchip/bootrom.h
> +++ b/arch/arm/include/asm/arch-rockchip/bootrom.h
> @@ -64,4 +64,6 @@ extern const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1];
>    */
>   #define BROM_BOOTSOURCE_ID_ADDR   (CFG_IRAM_BASE + 0x10)
>   
> +u32 read_brom_bootsource_id(void);
> +
>   #endif
> diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c
> index f4d29bbdd17e..1ce3a3b05547 100644
> --- a/arch/arm/mach-rockchip/spl.c
> +++ b/arch/arm/mach-rockchip/spl.c
> @@ -31,6 +31,11 @@ int board_return_to_bootrom(struct spl_image_info *spl_image,
>   __weak const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
>   };
>   
> +__weak u32 read_brom_bootsource_id(void)
> +{
> +	return readl(BROM_BOOTSOURCE_ID_ADDR);
> +}
> +
>   const char *board_spl_was_booted_from(void)
>   {
>   	static u32 brom_bootsource_id_cache = BROM_BOOTSOURCE_UNKNOWN;
> @@ -40,7 +45,7 @@ const char *board_spl_was_booted_from(void)
>   	if (brom_bootsource_id_cache != BROM_BOOTSOURCE_UNKNOWN)
>   		bootdevice_brom_id = brom_bootsource_id_cache;
>   	else
> -		bootdevice_brom_id = readl(BROM_BOOTSOURCE_ID_ADDR);
> +		bootdevice_brom_id = read_brom_bootsource_id();
>   
>   	if (bootdevice_brom_id < ARRAY_SIZE(boot_devices))
>   		bootdevice_ofpath = boot_devices[bootdevice_brom_id];

-- 
Thanks & Best regards,
   Kever Yang
**************************************************************************************************
杨凯  市场部             Kever Yang      Marketing Department
瑞芯微电子股份有限公司                Rockchip Electronics Co.,Ltd。
地址:福建省福州市铜盘路软件大道89号软件园A区18号楼 (350003)
Addr : No.18 Building,A District,No.89,Fuzhou Software Boulevard,Fuzhou,Fujian,PRC



More information about the U-Boot mailing list