[PATCH v1 2/4] common: move ram_base calculation to independent INITCALL()
Tom Rini
trini at konsulko.com
Mon Apr 6 18:14:05 CEST 2026
On Mon, Apr 06, 2026 at 05:56:41PM +0200, Marek Vasut wrote:
> On 4/6/26 5:41 PM, Tom Rini wrote:
> > On Sun, Apr 05, 2026 at 05:59:52AM +0200, Marek Vasut wrote:
> > > On 4/3/26 11:01 AM, Ilias Apalodimas wrote:
> > > > Currently, ram_base is calculated within setup_dest_addr().
> > > > However, upcoming patches that enable U-Boot relocation to the highest
> > > > DRAM bank require ram_base to be initialized earlier.
> > > >
> > > > The default dram_init_banksize() definition relies on ram_base
> > > > to calculate the start of the first bank. But following patches
> > > > will move that function to execute immediately before setup_dest_addr().
> > > >
> > > > So let's split the ram_base initialization in its own INITCALL.
> > > >
> > > > Signed-off-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
> > > > ---
> > > > common/board_f.c | 12 +++++++++---
> > > > 1 file changed, 9 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/common/board_f.c b/common/board_f.c
> > > > index 91c569da9682..7df92281c35a 100644
> > > > --- a/common/board_f.c
> > > > +++ b/common/board_f.c
> > > > @@ -329,6 +329,14 @@ __weak int arch_setup_dest_addr(void)
> > > > return 0;
> > > > }
> > > > +static int setup_ram_base(void)
> > > > +{
> > > > +#ifdef CFG_SYS_SDRAM_BASE
> > > > + gd->ram_base = CFG_SYS_SDRAM_BASE;
> > >
> > > Would it make sense to reset the variable to 0 in case CFG_SYS_SDRAM_BASE is
> > > not defined ?
> >
> > In that gd should be zeroed out do we need to?
> >
> > > Or better yet, how about moving CFG_SYS_SDRAM_BASE to Kconfig with default
> > > value 0 ?
> >
> > We don't set default values when a valid value must be provided for a
> > platform to work. It wasn't migrated to Kconfig as it's not really a
> > configurable value, it's something that if we could pull it from the
> > device tree, would be great. A someday middle-ground would be to mimic
> > how Zephyr uses the device tree and get some compile-time constants from
> > the device tree.
> It could still be a Kconfig hex value without description and with default
> value for each platform. That would still be better than the CFG_* remnants
> and would simplify this code.
I didn't do that migration because it *really* sucks (it depends on the
SoC, every time, some families from the same semi may share for a while,
or they may not). And that's why the CFG_SYS namespace was born. I don't
object to someone else trying to tackle it, which is why I suggested an
alternative too, that I think would solve the more general problem in a
way that won't be so painful moving forward either, but it's orthogonal
to this patch either way.
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20260406/9216ef28/attachment.sig>
More information about the U-Boot
mailing list