blob: f3a8134a3f2f5c3767954bc43f8143cb99a589dc [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Bin Meng08e484c2014-12-17 15:50:36 +08002/*
3 * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
Bin Meng08e484c2014-12-17 15:50:36 +08004 */
5
Simon Glass97589732020-05-10 11:40:02 -06006#include <init.h>
Simon Glassddb39b22019-08-24 14:10:32 -06007#include <asm/fsp/fsp_support.h>
Simon Glass3ba929a2020-10-30 21:38:53 -06008#include <asm/global_data.h>
Bin Meng08e484c2014-12-17 15:50:36 +08009
10int dram_init(void)
11{
Simon Glassddb39b22019-08-24 14:10:32 -060012 int ret;
Bin Meng08e484c2014-12-17 15:50:36 +080013
Simon Glassddb39b22019-08-24 14:10:32 -060014 /* The FSP has already set up DRAM, so grab the info we need */
15 ret = fsp_scan_for_ram_size();
16 if (ret)
17 return ret;
Bin Meng08e484c2014-12-17 15:50:36 +080018
Simon Glass91efff52019-12-06 21:42:07 -070019 if (IS_ENABLED(CONFIG_ENABLE_MRC_CACHE)) {
20 struct mrc_output *mrc = &gd->arch.mrc[MRC_TYPE_NORMAL];
21
22 mrc->buf = fsp_get_nvs_data(gd->arch.hob_list, &mrc->len);
23 }
Bin Meng07793c082015-10-11 21:37:42 -070024
Bin Meng08e484c2014-12-17 15:50:36 +080025 return 0;
26}
27
Bin Meng08e484c2014-12-17 15:50:36 +080028/*
29 * This function looks for the highest region of memory lower than 4GB which
30 * has enough space for U-Boot where U-Boot is aligned on a page boundary.
31 * It overrides the default implementation found elsewhere which simply
32 * picks the end of ram, wherever that may be. The location of the stack,
33 * the relocation address, and how far U-Boot is moved by relocation are
34 * set in the global data structure.
35 */
Heinrich Schuchardt51a9aac2023-08-12 20:16:58 +020036phys_addr_t board_get_usable_ram_top(phys_size_t total_size)
Bin Meng08e484c2014-12-17 15:50:36 +080037{
Bin Mengdb60d862014-12-17 15:50:49 +080038 return fsp_get_usable_lowmem_top(gd->arch.hob_list);
Bin Meng08e484c2014-12-17 15:50:36 +080039}