summaryrefslogtreecommitdiffstats
path: root/target/linux/ramips/patches-3.10/999-memory-detect.patch
blob: 165a1f0deddc0cab184e27c497461d45d81f67c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
--- a/arch/mips/ralink/of.c
+++ b/arch/mips/ralink/of.c
@@ -80,6 +80,16 @@ void __init device_tree_init(void)
 }
 
 extern struct boot_param_header __image_dtb;
+static int memory_dtb;
+
+static int __init early_init_dt_find_memory(unsigned long node, const char *uname,
+				     int depth, void *data)
+{
+	if (depth == 1 && !strcmp(uname, "memory@0"))
+		memory_dtb = 1;
+
+	return 0;
+}
 
 void __init plat_mem_setup(void)
 {
@@ -90,8 +100,10 @@ void __init plat_mem_setup(void)
 	 * parsed resulting in our memory appearing
 	 */
 	__dt_setup_arch(&__image_dtb);
-
-	if (soc_info.mem_size)
+	of_scan_flat_dt(early_init_dt_find_memory, NULL);
+	if (memory_dtb)
+		of_scan_flat_dt(early_init_dt_scan_memory, NULL);
+	else if (soc_info.mem_size)
 		add_memory_region(soc_info.mem_base, soc_info.mem_size * SZ_1M,
 				  BOOT_MEM_RAM);
 	else