include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / arch / powerpc / platforms / pseries / setup.c
index 3ba8783..6710761 100644 (file)
@@ -16,9 +16,6 @@
  * bootup setup stuff..
  */
 
-#undef DEBUG
-
-#include <linux/config.h>
 #include <linux/cpu.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
@@ -26,9 +23,7 @@
 #include <linux/mm.h>
 #include <linux/stddef.h>
 #include <linux/unistd.h>
-#include <linux/slab.h>
 #include <linux/user.h>
-#include <linux/a.out.h>
 #include <linux/tty.h>
 #include <linux/major.h>
 #include <linux/interrupt.h>
@@ -56,7 +51,6 @@
 #include <asm/dma.h>
 #include <asm/machdep.h>
 #include <asm/irq.h>
-#include <asm/kexec.h>
 #include <asm/time.h>
 #include <asm/nvram.h>
 #include "xics.h"
 #include <asm/i8259.h>
 #include <asm/udbg.h>
 #include <asm/smp.h>
+#include <asm/firmware.h>
+#include <asm/eeh.h>
+#include <asm/pSeries_reconfig.h>
 
 #include "plpar_wrappers.h"
-#include "ras.h"
-#include "firmware.h"
-
-#ifdef DEBUG
-#define DBG(fmt...) udbg_printf(fmt)
-#else
-#define DBG(fmt...)
-#endif
+#include "pseries.h"
 
-extern void find_udbg_vterm(void);
+int CMO_PrPSP = -1;
+int CMO_SecPSP = -1;
+unsigned long CMO_PageSize = (ASM_CONST(1) << IOMMU_PAGE_SHIFT);
+EXPORT_SYMBOL(CMO_PageSize);
 
 int fwnmi_active;  /* TRUE if an FWNMI handler is present */
 
 static void pseries_shared_idle_sleep(void);
 static void pseries_dedicated_idle_sleep(void);
 
-struct mpic *pSeries_mpic;
+static struct device_node *pSeries_mpic_node;
 
 static void pSeries_show_cpuinfo(struct seq_file *m)
 {
@@ -93,7 +86,7 @@ static void pSeries_show_cpuinfo(struct seq_file *m)
 
        root = of_find_node_by_path("/");
        if (root)
-               model = get_property(root, "model", NULL);
+               model = of_get_property(root, "model", NULL);
        seq_printf(m, "machine\t\t: CHRP %s\n", model);
        of_node_put(root);
 }
@@ -119,97 +112,172 @@ static void __init fwnmi_init(void)
                fwnmi_active = 1;
 }
 
-static void __init pSeries_init_mpic(void)
+static void pseries_8259_cascade(unsigned int irq, struct irq_desc *desc)
 {
-        unsigned int *addrp;
-       struct device_node *np;
+       unsigned int cascade_irq = i8259_irq();
+       if (cascade_irq != NO_IRQ)
+               generic_handle_irq(cascade_irq);
+       desc->chip->eoi(irq);
+}
+
+static void __init pseries_setup_i8259_cascade(void)
+{
+       struct device_node *np, *old, *found = NULL;
+       unsigned int cascade;
+       const u32 *addrp;
        unsigned long intack = 0;
+       int naddr;
 
-       /* All ISUs are setup, complete initialization */
-       mpic_init(pSeries_mpic);
-
-       /* Check what kind of cascade ACK we have */
-        if (!(np = of_find_node_by_name(NULL, "pci"))
-            || !(addrp = (unsigned int *)
-                 get_property(np, "8259-interrupt-acknowledge", NULL)))
-                printk(KERN_ERR "Cannot find pci to get ack address\n");
-        else
-               intack = addrp[prom_n_addr_cells(np)-1];
-       of_node_put(np);
+       for_each_node_by_type(np, "interrupt-controller") {
+               if (of_device_is_compatible(np, "chrp,iic")) {
+                       found = np;
+                       break;
+               }
+       }
 
-       /* Setup the legacy interrupts & controller */
-       i8259_init(intack, 0);
+       if (found == NULL) {
+               printk(KERN_DEBUG "pic: no ISA interrupt controller\n");
+               return;
+       }
+
+       cascade = irq_of_parse_and_map(found, 0);
+       if (cascade == NO_IRQ) {
+               printk(KERN_ERR "pic: failed to map cascade interrupt");
+               return;
+       }
+       pr_debug("pic: cascade mapped to irq %d\n", cascade);
 
-       /* Hook cascade to mpic */
-       mpic_setup_cascade(NUM_ISA_INTERRUPTS, i8259_irq_cascade, NULL);
+       for (old = of_node_get(found); old != NULL ; old = np) {
+               np = of_get_parent(old);
+               of_node_put(old);
+               if (np == NULL)
+                       break;
+               if (strcmp(np->name, "pci") != 0)
+                       continue;
+               addrp = of_get_property(np, "8259-interrupt-acknowledge", NULL);
+               if (addrp == NULL)
+                       continue;
+               naddr = of_n_addr_cells(np);
+               intack = addrp[naddr-1];
+               if (naddr > 1)
+                       intack |= ((unsigned long)addrp[naddr-2]) << 32;
+       }
+       if (intack)
+               printk(KERN_DEBUG "pic: PCI 8259 intack at 0x%016lx\n", intack);
+       i8259_init(found, intack);
+       of_node_put(found);
+       set_irq_chained_handler(cascade, pseries_8259_cascade);
 }
 
-static void __init pSeries_setup_mpic(void)
+static void __init pseries_mpic_init_IRQ(void)
 {
-       unsigned int *opprop;
+       struct device_node *np;
+       const unsigned int *opprop;
        unsigned long openpic_addr = 0;
-        unsigned char senses[NR_IRQS - NUM_ISA_INTERRUPTS];
-        struct device_node *root;
-       int irq_count;
+       int naddr, n, i, opplen;
+       struct mpic *mpic;
 
-       /* Find the Open PIC if present */
-       root = of_find_node_by_path("/");
-       opprop = (unsigned int *) get_property(root, "platform-open-pic", NULL);
+       np = of_find_node_by_path("/");
+       naddr = of_n_addr_cells(np);
+       opprop = of_get_property(np, "platform-open-pic", &opplen);
        if (opprop != 0) {
-               int n = prom_n_addr_cells(root);
-
-               for (openpic_addr = 0; n > 0; --n)
-                       openpic_addr = (openpic_addr << 32) + *opprop++;
+               openpic_addr = of_read_number(opprop, naddr);
                printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr);
        }
-       of_node_put(root);
+       of_node_put(np);
 
        BUG_ON(openpic_addr == 0);
 
-       /* Get the sense values from OF */
-       prom_get_irq_senses(senses, NUM_ISA_INTERRUPTS, NR_IRQS);
-       
        /* Setup the openpic driver */
-       irq_count = NR_IRQS - NUM_ISA_INTERRUPTS - 4; /* leave room for IPIs */
-       pSeries_mpic = mpic_alloc(openpic_addr, MPIC_PRIMARY,
-                                 16, 16, irq_count, /* isu size, irq offset, irq count */ 
-                                 NR_IRQS - 4, /* ipi offset */
-                                 senses, irq_count, /* sense & sense size */
-                                 " MPIC     ");
+       mpic = mpic_alloc(pSeries_mpic_node, openpic_addr,
+                         MPIC_PRIMARY,
+                         16, 250, /* isu size, irq count */
+                         " MPIC     ");
+       BUG_ON(mpic == NULL);
+
+       /* Add ISUs */
+       opplen /= sizeof(u32);
+       for (n = 0, i = naddr; i < opplen; i += naddr, n++) {
+               unsigned long isuaddr = of_read_number(opprop + i, naddr);
+               mpic_assign_isu(mpic, n, isuaddr);
+       }
+
+       /* All ISUs are setup, complete initialization */
+       mpic_init(mpic);
+
+       /* Look for cascade */
+       pseries_setup_i8259_cascade();
+}
+
+static void __init pseries_xics_init_IRQ(void)
+{
+       xics_init_IRQ();
+       pseries_setup_i8259_cascade();
 }
 
 static void pseries_lpar_enable_pmcs(void)
 {
        unsigned long set, reset;
 
-       power4_enable_pmcs();
-
        set = 1UL << 63;
        reset = 0;
        plpar_hcall_norets(H_PERFMON, set, reset);
+}
+
+static void __init pseries_discover_pic(void)
+{
+       struct device_node *np;
+       const char *typep;
 
-       /* instruct hypervisor to maintain PMCs */
-       if (firmware_has_feature(FW_FEATURE_SPLPAR))
-               get_lppaca()->pmcregs_in_use = 1;
+       for (np = NULL; (np = of_find_node_by_name(np,
+                                                  "interrupt-controller"));) {
+               typep = of_get_property(np, "compatible", NULL);
+               if (strstr(typep, "open-pic")) {
+                       pSeries_mpic_node = of_node_get(np);
+                       ppc_md.init_IRQ       = pseries_mpic_init_IRQ;
+                       ppc_md.get_irq        = mpic_get_irq;
+                       setup_kexec_cpu_down_mpic();
+                       smp_init_pseries_mpic();
+                       return;
+               } else if (strstr(typep, "ppc-xicp")) {
+                       ppc_md.init_IRQ       = pseries_xics_init_IRQ;
+                       setup_kexec_cpu_down_xics();
+                       smp_init_pseries_xics();
+                       return;
+               }
+       }
+       printk(KERN_ERR "pSeries_discover_pic: failed to recognize"
+              " interrupt-controller\n");
 }
 
-static void __init pSeries_setup_arch(void)
+static int pci_dn_reconfig_notifier(struct notifier_block *nb, unsigned long action, void *node)
 {
-       /* Fixup ppc_md depending on the type of interrupt controller */
-       if (ppc64_interrupt_controller == IC_OPEN_PIC) {
-               ppc_md.init_IRQ       = pSeries_init_mpic;
-               ppc_md.get_irq        = mpic_get_irq;
-               /* Allocate the mpic now, so that find_and_init_phbs() can
-                * fill the ISUs */
-               pSeries_setup_mpic();
-       } else {
-               ppc_md.init_IRQ       = xics_init_IRQ;
-               ppc_md.get_irq        = xics_get_irq;
+       struct device_node *np = node;
+       struct pci_dn *pci = NULL;
+       int err = NOTIFY_OK;
+
+       switch (action) {
+       case PSERIES_RECONFIG_ADD:
+               pci = np->parent->data;
+               if (pci)
+                       update_dn_pci_info(np, pci->phb);
+               break;
+       default:
+               err = NOTIFY_DONE;
+               break;
        }
+       return err;
+}
+
+static struct notifier_block pci_dn_reconfig_nb = {
+       .notifier_call = pci_dn_reconfig_notifier,
+};
+
+static void __init pSeries_setup_arch(void)
+{
+       /* Discover PIC type and setup ppc_md accordingly */
+       pseries_discover_pic();
 
-#ifdef CONFIG_SMP
-       smp_init_pSeries();
-#endif
        /* openpic global configuration register (64-bit format). */
        /* openpic Interrupt Source Unit pointer (64-bit format). */
        /* python0 facility area (mmio) (64-bit format) REAL address. */
@@ -217,16 +285,12 @@ static void __init pSeries_setup_arch(void)
        /* init to some ~sane value until calibrate_delay() runs */
        loops_per_jiffy = 50000000;
 
-       if (ROOT_DEV == 0) {
-               printk("No ramdisk, default root is /dev/sda2\n");
-               ROOT_DEV = Root_SDA2;
-       }
-
        fwnmi_init();
 
        /* Find and initialize PCI host bridges */
        init_pci_config_tokens();
        find_and_init_phbs();
+       pSeries_reconfig_notifier_register(&pci_dn_reconfig_nb);
        eeh_init();
 
        pSeries_nvram_init();
@@ -235,14 +299,14 @@ static void __init pSeries_setup_arch(void)
        if (firmware_has_feature(FW_FEATURE_SPLPAR)) {
                vpa_init(boot_cpuid);
                if (get_lppaca()->shared_proc) {
-                       printk(KERN_INFO "Using shared processor idle loop\n");
+                       printk(KERN_DEBUG "Using shared processor idle loop\n");
                        ppc_md.power_save = pseries_shared_idle_sleep;
                } else {
-                       printk(KERN_INFO "Using dedicated idle loop\n");
+                       printk(KERN_DEBUG "Using dedicated idle loop\n");
                        ppc_md.power_save = pseries_dedicated_idle_sleep;
                }
        } else {
-               printk(KERN_INFO "Using default idle loop\n");
+               printk(KERN_DEBUG "Using default idle loop\n");
        }
 
        if (firmware_has_feature(FW_FEATURE_LPAR))
@@ -255,53 +319,12 @@ static int __init pSeries_init_panel(void)
 {
        /* Manually leave the kernel version on the panel. */
        ppc_md.progress("Linux ppc64\n", 0);
-       ppc_md.progress(system_utsname.release, 0);
+       ppc_md.progress(init_utsname()->version, 0);
 
        return 0;
 }
 arch_initcall(pSeries_init_panel);
 
-static  void __init pSeries_discover_pic(void)
-{
-       struct device_node *np;
-       char *typep;
-
-       /*
-        * Setup interrupt mapping options that are needed for finish_device_tree
-        * to properly parse the OF interrupt tree & do the virtual irq mapping
-        */
-       __irq_offset_value = NUM_ISA_INTERRUPTS;
-       ppc64_interrupt_controller = IC_INVALID;
-       for (np = NULL; (np = of_find_node_by_name(np, "interrupt-controller"));) {
-               typep = (char *)get_property(np, "compatible", NULL);
-               if (strstr(typep, "open-pic")) {
-                       ppc64_interrupt_controller = IC_OPEN_PIC;
-                       break;
-               } else if (strstr(typep, "ppc-xicp")) {
-                       ppc64_interrupt_controller = IC_PPC_XIC;
-                       break;
-               }
-       }
-       if (ppc64_interrupt_controller == IC_INVALID)
-               printk("pSeries_discover_pic: failed to recognize"
-                       " interrupt-controller\n");
-
-}
-
-static void pSeries_mach_cpu_die(void)
-{
-       local_irq_disable();
-       idle_task_exit();
-       /* Some hardware requires clearing the CPPR, while other hardware does not
-        * it is safe either way
-        */
-       pSeriesLP_cppr_info(0, 0);
-       rtas_stop_self();
-       /* Should never get here... */
-       BUG();
-       for(;;);
-}
-
 static int pseries_set_dabr(unsigned long dabr)
 {
        return plpar_hcall_norets(H_SET_DABR, dabr);
@@ -314,19 +337,91 @@ static int pseries_set_xdabr(unsigned long dabr)
                        H_DABRX_KERNEL | H_DABRX_USER);
 }
 
+#define CMO_CHARACTERISTICS_TOKEN 44
+#define CMO_MAXLENGTH 1026
+
+/**
+ * fw_cmo_feature_init - FW_FEATURE_CMO is not stored in ibm,hypertas-functions,
+ * handle that here. (Stolen from parse_system_parameter_string)
+ */
+void pSeries_cmo_feature_init(void)
+{
+       char *ptr, *key, *value, *end;
+       int call_status;
+       int page_order = IOMMU_PAGE_SHIFT;
+
+       pr_debug(" -> fw_cmo_feature_init()\n");
+       spin_lock(&rtas_data_buf_lock);
+       memset(rtas_data_buf, 0, RTAS_DATA_BUF_SIZE);
+       call_status = rtas_call(rtas_token("ibm,get-system-parameter"), 3, 1,
+                               NULL,
+                               CMO_CHARACTERISTICS_TOKEN,
+                               __pa(rtas_data_buf),
+                               RTAS_DATA_BUF_SIZE);
+
+       if (call_status != 0) {
+               spin_unlock(&rtas_data_buf_lock);
+               pr_debug("CMO not available\n");
+               pr_debug(" <- fw_cmo_feature_init()\n");
+               return;
+       }
+
+       end = rtas_data_buf + CMO_MAXLENGTH - 2;
+       ptr = rtas_data_buf + 2;        /* step over strlen value */
+       key = value = ptr;
+
+       while (*ptr && (ptr <= end)) {
+               /* Separate the key and value by replacing '=' with '\0' and
+                * point the value at the string after the '='
+                */
+               if (ptr[0] == '=') {
+                       ptr[0] = '\0';
+                       value = ptr + 1;
+               } else if (ptr[0] == '\0' || ptr[0] == ',') {
+                       /* Terminate the string containing the key/value pair */
+                       ptr[0] = '\0';
+
+                       if (key == value) {
+                               pr_debug("Malformed key/value pair\n");
+                               /* Never found a '=', end processing */
+                               break;
+                       }
+
+                       if (0 == strcmp(key, "CMOPageSize"))
+                               page_order = simple_strtol(value, NULL, 10);
+                       else if (0 == strcmp(key, "PrPSP"))
+                               CMO_PrPSP = simple_strtol(value, NULL, 10);
+                       else if (0 == strcmp(key, "SecPSP"))
+                               CMO_SecPSP = simple_strtol(value, NULL, 10);
+                       value = key = ptr + 1;
+               }
+               ptr++;
+       }
+
+       /* Page size is returned as the power of 2 of the page size,
+        * convert to the page size in bytes before returning
+        */
+       CMO_PageSize = 1 << page_order;
+       pr_debug("CMO_PageSize = %lu\n", CMO_PageSize);
+
+       if (CMO_PrPSP != -1 || CMO_SecPSP != -1) {
+               pr_info("CMO enabled\n");
+               pr_debug("CMO enabled, PrPSP=%d, SecPSP=%d\n", CMO_PrPSP,
+                        CMO_SecPSP);
+               powerpc_firmware_features |= FW_FEATURE_CMO;
+       } else
+               pr_debug("CMO not enabled, PrPSP=%d, SecPSP=%d\n", CMO_PrPSP,
+                        CMO_SecPSP);
+       spin_unlock(&rtas_data_buf_lock);
+       pr_debug(" <- fw_cmo_feature_init()\n");
+}
+
 /*
  * Early initialization.  Relocation is on but do not reference unbolted pages
  */
 static void __init pSeries_init_early(void)
 {
-       DBG(" -> pSeries_init_early()\n");
-
-       fw_feature_init();
-       
-       if (firmware_has_feature(FW_FEATURE_LPAR))
-               hpte_init_lpar();
-       else
-               hpte_init_native();
+       pr_debug(" -> pSeries_init_early()\n");
 
        if (firmware_has_feature(FW_FEATURE_LPAR))
                find_udbg_vterm();
@@ -336,37 +431,10 @@ static void __init pSeries_init_early(void)
        else if (firmware_has_feature(FW_FEATURE_XDABR))
                ppc_md.set_dabr = pseries_set_xdabr;
 
+       pSeries_cmo_feature_init();
        iommu_init_early_pSeries();
 
-       pSeries_discover_pic();
-
-       DBG(" <- pSeries_init_early()\n");
-}
-
-
-static int pSeries_check_legacy_ioport(unsigned int baseport)
-{
-       struct device_node *np;
-
-#define I8042_DATA_REG 0x60
-#define FDC_BASE       0x3f0
-
-
-       switch(baseport) {
-       case I8042_DATA_REG:
-               np = of_find_node_by_type(NULL, "8042");
-               if (np == NULL)
-                       return -ENODEV;
-               of_node_put(np);
-               break;
-       case FDC_BASE:
-               np = of_find_node_by_type(NULL, "fdc");
-               if (np == NULL)
-                       return -ENODEV;
-               of_node_put(np);
-               break;
-       }
-       return 0;
+       pr_debug(" <- pSeries_init_early()\n");
 }
 
 /*
@@ -377,21 +445,28 @@ static int __init pSeries_probe_hypertas(unsigned long node,
                                         const char *uname, int depth,
                                         void *data)
 {
+       const char *hypertas;
+       unsigned long len;
+
        if (depth != 1 ||
            (strcmp(uname, "rtas") != 0 && strcmp(uname, "rtas@0") != 0))
-               return 0;
+               return 0;
+
+       hypertas = of_get_flat_dt_prop(node, "ibm,hypertas-functions", &len);
+       if (!hypertas)
+               return 1;
 
-       if (of_get_flat_dt_prop(node, "ibm,hypertas-functions", NULL) != NULL)
-               powerpc_firmware_features |= FW_FEATURE_LPAR;
+       powerpc_firmware_features |= FW_FEATURE_LPAR;
+       fw_feature_init(hypertas, len);
 
-       return 1;
+       return 1;
 }
 
 static int __init pSeries_probe(void)
 {
        unsigned long root = of_get_flat_dt_root();
-       char *dtype = of_get_flat_dt_prop(of_get_flat_dt_root(),
-                                         "device_type", NULL);
+       char *dtype = of_get_flat_dt_prop(root, "device_type", NULL);
+
        if (dtype == NULL)
                return 0;
        if (strcmp(dtype, "chrp"))
@@ -404,13 +479,18 @@ static int __init pSeries_probe(void)
            of_flat_dt_is_compatible(root, "IBM,CBEA"))
                return 0;
 
-       DBG("pSeries detected, looking for LPAR capability...\n");
+       pr_debug("pSeries detected, looking for LPAR capability...\n");
 
        /* Now try to figure out if we are running on LPAR */
        of_scan_flat_dt(pSeries_probe_hypertas, NULL);
 
-       DBG("Machine is%s LPAR !\n",
-           (powerpc_firmware_features & FW_FEATURE_LPAR) ? "" : " not");
+       if (firmware_has_feature(FW_FEATURE_LPAR))
+               hpte_init_lpar();
+       else
+               hpte_init_native();
+
+       pr_debug("Machine is%s LPAR !\n",
+                (powerpc_firmware_features & FW_FEATURE_LPAR) ? "" : " not");
 
        return 1;
 }
@@ -422,22 +502,24 @@ static void pseries_dedicated_idle_sleep(void)
 { 
        unsigned int cpu = smp_processor_id();
        unsigned long start_snooze;
-       unsigned long *smt_snooze_delay = &__get_cpu_var(smt_snooze_delay);
+       unsigned long in_purr, out_purr;
 
        /*
         * Indicate to the HV that we are idle. Now would be
         * a good time to find other work to dispatch.
         */
        get_lppaca()->idle = 1;
+       get_lppaca()->donate_dedicated_cpu = 1;
+       in_purr = mfspr(SPRN_PURR);
 
        /*
         * We come in with interrupts disabled, and need_resched()
         * has been checked recently.  If we should poll for a little
         * while, do so.
         */
-       if (*smt_snooze_delay) {
+       if (__get_cpu_var(smt_snooze_delay)) {
                start_snooze = get_tb() +
-                       *smt_snooze_delay * tb_ticks_per_usec;
+                       __get_cpu_var(smt_snooze_delay) * tb_ticks_per_usec;
                local_irq_enable();
                set_thread_flag(TIF_POLLING_NRFLAG);
 
@@ -457,25 +539,13 @@ static void pseries_dedicated_idle_sleep(void)
                        goto out;
        }
 
-       /*
-        * Cede if the other thread is not idle, so that it can
-        * go single-threaded.  If the other thread is idle,
-        * we ask the hypervisor if it has pending work it
-        * wants to do and cede if it does.  Otherwise we keep
-        * polling in order to reduce interrupt latency.
-        *
-        * Doing the cede when the other thread is active will
-        * result in this thread going dormant, meaning the other
-        * thread gets to run in single-threaded (ST) mode, which
-        * is slightly faster than SMT mode with this thread at
-        * very low priority.  The cede enables interrupts, which
-        * doesn't matter here.
-        */
-       if (!lppaca[cpu ^ 1].idle || poll_pending() == H_PENDING)
-               cede_processor();
+       cede_processor();
 
 out:
        HMT_medium();
+       out_purr = mfspr(SPRN_PURR);
+       get_lppaca()->wait_state_cycles += out_purr - in_purr;
+       get_lppaca()->donate_dedicated_cpu = 0;
        get_lppaca()->idle = 0;
 }
 
@@ -506,25 +576,36 @@ static int pSeries_pci_probe_mode(struct pci_bus *bus)
        return PCI_PROBE_NORMAL;
 }
 
-#ifdef CONFIG_KEXEC
-static void pseries_kexec_cpu_down(int crash_shutdown, int secondary)
+/**
+ * pSeries_power_off - tell firmware about how to power off the system.
+ *
+ * This function calls either the power-off rtas token in normal cases
+ * or the ibm,power-off-ups token (if present & requested) in case of
+ * a power failure. If power-off token is used, power on will only be
+ * possible with power button press. If ibm,power-off-ups token is used
+ * it will allow auto poweron after power is restored.
+ */
+static void pSeries_power_off(void)
 {
-       /* Don't risk a hypervisor call if we're crashing */
-       if (firmware_has_feature(FW_FEATURE_SPLPAR) && !crash_shutdown) {
-               unsigned long vpa = __pa(get_lppaca());
-
-               if (unregister_vpa(hard_smp_processor_id(), vpa)) {
-                       printk("VPA deregistration of cpu %u (hw_cpu_id %d) "
-                                       "failed\n", smp_processor_id(),
-                                       hard_smp_processor_id());
-               }
-       }
+       int rc;
+       int rtas_poweroff_ups_token = rtas_token("ibm,power-off-ups");
 
-       if (ppc64_interrupt_controller == IC_OPEN_PIC)
-               mpic_teardown_this_cpu(secondary);
-       else
-               xics_teardown_cpu(secondary);
+       if (rtas_flash_term_hook)
+               rtas_flash_term_hook(SYS_POWER_OFF);
+
+       if (rtas_poweron_auto == 0 ||
+               rtas_poweroff_ups_token == RTAS_UNKNOWN_SERVICE) {
+               rc = rtas_call(rtas_token("power-off"), 2, 1, NULL, -1, -1);
+               printk(KERN_INFO "RTAS power-off returned %d\n", rc);
+       } else {
+               rc = rtas_call(rtas_poweroff_ups_token, 0, 1, NULL);
+               printk(KERN_INFO "RTAS ibm,power-off-ups returned %d\n", rc);
+       }
+       for (;;);
 }
+
+#ifndef CONFIG_PCI
+void pSeries_final_fixup(void) { }
 #endif
 
 define_machine(pseries) {
@@ -536,24 +617,15 @@ define_machine(pseries) {
        .log_error              = pSeries_log_error,
        .pcibios_fixup          = pSeries_final_fixup,
        .pci_probe_mode         = pSeries_pci_probe_mode,
-       .irq_bus_setup          = pSeries_irq_bus_setup,
        .restart                = rtas_restart,
-       .power_off              = rtas_power_off,
+       .power_off              = pSeries_power_off,
        .halt                   = rtas_halt,
        .panic                  = rtas_os_term,
-       .cpu_die                = pSeries_mach_cpu_die,
        .get_boot_time          = rtas_get_boot_time,
        .get_rtc_time           = rtas_get_rtc_time,
        .set_rtc_time           = rtas_set_rtc_time,
        .calibrate_decr         = generic_calibrate_decr,
        .progress               = rtas_progress,
-       .check_legacy_ioport    = pSeries_check_legacy_ioport,
        .system_reset_exception = pSeries_system_reset_exception,
        .machine_check_exception = pSeries_machine_check_exception,
-#ifdef CONFIG_KEXEC
-       .kexec_cpu_down         = pseries_kexec_cpu_down,
-       .machine_kexec          = default_machine_kexec,
-       .machine_kexec_prepare  = default_machine_kexec_prepare,
-       .machine_crash_shutdown = default_machine_crash_shutdown,
-#endif
 };