[PATCH v3 3/6] treewide: move bi_dram[] from bd to gd

Ilias Apalodimas ilias.apalodimas at linaro.org
Wed Apr 29 08:19:46 CEST 2026


On Tue, 28 Apr 2026 at 16:48, Simon Glass <sjg at chromium.org> wrote:
>
> Hi Ilias,
>
> On 2026-04-27T10:08:21, Ilias Apalodimas <ilias.apalodimas at linaro.org> wrote:
> > 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 <anshuld at ti.com>
> > [...]
>
> > diff --git 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];
> >  };
>
> The mediatek boards recently started accessing this field, e.g.
> arch/arm/mach-mediatek/mt7987/init.c

Where? I can't find anything in -master.

>
> > diff --git a/include/init.h b/include/init.h
> > @@ -74,7 +74,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.
>
> Since you are touching this, please use gd->dram[] - it's an array,
> not a function.

Sure
>
> Regards,
> Simon


More information about the U-Boot mailing list