[U-Boot] [RESUBMIT PATCH v3 8/8] armv8: cavium: Get DRAM size from ATF

Sergey Temerkhanov s.temerkhanov at gmail.com
Thu Aug 13 18:51:28 CEST 2015


Change the dram_init() function on ThunderX to query ATF services for
the real installed DRAM size

Signed-off-by: Sergey Temerkhanov <s.temerkhanov at gmail.com>
Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla at cavium.com>
---

Changes in v3: None
Changes in v2: None

 board/cavium/thunderx/Makefile   |  2 +-
 board/cavium/thunderx/dram.c     | 35 +++++++++++++++++++++++++++++++++++
 board/cavium/thunderx/thunderx.c | 12 ------------
 3 files changed, 36 insertions(+), 13 deletions(-)
 create mode 100644 board/cavium/thunderx/dram.c

diff --git a/board/cavium/thunderx/Makefile b/board/cavium/thunderx/Makefile
index c78c414..9200dd6 100644
--- a/board/cavium/thunderx/Makefile
+++ b/board/cavium/thunderx/Makefile
@@ -5,4 +5,4 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-y	:= thunderx.o atf.o
+obj-y	:= thunderx.o atf.o dram.o
diff --git a/board/cavium/thunderx/dram.c b/board/cavium/thunderx/dram.c
new file mode 100644
index 0000000..858699d
--- /dev/null
+++ b/board/cavium/thunderx/dram.c
@@ -0,0 +1,35 @@
+/**
+ * (C) Copyright 2014, Cavium Inc.
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+**/
+
+#include <common.h>
+#include <cavium/atf.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int dram_init(void)
+{
+	ssize_t node_count = atf_node_count();
+	ssize_t dram_size;
+	int node;
+
+	printf("Initializing\nNodes in system: %zd\n", node_count);
+
+	gd->ram_size = 0;
+
+	for (node = 0; node < node_count; node++) {
+		dram_size = atf_dram_size(node);
+		printf("Node %d: %zd MBytes of DRAM\n", node, dram_size >> 20);
+		gd->ram_size += dram_size;
+	}
+
+	gd->ram_size -= MEM_BASE;
+
+	*(unsigned long *)CPU_RELEASE_ADDR = 0;
+
+	puts("DRAM size:");
+
+	return 0;
+}
diff --git a/board/cavium/thunderx/thunderx.c b/board/cavium/thunderx/thunderx.c
index 5a5e259..a5cf7c5 100644
--- a/board/cavium/thunderx/thunderx.c
+++ b/board/cavium/thunderx/thunderx.c
@@ -16,18 +16,6 @@ int board_init(void)
 	return 0;
 }
 
-int dram_init(void)
-{
-	/*
-	 * Clear spin table so that secondary processors
-	 * observe the correct value after waken up from wfe.
-	 */
-	*(unsigned long *)CPU_RELEASE_ADDR = 0;
-
-	gd->ram_size = PHYS_SDRAM_1_SIZE;
-	return 0;
-}
-
 int timer_init(void)
 {
 	return 0;
-- 
2.2.0



More information about the U-Boot mailing list