Where the bloblist is located in internal memory and TF-A's BL31 blob
removes access to this memory, the best option seems to be to relocate
the bloblist just before running TF-A.

We can do the relocation in board-specific code, but need an option to
pick up the correct address within U-Boot proper.

Signed-off-by: Simon Glass <s...@chromium.org>
---

Changes in v2:
- Move the actual relocation code to a previous board-specific patch

 common/Kconfig    | 20 ++++++++++++++++++++
 common/bloblist.c | 15 ++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/common/Kconfig b/common/Kconfig
index 0e8c44f3f74..962e7fd76eb 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1125,6 +1125,26 @@ config SPL_BLOBLIST_ALLOC
 
 endchoice
 
+config SPL_BLOBLIST_RELOC
+       bool "Relocate the bloblist before existing SPL"
+       depends on BLOBLIST_FIXED
+       help
+         Some platforms locate the bloblist in SRAM in SPL. In some cases,
+         the TF-A BL31 blob removes access to SRAM, e.g. with Rockchip RK3399.
+
+         Enable this option to make U-Boot copy the bloblist from SRAM to SDRAM
+         before leaving SPL.
+
+config SPL_BLOBLIST_RELOC_ADDR
+       hex "Relocate the bloblist before existing SPL"
+       depends on SPL_BLOBLIST_RELOC
+       default BLOBLIST_ADDR
+       help
+         Sets the address to which the bloblist is relocated at the end of SPL.
+         U-Boot proper uses this address when it starts up. Note that U-Boot
+         always relocates the bloblist again as part of its own relocation
+         process.
+
 endif # SPL_BLOBLIST
 
 if TPL_BLOBLIST
diff --git a/common/bloblist.c b/common/bloblist.c
index 7eda94ecdf9..60c23d604b6 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -503,9 +503,22 @@ int bloblist_init(void)
        expected = fixed && !xpl_is_first_phase();
        if (xpl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST))
                expected = false;
-       if (fixed)
+       if (fixed) {
                addr = IF_ENABLED_INT(CONFIG_BLOBLIST_FIXED,
                                      CONFIG_BLOBLIST_ADDR);
+
+               if (xpl_phase() == PHASE_BOARD_F &&
+                   IS_ENABLED(CONFIG_SPL_BLOBLIST_RELOC)) {
+                       ulong addr = IF_ENABLED_INT(CONFIG_SPL_BLOBLIST_RELOC,
+                                           CONFIG_SPL_BLOBLIST_RELOC_ADDR);
+
+                       log_debug("Using bloblist at %lx\n", addr);
+                       bloblist_reloc(map_sysmem(addr, 0),
+                                      bloblist_get_total_size());
+               }
+               log_debug("bloblist addr=%lx\n", addr);
+       }
+
        size = CONFIG_BLOBLIST_SIZE;
        if (expected) {
                ret = bloblist_check(addr, size);
-- 
2.43.0

Reply via email to