[POWERPC] Generic check_legacy_ioport
[safe/jmp/linux-2.6] / arch / powerpc / kernel / setup-common.c
index d050d9a..3708037 100644 (file)
@@ -21,7 +21,6 @@
 #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>
 #include <linux/console.h>
@@ -353,11 +352,12 @@ void __init smp_setup_cpu_maps(void)
                const int *intserv;
                int j, len = sizeof(u32), nthreads = 1;
 
-               intserv = 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 = get_property(dn, "reg", NULL);
+                       intserv = of_get_property(dn, "reg", NULL);
                        if (!intserv)
                                intserv = &cpu; /* assume logical == phys */
                }
@@ -380,10 +380,10 @@ void __init smp_setup_cpu_maps(void)
                int num_addr_cell, num_size_cell, maxcpus;
                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 = get_property(dn, "ibm,lrdr-capacity", NULL);
+               ireg = of_get_property(dn, "ibm,lrdr-capacity", NULL);
 
                if (!ireg)
                        goto out;
@@ -478,11 +478,39 @@ 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)
 {
-       if (ppc_md.check_legacy_ioport == NULL)
-               return 0;
-       return ppc_md.check_legacy_ioport(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);