arm: tegra: move ram console to common codes
Haley Teng [Tue, 27 Sep 2011 04:20:32 +0000 (12:20 +0800)]
cleanup ram console related source codes and move most of the
implementation in board files to common.c since ram console is a common
debug mechanism.

bug 873307

Signed-off-by: Haley Teng <hteng@nvidia.com>
Reviewed-on: http://git-master/r/54598
Reviewed-on: http://git-master/r/66588
(cherry picked from commit 119ce36b7bed370a528dfebc80bd79698118248d)

Change-Id: I8b769b422305101a97f1fbc99db4af48dc7d4f25
Reviewed-on: http://git-master/r/71961
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>
Reviewed-on: http://git-master/r/74552
Reviewed-by: Rohan Somvanshi <rsomvanshi@nvidia.com>
Tested-by: Rohan Somvanshi <rsomvanshi@nvidia.com>

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

index 2fc621d..a2be52f 100644 (file)
@@ -549,19 +549,6 @@ static struct platform_device cardhu_audio_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,
@@ -593,7 +580,6 @@ 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
@@ -982,6 +968,7 @@ static void __init tegra_cardhu_init(void)
        cardhu_uart_init();
        cardhu_tsensor_init();
        platform_add_devices(cardhu_devices, ARRAY_SIZE(cardhu_devices));
+       tegra_ram_console_debug_init();
        cardhu_sdhci_init();
        cardhu_regulator_init();
        cardhu_gpio_switch_regulator_init();
@@ -1014,19 +1001,7 @@ static void __init cardhu_ramconsole_reserve(unsigned long size)
        struct resource *res;
        long ret;
 
-       res = platform_get_resource(&ram_console_device, IORESOURCE_MEM, 0);
-       if (!res) {
-               pr_err("Failed to find memory resource for ram console\n");
-               return;
-       }
-       res->start = memblock_end_of_DRAM() - size;
-       res->end = res->start + size - 1;
-       ret = memblock_remove(res->start, size);
-       if (ret) {
-               ram_console_device.resource = NULL;
-               ram_console_device.num_resources = 0;
-               pr_err("Failed to reserve memory block for ram console\n");
-       }
+       tegra_ram_console_debug_reserve(SZ_1M);
 }
 
 static void __init tegra_cardhu_reserve(void)
index b5bedac..a163720 100644 (file)
@@ -510,19 +510,6 @@ static struct platform_device enterprise_audio_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 *enterprise_devices[] __initdata = {
        &tegra_pmu_device,
        &tegra_rtc_device,
@@ -544,7 +531,6 @@ static struct platform_device *enterprise_devices[] __initdata = {
 #if defined(CONFIG_CRYPTO_DEV_TEGRA_AES)
        &tegra_aes_device,
 #endif
-       &ram_console_device,
 };
 
 #define MXT_CONFIG_CRC 0x62F903
@@ -945,6 +931,7 @@ static void __init tegra_enterprise_init(void)
        enterprise_usb_init();
        enterprise_tsensor_init();
        platform_add_devices(enterprise_devices, ARRAY_SIZE(enterprise_devices));
+       tegra_ram_console_debug_init();
        enterprise_regulator_init();
        enterprise_sdhci_init();
 #ifdef CONFIG_TEGRA_EDP_LIMITS
@@ -970,19 +957,7 @@ static void __init tegra_enterprise_ramconsole_reserve(unsigned long size)
        struct resource *res;
        long ret;
 
-       res = platform_get_resource(&ram_console_device, IORESOURCE_MEM, 0);
-       if (!res) {
-               pr_err("Failed to find memory resource for ram console\n");
-               return;
-       }
-       res->start = memblock_end_of_DRAM() - size;
-       res->end = res->start + size - 1;
-       ret = memblock_remove(res->start, size);
-       if (ret) {
-               ram_console_device.resource = NULL;
-               ram_console_device.num_resources = 0;
-               pr_err("Failed to reserve memory block for ram console\n");
-       }
+       tegra_ram_console_debug_reserve(SZ_1M);
 }
 
 static void __init tegra_enterprise_reserve(void)
index bb53345..950ccdf 100644 (file)
@@ -45,6 +45,8 @@ void __init tegra_init_clock(void);
 void __init tegra_reserve(unsigned long carveout_size, unsigned long fb_size,
        unsigned long fb2_size);
 void tegra_init_cache(bool init);
+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);
 void tegra_move_framebuffer(unsigned long to, unsigned long from,
index ea3ca06..2acf4bd 100644 (file)
@@ -896,6 +896,51 @@ void __init tegra_reserve(unsigned long carveout_size, unsigned long fb_size,
 #endif
 }
 
+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_reserve(unsigned long ram_console_size)
+{
+       struct resource *res;
+       long 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);
+       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");
+}
+
+void __init tegra_ram_console_debug_init(void)
+{
+       int err;
+
+       err = platform_device_register(&ram_console_device);
+       if (err) {
+               pr_err("%s: ram console registration failed (%d)!\n", __func__, err);
+       }
+}
+
 void __init tegra_release_bootloader_fb(void)
 {
        /* Since bootloader fb is reserved in common.c, it is freed here. */