Merge branch 'merge'
[safe/jmp/linux-2.6] / arch / powerpc / platforms / maple / pci.c
index 895aeb3..dc05af5 100644 (file)
@@ -38,16 +38,16 @@ static struct pci_controller *u3_agp, *u3_ht;
 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 = 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 = get_property(node, "bus-range", &len);
                if (bus_range != NULL && len > 2 * sizeof(int)) {
                        if (bus_range[1] > higher)
                                higher = bus_range[1];
@@ -65,16 +65,18 @@ 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 *bus_range;
+       struct property *prop;
        int len;
 
        /* 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->value == NULL || len < 2 * sizeof(int)) {
                printk(KERN_WARNING "Can't get bus-range for %s\n",
                               bridge->full_name);
                return;
        }
+       bus_range = (int *)prop->value;
        bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]);
 }
 
@@ -314,38 +316,23 @@ static int __init add_bridge(struct device_node *dev)
        int len;
        struct pci_controller *hose;
        char* disp_name;
-       int *bus_range;
+       const int *bus_range;
        int primary = 1;
-       struct property *of_prop;
 
        DBG("Adding PCI host bridge %s\n", dev->full_name);
 
-       bus_range = (int *) get_property(dev, "bus-range", &len);
+       bus_range = 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);
        }
 
-       hose = alloc_bootmem(sizeof(struct pci_controller));
+       hose = pcibios_alloc_controller(dev);
        if (hose == NULL)
                return -ENOMEM;
-       pci_setup_pci_controller(hose);
-
-       hose->arch_data = dev;
        hose->first_busno = bus_range ? bus_range[0] : 0;
        hose->last_busno = bus_range ? bus_range[1] : 0xff;
 
-       of_prop = alloc_bootmem(sizeof(struct property) +
-                               sizeof(hose->global_number));
-       if (of_prop) {
-               memset(of_prop, 0, sizeof(struct property));
-               of_prop->name = "linux,pci-domain";
-               of_prop->length = sizeof(hose->global_number);
-               of_prop->value = (unsigned char *)&of_prop[1];
-               memcpy(of_prop->value, &hose->global_number, sizeof(hose->global_number));
-               prom_add_property(dev, of_prop);
-       }
-
        disp_name = NULL;
        if (device_is_compatible(dev, "u3-agp")) {
                setup_u3_agp(hose);
@@ -391,9 +378,10 @@ static void __init maple_fixup_phb_resources(void)
                unsigned long offset = (unsigned long)hose->io_base_virt - pci_io_base;
                hose->io_resource.start += offset;
                hose->io_resource.end += offset;
-               printk(KERN_INFO "PCI Host %d, io start: %lx; io end: %lx\n",
+               printk(KERN_INFO "PCI Host %d, io start: %llx; io end: %llx\n",
                       hose->global_number,
-                      hose->io_resource.start, hose->io_resource.end);
+                      (unsigned long long)hose->io_resource.start,
+                      (unsigned long long)hose->io_resource.end);
        }
 }
 
@@ -450,28 +438,30 @@ void __init maple_pci_init(void)
                        PCI_DN(np)->busno = 0xf0;
        }
 
-       /* Tell pci.c to use the common resource allocation mecanism */
-       pci_probe_only = 0;
-       
-       /* Allow all IO */
-       io_page_mask = -1;
+       /* Tell pci.c to not change any resource allocations.  */
+       pci_probe_only = 1;
 }
 
 int maple_pci_get_legacy_ide_irq(struct pci_dev *pdev, int channel)
 {
        struct device_node *np;
-       int irq = channel ? 15 : 14;
+       unsigned int defirq = channel ? 15 : 14;
+       unsigned int irq;
 
        if (pdev->vendor != PCI_VENDOR_ID_AMD ||
            pdev->device != PCI_DEVICE_ID_AMD_8111_IDE)
-               return irq;
+               return defirq;
 
        np = pci_device_to_OF_node(pdev);
        if (np == NULL)
-               return irq;
-       if (np->n_intrs < 2)
-               return irq;
-       return np->intrs[channel & 0x1].line;
+               return defirq;
+       irq = irq_of_parse_and_map(np, channel & 0x1);
+       if (irq == NO_IRQ) {
+               printk("Failed to map onboard IDE interrupt for channel %d\n",
+                      channel);
+               return defirq;
+       }
+       return irq;
 }
 
 /* XXX: To remove once all firmwares are ok */