aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2007-03-01 14:20:37 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 04:55:08 -0400
commitbc606f3c917aa453fca62b76c8e9998b4171f4fa (patch)
treed7a91e88f2f8a1ab12af68d0ec49545298831415 /arch/sparc64
parent1e8a8cc52daa95e702303ca3ce67955a4c051d7d (diff)
[SPARC64]: Minor cleanups to schizo pci controller driver.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64')
-rw-r--r--arch/sparc64/kernel/pci_schizo.c110
1 files changed, 31 insertions, 79 deletions
diff --git a/arch/sparc64/kernel/pci_schizo.c b/arch/sparc64/kernel/pci_schizo.c
index 48dea52ac522..332cfd9736b7 100644
--- a/arch/sparc64/kernel/pci_schizo.c
+++ b/arch/sparc64/kernel/pci_schizo.c
@@ -1229,21 +1229,8 @@ static void pbm_config_busmastering(struct pci_pbm_info *pbm)
1229 pci_config_write8(addr, 64); 1229 pci_config_write8(addr, 64);
1230} 1230}
1231 1231
1232static void pbm_scan_bus(struct pci_controller_info *p, 1232static void schizo_scan_bus(struct pci_controller_info *p)
1233 struct pci_pbm_info *pbm)
1234{
1235 pbm->pci_bus = pci_scan_one_pbm(pbm);
1236}
1237
1238static void __schizo_scan_bus(struct pci_controller_info *p,
1239 int chip_type)
1240{ 1233{
1241 if (!p->pbm_B.prom_node || !p->pbm_A.prom_node) {
1242 printk("PCI: Only one PCI bus module of controller found.\n");
1243 printk("PCI: Ignoring entire controller.\n");
1244 return;
1245 }
1246
1247 pbm_config_busmastering(&p->pbm_B); 1234 pbm_config_busmastering(&p->pbm_B);
1248 p->pbm_B.is_66mhz_capable = 1235 p->pbm_B.is_66mhz_capable =
1249 (of_find_property(p->pbm_B.prom_node, "66mhz-capable", NULL) 1236 (of_find_property(p->pbm_B.prom_node, "66mhz-capable", NULL)
@@ -1252,28 +1239,19 @@ static void __schizo_scan_bus(struct pci_controller_info *p,
1252 p->pbm_A.is_66mhz_capable = 1239 p->pbm_A.is_66mhz_capable =
1253 (of_find_property(p->pbm_A.prom_node, "66mhz-capable", NULL) 1240 (of_find_property(p->pbm_A.prom_node, "66mhz-capable", NULL)
1254 != NULL); 1241 != NULL);
1255 pbm_scan_bus(p, &p->pbm_B); 1242
1256 pbm_scan_bus(p, &p->pbm_A); 1243 p->pbm_B.pci_bus = pci_scan_one_pbm(&p->pbm_B);
1244 p->pbm_A.pci_bus = pci_scan_one_pbm(&p->pbm_A);
1257 1245
1258 /* After the PCI bus scan is complete, we can register 1246 /* After the PCI bus scan is complete, we can register
1259 * the error interrupt handlers. 1247 * the error interrupt handlers.
1260 */ 1248 */
1261 if (chip_type == PBM_CHIP_TYPE_TOMATILLO) 1249 if (p->pbm_B.chip_type == PBM_CHIP_TYPE_TOMATILLO)
1262 tomatillo_register_error_handlers(p); 1250 tomatillo_register_error_handlers(p);
1263 else 1251 else
1264 schizo_register_error_handlers(p); 1252 schizo_register_error_handlers(p);
1265} 1253}
1266 1254
1267static void schizo_scan_bus(struct pci_controller_info *p)
1268{
1269 __schizo_scan_bus(p, PBM_CHIP_TYPE_SCHIZO);
1270}
1271
1272static void tomatillo_scan_bus(struct pci_controller_info *p)
1273{
1274 __schizo_scan_bus(p, PBM_CHIP_TYPE_TOMATILLO);
1275}
1276
1277static void schizo_base_address_update(struct pci_dev *pdev, int resource) 1255static void schizo_base_address_update(struct pci_dev *pdev, int resource)
1278{ 1256{
1279 struct pci_pbm_info *pbm = pdev->dev.archdata.host_controller; 1257 struct pci_pbm_info *pbm = pdev->dev.archdata.host_controller;
@@ -1633,7 +1611,6 @@ static void schizo_pbm_init(struct pci_controller_info *p,
1633 int chip_type) 1611 int chip_type)
1634{ 1612{
1635 struct linux_prom64_registers *regs; 1613 struct linux_prom64_registers *regs;
1636 struct property *prop;
1637 unsigned int *busrange; 1614 unsigned int *busrange;
1638 struct pci_pbm_info *pbm; 1615 struct pci_pbm_info *pbm;
1639 const char *chipset_name; 1616 const char *chipset_name;
@@ -1667,11 +1644,9 @@ static void schizo_pbm_init(struct pci_controller_info *p,
1667 * 3) PBM PCI config space 1644 * 3) PBM PCI config space
1668 * 4) Ichip regs 1645 * 4) Ichip regs
1669 */ 1646 */
1670 prop = of_find_property(dp, "reg", NULL); 1647 regs = of_get_property(dp, "reg", NULL);
1671 regs = prop->value;
1672 1648
1673 is_pbm_a = ((regs[0].phys_addr & 0x00700000) == 0x00600000); 1649 is_pbm_a = ((regs[0].phys_addr & 0x00700000) == 0x00600000);
1674
1675 if (is_pbm_a) 1650 if (is_pbm_a)
1676 pbm = &p->pbm_A; 1651 pbm = &p->pbm_A;
1677 else 1652 else
@@ -1683,14 +1658,8 @@ static void schizo_pbm_init(struct pci_controller_info *p,
1683 pbm->pci_first_slot = 1; 1658 pbm->pci_first_slot = 1;
1684 1659
1685 pbm->chip_type = chip_type; 1660 pbm->chip_type = chip_type;
1686 pbm->chip_version = 0; 1661 pbm->chip_version = of_getintprop_default(dp, "version#", 0);
1687 prop = of_find_property(dp, "version#", NULL); 1662 pbm->chip_revision = of_getintprop_default(dp, "module-version#", 0);
1688 if (prop)
1689 pbm->chip_version = *(int *) prop->value;
1690 pbm->chip_revision = 0;
1691 prop = of_find_property(dp, "module-revision#", NULL);
1692 if (prop)
1693 pbm->chip_revision = *(int *) prop->value;
1694 1663
1695 pbm->pbm_regs = regs[0].phys_addr; 1664 pbm->pbm_regs = regs[0].phys_addr;
1696 pbm->controller_regs = regs[1].phys_addr - 0x10000UL; 1665 pbm->controller_regs = regs[1].phys_addr - 0x10000UL;
@@ -1701,40 +1670,31 @@ static void schizo_pbm_init(struct pci_controller_info *p,
1701 pbm->name = dp->full_name; 1670 pbm->name = dp->full_name;
1702 1671
1703 printk("%s: %s PCI Bus Module ver[%x:%x]\n", 1672 printk("%s: %s PCI Bus Module ver[%x:%x]\n",
1704 pbm->name, 1673 pbm->name, chipset_name,
1705 (chip_type == PBM_CHIP_TYPE_TOMATILLO ?
1706 "TOMATILLO" : "SCHIZO"),
1707 pbm->chip_version, pbm->chip_revision); 1674 pbm->chip_version, pbm->chip_revision);
1708 1675
1709 schizo_pbm_hw_init(pbm); 1676 schizo_pbm_hw_init(pbm);
1710 1677
1711 prop = of_find_property(dp, "ranges", &len); 1678 pbm->pbm_ranges = of_get_property(dp, "ranges", &len);
1712 pbm->pbm_ranges = prop->value;
1713 pbm->num_pbm_ranges = 1679 pbm->num_pbm_ranges =
1714 (len / sizeof(struct linux_prom_pci_ranges)); 1680 (len / sizeof(struct linux_prom_pci_ranges));
1715 1681
1716 schizo_determine_mem_io_space(pbm); 1682 schizo_determine_mem_io_space(pbm);
1717 pbm_register_toplevel_resources(p, pbm); 1683 pbm_register_toplevel_resources(p, pbm);
1718 1684
1719 prop = of_find_property(dp, "interrupt-map", &len); 1685 pbm->pbm_intmap = of_get_property(dp, "interrupt-map", &len);
1720 if (prop) { 1686 if (pbm->pbm_intmap) {
1721 pbm->pbm_intmap = prop->value;
1722 pbm->num_pbm_intmap = 1687 pbm->num_pbm_intmap =
1723 (len / sizeof(struct linux_prom_pci_intmap)); 1688 (len / sizeof(struct linux_prom_pci_intmap));
1724 1689 pbm->pbm_intmask =
1725 prop = of_find_property(dp, "interrupt-map-mask", NULL); 1690 of_get_property(dp, "interrupt-map-mask", NULL);
1726 pbm->pbm_intmask = prop->value;
1727 } else {
1728 pbm->num_pbm_intmap = 0;
1729 } 1691 }
1730 1692
1731 prop = of_find_property(dp, "ino-bitmap", NULL); 1693 ino_bitmap = of_get_property(dp, "ino-bitmap", NULL);
1732 ino_bitmap = prop->value;
1733 pbm->ino_bitmap = (((u64)ino_bitmap[1] << 32UL) | 1694 pbm->ino_bitmap = (((u64)ino_bitmap[1] << 32UL) |
1734 ((u64)ino_bitmap[0] << 0UL)); 1695 ((u64)ino_bitmap[0] << 0UL));
1735 1696
1736 prop = of_find_property(dp, "bus-range", NULL); 1697 busrange = of_get_property(dp, "bus-range", NULL);
1737 busrange = prop->value;
1738 pbm->pci_first_busno = busrange[0]; 1698 pbm->pci_first_busno = busrange[0];
1739 pbm->pci_last_busno = busrange[1]; 1699 pbm->pci_last_busno = busrange[1];
1740 1700
@@ -1756,14 +1716,9 @@ static void __schizo_init(struct device_node *dp, char *model_name, int chip_typ
1756{ 1716{
1757 struct pci_controller_info *p; 1717 struct pci_controller_info *p;
1758 struct pci_iommu *iommu; 1718 struct pci_iommu *iommu;
1759 struct property *prop;
1760 int is_pbm_a;
1761 u32 portid; 1719 u32 portid;
1762 1720
1763 portid = 0xff; 1721 portid = of_getintprop_default(dp, "portid", 0xff);
1764 prop = of_find_property(dp, "portid", NULL);
1765 if (prop)
1766 portid = *(u32 *) prop->value;
1767 1722
1768 for (p = pci_controller_root; p; p = p->next) { 1723 for (p = pci_controller_root; p; p = p->next) {
1769 struct pci_pbm_info *pbm; 1724 struct pci_pbm_info *pbm;
@@ -1776,40 +1731,32 @@ static void __schizo_init(struct device_node *dp, char *model_name, int chip_typ
1776 &p->pbm_B); 1731 &p->pbm_B);
1777 1732
1778 if (portid_compare(pbm->portid, portid, chip_type)) { 1733 if (portid_compare(pbm->portid, portid, chip_type)) {
1779 is_pbm_a = (p->pbm_A.prom_node == NULL);
1780 schizo_pbm_init(p, dp, portid, chip_type); 1734 schizo_pbm_init(p, dp, portid, chip_type);
1781 return; 1735 return;
1782 } 1736 }
1783 } 1737 }
1784 1738
1785 p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC); 1739 p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC);
1786 if (!p) { 1740 if (!p)
1787 prom_printf("SCHIZO: Fatal memory allocation error.\n"); 1741 goto memfail;
1788 prom_halt();
1789 }
1790 1742
1791 iommu = kzalloc(sizeof(struct pci_iommu), GFP_ATOMIC); 1743 iommu = kzalloc(sizeof(struct pci_iommu), GFP_ATOMIC);
1792 if (!iommu) { 1744 if (!iommu)
1793 prom_printf("SCHIZO: Fatal memory allocation error.\n"); 1745 goto memfail;
1794 prom_halt(); 1746
1795 }
1796 p->pbm_A.iommu = iommu; 1747 p->pbm_A.iommu = iommu;
1797 1748
1798 iommu = kzalloc(sizeof(struct pci_iommu), GFP_ATOMIC); 1749 iommu = kzalloc(sizeof(struct pci_iommu), GFP_ATOMIC);
1799 if (!iommu) { 1750 if (!iommu)
1800 prom_printf("SCHIZO: Fatal memory allocation error.\n"); 1751 goto memfail;
1801 prom_halt(); 1752
1802 }
1803 p->pbm_B.iommu = iommu; 1753 p->pbm_B.iommu = iommu;
1804 1754
1805 p->next = pci_controller_root; 1755 p->next = pci_controller_root;
1806 pci_controller_root = p; 1756 pci_controller_root = p;
1807 1757
1808 p->index = pci_num_controllers++; 1758 p->index = pci_num_controllers++;
1809 p->pbms_same_domain = 0; 1759 p->scan_bus = schizo_scan_bus;
1810 p->scan_bus = (chip_type == PBM_CHIP_TYPE_TOMATILLO ?
1811 tomatillo_scan_bus :
1812 schizo_scan_bus);
1813 p->base_address_update = schizo_base_address_update; 1760 p->base_address_update = schizo_base_address_update;
1814 p->resource_adjust = schizo_resource_adjust; 1761 p->resource_adjust = schizo_resource_adjust;
1815 p->pci_ops = &schizo_ops; 1762 p->pci_ops = &schizo_ops;
@@ -1818,6 +1765,11 @@ static void __schizo_init(struct device_node *dp, char *model_name, int chip_typ
1818 pci_memspace_mask = 0x7fffffffUL; 1765 pci_memspace_mask = 0x7fffffffUL;
1819 1766
1820 schizo_pbm_init(p, dp, portid, chip_type); 1767 schizo_pbm_init(p, dp, portid, chip_type);
1768 return;
1769
1770memfail:
1771 prom_printf("SCHIZO: Fatal memory allocation error.\n");
1772 prom_halt();
1821} 1773}
1822 1774
1823void schizo_init(struct device_node *dp, char *model_name) 1775void schizo_init(struct device_node *dp, char *model_name)