diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2010-02-01 23:34:14 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2010-02-09 10:33:10 -0500 |
commit | 51975db0b7333cf389b64b5040c2a910341d241a (patch) | |
tree | aba9d6bf56eec915265a8b630c3192affc2a549c /arch/powerpc/kernel/prom.c | |
parent | 71a157e8edca55198e808f8561dd49017a54ee34 (diff) |
of/flattree: merge early_init_dt_scan_memory() common code
Merge common code between PowerPC and Microblaze architectures.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'arch/powerpc/kernel/prom.c')
-rw-r--r-- | arch/powerpc/kernel/prom.c | 69 |
1 files changed, 18 insertions, 51 deletions
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index 28be19ab0f18..e0f368ff8d12 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c | |||
@@ -483,64 +483,31 @@ static int __init early_init_dt_scan_drconf_memory(unsigned long node) | |||
483 | #define early_init_dt_scan_drconf_memory(node) 0 | 483 | #define early_init_dt_scan_drconf_memory(node) 0 |
484 | #endif /* CONFIG_PPC_PSERIES */ | 484 | #endif /* CONFIG_PPC_PSERIES */ |
485 | 485 | ||
486 | static int __init early_init_dt_scan_memory(unsigned long node, | 486 | static int __init early_init_dt_scan_memory_ppc(unsigned long node, |
487 | const char *uname, int depth, void *data) | 487 | const char *uname, |
488 | int depth, void *data) | ||
488 | { | 489 | { |
489 | char *type = of_get_flat_dt_prop(node, "device_type", NULL); | ||
490 | __be32 *reg, *endp; | ||
491 | unsigned long l; | ||
492 | |||
493 | /* Look for the ibm,dynamic-reconfiguration-memory node */ | ||
494 | if (depth == 1 && | 490 | if (depth == 1 && |
495 | strcmp(uname, "ibm,dynamic-reconfiguration-memory") == 0) | 491 | strcmp(uname, "ibm,dynamic-reconfiguration-memory") == 0) |
496 | return early_init_dt_scan_drconf_memory(node); | 492 | return early_init_dt_scan_drconf_memory(node); |
493 | |||
494 | return early_init_dt_scan_memory(node, uname, depth, data); | ||
495 | } | ||
497 | 496 | ||
498 | /* We are scanning "memory" nodes only */ | 497 | void __init early_init_dt_add_memory_arch(u64 base, u64 size) |
499 | if (type == NULL) { | 498 | { |
500 | /* | 499 | #if defined(CONFIG_PPC64) |
501 | * The longtrail doesn't have a device_type on the | 500 | if (iommu_is_off) { |
502 | * /memory node, so look for the node called /memory@0. | 501 | if (base >= 0x80000000ul) |
503 | */ | 502 | return; |
504 | if (depth != 1 || strcmp(uname, "memory@0") != 0) | 503 | if ((base + size) > 0x80000000ul) |
505 | return 0; | 504 | size = 0x80000000ul - base; |
506 | } else if (strcmp(type, "memory") != 0) | 505 | } |
507 | return 0; | ||
508 | |||
509 | reg = of_get_flat_dt_prop(node, "linux,usable-memory", &l); | ||
510 | if (reg == NULL) | ||
511 | reg = of_get_flat_dt_prop(node, "reg", &l); | ||
512 | if (reg == NULL) | ||
513 | return 0; | ||
514 | |||
515 | endp = reg + (l / sizeof(__be32)); | ||
516 | |||
517 | DBG("memory scan node %s, reg size %ld, data: %x %x %x %x,\n", | ||
518 | uname, l, reg[0], reg[1], reg[2], reg[3]); | ||
519 | |||
520 | while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) { | ||
521 | u64 base, size; | ||
522 | |||
523 | base = dt_mem_next_cell(dt_root_addr_cells, ®); | ||
524 | size = dt_mem_next_cell(dt_root_size_cells, ®); | ||
525 | |||
526 | if (size == 0) | ||
527 | continue; | ||
528 | DBG(" - %llx , %llx\n", (unsigned long long)base, | ||
529 | (unsigned long long)size); | ||
530 | #ifdef CONFIG_PPC64 | ||
531 | if (iommu_is_off) { | ||
532 | if (base >= 0x80000000ul) | ||
533 | continue; | ||
534 | if ((base + size) > 0x80000000ul) | ||
535 | size = 0x80000000ul - base; | ||
536 | } | ||
537 | #endif | 506 | #endif |
538 | lmb_add(base, size); | ||
539 | 507 | ||
540 | memstart_addr = min((u64)memstart_addr, base); | 508 | lmb_add(base, size); |
541 | } | ||
542 | 509 | ||
543 | return 0; | 510 | memstart_addr = min((u64)memstart_addr, base); |
544 | } | 511 | } |
545 | 512 | ||
546 | static void __init early_reserve_mem(void) | 513 | static void __init early_reserve_mem(void) |
@@ -706,7 +673,7 @@ void __init early_init_devtree(void *params) | |||
706 | /* Scan memory nodes and rebuild LMBs */ | 673 | /* Scan memory nodes and rebuild LMBs */ |
707 | lmb_init(); | 674 | lmb_init(); |
708 | of_scan_flat_dt(early_init_dt_scan_root, NULL); | 675 | of_scan_flat_dt(early_init_dt_scan_root, NULL); |
709 | of_scan_flat_dt(early_init_dt_scan_memory, NULL); | 676 | of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL); |
710 | 677 | ||
711 | /* Save command line for /proc/cmdline and then parse parameters */ | 678 | /* Save command line for /proc/cmdline and then parse parameters */ |
712 | strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE); | 679 | strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE); |