Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Bin Meng | 08e484c | 2014-12-17 15:50:36 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com> |
Bin Meng | 08e484c | 2014-12-17 15:50:36 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 7 | #include <init.h> |
Simon Glass | ddb39b2 | 2019-08-24 14:10:32 -0600 | [diff] [blame] | 8 | #include <asm/fsp/fsp_support.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 9 | #include <asm/global_data.h> |
Bin Meng | 08e484c | 2014-12-17 15:50:36 +0800 | [diff] [blame] | 10 | |
| 11 | int dram_init(void) |
| 12 | { |
Simon Glass | ddb39b2 | 2019-08-24 14:10:32 -0600 | [diff] [blame] | 13 | int ret; |
Bin Meng | 08e484c | 2014-12-17 15:50:36 +0800 | [diff] [blame] | 14 | |
Simon Glass | ddb39b2 | 2019-08-24 14:10:32 -0600 | [diff] [blame] | 15 | /* The FSP has already set up DRAM, so grab the info we need */ |
| 16 | ret = fsp_scan_for_ram_size(); |
| 17 | if (ret) |
| 18 | return ret; |
Bin Meng | 08e484c | 2014-12-17 15:50:36 +0800 | [diff] [blame] | 19 | |
Simon Glass | 91efff5 | 2019-12-06 21:42:07 -0700 | [diff] [blame] | 20 | if (IS_ENABLED(CONFIG_ENABLE_MRC_CACHE)) { |
| 21 | struct mrc_output *mrc = &gd->arch.mrc[MRC_TYPE_NORMAL]; |
| 22 | |
| 23 | mrc->buf = fsp_get_nvs_data(gd->arch.hob_list, &mrc->len); |
| 24 | } |
Bin Meng | 07793c08 | 2015-10-11 21:37:42 -0700 | [diff] [blame] | 25 | |
Bin Meng | 08e484c | 2014-12-17 15:50:36 +0800 | [diff] [blame] | 26 | return 0; |
| 27 | } |
| 28 | |
Bin Meng | 08e484c | 2014-12-17 15:50:36 +0800 | [diff] [blame] | 29 | /* |
| 30 | * This function looks for the highest region of memory lower than 4GB which |
| 31 | * has enough space for U-Boot where U-Boot is aligned on a page boundary. |
| 32 | * It overrides the default implementation found elsewhere which simply |
| 33 | * picks the end of ram, wherever that may be. The location of the stack, |
| 34 | * the relocation address, and how far U-Boot is moved by relocation are |
| 35 | * set in the global data structure. |
| 36 | */ |
| 37 | ulong board_get_usable_ram_top(ulong total_size) |
| 38 | { |
Bin Meng | db60d86 | 2014-12-17 15:50:49 +0800 | [diff] [blame] | 39 | return fsp_get_usable_lowmem_top(gd->arch.hob_list); |
Bin Meng | 08e484c | 2014-12-17 15:50:36 +0800 | [diff] [blame] | 40 | } |