summaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2022-04-20 14:33:53 -0400
committerTom Rini <[email protected]>2022-04-20 14:33:53 -0400
commite2743c2aa0390f9590c13197cfee288a11b88dc0 (patch)
tree127dc4d0079353e6f5cb7df708bfc5bc5f348bb5 /boot
parent246e03476ba325051600017b552460d7f37c3191 (diff)
parentdd2b8c1155d016800cbbaa1bd70efdd81f9da493 (diff)
Merge branch '2022-04-20-assorted-improvements'
- Two TI K3 updates, update SYS_MALLOC_F_LEN default to be 0x2000 and move TI am33xx to use that as well, fix DT relocation with multiple DRAM banks, and add a gpio read sub-command.
Diffstat (limited to 'boot')
-rw-r--r--boot/image-fdt.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/boot/image-fdt.c b/boot/image-fdt.c
index fdb69926a26..9db2cee9942 100644
--- a/boot/image-fdt.c
+++ b/boot/image-fdt.c
@@ -165,8 +165,11 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
{
void *fdt_blob = *of_flat_tree;
void *of_start = NULL;
+ u64 start, size, usable;
char *fdt_high;
+ ulong mapsize, low;
ulong of_len = 0;
+ int bank;
int err;
int disable_relocation = 0;
@@ -206,10 +209,39 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
(void *)(ulong) lmb_alloc(lmb, of_len, 0x1000);
}
} else {
- of_start =
- (void *)(ulong) lmb_alloc_base(lmb, of_len, 0x1000,
- env_get_bootm_mapsize()
- + env_get_bootm_low());
+ mapsize = env_get_bootm_mapsize();
+ low = env_get_bootm_low();
+ of_start = NULL;
+
+ for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
+ start = gd->bd->bi_dram[bank].start;
+ size = gd->bd->bi_dram[bank].size;
+
+ /* DRAM bank addresses are too low, skip it. */
+ if (start + size < low)
+ continue;
+
+ usable = min(size, (u64)mapsize);
+
+ /*
+ * At least part of this DRAM bank is usable, try
+ * using it for LMB allocation.
+ */
+ of_start =
+ (void *)(ulong) lmb_alloc_base(lmb, of_len, 0x1000,
+ start + usable);
+ /* Allocation succeeded, use this block. */
+ if (of_start != NULL)
+ break;
+
+ /*
+ * Reduce the mapping size in the next bank
+ * by the size of attempt in current bank.
+ */
+ mapsize -= usable - max(start, (u64)low);
+ if (!mapsize)
+ break;
+ }
}
if (of_start == NULL) {