[SPARC64]: Handle PCI bridges without 'ranges' property.
[sfrench/cifs-2.6.git] / arch / sparc64 / kernel / of_device.c
index 9ac9a307999ade4a2d56e609d12fca3bcf6008cc..6676b93219dcd51cee5454cb2577854074c4ec80 100644 (file)
@@ -343,6 +343,15 @@ static int of_bus_simba_match(struct device_node *np)
 
        if (model && !strcmp(model, "SUNW,simba"))
                return 1;
+
+       /* Treat PCI busses lacking ranges property just like
+        * simba.
+        */
+       if (!strcmp(np->type, "pci") || !strcmp(np->type, "pciex")) {
+               if (!of_find_property(np, "ranges", NULL))
+                       return 1;
+       }
+
        return 0;
 }
 
@@ -537,13 +546,18 @@ static int __init build_one_resource(struct device_node *parent,
                        return 0;
        }
 
+       /* When we miss an I/O space match on PCI, just pass it up
+        * to the next PCI bridge and/or controller.
+        */
+       if (!strcmp(bus->name, "pci") &&
+           (addr[0] & 0x03000000) == 0x01000000)
+               return 0;
+
        return 1;
 }
 
 static int __init use_1to1_mapping(struct device_node *pp)
 {
-       const char *model;
-
        /* If this is on the PMU bus, don't try to translate it even
         * if a ranges property exists.
         */
@@ -560,9 +574,11 @@ static int __init use_1to1_mapping(struct device_node *pp)
        if (!strcmp(pp->name, "dma"))
                return 0;
 
-       /* Similarly for Simba PCI bridges.  */
-       model = of_get_property(pp, "model", NULL);
-       if (model && !strcmp(model, "SUNW,simba"))
+       /* Similarly for all PCI bridges, if we get this far
+        * it lacks a ranges property, and this will include
+        * cases like Simba.
+        */
+       if (!strcmp(pp->type, "pci") || !strcmp(pp->type, "pciex"))
                return 0;
 
        return 1;
@@ -596,7 +612,7 @@ static void __init build_device_resources(struct of_device *op,
        /* Convert to num-entries.  */
        num_reg /= na + ns;
 
-       /* Prevent overruning the op->resources[] array.  */
+       /* Prevent overrunning the op->resources[] array.  */
        if (num_reg > PROMREG_MAX) {
                printk(KERN_WARNING "%s: Too many regs (%d), "
                       "limiting to %d.\n",
@@ -904,7 +920,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
                op->num_irqs = 0;
        }
 
-       /* Prevent overruning the op->irqs[] array.  */
+       /* Prevent overrunning the op->irqs[] array.  */
        if (op->num_irqs > PROMINTR_MAX) {
                printk(KERN_WARNING "%s: Too many irqs (%d), "
                       "limiting to %d.\n",