Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/upstream-linus
[pandora-kernel.git] / arch / powerpc / mm / 44x_mmu.c
index d8c6efb..f60e006 100644 (file)
@@ -24,6 +24,8 @@
  */
 
 #include <linux/init.h>
+#include <linux/memblock.h>
+
 #include <asm/mmu.h>
 #include <asm/system.h>
 #include <asm/page.h>
@@ -184,10 +186,11 @@ void __init MMU_init_hw(void)
 unsigned long __init mmu_mapin_ram(unsigned long top)
 {
        unsigned long addr;
+       unsigned long memstart = memstart_addr & ~(PPC_PIN_SIZE - 1);
 
        /* Pin in enough TLBs to cover any lowmem not covered by the
         * initial 256M mapping established in head_44x.S */
-       for (addr = PPC_PIN_SIZE; addr < lowmem_end_addr;
+       for (addr = memstart + PPC_PIN_SIZE; addr < lowmem_end_addr;
             addr += PPC_PIN_SIZE) {
                if (mmu_has_feature(MMU_FTR_TYPE_47x))
                        ppc47x_pin_tlb(addr + PAGE_OFFSET, addr);
@@ -213,10 +216,28 @@ unsigned long __init mmu_mapin_ram(unsigned long top)
        return total_lowmem;
 }
 
+void setup_initial_memory_limit(phys_addr_t first_memblock_base,
+                               phys_addr_t first_memblock_size)
+{
+       u64 size;
+
+#ifndef CONFIG_RELOCATABLE
+       /* We don't currently support the first MEMBLOCK not mapping 0
+        * physical on those processors
+        */
+       BUG_ON(first_memblock_base != 0);
+#endif
+
+       /* 44x has a 256M TLB entry pinned at boot */
+       size = (min_t(u64, first_memblock_size, PPC_PIN_SIZE));
+       memblock_set_current_limit(first_memblock_base + size);
+}
+
 #ifdef CONFIG_SMP
 void __cpuinit mmu_init_secondary(int cpu)
 {
        unsigned long addr;
+       unsigned long memstart = memstart_addr & ~(PPC_PIN_SIZE - 1);
 
        /* Pin in enough TLBs to cover any lowmem not covered by the
         * initial 256M mapping established in head_44x.S
@@ -227,7 +248,7 @@ void __cpuinit mmu_init_secondary(int cpu)
         * stack. current (r2) isn't initialized, smp_processor_id()
         * will not work, current thread info isn't accessible, ...
         */
-       for (addr = PPC_PIN_SIZE; addr < lowmem_end_addr;
+       for (addr = memstart + PPC_PIN_SIZE; addr < lowmem_end_addr;
             addr += PPC_PIN_SIZE) {
                if (mmu_has_feature(MMU_FTR_TYPE_47x))
                        ppc47x_pin_tlb(addr + PAGE_OFFSET, addr);