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 | |
Pragnesh Patel | 25269c0 | 2020-05-29 11:33:34 +0530 | [diff] [blame] | 6 | #include <fdtdec.h> |
| 7 | #include <init.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 8 | #include <asm/global_data.h> |
Pragnesh Patel | 25269c0 | 2020-05-29 11:33:34 +0530 | [diff] [blame] | 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 | |
Heinrich Schuchardt | 51a9aac | 2023-08-12 20:16:58 +0200 | [diff] [blame] | 23 | phys_addr_t board_get_usable_ram_top(phys_size_t total_size) |
Pragnesh Patel | 25269c0 | 2020-05-29 11:33:34 +0530 | [diff] [blame] | 24 | { |
Pragnesh Patel | 25269c0 | 2020-05-29 11:33:34 +0530 | [diff] [blame] | 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 | */ |
Bin Meng | 489b25a | 2021-01-31 20:35:57 +0800 | [diff] [blame] | 33 | if (gd->ram_top >= SZ_4G) |
| 34 | return SZ_4G - 1; |
| 35 | |
Pragnesh Patel | 25269c0 | 2020-05-29 11:33:34 +0530 | [diff] [blame] | 36 | return gd->ram_top; |
| 37 | } |