m68k: add ColdFire 54xx CPU MMU memory init code
authorGreg Ungerer <gerg@uclinux.org>
Fri, 14 Oct 2011 05:06:22 +0000 (15:06 +1000)
committerGreg Ungerer <gerg@uclinux.org>
Fri, 30 Dec 2011 00:20:23 +0000 (10:20 +1000)
Add code to the 54xx ColdFire CPU init to setup memory ready for the m68k
paged memory start up.

Some of the RAM variables that were specific to the non-mmu code paths
now need to be used during this setup, so when CONFIG_MMU is enabled.
Move these out of page_no.h and into page.h.

Signed-off-by: Greg Ungerer <gerg@uclinux.org>
Acked-by: Matt Waddel <mwaddel@yahoo.com>
Acked-by: Kurt Mahan <kmahan@xmission.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
arch/m68k/include/asm/page.h
arch/m68k/include/asm/page_no.h
arch/m68k/platform/54xx/config.c

index dfebb7c1e3796bf49adf5c691095a4319424e906..ba6c91d5f3a9feab2ebeb18e60346f0a9877ab9a 100644 (file)
@@ -36,6 +36,10 @@ typedef struct page *pgtable_t;
 #define __pgd(x)       ((pgd_t) { (x) } )
 #define __pgprot(x)    ((pgprot_t) { (x) } )
 
+extern unsigned long _rambase;
+extern unsigned long _ramstart;
+extern unsigned long _ramend;
+
 #endif /* !__ASSEMBLY__ */
 
 #ifdef CONFIG_MMU
index a8d1c60eb9cec846ad26662497513f676623c7e1..90595721185fc20a4b3ba79cacab1461fd50e3b4 100644 (file)
@@ -5,9 +5,6 @@
  
 extern unsigned long memory_start;
 extern unsigned long memory_end;
-extern unsigned long _rambase;
-extern unsigned long _ramstart;
-extern unsigned long _ramend;
 
 #define get_user_page(vaddr)           __get_free_page(GFP_KERNEL)
 #define free_user_page(page, addr)     free_page(addr)
index 78130984db956045c4e3371d138f8c7e70070344..ee043540bfa2af220c89e47ec640e196c1f2444c 100644 (file)
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/mm.h>
+#include <linux/bootmem.h>
+#include <asm/pgalloc.h>
 #include <asm/machdep.h>
 #include <asm/coldfire.h>
 #include <asm/m54xxsim.h>
 #include <asm/mcfuart.h>
 #include <asm/m54xxgpt.h>
+#ifdef CONFIG_MMU
+#include <asm/mmu_context.h>
+#endif
 
 /***************************************************************************/
 
@@ -95,8 +101,49 @@ static void mcf54xx_reset(void)
 
 /***************************************************************************/
 
+#ifdef CONFIG_MMU
+
+unsigned long num_pages;
+
+static void __init mcf54xx_bootmem_alloc(void)
+{
+       unsigned long start_pfn;
+       unsigned long memstart;
+
+       /* _rambase and _ramend will be naturally page aligned */
+       m68k_memory[0].addr = _rambase;
+       m68k_memory[0].size = _ramend - _rambase;
+
+       /* compute total pages in system */
+       num_pages = (_ramend - _rambase) >> PAGE_SHIFT;
+
+       /* page numbers */
+       memstart = PAGE_ALIGN(_ramstart);
+       min_low_pfn = _rambase >> PAGE_SHIFT;
+       start_pfn = memstart >> PAGE_SHIFT;
+       max_low_pfn = _ramend >> PAGE_SHIFT;
+       high_memory = (void *)_ramend;
+
+       m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6;
+       module_fixup(NULL, __start_fixup, __stop_fixup);
+
+       /* setup bootmem data */
+       m68k_setup_node(0);
+       memstart += init_bootmem_node(NODE_DATA(0), start_pfn,
+               min_low_pfn, max_low_pfn);
+       free_bootmem_node(NODE_DATA(0), memstart, _ramend - memstart);
+}
+
+#endif /* CONFIG_MMU */
+
+/***************************************************************************/
+
 void __init config_BSP(char *commandp, int size)
 {
+#ifdef CONFIG_MMU
+       mcf54xx_bootmem_alloc();
+       mmu_context_init();
+#endif
        mach_reset = mcf54xx_reset;
        m54xx_uarts_init();
 }
This page took 0.026743 seconds and 5 git commands to generate.