From 447f18d00de80384df334acdbe5972762d3d1e1e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 2 Nov 2024 11:49:41 -0600 Subject: fdt: Correct condition for receiving bloblist The condition for receiving a bloblist from TPL is reversed. This was only noticed are the other fixes landed. Fix it. Signed-off-by: Simon Glass Reviewed-by: Matthias Brugger --- lib/fdtdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/fdtdec.c') diff --git a/lib/fdtdec.c b/lib/fdtdec.c index b0655988029..60e28173c03 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1677,7 +1677,7 @@ int fdtdec_setup(void) */ if (CONFIG_IS_ENABLED(BLOBLIST) && (xpl_prev_phase() != PHASE_TPL || - !IS_ENABLED(CONFIG_TPL_BLOBLIST))) { + IS_ENABLED(CONFIG_TPL_BLOBLIST))) { ret = bloblist_maybe_init(); if (!ret) { gd->fdt_blob = bloblist_find(BLOBLISTT_CONTROL_FDT, 0); -- cgit v1.2.3 From fc37a73e667916e15e01e0f9d189da792df2b351 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 2 Nov 2024 11:49:42 -0600 Subject: fdt: Swap the signature for board_fdt_blob_setup() This returns a devicetree and updates a parameter with an error code. Swap it, since this fits better with the way U-Boot normally works. It also (more easily) allows leaving the existing pointer unchanged. No yaks were harmed in this change, but there is a very small code-size reduction. For sifive, the OF_BOARD option must be set for the function to be called, so there is no point in checking it again. Also OF_SEPARATE is defined always. Signed-off-by: Simon Glass Reviewed-by: Matthias Brugger Reviewed-by: Patrice Chotard [trini: Update total_compute] Signed-off-by: Tom Rini --- lib/fdtdec.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/fdtdec.c') diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 60e28173c03..c5d29d4385a 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1706,11 +1706,17 @@ int fdtdec_setup(void) /* Allow the board to override the fdt address. */ if (IS_ENABLED(CONFIG_OF_BOARD)) { - gd->fdt_blob = board_fdt_blob_setup(&ret); - if (!ret) + void *blob; + + blob = (void *)gd->fdt_blob; + ret = board_fdt_blob_setup(&blob); + if (ret) { + if (ret != -EEXIST) + return ret; + } else { gd->fdt_src = FDTSRC_BOARD; - else if (ret != -EEXIST) - return ret; + gd->fdt_blob = blob; + } } /* Allow the early environment to override the fdt address */ -- cgit v1.2.3 From 623f5cf517ae0e0f6f7132ac6411ea0a8dd9b3f7 Mon Sep 17 00:00:00 2001 From: Evgeny Bachinin Date: Wed, 11 Dec 2024 01:39:57 +0300 Subject: fdtdec: encapsulate dtb_dt_embedded() within Patch keeps the access to dtb_dt_embedded() within fdtdec API, by means of new API function introduction. This new function is a common place for updating appropriate global_data fields for OF_EMBED case. Also, the consequence of the patch is movement of '___dtb_dt_*begin' symbols' declaration from header file, because nobody used symbols outside the lib/fdtdec.c. Signed-off-by: Evgeny Bachinin Suggested-by: Simon Glass Reviewed-by: Simon Glass --- lib/fdtdec.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'lib/fdtdec.c') diff --git a/lib/fdtdec.c b/lib/fdtdec.c index b0655988029..9cb94a15844 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -93,6 +93,23 @@ static const char *const fdt_src_name[] = { [FDTSRC_BLOBLIST] = "bloblist", }; +extern u8 __dtb_dt_begin[]; /* embedded device tree blob */ +extern u8 __dtb_dt_spl_begin[]; /* embedded device tree blob for SPL/TPL */ + +/* Get a pointer to the embedded devicetree, if there is one, else NULL */ +static u8 *dtb_dt_embedded(void) +{ +#ifdef CONFIG_OF_EMBED +# ifdef CONFIG_XPL_BUILD + return __dtb_dt_spl_begin; +# else + return __dtb_dt_begin; +# endif +#else + return NULL; +#endif +} + const char *fdtdec_get_srcname(void) { return fdt_src_name[gd->fdt_src]; @@ -1664,6 +1681,12 @@ static void setup_multi_dtb_fit(void) } } +void fdtdec_setup_embed(void) +{ + gd->fdt_blob = dtb_dt_embedded(); + gd->fdt_src = FDTSRC_EMBED; +} + int fdtdec_setup(void) { int ret = -ENOENT; @@ -1699,8 +1722,7 @@ int fdtdec_setup(void) gd->fdt_blob = fdt_find_separate(); gd->fdt_src = FDTSRC_SEPARATE; } else { /* embed dtb in ELF file for testing / development */ - gd->fdt_blob = dtb_dt_embedded(); - gd->fdt_src = FDTSRC_EMBED; + fdtdec_setup_embed(); } } -- cgit v1.2.3 From e2f0e9a320d1efba9ed280e9a4b14df661daef54 Mon Sep 17 00:00:00 2001 From: Evgeny Bachinin Date: Wed, 11 Dec 2024 01:39:58 +0300 Subject: fdtdec: dtb_dt_embedded: replace ifdefs by IS_ENABLED() Patch fixes the checkpatch warnings like: ``` WARNING: Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' #94: FILE: lib/fdtdec.c:102: +#ifdef CONFIG_OF_EMBED ``` Signed-off-by: Evgeny Bachinin Reviewed-by: Simon Glass --- lib/fdtdec.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lib/fdtdec.c') diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 9cb94a15844..7f141889086 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -99,15 +99,15 @@ extern u8 __dtb_dt_spl_begin[]; /* embedded device tree blob for SPL/TPL */ /* Get a pointer to the embedded devicetree, if there is one, else NULL */ static u8 *dtb_dt_embedded(void) { -#ifdef CONFIG_OF_EMBED -# ifdef CONFIG_XPL_BUILD - return __dtb_dt_spl_begin; -# else - return __dtb_dt_begin; -# endif -#else - return NULL; -#endif + u8 *addr = NULL; + + if (IS_ENABLED(CONFIG_OF_EMBED)) { + addr = __dtb_dt_begin; + + if (IS_ENABLED(CONFIG_XPL_BUILD)) + addr = __dtb_dt_spl_begin; + } + return addr; } const char *fdtdec_get_srcname(void) -- cgit v1.2.3