Add ram console device to cardhu
Alon Farchy [Thu, 16 Jun 2011 18:02:51 +0000 (11:02 -0700)]
ram console will buffer kmsg in reserved memory block, which
will be written to file /proc/last_ksmg on bootup.

Original-Change-Id: I6be8b9d22ce08040bbd95bf740a84b565e2300cf
Reviewed-on: http://git-master/r/37104
Tested-by: Alon Farchy <afarchy@nvidia.com>
Reviewed-by: Nitin Kumbhar <nkumbhar@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

Rebase-Id: R367cb265f487736c91fdcb0548d10a4b13f2f293

arch/arm/mach-tegra/board-cardhu.c

index 3d4e562..b576a23 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/spi/spi.h>
 #include <linux/i2c/atmel_mxt_ts.h>
 #include <linux/tegra_uart.h>
+#include <linux/memblock.h>
 #include <linux/spi-tegra.h>
 #include <linux/nfc/pn544.h>
 
@@ -68,6 +69,9 @@
 #include "baseband-xmm-power.h"
 #include "wdt-recovery.h"
 
+static unsigned long ramconsole_start;
+static unsigned long ramconsole_size;
+
 /* All units are in millicelsius */
 static struct tegra_thermal_data thermal_data = {
        .temp_throttle = 85000,
@@ -732,6 +736,19 @@ static struct platform_device cardhu_audio_aic326x_device = {
        },
 };
 
+static struct resource ram_console_resources[] = {
+       {
+               .flags = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device ram_console_device = {
+       .name           = "ram_console",
+       .id             = -1,
+       .num_resources  = ARRAY_SIZE(ram_console_resources),
+       .resource       = ram_console_resources,
+};
+
 static struct platform_device *cardhu_devices[] __initdata = {
        &tegra_pmu_device,
        &tegra_rtc_device,
@@ -766,6 +783,7 @@ static struct platform_device *cardhu_devices[] __initdata = {
 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
        &tegra_aes_device,
 #endif
+       &ram_console_device,
 };
 
 #define MXT_CONFIG_CRC  0xD62DE8
@@ -1106,6 +1124,14 @@ static void cardhu_sata_init(void)
 static void cardhu_sata_init(void) { }
 #endif
 
+static void cardhu_ramconsole_init(void)
+{
+       struct resource *res;
+       res = platform_get_resource(&ram_console_device, IORESOURCE_MEM, 0);
+       res->start = ramconsole_start;
+       res->end = res->start + ramconsole_size - 1;
+}
+
 static void __init tegra_cardhu_init(void)
 {
        tegra_thermal_init(&thermal_data);
@@ -1118,6 +1144,7 @@ static void __init tegra_cardhu_init(void)
        cardhu_edp_init();
 #endif
        cardhu_uart_init();
+       cardhu_ramconsole_init();
        platform_add_devices(cardhu_devices, ARRAY_SIZE(cardhu_devices));
        cardhu_sdhci_init();
        cardhu_regulator_init();
@@ -1148,6 +1175,15 @@ static void __init tegra_cardhu_init(void)
 
 static void __init tegra_cardhu_reserve(void)
 {
+       long ret;
+       ramconsole_size = SZ_1M;
+       ramconsole_start = memblock_end_of_DRAM() - ramconsole_size;
+       ret = memblock_remove(ramconsole_start, ramconsole_size);
+       if (ret) {
+               ramconsole_size = 0;
+               pr_err("Failed to reserve memory block for ram console\n");
+       }
+
 #if defined(CONFIG_NVMAP_CONVERT_CARVEOUT_TO_IOVMM)
        /* support 1920X1200 with 24bpp */
        tegra_reserve(0, SZ_8M + SZ_1M, SZ_8M + SZ_1M);