[POWERPC] Merge 32 and 64 bits asm-powerpc/io.h
[linux-3.10.git] / arch / powerpc / platforms / powermac / setup.c
index b6414e7..d949e9d 100644 (file)
@@ -1,11 +1,11 @@
 /*
- *  arch/ppc/platforms/setup.c
+ *  Powermac setup and early boot code plus other random bits.
  *
  *  PowerPC version
  *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
  *
  *  Adapted for Power Macintosh by Paul Mackerras
- *    Copyright (C) 1996 Paul Mackerras (paulus@cs.anu.edu.au)
+ *    Copyright (C) 1996 Paul Mackerras (paulus@samba.org)
  *
  *  Derived from "arch/alpha/kernel/setup.c"
  *    Copyright (C) 1995 Linus Torvalds
@@ -23,7 +23,6 @@
  * bootup setup stuff..
  */
 
-#include <linux/config.h>
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <asm/system.h>
 #include <asm/pgtable.h>
 #include <asm/io.h>
+#include <asm/kexec.h>
 #include <asm/pci-bridge.h>
 #include <asm/ohare.h>
 #include <asm/mediabay.h>
 #include <asm/machdep.h>
 #include <asm/dma.h>
-#include <asm/bootx.h>
 #include <asm/cputable.h>
 #include <asm/btext.h>
 #include <asm/pmac_feature.h>
 #include <asm/time.h>
 #include <asm/of_device.h>
+#include <asm/of_platform.h>
 #include <asm/mmu_context.h>
+#include <asm/iommu.h>
+#include <asm/smu.h>
+#include <asm/pmc.h>
+#include <asm/lmb.h>
+#include <asm/udbg.h>
 
 #include "pmac.h"
 
 #undef SHOW_GATWICK_IRQS
 
-unsigned char drive_info;
-
 int ppc_override_l2cr = 0;
 int ppc_override_l2cr_value;
 int has_l2cache = 0;
 
-int pmac_newworld = 1;
+int pmac_newworld;
 
 static int current_root_goodness = -1;
 
-extern int pmac_newworld;
+extern struct machdep_calls pmac_md;
 
 #define DEFAULT_ROOT_DEVICE Root_SDA1  /* sda1 - slightly silly choice */
 
-extern void zs_kgdb_hook(int tty_num);
-static void ohare_init(void);
-#ifdef CONFIG_BOOTX_TEXT
-static void pmac_progress(char *s, unsigned short hex);
+#ifdef CONFIG_PPC64
+#include <asm/udbg.h>
+int sccdbg;
 #endif
 
+extern void zs_kgdb_hook(int tty_num);
+
 sys_ctrler_t sys_ctrler = SYS_CTRLER_UNKNOWN;
+EXPORT_SYMBOL(sys_ctrler);
+
+#ifdef CONFIG_PMAC_SMU
+unsigned long smu_cmdbuf_abs;
+EXPORT_SYMBOL(smu_cmdbuf_abs);
+#endif
 
 #ifdef CONFIG_SMP
 extern struct smp_ops_t psurge_smp_ops;
 extern struct smp_ops_t core99_smp_ops;
 #endif /* CONFIG_SMP */
 
-static int
-pmac_show_cpuinfo(struct seq_file *m)
+static void pmac_show_cpuinfo(struct seq_file *m)
 {
        struct device_node *np;
-       char *pp;
+       const char *pp;
        int plen;
-       int mbmodel = pmac_call_feature(PMAC_FTR_GET_MB_INFO,
-               NULL, PMAC_MB_INFO_MODEL, 0);
-       unsigned int mbflags = (unsigned int)pmac_call_feature(PMAC_FTR_GET_MB_INFO,
-               NULL, PMAC_MB_INFO_FLAGS, 0);
+       int mbmodel;
+       unsigned int mbflags;
        char* mbname;
 
-       if (pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL, PMAC_MB_INFO_NAME, (int)&mbname) != 0)
+       mbmodel = pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL,
+                                   PMAC_MB_INFO_MODEL, 0);
+       mbflags = pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL,
+                                   PMAC_MB_INFO_FLAGS, 0);
+       if (pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL, PMAC_MB_INFO_NAME,
+                             (long) &mbname) != 0)
                mbname = "Unknown";
 
        /* find motherboard type */
        seq_printf(m, "machine\t\t: ");
-       np = find_devices("device-tree");
+       np = of_find_node_by_path("/");
        if (np != NULL) {
-               pp = (char *) get_property(np, "model", NULL);
+               pp = get_property(np, "model", NULL);
                if (pp != NULL)
                        seq_printf(m, "%s\n", pp);
                else
                        seq_printf(m, "PowerMac\n");
-               pp = (char *) get_property(np, "compatible", &plen);
+               pp = get_property(np, "compatible", &plen);
                if (pp != NULL) {
                        seq_printf(m, "motherboard\t:");
                        while (plen > 0) {
@@ -139,6 +151,7 @@ pmac_show_cpuinfo(struct seq_file *m)
                        }
                        seq_printf(m, "\n");
                }
+               of_node_put(np);
        } else
                seq_printf(m, "PowerMac\n");
 
@@ -147,14 +160,12 @@ pmac_show_cpuinfo(struct seq_file *m)
        seq_printf(m, "pmac flags\t: %08x\n", mbflags);
 
        /* find l2 cache info */
-       np = find_devices("l2-cache");
-       if (np == 0)
-               np = find_type_devices("cache");
-       if (np != 0) {
-               unsigned int *ic = (unsigned int *)
-                       get_property(np, "i-cache-size", NULL);
-               unsigned int *dc = (unsigned int *)
-                       get_property(np, "d-cache-size", NULL);
+       np = of_find_node_by_name(NULL, "l2-cache");
+       if (np == NULL)
+               np = of_find_node_by_type(NULL, "cache");
+       if (np != NULL) {
+               const unsigned int *ic = get_property(np, "i-cache-size", NULL);
+               const unsigned int *dc = get_property(np, "d-cache-size", NULL);
                seq_printf(m, "L2 cache\t:");
                has_l2cache = 1;
                if (get_property(np, "cache-unified", NULL) != 0 && dc) {
@@ -170,100 +181,79 @@ pmac_show_cpuinfo(struct seq_file *m)
                if (pp)
                        seq_printf(m, " %s", pp);
                seq_printf(m, "\n");
-       }
-
-       /* find ram info */
-       np = find_devices("memory");
-       if (np != 0) {
-               int n;
-               struct reg_property *reg = (struct reg_property *)
-                       get_property(np, "reg", &n);
-
-               if (reg != 0) {
-                       unsigned long total = 0;
-
-                       for (n /= sizeof(struct reg_property); n > 0; --n)
-                               total += (reg++)->size;
-                       seq_printf(m, "memory\t\t: %luMB\n", total >> 20);
-               }
-       }
-
-       /* Checks "l2cr-value" property in the registry */
-       np = find_devices("cpus");
-       if (np == 0)
-               np = find_type_devices("cpu");
-       if (np != 0) {
-               unsigned int *l2cr = (unsigned int *)
-                       get_property(np, "l2cr-value", NULL);
-               if (l2cr != 0) {
-                       seq_printf(m, "l2cr override\t: 0x%x\n", *l2cr);
-               }
+               of_node_put(np);
        }
 
        /* Indicate newworld/oldworld */
        seq_printf(m, "pmac-generation\t: %s\n",
                   pmac_newworld ? "NewWorld" : "OldWorld");
+}
 
-
+#ifndef CONFIG_ADB_CUDA
+int find_via_cuda(void)
+{
+       if (!find_devices("via-cuda"))
+               return 0;
+       printk("WARNING ! Your machine is CUDA-based but your kernel\n");
+       printk("          wasn't compiled with CONFIG_ADB_CUDA option !\n");
        return 0;
 }
+#endif
 
-static int
-pmac_show_percpuinfo(struct seq_file *m, int i)
+#ifndef CONFIG_ADB_PMU
+int find_via_pmu(void)
 {
-#ifdef CONFIG_CPU_FREQ_PMAC
-       extern unsigned int pmac_get_one_cpufreq(int i);
-       unsigned int freq = pmac_get_one_cpufreq(i);
-       if (freq != 0) {
-               seq_printf(m, "clock\t\t: %dMHz\n", freq/1000);
+       if (!find_devices("via-pmu"))
                return 0;
-       }
-#endif /* CONFIG_CPU_FREQ_PMAC */
-       return of_show_percpuinfo(m, i);
+       printk("WARNING ! Your machine is PMU-based but your kernel\n");
+       printk("          wasn't compiled with CONFIG_ADB_PMU option !\n");
+       return 0;
 }
+#endif
 
-static volatile u32 *sysctrl_regs;
-
-void __init
-pmac_setup_arch(void)
+#ifndef CONFIG_PMAC_SMU
+int smu_init(void)
 {
-       struct device_node *cpu;
-       int *fp;
-       unsigned long pvr;
-
-       pvr = PVR_VER(mfspr(SPRN_PVR));
+       /* should check and warn if SMU is present */
+       return 0;
+}
+#endif
 
-       /* Set loops_per_jiffy to a half-way reasonable value,
-          for use until calibrate_delay gets called. */
-       cpu = find_type_devices("cpu");
-       if (cpu != 0) {
-               fp = (int *) get_property(cpu, "clock-frequency", NULL);
-               if (fp != 0) {
-                       if (pvr == 4 || pvr >= 8)
-                               /* 604, G3, G4 etc. */
-                               loops_per_jiffy = *fp / HZ;
-                       else
-                               /* 601, 603, etc. */
-                               loops_per_jiffy = *fp / (2*HZ);
-               } else
-                       loops_per_jiffy = 50000000 / HZ;
-       }
+#ifdef CONFIG_PPC32
+static volatile u32 *sysctrl_regs;
 
+static void __init ohare_init(void)
+{
        /* this area has the CPU identification register
           and some registers used by smp boards */
        sysctrl_regs = (volatile u32 *) ioremap(0xf8000000, 0x1000);
-       ohare_init();
 
-       /* Lookup PCI hosts */
-       pmac_find_bridges();
+       /*
+        * Turn on the L2 cache.
+        * We assume that we have a PSX memory controller iff
+        * we have an ohare I/O controller.
+        */
+       if (find_devices("ohare") != NULL) {
+               if (((sysctrl_regs[2] >> 24) & 0xf) >= 3) {
+                       if (sysctrl_regs[4] & 0x10)
+                               sysctrl_regs[4] |= 0x04000020;
+                       else
+                               sysctrl_regs[4] |= 0x04000000;
+                       if(has_l2cache)
+                               printk(KERN_INFO "Level 2 cache enabled\n");
+               }
+       }
+}
 
+static void __init l2cr_init(void)
+{
        /* Checks "l2cr-value" property in the registry */
        if (cpu_has_feature(CPU_FTR_L2CR)) {
                struct device_node *np = find_devices("cpus");
                if (np == 0)
                        np = find_type_devices("cpu");
                if (np != 0) {
-                       unsigned int *l2cr = (unsigned int *)
+                       const unsigned int *l2cr =
                                get_property(np, "l2cr-value", NULL);
                        if (l2cr != 0) {
                                ppc_override_l2cr = 1;
@@ -275,68 +265,96 @@ pmac_setup_arch(void)
        }
 
        if (ppc_override_l2cr)
-               printk(KERN_INFO "L2CR overriden (0x%x), backside cache is %s\n",
-                       ppc_override_l2cr_value, (ppc_override_l2cr_value & 0x80000000)
+               printk(KERN_INFO "L2CR overridden (0x%x), "
+                      "backside cache is %s\n",
+                      ppc_override_l2cr_value,
+                      (ppc_override_l2cr_value & 0x80000000)
                                ? "enabled" : "disabled");
+}
+#endif
+
+static void __init pmac_setup_arch(void)
+{
+       struct device_node *cpu, *ic;
+       const int *fp;
+       unsigned long pvr;
+
+       pvr = PVR_VER(mfspr(SPRN_PVR));
+
+       /* Set loops_per_jiffy to a half-way reasonable value,
+          for use until calibrate_delay gets called. */
+       loops_per_jiffy = 50000000 / HZ;
+       cpu = of_find_node_by_type(NULL, "cpu");
+       if (cpu != NULL) {
+               fp = get_property(cpu, "clock-frequency", NULL);
+               if (fp != NULL) {
+                       if (pvr >= 0x30 && pvr < 0x80)
+                               /* PPC970 etc. */
+                               loops_per_jiffy = *fp / (3 * HZ);
+                       else if (pvr == 4 || pvr >= 8)
+                               /* 604, G3, G4 etc. */
+                               loops_per_jiffy = *fp / HZ;
+                       else
+                               /* 601, 603, etc. */
+                               loops_per_jiffy = *fp / (2 * HZ);
+               }
+               of_node_put(cpu);
+       }
+
+       /* See if newworld or oldworld */
+       for (ic = NULL; (ic = of_find_all_nodes(ic)) != NULL; )
+               if (get_property(ic, "interrupt-controller", NULL))
+                       break;
+       if (ic) {
+               pmac_newworld = 1;
+               of_node_put(ic);
+       }
+
+       /* Lookup PCI hosts */
+       pmac_pci_init();
+
+#ifdef CONFIG_PPC32
+       ohare_init();
+       l2cr_init();
+#endif /* CONFIG_PPC32 */
 
 #ifdef CONFIG_KGDB
        zs_kgdb_hook(0);
 #endif
 
-#ifdef CONFIG_ADB_CUDA
        find_via_cuda();
-#else
-       if (find_devices("via-cuda")) {
-               printk("WARNING ! Your machine is Cuda based but your kernel\n");
-               printk("          wasn't compiled with CONFIG_ADB_CUDA option !\n");
-       }
-#endif
-#ifdef CONFIG_ADB_PMU
        find_via_pmu();
-#else
-       if (find_devices("via-pmu")) {
-               printk("WARNING ! Your machine is PMU based but your kernel\n");
-               printk("          wasn't compiled with CONFIG_ADB_PMU option !\n");
-       }
-#endif
-#ifdef CONFIG_NVRAM
+       smu_init();
+
+#if defined(CONFIG_NVRAM) || defined(CONFIG_PPC64)
        pmac_nvram_init();
 #endif
+
+#ifdef CONFIG_PPC32
 #ifdef CONFIG_BLK_DEV_INITRD
        if (initrd_start)
                ROOT_DEV = Root_RAM0;
        else
 #endif
                ROOT_DEV = DEFAULT_ROOT_DEVICE;
+#endif
 
 #ifdef CONFIG_SMP
        /* Check for Core99 */
-       if (find_devices("uni-n") || find_devices("u3"))
+       if (find_devices("uni-n") || find_devices("u3") || find_devices("u4"))
                smp_ops = &core99_smp_ops;
+#ifdef CONFIG_PPC32
        else
                smp_ops = &psurge_smp_ops;
+#endif
 #endif /* CONFIG_SMP */
 
-       pci_create_OF_bus_map();
-}
-
-static void __init ohare_init(void)
-{
-       /*
-        * Turn on the L2 cache.
-        * We assume that we have a PSX memory controller iff
-        * we have an ohare I/O controller.
-        */
-       if (find_devices("ohare") != NULL) {
-               if (((sysctrl_regs[2] >> 24) & 0xf) >= 3) {
-                       if (sysctrl_regs[4] & 0x10)
-                               sysctrl_regs[4] |= 0x04000020;
-                       else
-                               sysctrl_regs[4] |= 0x04000000;
-                       if(has_l2cache)
-                               printk(KERN_INFO "Level 2 cache enabled\n");
-               }
+#ifdef CONFIG_ADB
+       if (strstr(cmd_line, "adb_sync")) {
+               extern int __adb_probe_sync;
+               __adb_probe_sync = 1;
        }
+#endif /* CONFIG_ADB */
 }
 
 char *bootpath;
@@ -344,11 +362,10 @@ char *bootdevice;
 void *boot_host;
 int boot_target;
 int boot_part;
-extern dev_t boot_dev;
+static dev_t boot_dev;
 
 #ifdef CONFIG_SCSI
-void __init
-note_scsi_host(struct device_node *node, void *host)
+void __init note_scsi_host(struct device_node *node, void *host)
 {
        int l;
        char *p;
@@ -379,8 +396,7 @@ EXPORT_SYMBOL(note_scsi_host);
 #endif
 
 #if defined(CONFIG_BLK_DEV_IDE) && defined(CONFIG_BLK_DEV_IDE_PMAC)
-static dev_t __init
-find_ide_boot(void)
+static dev_t __init find_ide_boot(void)
 {
        char *p;
        int n;
@@ -397,15 +413,13 @@ find_ide_boot(void)
 }
 #endif /* CONFIG_BLK_DEV_IDE && CONFIG_BLK_DEV_IDE_PMAC */
 
-static void __init
-find_boot_device(void)
+static void __init find_boot_device(void)
 {
 #if defined(CONFIG_BLK_DEV_IDE) && defined(CONFIG_BLK_DEV_IDE_PMAC)
        boot_dev = find_ide_boot();
 #endif
 }
 
-static int initializing = 1;
 /* TODO: Merge the suspend-to-ram with the common code !!!
  * currently, this is a stub implementation for suspend-to-disk
  * only
@@ -442,20 +456,34 @@ static int pmac_pm_finish(suspend_state_t state)
        printk(KERN_DEBUG "%s(%d)\n", __FUNCTION__, state);
 
        /* Restore userland MMU context */
-       set_context(current->active_mm->context, current->active_mm->pgd);
+       set_context(current->active_mm->context.id, current->active_mm->pgd);
 
        return 0;
 }
 
+static int pmac_pm_valid(suspend_state_t state)
+{
+       switch (state) {
+       case PM_SUSPEND_DISK:
+               return 1;
+       /* can't do any other states via generic mechanism yet */
+       default:
+               return 0;
+       }
+}
+
 static struct pm_ops pmac_pm_ops = {
        .pm_disk_mode   = PM_DISK_SHUTDOWN,
        .prepare        = pmac_pm_prepare,
        .enter          = pmac_pm_enter,
        .finish         = pmac_pm_finish,
+       .valid          = pmac_pm_valid,
 };
 
 #endif /* CONFIG_SOFTWARE_SUSPEND */
 
+static int initializing = 1;
+
 static int pmac_late_init(void)
 {
        initializing = 0;
@@ -468,8 +496,7 @@ static int pmac_late_init(void)
 late_initcall(pmac_late_init);
 
 /* can't be __init - can be called whenever a disk is first accessed */
-void
-note_bootable_part(dev_t dev, int part, int goodness)
+void note_bootable_part(dev_t dev, int part, int goodness)
 {
        static int found_boot = 0;
        char *p;
@@ -494,52 +521,68 @@ note_bootable_part(dev_t dev, int part, int goodness)
        }
 }
 
-static void
-pmac_restart(char *cmd)
-{
 #ifdef CONFIG_ADB_CUDA
+static void cuda_restart(void)
+{
+       struct adb_request req;
+
+       cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_RESET_SYSTEM);
+       for (;;)
+               cuda_poll();
+}
+
+static void cuda_shutdown(void)
+{
        struct adb_request req;
-#endif /* CONFIG_ADB_CUDA */
 
+       cuda_request(&req, NULL, 2, CUDA_PACKET, CUDA_POWERDOWN);
+       for (;;)
+               cuda_poll();
+}
+
+#else
+#define cuda_restart()
+#define cuda_shutdown()
+#endif
+
+#ifndef CONFIG_ADB_PMU
+#define pmu_restart()
+#define pmu_shutdown()
+#endif
+
+#ifndef CONFIG_PMAC_SMU
+#define smu_restart()
+#define smu_shutdown()
+#endif
+
+static void pmac_restart(char *cmd)
+{
        switch (sys_ctrler) {
-#ifdef CONFIG_ADB_CUDA
        case SYS_CTRLER_CUDA:
-               cuda_request(&req, NULL, 2, CUDA_PACKET,
-                            CUDA_RESET_SYSTEM);
-               for (;;)
-                       cuda_poll();
+               cuda_restart();
                break;
-#endif /* CONFIG_ADB_CUDA */
-#ifdef CONFIG_ADB_PMU
        case SYS_CTRLER_PMU:
                pmu_restart();
                break;
-#endif /* CONFIG_ADB_PMU */
+       case SYS_CTRLER_SMU:
+               smu_restart();
+               break;
        default: ;
        }
 }
 
-static void
-pmac_power_off(void)
+static void pmac_power_off(void)
 {
-#ifdef CONFIG_ADB_CUDA
-       struct adb_request req;
-#endif /* CONFIG_ADB_CUDA */
-
        switch (sys_ctrler) {
-#ifdef CONFIG_ADB_CUDA
        case SYS_CTRLER_CUDA:
-               cuda_request(&req, NULL, 2, CUDA_PACKET,
-                            CUDA_POWERDOWN);
-               for (;;)
-                       cuda_poll();
+               cuda_shutdown();
                break;
-#endif /* CONFIG_ADB_CUDA */
-#ifdef CONFIG_ADB_PMU
        case SYS_CTRLER_PMU:
                pmu_shutdown();
                break;
-#endif /* CONFIG_ADB_PMU */
+       case SYS_CTRLER_SMU:
+               smu_shutdown();
+               break;
        default: ;
        }
 }
@@ -550,96 +593,167 @@ pmac_halt(void)
        pmac_power_off();
 }
 
-void __init pmac_init(void)
+/* 
+ * Early initialization.
+ */
+static void __init pmac_init_early(void)
 {
-       /* isa_io_base gets set in pmac_find_bridges */
-       isa_mem_base = PMAC_ISA_MEM_BASE;
-       pci_dram_offset = PMAC_PCI_DRAM_OFFSET;
-       ISA_DMA_THRESHOLD = ~0L;
-       DMA_MODE_READ = 1;
-       DMA_MODE_WRITE = 2;
-
-       ppc_md.setup_arch     = pmac_setup_arch;
-       ppc_md.show_cpuinfo   = pmac_show_cpuinfo;
-       ppc_md.show_percpuinfo = pmac_show_percpuinfo;
-       ppc_md.init_IRQ       = pmac_pic_init;
-       ppc_md.get_irq        = pmac_get_irq; /* Changed later on ... */
-
-       ppc_md.pcibios_fixup  = pmac_pcibios_fixup;
-       ppc_md.pcibios_enable_device_hook = pmac_pci_enable_device_hook;
-       ppc_md.pcibios_after_init = pmac_pcibios_after_init;
-       ppc_md.phys_mem_access_prot = pci_phys_mem_access_prot;
-
-       ppc_md.restart        = pmac_restart;
-       ppc_md.power_off      = pmac_power_off;
-       ppc_md.halt           = pmac_halt;
-
-       ppc_md.time_init      = pmac_time_init;
-       ppc_md.set_rtc_time   = pmac_set_rtc_time;
-       ppc_md.get_rtc_time   = pmac_get_rtc_time;
-       ppc_md.get_boot_time  = pmac_get_boot_time;
-       ppc_md.calibrate_decr = pmac_calibrate_decr;
-
-       ppc_md.feature_call   = pmac_do_feature_call;
-
-#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
-#ifdef CONFIG_BLK_DEV_IDE_PMAC
-        ppc_ide_md.ide_init_hwif       = pmac_ide_init_hwif_ports;
-        ppc_ide_md.default_io_base     = pmac_ide_get_base;
-#endif /* CONFIG_BLK_DEV_IDE_PMAC */
-#endif /* defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) */
+       /* Enable early btext debug if requested */
+       if (strstr(cmd_line, "btextdbg")) {
+               udbg_adb_init_early();
+               register_early_udbg_console();
+       }
 
-#ifdef CONFIG_BOOTX_TEXT
-       ppc_md.progress = pmac_progress;
-#endif /* CONFIG_BOOTX_TEXT */
+       /* Probe motherboard chipset */
+       pmac_feature_init();
 
-       if (ppc_md.progress) ppc_md.progress("pmac_init(): exit", 0);
+       /* Initialize debug stuff */
+       udbg_scc_init(!!strstr(cmd_line, "sccdbg"));
+       udbg_adb_init(!!strstr(cmd_line, "btextdbg"));
 
+#ifdef CONFIG_PPC64
+       iommu_init_early_dart();
+#endif
 }
 
-#ifdef CONFIG_BOOTX_TEXT
-static void __init
-pmac_progress(char *s, unsigned short hex)
+/*
+ * pmac has no legacy IO, anything calling this function has to
+ * fail or bad things will happen
+ */
+static int pmac_check_legacy_ioport(unsigned int baseport)
 {
-       if (boot_text_mapped) {
-               btext_drawstring(s);
-               btext_drawchar('\n');
-       }
+       return -ENODEV;
 }
-#endif /* CONFIG_BOOTX_TEXT */
 
-static int __init
-pmac_declare_of_platform_devices(void)
+static int __init pmac_declare_of_platform_devices(void)
 {
        struct device_node *np;
 
-       np = find_devices("uni-n");
-       if (np) {
-               for (np = np->child; np != NULL; np = np->sibling)
-                       if (strncmp(np->name, "i2c", 3) == 0) {
-                               of_platform_device_create(np, "uni-n-i2c",
-                                                         NULL);
-                               break;
-                       }
-       }
-       np = find_devices("u3");
-       if (np) {
-               for (np = np->child; np != NULL; np = np->sibling)
-                       if (strncmp(np->name, "i2c", 3) == 0) {
-                               of_platform_device_create(np, "u3-i2c",
-                                                         NULL);
-                               break;
-                       }
-       }
+       if (machine_is(chrp))
+               return -1;
 
-       np = find_devices("valkyrie");
+       if (!machine_is(powermac))
+               return 0;
+
+       np = of_find_node_by_name(NULL, "valkyrie");
        if (np)
                of_platform_device_create(np, "valkyrie", NULL);
-       np = find_devices("platinum");
+       np = of_find_node_by_name(NULL, "platinum");
        if (np)
                of_platform_device_create(np, "platinum", NULL);
+        np = of_find_node_by_type(NULL, "smu");
+        if (np) {
+               of_platform_device_create(np, "smu", NULL);
+               of_node_put(np);
+       }
 
        return 0;
 }
 
 device_initcall(pmac_declare_of_platform_devices);
+
+/*
+ * Called very early, MMU is off, device-tree isn't unflattened
+ */
+static int __init pmac_probe(void)
+{
+       unsigned long root = of_get_flat_dt_root();
+
+       if (!of_flat_dt_is_compatible(root, "Power Macintosh") &&
+           !of_flat_dt_is_compatible(root, "MacRISC"))
+               return 0;
+
+#ifdef CONFIG_PPC64
+       /*
+        * On U3, the DART (iommu) must be allocated now since it
+        * has an impact on htab_initialize (due to the large page it
+        * occupies having to be broken up so the DART itself is not
+        * part of the cacheable linar mapping
+        */
+       alloc_dart_table();
+
+       hpte_init_native();
+#endif
+
+#ifdef CONFIG_PPC32
+       /* isa_io_base gets set in pmac_pci_init */
+       ISA_DMA_THRESHOLD = ~0L;
+       DMA_MODE_READ = 1;
+       DMA_MODE_WRITE = 2;
+
+#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
+#ifdef CONFIG_BLK_DEV_IDE_PMAC
+        ppc_ide_md.ide_init_hwif       = pmac_ide_init_hwif_ports;
+        ppc_ide_md.default_io_base     = pmac_ide_get_base;
+#endif /* CONFIG_BLK_DEV_IDE_PMAC */
+#endif /* defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) */
+
+#endif /* CONFIG_PPC32 */
+
+#ifdef CONFIG_PMAC_SMU
+       /*
+        * SMU based G5s need some memory below 2Gb, at least the current
+        * driver needs that. We have to allocate it now. We allocate 4k
+        * (1 small page) for now.
+        */
+       smu_cmdbuf_abs = lmb_alloc_base(4096, 4096, 0x80000000UL);
+#endif /* CONFIG_PMAC_SMU */
+
+       return 1;
+}
+
+#ifdef CONFIG_PPC64
+/* Move that to pci.c */
+static int pmac_pci_probe_mode(struct pci_bus *bus)
+{
+       struct device_node *node = bus->sysdata;
+
+       /* We need to use normal PCI probing for the AGP bus,
+        * since the device for the AGP bridge isn't in the tree.
+        */
+       if (bus->self == NULL && (device_is_compatible(node, "u3-agp") ||
+                                 device_is_compatible(node, "u4-pcie")))
+               return PCI_PROBE_NORMAL;
+       return PCI_PROBE_DEVTREE;
+}
+#endif
+
+define_machine(powermac) {
+       .name                   = "PowerMac",
+       .probe                  = pmac_probe,
+       .setup_arch             = pmac_setup_arch,
+       .init_early             = pmac_init_early,
+       .show_cpuinfo           = pmac_show_cpuinfo,
+       .init_IRQ               = pmac_pic_init,
+       .get_irq                = NULL, /* changed later */
+       .pci_irq_fixup          = pmac_pci_irq_fixup,
+       .restart                = pmac_restart,
+       .power_off              = pmac_power_off,
+       .halt                   = pmac_halt,
+       .time_init              = pmac_time_init,
+       .get_boot_time          = pmac_get_boot_time,
+       .set_rtc_time           = pmac_set_rtc_time,
+       .get_rtc_time           = pmac_get_rtc_time,
+       .calibrate_decr         = pmac_calibrate_decr,
+       .feature_call           = pmac_do_feature_call,
+       .check_legacy_ioport    = pmac_check_legacy_ioport,
+       .progress               = udbg_progress,
+#ifdef CONFIG_PPC64
+       .pci_probe_mode         = pmac_pci_probe_mode,
+       .power_save             = power4_idle,
+       .enable_pmcs            = power4_enable_pmcs,
+#ifdef CONFIG_KEXEC
+       .machine_kexec          = default_machine_kexec,
+       .machine_kexec_prepare  = default_machine_kexec_prepare,
+       .machine_crash_shutdown = default_machine_crash_shutdown,
+#endif
+#endif /* CONFIG_PPC64 */
+#ifdef CONFIG_PPC32
+       .pcibios_enable_device_hook = pmac_pci_enable_device_hook,
+       .pcibios_after_init     = pmac_pcibios_after_init,
+       .phys_mem_access_prot   = pci_phys_mem_access_prot,
+#endif
+#if defined(CONFIG_HOTPLUG_CPU) && defined(CONFIG_PPC64)
+       .cpu_die                = generic_mach_cpu_die,
+#endif
+};