1 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
2 /*
3  * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
4  */
5 
6 #include <common.h>
7 #include <dm.h>
8 #include <ram.h>
9 
10 DECLARE_GLOBAL_DATA_PTR;
11 
12 int dram_init(void)
13 {
14 	struct ram_info ram;
15 	struct udevice *dev;
16 	int ret;
17 
18 	ret = uclass_get_device(UCLASS_RAM, 0, &dev);
19 	if (ret) {
20 		debug("RAM init failed: %d\n", ret);
21 		return ret;
22 	}
23 	ret = ram_get_info(dev, &ram);
24 	if (ret) {
25 		debug("Cannot get RAM size: %d\n", ret);
26 		return ret;
27 	}
28 	debug("RAM init base=%lx, size=%x\n", ram.base, ram.size);
29 
30 	gd->ram_size = ram.size;
31 
32 	return 0;
33 }
34