Bin Meng | 510e379 | 2018-09-26 06:55:21 -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> |
Simon Glass | 67c4e9f | 2019-11-14 12:57:45 -0700 | [diff] [blame] | 8 | #include <init.h> |
Simon Glass | 401d1c4 | 2020-10-30 21:38:53 -0600 | [diff] [blame^] | 9 | #include <asm/global_data.h> |
Anup Patel | 26f4fd1 | 2019-02-25 08:14:30 +0000 | [diff] [blame] | 10 | #include <linux/sizes.h> |
| 11 | |
| 12 | DECLARE_GLOBAL_DATA_PTR; |
Bin Meng | 510e379 | 2018-09-26 06:55:21 -0700 | [diff] [blame] | 13 | |
| 14 | int dram_init(void) |
| 15 | { |
| 16 | return fdtdec_setup_mem_size_base(); |
| 17 | } |
| 18 | |
| 19 | int dram_init_banksize(void) |
| 20 | { |
| 21 | return fdtdec_setup_memory_banksize(); |
| 22 | } |
Anup Patel | 26f4fd1 | 2019-02-25 08:14:30 +0000 | [diff] [blame] | 23 | |
| 24 | ulong 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 | } |