1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (C) 2016 Imagination Technologies
4  */
5 
6 #include <common.h>
7 #include <init.h>
8 #include <asm/global_data.h>
9 
10 #include <asm/io.h>
11 
12 #include "boston-regs.h"
13 
14 DECLARE_GLOBAL_DATA_PTR;
15 
dram_init(void)16 int dram_init(void)
17 {
18 	u32 ddrconf0 = __raw_readl((uint32_t *)BOSTON_PLAT_DDRCONF0);
19 
20 	gd->ram_size = (phys_size_t)(ddrconf0 & BOSTON_PLAT_DDRCONF0_SIZE) <<
21 			30;
22 
23 	return 0;
24 }
25 
board_get_usable_ram_top(ulong total_size)26 ulong board_get_usable_ram_top(ulong total_size)
27 {
28 	DECLARE_GLOBAL_DATA_PTR;
29 
30 	if (gd->ram_top < CONFIG_SYS_SDRAM_BASE) {
31 		/* 2GB wrapped around to 0 */
32 		return CKSEG0ADDR(256 << 20);
33 	}
34 
35 	return min_t(unsigned long, gd->ram_top, CKSEG0ADDR(256 << 20));
36 }
37