diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2009-12-14 16:28:58 +1100 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2009-12-14 16:28:58 +1100 |
commit | 5407df6e0d2da0f0df3d8381c8b93c0cf2979009 (patch) | |
tree | 6d7f315fd97be83bce40fad6e13191f14484433b | |
parent | 4cb51b33ad5d3e14fa468d34df417f9ae2d26bbb (diff) |
Revert "of/flattree: merge early_init_devtree() and early_init_move_devtree()"
This reverts commit 825b073d40b34e331d49e727b9e208744ad26259.
-rw-r--r-- | arch/microblaze/kernel/prom.c | 53 | ||||
-rw-r--r-- | arch/powerpc/kernel/prom.c | 94 | ||||
-rw-r--r-- | drivers/of/fdt.c | 92 | ||||
-rw-r--r-- | include/linux/of_fdt.h | 7 |
4 files changed, 131 insertions, 115 deletions
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c index e297d961c4cf..5505bcffd7dd 100644 --- a/arch/microblaze/kernel/prom.c +++ b/arch/microblaze/kernel/prom.c @@ -47,8 +47,9 @@ struct device_node *of_chosen; #define early_init_dt_scan_drconf_memory(node) 0 -int __init early_init_dt_scan_cpus(unsigned long node, const char *uname, - int depth, void *data) +static int __init early_init_dt_scan_cpus(unsigned long node, + const char *uname, int depth, + void *data) { static int logical_cpuid; char *type = of_get_flat_dt_prop(node, "device_type", NULL); @@ -112,8 +113,8 @@ void __init early_init_dt_scan_chosen_arch(unsigned long node) /* No Microblaze specific code here */ } -int __init early_init_dt_scan_memory(unsigned long node, const char *uname, - int depth, void *data) +static int __init early_init_dt_scan_memory(unsigned long node, + const char *uname, int depth, void *data) { char *type = of_get_flat_dt_prop(node, "device_type", NULL); __be32 *reg, *endp; @@ -200,7 +201,7 @@ static inline unsigned long phyp_dump_calculate_reserve_size(void) * without reserving anything. The memory in case of dump being * active is freed when the dump is collected (by userland tools). */ -void __init phyp_dump_reserve_mem(void) +static void __init phyp_dump_reserve_mem(void) { unsigned long base, size; unsigned long variable_reserve_size; @@ -239,7 +240,7 @@ void __init phyp_dump_reserve_mem(void) } } #else -inline void __init phyp_dump_reserve_mem(void) {} +static inline void __init phyp_dump_reserve_mem(void) {} #endif /* CONFIG_PHYP_DUMP && CONFIG_PPC_RTAS */ #ifdef CONFIG_EARLY_PRINTK @@ -276,9 +277,45 @@ int __init early_uartlite_console(void) } #endif -void __init early_init_devtree_arch(void) +void __init early_init_devtree(void *params) { - /* No Microblaze specific code here */ + pr_debug(" -> early_init_devtree(%p)\n", params); + + /* Setup flat device-tree pointer */ + initial_boot_params = params; + +#ifdef CONFIG_PHYP_DUMP + /* scan tree to see if dump occured during last boot */ + of_scan_flat_dt(early_init_dt_scan_phyp_dump, NULL); +#endif + + /* Retrieve various informations from the /chosen node of the + * device-tree, including the platform type, initrd location and + * size, TCE reserve, and more ... + */ + of_scan_flat_dt(early_init_dt_scan_chosen, NULL); + + /* Scan memory nodes and rebuild LMBs */ + lmb_init(); + of_scan_flat_dt(early_init_dt_scan_root, NULL); + of_scan_flat_dt(early_init_dt_scan_memory, NULL); + + /* Save command line for /proc/cmdline and then parse parameters */ + strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE); + parse_early_param(); + + lmb_analyze(); + + pr_debug("Phys. mem: %lx\n", (unsigned long) lmb_phys_mem_size()); + + pr_debug("Scanning CPUs ...\n"); + + /* Retreive CPU related informations from the flat tree + * (altivec support, boot CPU ID, ...) + */ + of_scan_flat_dt(early_init_dt_scan_cpus, NULL); + + pr_debug(" <- early_init_devtree()\n"); } /** diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index aac889074292..877fad9b3745 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -84,6 +84,33 @@ static int __init early_parse_mem(char *p) } early_param("mem", early_parse_mem); +/** + * move_device_tree - move tree to an unused area, if needed. + * + * The device tree may be allocated beyond our memory limit, or inside the + * crash kernel region for kdump. If so, move it out of the way. + */ +static void __init move_device_tree(void) +{ + unsigned long start, size; + void *p; + + DBG("-> move_device_tree\n"); + + start = __pa(initial_boot_params); + size = initial_boot_params->totalsize; + + if ((memory_limit && (start + size) > memory_limit) || + overlaps_crashkernel(start, size)) { + p = __va(lmb_alloc_base(size, PAGE_SIZE, lmb.rmo_size)); + memcpy(p, initial_boot_params, size); + initial_boot_params = (struct boot_param_header *)p; + DBG("Moved device tree to 0x%p\n", p); + } + + DBG("<- move_device_tree\n"); +} + /* * ibm,pa-features is a per-cpu property that contains a string of * attribute descriptors, each of which has a 2 byte header plus up @@ -240,8 +267,9 @@ static void __init check_cpu_feature_properties(unsigned long node) } } -int __init early_init_dt_scan_cpus(unsigned long node, const char *uname, - int depth, void *data) +static int __init early_init_dt_scan_cpus(unsigned long node, + const char *uname, int depth, + void *data) { static int logical_cpuid = 0; char *type = of_get_flat_dt_prop(node, "device_type", NULL); @@ -455,8 +483,8 @@ static int __init early_init_dt_scan_drconf_memory(unsigned long node) #define early_init_dt_scan_drconf_memory(node) 0 #endif /* CONFIG_PPC_PSERIES */ -int __init early_init_dt_scan_memory(unsigned long node, const char *uname, - int depth, void *data) +static int __init early_init_dt_scan_memory(unsigned long node, + const char *uname, int depth, void *data) { char *type = of_get_flat_dt_prop(node, "device_type", NULL); __be32 *reg, *endp; @@ -515,7 +543,7 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname, return 0; } -void __init early_reserve_mem(void) +static void __init early_reserve_mem(void) { u64 base, size; u64 *reserve_map; @@ -607,7 +635,7 @@ static inline unsigned long phyp_dump_calculate_reserve_size(void) * without reserving anything. The memory in case of dump being * active is freed when the dump is collected (by userland tools). */ -void __init phyp_dump_reserve_mem(void) +static void __init phyp_dump_reserve_mem(void) { unsigned long base, size; unsigned long variable_reserve_size; @@ -646,13 +674,44 @@ void __init phyp_dump_reserve_mem(void) } } #else -inline void __init phyp_dump_reserve_mem(void) {} +static inline void __init phyp_dump_reserve_mem(void) {} #endif /* CONFIG_PHYP_DUMP && CONFIG_PPC_RTAS */ -void __init early_init_devtree_arch(void) + +void __init early_init_devtree(void *params) { phys_addr_t limit; + DBG(" -> early_init_devtree(%p)\n", params); + + /* Setup flat device-tree pointer */ + initial_boot_params = params; + +#ifdef CONFIG_PPC_RTAS + /* Some machines might need RTAS info for debugging, grab it now. */ + of_scan_flat_dt(early_init_dt_scan_rtas, NULL); +#endif + +#ifdef CONFIG_PHYP_DUMP + /* scan tree to see if dump occured during last boot */ + of_scan_flat_dt(early_init_dt_scan_phyp_dump, NULL); +#endif + + /* Retrieve various informations from the /chosen node of the + * device-tree, including the platform type, initrd location and + * size, TCE reserve, and more ... + */ + of_scan_flat_dt(early_init_dt_scan_chosen, NULL); + + /* Scan memory nodes and rebuild LMBs */ + lmb_init(); + of_scan_flat_dt(early_init_dt_scan_root, NULL); + of_scan_flat_dt(early_init_dt_scan_memory, NULL); + + /* Save command line for /proc/cmdline and then parse parameters */ + strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE); + parse_early_param(); + /* Reserve LMB regions used by kernel, initrd, dt, etc... */ lmb_reserve(PHYSICAL_START, __pa(klimit) - PHYSICAL_START); /* If relocatable, reserve first 32k for interrupt vectors etc. */ @@ -675,8 +734,27 @@ void __init early_init_devtree_arch(void) limit = memsize & PAGE_MASK; } lmb_enforce_memory_limit(limit); + + lmb_analyze(); + lmb_dump_all(); + + DBG("Phys. mem: %llx\n", lmb_phys_mem_size()); + + /* We may need to relocate the flat tree, do it now. + * FIXME .. and the initrd too? */ + move_device_tree(); + + DBG("Scanning CPUs ...\n"); + + /* Retreive CPU related informations from the flat tree + * (altivec support, boot CPU ID, ...) + */ + of_scan_flat_dt(early_init_dt_scan_cpus, NULL); + + DBG(" <- early_init_devtree()\n"); } + /** * Indicates whether the root node has a given value in its * compatible property. diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 616478104b2e..616a4767a950 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -16,12 +16,7 @@ #include <linux/of_fdt.h> #ifdef CONFIG_PPC -#include <asm/kexec.h> #include <asm/machdep.h> - -#ifdef CONFIG_PPC_RTAS -#include <asm/rtas.h> -#endif #endif /* CONFIG_PPC */ int __initdata dt_root_addr_cells; @@ -484,93 +479,6 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, } /** - * early_init_move_devtree - move tree to an unused area, if needed. - * - * The device tree may be allocated beyond our memory limit, or inside the - * crash kernel region for kdump. If so, move it out of the way. - */ -#if defined(CONFIG_PPC) -static void __init early_init_move_devtree(void) -{ - unsigned long start, size; - void *p; - - pr_debug("-> %s()\n", __func__); - - start = __pa(initial_boot_params); - size = initial_boot_params->totalsize; - - if ((memory_limit && (start + size) > memory_limit) || - overlaps_crashkernel(start, size)) { - p = __va(lmb_alloc_base(size, PAGE_SIZE, lmb.rmo_size)); - memcpy(p, initial_boot_params, size); - initial_boot_params = (struct boot_param_header *)p; - pr_debug("Moved device tree to 0x%p\n", p); - } - - pr_debug("<- %s()\n", __func__); -} -#else -static void __init early_init_move_devtree(void) {} -#endif - -void __init early_init_devtree(void *params) -{ - pr_debug(" -> early_init_devtree(%p)\n", params); - - /* Setup flat device-tree pointer */ - initial_boot_params = params; - -#ifdef CONFIG_PPC_RTAS - /* Some machines might need RTAS info for debugging, grab it now. */ - of_scan_flat_dt(early_init_dt_scan_rtas, NULL); -#endif - -#ifdef CONFIG_PHYP_DUMP - /* scan tree to see if dump occured during last boot */ - of_scan_flat_dt(early_init_dt_scan_phyp_dump, NULL); -#endif - - /* Retrieve various informations from the /chosen node of the - * device-tree, including the platform type, initrd location and - * size, TCE reserve, and more ... - */ - of_scan_flat_dt(early_init_dt_scan_chosen, NULL); - - /* Scan memory nodes and rebuild LMBs */ - lmb_init(); - of_scan_flat_dt(early_init_dt_scan_root, NULL); - of_scan_flat_dt(early_init_dt_scan_memory, NULL); - - /* Save command line for /proc/cmdline and then parse parameters */ - strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE); - parse_early_param(); - - /* This is in an arbitrary spot, but it is temporary. After all - * the common code is merged, the structure of the early init - * code will be reevaluated and refactored */ - early_init_devtree_arch(); - - lmb_analyze(); - lmb_dump_all(); - - pr_debug("Phys. mem: %llx\n", lmb_phys_mem_size()); - - /* We may need to relocate the flat tree, do it now. - * FIXME .. and the initrd too? */ - early_init_move_devtree(); - - pr_debug("Scanning CPUs ...\n"); - - /* Retreive CPU related informations from the flat tree - * (altivec support, boot CPU ID, ...) - */ - of_scan_flat_dt(early_init_dt_scan_cpus, NULL); - - pr_debug(" <- early_init_devtree()\n"); -} - -/** * unflatten_device_tree - create tree of device_nodes from flat blob * * unflattens the device-tree passed by the firmware, creating the diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index d1b157120b62..8118d4559dd5 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h @@ -75,13 +75,6 @@ extern void early_init_dt_scan_chosen_arch(unsigned long node); extern int early_init_dt_scan_chosen(unsigned long node, const char *uname, int depth, void *data); extern void early_init_dt_check_for_initrd(unsigned long node); -extern int early_init_dt_scan_cpus(unsigned long node, const char *uname, - int depth, void *data); -extern int early_init_dt_scan_memory(unsigned long node, const char *uname, - int depth, void *data); -extern void early_reserve_mem(void); -extern void early_init_devtree_arch(void); -extern void phyp_dump_reserve_mem(void); extern u64 dt_mem_next_cell(int s, u32 **cellp); /* Early flat tree scan hooks */ |