[PATCH v1 2/3] fdtdec: Introduce fdtdec_setup_mem_ram_top() to determine end of topmost DRAM bank
Marek Vasut
marek.vasut at mailbox.org
Thu Mar 26 13:54:41 CET 2026
On 3/26/26 12:51 PM, Ilias Apalodimas wrote:
[...]
> +/**
> + * fdtdec_setup_mem_ram_top() - decode and setup gd->ram_top to highest address
> + * available in any memory bank
> + *
> + * Decode the /memory 'reg' property to determine the highest end of the memory
> + * bank and populate the global data ram_top with it.
> + *
> + * This function should be called from a boards board_get_usable_ram_top().
> + * This helper function allows for boards to query the device tree for topmost
> + * DRAM address.
> + *
> + * Return: 0 if OK, -EINVAL if the /memory node or reg property is missing or
> + * invalid
> + */
> +int fdtdec_setup_mem_ram_top(void);
> +
> /**
> * fdtdec_setup_memory_banksize() - decode and populate gd->bd->bi_dram
> *
> diff --git a/lib/fdtdec.c b/lib/fdtdec.c
> index d820f75b031d..c5ee2ecb3a49 100644
> --- a/lib/fdtdec.c
> +++ b/lib/fdtdec.c
> @@ -1162,6 +1162,26 @@ int fdtdec_setup_mem_size_base_lowest(void)
> return fdtdec_setup_mem_for_each_bank(fdtdec_setup_mem_size_base_lowest_bankfn);
> }
>
> +static void fdtdec_setup_mem_ram_top_bankfn(struct resource *res, int bank)
> +{
> + if ((res->end + 1) > gd->ram_top) {
> + gd->ram_top = res->end + 1;
> + gd->ram_size += res->end - res->start;
Since this is called fdtdec_setup_mem_ram_top(), it likely shouldn't be
manipulating with gd->ram_size ?
More information about the U-Boot
mailing list