]> git.karo-electronics.de Git - linux-beck.git/blobdiff - arch/powerpc/kernel/setup-common.c
[PATCH] powerpc: Use check_legacy_ioport() on ppc32 too.
[linux-beck.git] / arch / powerpc / kernel / setup-common.c
index b17630ad4ac73f361658c50d08367ff3d518e1f4..684ab1d49c65366d62930c22346cb3581e588e71 100644 (file)
@@ -9,6 +9,9 @@
  *      as published by the Free Software Foundation; either version
  *      2 of the License, or (at your option) any later version.
  */
+
+#undef DEBUG
+
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/string.h>
@@ -18,6 +21,7 @@
 #include <linux/reboot.h>
 #include <linux/delay.h>
 #include <linux/initrd.h>
+#include <linux/platform_device.h>
 #include <linux/ide.h>
 #include <linux/seq_file.h>
 #include <linux/ioport.h>
@@ -41,6 +45,7 @@
 #include <asm/time.h>
 #include <asm/cputable.h>
 #include <asm/sections.h>
+#include <asm/firmware.h>
 #include <asm/btext.h>
 #include <asm/nvram.h>
 #include <asm/setup.h>
@@ -56,8 +61,6 @@
 
 #include "setup.h"
 
-#undef DEBUG
-
 #ifdef DEBUG
 #include <asm/udbg.h>
 #define DBG(fmt...) udbg_printf(fmt)
 #define DBG(fmt...)
 #endif
 
-#ifdef CONFIG_PPC_MULTIPLATFORM
-int _machine = 0;
-EXPORT_SYMBOL(_machine);
-#endif
+/* The main machine-dep calls structure
+ */
+struct machdep_calls ppc_md;
+EXPORT_SYMBOL(ppc_md);
+struct machdep_calls *machine_id;
+EXPORT_SYMBOL(machine_id);
 
 unsigned long klimit = (unsigned long) _end;
 
@@ -168,7 +173,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
                           bogosum/(500000/HZ), bogosum/(5000/HZ) % 100);
 #endif /* CONFIG_SMP && CONFIG_PPC32 */
                seq_printf(m, "timebase\t: %lu\n", ppc_tb_freq);
-
+               if (ppc_md.name)
+                       seq_printf(m, "platform\t: %s\n", ppc_md.name);
                if (ppc_md.show_cpuinfo != NULL)
                        ppc_md.show_cpuinfo(m);
 
@@ -387,7 +393,7 @@ void __init smp_setup_cpu_maps(void)
         * On pSeries LPAR, we need to know how many cpus
         * could possibly be added to this partition.
         */
-       if (_machine == PLATFORM_PSERIES_LPAR &&
+       if (machine_is(pseries) && firmware_has_feature(FW_FEATURE_LPAR) &&
            (dn = of_find_node_by_path("/rtas"))) {
                int num_addr_cell, num_size_cell, maxcpus;
                unsigned int *ireg;
@@ -426,7 +432,7 @@ void __init smp_setup_cpu_maps(void)
        /*
         * Do the sibling map; assume only two threads per processor.
         */
-       for_each_cpu(cpu) {
+       for_each_possible_cpu(cpu) {
                cpu_set(cpu, cpu_sibling_map[cpu]);
                if (cpu_has_feature(CPU_FTR_SMT))
                        cpu_set(cpu ^ 0x1, cpu_sibling_map[cpu]);
@@ -456,3 +462,65 @@ static int __init early_xmon(char *p)
 }
 early_param("xmon", early_xmon);
 #endif
+
+static __init int add_pcspkr(void)
+{
+       struct device_node *np;
+       struct platform_device *pd;
+       int ret;
+
+       np = of_find_compatible_node(NULL, NULL, "pnpPNP,100");
+       of_node_put(np);
+       if (!np)
+               return -ENODEV;
+
+       pd = platform_device_alloc("pcspkr", -1);
+       if (!pd)
+               return -ENOMEM;
+
+       ret = platform_device_add(pd);
+       if (ret)
+               platform_device_put(pd);
+
+       return ret;
+}
+device_initcall(add_pcspkr);
+
+void probe_machine(void)
+{
+       extern struct machdep_calls __machine_desc_start;
+       extern struct machdep_calls __machine_desc_end;
+
+       /*
+        * Iterate all ppc_md structures until we find the proper
+        * one for the current machine type
+        */
+       DBG("Probing machine type ...\n");
+
+       for (machine_id = &__machine_desc_start;
+            machine_id < &__machine_desc_end;
+            machine_id++) {
+               DBG("  %s ...", machine_id->name);
+               memcpy(&ppc_md, machine_id, sizeof(struct machdep_calls));
+               if (ppc_md.probe()) {
+                       DBG(" match !\n");
+                       break;
+               }
+               DBG("\n");
+       }
+       /* What can we do if we didn't find ? */
+       if (machine_id >= &__machine_desc_end) {
+               DBG("No suitable machine found !\n");
+               for (;;);
+       }
+
+       printk(KERN_INFO "Using %s machine description\n", ppc_md.name);
+}
+
+int check_legacy_ioport(unsigned long base_port)
+{
+       if (ppc_md.check_legacy_ioport == NULL)
+               return 0;
+       return ppc_md.check_legacy_ioport(base_port);
+}
+EXPORT_SYMBOL(check_legacy_ioport);