blob: cec130ec8dc6ba96f91212e933dfa2cc9d4f9d26 [file] [log] [blame]
Pragnesh Patel25269c02020-05-29 11:33:34 +05301// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
4 */
5
6#include <common.h>
7#include <fdtdec.h>
8#include <init.h>
Simon Glass3ba929a2020-10-30 21:38:53 -06009#include <asm/global_data.h>
Pragnesh Patel25269c02020-05-29 11:33:34 +053010#include <linux/sizes.h>
11
12DECLARE_GLOBAL_DATA_PTR;
13
14int dram_init(void)
15{
16 return fdtdec_setup_mem_size_base();
17}
18
19int dram_init_banksize(void)
20{
21 return fdtdec_setup_memory_banksize();
22}
23
24ulong board_get_usable_ram_top(ulong total_size)
25{
26#ifdef CONFIG_64BIT
27 /*
28 * Ensure that we run from first 4GB so that all
29 * addresses used by U-Boot are 32bit addresses.
30 *
31 * This in-turn ensures that 32bit DMA capable
32 * devices work fine because DMA mapping APIs will
33 * provide 32bit DMA addresses only.
34 */
35 if (gd->ram_top > SZ_4G)
36 return SZ_4G;
37#endif
38 return gd->ram_top;
39}