]> err.no Git - linux-2.6/blobdiff - arch/sparc64/kernel/of_device.c
[SPARC64]: Handle PCI bridges without 'ranges' property.
[linux-2.6] / arch / sparc64 / kernel / of_device.c
index 6b8798141f2cb164cb6176fb0d06396dfe2bd3fb..6676b93219dcd51cee5454cb2577854074c4ec80 100644 (file)
@@ -317,6 +317,11 @@ static unsigned int of_bus_default_get_flags(const u32 *addr)
 static int of_bus_pci_match(struct device_node *np)
 {
        if (!strcmp(np->type, "pci") || !strcmp(np->type, "pciex")) {
+               const char *model = of_get_property(np, "model", NULL);
+
+               if (model && !strcmp(model, "SUNW,simba"))
+                       return 0;
+
                /* Do not do PCI specific frobbing if the
                 * PCI bridge lacks a ranges property.  We
                 * want to pass it through up to the next
@@ -332,6 +337,30 @@ static int of_bus_pci_match(struct device_node *np)
        return 0;
 }
 
+static int of_bus_simba_match(struct device_node *np)
+{
+       const char *model = of_get_property(np, "model", NULL);
+
+       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;
+}
+
+static int of_bus_simba_map(u32 *addr, const u32 *range,
+                           int na, int ns, int pna)
+{
+       return 0;
+}
+
 static void of_bus_pci_count_cells(struct device_node *np,
                                   int *addrc, int *sizec)
 {
@@ -436,6 +465,15 @@ static struct of_bus of_busses[] = {
                .map = of_bus_pci_map,
                .get_flags = of_bus_pci_get_flags,
        },
+       /* SIMBA */
+       {
+               .name = "simba",
+               .addr_prop_name = "assigned-addresses",
+               .match = of_bus_simba_match,
+               .count_cells = of_bus_pci_count_cells,
+               .map = of_bus_simba_map,
+               .get_flags = of_bus_pci_get_flags,
+       },
        /* SBUS */
        {
                .name = "sbus",
@@ -508,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.
         */
@@ -531,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;
@@ -567,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",
@@ -730,12 +775,6 @@ static unsigned int __init pci_irq_swizzle(struct device_node *dp,
                 * D: 2-bit slot number, derived from PCI device number as
                 *    (dev - 1) for bus A, or (dev - 2) for bus B
                 * L: 2-bit line number
-                *
-                * Actually, more "portable" way to calculate the funky
-                * slot number is to subtract pbm->pci_first_slot from the
-                * device number, and that's exactly what the pre-OF
-                * sparc64 code did, but we're building this stuff generically
-                * using the OBP tree, not in the PCI controller layer.
                 */
                if (bus & 0x80) {
                        /* PBM-A */
@@ -881,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",