[ARM] tegra: Use memblock_remove to allocate carveout and framebuffer
Colin Cross [Tue, 19 Oct 2010 21:45:50 +0000 (14:45 -0700)]
This uses the patch by rmk to allow memblock_remove to be used to
remove areas of memory from the 1:1 mapping, allowing them to be
remapped later using iomap or, for Tegra, nvmap.

Also uses memblock_reserve to reserve the lp0 boot vector, so it
doesn't need to be copied later in tegra_init_suspend.

tegra_reserve should be called from the machine reserve callback
after any board-specific memory areas are reserved.

Change-Id: I26be8544a03b6da74fe66dc53a77681d431c303c
Signed-off-by: Colin Cross <ccross@android.com>

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

index db46d4d..16446e1 100644 (file)
@@ -29,10 +29,19 @@ void __init tegra_init_early(void);
 void __init tegra_map_common_io(void);
 void __init tegra_init_irq(void);
 void __init tegra_init_clock(void);
-void __init tegra_reserve(void);
+void __init tegra_reserve(unsigned long carveout_size, unsigned long fb_size,
+       unsigned long fb2_size);
 int __init tegra_pcie_init(bool init_port0, bool init_port1);
 void tegra_init_cache(void);
 
+extern unsigned long tegra_bootloader_fb_start;
+extern unsigned long tegra_bootloader_fb_size;
+extern unsigned long tegra_fb_start;
+extern unsigned long tegra_fb_size;
+extern unsigned long tegra_fb2_start;
+extern unsigned long tegra_fb2_size;
+extern unsigned long tegra_carveout_start;
+extern unsigned long tegra_carveout_size;
 extern unsigned long tegra_lp0_vec_start;
 extern unsigned long tegra_lp0_vec_size;
 
index 446b189..56dcf60 100644 (file)
 #include "fuse.h"
 #include "pm.h"
 
+unsigned long tegra_bootloader_fb_start;
+unsigned long tegra_bootloader_fb_size;
+unsigned long tegra_fb_start;
+unsigned long tegra_fb_size;
+unsigned long tegra_fb2_start;
+unsigned long tegra_fb2_size;
+unsigned long tegra_carveout_start;
+unsigned long tegra_carveout_size;
 unsigned long tegra_lp0_vec_start;
 unsigned long tegra_lp0_vec_size;
 
@@ -129,3 +137,79 @@ void __init tegra_reserve(void)
                tegra_lp0_vec_start,
                tegra_lp0_vec_start + tegra_lp0_vec_size - 1);
 }
+
+static int __init tegra_bootloader_fb_arg(char *options)
+{
+       char *p = options;
+
+       tegra_bootloader_fb_size = memparse(p, &p);
+       if (*p == '@')
+               tegra_bootloader_fb_start = memparse(p+1, &p);
+
+       pr_info("Found tegra_fbmem: %08lx@%08lx\n",
+               tegra_bootloader_fb_size, tegra_bootloader_fb_start);
+
+       return 0;
+}
+early_param("tegra_fbmem", tegra_bootloader_fb_arg);
+
+void __init tegra_reserve(unsigned long carveout_size, unsigned long fb_size,
+       unsigned long fb2_size)
+{
+       if (tegra_lp0_vec_size)
+               if (memblock_reserve(tegra_lp0_vec_start, tegra_lp0_vec_size))
+                       pr_err("Failed to reserve lp0_vec %08lx@%08lx\n",
+                               tegra_lp0_vec_size, tegra_lp0_vec_start);
+
+
+       tegra_carveout_start = memblock_end_of_DRAM() - carveout_size;
+       if (memblock_remove(tegra_carveout_start, carveout_size))
+               pr_err("Failed to remove carveout %08lx@%08lx from memory "
+                       "map\n",
+                       tegra_carveout_start, carveout_size);
+       else
+               tegra_carveout_size = carveout_size;
+
+       tegra_fb2_start = memblock_end_of_DRAM() - fb2_size;
+       if (memblock_remove(tegra_fb2_start, fb2_size))
+               pr_err("Failed to remove second framebuffer %08lx@%08lx from "
+                       "memory map\n",
+                       tegra_fb2_start, fb2_size);
+       else
+               tegra_fb2_size = fb2_size;
+
+       tegra_fb_start = memblock_end_of_DRAM() - fb_size;
+       if (memblock_remove(tegra_fb_start, fb_size))
+               pr_err("Failed to remove framebuffer %08lx@%08lx from memory "
+                       "map\n",
+                       tegra_fb_start, fb_size);
+       else
+               tegra_fb_size = fb_size;
+
+       /*
+        * TODO: We should copy the bootloader's framebuffer to the framebuffer
+        * allocated above, and then free this one.
+        */
+       if (tegra_bootloader_fb_size)
+               if (memblock_reserve(tegra_bootloader_fb_start,
+                               tegra_bootloader_fb_size))
+                       pr_err("Failed to reserve lp0_vec %08lx@%08lx\n",
+                               tegra_lp0_vec_size, tegra_lp0_vec_start);
+
+       pr_info("Tegra reserved memory:\n"
+               "LP0:                    %08lx - %08lx\n"
+               "Bootloader framebuffer: %08lx - %08lx\n"
+               "Framebuffer:            %08lx - %08lx\n"
+               "2nd Framebuffer:         %08lx - %08lx\n"
+               "Carveout:               %08lx - %08lx\n",
+               tegra_lp0_vec_start,
+               tegra_lp0_vec_start + tegra_lp0_vec_size - 1,
+               tegra_bootloader_fb_start,
+               tegra_bootloader_fb_start + tegra_bootloader_fb_size - 1,
+               tegra_fb_start,
+               tegra_fb_start + tegra_fb_size - 1,
+               tegra_fb2_start,
+               tegra_fb2_start + tegra_fb2_size - 1,
+               tegra_carveout_start,
+               tegra_carveout_start + tegra_carveout_size - 1);
+}