[PATCH v2 02/10] of_live: support in SPL

michael.srba
2026-04-11T07:12:01Z

From: Michael Srba <Michael.Srba@seznam.cz>

Add CONFIG_SPL_OF_LIVE and if set, initialize of_live in spl.c

Signed-off-by: Michael Srba <Michael.Srba@seznam.cz>
---
common/spl/spl.c | 11 +++++++++++
dts/Kconfig | 6 ++++++
lib/Makefile | 2 +-
3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 8256fa97862..179694a38cd 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -17,6 +17,7 @@
#include <irq_func.h>
#include <log.h>
#include <mapmem.h>
+#include <of_live.h>
#include <serial.h>
#include <spl.h>
#include <spl_load.h>
@@ -510,6 +511,16 @@ static int spl_common_init(bool setup_malloc)
return ret;
}
}
+ if (CONFIG_IS_ENABLED(OF_LIVE)) {
+ int ret;
+
+ bootstage_start(BOOTSTAGE_ID_ACCUM_OF_LIVE, "of_live");
+ ret = of_live_build(gd->fdt_blob,
+ (struct device_node **)gd_of_root_ptr());
+ bootstage_accum(BOOTSTAGE_ID_ACCUM_OF_LIVE);
+ if (ret)
+ return ret;
+ }
if (CONFIG_IS_ENABLED(DM)) {
bootstage_start(BOOTSTAGE_ID_ACCUM_DM_SPL,
xpl_phase() == PHASE_TPL ? "dm tpl" : "dm_spl");
diff --git a/dts/Kconfig b/dts/Kconfig
index af8d30b45ab..b30bc5db5d1 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -86,6 +86,12 @@ config OF_LIVE
enables a live tree which is available after relocation,
and can be adjusted as needed.

+config SPL_OF_LIVE
+ bool "Enable use of a live tree in SPL"
+ depends on SPL_DM && SPL_OF_CONTROL
+ help
+ This option enables a live tree in SPL.
+
config OF_UPSTREAM
bool "Enable use of devicetree imported from Linux kernel release"
depends on !COMPILE_TEST
diff --git a/lib/Makefile b/lib/Makefile
index d0ffabc2b47..bbd540e9687 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -13,7 +13,6 @@ obj-$(CONFIG_FWU_MULTI_BANK_UPDATE) += fwu_updates/
obj-$(CONFIG_LZMA) += lzma/
obj-$(CONFIG_BZIP2) += bzip2/
obj-$(CONFIG_FIT) += libfdt/
-obj-$(CONFIG_OF_LIVE) += of_live.o
obj-$(CONFIG_CMD_DHRYSTONE) += dhry/
obj-$(CONFIG_ARCH_AT91) += at91/
obj-$(CONFIG_OPTEE_LIB) += optee/
@@ -55,6 +54,7 @@ obj-$(CONFIG_BITREVERSE) += bitrev.o
obj-y += list_sort.o
endif

+obj-$(CONFIG_$(PHASE_)OF_LIVE) += of_live.o
obj-$(CONFIG_$(PHASE_)TPM) += tpm-common.o
ifeq ($(CONFIG_$(PHASE_)TPM),y)
obj-$(CONFIG_TPM) += tpm_api.o

--
2.53.0