[PATCH v3 1/6] rockchip: rk3399: simplify logic for getting SPL boot medium DT node

Kever Yang kever.yang at rock-chips.com
Thu Jan 18 07:57:20 CET 2024


On 2024/1/18 01:22, Quentin Schulz wrote:
> From: Quentin Schulz <quentin.schulz at theobroma-systems.com>
>
> In preparation of moving spl_perform_fixups to spl-boot-order.c, let's
> simplify the logic around mapping the BOOT_DEVICE_x enum index to a DT
> node by using an instantiated array of chars instead of creating a new
> data structure on the fly.
>
> This will make it easier to only define the spl_boot_devices array in
> the appropriate SoC file in an upcoming commit.
>
> Cc: Quentin Schulz <foss+uboot at 0leil.net>
> Signed-off-by: Quentin Schulz <quentin.schulz at theobroma-systems.com>
Reviewed-by: Kever Yang <kever.yang at rock-chips.com>

Thanks,
- Kever
> ---
>   arch/arm/mach-rockchip/rk3399/rk3399.c | 34 +++++++++++++++++++---------------
>   1 file changed, 19 insertions(+), 15 deletions(-)
>
> diff --git a/arch/arm/mach-rockchip/rk3399/rk3399.c b/arch/arm/mach-rockchip/rk3399/rk3399.c
> index 14565d2ed9f..60d95c81cd2 100644
> --- a/arch/arm/mach-rockchip/rk3399/rk3399.c
> +++ b/arch/arm/mach-rockchip/rk3399/rk3399.c
> @@ -175,23 +175,27 @@ void board_debug_uart_init(void)
>   #endif
>   
>   #if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
> +const char * const spl_boot_devices[BOOT_DEVICE_NONE + 1] = {
> +	[BOOT_DEVICE_MMC2] = "/mmc at fe320000",
> +	[BOOT_DEVICE_MMC1] = "/mmc at fe330000",
> +	[BOOT_DEVICE_SPI] = "/spi at ff1d0000/flash at 0",
> +};
> +
>   const char *spl_decode_boot_device(u32 boot_device)
>   {
> -	int i;
> -	static const struct {
> -		u32 boot_device;
> -		const char *ofpath;
> -	} spl_boot_devices_tbl[] = {
> -		{ BOOT_DEVICE_MMC2, "/mmc at fe320000" },
> -		{ BOOT_DEVICE_MMC1, "/mmc at fe330000" },
> -		{ BOOT_DEVICE_SPI, "/spi at ff1d0000/flash at 0" },
> -	};
> -
> -	for (i = 0; i < ARRAY_SIZE(spl_boot_devices_tbl); ++i)
> -		if (spl_boot_devices_tbl[i].boot_device == boot_device)
> -			return spl_boot_devices_tbl[i].ofpath;
> -
> -	return NULL;
> +	const char *spl_bootdevice_ofpath = NULL;
> +
> +	if (boot_device < ARRAY_SIZE(spl_boot_devices))
> +		spl_bootdevice_ofpath = spl_boot_devices[boot_device];
> +
> +	if (spl_bootdevice_ofpath)
> +		debug("%s: spl_bootdevice_id %x maps to '%s'\n",
> +		      __func__, boot_device, spl_bootdevice_ofpath);
> +	else
> +		debug("%s: failed to resolve spl_bootdevice_id %x\n",
> +		      __func__, boot_device);
> +
> +	return spl_bootdevice_ofpath;
>   }
>   
>   void spl_perform_fixups(struct spl_image_info *spl_image)
>


More information about the U-Boot mailing list