Merge git://git.infradead.org/mtd-2.6
[pandora-kernel.git] / arch / sh / kernel / setup.c
index 2c9ab28..2727346 100644 (file)
@@ -95,6 +95,7 @@ unsigned long memory_start;
 EXPORT_SYMBOL(memory_start);
 unsigned long memory_end = 0;
 EXPORT_SYMBOL(memory_end);
+unsigned long memory_limit = 0;
 
 static struct resource mem_resources[MAX_NUMNODES];
 
@@ -102,51 +103,18 @@ int l1i_cache_shape, l1d_cache_shape, l2_cache_shape;
 
 static int __init early_parse_mem(char *p)
 {
-       unsigned long size;
+       if (!p)
+               return 1;
 
-       memory_start = (unsigned long)__va(__MEMORY_START);
-       size = memparse(p, &p);
+       memory_limit = PAGE_ALIGN(memparse(p, &p));
 
-       if (size > __MEMORY_SIZE) {
-               printk(KERN_ERR
-                       "Using mem= to increase the size of kernel memory "
-                       "is not allowed.\n"
-                       "  Recompile the kernel with the correct value for "
-                       "CONFIG_MEMORY_SIZE.\n");
-               return 0;
-       }
-
-       memory_end = memory_start + size;
+       pr_notice("Memory limited to %ldMB\n", memory_limit >> 20);
 
        return 0;
 }
 early_param("mem", early_parse_mem);
 
-/*
- * Register fully available low RAM pages with the bootmem allocator.
- */
-static void __init register_bootmem_low_pages(void)
-{
-       unsigned long curr_pfn, last_pfn, pages;
-
-       /*
-        * We are rounding up the start address of usable memory:
-        */
-       curr_pfn = PFN_UP(__MEMORY_START);
-
-       /*
-        * ... and at the end of the usable range downwards:
-        */
-       last_pfn = PFN_DOWN(__pa(memory_end));
-
-       if (last_pfn > max_low_pfn)
-               last_pfn = max_low_pfn;
-
-       pages = last_pfn - curr_pfn;
-       free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(pages));
-}
-
-static void __init check_for_initrd(void)
+void __init check_for_initrd(void)
 {
 #ifdef CONFIG_BLK_DEV_INITRD
        unsigned long start, end;
@@ -223,13 +191,18 @@ void __init __add_active_range(unsigned int nid, unsigned long start_pfn,
                                                unsigned long end_pfn)
 {
        struct resource *res = &mem_resources[nid];
+       unsigned long start, end;
 
        WARN_ON(res->name); /* max one active range per node for now */
 
+       start = start_pfn << PAGE_SHIFT;
+       end = end_pfn << PAGE_SHIFT;
+
        res->name = "System RAM";
-       res->start = start_pfn << PAGE_SHIFT;
-       res->end = (end_pfn << PAGE_SHIFT) - 1;
+       res->start = start;
+       res->end = end - 1;
        res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
+
        if (request_resource(&iomem_resource, res)) {
                pr_err("unable to request memory_resource 0x%lx 0x%lx\n",
                       start_pfn, end_pfn);
@@ -245,121 +218,21 @@ void __init __add_active_range(unsigned int nid, unsigned long start_pfn,
        request_resource(res, &data_resource);
        request_resource(res, &bss_resource);
 
-       add_active_range(nid, start_pfn, end_pfn);
-}
-
-void __init do_init_bootmem(void)
-{
-       unsigned long bootmap_size;
-       unsigned long bootmap_pages, bootmem_paddr;
-       u64 total_pages = (lmb_end_of_DRAM() - __MEMORY_START) >> PAGE_SHIFT;
-       int i;
-
-       bootmap_pages = bootmem_bootmap_pages(total_pages);
-
-       bootmem_paddr = lmb_alloc(bootmap_pages << PAGE_SHIFT, PAGE_SIZE);
-
-       /*
-        * Find a proper area for the bootmem bitmap. After this
-        * bootstrap step all allocations (until the page allocator
-        * is intact) must be done via bootmem_alloc().
-        */
-       bootmap_size = init_bootmem_node(NODE_DATA(0),
-                                        bootmem_paddr >> PAGE_SHIFT,
-                                        min_low_pfn, max_low_pfn);
-
-       /* Add active regions with valid PFNs. */
-       for (i = 0; i < lmb.memory.cnt; i++) {
-               unsigned long start_pfn, end_pfn;
-               start_pfn = lmb.memory.region[i].base >> PAGE_SHIFT;
-               end_pfn = start_pfn + lmb_size_pages(&lmb.memory, i);
-               __add_active_range(0, start_pfn, end_pfn);
-       }
-
-       /*
-        * Handle additional early reservations
-        */
-       check_for_initrd();
-       reserve_crashkernel();
-
-       /*
-        * Add all physical memory to the bootmem map and mark each
-        * area as present.
-        */
-       register_bootmem_low_pages();
-
-       /* Reserve the sections we're already using. */
-       for (i = 0; i < lmb.reserved.cnt; i++)
-               reserve_bootmem(lmb.reserved.region[i].base,
-                               lmb_size_bytes(&lmb.reserved, i),
-                               BOOTMEM_DEFAULT);
-
-       node_set_online(0);
-
-       sparse_memory_present_with_active_regions(0);
-}
-
-static void __init setup_memory(void)
-{
-       unsigned long start_pfn;
-
-       /*
-        * Partially used pages are not usable - thus
-        * we are rounding upwards:
-        */
-       start_pfn = PFN_UP(__pa(_end));
-
        /*
-        * Reserve the kernel text and
-        * Reserve the bootmem bitmap. We do this in two steps (first step
-        * was init_bootmem()), because this catches the (definitely buggy)
-        * case of us accidentally initializing the bootmem allocator with
-        * an invalid RAM area.
+        * Also make sure that there is a PMB mapping that covers this
+        * range before we attempt to activate it, to avoid reset by MMU.
+        * We can hit this path with NUMA or memory hot-add.
         */
-       lmb_reserve(__MEMORY_START + CONFIG_ZERO_PAGE_OFFSET,
-                   (PFN_PHYS(start_pfn) + PAGE_SIZE - 1) -
-                   (__MEMORY_START + CONFIG_ZERO_PAGE_OFFSET));
-
-       /*
-        * Reserve physical pages below CONFIG_ZERO_PAGE_OFFSET.
-        */
-       if (CONFIG_ZERO_PAGE_OFFSET != 0)
-               lmb_reserve(__MEMORY_START, CONFIG_ZERO_PAGE_OFFSET);
-
-       lmb_analyze();
-       lmb_dump_all();
+       pmb_bolt_mapping((unsigned long)__va(start), start, end - start,
+                        PAGE_KERNEL);
 
-       do_init_bootmem();
-       plat_mem_setup();
-}
-
-/*
- * Note: elfcorehdr_addr is not just limited to vmcore. It is also used by
- * is_kdump_kernel() to determine if we are booting after a panic. Hence
- * ifdef it under CONFIG_CRASH_DUMP and not CONFIG_PROC_VMCORE.
- */
-#ifdef CONFIG_CRASH_DUMP
-/* elfcorehdr= specifies the location of elf core header
- * stored by the crashed kernel.
- */
-static int __init parse_elfcorehdr(char *arg)
-{
-       if (!arg)
-               return -EINVAL;
-       elfcorehdr_addr = memparse(arg, &arg);
-       return 0;
+       add_active_range(nid, start_pfn, end_pfn);
 }
-early_param("elfcorehdr", parse_elfcorehdr);
-#endif
 
 void __init __weak plat_early_device_setup(void)
 {
 }
 
-void __init __weak plat_mem_setup(void)
-{
-}
-
 void __init setup_arch(char **cmdline_p)
 {
        enable_mmu();
@@ -397,10 +270,6 @@ void __init setup_arch(char **cmdline_p)
        bss_resource.start = virt_to_phys(__bss_start);
        bss_resource.end = virt_to_phys(_ebss)-1;
 
-       memory_start = (unsigned long)__va(__MEMORY_START);
-       if (!memory_end)
-               memory_end = memory_start + __MEMORY_SIZE;
-
 #ifdef CONFIG_CMDLINE_OVERWRITE
        strlcpy(command_line, CONFIG_CMDLINE, sizeof(command_line));
 #else
@@ -417,41 +286,18 @@ void __init setup_arch(char **cmdline_p)
 
        parse_early_param();
 
-       uncached_init();
-
        plat_early_device_setup();
 
-       /* Let earlyprintk output early console messages */
-       early_platform_driver_probe("earlyprintk", 1, 1);
-
-       lmb_init();
-
        sh_mv_setup();
-       sh_mv.mv_mem_init();
 
-       /*
-        * Find the highest page frame number we have available
-        */
-       max_pfn = PFN_DOWN(__pa(memory_end));
-
-       /*
-        * Determine low and high memory ranges:
-        */
-       max_low_pfn = max_pfn;
-       min_low_pfn = __MEMORY_START >> PAGE_SHIFT;
-
-       nodes_clear(node_online_map);
+       /* Let earlyprintk output early console messages */
+       early_platform_driver_probe("earlyprintk", 1, 1);
 
-       pmb_init();
-       setup_memory();
-       sparse_init();
+       paging_init();
 
 #ifdef CONFIG_DUMMY_CONSOLE
        conswitchp = &dummy_con;
 #endif
-       paging_init();
-
-       ioremap_fixed_init();
 
        /* Perform the machine specific initialisation */
        if (likely(sh_mv.mv_setup))