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