From 3ac66e05ab42afdd21d5027a481f4ba2af058c2f Mon Sep 17 00:00:00 2001
From: Mike Kasick <mike@kasick.org>
Date: Fri, 6 Jul 2012 01:59:15 -0400
Subject: [PATCH] Add ram_console support.

- Place in the last 1 MB of RAM, in high memory.
- Exclude the final 4 kB for the kexec hardboot page.
---
 arch/arm/mach-msm/board-m2_spr.c |   29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/arch/arm/mach-msm/board-m2_spr.c b/arch/arm/mach-msm/board-m2_spr.c
index 5691909..d9be17b 100644
--- a/arch/arm/mach-msm/board-m2_spr.c
+++ b/arch/arm/mach-msm/board-m2_spr.c
@@ -992,6 +992,25 @@ static int __init ext_display_setup(char *param)
 }
 early_param("ext_display", ext_display_setup);
 
+/* Exclude the last 4 kB to preserve the kexec hardboot page. */
+#ifdef CONFIG_ANDROID_RAM_CONSOLE
+#define RAM_CONSOLE_START 0xfff00000
+#define RAM_CONSOLE_SIZE  (SZ_1M-SZ_4K)
+
+static struct resource ram_console_resource[] = {
+	{
+		.flags = IORESOURCE_MEM,
+	},
+};
+
+static struct platform_device ram_console_device = {
+	.name          = "ram_console",
+	.id            = -1,
+	.num_resources = ARRAY_SIZE(ram_console_resource),
+	.resource      = ram_console_resource,
+};
+#endif
+
 unsigned int address = 0xea000000;
 unsigned int size = 0x100000;
 
@@ -1017,6 +1036,13 @@ static void __init msm8960_reserve(void)
 		ret = memblock_remove(address, size);
 		BUG_ON(ret);
 	}
+
+#ifdef CONFIG_ANDROID_RAM_CONSOLE
+	if (memblock_remove(RAM_CONSOLE_START, RAM_CONSOLE_SIZE) == 0) {
+		ram_console_resource[0].start = RAM_CONSOLE_START;
+		ram_console_resource[0].end   = RAM_CONSOLE_START+RAM_CONSOLE_SIZE-1;
+	}
+#endif
 }
 
 static int msm8960_change_memory_power(u64 start, u64 size,
@@ -4362,6 +4388,9 @@ static struct platform_device *m2_spr_devices[] __initdata = {
 #ifdef CONFIG_VIBETONZ
 	&vibetonz_device,
 #endif /* CONFIG_VIBETONZ */
+#ifdef CONFIG_ANDROID_RAM_CONSOLE
+	&ram_console_device,
+#endif
 };
 
 static void __init msm8960_i2c_init(void)
-- 
1.7.10

