blob: 2ad3f2044a2e6fd3081f8a12c6081dd2fa1230e7 [file] [log] [blame]
Yanhong Wange28ec342023-03-29 11:42:08 +08001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2022 StarFive Technology Co., Ltd.
4 * Author: Yanhong Wang <yanhong.wang@starfivetech.com>
5 */
6
7#include <common.h>
8#include <fdtdec.h>
9#include <init.h>
10#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
24phys_size_t board_get_usable_ram_top(phys_size_t total_size)
25{
26 /*
27 * Ensure that we run from first 4GB so that all
28 * addresses used by U-Boot are 32bit addresses.
29 *
30 * This in-turn ensures that 32bit DMA capable
31 * devices work fine because DMA mapping APIs will
32 * provide 32bit DMA addresses only.
33 */
34 if (IS_ENABLED(CONFIG_64BIT) && gd->ram_top > SZ_4G)
35 return SZ_4G;
36
37 return gd->ram_top;
38}