diff options
Diffstat (limited to 'arch/powerpc/platforms/powermac/feature.c')
-rw-r--r-- | arch/powerpc/platforms/powermac/feature.c | 101 |
1 files changed, 58 insertions, 43 deletions
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c index 24cc50c1774a..52cfdd86c928 100644 --- a/arch/powerpc/platforms/powermac/feature.c +++ b/arch/powerpc/platforms/powermac/feature.c | |||
@@ -1044,6 +1044,7 @@ core99_reset_cpu(struct device_node *node, long param, long value) | |||
1044 | unsigned long flags; | 1044 | unsigned long flags; |
1045 | struct macio_chip *macio; | 1045 | struct macio_chip *macio; |
1046 | struct device_node *np; | 1046 | struct device_node *np; |
1047 | struct device_node *cpus; | ||
1047 | const int dflt_reset_lines[] = { KL_GPIO_RESET_CPU0, | 1048 | const int dflt_reset_lines[] = { KL_GPIO_RESET_CPU0, |
1048 | KL_GPIO_RESET_CPU1, | 1049 | KL_GPIO_RESET_CPU1, |
1049 | KL_GPIO_RESET_CPU2, | 1050 | KL_GPIO_RESET_CPU2, |
@@ -1053,12 +1054,12 @@ core99_reset_cpu(struct device_node *node, long param, long value) | |||
1053 | if (macio->type != macio_keylargo) | 1054 | if (macio->type != macio_keylargo) |
1054 | return -ENODEV; | 1055 | return -ENODEV; |
1055 | 1056 | ||
1056 | np = find_path_device("/cpus"); | 1057 | cpus = of_find_node_by_path("/cpus"); |
1057 | if (np == NULL) | 1058 | if (cpus == NULL) |
1058 | return -ENODEV; | 1059 | return -ENODEV; |
1059 | for (np = np->child; np != NULL; np = np->sibling) { | 1060 | for (np = cpus->child; np != NULL; np = np->sibling) { |
1060 | const u32 *num = get_property(np, "reg", NULL); | 1061 | const u32 *num = of_get_property(np, "reg", NULL); |
1061 | const u32 *rst = get_property(np, "soft-reset", NULL); | 1062 | const u32 *rst = of_get_property(np, "soft-reset", NULL); |
1062 | if (num == NULL || rst == NULL) | 1063 | if (num == NULL || rst == NULL) |
1063 | continue; | 1064 | continue; |
1064 | if (param == *num) { | 1065 | if (param == *num) { |
@@ -1066,6 +1067,7 @@ core99_reset_cpu(struct device_node *node, long param, long value) | |||
1066 | break; | 1067 | break; |
1067 | } | 1068 | } |
1068 | } | 1069 | } |
1070 | of_node_put(cpus); | ||
1069 | if (np == NULL || reset_io == 0) | 1071 | if (np == NULL || reset_io == 0) |
1070 | reset_io = dflt_reset_lines[param]; | 1072 | reset_io = dflt_reset_lines[param]; |
1071 | 1073 | ||
@@ -1095,7 +1097,7 @@ core99_usb_enable(struct device_node *node, long param, long value) | |||
1095 | macio->type != macio_intrepid) | 1097 | macio->type != macio_intrepid) |
1096 | return -ENODEV; | 1098 | return -ENODEV; |
1097 | 1099 | ||
1098 | prop = get_property(node, "AAPL,clock-id", NULL); | 1100 | prop = of_get_property(node, "AAPL,clock-id", NULL); |
1099 | if (!prop) | 1101 | if (!prop) |
1100 | return -ENODEV; | 1102 | return -ENODEV; |
1101 | if (strncmp(prop, "usb0u048", 8) == 0) | 1103 | if (strncmp(prop, "usb0u048", 8) == 0) |
@@ -1497,17 +1499,18 @@ static long g5_reset_cpu(struct device_node *node, long param, long value) | |||
1497 | unsigned long flags; | 1499 | unsigned long flags; |
1498 | struct macio_chip *macio; | 1500 | struct macio_chip *macio; |
1499 | struct device_node *np; | 1501 | struct device_node *np; |
1502 | struct device_node *cpus; | ||
1500 | 1503 | ||
1501 | macio = &macio_chips[0]; | 1504 | macio = &macio_chips[0]; |
1502 | if (macio->type != macio_keylargo2 && macio->type != macio_shasta) | 1505 | if (macio->type != macio_keylargo2 && macio->type != macio_shasta) |
1503 | return -ENODEV; | 1506 | return -ENODEV; |
1504 | 1507 | ||
1505 | np = find_path_device("/cpus"); | 1508 | cpus = of_find_node_by_path("/cpus"); |
1506 | if (np == NULL) | 1509 | if (cpus == NULL) |
1507 | return -ENODEV; | 1510 | return -ENODEV; |
1508 | for (np = np->child; np != NULL; np = np->sibling) { | 1511 | for (np = cpus->child; np != NULL; np = np->sibling) { |
1509 | const u32 *num = get_property(np, "reg", NULL); | 1512 | const u32 *num = of_get_property(np, "reg", NULL); |
1510 | const u32 *rst = get_property(np, "soft-reset", NULL); | 1513 | const u32 *rst = of_get_property(np, "soft-reset", NULL); |
1511 | if (num == NULL || rst == NULL) | 1514 | if (num == NULL || rst == NULL) |
1512 | continue; | 1515 | continue; |
1513 | if (param == *num) { | 1516 | if (param == *num) { |
@@ -1515,6 +1518,7 @@ static long g5_reset_cpu(struct device_node *node, long param, long value) | |||
1515 | break; | 1518 | break; |
1516 | } | 1519 | } |
1517 | } | 1520 | } |
1521 | of_node_put(cpus); | ||
1518 | if (np == NULL || reset_io == 0) | 1522 | if (np == NULL || reset_io == 0) |
1519 | return -ENODEV; | 1523 | return -ENODEV; |
1520 | 1524 | ||
@@ -2404,14 +2408,15 @@ static int __init probe_motherboard(void) | |||
2404 | struct macio_chip *macio = &macio_chips[0]; | 2408 | struct macio_chip *macio = &macio_chips[0]; |
2405 | const char *model = NULL; | 2409 | const char *model = NULL; |
2406 | struct device_node *dt; | 2410 | struct device_node *dt; |
2411 | int ret = 0; | ||
2407 | 2412 | ||
2408 | /* Lookup known motherboard type in device-tree. First try an | 2413 | /* Lookup known motherboard type in device-tree. First try an |
2409 | * exact match on the "model" property, then try a "compatible" | 2414 | * exact match on the "model" property, then try a "compatible" |
2410 | * match is none is found. | 2415 | * match is none is found. |
2411 | */ | 2416 | */ |
2412 | dt = find_devices("device-tree"); | 2417 | dt = of_find_node_by_name(NULL, "device-tree"); |
2413 | if (dt != NULL) | 2418 | if (dt != NULL) |
2414 | model = get_property(dt, "model", NULL); | 2419 | model = of_get_property(dt, "model", NULL); |
2415 | for(i=0; model && i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) { | 2420 | for(i=0; model && i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) { |
2416 | if (strcmp(model, pmac_mb_defs[i].model_string) == 0) { | 2421 | if (strcmp(model, pmac_mb_defs[i].model_string) == 0) { |
2417 | pmac_mb = pmac_mb_defs[i]; | 2422 | pmac_mb = pmac_mb_defs[i]; |
@@ -2474,15 +2479,18 @@ static int __init probe_motherboard(void) | |||
2474 | break; | 2479 | break; |
2475 | #endif /* CONFIG_POWER4 */ | 2480 | #endif /* CONFIG_POWER4 */ |
2476 | default: | 2481 | default: |
2477 | return -ENODEV; | 2482 | ret = -ENODEV; |
2483 | goto done; | ||
2478 | } | 2484 | } |
2479 | found: | 2485 | found: |
2480 | #ifndef CONFIG_POWER4 | 2486 | #ifndef CONFIG_POWER4 |
2481 | /* Fixup Hooper vs. Comet */ | 2487 | /* Fixup Hooper vs. Comet */ |
2482 | if (pmac_mb.model_id == PMAC_TYPE_HOOPER) { | 2488 | if (pmac_mb.model_id == PMAC_TYPE_HOOPER) { |
2483 | u32 __iomem * mach_id_ptr = ioremap(0xf3000034, 4); | 2489 | u32 __iomem * mach_id_ptr = ioremap(0xf3000034, 4); |
2484 | if (!mach_id_ptr) | 2490 | if (!mach_id_ptr) { |
2485 | return -ENODEV; | 2491 | ret = -ENODEV; |
2492 | goto done; | ||
2493 | } | ||
2486 | /* Here, I used to disable the media-bay on comet. It | 2494 | /* Here, I used to disable the media-bay on comet. It |
2487 | * appears this is wrong, the floppy connector is actually | 2495 | * appears this is wrong, the floppy connector is actually |
2488 | * a kind of media-bay and works with the current driver. | 2496 | * a kind of media-bay and works with the current driver. |
@@ -2499,18 +2507,26 @@ found: | |||
2499 | * that all Apple OF revs did it properly, I do it the paranoid way. | 2507 | * that all Apple OF revs did it properly, I do it the paranoid way. |
2500 | */ | 2508 | */ |
2501 | while (uninorth_base && uninorth_rev > 3) { | 2509 | while (uninorth_base && uninorth_rev > 3) { |
2502 | struct device_node *np = find_path_device("/cpus"); | 2510 | struct device_node *cpus = of_find_node_by_path("/cpus"); |
2503 | if (!np || !np->child) { | 2511 | struct device_node *np; |
2512 | |||
2513 | if (!cpus || !cpus->child) { | ||
2504 | printk(KERN_WARNING "Can't find CPU(s) in device tree !\n"); | 2514 | printk(KERN_WARNING "Can't find CPU(s) in device tree !\n"); |
2515 | of_node_put(cpus); | ||
2505 | break; | 2516 | break; |
2506 | } | 2517 | } |
2507 | np = np->child; | 2518 | np = cpus->child; |
2508 | /* Nap mode not supported on SMP */ | 2519 | /* Nap mode not supported on SMP */ |
2509 | if (np->sibling) | 2520 | if (np->sibling) { |
2521 | of_node_put(cpus); | ||
2510 | break; | 2522 | break; |
2523 | } | ||
2511 | /* Nap mode not supported if flush-on-lock property is present */ | 2524 | /* Nap mode not supported if flush-on-lock property is present */ |
2512 | if (get_property(np, "flush-on-lock", NULL)) | 2525 | if (of_get_property(np, "flush-on-lock", NULL)) { |
2526 | of_node_put(cpus); | ||
2513 | break; | 2527 | break; |
2528 | } | ||
2529 | of_node_put(cpus); | ||
2514 | powersave_nap = 1; | 2530 | powersave_nap = 1; |
2515 | printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n"); | 2531 | printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n"); |
2516 | break; | 2532 | break; |
@@ -2532,7 +2548,9 @@ found: | |||
2532 | 2548 | ||
2533 | 2549 | ||
2534 | printk(KERN_INFO "PowerMac motherboard: %s\n", pmac_mb.model_name); | 2550 | printk(KERN_INFO "PowerMac motherboard: %s\n", pmac_mb.model_name); |
2535 | return 0; | 2551 | done: |
2552 | of_node_put(dt); | ||
2553 | return ret; | ||
2536 | } | 2554 | } |
2537 | 2555 | ||
2538 | /* Initialize the Core99 UniNorth host bridge and memory controller | 2556 | /* Initialize the Core99 UniNorth host bridge and memory controller |
@@ -2558,7 +2576,7 @@ static void __init probe_uninorth(void) | |||
2558 | if (uninorth_node == NULL) | 2576 | if (uninorth_node == NULL) |
2559 | return; | 2577 | return; |
2560 | 2578 | ||
2561 | addrp = get_property(uninorth_node, "reg", NULL); | 2579 | addrp = of_get_property(uninorth_node, "reg", NULL); |
2562 | if (addrp == NULL) | 2580 | if (addrp == NULL) |
2563 | return; | 2581 | return; |
2564 | address = of_translate_address(uninorth_node, addrp); | 2582 | address = of_translate_address(uninorth_node, addrp); |
@@ -2642,7 +2660,7 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ | |||
2642 | return; | 2660 | return; |
2643 | } | 2661 | } |
2644 | if (type == macio_keylargo || type == macio_keylargo2) { | 2662 | if (type == macio_keylargo || type == macio_keylargo2) { |
2645 | const u32 *did = get_property(node, "device-id", NULL); | 2663 | const u32 *did = of_get_property(node, "device-id", NULL); |
2646 | if (*did == 0x00000025) | 2664 | if (*did == 0x00000025) |
2647 | type = macio_pangea; | 2665 | type = macio_pangea; |
2648 | if (*did == 0x0000003e) | 2666 | if (*did == 0x0000003e) |
@@ -2655,7 +2673,7 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ | |||
2655 | macio_chips[i].base = base; | 2673 | macio_chips[i].base = base; |
2656 | macio_chips[i].flags = MACIO_FLAG_SCCB_ON | MACIO_FLAG_SCCB_ON; | 2674 | macio_chips[i].flags = MACIO_FLAG_SCCB_ON | MACIO_FLAG_SCCB_ON; |
2657 | macio_chips[i].name = macio_names[type]; | 2675 | macio_chips[i].name = macio_names[type]; |
2658 | revp = get_property(node, "revision-id", NULL); | 2676 | revp = of_get_property(node, "revision-id", NULL); |
2659 | if (revp) | 2677 | if (revp) |
2660 | macio_chips[i].rev = *revp; | 2678 | macio_chips[i].rev = *revp; |
2661 | printk(KERN_INFO "Found a %s mac-io controller, rev: %d, mapped at 0x%p\n", | 2679 | printk(KERN_INFO "Found a %s mac-io controller, rev: %d, mapped at 0x%p\n", |
@@ -2706,8 +2724,8 @@ initial_serial_shutdown(struct device_node *np) | |||
2706 | int port_type = PMAC_SCC_ASYNC; | 2724 | int port_type = PMAC_SCC_ASYNC; |
2707 | int modem = 0; | 2725 | int modem = 0; |
2708 | 2726 | ||
2709 | slots = get_property(np, "slot-names", &len); | 2727 | slots = of_get_property(np, "slot-names", &len); |
2710 | conn = get_property(np, "AAPL,connector", &len); | 2728 | conn = of_get_property(np, "AAPL,connector", &len); |
2711 | if (conn && (strcmp(conn, "infrared") == 0)) | 2729 | if (conn && (strcmp(conn, "infrared") == 0)) |
2712 | port_type = PMAC_SCC_IRDA; | 2730 | port_type = PMAC_SCC_IRDA; |
2713 | else if (device_is_compatible(np, "cobalt")) | 2731 | else if (device_is_compatible(np, "cobalt")) |
@@ -2735,12 +2753,14 @@ set_initial_features(void) | |||
2735 | * differenciate them all and since that hack was there for a long | 2753 | * differenciate them all and since that hack was there for a long |
2736 | * time, I'll keep it around | 2754 | * time, I'll keep it around |
2737 | */ | 2755 | */ |
2738 | if (macio_chips[0].type == macio_ohare && !find_devices("via-pmu")) { | 2756 | if (macio_chips[0].type == macio_ohare) { |
2739 | struct macio_chip *macio = &macio_chips[0]; | 2757 | struct macio_chip *macio = &macio_chips[0]; |
2740 | MACIO_OUT32(OHARE_FCR, STARMAX_FEATURES); | 2758 | np = of_find_node_by_name(NULL, "via-pmu"); |
2741 | } else if (macio_chips[0].type == macio_ohare) { | 2759 | if (np) |
2742 | struct macio_chip *macio = &macio_chips[0]; | 2760 | MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE); |
2743 | MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE); | 2761 | else |
2762 | MACIO_OUT32(OHARE_FCR, STARMAX_FEATURES); | ||
2763 | of_node_put(np); | ||
2744 | } else if (macio_chips[1].type == macio_ohare) { | 2764 | } else if (macio_chips[1].type == macio_ohare) { |
2745 | struct macio_chip *macio = &macio_chips[1]; | 2765 | struct macio_chip *macio = &macio_chips[1]; |
2746 | MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE); | 2766 | MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE); |
@@ -2833,14 +2853,13 @@ set_initial_features(void) | |||
2833 | } | 2853 | } |
2834 | 2854 | ||
2835 | /* Switch airport off */ | 2855 | /* Switch airport off */ |
2836 | np = find_devices("radio"); | 2856 | for_each_node_by_name(np, "radio") { |
2837 | while(np) { | ||
2838 | if (np && np->parent == macio_chips[0].of_node) { | 2857 | if (np && np->parent == macio_chips[0].of_node) { |
2839 | macio_chips[0].flags |= MACIO_FLAG_AIRPORT_ON; | 2858 | macio_chips[0].flags |= MACIO_FLAG_AIRPORT_ON; |
2840 | core99_airport_enable(np, 0, 0); | 2859 | core99_airport_enable(np, 0, 0); |
2841 | } | 2860 | } |
2842 | np = np->next; | ||
2843 | } | 2861 | } |
2862 | of_node_put(np); | ||
2844 | } | 2863 | } |
2845 | 2864 | ||
2846 | /* On all machines that support sound PM, switch sound off */ | 2865 | /* On all machines that support sound PM, switch sound off */ |
@@ -2860,16 +2879,12 @@ set_initial_features(void) | |||
2860 | #endif /* CONFIG_POWER4 */ | 2879 | #endif /* CONFIG_POWER4 */ |
2861 | 2880 | ||
2862 | /* On all machines, switch modem & serial ports off */ | 2881 | /* On all machines, switch modem & serial ports off */ |
2863 | np = find_devices("ch-a"); | 2882 | for_each_node_by_name(np, "ch-a") |
2864 | while(np) { | ||
2865 | initial_serial_shutdown(np); | 2883 | initial_serial_shutdown(np); |
2866 | np = np->next; | 2884 | of_node_put(np); |
2867 | } | 2885 | for_each_node_by_name(np, "ch-b") |
2868 | np = find_devices("ch-b"); | ||
2869 | while(np) { | ||
2870 | initial_serial_shutdown(np); | 2886 | initial_serial_shutdown(np); |
2871 | np = np->next; | 2887 | of_node_put(np); |
2872 | } | ||
2873 | } | 2888 | } |
2874 | 2889 | ||
2875 | void __init | 2890 | void __init |