diff options
| author | John Crispin <blogic@openwrt.org> | 2013-04-13 13:15:47 +0200 | 
|---|---|---|
| committer | Ralf Baechle <ralf@linux-mips.org> | 2013-05-08 01:19:11 +0200 | 
| commit | 4d9f77d2526840fc2b3d4dcaedfd2f633a6d5426 (patch) | |
| tree | 7efbfc22a32c23dc886855b325b88e7356a4f355 /arch/mips/kernel/setup.c | |
| parent | 9d50094dfec829a1361e595d5d09dfa0f2fe5057 (diff) | |
| download | olio-linux-3.10-4d9f77d2526840fc2b3d4dcaedfd2f633a6d5426.tar.xz olio-linux-3.10-4d9f77d2526840fc2b3d4dcaedfd2f633a6d5426.zip  | |
MIPS: add detect_memory_region()
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>
Patchwork: http://patchwork.linux-mips.org/patch/5178/
Diffstat (limited to 'arch/mips/kernel/setup.c')
| -rw-r--r-- | arch/mips/kernel/setup.c | 22 | 
1 files changed, 22 insertions, 0 deletions
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 4c774d5d508..c7f90519e58 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> @@ -77,6 +78,8 @@ EXPORT_SYMBOL(mips_io_port_base);  static struct resource code_resource = { .name = "Kernel code", };  static struct resource data_resource = { .name = "Kernel data", }; +static void *detect_magic __initdata = detect_memory_region; +  void __init add_memory_region(phys_t start, phys_t size, long type)  {  	int x = boot_mem_map.nr_map; @@ -122,6 +125,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) +{ +	void *dm = &detect_magic; +	phys_t size; + +	for (size = sz_min; size < sz_max; size <<= 1) { +		if (!memcmp(dm, dm + size, sizeof(detect_magic))) +			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;  |