aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/pci-common.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2008-10-27 15:48:29 -0400
committerPaul Mackerras <paulus@samba.org>2008-11-05 06:11:53 -0500
commit53280323350621985b3f2f8ffe649215304bcc5f (patch)
treeec4c126dd620ecb1b36f67fc4201e24fcca6ab18 /arch/powerpc/kernel/pci-common.c
parentb0494bc8ee449f0534afa92a51e2e3bb27bab69b (diff)
powerpc/pci: Use common PHB resource hookup
The 32-bit and 64-bit powerpc PCI code used to set up the resource pointers of the root bus of a given PHB in completely different places. This unifies this in large part, by making 32-bit use a routine very similar to what 64-bit does when initially scanning the PCI busses. The actual setup of the PHB resources itself is then moved to a common function in pci-common.c. This should cause no functional change on 64-bit. On 32-bit, the effect is that the PHB resources are going to be setup a bit earlier, instead of being setup from pcibios_fixup_bus(). Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel/pci-common.c')
-rw-r--r--arch/powerpc/kernel/pci-common.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 09ac98e2a502..6d46bfabdbe4 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1421,3 +1421,61 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
1421 1421
1422 return pci_enable_resources(dev, mask); 1422 return pci_enable_resources(dev, mask);
1423} 1423}
1424
1425void __devinit pcibios_setup_phb_resources(struct pci_controller *hose)
1426{
1427 struct pci_bus *bus = hose->bus;
1428 struct resource *res;
1429 int i;
1430
1431 /* Hookup PHB IO resource */
1432 bus->resource[0] = res = &hose->io_resource;
1433
1434 if (!res->flags) {
1435 printk(KERN_WARNING "PCI: I/O resource not set for host"
1436 " bridge %s (domain %d)\n",
1437 hose->dn->full_name, hose->global_number);
1438#ifdef CONFIG_PPC32
1439 /* Workaround for lack of IO resource only on 32-bit */
1440 res->start = (unsigned long)hose->io_base_virt - isa_io_base;
1441 res->end = res->start + IO_SPACE_LIMIT;
1442 res->flags = IORESOURCE_IO;
1443#endif /* CONFIG_PPC32 */
1444 }
1445
1446 pr_debug("PCI: PHB IO resource = %016llx-%016llx [%lx]\n",
1447 (unsigned long long)res->start,
1448 (unsigned long long)res->end,
1449 (unsigned long)res->flags);
1450
1451 /* Hookup PHB Memory resources */
1452 for (i = 0; i < 3; ++i) {
1453 res = &hose->mem_resources[i];
1454 if (!res->flags) {
1455 if (i > 0)
1456 continue;
1457 printk(KERN_ERR "PCI: Memory resource 0 not set for "
1458 "host bridge %s (domain %d)\n",
1459 hose->dn->full_name, hose->global_number);
1460#ifdef CONFIG_PPC32
1461 /* Workaround for lack of MEM resource only on 32-bit */
1462 res->start = hose->pci_mem_offset;
1463 res->end = (resource_size_t)-1LL;
1464 res->flags = IORESOURCE_MEM;
1465#endif /* CONFIG_PPC32 */
1466 }
1467 bus->resource[i+1] = res;
1468
1469 pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n", i,
1470 (unsigned long long)res->start,
1471 (unsigned long long)res->end,
1472 (unsigned long)res->flags);
1473 }
1474
1475 pr_debug("PCI: PHB MEM offset = %016llx\n",
1476 (unsigned long long)hose->pci_mem_offset);
1477 pr_debug("PCI: PHB IO offset = %08lx\n",
1478 (unsigned long)hose->io_base_virt - _IO_BASE);
1479
1480}
1481