From: Simon Glass Date: Wed, 7 Aug 2024 22:47:34 +0000 (-0600) Subject: upl: Plumb in universal payload to the init process X-Git-Url: http://git.dujemihanovic.xyz/%22http:/www.sics.se/static/git-logo.png?a=commitdiff_plain;h=0fc406ab20e6fa1e92e68a2c51b73fc4d59b057f;p=u-boot.git upl: Plumb in universal payload to the init process Read the UPL early in boot so that it is available. For now none of the information is used. Signed-off-by: Simon Glass --- diff --git a/boot/Kconfig b/boot/Kconfig index 60a4cddf5e..7ac3457407 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -763,7 +763,9 @@ config UPL_READ help Provides support for decoding a UPL-format payload into a C structure which can be used elsewhere in U-Boot. This is just the reading - implementation, useful for trying it out. + implementation, useful for trying it out. See UPL_IN for how + to tell U-Boot to actually read it on startup and use it for memory + and device information, etc. config UPL_WRITE bool "upl - Support writing a Universal Payload handoff" @@ -774,6 +776,14 @@ config UPL_WRITE for how to tell U-Boot SPL to actually write it before jumping to the next phase. +config UPL_IN + bool "upl - Read the UPL handoff on startup" + select UPL_READ + help + Read an SPL handoff when U-Boot starts and use it to provide + devices, memory layout, etc. required by U-Boot. This allows U-Boot + to function as a payload in the meaning of the specification. + if SPL config SPL_UPL diff --git a/common/board_f.c b/common/board_f.c index 29e185137a..d71005d9f8 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -859,6 +860,26 @@ __weak int clear_bss(void) return 0; } +static int initf_upl(void) +{ + struct upl *upl; + int ret; + + if (!IS_ENABLED(CONFIG_UPL_IN) || !(gd->flags & GD_FLG_UPL)) + return 0; + + upl = malloc(sizeof(struct upl)); + if (upl) + ret = upl_read_handoff(upl, oftree_default()); + if (ret) { + printf("UPL handoff: read failure (err=%dE)\n", ret); + return ret; + } + gd_set_upl(upl); + + return 0; +} + static const init_fnc_t init_sequence_f[] = { setup_mon_len, #ifdef CONFIG_OF_CONTROL @@ -868,6 +889,7 @@ static const init_fnc_t init_sequence_f[] = { trace_early_init, #endif initf_malloc, + initf_upl, log_init, initf_bootstage, /* uses its own timer, so does not need DM */ event_init, diff --git a/common/board_r.c b/common/board_r.c index d4ba245ac6..f445803d7a 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -521,6 +521,8 @@ static int dm_announce(void) uclass_count); if (CONFIG_IS_ENABLED(OF_REAL)) printf(", devicetree: %s", fdtdec_get_srcname()); + if (CONFIG_IS_ENABLED(UPL)) + printf(", universal payload active"); printf("\n"); if (IS_ENABLED(CONFIG_OF_HAS_PRIOR_STAGE) && (gd->fdt_src == FDTSRC_SEPARATE ||