summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorIlias Apalodimas <[email protected]>2026-06-17 10:48:19 +0300
committerTom Rini <[email protected]>2026-06-24 18:13:24 -0600
commit1174c99ab421168221be372bd83a4143bf5f167d (patch)
tree8cf44beda8b853593a111add53bfab27c0b06293 /include
parent47e9c542ee032e89f556adc73c2aeff3acb0e5a9 (diff)
treewide: move bi_dram[] from bd to gd
Currently, the bi_dram[] information is stored in the board info structure (bd). Because bd is only valid after reserve_board(), dram_init_banksize() must be called late in the initialization process. This limitation is problematic, as it forces us to rely on a variety of bespoke functions to determine board RAM, bank memory sizes, and other early setup requirements. By moving bi_dram[] into the global data (gd), we can run it earlier. This is particularly convenient since boards define their own dram_init_banksize() routines, which do not always rely on parsing Device Tree (DT) memory nodes. Additionally, U-Boot defaults to relocating to the top of the first memory bank. While boards currently use custom functions to override this behavior, having the DRAM bank information available earlier in gd makes relocating to a different bank trivial and standardizes the process. Reviewed-by: Anshul Dalal <[email protected]> Tested-by: Michal Simek <[email protected]> # Versal Gen 2 Vek385 Tested-by: Anshul Dalal <[email protected]> Reviewed-by: Simon Glass <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]> Tested-by: Christophe Leroy (CS GROUP) <[email protected]>
Diffstat (limited to 'include')
-rw-r--r--include/asm-generic/global_data.h7
-rw-r--r--include/asm-generic/u-boot.h4
-rw-r--r--include/configs/m53menlo.h4
-rw-r--r--include/configs/mx53cx9020.h4
-rw-r--r--include/configs/mx53loco.h4
-rw-r--r--include/configs/mx53ppd.h4
-rw-r--r--include/fdtdec.h7
-rw-r--r--include/init.h2
8 files changed, 20 insertions, 16 deletions
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index ba6a10cf2ad..ad7ebb1bbc9 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -457,6 +457,13 @@ struct global_data {
*/
struct upl *upl;
#endif
+ /**
+ * @dram: array describing DRAM banks (start address and size for each bank)
+ */
+ struct { /* RAM configuration */
+ phys_addr_t start;
+ phys_size_t size;
+ } dram[CONFIG_NR_DRAM_BANKS];
};
#ifndef DO_DEPS_ONLY
static_assert(sizeof(struct global_data) == GD_SIZE);
diff --git a/include/asm-generic/u-boot.h b/include/asm-generic/u-boot.h
index 8c619c1b74a..931fe2f3274 100644
--- a/include/asm-generic/u-boot.h
+++ b/include/asm-generic/u-boot.h
@@ -59,10 +59,6 @@ struct bd_info {
#endif
ulong bi_arch_number; /* unique id for this board */
ulong bi_boot_params; /* where this board expects params */
- struct { /* RAM configuration */
- phys_addr_t start;
- phys_size_t size;
- } bi_dram[CONFIG_NR_DRAM_BANKS];
};
#endif /* __ASSEMBLY__ */
diff --git a/include/configs/m53menlo.h b/include/configs/m53menlo.h
index a6aafb51854..36e330887cd 100644
--- a/include/configs/m53menlo.h
+++ b/include/configs/m53menlo.h
@@ -15,9 +15,9 @@
* Memory configurations
*/
#define PHYS_SDRAM_1 CSD0_BASE_ADDR
-#define PHYS_SDRAM_1_SIZE (gd->bd->bi_dram[0].size)
+#define PHYS_SDRAM_1_SIZE (gd->dram[0].size)
#define PHYS_SDRAM_2 CSD1_BASE_ADDR
-#define PHYS_SDRAM_2_SIZE (gd->bd->bi_dram[1].size)
+#define PHYS_SDRAM_2_SIZE (gd->dram[1].size)
#define PHYS_SDRAM_SIZE (gd->ram_size)
#define CFG_SYS_SDRAM_BASE (PHYS_SDRAM_1)
diff --git a/include/configs/mx53cx9020.h b/include/configs/mx53cx9020.h
index 2bd1426c7d9..e823611d2e4 100644
--- a/include/configs/mx53cx9020.h
+++ b/include/configs/mx53cx9020.h
@@ -51,9 +51,9 @@
/* Physical Memory Map */
#define PHYS_SDRAM_1 CSD0_BASE_ADDR
-#define PHYS_SDRAM_1_SIZE (gd->bd->bi_dram[0].size)
+#define PHYS_SDRAM_1_SIZE (gd->dram[0].size)
#define PHYS_SDRAM_2 CSD1_BASE_ADDR
-#define PHYS_SDRAM_2_SIZE (gd->bd->bi_dram[1].size)
+#define PHYS_SDRAM_2_SIZE (gd->dram[1].size)
#define PHYS_SDRAM_SIZE (gd->ram_size)
#define CFG_SYS_SDRAM_BASE (PHYS_SDRAM_1)
diff --git a/include/configs/mx53loco.h b/include/configs/mx53loco.h
index 14095b99f03..acd6eb6f8ac 100644
--- a/include/configs/mx53loco.h
+++ b/include/configs/mx53loco.h
@@ -86,9 +86,9 @@
/* Physical Memory Map */
#define PHYS_SDRAM_1 CSD0_BASE_ADDR
-#define PHYS_SDRAM_1_SIZE (gd->bd->bi_dram[0].size)
+#define PHYS_SDRAM_1_SIZE (gd->dram[0].size)
#define PHYS_SDRAM_2 CSD1_BASE_ADDR
-#define PHYS_SDRAM_2_SIZE (gd->bd->bi_dram[1].size)
+#define PHYS_SDRAM_2_SIZE (gd->dram[1].size)
#define PHYS_SDRAM_SIZE (gd->ram_size)
#define CFG_SYS_SDRAM_BASE (PHYS_SDRAM_1)
diff --git a/include/configs/mx53ppd.h b/include/configs/mx53ppd.h
index 3707de254e1..65babf50546 100644
--- a/include/configs/mx53ppd.h
+++ b/include/configs/mx53ppd.h
@@ -81,9 +81,9 @@
/* Physical Memory Map */
#define PHYS_SDRAM_1 CSD0_BASE_ADDR
-#define PHYS_SDRAM_1_SIZE (gd->bd->bi_dram[0].size)
+#define PHYS_SDRAM_1_SIZE (gd->dram[0].size)
#define PHYS_SDRAM_2 CSD1_BASE_ADDR
-#define PHYS_SDRAM_2_SIZE (gd->bd->bi_dram[1].size)
+#define PHYS_SDRAM_2_SIZE (gd->dram[1].size)
#define PHYS_SDRAM_SIZE (gd->ram_size)
#define CFG_SYS_SDRAM_BASE (PHYS_SDRAM_1)
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 46eaa0da63c..51d9f14a9f2 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -57,6 +57,7 @@ struct fdt_memory {
};
struct bd_info;
+struct global_data;
/**
* enum fdt_source_t - indicates where the devicetree came from
@@ -974,7 +975,7 @@ int fdtdec_setup_mem_size_base(void);
int fdtdec_setup_mem_size_base_lowest(void);
/**
- * fdtdec_setup_memory_banksize() - decode and populate gd->bd->bi_dram
+ * fdtdec_setup_memory_banksize() - decode and populate gd->dram
*
* Decode the /memory 'reg' property to determine the address and size of the
* memory banks. Use this data to populate the global data board info with the
@@ -1256,12 +1257,12 @@ int board_fdt_blob_setup(void **fdtp);
* @param basep Returns base address of first memory bank (NULL to
* ignore)
* @param sizep Returns total memory size (NULL to ignore)
- * @param bd Updated with the memory bank information (NULL to skip)
+ * @param gd_ptr Updated with the memory bank information (NULL to skip)
* Return: 0 if OK, -ve on error
*/
int fdtdec_decode_ram_size(const void *blob, const char *area, int board_id,
phys_addr_t *basep, phys_size_t *sizep,
- struct bd_info *bd);
+ struct global_data *gd_ptr);
/**
* fdtdec_get_srcname() - Get the name of where the devicetree comes from
diff --git a/include/init.h b/include/init.h
index c31ebd83b85..23466d3f153 100644
--- a/include/init.h
+++ b/include/init.h
@@ -80,7 +80,7 @@ int dram_init(void);
* dram_init_banksize() - Set up DRAM bank sizes
*
* This can be implemented by boards to set up the DRAM bank information in
- * gd->bd->bi_dram(). It is called just before relocation, after dram_init()
+ * gd->dram[] It is called just before relocation, after dram_init()
* is called.
*
* If this is not provided, a default implementation will try to set up a