Pragnesh Patel | 25269c0 | 2020-05-29 11:33:34 +0530 | [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> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 9 | #include <asm/global_data.h> |
Pragnesh Patel | 25269c0 | 2020-05-29 11:33:34 +0530 | [diff] [blame] | 10 | #include <linux/sizes.h> |
| 11 | |
| 12 | DECLARE_GLOBAL_DATA_PTR; |
| 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 | } |
| 23 | |
| 24 | ulong board_get_usable_ram_top(ulong total_size) |
| 25 | { |
Pragnesh Patel | 25269c0 | 2020-05-29 11:33:34 +0530 | [diff] [blame] | 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 | */ |
Bin Meng | 489b25a | 2021-01-31 20:35:57 +0800 | [diff] [blame] | 34 | if (gd->ram_top >= SZ_4G) |
| 35 | return SZ_4G - 1; |
| 36 | |
Pragnesh Patel | 25269c0 | 2020-05-29 11:33:34 +0530 | [diff] [blame] | 37 | return gd->ram_top; |
| 38 | } |