]> 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 f42475b27c153c324f150d9e4ff3a352c4cafba3..c4af9e21ac9329532ca1bd7735fe336115576cf4 100644 (file)
@@ -70,11 +70,11 @@ static int __init fixup_one_level_bus_range(struct device_node *node, int higher
                int len;
 
                /* For PCI<->PCI bridges or CardBus bridges, we go down */
-               class_code = 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 = 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];
@@ -100,7 +100,7 @@ static void __init fixup_bus_range(struct device_node *bridge)
        if (prop == NULL || prop->length < 2 * sizeof(int))
                return;
 
-       bus_range = (int *)prop->value;
+       bus_range = prop->value;
        bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]);
 }
 
@@ -246,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 = get_property(np, "vendor-id", NULL);
-       device = 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;
 
@@ -622,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
@@ -636,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)
@@ -691,17 +694,17 @@ static void __init fixup_nec_usb2(void)
                const u32 *prop;
                u8 bus, devfn;
 
-               prop = get_property(nec, "vendor-id", NULL);
+               prop = of_get_property(nec, "vendor-id", NULL);
                if (prop == NULL)
                        continue;
                if (0x1033 != *prop)
                        continue;
-               prop = get_property(nec, "device-id", NULL);
+               prop = of_get_property(nec, "device-id", NULL);
                if (prop == NULL)
                        continue;
                if (0x0035 != *prop)
                        continue;
-               prop = get_property(nec, "reg", NULL);
+               prop = of_get_property(nec, "reg", NULL);
                if (prop == NULL)
                        continue;
                devfn = (prop[0] >> 8) & 0xff;
@@ -909,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 = 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);
@@ -931,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;
@@ -950,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) {
@@ -1126,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;
        }
@@ -1191,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