aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/agp/intel-gtt.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2010-09-08 15:18:53 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2010-09-08 16:20:14 -0400
commit1a997ff2a0089a07a5494545d31f4366742dea43 (patch)
tree31b1922f2922c76ef1aff40cc298fd8a2e49d114 /drivers/char/agp/intel-gtt.c
parente5e408fc94595aab897f613b6f4e2f5b36870a6f (diff)
intel-gtt: introduce intel_gtt_driver
Same idea as INTEL_INFO from drm/i915. This - reduces the dependancy on agp_driver - stops the what-does-IS_I965G-mean confusion (here it's just gen4, in drm/i915 it's gen >=4) - further prepares the separation of the fake agp driver from the rest. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/char/agp/intel-gtt.c')
-rw-r--r--drivers/char/agp/intel-gtt.c167
1 files changed, 120 insertions, 47 deletions
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index 3b84d8445a43..831f3c527bdf 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -81,8 +81,16 @@ static struct gatt_mask intel_gen6_masks[] =
81 .type = INTEL_AGP_CACHED_MEMORY_LLC_MLC_GFDT }, 81 .type = INTEL_AGP_CACHED_MEMORY_LLC_MLC_GFDT },
82}; 82};
83 83
84struct intel_gtt_driver {
85 unsigned int gen : 8;
86 unsigned int is_g33 : 1;
87 unsigned int is_pineview : 1;
88 unsigned int is_ironlake : 1;
89};
90
84static struct _intel_private { 91static struct _intel_private {
85 struct intel_gtt base; 92 struct intel_gtt base;
93 const struct intel_gtt_driver *driver;
86 struct pci_dev *pcidev; /* device one */ 94 struct pci_dev *pcidev; /* device one */
87 struct pci_dev *bridge_dev; 95 struct pci_dev *bridge_dev;
88 u8 __iomem *registers; 96 u8 __iomem *registers;
@@ -97,6 +105,11 @@ static struct _intel_private {
97 int resource_valid; 105 int resource_valid;
98} intel_private; 106} intel_private;
99 107
108#define INTEL_GTT_GEN intel_private.driver->gen
109#define IS_G33 intel_private.driver->is_g33
110#define IS_PINEVIEW intel_private.driver->is_pineview
111#define IS_IRONLAKE intel_private.driver->is_ironlake
112
100#ifdef USE_PCI_DMA_API 113#ifdef USE_PCI_DMA_API
101static int intel_agp_map_page(struct page *page, dma_addr_t *ret) 114static int intel_agp_map_page(struct page *page, dma_addr_t *ret)
102{ 115{
@@ -543,7 +556,7 @@ static unsigned int intel_gtt_stolen_entries(void)
543 pci_read_config_word(intel_private.bridge_dev, 556 pci_read_config_word(intel_private.bridge_dev,
544 I830_GMCH_CTRL, &gmch_ctrl); 557 I830_GMCH_CTRL, &gmch_ctrl);
545 558
546 if (IS_G4X || IS_PINEVIEW) 559 if (INTEL_GTT_GEN > 4 || IS_PINEVIEW)
547 overhead_entries = 0; 560 overhead_entries = 0;
548 else 561 else
549 overhead_entries = intel_private.base.gtt_mappable_entries 562 overhead_entries = intel_private.base.gtt_mappable_entries
@@ -573,7 +586,7 @@ static unsigned int intel_gtt_stolen_entries(void)
573 stolen_size = 0; 586 stolen_size = 0;
574 break; 587 break;
575 } 588 }
576 } else if (IS_SNB) { 589 } else if (INTEL_GTT_GEN == 6) {
577 /* 590 /*
578 * SandyBridge has new memory control reg at 0x50.w 591 * SandyBridge has new memory control reg at 0x50.w
579 */ 592 */
@@ -700,7 +713,7 @@ static unsigned int intel_gtt_total_entries(void)
700{ 713{
701 int size; 714 int size;
702 715
703 if (IS_G33 || IS_I965 || IS_G4X) { 716 if (IS_G33 || INTEL_GTT_GEN >= 4) {
704 u32 pgetbl_ctl; 717 u32 pgetbl_ctl;
705 pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL); 718 pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL);
706 719
@@ -1086,7 +1099,7 @@ static void intel_i9xx_setup_flush(void)
1086 if (intel_private.ifp_resource.start) 1099 if (intel_private.ifp_resource.start)
1087 return; 1100 return;
1088 1101
1089 if (IS_SNB) 1102 if (INTEL_GTT_GEN == 6)
1090 return; 1103 return;
1091 1104
1092 /* setup a resource for this object */ 1105 /* setup a resource for this object */
@@ -1094,7 +1107,7 @@ static void intel_i9xx_setup_flush(void)
1094 intel_private.ifp_resource.flags = IORESOURCE_MEM; 1107 intel_private.ifp_resource.flags = IORESOURCE_MEM;
1095 1108
1096 /* Setup chipset flush for 915 */ 1109 /* Setup chipset flush for 915 */
1097 if (IS_I965 || IS_G33 || IS_G4X) { 1110 if (IS_G33 || INTEL_GTT_GEN >= 4) {
1098 intel_i965_g33_setup_chipset_flush(); 1111 intel_i965_g33_setup_chipset_flush();
1099 } else { 1112 } else {
1100 intel_i915_setup_chipset_flush(); 1113 intel_i915_setup_chipset_flush();
@@ -1196,7 +1209,8 @@ static int intel_i915_insert_entries(struct agp_memory *mem, off_t pg_start,
1196 1209
1197 mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type); 1210 mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
1198 1211
1199 if (!IS_SNB && mask_type != 0 && mask_type != AGP_PHYS_MEMORY && 1212 if (INTEL_GTT_GEN != 6 && mask_type != 0 &&
1213 mask_type != AGP_PHYS_MEMORY &&
1200 mask_type != INTEL_AGP_CACHED_MEMORY) 1214 mask_type != INTEL_AGP_CACHED_MEMORY)
1201 goto out_err; 1215 goto out_err;
1202 1216
@@ -1631,6 +1645,34 @@ static const struct agp_bridge_driver intel_g33_driver = {
1631#endif 1645#endif
1632}; 1646};
1633 1647
1648static const struct intel_gtt_driver i8xx_gtt_driver = {
1649 .gen = 2,
1650};
1651static const struct intel_gtt_driver i915_gtt_driver = {
1652 .gen = 3,
1653};
1654static const struct intel_gtt_driver g33_gtt_driver = {
1655 .gen = 3,
1656 .is_g33 = 1,
1657};
1658static const struct intel_gtt_driver pineview_gtt_driver = {
1659 .gen = 3,
1660 .is_pineview = 1, .is_g33 = 1,
1661};
1662static const struct intel_gtt_driver i965_gtt_driver = {
1663 .gen = 4,
1664};
1665static const struct intel_gtt_driver g4x_gtt_driver = {
1666 .gen = 5,
1667};
1668static const struct intel_gtt_driver ironlake_gtt_driver = {
1669 .gen = 5,
1670 .is_ironlake = 1,
1671};
1672static const struct intel_gtt_driver sandybridge_gtt_driver = {
1673 .gen = 6,
1674};
1675
1634/* Table to describe Intel GMCH and AGP/PCIE GART drivers. At least one of 1676/* Table to describe Intel GMCH and AGP/PCIE GART drivers. At least one of
1635 * driver and gmch_driver must be non-null, and find_gmch will determine 1677 * driver and gmch_driver must be non-null, and find_gmch will determine
1636 * which one should be used if a gmch_chip_id is present. 1678 * which one should be used if a gmch_chip_id is present.
@@ -1639,57 +1681,86 @@ static const struct intel_gtt_driver_description {
1639 unsigned int gmch_chip_id; 1681 unsigned int gmch_chip_id;
1640 char *name; 1682 char *name;
1641 const struct agp_bridge_driver *gmch_driver; 1683 const struct agp_bridge_driver *gmch_driver;
1684 const struct intel_gtt_driver *gtt_driver;
1642} intel_gtt_chipsets[] = { 1685} intel_gtt_chipsets[] = {
1643 { PCI_DEVICE_ID_INTEL_82810_IG1, "i810", &intel_810_driver }, 1686 { PCI_DEVICE_ID_INTEL_82810_IG1, "i810", &intel_810_driver , NULL},
1644 { PCI_DEVICE_ID_INTEL_82810_IG3, "i810", &intel_810_driver }, 1687 { PCI_DEVICE_ID_INTEL_82810_IG3, "i810", &intel_810_driver , NULL},
1645 { PCI_DEVICE_ID_INTEL_82810E_IG, "i810", &intel_810_driver }, 1688 { PCI_DEVICE_ID_INTEL_82810E_IG, "i810", &intel_810_driver , NULL},
1646 { PCI_DEVICE_ID_INTEL_82815_CGC, "i815", &intel_810_driver }, 1689 { PCI_DEVICE_ID_INTEL_82815_CGC, "i815", &intel_810_driver , NULL},
1647 { PCI_DEVICE_ID_INTEL_82830_CGC, "830M", &intel_830_driver }, 1690 { PCI_DEVICE_ID_INTEL_82830_CGC, "830M",
1648 { PCI_DEVICE_ID_INTEL_82845G_IG, "830M", &intel_830_driver }, 1691 &intel_830_driver , &i8xx_gtt_driver},
1649 { PCI_DEVICE_ID_INTEL_82854_IG, "854", &intel_830_driver }, 1692 { PCI_DEVICE_ID_INTEL_82845G_IG, "830M",
1650 { PCI_DEVICE_ID_INTEL_82855GM_IG, "855GM", &intel_830_driver }, 1693 &intel_830_driver , &i8xx_gtt_driver},
1651 { PCI_DEVICE_ID_INTEL_82865_IG, "865", &intel_830_driver }, 1694 { PCI_DEVICE_ID_INTEL_82854_IG, "854",
1652 { PCI_DEVICE_ID_INTEL_E7221_IG, "E7221 (i915)", &intel_915_driver }, 1695 &intel_830_driver , &i8xx_gtt_driver},
1653 { PCI_DEVICE_ID_INTEL_82915G_IG, "915G", &intel_915_driver }, 1696 { PCI_DEVICE_ID_INTEL_82855GM_IG, "855GM",
1654 { PCI_DEVICE_ID_INTEL_82915GM_IG, "915GM", &intel_915_driver }, 1697 &intel_830_driver , &i8xx_gtt_driver},
1655 { PCI_DEVICE_ID_INTEL_82945G_IG, "945G", &intel_915_driver }, 1698 { PCI_DEVICE_ID_INTEL_82865_IG, "865",
1656 { PCI_DEVICE_ID_INTEL_82945GM_IG, "945GM", &intel_915_driver }, 1699 &intel_830_driver , &i8xx_gtt_driver},
1657 { PCI_DEVICE_ID_INTEL_82945GME_IG, "945GME", &intel_915_driver }, 1700 { PCI_DEVICE_ID_INTEL_E7221_IG, "E7221 (i915)",
1658 { PCI_DEVICE_ID_INTEL_82946GZ_IG, "946GZ", &intel_i965_driver }, 1701 &intel_915_driver , &i915_gtt_driver },
1659 { PCI_DEVICE_ID_INTEL_82G35_IG, "G35", &intel_i965_driver }, 1702 { PCI_DEVICE_ID_INTEL_82915G_IG, "915G",
1660 { PCI_DEVICE_ID_INTEL_82965Q_IG, "965Q", &intel_i965_driver }, 1703 &intel_915_driver , &i915_gtt_driver },
1661 { PCI_DEVICE_ID_INTEL_82965G_IG, "965G", &intel_i965_driver }, 1704 { PCI_DEVICE_ID_INTEL_82915GM_IG, "915GM",
1662 { PCI_DEVICE_ID_INTEL_82965GM_IG, "965GM", &intel_i965_driver }, 1705 &intel_915_driver , &i915_gtt_driver },
1663 { PCI_DEVICE_ID_INTEL_82965GME_IG, "965GME/GLE", &intel_i965_driver }, 1706 { PCI_DEVICE_ID_INTEL_82945G_IG, "945G",
1664 { PCI_DEVICE_ID_INTEL_G33_IG, "G33", &intel_g33_driver }, 1707 &intel_915_driver , &i915_gtt_driver },
1665 { PCI_DEVICE_ID_INTEL_Q35_IG, "Q35", &intel_g33_driver }, 1708 { PCI_DEVICE_ID_INTEL_82945GM_IG, "945GM",
1666 { PCI_DEVICE_ID_INTEL_Q33_IG, "Q33", &intel_g33_driver }, 1709 &intel_915_driver , &i915_gtt_driver },
1667 { PCI_DEVICE_ID_INTEL_PINEVIEW_M_IG, "GMA3150", &intel_g33_driver }, 1710 { PCI_DEVICE_ID_INTEL_82945GME_IG, "945GME",
1668 { PCI_DEVICE_ID_INTEL_PINEVIEW_IG, "GMA3150", &intel_g33_driver }, 1711 &intel_915_driver , &i915_gtt_driver },
1669 { PCI_DEVICE_ID_INTEL_GM45_IG, "GM45", &intel_i965_driver }, 1712 { PCI_DEVICE_ID_INTEL_82946GZ_IG, "946GZ",
1670 { PCI_DEVICE_ID_INTEL_EAGLELAKE_IG, "Eaglelake", &intel_i965_driver }, 1713 &intel_i965_driver , &i965_gtt_driver },
1671 { PCI_DEVICE_ID_INTEL_Q45_IG, "Q45/Q43", &intel_i965_driver }, 1714 { PCI_DEVICE_ID_INTEL_82G35_IG, "G35",
1672 { PCI_DEVICE_ID_INTEL_G45_IG, "G45/G43", &intel_i965_driver }, 1715 &intel_i965_driver , &i965_gtt_driver },
1673 { PCI_DEVICE_ID_INTEL_B43_IG, "B43", &intel_i965_driver }, 1716 { PCI_DEVICE_ID_INTEL_82965Q_IG, "965Q",
1674 { PCI_DEVICE_ID_INTEL_G41_IG, "G41", &intel_i965_driver }, 1717 &intel_i965_driver , &i965_gtt_driver },
1718 { PCI_DEVICE_ID_INTEL_82965G_IG, "965G",
1719 &intel_i965_driver , &i965_gtt_driver },
1720 { PCI_DEVICE_ID_INTEL_82965GM_IG, "965GM",
1721 &intel_i965_driver , &i965_gtt_driver },
1722 { PCI_DEVICE_ID_INTEL_82965GME_IG, "965GME/GLE",
1723 &intel_i965_driver , &i965_gtt_driver },
1724 { PCI_DEVICE_ID_INTEL_G33_IG, "G33",
1725 &intel_g33_driver , &g33_gtt_driver },
1726 { PCI_DEVICE_ID_INTEL_Q35_IG, "Q35",
1727 &intel_g33_driver , &g33_gtt_driver },
1728 { PCI_DEVICE_ID_INTEL_Q33_IG, "Q33",
1729 &intel_g33_driver , &g33_gtt_driver },
1730 { PCI_DEVICE_ID_INTEL_PINEVIEW_M_IG, "GMA3150",
1731 &intel_g33_driver , &pineview_gtt_driver },
1732 { PCI_DEVICE_ID_INTEL_PINEVIEW_IG, "GMA3150",
1733 &intel_g33_driver , &pineview_gtt_driver },
1734 { PCI_DEVICE_ID_INTEL_GM45_IG, "GM45",
1735 &intel_i965_driver , &g4x_gtt_driver },
1736 { PCI_DEVICE_ID_INTEL_EAGLELAKE_IG, "Eaglelake",
1737 &intel_i965_driver , &g4x_gtt_driver },
1738 { PCI_DEVICE_ID_INTEL_Q45_IG, "Q45/Q43",
1739 &intel_i965_driver , &g4x_gtt_driver },
1740 { PCI_DEVICE_ID_INTEL_G45_IG, "G45/G43",
1741 &intel_i965_driver , &g4x_gtt_driver },
1742 { PCI_DEVICE_ID_INTEL_B43_IG, "B43",
1743 &intel_i965_driver , &g4x_gtt_driver },
1744 { PCI_DEVICE_ID_INTEL_G41_IG, "G41",
1745 &intel_i965_driver , &g4x_gtt_driver },
1675 { PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG, 1746 { PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG,
1676 "HD Graphics", &intel_i965_driver }, 1747 "HD Graphics", &intel_i965_driver , &ironlake_gtt_driver },
1677 { PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG, 1748 { PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG,
1678 "HD Graphics", &intel_i965_driver }, 1749 "HD Graphics", &intel_i965_driver , &ironlake_gtt_driver },
1679 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT1_IG, 1750 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT1_IG,
1680 "Sandybridge", &intel_gen6_driver }, 1751 "Sandybridge", &intel_gen6_driver , &sandybridge_gtt_driver },
1681 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_IG, 1752 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_IG,
1682 "Sandybridge", &intel_gen6_driver }, 1753 "Sandybridge", &intel_gen6_driver , &sandybridge_gtt_driver },
1683 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_PLUS_IG, 1754 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_PLUS_IG,
1684 "Sandybridge", &intel_gen6_driver }, 1755 "Sandybridge", &intel_gen6_driver , &sandybridge_gtt_driver },
1685 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT1_IG, 1756 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT1_IG,
1686 "Sandybridge", &intel_gen6_driver }, 1757 "Sandybridge", &intel_gen6_driver , &sandybridge_gtt_driver },
1687 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_IG, 1758 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_IG,
1688 "Sandybridge", &intel_gen6_driver }, 1759 "Sandybridge", &intel_gen6_driver , &sandybridge_gtt_driver },
1689 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_PLUS_IG, 1760 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_PLUS_IG,
1690 "Sandybridge", &intel_gen6_driver }, 1761 "Sandybridge", &intel_gen6_driver , &sandybridge_gtt_driver },
1691 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_IG, 1762 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_IG,
1692 "Sandybridge", &intel_gen6_driver }, 1763 "Sandybridge", &intel_gen6_driver , &sandybridge_gtt_driver },
1693 { 0, NULL, NULL } 1764 { 0, NULL, NULL }
1694}; 1765};
1695 1766
@@ -1720,6 +1791,8 @@ int intel_gmch_probe(struct pci_dev *pdev,
1720 if (find_gmch(intel_gtt_chipsets[i].gmch_chip_id)) { 1791 if (find_gmch(intel_gtt_chipsets[i].gmch_chip_id)) {
1721 bridge->driver = 1792 bridge->driver =
1722 intel_gtt_chipsets[i].gmch_driver; 1793 intel_gtt_chipsets[i].gmch_driver;
1794 intel_private.driver =
1795 intel_gtt_chipsets[i].gtt_driver;
1723 break; 1796 break;
1724 } 1797 }
1725 } 1798 }