pci-common.c (10ce3cc919f50c2043b41ca968b43c26a3672600) pci-common.c (38973ba7903fa0660a31b2bdc50ff711ec8d08c9)
1/*
2 * Contains common pci routines for ALL ppc platform
3 * (based on pci_32.c and pci_64.c)
4 *
5 * Port for PPC64 David Engebretsen, IBM Corp.
6 * Contains common pci routines for ppc64 platform, pSeries and iSeries brands.
7 *
8 * Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM

--- 36 unchanged lines hidden (view full) ---

45LIST_HEAD(hose_list);
46
47/* XXX kill that some day ... */
48static int global_phb_number; /* Global phb counter */
49
50/* ISA Memory physical address */
51resource_size_t isa_mem_base;
52
1/*
2 * Contains common pci routines for ALL ppc platform
3 * (based on pci_32.c and pci_64.c)
4 *
5 * Port for PPC64 David Engebretsen, IBM Corp.
6 * Contains common pci routines for ppc64 platform, pSeries and iSeries brands.
7 *
8 * Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM

--- 36 unchanged lines hidden (view full) ---

45LIST_HEAD(hose_list);
46
47/* XXX kill that some day ... */
48static int global_phb_number; /* Global phb counter */
49
50/* ISA Memory physical address */
51resource_size_t isa_mem_base;
52
53/* Default PCI flags is 0 on ppc32, modified at boot on ppc64 */
54unsigned int pci_flags = 0;
55
53
56
57static struct dma_map_ops *pci_dma_ops = &dma_direct_ops;
58
59void set_pci_dma_ops(struct dma_map_ops *dma_ops)
60{
61 pci_dma_ops = dma_ops;
62}
63
64struct dma_map_ops *get_pci_dma_ops(void)

--- 779 unchanged lines hidden (view full) ---

844
845 if (!pci_has_flag(PCI_ENABLE_PROC_DOMAINS))
846 return 0;
847 if (pci_has_flag(PCI_COMPAT_DOMAIN_0))
848 return hose->global_number != 0;
849 return 1;
850}
851
54static struct dma_map_ops *pci_dma_ops = &dma_direct_ops;
55
56void set_pci_dma_ops(struct dma_map_ops *dma_ops)
57{
58 pci_dma_ops = dma_ops;
59}
60
61struct dma_map_ops *get_pci_dma_ops(void)

--- 779 unchanged lines hidden (view full) ---

841
842 if (!pci_has_flag(PCI_ENABLE_PROC_DOMAINS))
843 return 0;
844 if (pci_has_flag(PCI_COMPAT_DOMAIN_0))
845 return hose->global_number != 0;
846 return 1;
847}
848
852void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
853 struct resource *res)
854{
855 resource_size_t offset = 0, mask = (resource_size_t)-1;
856 struct pci_controller *hose = pci_bus_to_host(dev->bus);
857
858 if (!hose)
859 return;
860 if (res->flags & IORESOURCE_IO) {
861 offset = (unsigned long)hose->io_base_virt - _IO_BASE;
862 mask = 0xffffffffu;
863 } else if (res->flags & IORESOURCE_MEM)
864 offset = hose->pci_mem_offset;
865
866 region->start = (res->start - offset) & mask;
867 region->end = (res->end - offset) & mask;
868}
869EXPORT_SYMBOL(pcibios_resource_to_bus);
870
871void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
872 struct pci_bus_region *region)
873{
874 resource_size_t offset = 0, mask = (resource_size_t)-1;
875 struct pci_controller *hose = pci_bus_to_host(dev->bus);
876
877 if (!hose)
878 return;
879 if (res->flags & IORESOURCE_IO) {
880 offset = (unsigned long)hose->io_base_virt - _IO_BASE;
881 mask = 0xffffffffu;
882 } else if (res->flags & IORESOURCE_MEM)
883 offset = hose->pci_mem_offset;
884 res->start = (region->start + offset) & mask;
885 res->end = (region->end + offset) & mask;
886}
887EXPORT_SYMBOL(pcibios_bus_to_resource);
888
889/* Fixup a bus resource into a linux resource */
890static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev)
891{
892 struct pci_controller *hose = pci_bus_to_host(dev->bus);
893 resource_size_t offset = 0, mask = (resource_size_t)-1;
894
895 if (res->flags & IORESOURCE_IO) {
896 offset = (unsigned long)hose->io_base_virt - _IO_BASE;
897 mask = 0xffffffffu;
898 } else if (res->flags & IORESOURCE_MEM)
899 offset = hose->pci_mem_offset;
900
901 res->start = (res->start + offset) & mask;
902 res->end = (res->end + offset) & mask;
903}
904
905
906/* This header fixup will do the resource fixup for all devices as they are
907 * probed, but not for bridge ranges
908 */
909static void __devinit pcibios_fixup_resources(struct pci_dev *dev)
910{
911 struct pci_controller *hose = pci_bus_to_host(dev->bus);
912 int i;
913

--- 23 unchanged lines hidden (view full) ---

937 (unsigned long long)res->end,
938 (unsigned int)res->flags);
939 res->end -= res->start;
940 res->start = 0;
941 res->flags |= IORESOURCE_UNSET;
942 continue;
943 }
944
849/* This header fixup will do the resource fixup for all devices as they are
850 * probed, but not for bridge ranges
851 */
852static void __devinit pcibios_fixup_resources(struct pci_dev *dev)
853{
854 struct pci_controller *hose = pci_bus_to_host(dev->bus);
855 int i;
856

--- 23 unchanged lines hidden (view full) ---

880 (unsigned long long)res->end,
881 (unsigned int)res->flags);
882 res->end -= res->start;
883 res->start = 0;
884 res->flags |= IORESOURCE_UNSET;
885 continue;
886 }
887
945 pr_debug("PCI:%s Resource %d %016llx-%016llx [%x] fixup...\n",
888 pr_debug("PCI:%s Resource %d %016llx-%016llx [%x]\n",
946 pci_name(dev), i,
947 (unsigned long long)res->start,\
948 (unsigned long long)res->end,
949 (unsigned int)res->flags);
889 pci_name(dev), i,
890 (unsigned long long)res->start,\
891 (unsigned long long)res->end,
892 (unsigned int)res->flags);
950
951 fixup_resource(res, dev);
952
953 pr_debug("PCI:%s %016llx-%016llx\n",
954 pci_name(dev),
955 (unsigned long long)res->start,
956 (unsigned long long)res->end);
957 }
958
959 /* Call machine specific resource fixup */
960 if (ppc_md.pcibios_fixup_resources)
961 ppc_md.pcibios_fixup_resources(dev);
962}
963DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_resources);
964

--- 85 unchanged lines hidden (view full) ---

1050 */
1051 if (pci_has_flag(PCI_REASSIGN_ALL_RSRC)) {
1052 res->flags |= IORESOURCE_UNSET;
1053 res->end -= res->start;
1054 res->start = 0;
1055 continue;
1056 }
1057
893 }
894
895 /* Call machine specific resource fixup */
896 if (ppc_md.pcibios_fixup_resources)
897 ppc_md.pcibios_fixup_resources(dev);
898}
899DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_resources);
900

--- 85 unchanged lines hidden (view full) ---

986 */
987 if (pci_has_flag(PCI_REASSIGN_ALL_RSRC)) {
988 res->flags |= IORESOURCE_UNSET;
989 res->end -= res->start;
990 res->start = 0;
991 continue;
992 }
993
1058 pr_debug("PCI:%s Bus rsrc %d %016llx-%016llx [%x] fixup...\n",
994 pr_debug("PCI:%s Bus rsrc %d %016llx-%016llx [%x]\n",
1059 pci_name(dev), i,
1060 (unsigned long long)res->start,\
1061 (unsigned long long)res->end,
1062 (unsigned int)res->flags);
1063
995 pci_name(dev), i,
996 (unsigned long long)res->start,\
997 (unsigned long long)res->end,
998 (unsigned int)res->flags);
999
1064 /* Perform fixup */
1065 fixup_resource(res, dev);
1066
1067 /* Try to detect uninitialized P2P bridge resources,
1068 * and clear them out so they get re-assigned later
1069 */
1070 if (pcibios_uninitialized_bridge_resource(bus, res)) {
1071 res->flags = 0;
1072 pr_debug("PCI:%s (unassigned)\n", pci_name(dev));
1000 /* Try to detect uninitialized P2P bridge resources,
1001 * and clear them out so they get re-assigned later
1002 */
1003 if (pcibios_uninitialized_bridge_resource(bus, res)) {
1004 res->flags = 0;
1005 pr_debug("PCI:%s (unassigned)\n", pci_name(dev));
1073 } else {
1074
1075 pr_debug("PCI:%s %016llx-%016llx\n",
1076 pci_name(dev),
1077 (unsigned long long)res->start,
1078 (unsigned long long)res->end);
1079 }
1080 }
1081}
1082
1083void __devinit pcibios_setup_bus_self(struct pci_bus *bus)
1084{
1085 /* Fix up the bus resources for P2P bridges */
1086 if (bus->self != NULL)

--- 473 unchanged lines hidden (view full) ---

1560{
1561 if (ppc_md.pcibios_enable_device_hook)
1562 if (ppc_md.pcibios_enable_device_hook(dev))
1563 return -EINVAL;
1564
1565 return pci_enable_resources(dev, mask);
1566}
1567
1006 }
1007 }
1008}
1009
1010void __devinit pcibios_setup_bus_self(struct pci_bus *bus)
1011{
1012 /* Fix up the bus resources for P2P bridges */
1013 if (bus->self != NULL)

--- 473 unchanged lines hidden (view full) ---

1487{
1488 if (ppc_md.pcibios_enable_device_hook)
1489 if (ppc_md.pcibios_enable_device_hook(dev))
1490 return -EINVAL;
1491
1492 return pci_enable_resources(dev, mask);
1493}
1494
1495resource_size_t pcibios_io_space_offset(struct pci_controller *hose)
1496{
1497 return (unsigned long) hose->io_base_virt - _IO_BASE;
1498}
1499
1568static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources)
1569{
1570 struct resource *res;
1571 int i;
1572
1573 /* Hookup PHB IO resource */
1574 res = &hose->io_resource;
1575

--- 8 unchanged lines hidden (view full) ---

1584 res->flags = IORESOURCE_IO;
1585#endif /* CONFIG_PPC32 */
1586 }
1587
1588 pr_debug("PCI: PHB IO resource = %016llx-%016llx [%lx]\n",
1589 (unsigned long long)res->start,
1590 (unsigned long long)res->end,
1591 (unsigned long)res->flags);
1500static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources)
1501{
1502 struct resource *res;
1503 int i;
1504
1505 /* Hookup PHB IO resource */
1506 res = &hose->io_resource;
1507

--- 8 unchanged lines hidden (view full) ---

1516 res->flags = IORESOURCE_IO;
1517#endif /* CONFIG_PPC32 */
1518 }
1519
1520 pr_debug("PCI: PHB IO resource = %016llx-%016llx [%lx]\n",
1521 (unsigned long long)res->start,
1522 (unsigned long long)res->end,
1523 (unsigned long)res->flags);
1592 pci_add_resource(resources, res);
1524 pci_add_resource_offset(resources, res, pcibios_io_space_offset(hose));
1593
1594 /* Hookup PHB Memory resources */
1595 for (i = 0; i < 3; ++i) {
1596 res = &hose->mem_resources[i];
1597 if (!res->flags) {
1598 if (i > 0)
1599 continue;
1600 printk(KERN_ERR "PCI: Memory resource 0 not set for "

--- 6 unchanged lines hidden (view full) ---

1607 res->flags = IORESOURCE_MEM;
1608#endif /* CONFIG_PPC32 */
1609 }
1610
1611 pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n", i,
1612 (unsigned long long)res->start,
1613 (unsigned long long)res->end,
1614 (unsigned long)res->flags);
1525
1526 /* Hookup PHB Memory resources */
1527 for (i = 0; i < 3; ++i) {
1528 res = &hose->mem_resources[i];
1529 if (!res->flags) {
1530 if (i > 0)
1531 continue;
1532 printk(KERN_ERR "PCI: Memory resource 0 not set for "

--- 6 unchanged lines hidden (view full) ---

1539 res->flags = IORESOURCE_MEM;
1540#endif /* CONFIG_PPC32 */
1541 }
1542
1543 pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n", i,
1544 (unsigned long long)res->start,
1545 (unsigned long long)res->end,
1546 (unsigned long)res->flags);
1615 pci_add_resource(resources, res);
1547 pci_add_resource_offset(resources, res, hose->pci_mem_offset);
1616 }
1617
1618 pr_debug("PCI: PHB MEM offset = %016llx\n",
1619 (unsigned long long)hose->pci_mem_offset);
1620 pr_debug("PCI: PHB IO offset = %08lx\n",
1621 (unsigned long)hose->io_base_virt - _IO_BASE);
1622
1623}

--- 162 unchanged lines hidden ---
1548 }
1549
1550 pr_debug("PCI: PHB MEM offset = %016llx\n",
1551 (unsigned long long)hose->pci_mem_offset);
1552 pr_debug("PCI: PHB IO offset = %08lx\n",
1553 (unsigned long)hose->io_base_virt - _IO_BASE);
1554
1555}

--- 162 unchanged lines hidden ---