fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / arch / powerpc / platforms / maple / setup.c
index 57567df..50855d4 100644 (file)
@@ -60,6 +60,7 @@
 #include <asm/of_device.h>
 #include <asm/lmb.h>
 #include <asm/mpic.h>
+#include <asm/rtas.h>
 #include <asm/udbg.h>
 
 #include "maple.h"
@@ -99,8 +100,7 @@ static unsigned long maple_find_nvram_base(void)
 static void maple_restart(char *cmd)
 {
        unsigned int maple_nvram_base;
-       unsigned int maple_nvram_offset;
-       unsigned int maple_nvram_command;
+       const unsigned int *maple_nvram_offset, *maple_nvram_command;
        struct device_node *sp;
 
        maple_nvram_base = maple_find_nvram_base();
@@ -113,14 +113,12 @@ static void maple_restart(char *cmd)
                printk(KERN_EMERG "Maple: Unable to find Service Processor\n");
                goto fail;
        }
-       maple_nvram_offset = *(unsigned int*) get_property(sp,
-                       "restart-addr", NULL);
-       maple_nvram_command = *(unsigned int*) get_property(sp,
-                       "restart-value", NULL);
+       maple_nvram_offset = get_property(sp, "restart-addr", NULL);
+       maple_nvram_command = get_property(sp, "restart-value", NULL);
        of_node_put(sp);
 
        /* send command */
-       outb_p(maple_nvram_command, maple_nvram_base + maple_nvram_offset);
+       outb_p(*maple_nvram_command, maple_nvram_base + *maple_nvram_offset);
        for (;;) ;
  fail:
        printk(KERN_EMERG "Maple: Manual Restart Required\n");
@@ -129,8 +127,7 @@ static void maple_restart(char *cmd)
 static void maple_power_off(void)
 {
        unsigned int maple_nvram_base;
-       unsigned int maple_nvram_offset;
-       unsigned int maple_nvram_command;
+       const unsigned int *maple_nvram_offset, *maple_nvram_command;
        struct device_node *sp;
 
        maple_nvram_base = maple_find_nvram_base();
@@ -143,14 +140,12 @@ static void maple_power_off(void)
                printk(KERN_EMERG "Maple: Unable to find Service Processor\n");
                goto fail;
        }
-       maple_nvram_offset = *(unsigned int*) get_property(sp,
-                       "power-off-addr", NULL);
-       maple_nvram_command = *(unsigned int*) get_property(sp,
-                       "power-off-value", NULL);
+       maple_nvram_offset = get_property(sp, "power-off-addr", NULL);
+       maple_nvram_command = get_property(sp, "power-off-value", NULL);
        of_node_put(sp);
 
        /* send command */
-       outb_p(maple_nvram_command, maple_nvram_base + maple_nvram_offset);
+       outb_p(*maple_nvram_command, maple_nvram_base + *maple_nvram_offset);
        for (;;) ;
  fail:
        printk(KERN_EMERG "Maple: Manual Power-Down Required\n");
@@ -172,6 +167,16 @@ struct smp_ops_t maple_smp_ops = {
 };
 #endif /* CONFIG_SMP */
 
+static void __init maple_use_rtas_reboot_and_halt_if_present(void)
+{
+       if (rtas_service_present("system-reboot") &&
+           rtas_service_present("power-off")) {
+               ppc_md.restart = rtas_restart;
+               ppc_md.power_off = rtas_power_off;
+               ppc_md.halt = rtas_halt;
+       }
+}
+
 void __init maple_setup_arch(void)
 {
        /* init to some ~sane value until calibrate_delay() runs */
@@ -187,6 +192,7 @@ void __init maple_setup_arch(void)
 #ifdef CONFIG_DUMMY_CONSOLE
        conswitchp = &dummy_con;
 #endif
+       maple_use_rtas_reboot_and_halt_if_present();
 
        printk(KERN_DEBUG "Using native/NAP idle loop\n");
 }
@@ -211,7 +217,7 @@ static void __init maple_init_early(void)
 static void __init maple_init_IRQ(void)
 {
        struct device_node *root, *np, *mpic_node = NULL;
-       unsigned int *opprop;
+       const unsigned int *opprop;
        unsigned long openpic_addr = 0;
        int naddr, n, i, opplen, has_isus = 0;
        struct mpic *mpic;
@@ -241,15 +247,13 @@ static void __init maple_init_IRQ(void)
        /* Find address list in /platform-open-pic */
        root = of_find_node_by_path("/");
        naddr = prom_n_addr_cells(root);
-       opprop = (unsigned int *) get_property(root, "platform-open-pic",
-                                              &opplen);
+       opprop = get_property(root, "platform-open-pic", &opplen);
        if (opprop != 0) {
                openpic_addr = of_read_number(opprop, naddr);
                has_isus = (opplen > naddr);
                printk(KERN_DEBUG "OpenPIC addr: %lx, has ISUs: %d\n",
                       openpic_addr, has_isus);
        }
-       of_node_put(root);
 
        BUG_ON(openpic_addr == 0);
 
@@ -319,7 +323,7 @@ define_machine(maple_md) {
        .setup_arch             = maple_setup_arch,
        .init_early             = maple_init_early,
        .init_IRQ               = maple_init_IRQ,
-       .pcibios_fixup          = maple_pcibios_fixup,
+       .pci_irq_fixup          = maple_pci_irq_fixup,
        .pci_get_legacy_ide_irq = maple_pci_get_legacy_ide_irq,
        .restart                = maple_restart,
        .power_off              = maple_power_off,