blob: 764ce892318c3d05b7af7d7faae8b75de1a19aa6 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Álvaro Fernández Rojas98a97a82017-04-25 00:39:20 +02002/*
3 * Copyright (C) 2016 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
4 * Copyright (C) 2017 Álvaro Fernández Rojas <noltari@gmail.com>
Álvaro Fernández Rojas98a97a82017-04-25 00:39:20 +02005 */
6
7#include <common.h>
Simon Glass97589732020-05-10 11:40:02 -06008#include <init.h>
Álvaro Fernández Rojas98a97a82017-04-25 00:39:20 +02009#include <ram.h>
10#include <dm.h>
11
12DECLARE_GLOBAL_DATA_PTR;
13
14int dram_init(void)
15{
16 struct ram_info ram;
17 struct udevice *dev;
18 int err;
19
20 err = uclass_get_device(UCLASS_RAM, 0, &dev);
21 if (err) {
22 debug("DRAM init failed: %d\n", err);
23 return 0;
24 }
25
26 err = ram_get_info(dev, &ram);
27 if (err) {
28 debug("Cannot get DRAM size: %d\n", err);
29 return 0;
30 }
31
32 debug("SDRAM base=%zx, size=%x\n", ram.base, ram.size);
33
34 gd->ram_size = ram.size;
35
36 return 0;
37}