ARM: Tegra: add support for persistent_ram
Varun Wadekar [Tue, 17 Apr 2012 12:40:49 +0000 (17:40 +0530)]
ram_console driver now depends on persistent_ram to carve the chunk
of memory that it needs. So ask persistent_ram driver to reserve
memory for ram_console instead of doing it in the tegra common
code.

Change-Id: I43854f059f0610f3b5bf54acd1af51e33f9dd330
Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
Signed-off-by: Johnny Qiu <joqiu@nvidia.com>
Reviewed-on: http://git-master/r/130066
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>

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

index a0f7596..ce34e17 100644 (file)
@@ -1469,7 +1469,6 @@ static void __init tegra_cardhu_init(void)
        cardhu_sensors_init();
        cardhu_setup_bluesleep();
        cardhu_sata_init();
-       //audio_wired_jack_init();
        cardhu_pins_state_init();
        cardhu_emc_init();
        tegra_release_bootloader_fb();
@@ -1496,7 +1495,6 @@ static void __init tegra_cardhu_reserve(void)
 #else
        tegra_reserve(SZ_128M, SZ_8M, SZ_8M);
 #endif
-       tegra_ram_console_debug_reserve(SZ_1M);
 }
 
 static const char *cardhu_dt_board_compat[] = {
index ba42b90..11c7dcb 100644 (file)
@@ -81,8 +81,6 @@ void __init tegra_init_irq(void);
 void __init tegra_dt_init_irq(void);
 void __init tegra_reserve(unsigned long carveout_size, unsigned long fb_size,
        unsigned long fb2_size);
-void __init tegra_ram_console_debug_reserve(unsigned long ram_console_size);
-void __init tegra_ram_console_debug_init(void);
 void __init tegra_release_bootloader_fb(void);
 void __init tegra_protected_aperture_init(unsigned long aperture);
 int  __init tegra_init_board_info(void);
@@ -92,6 +90,16 @@ bool is_tegra_debug_uartport_hs(void);
 int get_tegra_uart_debug_port_id(void);
 int arb_lost_recovery(int scl_gpio, int sda_gpio);
 
+#ifdef CONFIG_ANDROID_RAM_CONSOLE
+void __init tegra_ram_console_debug_reserve(unsigned long ram_console_size);
+void __init tegra_ram_console_debug_init(void);
+#else
+static inline void __init tegra_ram_console_debug_reserve(unsigned long ram_console_size)
+{}
+static inline void __init tegra_ram_console_debug_init(void)
+{}
+#endif
+
 extern unsigned long tegra_bootloader_fb_start;
 extern unsigned long tegra_bootloader_fb_size;
 extern unsigned long tegra_fb_start;
index adc2984..c9d961c 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/sched.h>
 #include <linux/cpufreq.h>
 #include <linux/of.h>
+#include <linux/persistent_ram.h>
 
 #include <asm/soc.h>
 #include <asm/hardware/cache-l2x0.h>
@@ -606,6 +607,7 @@ void __init tegra20_init_early(void)
        tegra_init_ahb_gizmo_settings();
        tegra_init_debug_uart_rate();
        tegra_gpio_resume_init();
+       tegra_ram_console_debug_reserve(SZ_1M);
 }
 #endif
 #ifdef CONFIG_ARCH_TEGRA_3x_SOC
@@ -629,6 +631,7 @@ void __init tegra30_init_early(void)
        tegra_init_ahb_gizmo_settings();
        tegra_init_debug_uart_rate();
        tegra_gpio_resume_init();
+       tegra_ram_console_debug_reserve(SZ_1M);
 }
 #endif
 #ifdef CONFIG_ARCH_TEGRA_11x_SOC
@@ -1179,41 +1182,49 @@ void __init tegra_reserve(unsigned long carveout_size, unsigned long fb_size,
        }
 }
 
-static struct resource ram_console_resources[] = {
-       {
-               .flags = IORESOURCE_MEM,
-       },
+#ifdef CONFIG_ANDROID_RAM_CONSOLE
+static struct persistent_ram_descriptor desc = {
+       .name = "ram_console",
 };
 
-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 persistent_ram ram = {
+       .descs = &desc,
+       .num_descs = 1,
 };
 
 void __init tegra_ram_console_debug_reserve(unsigned long ram_console_size)
 {
-       struct resource *res;
-       long ret;
+       int ret;
 
-       res = platform_get_resource(&ram_console_device, IORESOURCE_MEM, 0);
-       if (!res)
-               goto fail;
-       res->start = memblock_end_of_DRAM() - ram_console_size;
-       res->end = res->start + ram_console_size - 1;
-       ret = memblock_remove(res->start, ram_console_size);
+       ram.start = memblock_end_of_DRAM() - ram_console_size;
+       ram.size = ram_console_size;
+       ram.descs->size = ram_console_size;
+
+       INIT_LIST_HEAD(&ram.node);
+
+       ret = persistent_ram_early_init(&ram);
        if (ret)
                goto fail;
 
        return;
 
 fail:
-       ram_console_device.resource = NULL;
-       ram_console_device.num_resources = 0;
        pr_err("Failed to reserve memory block for ram console\n");
 }
 
+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,
+};
+
 void __init tegra_ram_console_debug_init(void)
 {
        int err;
@@ -1223,6 +1234,7 @@ void __init tegra_ram_console_debug_init(void)
                pr_err("%s: ram console registration failed (%d)!\n",
                        __func__, err);
 }
+#endif
 
 void __init tegra_release_bootloader_fb(void)
 {