blob: eec8b44e47ea25de97eaff776655247faab83f20 [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
Simon Glass97589732020-05-10 11:40:02 -06007#include <init.h>
Simon Glass0f2af882020-05-10 11:40:05 -06008#include <log.h>
Álvaro Fernández Rojas98a97a82017-04-25 00:39:20 +02009#include <ram.h>
10#include <dm.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060011#include <asm/global_data.h>
Álvaro Fernández Rojas98a97a82017-04-25 00:39:20 +020012
13DECLARE_GLOBAL_DATA_PTR;
14
15int dram_init(void)
16{
17 struct ram_info ram;
18 struct udevice *dev;
19 int err;
20
21 err = uclass_get_device(UCLASS_RAM, 0, &dev);
22 if (err) {
23 debug("DRAM init failed: %d\n", err);
24 return 0;
25 }
26
27 err = ram_get_info(dev, &ram);
28 if (err) {
29 debug("Cannot get DRAM size: %d\n", err);
30 return 0;
31 }
32
33 debug("SDRAM base=%zx, size=%x\n", ram.base, ram.size);
34
35 gd->ram_size = ram.size;
36
37 return 0;
38}