]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/powerpc/platforms/powermac/pci.c
Merge branch 'linux-2.6'
[linux-2.6-omap-h63xx.git] / arch / powerpc / platforms / powermac / pci.c
index 205d04471161eba2709af1a821c6c5d0ea9aac4b..c4af9e21ac9329532ca1bd7735fe336115576cf4 100644 (file)
@@ -48,7 +48,6 @@ static struct pci_controller *u3_ht;
 static int has_second_ohare;
 #endif /* CONFIG_PPC64 */
 
-extern u8 pci_cache_line_size;
 extern int pcibios_assign_bus_offset;
 
 struct device_node *k2_skiplist[2];
@@ -66,16 +65,16 @@ struct device_node *k2_skiplist[2];
 static int __init fixup_one_level_bus_range(struct device_node *node, int higher)
 {
        for (; node != 0;node = node->sibling) {
-               int * bus_range;
-               unsigned int *class_code;
+               const int * bus_range;
+               const unsigned int *class_code;
                int len;
 
                /* For PCI<->PCI bridges or CardBus bridges, we go down */
-               class_code = (unsigned int *) get_property(node, "class-code", NULL);
+               class_code = of_get_property(node, "class-code", NULL);
                if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI &&
                        (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS))
                        continue;
-               bus_range = (int *) get_property(node, "bus-range", &len);
+               bus_range = of_get_property(node, "bus-range", &len);
                if (bus_range != NULL && len > 2 * sizeof(int)) {
                        if (bus_range[1] > higher)
                                higher = bus_range[1];
@@ -93,13 +92,15 @@ static int __init fixup_one_level_bus_range(struct device_node *node, int higher
  */
 static void __init fixup_bus_range(struct device_node *bridge)
 {
-       int * bus_range;
-       int len;
+       int *bus_range, len;
+       struct property *prop;
 
        /* Lookup the "bus-range" property for the hose */
-       bus_range = (int *) get_property(bridge, "bus-range", &len);
-       if (bus_range == NULL || len < 2 * sizeof(int))
+       prop = of_find_property(bridge, "bus-range", &len);
+       if (prop == NULL || prop->length < 2 * sizeof(int))
                return;
+
+       bus_range = prop->value;
        bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]);
 }
 
@@ -237,7 +238,7 @@ static struct pci_ops macrisc_pci_ops =
 static int chaos_validate_dev(struct pci_bus *bus, int devfn, int offset)
 {
        struct device_node *np;
-       u32 *vendor, *device;
+       const u32 *vendor, *device;
 
        if (offset >= 0x100)
                return  PCIBIOS_BAD_REGISTER_NUMBER;
@@ -245,8 +246,8 @@ static int chaos_validate_dev(struct pci_bus *bus, int devfn, int offset)
        if (np == NULL)
                return PCIBIOS_DEVICE_NOT_FOUND;
 
-       vendor = (u32 *)get_property(np, "vendor-id", NULL);
-       device = (u32 *)get_property(np, "device-id", NULL);
+       vendor = of_get_property(np, "vendor-id", NULL);
+       device = of_get_property(np, "device-id", NULL);
        if (vendor == NULL || device == NULL)
                return PCIBIOS_DEVICE_NOT_FOUND;
 
@@ -621,13 +622,14 @@ static void __init init_p2pbridge(void)
 
        /* XXX it would be better here to identify the specific
           PCI-PCI bridge chip we have. */
-       if ((p2pbridge = find_devices("pci-bridge")) == 0
+       p2pbridge = of_find_node_by_name(NULL, "pci-bridge");
+       if (p2pbridge == NULL
            || p2pbridge->parent == NULL
            || strcmp(p2pbridge->parent->name, "pci") != 0)
-               return;
+               goto done;
        if (pci_device_from_OF_node(p2pbridge, &bus, &devfn) < 0) {
                DBG("Can't find PCI infos for PCI<->PCI bridge\n");
-               return;
+               goto done;
        }
        /* Warning: At this point, we have not yet renumbered all busses.
         * So we must use OF walking to find out hose
@@ -635,16 +637,18 @@ static void __init init_p2pbridge(void)
        hose = pci_find_hose_for_OF_device(p2pbridge);
        if (!hose) {
                DBG("Can't find hose for PCI<->PCI bridge\n");
-               return;
+               goto done;
        }
        if (early_read_config_word(hose, bus, devfn,
                                   PCI_BRIDGE_CONTROL, &val) < 0) {
                printk(KERN_ERR "init_p2pbridge: couldn't read bridge"
                       " control\n");
-               return;
+               goto done;
        }
        val &= ~PCI_BRIDGE_CTL_MASTER_ABORT;
        early_write_config_word(hose, bus, devfn, PCI_BRIDGE_CONTROL, val);
+done:
+       of_node_put(p2pbridge);
 }
 
 static void __init init_second_ohare(void)
@@ -686,20 +690,21 @@ static void __init fixup_nec_usb2(void)
 
        for (nec = NULL; (nec = of_find_node_by_name(nec, "usb")) != NULL;) {
                struct pci_controller *hose;
-               u32 data, *prop;
+               u32 data;
+               const u32 *prop;
                u8 bus, devfn;
 
-               prop = (u32 *)get_property(nec, "vendor-id", NULL);
+               prop = of_get_property(nec, "vendor-id", NULL);
                if (prop == NULL)
                        continue;
                if (0x1033 != *prop)
                        continue;
-               prop = (u32 *)get_property(nec, "device-id", NULL);
+               prop = of_get_property(nec, "device-id", NULL);
                if (prop == NULL)
                        continue;
                if (0x0035 != *prop)
                        continue;
-               prop = (u32 *)get_property(nec, "reg", NULL);
+               prop = of_get_property(nec, "reg", NULL);
                if (prop == NULL)
                        continue;
                devfn = (prop[0] >> 8) & 0xff;
@@ -898,7 +903,7 @@ static int __init add_bridge(struct device_node *dev)
        struct pci_controller *hose;
        struct resource rsrc;
        char *disp_name;
-       int *bus_range;
+       const int *bus_range;
        int primary = 1, has_address = 0;
 
        DBG("Adding PCI host bridge %s\n", dev->full_name);
@@ -907,7 +912,7 @@ static int __init add_bridge(struct device_node *dev)
        has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
 
        /* Get bus range if any */
-       bus_range = (int *) get_property(dev, "bus-range", &len);
+       bus_range = of_get_property(dev, "bus-range", &len);
        if (bus_range == NULL || len < 2 * sizeof(int)) {
                printk(KERN_WARNING "Can't get bus-range for %s, assume"
                       " bus 0\n", dev->full_name);
@@ -929,15 +934,15 @@ static int __init add_bridge(struct device_node *dev)
 
        /* 64 bits only bridges */
 #ifdef CONFIG_PPC64
-       if (device_is_compatible(dev, "u3-agp")) {
+       if (of_device_is_compatible(dev, "u3-agp")) {
                setup_u3_agp(hose);
                disp_name = "U3-AGP";
                primary = 0;
-       } else if (device_is_compatible(dev, "u3-ht")) {
+       } else if (of_device_is_compatible(dev, "u3-ht")) {
                setup_u3_ht(hose);
                disp_name = "U3-HT";
                primary = 1;
-       } else if (device_is_compatible(dev, "u4-pcie")) {
+       } else if (of_device_is_compatible(dev, "u4-pcie")) {
                setup_u4_pcie(hose);
                disp_name = "U4-PCIE";
                primary = 0;
@@ -948,7 +953,7 @@ static int __init add_bridge(struct device_node *dev)
 
        /* 32 bits only bridges */
 #ifdef CONFIG_PPC32
-       if (device_is_compatible(dev, "uni-north")) {
+       if (of_device_is_compatible(dev, "uni-north")) {
                primary = setup_uninorth(hose, &rsrc);
                disp_name = "UniNorth";
        } else if (strcmp(dev->name, "pci") == 0) {
@@ -982,30 +987,23 @@ static int __init add_bridge(struct device_node *dev)
        return 0;
 }
 
-void __init pmac_pcibios_fixup(void)
+void __devinit pmac_pci_irq_fixup(struct pci_dev *dev)
 {
-       struct pci_dev* dev = NULL;
-
-       for_each_pci_dev(dev) {
-               /* Read interrupt from the device-tree */
-               pci_read_irq_line(dev);
-
 #ifdef CONFIG_PPC32
-               /* Fixup interrupt for the modem/ethernet combo controller.
-                * on machines with a second ohare chip.
-                * The number in the device tree (27) is bogus (correct for
-                * the ethernet-only board but not the combo ethernet/modem
-                * board). The real interrupt is 28 on the second controller
-                * -> 28+32 = 60.
-                */
-               if (has_second_ohare &&
-                   dev->vendor == PCI_VENDOR_ID_DEC &&
-                   dev->device == PCI_DEVICE_ID_DEC_TULIP_PLUS) {
-                       dev->irq = irq_create_mapping(NULL, 60);
-                       set_irq_type(dev->irq, IRQ_TYPE_LEVEL_LOW);
-               }
-#endif /* CONFIG_PPC32 */
+       /* Fixup interrupt for the modem/ethernet combo controller.
+        * on machines with a second ohare chip.
+        * The number in the device tree (27) is bogus (correct for
+        * the ethernet-only board but not the combo ethernet/modem
+        * board). The real interrupt is 28 on the second controller
+        * -> 28+32 = 60.
+        */
+       if (has_second_ohare &&
+           dev->vendor == PCI_VENDOR_ID_DEC &&
+           dev->device == PCI_DEVICE_ID_DEC_TULIP_PLUS) {
+               dev->irq = irq_create_mapping(NULL, 60);
+               set_irq_type(dev->irq, IRQ_TYPE_LEVEL_LOW);
        }
+#endif /* CONFIG_PPC32 */
 }
 
 #ifdef CONFIG_PPC64
@@ -1131,21 +1129,21 @@ pmac_pci_enable_device_hook(struct pci_dev *dev, int initial)
                return 0;
 
        uninorth_child = node->parent &&
-               device_is_compatible(node->parent, "uni-north");
+               of_device_is_compatible(node->parent, "uni-north");
 
        /* Firewire & GMAC were disabled after PCI probe, the driver is
         * claiming them, we must re-enable them now.
         */
        if (uninorth_child && !strcmp(node->name, "firewire") &&
-           (device_is_compatible(node, "pci106b,18") ||
-            device_is_compatible(node, "pci106b,30") ||
-            device_is_compatible(node, "pci11c1,5811"))) {
+           (of_device_is_compatible(node, "pci106b,18") ||
+            of_device_is_compatible(node, "pci106b,30") ||
+            of_device_is_compatible(node, "pci11c1,5811"))) {
                pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, node, 0, 1);
                pmac_call_feature(PMAC_FTR_1394_ENABLE, node, 0, 1);
                updatecfg = 1;
        }
        if (uninorth_child && !strcmp(node->name, "ethernet") &&
-           device_is_compatible(node, "gmac")) {
+           of_device_is_compatible(node, "gmac")) {
                pmac_call_feature(PMAC_FTR_GMAC_ENABLE, node, 0, 1);
                updatecfg = 1;
        }
@@ -1196,29 +1194,30 @@ void __init pmac_pcibios_after_init(void)
         * -- BenH
         */
        for_each_pci_dev(dev) {
-               if ((dev->class >> 16) == PCI_BASE_CLASS_STORAGE)
-                       pci_enable_device(dev);
+               if ((dev->class >> 16) != PCI_BASE_CLASS_STORAGE)
+                       continue;
+               if (pci_enable_device(dev))
+                       printk(KERN_WARNING
+                              "pci: Failed to enable %s\n", pci_name(dev));
        }
 #endif /* CONFIG_BLK_DEV_IDE */
 
-       nd = find_devices("firewire");
-       while (nd) {
-               if (nd->parent && (device_is_compatible(nd, "pci106b,18") ||
-                                  device_is_compatible(nd, "pci106b,30") ||
-                                  device_is_compatible(nd, "pci11c1,5811"))
-                   && device_is_compatible(nd->parent, "uni-north")) {
+       for_each_node_by_name(nd, "firewire") {
+               if (nd->parent && (of_device_is_compatible(nd, "pci106b,18") ||
+                                  of_device_is_compatible(nd, "pci106b,30") ||
+                                  of_device_is_compatible(nd, "pci11c1,5811"))
+                   && of_device_is_compatible(nd->parent, "uni-north")) {
                        pmac_call_feature(PMAC_FTR_1394_ENABLE, nd, 0, 0);
                        pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, nd, 0, 0);
                }
-               nd = nd->next;
        }
-       nd = find_devices("ethernet");
-       while (nd) {
-               if (nd->parent && device_is_compatible(nd, "gmac")
-                   && device_is_compatible(nd->parent, "uni-north"))
+       of_node_put(nd);
+       for_each_node_by_name(nd, "ethernet") {
+               if (nd->parent && of_device_is_compatible(nd, "gmac")
+                   && of_device_is_compatible(nd->parent, "uni-north"))
                        pmac_call_feature(PMAC_FTR_GMAC_ENABLE, nd, 0, 0);
-               nd = nd->next;
        }
+       of_node_put(nd);
 }
 
 #ifdef CONFIG_PPC32