blob: 664b9b93eb62da8fda96d89f1e94078d5c7dde38 [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
Yanhong Wange28ec342023-03-29 11:42:08 +08007#include <fdtdec.h>
8#include <init.h>
9#include <linux/sizes.h>
10
11DECLARE_GLOBAL_DATA_PTR;
12
13int dram_init(void)
14{
15 return fdtdec_setup_mem_size_base();
16}
17
18int dram_init_banksize(void)
19{
20 return fdtdec_setup_memory_banksize();
21}
22
Heinrich Schuchardt51a9aac2023-08-12 20:16:58 +020023phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
Yanhong Wange28ec342023-03-29 11:42:08 +080024{
25 /*
26 * Ensure that we run from first 4GB so that all
27 * addresses used by U-Boot are 32bit addresses.
28 *
29 * This in-turn ensures that 32bit DMA capable
30 * devices work fine because DMA mapping APIs will
31 * provide 32bit DMA addresses only.
32 */
33 if (IS_ENABLED(CONFIG_64BIT) && gd->ram_top > SZ_4G)
34 return SZ_4G;
35
36 return gd->ram_top;
37}