[POWERPC] Generic check_legacy_ioport
[safe/jmp/linux-2.6] / arch / powerpc / kernel / setup-common.c
index c607f3b..3708037 100644 (file)
@@ -12,7 +12,6 @@
 
 #undef DEBUG
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/string.h>
 #include <linux/sched.h>
 #include <linux/reboot.h>
 #include <linux/delay.h>
 #include <linux/initrd.h>
-#include <linux/ide.h>
+#include <linux/platform_device.h>
 #include <linux/seq_file.h>
 #include <linux/ioport.h>
 #include <linux/console.h>
 #include <linux/utsname.h>
-#include <linux/tty.h>
+#include <linux/screen_info.h>
 #include <linux/root_dev.h>
 #include <linux/notifier.h>
 #include <linux/cpu.h>
@@ -304,24 +303,8 @@ struct seq_operations cpuinfo_op = {
 void __init check_for_initrd(void)
 {
 #ifdef CONFIG_BLK_DEV_INITRD
-       unsigned long *prop;
-
-       DBG(" -> check_for_initrd()\n");
-
-       if (of_chosen) {
-               prop = (unsigned long *)get_property(of_chosen,
-                               "linux,initrd-start", NULL);
-               if (prop != NULL) {
-                       initrd_start = (unsigned long)__va(*prop);
-                       prop = (unsigned long *)get_property(of_chosen,
-                                       "linux,initrd-end", NULL);
-                       if (prop != NULL) {
-                               initrd_end = (unsigned long)__va(*prop);
-                               initrd_below_start_ok = 1;
-                       } else
-                               initrd_start = 0;
-               }
-       }
+       DBG(" -> check_for_initrd()  initrd_start=0x%lx  initrd_end=0x%lx\n",
+           initrd_start, initrd_end);
 
        /* If we were passed an initrd, set the ROOT_DEV properly if the values
         * look sensible. If not, clear initrd reference.
@@ -366,15 +349,15 @@ void __init smp_setup_cpu_maps(void)
        int cpu = 0;
 
        while ((dn = of_find_node_by_type(dn, "cpu")) && cpu < NR_CPUS) {
-               int *intserv;
+               const int *intserv;
                int j, len = sizeof(u32), nthreads = 1;
 
-               intserv = (int *)get_property(dn, "ibm,ppc-interrupt-server#s",
-                                             &len);
+               intserv = of_get_property(dn, "ibm,ppc-interrupt-server#s",
+                               &len);
                if (intserv)
                        nthreads = len / sizeof(int);
                else {
-                       intserv = (int *) get_property(dn, "reg", NULL);
+                       intserv = of_get_property(dn, "reg", NULL);
                        if (!intserv)
                                intserv = &cpu; /* assume logical == phys */
                }
@@ -395,13 +378,12 @@ void __init smp_setup_cpu_maps(void)
        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;
+               const unsigned int *ireg;
 
-               num_addr_cell = prom_n_addr_cells(dn);
-               num_size_cell = prom_n_size_cells(dn);
+               num_addr_cell = of_n_addr_cells(dn);
+               num_size_cell = of_n_size_cells(dn);
 
-               ireg = (unsigned int *)
-                       get_property(dn, "ibm,lrdr-capacity", NULL);
+               ireg = of_get_property(dn, "ibm,lrdr-capacity", NULL);
 
                if (!ireg)
                        goto out;
@@ -442,25 +424,28 @@ void __init smp_setup_cpu_maps(void)
 }
 #endif /* CONFIG_SMP */
 
-#ifdef CONFIG_XMON
-static int __init early_xmon(char *p)
+static __init int add_pcspkr(void)
 {
-       /* ensure xmon is enabled */
-       if (p) {
-               if (strncmp(p, "on", 2) == 0)
-                       xmon_init(1);
-               if (strncmp(p, "off", 3) == 0)
-                       xmon_init(0);
-               if (strncmp(p, "early", 5) != 0)
-                       return 0;
-       }
-       xmon_init(1);
-       debugger(NULL);
+       struct device_node *np;
+       struct platform_device *pd;
+       int ret;
 
-       return 0;
+       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;
 }
-early_param("xmon", early_xmon);
-#endif
+device_initcall(add_pcspkr);
 
 void probe_machine(void)
 {
@@ -492,3 +477,56 @@ void probe_machine(void)
 
        printk(KERN_INFO "Using %s machine description\n", ppc_md.name);
 }
+
+/* Match a class of boards, not a specific device configuration. */
+int check_legacy_ioport(unsigned long base_port)
+{
+       struct device_node *parent, *np = NULL;
+       int ret = -ENODEV;
+
+       switch(base_port) {
+       case I8042_DATA_REG:
+               np = of_find_node_by_type(NULL, "8042");
+               break;
+       case FDC_BASE: /* FDC1 */
+               np = of_find_node_by_type(NULL, "fdc");
+               break;
+#ifdef CONFIG_PPC_PREP
+       case _PIDXR:
+       case _PNPWRP:
+       case PNPBIOS_BASE:
+               /* implement me */
+#endif
+       default:
+               /* ipmi is supposed to fail here */
+               break;
+       }
+       if (!np)
+               return ret;
+       parent = of_get_parent(np);
+       if (parent) {
+               if (strcmp(parent->type, "isa") == 0)
+                       ret = 0;
+               of_node_put(parent);
+       }
+       of_node_put(np);
+       return ret;
+}
+EXPORT_SYMBOL(check_legacy_ioport);
+
+static int ppc_panic_event(struct notifier_block *this,
+                             unsigned long event, void *ptr)
+{
+       ppc_md.panic(ptr);  /* May not return */
+       return NOTIFY_DONE;
+}
+
+static struct notifier_block ppc_panic_block = {
+       .notifier_call = ppc_panic_event,
+       .priority = INT_MIN /* may not return; must be done last */
+};
+
+void __init setup_panic(void)
+{
+       atomic_notifier_chain_register(&panic_notifier_list, &ppc_panic_block);
+}