@@ -4,15 +4,41 @@
*/
#include <common.h>
+#include <dm.h>
#include <fdtdec.h>
#include <init.h>
+#include <log.h>
+#include <ram.h>
#include <linux/sizes.h>
DECLARE_GLOBAL_DATA_PTR;
int dram_init(void)
{
+#if CONFIG_IS_ENABLED(RAM)
+ int ret;
+ struct ram_info info;
+ struct udevice *dev;
+
+ ret = uclass_get_device(UCLASS_RAM, 0, &dev);
+ if (ret) {
+ debug("DRAM init failed: %d\n", ret);
+ return ret;
+ }
+
+ ret = ram_get_info(dev, &info);
+ if (ret) {
+ debug("Cannot get DRAM size: %d\n", ret);
+ return ret;
+ }
+
+ gd->ram_base = info.base;
+ gd->ram_size = info.size;
+
+ return 0;
+#else
return fdtdec_setup_mem_size_base();
+#endif
}
int dram_init_banksize(void)
If CONFIG_RAM is enabled, use the ram device to get the base/size of memory. This provides an easy way for boards/cpus to hook into the dram_init logic, without needing to provide a second SYS_CPU. Signed-off-by: Sean Anderson <seanga2@gmail.com> --- arch/riscv/cpu/generic/dram.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)