aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Schulz <quentin.schulz@theobroma-systems.com>2024-01-18 14:55:56 +0100
committerKever Yang <kever.yang@rock-chips.com>2024-01-19 10:57:36 +0800
commita5843cfce8a73f3c360a0dc6fadc33fe2c36367a (patch)
tree65896302f0d50a5b23b5cd0eab3f5c6366433d38
parent543f24dffcf1a85faf95228c0d0ba2dee097939f (diff)
downloadu-boot-a5843cfce8a73f3c360a0dc6fadc33fe2c36367a.zip
u-boot-a5843cfce8a73f3c360a0dc6fadc33fe2c36367a.tar.gz
u-boot-a5843cfce8a73f3c360a0dc6fadc33fe2c36367a.tar.bz2
rockchip: px30: simplify logic for getting SPL boot medium DT node
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 factor out the code handling the SPL boot medium detection by having spl_decode_boot_device common to all SoCs. Cc: Quentin Schulz <foss+uboot@0leil.net> Reviewed-by: Kever Yang <kever.yang@rock-chips.com> Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
-rw-r--r--arch/arm/mach-rockchip/px30/px30.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/arch/arm/mach-rockchip/px30/px30.c b/arch/arm/mach-rockchip/px30/px30.c
index 3bca25c..8937677 100644
--- a/arch/arm/mach-rockchip/px30/px30.c
+++ b/arch/arm/mach-rockchip/px30/px30.c
@@ -445,22 +445,26 @@ void board_debug_uart_init(void)
#endif /* CONFIG_DEBUG_UART_BOARD_INIT */
#if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
+const char * const spl_boot_devices[BOOT_DEVICE_NONE + 1] = {
+ [BOOT_DEVICE_MMC2] = "/mmc@ff370000",
+ [BOOT_DEVICE_MMC1] = "/mmc@ff390000",
+};
+
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@ff370000" },
- { BOOT_DEVICE_MMC1, "/mmc@ff390000" },
- };
+ const char *spl_bootdevice_ofpath = NULL;
+
+ if (boot_device < ARRAY_SIZE(spl_boot_devices))
+ spl_bootdevice_ofpath = spl_boot_devices[boot_device];
- 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;
+ 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 NULL;
+ return spl_bootdevice_ofpath;
}
void spl_perform_fixups(struct spl_image_info *spl_image)