All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] board: developerbox: move mem_map setup later
@ 2022-09-12 17:05 jassisinghbrar
  2022-10-07 15:47 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: jassisinghbrar @ 2022-09-12 17:05 UTC (permalink / raw)
  To: trini, u-boot; +Cc: kojima.masahisa, ilias.apalodimas, Jassi Brar

From: Jassi Brar <jaswinder.singh@linaro.org>

dram_init() can't modify global/static variables, so
move the mem_map setup later when bss is available.

Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
---
 board/socionext/developerbox/developerbox.c | 57 ++++++++++++---------
 1 file changed, 34 insertions(+), 23 deletions(-)

diff --git a/board/socionext/developerbox/developerbox.c b/board/socionext/developerbox/developerbox.c
index b680f77d80..412c811c12 100644
--- a/board/socionext/developerbox/developerbox.c
+++ b/board/socionext/developerbox/developerbox.c
@@ -56,8 +56,6 @@ struct draminfo {
 	struct draminfo_entry	entry[3];
 };
 
-struct draminfo *synquacer_draminfo = (void *)SQ_DRAMINFO_BASE;
-
 DECLARE_GLOBAL_DATA_PTR;
 
 #define LOAD_OFFSET 0x100
@@ -104,21 +102,44 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 
 int dram_init(void)
 {
+	struct draminfo *synquacer_draminfo = (void *)SQ_DRAMINFO_BASE;
+	struct draminfo_entry *ent = synquacer_draminfo->entry;
+
+	gd->ram_size = ent[0].size;
+	gd->ram_base = ent[0].base;
+
+	return 0;
+}
+
+int dram_init_banksize(void)
+{
+	struct draminfo *synquacer_draminfo = (void *)SQ_DRAMINFO_BASE;
+	struct draminfo_entry *ent = synquacer_draminfo->entry;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(gd->bd->bi_dram); i++) {
+		if (i < synquacer_draminfo->nr_regions) {
+			debug("%s: dram[%d] = %llx@%llx\n", __func__, i, ent[i].size, ent[i].base);
+			gd->bd->bi_dram[i].start = ent[i].base;
+			gd->bd->bi_dram[i].size = ent[i].size;
+		}
+	}
+
+	return 0;
+}
+
+void build_mem_map(void)
+{
+	struct draminfo *synquacer_draminfo = (void *)SQ_DRAMINFO_BASE;
 	struct draminfo_entry *ent = synquacer_draminfo->entry;
 	struct mm_region *mr;
 	int i, ri;
 
 	if (synquacer_draminfo->nr_regions < 1) {
 		log_err("Failed to get correct DRAM information\n");
-		return -1;
+		return;
 	}
 
-	/*
-	 * U-Boot RAM size must be under the first DRAM region so that it doesn't
-	 * access secure memory which is at the end of the first DRAM region.
-	 */
-	gd->ram_size = ent[0].size;
-
 	/* Update memory region maps */
 	for (i = 0; i < synquacer_draminfo->nr_regions; i++) {
 		if (i >= MAX_DDR_REGIONS)
@@ -134,24 +155,14 @@ int dram_init(void)
 		mr = &mem_map[DDR_REGION_INDEX(0)];
 		mem_map[ri].attrs = mr->attrs;
 	}
-
-	return 0;
 }
 
-int dram_init_banksize(void)
+void enable_caches(void)
 {
-	struct draminfo_entry *ent = synquacer_draminfo->entry;
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(gd->bd->bi_dram); i++) {
-		if (i < synquacer_draminfo->nr_regions) {
-			debug("%s: dram[%d] = %llx@%llx\n", __func__, i, ent[i].size, ent[i].base);
-			gd->bd->bi_dram[i].start = ent[i].base;
-			gd->bd->bi_dram[i].size = ent[i].size;
-		}
-	}
+	build_mem_map();
 
-	return 0;
+	icache_enable();
+	dcache_enable();
 }
 
 int print_cpuinfo(void)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 2/2] board: developerbox: move mem_map setup later
  2022-09-12 17:05 [PATCH 2/2] board: developerbox: move mem_map setup later jassisinghbrar
@ 2022-10-07 15:47 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2022-10-07 15:47 UTC (permalink / raw)
  To: jassisinghbrar; +Cc: u-boot, kojima.masahisa, ilias.apalodimas, Jassi Brar

[-- Attachment #1: Type: text/plain, Size: 352 bytes --]

On Mon, Sep 12, 2022 at 12:05:29PM -0500, jassisinghbrar@gmail.com wrote:

> From: Jassi Brar <jaswinder.singh@linaro.org>
> 
> dram_init() can't modify global/static variables, so
> move the mem_map setup later when bss is available.
> 
> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-07 15:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-12 17:05 [PATCH 2/2] board: developerbox: move mem_map setup later jassisinghbrar
2022-10-07 15:47 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.