[PATCH next] rockchip: rk3588: insert u-boot, spl-boot-device into U-Boot device tree
Jonas Karlman
jonas at kwiboo.se
Tue May 2 19:56:29 CEST 2023
Hi Quentin,
On 2023-05-02 18:23, Quentin Schulz wrote:
> From: Quentin Schulz <quentin.schulz at theobroma-systems.com>
>
> It is possible to boot U-Boot proper from a different storage medium
> than the one used by the BOOTROM to load the SPL. This information is
> stored in the u-boot,spl-boot-device Device Tree property and is
> accessible from U-Boot proper so that it has knowledge at runtime where
> it was loaded from.
>
> Let's add support for this feature for rk3588 the same way it was done
> for px30 and rk3399.
Why does this need to be soc specific, why can it not be added to spl.c
or spl-boot-order.c?
The soc specific boot_devices already have BROM_BOOTSOURCE to ofpath
defined. With a BOOT_DEVICE > BROM_BOOTSOURCE > ofpath translation
helper this could be made more generic to work for all rk socs.
Regards,
Jonas
>
> Cc: Quentin Schulz <foss+uboot at 0leil.net>
> Signed-off-by: Quentin Schulz <quentin.schulz at theobroma-systems.com>
> ---
> arch/arm/mach-rockchip/rk3588/rk3588.c | 50 ++++++++++++++++++++++++++++++++++
> 1 file changed, 50 insertions(+)
>
> diff --git a/arch/arm/mach-rockchip/rk3588/rk3588.c b/arch/arm/mach-rockchip/rk3588/rk3588.c
> index 18e67b5ca9b..694177e3976 100644
> --- a/arch/arm/mach-rockchip/rk3588/rk3588.c
> +++ b/arch/arm/mach-rockchip/rk3588/rk3588.c
> @@ -162,3 +162,53 @@ int arch_cpu_init(void)
> return 0;
> }
> #endif
> +
> +#if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
> +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 fe2e0000" },
> + { BOOT_DEVICE_MMC1, "/mmc at fe2c0000" },
> + { BOOT_DEVICE_SPI, "/spi at fe2b0000/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;
> +}
> +
> +void spl_perform_fixups(struct spl_image_info *spl_image)
> +{
> + void *blob = spl_image->fdt_addr;
> + const char *boot_ofpath;
> + int chosen;
> +
> + /*
> + * Inject the ofpath of the device the full U-Boot (or Linux in
> + * Falcon-mode) was booted from into the FDT, if a FDT has been
> + * loaded at the same time.
> + */
> + if (!blob)
> + return;
> +
> + boot_ofpath = spl_decode_boot_device(spl_image->boot_device);
> + if (!boot_ofpath) {
> + pr_err("%s: could not map boot_device to ofpath\n", __func__);
> + return;
> + }
> +
> + chosen = fdt_find_or_add_subnode(blob, 0, "chosen");
> + if (chosen < 0) {
> + pr_err("%s: could not find/create '/chosen'\n", __func__);
> + return;
> + }
> + fdt_setprop_string(blob, chosen,
> + "u-boot,spl-boot-device", boot_ofpath);
> +}
> +#endif
>
> ---
> base-commit: 6735ab59e6fd71ced1c58d8dfb3dd6baf3690d16
> change-id: 20230502-rk3588-spl-boot-dev-efa2777cc21b
>
> Best regards,
> --
> Quentin Schulz <quentin.schulz at theobroma-systems.com>
More information about the U-Boot
mailing list