Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Álvaro Fernández Rojas | 98a97a8 | 2017-04-25 00:39:20 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2016 Daniel Schwierzeck <daniel.schwierzeck@gmail.com> |
| 4 | * Copyright (C) 2017 Álvaro Fernández Rojas <noltari@gmail.com> |
Álvaro Fernández Rojas | 98a97a8 | 2017-04-25 00:39:20 +0200 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <ram.h> |
| 9 | #include <dm.h> |
| 10 | |
| 11 | DECLARE_GLOBAL_DATA_PTR; |
| 12 | |
| 13 | int dram_init(void) |
| 14 | { |
| 15 | struct ram_info ram; |
| 16 | struct udevice *dev; |
| 17 | int err; |
| 18 | |
| 19 | err = uclass_get_device(UCLASS_RAM, 0, &dev); |
| 20 | if (err) { |
| 21 | debug("DRAM init failed: %d\n", err); |
| 22 | return 0; |
| 23 | } |
| 24 | |
| 25 | err = ram_get_info(dev, &ram); |
| 26 | if (err) { |
| 27 | debug("Cannot get DRAM size: %d\n", err); |
| 28 | return 0; |
| 29 | } |
| 30 | |
| 31 | debug("SDRAM base=%zx, size=%x\n", ram.base, ram.size); |
| 32 | |
| 33 | gd->ram_size = ram.size; |
| 34 | |
| 35 | return 0; |
| 36 | } |