Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH 1/7] MIPS: add detect_memory_region()
@ 2013-04-15 10:41 John Crispin
  2013-04-15 10:41 ` [PATCH 2/7] MIPS: ralink: add memory definition to struct ralink_soc_info John Crispin
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: John Crispin @ 2013-04-15 10:41 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: linux-mips, John Crispin

Add a generic way of detecting the available RAM. This function is based on the
implementation already used by ath79.

Signed-off-by: John Crispin <blogic@openwrt.org>
---
 arch/mips/include/asm/bootinfo.h |    1 +
 arch/mips/kernel/setup.c         |   20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/arch/mips/include/asm/bootinfo.h b/arch/mips/include/asm/bootinfo.h
index b71dd5b..4d2cdea 100644
--- a/arch/mips/include/asm/bootinfo.h
+++ b/arch/mips/include/asm/bootinfo.h
@@ -104,6 +104,7 @@ struct boot_mem_map {
 extern struct boot_mem_map boot_mem_map;
 
 extern void add_memory_region(phys_t start, phys_t size, long type);
+extern void detect_memory_region(phys_t start, phys_t sz_min,  phys_t sz_max);
 
 extern void prom_init(void);
 extern void prom_free_prom_memory(void);
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 4c774d5..dfe776a 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -23,6 +23,7 @@
 #include <linux/pfn.h>
 #include <linux/debugfs.h>
 #include <linux/kexec.h>
+#include <linux/sizes.h>
 
 #include <asm/addrspace.h>
 #include <asm/bootinfo.h>
@@ -122,6 +123,25 @@ void __init add_memory_region(phys_t start, phys_t size, long type)
 	boot_mem_map.nr_map++;
 }
 
+void __init detect_memory_region(phys_t start, phys_t sz_min,  phys_t sz_max)
+{
+	phys_t size;
+
+	for (size = sz_min; size < sz_max; size <<= 1) {
+		if (!memcmp(detect_memory_region,
+				detect_memory_region + size, 1024))
+			break;
+	}
+
+	pr_debug("Memory: %lluMB of RAM detected at 0x%llx (min: %lluMB, max: %lluMB)\n",
+		((unsigned long long) size) / SZ_1M,
+		(unsigned long long) start,
+		((unsigned long long) sz_min) / SZ_1M,
+		((unsigned long long) sz_max) / SZ_1M);
+
+	add_memory_region(start, size, BOOT_MEM_RAM);
+}
+
 static void __init print_memory_map(void)
 {
 	int i;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-04-15 11:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-15 10:41 [PATCH 1/7] MIPS: add detect_memory_region() John Crispin
2013-04-15 10:41 ` [PATCH 2/7] MIPS: ralink: add memory definition to struct ralink_soc_info John Crispin
2013-04-15 10:41 ` [PATCH 3/7] MIPS: ralink: add memory definition for RT305x John Crispin
2013-04-15 11:29   ` Sergei Shtylyov
2013-04-15 10:41 ` [PATCH 4/7] MIPS: ralink: add memory definition for RT2880 John Crispin
2013-04-15 10:41 ` [PATCH 5/7] MIPS: ralink: add memory definition for RT3883 John Crispin
2013-04-15 10:41 ` [PATCH 6/7] MIPS: ralink: add memory definition for MT7620 John Crispin
2013-04-15 10:41 ` [PATCH 7/7] MIPS: ralink: make use of the new memory detection code John Crispin
2013-04-15 11:26 ` [PATCH 1/7] MIPS: add detect_memory_region() Sergei Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox