Pull kmalloc into release branch
[pandora-kernel.git] / arch / powerpc / platforms / maple / setup.c
index a1cb4d2..5cf90c2 100644 (file)
@@ -13,7 +13,6 @@
 
 #define DEBUG
 
-#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
 #define DBG(fmt...)
 #endif
 
+static unsigned long maple_find_nvram_base(void)
+{
+       struct device_node *rtcs;
+       unsigned long result = 0;
+
+       /* find NVRAM device */
+       rtcs = of_find_compatible_node(NULL, "nvram", "AMD8111");
+       if (rtcs) {
+               struct resource r;
+               if (of_address_to_resource(rtcs, 0, &r)) {
+                       printk(KERN_EMERG "Maple: Unable to translate NVRAM"
+                              " address\n");
+                       goto bail;
+               }
+               if (!(r.flags & IORESOURCE_IO)) {
+                       printk(KERN_EMERG "Maple: NVRAM address isn't PIO!\n");
+                       goto bail;
+               }
+               result = r.start;
+       } else
+               printk(KERN_EMERG "Maple: Unable to find NVRAM\n");
+ bail:
+       of_node_put(rtcs);
+       return result;
+}
+
 static void maple_restart(char *cmd)
 {
        unsigned int maple_nvram_base;
        unsigned int maple_nvram_offset;
        unsigned int maple_nvram_command;
-       struct device_node *rtcs;
+       struct device_node *sp;
 
-       /* find NVRAM device */
-       rtcs = find_compatible_devices("nvram", "AMD8111");
-       if (rtcs && rtcs->addrs) {
-               maple_nvram_base = rtcs->addrs[0].address;
-       } else {
-               printk(KERN_EMERG "Maple: Unable to find NVRAM\n");
-               printk(KERN_EMERG "Maple: Manual Restart Required\n");
-               return;
-       }
+       maple_nvram_base = maple_find_nvram_base();
+       if (maple_nvram_base == 0)
+               goto fail;
 
        /* find service processor device */
-       rtcs = find_devices("service-processor");
-       if (!rtcs) {
+       sp = of_find_node_by_name(NULL, "service-processor");
+       if (!sp) {
                printk(KERN_EMERG "Maple: Unable to find Service Processor\n");
-               printk(KERN_EMERG "Maple: Manual Restart Required\n");
-               return;
+               goto fail;
        }
-       maple_nvram_offset = *(unsigned int*) get_property(rtcs,
+       maple_nvram_offset = *(unsigned int*) get_property(sp,
                        "restart-addr", NULL);
-       maple_nvram_command = *(unsigned int*) get_property(rtcs,
+       maple_nvram_command = *(unsigned int*) get_property(sp,
                        "restart-value", NULL);
+       of_node_put(sp);
 
        /* send command */
        outb_p(maple_nvram_command, maple_nvram_base + maple_nvram_offset);
        for (;;) ;
+ fail:
+       printk(KERN_EMERG "Maple: Manual Restart Required\n");
 }
 
 static void maple_power_off(void)
@@ -110,33 +131,29 @@ static void maple_power_off(void)
        unsigned int maple_nvram_base;
        unsigned int maple_nvram_offset;
        unsigned int maple_nvram_command;
-       struct device_node *rtcs;
+       struct device_node *sp;
 
-       /* find NVRAM device */
-       rtcs = find_compatible_devices("nvram", "AMD8111");
-       if (rtcs && rtcs->addrs) {
-               maple_nvram_base = rtcs->addrs[0].address;
-       } else {
-               printk(KERN_EMERG "Maple: Unable to find NVRAM\n");
-               printk(KERN_EMERG "Maple: Manual Power-Down Required\n");
-               return;
-       }
+       maple_nvram_base = maple_find_nvram_base();
+       if (maple_nvram_base == 0)
+               goto fail;
 
        /* find service processor device */
-       rtcs = find_devices("service-processor");
-       if (!rtcs) {
+       sp = of_find_node_by_name(NULL, "service-processor");
+       if (!sp) {
                printk(KERN_EMERG "Maple: Unable to find Service Processor\n");
-               printk(KERN_EMERG "Maple: Manual Power-Down Required\n");
-               return;
+               goto fail;
        }
-       maple_nvram_offset = *(unsigned int*) get_property(rtcs,
+       maple_nvram_offset = *(unsigned int*) get_property(sp,
                        "power-off-addr", NULL);
-       maple_nvram_command = *(unsigned int*) get_property(rtcs,
+       maple_nvram_command = *(unsigned int*) get_property(sp,
                        "power-off-value", NULL);
+       of_node_put(sp);
 
        /* send command */
        outb_p(maple_nvram_command, maple_nvram_base + maple_nvram_offset);
        for (;;) ;
+ fail:
+       printk(KERN_EMERG "Maple: Manual Power-Down Required\n");
 }
 
 static void maple_halt(void)
@@ -171,7 +188,7 @@ void __init maple_setup_arch(void)
        conswitchp = &dummy_con;
 #endif
 
-       printk(KERN_INFO "Using native/NAP idle loop\n");
+       printk(KERN_DEBUG "Using native/NAP idle loop\n");
 }
 
 /* 
@@ -179,16 +196,8 @@ void __init maple_setup_arch(void)
  */
 static void __init maple_init_early(void)
 {
-       unsigned int default_speed;
-       u64 physport;
-
        DBG(" -> maple_init_early\n");
 
-       /* Initialize hash table, from now on, we can take hash faults
-        * and call ioremap
-        */
-       hpte_init_native();
-
        /* Setup interrupt mapping options */
        ppc64_interrupt_controller = IC_OPEN_PIC;
 
@@ -244,9 +253,10 @@ static void __init maple_progress(char *s, unsigned short hex)
 /*
  * Called very early, MMU is off, device-tree isn't unflattened
  */
-static int __init maple_probe(int platform)
+static int __init maple_probe(void)
 {
-       if (platform != PLATFORM_MAPLE)
+       unsigned long root = of_get_flat_dt_root();
+       if (!of_flat_dt_is_compatible(root, "Momentum,Maple"))
                return 0;
        /*
         * On U3, the DART (iommu) must be allocated now since it
@@ -256,10 +266,13 @@ static int __init maple_probe(int platform)
         */
        alloc_dart_table();
 
+       hpte_init_native();
+
        return 1;
 }
 
-struct machdep_calls __initdata maple_md = {
+define_machine(maple_md) {
+       .name                   = "Maple",
        .probe                  = maple_probe,
        .setup_arch             = maple_setup_arch,
        .init_early             = maple_init_early,
@@ -275,7 +288,7 @@ struct machdep_calls __initdata maple_md = {
                .get_rtc_time           = maple_get_rtc_time,
        .calibrate_decr         = generic_calibrate_decr,
        .progress               = maple_progress,
-       .idle_loop              = native_idle,
+       .power_save             = power4_idle,
 #ifdef CONFIG_KEXEC
        .machine_kexec          = default_machine_kexec,
        .machine_kexec_prepare  = default_machine_kexec_prepare,