Green Wan | 7f33743 | 2021-05-27 06:52:07 -0700 | [diff] [blame] | 1 | // 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> |
| 9 | #include <linux/sizes.h> |
| 10 | |
| 11 | DECLARE_GLOBAL_DATA_PTR; |
| 12 | |
| 13 | int dram_init(void) |
| 14 | { |
| 15 | return fdtdec_setup_mem_size_base(); |
| 16 | } |
| 17 | |
| 18 | int dram_init_banksize(void) |
| 19 | { |
| 20 | return fdtdec_setup_memory_banksize(); |
| 21 | } |
| 22 | |
Pali Rohár | 4f4f583 | 2022-09-09 17:32:40 +0200 | [diff] [blame] | 23 | phys_size_t board_get_usable_ram_top(phys_size_t total_size) |
Green Wan | 7f33743 | 2021-05-27 06:52:07 -0700 | [diff] [blame] | 24 | { |
| 25 | #ifdef CONFIG_64BIT |
| 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 (gd->ram_top > SZ_4G) |
| 35 | return SZ_4G; |
| 36 | #endif |
| 37 | return gd->ram_top; |
| 38 | } |