Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Intel AGPGART routines. |
| 3 | */ |
| 4 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | #include <linux/module.h> |
| 6 | #include <linux/pci.h> |
| 7 | #include <linux/init.h> |
Ahmed S. Darwish | 1eaf122 | 2007-02-06 18:08:28 +0200 | [diff] [blame] | 8 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include <linux/pagemap.h> |
| 10 | #include <linux/agp_backend.h> |
| 11 | #include "agp.h" |
| 12 | |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 13 | /* |
| 14 | * If we have Intel graphics, we're not going to have anything other than |
| 15 | * an Intel IOMMU. So make the correct use of the PCI DMA API contingent |
| 16 | * on the Intel IOMMU support (CONFIG_DMAR). |
| 17 | * Only newer chipsets need to bother with this, of course. |
| 18 | */ |
| 19 | #ifdef CONFIG_DMAR |
| 20 | #define USE_PCI_DMA_API 1 |
| 21 | #endif |
| 22 | |
Carlos Martín | e914a36 | 2008-01-24 10:34:09 +1000 | [diff] [blame] | 23 | #define PCI_DEVICE_ID_INTEL_E7221_HB 0x2588 |
| 24 | #define PCI_DEVICE_ID_INTEL_E7221_IG 0x258a |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 25 | #define PCI_DEVICE_ID_INTEL_82946GZ_HB 0x2970 |
| 26 | #define PCI_DEVICE_ID_INTEL_82946GZ_IG 0x2972 |
Zhenyu Wang | 9119f85 | 2008-01-23 15:49:26 +1000 | [diff] [blame] | 27 | #define PCI_DEVICE_ID_INTEL_82G35_HB 0x2980 |
| 28 | #define PCI_DEVICE_ID_INTEL_82G35_IG 0x2982 |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 29 | #define PCI_DEVICE_ID_INTEL_82965Q_HB 0x2990 |
| 30 | #define PCI_DEVICE_ID_INTEL_82965Q_IG 0x2992 |
| 31 | #define PCI_DEVICE_ID_INTEL_82965G_HB 0x29A0 |
| 32 | #define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2 |
Wang Zhenyu | 4598af3 | 2007-04-09 08:51:36 +0800 | [diff] [blame] | 33 | #define PCI_DEVICE_ID_INTEL_82965GM_HB 0x2A00 |
| 34 | #define PCI_DEVICE_ID_INTEL_82965GM_IG 0x2A02 |
Zhenyu Wang | dde4787 | 2007-07-26 09:18:09 +0800 | [diff] [blame] | 35 | #define PCI_DEVICE_ID_INTEL_82965GME_HB 0x2A10 |
Wang Zhenyu | c8eebfd | 2007-05-31 11:34:06 +0800 | [diff] [blame] | 36 | #define PCI_DEVICE_ID_INTEL_82965GME_IG 0x2A12 |
Zhenyu Wang | dde4787 | 2007-07-26 09:18:09 +0800 | [diff] [blame] | 37 | #define PCI_DEVICE_ID_INTEL_82945GME_HB 0x27AC |
Wang Zhenyu | df80b14 | 2007-05-31 11:51:12 +0800 | [diff] [blame] | 38 | #define PCI_DEVICE_ID_INTEL_82945GME_IG 0x27AE |
Shaohua Li | 2177832 | 2009-02-23 15:19:16 +0800 | [diff] [blame] | 39 | #define PCI_DEVICE_ID_INTEL_IGDGM_HB 0xA010 |
| 40 | #define PCI_DEVICE_ID_INTEL_IGDGM_IG 0xA011 |
| 41 | #define PCI_DEVICE_ID_INTEL_IGDG_HB 0xA000 |
| 42 | #define PCI_DEVICE_ID_INTEL_IGDG_IG 0xA001 |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 43 | #define PCI_DEVICE_ID_INTEL_G33_HB 0x29C0 |
| 44 | #define PCI_DEVICE_ID_INTEL_G33_IG 0x29C2 |
| 45 | #define PCI_DEVICE_ID_INTEL_Q35_HB 0x29B0 |
| 46 | #define PCI_DEVICE_ID_INTEL_Q35_IG 0x29B2 |
| 47 | #define PCI_DEVICE_ID_INTEL_Q33_HB 0x29D0 |
| 48 | #define PCI_DEVICE_ID_INTEL_Q33_IG 0x29D2 |
Fabian Henze | 38d8a95 | 2009-09-08 00:59:58 +0800 | [diff] [blame] | 49 | #define PCI_DEVICE_ID_INTEL_B43_HB 0x2E40 |
| 50 | #define PCI_DEVICE_ID_INTEL_B43_IG 0x2E42 |
Zhenyu Wang | 99d32bd | 2008-07-30 12:26:50 -0700 | [diff] [blame] | 51 | #define PCI_DEVICE_ID_INTEL_GM45_HB 0x2A40 |
| 52 | #define PCI_DEVICE_ID_INTEL_GM45_IG 0x2A42 |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 53 | #define PCI_DEVICE_ID_INTEL_IGD_E_HB 0x2E00 |
| 54 | #define PCI_DEVICE_ID_INTEL_IGD_E_IG 0x2E02 |
| 55 | #define PCI_DEVICE_ID_INTEL_Q45_HB 0x2E10 |
| 56 | #define PCI_DEVICE_ID_INTEL_Q45_IG 0x2E12 |
| 57 | #define PCI_DEVICE_ID_INTEL_G45_HB 0x2E20 |
| 58 | #define PCI_DEVICE_ID_INTEL_G45_IG 0x2E22 |
Zhenyu Wang | a50ccc6 | 2008-11-17 14:39:00 +0800 | [diff] [blame] | 59 | #define PCI_DEVICE_ID_INTEL_G41_HB 0x2E30 |
| 60 | #define PCI_DEVICE_ID_INTEL_G41_IG 0x2E32 |
Zhenyu Wang | 32cb055 | 2009-06-05 15:38:36 +0800 | [diff] [blame] | 61 | #define PCI_DEVICE_ID_INTEL_IGDNG_D_HB 0x0040 |
| 62 | #define PCI_DEVICE_ID_INTEL_IGDNG_D_IG 0x0042 |
| 63 | #define PCI_DEVICE_ID_INTEL_IGDNG_M_HB 0x0044 |
Zhenyu Wang | 07fb611 | 2009-08-13 18:57:29 +0800 | [diff] [blame] | 64 | #define PCI_DEVICE_ID_INTEL_IGDNG_MA_HB 0x0062 |
Zhenyu Wang | 32cb055 | 2009-06-05 15:38:36 +0800 | [diff] [blame] | 65 | #define PCI_DEVICE_ID_INTEL_IGDNG_M_IG 0x0046 |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 66 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 67 | /* cover 915 and 945 variants */ |
| 68 | #define IS_I915 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_E7221_HB || \ |
| 69 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || \ |
| 70 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || \ |
| 71 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || \ |
| 72 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || \ |
| 73 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GME_HB) |
| 74 | |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 75 | #define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \ |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 76 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82G35_HB || \ |
| 77 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965Q_HB || \ |
| 78 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \ |
| 79 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB || \ |
Eric Anholt | 82e14a6 | 2008-10-14 11:28:58 -0700 | [diff] [blame] | 80 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GME_HB) |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 81 | |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 82 | #define IS_G33 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G33_HB || \ |
| 83 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q35_HB || \ |
Shaohua Li | 2177832 | 2009-02-23 15:19:16 +0800 | [diff] [blame] | 84 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q33_HB || \ |
| 85 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGDGM_HB || \ |
| 86 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGDG_HB) |
| 87 | |
| 88 | #define IS_IGD (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGDGM_HB || \ |
| 89 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGDG_HB) |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 90 | |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 91 | #define IS_G4X (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGD_E_HB || \ |
| 92 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q45_HB || \ |
Eric Anholt | 82e14a6 | 2008-10-14 11:28:58 -0700 | [diff] [blame] | 93 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G45_HB || \ |
Zhenyu Wang | a50ccc6 | 2008-11-17 14:39:00 +0800 | [diff] [blame] | 94 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_GM45_HB || \ |
Zhenyu Wang | 32cb055 | 2009-06-05 15:38:36 +0800 | [diff] [blame] | 95 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G41_HB || \ |
Fabian Henze | 38d8a95 | 2009-09-08 00:59:58 +0800 | [diff] [blame] | 96 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_B43_HB || \ |
Zhenyu Wang | 32cb055 | 2009-06-05 15:38:36 +0800 | [diff] [blame] | 97 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGDNG_D_HB || \ |
Zhenyu Wang | 07fb611 | 2009-08-13 18:57:29 +0800 | [diff] [blame] | 98 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGDNG_M_HB || \ |
| 99 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGDNG_MA_HB) |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 100 | |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 101 | extern int agp_memory_reserved; |
| 102 | |
| 103 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | /* Intel 815 register */ |
| 105 | #define INTEL_815_APCONT 0x51 |
| 106 | #define INTEL_815_ATTBASE_MASK ~0x1FFFFFFF |
| 107 | |
| 108 | /* Intel i820 registers */ |
| 109 | #define INTEL_I820_RDCR 0x51 |
| 110 | #define INTEL_I820_ERRSTS 0xc8 |
| 111 | |
| 112 | /* Intel i840 registers */ |
| 113 | #define INTEL_I840_MCHCFG 0x50 |
| 114 | #define INTEL_I840_ERRSTS 0xc8 |
| 115 | |
| 116 | /* Intel i850 registers */ |
| 117 | #define INTEL_I850_MCHCFG 0x50 |
| 118 | #define INTEL_I850_ERRSTS 0xc8 |
| 119 | |
| 120 | /* intel 915G registers */ |
| 121 | #define I915_GMADDR 0x18 |
| 122 | #define I915_MMADDR 0x10 |
| 123 | #define I915_PTEADDR 0x1C |
| 124 | #define I915_GMCH_GMS_STOLEN_48M (0x6 << 4) |
| 125 | #define I915_GMCH_GMS_STOLEN_64M (0x7 << 4) |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 126 | #define G33_GMCH_GMS_STOLEN_128M (0x8 << 4) |
| 127 | #define G33_GMCH_GMS_STOLEN_256M (0x9 << 4) |
| 128 | #define INTEL_GMCH_GMS_STOLEN_96M (0xa << 4) |
| 129 | #define INTEL_GMCH_GMS_STOLEN_160M (0xb << 4) |
| 130 | #define INTEL_GMCH_GMS_STOLEN_224M (0xc << 4) |
| 131 | #define INTEL_GMCH_GMS_STOLEN_352M (0xd << 4) |
| 132 | |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 133 | #define I915_IFPADDR 0x60 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 135 | /* Intel 965G registers */ |
| 136 | #define I965_MSAC 0x62 |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 137 | #define I965_IFPADDR 0x70 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
| 139 | /* Intel 7505 registers */ |
| 140 | #define INTEL_I7505_APSIZE 0x74 |
| 141 | #define INTEL_I7505_NCAPID 0x60 |
| 142 | #define INTEL_I7505_NISTAT 0x6c |
| 143 | #define INTEL_I7505_ATTBASE 0x78 |
| 144 | #define INTEL_I7505_ERRSTS 0x42 |
| 145 | #define INTEL_I7505_AGPCTRL 0x70 |
| 146 | #define INTEL_I7505_MCHCFG 0x50 |
| 147 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 148 | static const struct aper_size_info_fixed intel_i810_sizes[] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | { |
| 150 | {64, 16384, 4}, |
| 151 | /* The 32M mode still requires a 64k gatt */ |
| 152 | {32, 8192, 4} |
| 153 | }; |
| 154 | |
| 155 | #define AGP_DCACHE_MEMORY 1 |
| 156 | #define AGP_PHYS_MEMORY 2 |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 157 | #define INTEL_AGP_CACHED_MEMORY 3 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
| 159 | static struct gatt_mask intel_i810_masks[] = |
| 160 | { |
| 161 | {.mask = I810_PTE_VALID, .type = 0}, |
| 162 | {.mask = (I810_PTE_VALID | I810_PTE_LOCAL), .type = AGP_DCACHE_MEMORY}, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 163 | {.mask = I810_PTE_VALID, .type = 0}, |
| 164 | {.mask = I810_PTE_VALID | I830_PTE_SYSTEM_CACHED, |
| 165 | .type = INTEL_AGP_CACHED_MEMORY} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | }; |
| 167 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 168 | static struct _intel_private { |
| 169 | struct pci_dev *pcidev; /* device one */ |
| 170 | u8 __iomem *registers; |
| 171 | u32 __iomem *gtt; /* I915G */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | int num_dcache_entries; |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 173 | /* gtt_entries is the number of gtt entries that are already mapped |
| 174 | * to stolen memory. Stolen memory is larger than the memory mapped |
| 175 | * through gtt_entries, as it includes some reserved space for the BIOS |
| 176 | * popup and for the GTT. |
| 177 | */ |
| 178 | int gtt_entries; /* i830+ */ |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 179 | union { |
| 180 | void __iomem *i9xx_flush_page; |
| 181 | void *i8xx_flush_page; |
| 182 | }; |
| 183 | struct page *i8xx_page; |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 184 | struct resource ifp_resource; |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 185 | int resource_valid; |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 186 | } intel_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 188 | #ifdef USE_PCI_DMA_API |
David Woodhouse | c2980d8 | 2009-07-29 08:39:26 +0100 | [diff] [blame] | 189 | static int intel_agp_map_page(struct page *page, dma_addr_t *ret) |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 190 | { |
David Woodhouse | c2980d8 | 2009-07-29 08:39:26 +0100 | [diff] [blame] | 191 | *ret = pci_map_page(intel_private.pcidev, page, 0, |
| 192 | PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 193 | if (pci_dma_mapping_error(intel_private.pcidev, *ret)) |
| 194 | return -EINVAL; |
| 195 | return 0; |
| 196 | } |
| 197 | |
David Woodhouse | c2980d8 | 2009-07-29 08:39:26 +0100 | [diff] [blame] | 198 | static void intel_agp_unmap_page(struct page *page, dma_addr_t dma) |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 199 | { |
David Woodhouse | c2980d8 | 2009-07-29 08:39:26 +0100 | [diff] [blame] | 200 | pci_unmap_page(intel_private.pcidev, dma, |
| 201 | PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 202 | } |
| 203 | |
David Woodhouse | 91b8e30 | 2009-07-29 08:49:12 +0100 | [diff] [blame] | 204 | static void intel_agp_free_sglist(struct agp_memory *mem) |
| 205 | { |
David Woodhouse | f692775 | 2009-07-29 09:28:45 +0100 | [diff] [blame] | 206 | struct sg_table st; |
David Woodhouse | 91b8e30 | 2009-07-29 08:49:12 +0100 | [diff] [blame] | 207 | |
David Woodhouse | f692775 | 2009-07-29 09:28:45 +0100 | [diff] [blame] | 208 | st.sgl = mem->sg_list; |
| 209 | st.orig_nents = st.nents = mem->page_count; |
| 210 | |
| 211 | sg_free_table(&st); |
| 212 | |
David Woodhouse | 91b8e30 | 2009-07-29 08:49:12 +0100 | [diff] [blame] | 213 | mem->sg_list = NULL; |
| 214 | mem->num_sg = 0; |
| 215 | } |
| 216 | |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 217 | static int intel_agp_map_memory(struct agp_memory *mem) |
| 218 | { |
David Woodhouse | f692775 | 2009-07-29 09:28:45 +0100 | [diff] [blame] | 219 | struct sg_table st; |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 220 | struct scatterlist *sg; |
| 221 | int i; |
| 222 | |
| 223 | DBG("try mapping %lu pages\n", (unsigned long)mem->page_count); |
| 224 | |
David Woodhouse | f692775 | 2009-07-29 09:28:45 +0100 | [diff] [blame] | 225 | if (sg_alloc_table(&st, mem->page_count, GFP_KERNEL)) |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 226 | return -ENOMEM; |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 227 | |
David Woodhouse | f692775 | 2009-07-29 09:28:45 +0100 | [diff] [blame] | 228 | mem->sg_list = sg = st.sgl; |
| 229 | |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 230 | for (i = 0 ; i < mem->page_count; i++, sg = sg_next(sg)) |
| 231 | sg_set_page(sg, mem->pages[i], PAGE_SIZE, 0); |
| 232 | |
| 233 | mem->num_sg = pci_map_sg(intel_private.pcidev, mem->sg_list, |
| 234 | mem->page_count, PCI_DMA_BIDIRECTIONAL); |
David Woodhouse | 91b8e30 | 2009-07-29 08:49:12 +0100 | [diff] [blame] | 235 | if (unlikely(!mem->num_sg)) { |
| 236 | intel_agp_free_sglist(mem); |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 237 | return -ENOMEM; |
| 238 | } |
| 239 | return 0; |
| 240 | } |
| 241 | |
| 242 | static void intel_agp_unmap_memory(struct agp_memory *mem) |
| 243 | { |
| 244 | DBG("try unmapping %lu pages\n", (unsigned long)mem->page_count); |
| 245 | |
| 246 | pci_unmap_sg(intel_private.pcidev, mem->sg_list, |
| 247 | mem->page_count, PCI_DMA_BIDIRECTIONAL); |
David Woodhouse | 91b8e30 | 2009-07-29 08:49:12 +0100 | [diff] [blame] | 248 | intel_agp_free_sglist(mem); |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | static void intel_agp_insert_sg_entries(struct agp_memory *mem, |
| 252 | off_t pg_start, int mask_type) |
| 253 | { |
| 254 | struct scatterlist *sg; |
| 255 | int i, j; |
| 256 | |
| 257 | j = pg_start; |
| 258 | |
| 259 | WARN_ON(!mem->num_sg); |
| 260 | |
| 261 | if (mem->num_sg == mem->page_count) { |
| 262 | for_each_sg(mem->sg_list, sg, mem->page_count, i) { |
| 263 | writel(agp_bridge->driver->mask_memory(agp_bridge, |
| 264 | sg_dma_address(sg), mask_type), |
| 265 | intel_private.gtt+j); |
| 266 | j++; |
| 267 | } |
| 268 | } else { |
| 269 | /* sg may merge pages, but we have to seperate |
| 270 | * per-page addr for GTT */ |
| 271 | unsigned int len, m; |
| 272 | |
| 273 | for_each_sg(mem->sg_list, sg, mem->num_sg, i) { |
| 274 | len = sg_dma_len(sg) / PAGE_SIZE; |
| 275 | for (m = 0; m < len; m++) { |
| 276 | writel(agp_bridge->driver->mask_memory(agp_bridge, |
| 277 | sg_dma_address(sg) + m * PAGE_SIZE, |
| 278 | mask_type), |
| 279 | intel_private.gtt+j); |
| 280 | j++; |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | readl(intel_private.gtt+j-1); |
| 285 | } |
| 286 | |
| 287 | #else |
| 288 | |
| 289 | static void intel_agp_insert_sg_entries(struct agp_memory *mem, |
| 290 | off_t pg_start, int mask_type) |
| 291 | { |
| 292 | int i, j; |
| 293 | |
| 294 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { |
| 295 | writel(agp_bridge->driver->mask_memory(agp_bridge, |
David Woodhouse | 6a12235 | 2009-07-29 10:25:58 +0100 | [diff] [blame] | 296 | page_to_phys(mem->pages[i]), mask_type), |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 297 | intel_private.gtt+j); |
| 298 | } |
| 299 | |
| 300 | readl(intel_private.gtt+j-1); |
| 301 | } |
| 302 | |
| 303 | #endif |
| 304 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | static int intel_i810_fetch_size(void) |
| 306 | { |
| 307 | u32 smram_miscc; |
| 308 | struct aper_size_info_fixed *values; |
| 309 | |
| 310 | pci_read_config_dword(agp_bridge->dev, I810_SMRAM_MISCC, &smram_miscc); |
| 311 | values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes); |
| 312 | |
| 313 | if ((smram_miscc & I810_GMS) == I810_GMS_DISABLE) { |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 314 | dev_warn(&agp_bridge->dev->dev, "i810 is disabled\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | return 0; |
| 316 | } |
| 317 | if ((smram_miscc & I810_GFX_MEM_WIN_SIZE) == I810_GFX_MEM_WIN_32M) { |
| 318 | agp_bridge->previous_size = |
| 319 | agp_bridge->current_size = (void *) (values + 1); |
| 320 | agp_bridge->aperture_size_idx = 1; |
| 321 | return values[1].size; |
| 322 | } else { |
| 323 | agp_bridge->previous_size = |
| 324 | agp_bridge->current_size = (void *) (values); |
| 325 | agp_bridge->aperture_size_idx = 0; |
| 326 | return values[0].size; |
| 327 | } |
| 328 | |
| 329 | return 0; |
| 330 | } |
| 331 | |
| 332 | static int intel_i810_configure(void) |
| 333 | { |
| 334 | struct aper_size_info_fixed *current_size; |
| 335 | u32 temp; |
| 336 | int i; |
| 337 | |
| 338 | current_size = A_SIZE_FIX(agp_bridge->current_size); |
| 339 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 340 | if (!intel_private.registers) { |
| 341 | pci_read_config_dword(intel_private.pcidev, I810_MMADDR, &temp); |
Dave Jones | e4ac5e4 | 2007-02-04 17:37:42 -0500 | [diff] [blame] | 342 | temp &= 0xfff80000; |
| 343 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 344 | intel_private.registers = ioremap(temp, 128 * 4096); |
| 345 | if (!intel_private.registers) { |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 346 | dev_err(&intel_private.pcidev->dev, |
| 347 | "can't remap memory\n"); |
Dave Jones | e4ac5e4 | 2007-02-04 17:37:42 -0500 | [diff] [blame] | 348 | return -ENOMEM; |
| 349 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | } |
| 351 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 352 | if ((readl(intel_private.registers+I810_DRAM_CTL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) { |
| 354 | /* This will need to be dynamically assigned */ |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 355 | dev_info(&intel_private.pcidev->dev, |
| 356 | "detected 4MB dedicated video ram\n"); |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 357 | intel_private.num_dcache_entries = 1024; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | } |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 359 | pci_read_config_dword(intel_private.pcidev, I810_GMADDR, &temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 361 | writel(agp_bridge->gatt_bus_addr | I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL); |
| 362 | readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | |
| 364 | if (agp_bridge->driver->needs_scratch_page) { |
| 365 | for (i = 0; i < current_size->num_entries; i++) { |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 366 | writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | } |
Keith Packard | 44d4944 | 2008-10-14 17:18:45 -0700 | [diff] [blame] | 368 | readl(intel_private.registers+I810_PTE_BASE+((i-1)*4)); /* PCI posting. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | } |
| 370 | global_cache_flush(); |
| 371 | return 0; |
| 372 | } |
| 373 | |
| 374 | static void intel_i810_cleanup(void) |
| 375 | { |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 376 | writel(0, intel_private.registers+I810_PGETBL_CTL); |
| 377 | readl(intel_private.registers); /* PCI Posting. */ |
| 378 | iounmap(intel_private.registers); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | static void intel_i810_tlbflush(struct agp_memory *mem) |
| 382 | { |
| 383 | return; |
| 384 | } |
| 385 | |
| 386 | static void intel_i810_agp_enable(struct agp_bridge_data *bridge, u32 mode) |
| 387 | { |
| 388 | return; |
| 389 | } |
| 390 | |
| 391 | /* Exists to support ARGB cursors */ |
Dave Airlie | 07613ba | 2009-06-12 14:11:41 +1000 | [diff] [blame] | 392 | static struct page *i8xx_alloc_pages(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | { |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 394 | struct page *page; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | |
Linus Torvalds | 66c669b | 2006-11-22 14:55:29 -0800 | [diff] [blame] | 396 | page = alloc_pages(GFP_KERNEL | GFP_DMA32, 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | if (page == NULL) |
| 398 | return NULL; |
| 399 | |
Arjan van de Ven | 6d238cc | 2008-01-30 13:34:06 +0100 | [diff] [blame] | 400 | if (set_pages_uc(page, 4) < 0) { |
| 401 | set_pages_wb(page, 4); |
Jan Beulich | 89cf7cc | 2007-04-02 14:50:14 +0100 | [diff] [blame] | 402 | __free_pages(page, 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | return NULL; |
| 404 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | get_page(page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | atomic_inc(&agp_bridge->current_memory_agp); |
Dave Airlie | 07613ba | 2009-06-12 14:11:41 +1000 | [diff] [blame] | 407 | return page; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | } |
| 409 | |
Dave Airlie | 07613ba | 2009-06-12 14:11:41 +1000 | [diff] [blame] | 410 | static void i8xx_destroy_pages(struct page *page) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | { |
Dave Airlie | 07613ba | 2009-06-12 14:11:41 +1000 | [diff] [blame] | 412 | if (page == NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | return; |
| 414 | |
Arjan van de Ven | 6d238cc | 2008-01-30 13:34:06 +0100 | [diff] [blame] | 415 | set_pages_wb(page, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | put_page(page); |
Jan Beulich | 89cf7cc | 2007-04-02 14:50:14 +0100 | [diff] [blame] | 417 | __free_pages(page, 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | atomic_dec(&agp_bridge->current_memory_agp); |
| 419 | } |
| 420 | |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 421 | static int intel_i830_type_to_mask_type(struct agp_bridge_data *bridge, |
| 422 | int type) |
| 423 | { |
| 424 | if (type < AGP_USER_TYPES) |
| 425 | return type; |
| 426 | else if (type == AGP_USER_CACHED_MEMORY) |
| 427 | return INTEL_AGP_CACHED_MEMORY; |
| 428 | else |
| 429 | return 0; |
| 430 | } |
| 431 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start, |
| 433 | int type) |
| 434 | { |
| 435 | int i, j, num_entries; |
| 436 | void *temp; |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 437 | int ret = -EINVAL; |
| 438 | int mask_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 440 | if (mem->page_count == 0) |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 441 | goto out; |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 442 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | temp = agp_bridge->current_size; |
| 444 | num_entries = A_SIZE_FIX(temp)->num_entries; |
| 445 | |
Dave Jones | 6a92a4e | 2006-02-28 00:54:25 -0500 | [diff] [blame] | 446 | if ((pg_start + mem->page_count) > num_entries) |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 447 | goto out_err; |
| 448 | |
Dave Jones | 6a92a4e | 2006-02-28 00:54:25 -0500 | [diff] [blame] | 449 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | for (j = pg_start; j < (pg_start + mem->page_count); j++) { |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 451 | if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+j))) { |
| 452 | ret = -EBUSY; |
| 453 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | } |
| 456 | |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 457 | if (type != mem->type) |
| 458 | goto out_err; |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 459 | |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 460 | mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type); |
| 461 | |
| 462 | switch (mask_type) { |
| 463 | case AGP_DCACHE_MEMORY: |
| 464 | if (!mem->is_flushed) |
| 465 | global_cache_flush(); |
| 466 | for (i = pg_start; i < (pg_start + mem->page_count); i++) { |
| 467 | writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID, |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 468 | intel_private.registers+I810_PTE_BASE+(i*4)); |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 469 | } |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 470 | readl(intel_private.registers+I810_PTE_BASE+((i-1)*4)); |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 471 | break; |
| 472 | case AGP_PHYS_MEMORY: |
| 473 | case AGP_NORMAL_MEMORY: |
| 474 | if (!mem->is_flushed) |
| 475 | global_cache_flush(); |
| 476 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { |
| 477 | writel(agp_bridge->driver->mask_memory(agp_bridge, |
David Woodhouse | 6a12235 | 2009-07-29 10:25:58 +0100 | [diff] [blame] | 478 | page_to_phys(mem->pages[i]), mask_type), |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 479 | intel_private.registers+I810_PTE_BASE+(j*4)); |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 480 | } |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 481 | readl(intel_private.registers+I810_PTE_BASE+((j-1)*4)); |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 482 | break; |
| 483 | default: |
| 484 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | |
| 487 | agp_bridge->driver->tlb_flush(mem); |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 488 | out: |
| 489 | ret = 0; |
| 490 | out_err: |
Dave Airlie | 9516b03 | 2008-06-19 10:42:17 +1000 | [diff] [blame] | 491 | mem->is_flushed = true; |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 492 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 493 | } |
| 494 | |
| 495 | static int intel_i810_remove_entries(struct agp_memory *mem, off_t pg_start, |
| 496 | int type) |
| 497 | { |
| 498 | int i; |
| 499 | |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 500 | if (mem->page_count == 0) |
| 501 | return 0; |
| 502 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | for (i = pg_start; i < (mem->page_count + pg_start); i++) { |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 504 | writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | } |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 506 | readl(intel_private.registers+I810_PTE_BASE+((i-1)*4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | agp_bridge->driver->tlb_flush(mem); |
| 509 | return 0; |
| 510 | } |
| 511 | |
| 512 | /* |
| 513 | * The i810/i830 requires a physical address to program its mouse |
| 514 | * pointer into hardware. |
| 515 | * However the Xserver still writes to it through the agp aperture. |
| 516 | */ |
| 517 | static struct agp_memory *alloc_agpphysmem_i8xx(size_t pg_count, int type) |
| 518 | { |
| 519 | struct agp_memory *new; |
Dave Airlie | 07613ba | 2009-06-12 14:11:41 +1000 | [diff] [blame] | 520 | struct page *page; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | switch (pg_count) { |
Dave Airlie | 07613ba | 2009-06-12 14:11:41 +1000 | [diff] [blame] | 523 | case 1: page = agp_bridge->driver->agp_alloc_page(agp_bridge); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 524 | break; |
| 525 | case 4: |
| 526 | /* kludge to get 4 physical pages for ARGB cursor */ |
Dave Airlie | 07613ba | 2009-06-12 14:11:41 +1000 | [diff] [blame] | 527 | page = i8xx_alloc_pages(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | break; |
| 529 | default: |
| 530 | return NULL; |
| 531 | } |
| 532 | |
Dave Airlie | 07613ba | 2009-06-12 14:11:41 +1000 | [diff] [blame] | 533 | if (page == NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | return NULL; |
| 535 | |
| 536 | new = agp_create_memory(pg_count); |
| 537 | if (new == NULL) |
| 538 | return NULL; |
| 539 | |
Dave Airlie | 07613ba | 2009-06-12 14:11:41 +1000 | [diff] [blame] | 540 | new->pages[0] = page; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | if (pg_count == 4) { |
| 542 | /* kludge to get 4 physical pages for ARGB cursor */ |
Dave Airlie | 07613ba | 2009-06-12 14:11:41 +1000 | [diff] [blame] | 543 | new->pages[1] = new->pages[0] + 1; |
| 544 | new->pages[2] = new->pages[1] + 1; |
| 545 | new->pages[3] = new->pages[2] + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | } |
| 547 | new->page_count = pg_count; |
| 548 | new->num_scratch_pages = pg_count; |
| 549 | new->type = AGP_PHYS_MEMORY; |
Dave Airlie | 07613ba | 2009-06-12 14:11:41 +1000 | [diff] [blame] | 550 | new->physical = page_to_phys(new->pages[0]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | return new; |
| 552 | } |
| 553 | |
| 554 | static struct agp_memory *intel_i810_alloc_by_type(size_t pg_count, int type) |
| 555 | { |
| 556 | struct agp_memory *new; |
| 557 | |
| 558 | if (type == AGP_DCACHE_MEMORY) { |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 559 | if (pg_count != intel_private.num_dcache_entries) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | return NULL; |
| 561 | |
| 562 | new = agp_create_memory(1); |
| 563 | if (new == NULL) |
| 564 | return NULL; |
| 565 | |
| 566 | new->type = AGP_DCACHE_MEMORY; |
| 567 | new->page_count = pg_count; |
| 568 | new->num_scratch_pages = 0; |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 569 | agp_free_page_array(new); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | return new; |
| 571 | } |
| 572 | if (type == AGP_PHYS_MEMORY) |
| 573 | return alloc_agpphysmem_i8xx(pg_count, type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | return NULL; |
| 575 | } |
| 576 | |
| 577 | static void intel_i810_free_by_type(struct agp_memory *curr) |
| 578 | { |
| 579 | agp_free_key(curr->key); |
Dave Jones | 6a92a4e | 2006-02-28 00:54:25 -0500 | [diff] [blame] | 580 | if (curr->type == AGP_PHYS_MEMORY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | if (curr->page_count == 4) |
Dave Airlie | 07613ba | 2009-06-12 14:11:41 +1000 | [diff] [blame] | 582 | i8xx_destroy_pages(curr->pages[0]); |
Alan Hourihane | 88d5196 | 2005-11-06 23:35:34 -0800 | [diff] [blame] | 583 | else { |
Dave Airlie | 07613ba | 2009-06-12 14:11:41 +1000 | [diff] [blame] | 584 | agp_bridge->driver->agp_destroy_page(curr->pages[0], |
Dave Airlie | a2721e9 | 2007-10-15 10:19:16 +1000 | [diff] [blame] | 585 | AGP_PAGE_DESTROY_UNMAP); |
Dave Airlie | 07613ba | 2009-06-12 14:11:41 +1000 | [diff] [blame] | 586 | agp_bridge->driver->agp_destroy_page(curr->pages[0], |
Dave Airlie | a2721e9 | 2007-10-15 10:19:16 +1000 | [diff] [blame] | 587 | AGP_PAGE_DESTROY_FREE); |
Alan Hourihane | 88d5196 | 2005-11-06 23:35:34 -0800 | [diff] [blame] | 588 | } |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 589 | agp_free_page_array(curr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | } |
| 591 | kfree(curr); |
| 592 | } |
| 593 | |
| 594 | static unsigned long intel_i810_mask_memory(struct agp_bridge_data *bridge, |
David Woodhouse | 2a4ceb6 | 2009-07-27 10:27:29 +0100 | [diff] [blame] | 595 | dma_addr_t addr, int type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | { |
| 597 | /* Type checking must be done elsewhere */ |
| 598 | return addr | bridge->driver->masks[type].mask; |
| 599 | } |
| 600 | |
| 601 | static struct aper_size_info_fixed intel_i830_sizes[] = |
| 602 | { |
| 603 | {128, 32768, 5}, |
| 604 | /* The 64M mode still requires a 128k gatt */ |
| 605 | {64, 16384, 5}, |
| 606 | {256, 65536, 6}, |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 607 | {512, 131072, 7}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | }; |
| 609 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | static void intel_i830_init_gtt_entries(void) |
| 611 | { |
| 612 | u16 gmch_ctrl; |
| 613 | int gtt_entries; |
| 614 | u8 rdct; |
| 615 | int local = 0; |
| 616 | static const int ddt[4] = { 0, 16, 32, 64 }; |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 617 | int size; /* reserved space (in kb) at the top of stolen memory */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 619 | pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 621 | if (IS_I965) { |
| 622 | u32 pgetbl_ctl; |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 623 | pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL); |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 624 | |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 625 | /* The 965 has a field telling us the size of the GTT, |
| 626 | * which may be larger than what is necessary to map the |
| 627 | * aperture. |
| 628 | */ |
| 629 | switch (pgetbl_ctl & I965_PGETBL_SIZE_MASK) { |
| 630 | case I965_PGETBL_SIZE_128KB: |
| 631 | size = 128; |
| 632 | break; |
| 633 | case I965_PGETBL_SIZE_256KB: |
| 634 | size = 256; |
| 635 | break; |
| 636 | case I965_PGETBL_SIZE_512KB: |
| 637 | size = 512; |
| 638 | break; |
Zhenyu Wang | 4e8b6e2 | 2008-01-23 14:54:37 +1000 | [diff] [blame] | 639 | case I965_PGETBL_SIZE_1MB: |
| 640 | size = 1024; |
| 641 | break; |
| 642 | case I965_PGETBL_SIZE_2MB: |
| 643 | size = 2048; |
| 644 | break; |
| 645 | case I965_PGETBL_SIZE_1_5MB: |
| 646 | size = 1024 + 512; |
| 647 | break; |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 648 | default: |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 649 | dev_info(&intel_private.pcidev->dev, |
| 650 | "unknown page table size, assuming 512KB\n"); |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 651 | size = 512; |
| 652 | } |
| 653 | size += 4; /* add in BIOS popup space */ |
Shaohua Li | 2177832 | 2009-02-23 15:19:16 +0800 | [diff] [blame] | 654 | } else if (IS_G33 && !IS_IGD) { |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 655 | /* G33's GTT size defined in gmch_ctrl */ |
| 656 | switch (gmch_ctrl & G33_PGETBL_SIZE_MASK) { |
| 657 | case G33_PGETBL_SIZE_1M: |
| 658 | size = 1024; |
| 659 | break; |
| 660 | case G33_PGETBL_SIZE_2M: |
| 661 | size = 2048; |
| 662 | break; |
| 663 | default: |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 664 | dev_info(&agp_bridge->dev->dev, |
| 665 | "unknown page table size 0x%x, assuming 512KB\n", |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 666 | (gmch_ctrl & G33_PGETBL_SIZE_MASK)); |
| 667 | size = 512; |
| 668 | } |
| 669 | size += 4; |
Shaohua Li | 2177832 | 2009-02-23 15:19:16 +0800 | [diff] [blame] | 670 | } else if (IS_G4X || IS_IGD) { |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 671 | /* On 4 series hardware, GTT stolen is separate from graphics |
Eric Anholt | 82e14a6 | 2008-10-14 11:28:58 -0700 | [diff] [blame] | 672 | * stolen, ignore it in stolen gtt entries counting. However, |
| 673 | * 4KB of the stolen memory doesn't get mapped to the GTT. |
| 674 | */ |
| 675 | size = 4; |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 676 | } else { |
| 677 | /* On previous hardware, the GTT size was just what was |
| 678 | * required to map the aperture. |
| 679 | */ |
| 680 | size = agp_bridge->driver->fetch_size() + 4; |
| 681 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | |
| 683 | if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82830_HB || |
| 684 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) { |
| 685 | switch (gmch_ctrl & I830_GMCH_GMS_MASK) { |
| 686 | case I830_GMCH_GMS_STOLEN_512: |
| 687 | gtt_entries = KB(512) - KB(size); |
| 688 | break; |
| 689 | case I830_GMCH_GMS_STOLEN_1024: |
| 690 | gtt_entries = MB(1) - KB(size); |
| 691 | break; |
| 692 | case I830_GMCH_GMS_STOLEN_8192: |
| 693 | gtt_entries = MB(8) - KB(size); |
| 694 | break; |
| 695 | case I830_GMCH_GMS_LOCAL: |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 696 | rdct = readb(intel_private.registers+I830_RDRAM_CHANNEL_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | gtt_entries = (I830_RDRAM_ND(rdct) + 1) * |
| 698 | MB(ddt[I830_RDRAM_DDT(rdct)]); |
| 699 | local = 1; |
| 700 | break; |
| 701 | default: |
| 702 | gtt_entries = 0; |
| 703 | break; |
| 704 | } |
| 705 | } else { |
Dave Airlie | e67aa27 | 2007-09-18 22:46:35 -0700 | [diff] [blame] | 706 | switch (gmch_ctrl & I855_GMCH_GMS_MASK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | case I855_GMCH_GMS_STOLEN_1M: |
| 708 | gtt_entries = MB(1) - KB(size); |
| 709 | break; |
| 710 | case I855_GMCH_GMS_STOLEN_4M: |
| 711 | gtt_entries = MB(4) - KB(size); |
| 712 | break; |
| 713 | case I855_GMCH_GMS_STOLEN_8M: |
| 714 | gtt_entries = MB(8) - KB(size); |
| 715 | break; |
| 716 | case I855_GMCH_GMS_STOLEN_16M: |
| 717 | gtt_entries = MB(16) - KB(size); |
| 718 | break; |
| 719 | case I855_GMCH_GMS_STOLEN_32M: |
| 720 | gtt_entries = MB(32) - KB(size); |
| 721 | break; |
| 722 | case I915_GMCH_GMS_STOLEN_48M: |
| 723 | /* Check it's really I915G */ |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 724 | if (IS_I915 || IS_I965 || IS_G33 || IS_G4X) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | gtt_entries = MB(48) - KB(size); |
| 726 | else |
| 727 | gtt_entries = 0; |
| 728 | break; |
| 729 | case I915_GMCH_GMS_STOLEN_64M: |
| 730 | /* Check it's really I915G */ |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 731 | if (IS_I915 || IS_I965 || IS_G33 || IS_G4X) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 732 | gtt_entries = MB(64) - KB(size); |
| 733 | else |
| 734 | gtt_entries = 0; |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 735 | break; |
| 736 | case G33_GMCH_GMS_STOLEN_128M: |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 737 | if (IS_G33 || IS_I965 || IS_G4X) |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 738 | gtt_entries = MB(128) - KB(size); |
| 739 | else |
| 740 | gtt_entries = 0; |
| 741 | break; |
| 742 | case G33_GMCH_GMS_STOLEN_256M: |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 743 | if (IS_G33 || IS_I965 || IS_G4X) |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 744 | gtt_entries = MB(256) - KB(size); |
| 745 | else |
| 746 | gtt_entries = 0; |
| 747 | break; |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 748 | case INTEL_GMCH_GMS_STOLEN_96M: |
| 749 | if (IS_I965 || IS_G4X) |
| 750 | gtt_entries = MB(96) - KB(size); |
| 751 | else |
| 752 | gtt_entries = 0; |
| 753 | break; |
| 754 | case INTEL_GMCH_GMS_STOLEN_160M: |
| 755 | if (IS_I965 || IS_G4X) |
| 756 | gtt_entries = MB(160) - KB(size); |
| 757 | else |
| 758 | gtt_entries = 0; |
| 759 | break; |
| 760 | case INTEL_GMCH_GMS_STOLEN_224M: |
| 761 | if (IS_I965 || IS_G4X) |
| 762 | gtt_entries = MB(224) - KB(size); |
| 763 | else |
| 764 | gtt_entries = 0; |
| 765 | break; |
| 766 | case INTEL_GMCH_GMS_STOLEN_352M: |
| 767 | if (IS_I965 || IS_G4X) |
| 768 | gtt_entries = MB(352) - KB(size); |
| 769 | else |
| 770 | gtt_entries = 0; |
| 771 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | default: |
| 773 | gtt_entries = 0; |
| 774 | break; |
| 775 | } |
| 776 | } |
Lubomir Rintel | 9c1e8a4 | 2009-03-10 12:55:54 -0700 | [diff] [blame] | 777 | if (gtt_entries > 0) { |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 778 | dev_info(&agp_bridge->dev->dev, "detected %dK %s memory\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | gtt_entries / KB(1), local ? "local" : "stolen"); |
Lubomir Rintel | 9c1e8a4 | 2009-03-10 12:55:54 -0700 | [diff] [blame] | 780 | gtt_entries /= KB(4); |
| 781 | } else { |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 782 | dev_info(&agp_bridge->dev->dev, |
| 783 | "no pre-allocated video memory detected\n"); |
Lubomir Rintel | 9c1e8a4 | 2009-03-10 12:55:54 -0700 | [diff] [blame] | 784 | gtt_entries = 0; |
| 785 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 786 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 787 | intel_private.gtt_entries = gtt_entries; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 788 | } |
| 789 | |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 790 | static void intel_i830_fini_flush(void) |
| 791 | { |
| 792 | kunmap(intel_private.i8xx_page); |
| 793 | intel_private.i8xx_flush_page = NULL; |
| 794 | unmap_page_from_agp(intel_private.i8xx_page); |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 795 | |
| 796 | __free_page(intel_private.i8xx_page); |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 797 | intel_private.i8xx_page = NULL; |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 798 | } |
| 799 | |
| 800 | static void intel_i830_setup_flush(void) |
| 801 | { |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 802 | /* return if we've already set the flush mechanism up */ |
| 803 | if (intel_private.i8xx_page) |
| 804 | return; |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 805 | |
| 806 | intel_private.i8xx_page = alloc_page(GFP_KERNEL | __GFP_ZERO | GFP_DMA32); |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 807 | if (!intel_private.i8xx_page) |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 808 | return; |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 809 | |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 810 | intel_private.i8xx_flush_page = kmap(intel_private.i8xx_page); |
| 811 | if (!intel_private.i8xx_flush_page) |
| 812 | intel_i830_fini_flush(); |
| 813 | } |
| 814 | |
Eric Anholt | e517a5e | 2009-09-10 17:48:48 -0700 | [diff] [blame] | 815 | static void |
| 816 | do_wbinvd(void *null) |
| 817 | { |
| 818 | wbinvd(); |
| 819 | } |
| 820 | |
| 821 | /* The chipset_flush interface needs to get data that has already been |
| 822 | * flushed out of the CPU all the way out to main memory, because the GPU |
| 823 | * doesn't snoop those buffers. |
| 824 | * |
| 825 | * The 8xx series doesn't have the same lovely interface for flushing the |
| 826 | * chipset write buffers that the later chips do. According to the 865 |
| 827 | * specs, it's 64 octwords, or 1KB. So, to get those previous things in |
| 828 | * that buffer out, we just fill 1KB and clflush it out, on the assumption |
| 829 | * that it'll push whatever was in there out. It appears to work. |
| 830 | */ |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 831 | static void intel_i830_chipset_flush(struct agp_bridge_data *bridge) |
| 832 | { |
| 833 | unsigned int *pg = intel_private.i8xx_flush_page; |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 834 | |
Eric Anholt | e517a5e | 2009-09-10 17:48:48 -0700 | [diff] [blame] | 835 | memset(pg, 0, 1024); |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 836 | |
Eric Anholt | e517a5e | 2009-09-10 17:48:48 -0700 | [diff] [blame] | 837 | if (cpu_has_clflush) { |
| 838 | clflush_cache_range(pg, 1024); |
| 839 | } else { |
| 840 | if (on_each_cpu(do_wbinvd, NULL, 1) != 0) |
| 841 | printk(KERN_ERR "Timed out waiting for cache flush.\n"); |
| 842 | } |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 843 | } |
| 844 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 845 | /* The intel i830 automatically initializes the agp aperture during POST. |
| 846 | * Use the memory already set aside for in the GTT. |
| 847 | */ |
| 848 | static int intel_i830_create_gatt_table(struct agp_bridge_data *bridge) |
| 849 | { |
| 850 | int page_order; |
| 851 | struct aper_size_info_fixed *size; |
| 852 | int num_entries; |
| 853 | u32 temp; |
| 854 | |
| 855 | size = agp_bridge->current_size; |
| 856 | page_order = size->page_order; |
| 857 | num_entries = size->num_entries; |
| 858 | agp_bridge->gatt_table_real = NULL; |
| 859 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 860 | pci_read_config_dword(intel_private.pcidev, I810_MMADDR, &temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 861 | temp &= 0xfff80000; |
| 862 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 863 | intel_private.registers = ioremap(temp, 128 * 4096); |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 864 | if (!intel_private.registers) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 865 | return -ENOMEM; |
| 866 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 867 | temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 868 | global_cache_flush(); /* FIXME: ?? */ |
| 869 | |
| 870 | /* we have to call this as early as possible after the MMIO base address is known */ |
| 871 | intel_i830_init_gtt_entries(); |
| 872 | |
| 873 | agp_bridge->gatt_table = NULL; |
| 874 | |
| 875 | agp_bridge->gatt_bus_addr = temp; |
| 876 | |
| 877 | return 0; |
| 878 | } |
| 879 | |
| 880 | /* Return the gatt table to a sane state. Use the top of stolen |
| 881 | * memory for the GTT. |
| 882 | */ |
| 883 | static int intel_i830_free_gatt_table(struct agp_bridge_data *bridge) |
| 884 | { |
| 885 | return 0; |
| 886 | } |
| 887 | |
| 888 | static int intel_i830_fetch_size(void) |
| 889 | { |
| 890 | u16 gmch_ctrl; |
| 891 | struct aper_size_info_fixed *values; |
| 892 | |
| 893 | values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes); |
| 894 | |
| 895 | if (agp_bridge->dev->device != PCI_DEVICE_ID_INTEL_82830_HB && |
| 896 | agp_bridge->dev->device != PCI_DEVICE_ID_INTEL_82845G_HB) { |
| 897 | /* 855GM/852GM/865G has 128MB aperture size */ |
| 898 | agp_bridge->previous_size = agp_bridge->current_size = (void *) values; |
| 899 | agp_bridge->aperture_size_idx = 0; |
| 900 | return values[0].size; |
| 901 | } |
| 902 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 903 | pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 904 | |
| 905 | if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_128M) { |
| 906 | agp_bridge->previous_size = agp_bridge->current_size = (void *) values; |
| 907 | agp_bridge->aperture_size_idx = 0; |
| 908 | return values[0].size; |
| 909 | } else { |
| 910 | agp_bridge->previous_size = agp_bridge->current_size = (void *) (values + 1); |
| 911 | agp_bridge->aperture_size_idx = 1; |
| 912 | return values[1].size; |
| 913 | } |
| 914 | |
| 915 | return 0; |
| 916 | } |
| 917 | |
| 918 | static int intel_i830_configure(void) |
| 919 | { |
| 920 | struct aper_size_info_fixed *current_size; |
| 921 | u32 temp; |
| 922 | u16 gmch_ctrl; |
| 923 | int i; |
| 924 | |
| 925 | current_size = A_SIZE_FIX(agp_bridge->current_size); |
| 926 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 927 | pci_read_config_dword(intel_private.pcidev, I810_GMADDR, &temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 928 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 929 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 930 | pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 931 | gmch_ctrl |= I830_GMCH_ENABLED; |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 932 | pci_write_config_word(agp_bridge->dev, I830_GMCH_CTRL, gmch_ctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 933 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 934 | writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL); |
| 935 | readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 936 | |
| 937 | if (agp_bridge->driver->needs_scratch_page) { |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 938 | for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) { |
| 939 | writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 940 | } |
Keith Packard | 44d4944 | 2008-10-14 17:18:45 -0700 | [diff] [blame] | 941 | readl(intel_private.registers+I810_PTE_BASE+((i-1)*4)); /* PCI Posting. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 942 | } |
| 943 | |
| 944 | global_cache_flush(); |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 945 | |
| 946 | intel_i830_setup_flush(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | return 0; |
| 948 | } |
| 949 | |
| 950 | static void intel_i830_cleanup(void) |
| 951 | { |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 952 | iounmap(intel_private.registers); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 953 | } |
| 954 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 955 | static int intel_i830_insert_entries(struct agp_memory *mem, off_t pg_start, |
| 956 | int type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 957 | { |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 958 | int i, j, num_entries; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 959 | void *temp; |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 960 | int ret = -EINVAL; |
| 961 | int mask_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 962 | |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 963 | if (mem->page_count == 0) |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 964 | goto out; |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 965 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 966 | temp = agp_bridge->current_size; |
| 967 | num_entries = A_SIZE_FIX(temp)->num_entries; |
| 968 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 969 | if (pg_start < intel_private.gtt_entries) { |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 970 | dev_printk(KERN_DEBUG, &intel_private.pcidev->dev, |
| 971 | "pg_start == 0x%.8lx, intel_private.gtt_entries == 0x%.8x\n", |
| 972 | pg_start, intel_private.gtt_entries); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 973 | |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 974 | dev_info(&intel_private.pcidev->dev, |
| 975 | "trying to insert into local/stolen memory\n"); |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 976 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 977 | } |
| 978 | |
| 979 | if ((pg_start + mem->page_count) > num_entries) |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 980 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 981 | |
| 982 | /* The i830 can't check the GTT for entries since its read only, |
| 983 | * depend on the caller to make the correct offset decisions. |
| 984 | */ |
| 985 | |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 986 | if (type != mem->type) |
| 987 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 | |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 989 | mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type); |
| 990 | |
| 991 | if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY && |
| 992 | mask_type != INTEL_AGP_CACHED_MEMORY) |
| 993 | goto out_err; |
| 994 | |
| 995 | if (!mem->is_flushed) |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 996 | global_cache_flush(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 997 | |
| 998 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { |
| 999 | writel(agp_bridge->driver->mask_memory(agp_bridge, |
David Woodhouse | 6a12235 | 2009-07-29 10:25:58 +0100 | [diff] [blame] | 1000 | page_to_phys(mem->pages[i]), mask_type), |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1001 | intel_private.registers+I810_PTE_BASE+(j*4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1002 | } |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1003 | readl(intel_private.registers+I810_PTE_BASE+((j-1)*4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1004 | agp_bridge->driver->tlb_flush(mem); |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1005 | |
| 1006 | out: |
| 1007 | ret = 0; |
| 1008 | out_err: |
Dave Airlie | 9516b03 | 2008-06-19 10:42:17 +1000 | [diff] [blame] | 1009 | mem->is_flushed = true; |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1010 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1011 | } |
| 1012 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1013 | static int intel_i830_remove_entries(struct agp_memory *mem, off_t pg_start, |
| 1014 | int type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1015 | { |
| 1016 | int i; |
| 1017 | |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 1018 | if (mem->page_count == 0) |
| 1019 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1020 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1021 | if (pg_start < intel_private.gtt_entries) { |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 1022 | dev_info(&intel_private.pcidev->dev, |
| 1023 | "trying to disable local/stolen memory\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1024 | return -EINVAL; |
| 1025 | } |
| 1026 | |
| 1027 | for (i = pg_start; i < (mem->page_count + pg_start); i++) { |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1028 | writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | } |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1030 | readl(intel_private.registers+I810_PTE_BASE+((i-1)*4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1031 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1032 | agp_bridge->driver->tlb_flush(mem); |
| 1033 | return 0; |
| 1034 | } |
| 1035 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1036 | static struct agp_memory *intel_i830_alloc_by_type(size_t pg_count, int type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1037 | { |
| 1038 | if (type == AGP_PHYS_MEMORY) |
| 1039 | return alloc_agpphysmem_i8xx(pg_count, type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1040 | /* always return NULL for other allocation types for now */ |
| 1041 | return NULL; |
| 1042 | } |
| 1043 | |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 1044 | static int intel_alloc_chipset_flush_resource(void) |
| 1045 | { |
| 1046 | int ret; |
| 1047 | ret = pci_bus_alloc_resource(agp_bridge->dev->bus, &intel_private.ifp_resource, PAGE_SIZE, |
| 1048 | PAGE_SIZE, PCIBIOS_MIN_MEM, 0, |
| 1049 | pcibios_align_resource, agp_bridge->dev); |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 1050 | |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 1051 | return ret; |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 1052 | } |
| 1053 | |
| 1054 | static void intel_i915_setup_chipset_flush(void) |
| 1055 | { |
| 1056 | int ret; |
| 1057 | u32 temp; |
| 1058 | |
| 1059 | pci_read_config_dword(agp_bridge->dev, I915_IFPADDR, &temp); |
| 1060 | if (!(temp & 0x1)) { |
| 1061 | intel_alloc_chipset_flush_resource(); |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 1062 | intel_private.resource_valid = 1; |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 1063 | pci_write_config_dword(agp_bridge->dev, I915_IFPADDR, (intel_private.ifp_resource.start & 0xffffffff) | 0x1); |
| 1064 | } else { |
| 1065 | temp &= ~1; |
| 1066 | |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 1067 | intel_private.resource_valid = 1; |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 1068 | intel_private.ifp_resource.start = temp; |
| 1069 | intel_private.ifp_resource.end = temp + PAGE_SIZE; |
| 1070 | ret = request_resource(&iomem_resource, &intel_private.ifp_resource); |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 1071 | /* some BIOSes reserve this area in a pnp some don't */ |
| 1072 | if (ret) |
| 1073 | intel_private.resource_valid = 0; |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 1074 | } |
| 1075 | } |
| 1076 | |
| 1077 | static void intel_i965_g33_setup_chipset_flush(void) |
| 1078 | { |
| 1079 | u32 temp_hi, temp_lo; |
| 1080 | int ret; |
| 1081 | |
| 1082 | pci_read_config_dword(agp_bridge->dev, I965_IFPADDR + 4, &temp_hi); |
| 1083 | pci_read_config_dword(agp_bridge->dev, I965_IFPADDR, &temp_lo); |
| 1084 | |
| 1085 | if (!(temp_lo & 0x1)) { |
| 1086 | |
| 1087 | intel_alloc_chipset_flush_resource(); |
| 1088 | |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 1089 | intel_private.resource_valid = 1; |
Andrew Morton | 1fa4db7 | 2007-11-29 10:00:48 +1000 | [diff] [blame] | 1090 | pci_write_config_dword(agp_bridge->dev, I965_IFPADDR + 4, |
| 1091 | upper_32_bits(intel_private.ifp_resource.start)); |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 1092 | pci_write_config_dword(agp_bridge->dev, I965_IFPADDR, (intel_private.ifp_resource.start & 0xffffffff) | 0x1); |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 1093 | } else { |
| 1094 | u64 l64; |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1095 | |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 1096 | temp_lo &= ~0x1; |
| 1097 | l64 = ((u64)temp_hi << 32) | temp_lo; |
| 1098 | |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 1099 | intel_private.resource_valid = 1; |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 1100 | intel_private.ifp_resource.start = l64; |
| 1101 | intel_private.ifp_resource.end = l64 + PAGE_SIZE; |
| 1102 | ret = request_resource(&iomem_resource, &intel_private.ifp_resource); |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 1103 | /* some BIOSes reserve this area in a pnp some don't */ |
| 1104 | if (ret) |
| 1105 | intel_private.resource_valid = 0; |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 1106 | } |
| 1107 | } |
| 1108 | |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 1109 | static void intel_i9xx_setup_flush(void) |
| 1110 | { |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 1111 | /* return if already configured */ |
| 1112 | if (intel_private.ifp_resource.start) |
| 1113 | return; |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 1114 | |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 1115 | /* setup a resource for this object */ |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 1116 | intel_private.ifp_resource.name = "Intel Flush Page"; |
| 1117 | intel_private.ifp_resource.flags = IORESOURCE_MEM; |
| 1118 | |
| 1119 | /* Setup chipset flush for 915 */ |
Zhenyu Wang | 7d15ddf | 2008-06-20 11:48:06 +1000 | [diff] [blame] | 1120 | if (IS_I965 || IS_G33 || IS_G4X) { |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 1121 | intel_i965_g33_setup_chipset_flush(); |
| 1122 | } else { |
| 1123 | intel_i915_setup_chipset_flush(); |
| 1124 | } |
| 1125 | |
| 1126 | if (intel_private.ifp_resource.start) { |
| 1127 | intel_private.i9xx_flush_page = ioremap_nocache(intel_private.ifp_resource.start, PAGE_SIZE); |
| 1128 | if (!intel_private.i9xx_flush_page) |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 1129 | dev_info(&intel_private.pcidev->dev, "can't ioremap flush page - no chipset flushing"); |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 1130 | } |
| 1131 | } |
| 1132 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1133 | static int intel_i915_configure(void) |
| 1134 | { |
| 1135 | struct aper_size_info_fixed *current_size; |
| 1136 | u32 temp; |
| 1137 | u16 gmch_ctrl; |
| 1138 | int i; |
| 1139 | |
| 1140 | current_size = A_SIZE_FIX(agp_bridge->current_size); |
| 1141 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1142 | pci_read_config_dword(intel_private.pcidev, I915_GMADDR, &temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1143 | |
| 1144 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1145 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1146 | pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1147 | gmch_ctrl |= I830_GMCH_ENABLED; |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1148 | pci_write_config_word(agp_bridge->dev, I830_GMCH_CTRL, gmch_ctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1149 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1150 | writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL); |
| 1151 | readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1152 | |
| 1153 | if (agp_bridge->driver->needs_scratch_page) { |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1154 | for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) { |
| 1155 | writel(agp_bridge->scratch_page, intel_private.gtt+i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1156 | } |
Keith Packard | 44d4944 | 2008-10-14 17:18:45 -0700 | [diff] [blame] | 1157 | readl(intel_private.gtt+i-1); /* PCI Posting. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1158 | } |
| 1159 | |
| 1160 | global_cache_flush(); |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 1161 | |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 1162 | intel_i9xx_setup_flush(); |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1163 | |
David Woodhouse | ba3139f | 2009-08-05 08:12:40 +0100 | [diff] [blame] | 1164 | #ifdef USE_PCI_DMA_API |
| 1165 | if (pci_set_dma_mask(intel_private.pcidev, DMA_BIT_MASK(36))) |
| 1166 | dev_err(&intel_private.pcidev->dev, |
| 1167 | "set gfx device dma mask 36bit failed!\n"); |
| 1168 | #endif |
| 1169 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1170 | return 0; |
| 1171 | } |
| 1172 | |
| 1173 | static void intel_i915_cleanup(void) |
| 1174 | { |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 1175 | if (intel_private.i9xx_flush_page) |
| 1176 | iounmap(intel_private.i9xx_flush_page); |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 1177 | if (intel_private.resource_valid) |
| 1178 | release_resource(&intel_private.ifp_resource); |
| 1179 | intel_private.ifp_resource.start = 0; |
| 1180 | intel_private.resource_valid = 0; |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1181 | iounmap(intel_private.gtt); |
| 1182 | iounmap(intel_private.registers); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1183 | } |
| 1184 | |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 1185 | static void intel_i915_chipset_flush(struct agp_bridge_data *bridge) |
| 1186 | { |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 1187 | if (intel_private.i9xx_flush_page) |
| 1188 | writel(1, intel_private.i9xx_flush_page); |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 1189 | } |
| 1190 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1191 | static int intel_i915_insert_entries(struct agp_memory *mem, off_t pg_start, |
| 1192 | int type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1193 | { |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 1194 | int num_entries; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1195 | void *temp; |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1196 | int ret = -EINVAL; |
| 1197 | int mask_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1198 | |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 1199 | if (mem->page_count == 0) |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1200 | goto out; |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 1201 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1202 | temp = agp_bridge->current_size; |
| 1203 | num_entries = A_SIZE_FIX(temp)->num_entries; |
| 1204 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1205 | if (pg_start < intel_private.gtt_entries) { |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 1206 | dev_printk(KERN_DEBUG, &intel_private.pcidev->dev, |
| 1207 | "pg_start == 0x%.8lx, intel_private.gtt_entries == 0x%.8x\n", |
| 1208 | pg_start, intel_private.gtt_entries); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1209 | |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 1210 | dev_info(&intel_private.pcidev->dev, |
| 1211 | "trying to insert into local/stolen memory\n"); |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1212 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1213 | } |
| 1214 | |
| 1215 | if ((pg_start + mem->page_count) > num_entries) |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1216 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1217 | |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 1218 | /* The i915 can't check the GTT for entries since it's read only; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1219 | * depend on the caller to make the correct offset decisions. |
| 1220 | */ |
| 1221 | |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1222 | if (type != mem->type) |
| 1223 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1224 | |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1225 | mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type); |
| 1226 | |
| 1227 | if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY && |
| 1228 | mask_type != INTEL_AGP_CACHED_MEMORY) |
| 1229 | goto out_err; |
| 1230 | |
| 1231 | if (!mem->is_flushed) |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 1232 | global_cache_flush(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1233 | |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 1234 | intel_agp_insert_sg_entries(mem, pg_start, mask_type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1235 | agp_bridge->driver->tlb_flush(mem); |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1236 | |
| 1237 | out: |
| 1238 | ret = 0; |
| 1239 | out_err: |
Dave Airlie | 9516b03 | 2008-06-19 10:42:17 +1000 | [diff] [blame] | 1240 | mem->is_flushed = true; |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1241 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1242 | } |
| 1243 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1244 | static int intel_i915_remove_entries(struct agp_memory *mem, off_t pg_start, |
| 1245 | int type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1246 | { |
| 1247 | int i; |
| 1248 | |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 1249 | if (mem->page_count == 0) |
| 1250 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1251 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1252 | if (pg_start < intel_private.gtt_entries) { |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 1253 | dev_info(&intel_private.pcidev->dev, |
| 1254 | "trying to disable local/stolen memory\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1255 | return -EINVAL; |
| 1256 | } |
| 1257 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1258 | for (i = pg_start; i < (mem->page_count + pg_start); i++) |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1259 | writel(agp_bridge->scratch_page, intel_private.gtt+i); |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1260 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1261 | readl(intel_private.gtt+i-1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1262 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1263 | agp_bridge->driver->tlb_flush(mem); |
| 1264 | return 0; |
| 1265 | } |
| 1266 | |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 1267 | /* Return the aperture size by just checking the resource length. The effect |
| 1268 | * described in the spec of the MSAC registers is just changing of the |
| 1269 | * resource size. |
| 1270 | */ |
| 1271 | static int intel_i9xx_fetch_size(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1272 | { |
Ahmed S. Darwish | 1eaf122 | 2007-02-06 18:08:28 +0200 | [diff] [blame] | 1273 | int num_sizes = ARRAY_SIZE(intel_i830_sizes); |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 1274 | int aper_size; /* size in megabytes */ |
| 1275 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1276 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1277 | aper_size = pci_resource_len(intel_private.pcidev, 2) / MB(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1278 | |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 1279 | for (i = 0; i < num_sizes; i++) { |
| 1280 | if (aper_size == intel_i830_sizes[i].size) { |
| 1281 | agp_bridge->current_size = intel_i830_sizes + i; |
| 1282 | agp_bridge->previous_size = agp_bridge->current_size; |
| 1283 | return aper_size; |
| 1284 | } |
| 1285 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1286 | |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 1287 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1288 | } |
| 1289 | |
| 1290 | /* The intel i915 automatically initializes the agp aperture during POST. |
| 1291 | * Use the memory already set aside for in the GTT. |
| 1292 | */ |
| 1293 | static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge) |
| 1294 | { |
| 1295 | int page_order; |
| 1296 | struct aper_size_info_fixed *size; |
| 1297 | int num_entries; |
| 1298 | u32 temp, temp2; |
Zhenyu Wang | 4740622 | 2007-09-11 15:23:58 -0700 | [diff] [blame] | 1299 | int gtt_map_size = 256 * 1024; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1300 | |
| 1301 | size = agp_bridge->current_size; |
| 1302 | page_order = size->page_order; |
| 1303 | num_entries = size->num_entries; |
| 1304 | agp_bridge->gatt_table_real = NULL; |
| 1305 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1306 | pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &temp); |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1307 | pci_read_config_dword(intel_private.pcidev, I915_PTEADDR, &temp2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1308 | |
Zhenyu Wang | 4740622 | 2007-09-11 15:23:58 -0700 | [diff] [blame] | 1309 | if (IS_G33) |
| 1310 | gtt_map_size = 1024 * 1024; /* 1M on G33 */ |
| 1311 | intel_private.gtt = ioremap(temp2, gtt_map_size); |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1312 | if (!intel_private.gtt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1313 | return -ENOMEM; |
| 1314 | |
| 1315 | temp &= 0xfff80000; |
| 1316 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1317 | intel_private.registers = ioremap(temp, 128 * 4096); |
Scott Thompson | 5bdbc7d | 2007-08-25 18:14:00 +1000 | [diff] [blame] | 1318 | if (!intel_private.registers) { |
| 1319 | iounmap(intel_private.gtt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1320 | return -ENOMEM; |
Scott Thompson | 5bdbc7d | 2007-08-25 18:14:00 +1000 | [diff] [blame] | 1321 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1322 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1323 | temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1324 | global_cache_flush(); /* FIXME: ? */ |
| 1325 | |
| 1326 | /* we have to call this as early as possible after the MMIO base address is known */ |
| 1327 | intel_i830_init_gtt_entries(); |
| 1328 | |
| 1329 | agp_bridge->gatt_table = NULL; |
| 1330 | |
| 1331 | agp_bridge->gatt_bus_addr = temp; |
| 1332 | |
| 1333 | return 0; |
| 1334 | } |
Linus Torvalds | 7d915a3 | 2006-11-22 09:37:54 -0800 | [diff] [blame] | 1335 | |
| 1336 | /* |
| 1337 | * The i965 supports 36-bit physical addresses, but to keep |
| 1338 | * the format of the GTT the same, the bits that don't fit |
| 1339 | * in a 32-bit word are shifted down to bits 4..7. |
| 1340 | * |
| 1341 | * Gcc is smart enough to notice that "(addr >> 28) & 0xf0" |
| 1342 | * is always zero on 32-bit architectures, so no need to make |
| 1343 | * this conditional. |
| 1344 | */ |
| 1345 | static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge, |
David Woodhouse | 2a4ceb6 | 2009-07-27 10:27:29 +0100 | [diff] [blame] | 1346 | dma_addr_t addr, int type) |
Linus Torvalds | 7d915a3 | 2006-11-22 09:37:54 -0800 | [diff] [blame] | 1347 | { |
| 1348 | /* Shift high bits down */ |
| 1349 | addr |= (addr >> 28) & 0xf0; |
| 1350 | |
| 1351 | /* Type checking must be done elsewhere */ |
| 1352 | return addr | bridge->driver->masks[type].mask; |
| 1353 | } |
| 1354 | |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 1355 | static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size) |
| 1356 | { |
| 1357 | switch (agp_bridge->dev->device) { |
Zhenyu Wang | 99d32bd | 2008-07-30 12:26:50 -0700 | [diff] [blame] | 1358 | case PCI_DEVICE_ID_INTEL_GM45_HB: |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 1359 | case PCI_DEVICE_ID_INTEL_IGD_E_HB: |
| 1360 | case PCI_DEVICE_ID_INTEL_Q45_HB: |
| 1361 | case PCI_DEVICE_ID_INTEL_G45_HB: |
Zhenyu Wang | a50ccc6 | 2008-11-17 14:39:00 +0800 | [diff] [blame] | 1362 | case PCI_DEVICE_ID_INTEL_G41_HB: |
Fabian Henze | 38d8a95 | 2009-09-08 00:59:58 +0800 | [diff] [blame] | 1363 | case PCI_DEVICE_ID_INTEL_B43_HB: |
Zhenyu Wang | 32cb055 | 2009-06-05 15:38:36 +0800 | [diff] [blame] | 1364 | case PCI_DEVICE_ID_INTEL_IGDNG_D_HB: |
| 1365 | case PCI_DEVICE_ID_INTEL_IGDNG_M_HB: |
Zhenyu Wang | 07fb611 | 2009-08-13 18:57:29 +0800 | [diff] [blame] | 1366 | case PCI_DEVICE_ID_INTEL_IGDNG_MA_HB: |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 1367 | *gtt_offset = *gtt_size = MB(2); |
| 1368 | break; |
| 1369 | default: |
| 1370 | *gtt_offset = *gtt_size = KB(512); |
| 1371 | } |
| 1372 | } |
| 1373 | |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1374 | /* The intel i965 automatically initializes the agp aperture during POST. |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 1375 | * Use the memory already set aside for in the GTT. |
| 1376 | */ |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1377 | static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge) |
| 1378 | { |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1379 | int page_order; |
| 1380 | struct aper_size_info_fixed *size; |
| 1381 | int num_entries; |
| 1382 | u32 temp; |
| 1383 | int gtt_offset, gtt_size; |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1384 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1385 | size = agp_bridge->current_size; |
| 1386 | page_order = size->page_order; |
| 1387 | num_entries = size->num_entries; |
| 1388 | agp_bridge->gatt_table_real = NULL; |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1389 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1390 | pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &temp); |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1391 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1392 | temp &= 0xfff00000; |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1393 | |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 1394 | intel_i965_get_gtt_range(>t_offset, >t_size); |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1395 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1396 | intel_private.gtt = ioremap((temp + gtt_offset) , gtt_size); |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1397 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1398 | if (!intel_private.gtt) |
| 1399 | return -ENOMEM; |
Zhenyu Wang | 4e8b6e2 | 2008-01-23 14:54:37 +1000 | [diff] [blame] | 1400 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1401 | intel_private.registers = ioremap(temp, 128 * 4096); |
| 1402 | if (!intel_private.registers) { |
Scott Thompson | 5bdbc7d | 2007-08-25 18:14:00 +1000 | [diff] [blame] | 1403 | iounmap(intel_private.gtt); |
| 1404 | return -ENOMEM; |
| 1405 | } |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1406 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1407 | temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; |
| 1408 | global_cache_flush(); /* FIXME: ? */ |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1409 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1410 | /* we have to call this as early as possible after the MMIO base address is known */ |
| 1411 | intel_i830_init_gtt_entries(); |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1412 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1413 | agp_bridge->gatt_table = NULL; |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1414 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1415 | agp_bridge->gatt_bus_addr = temp; |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1416 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1417 | return 0; |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1418 | } |
| 1419 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1420 | |
| 1421 | static int intel_fetch_size(void) |
| 1422 | { |
| 1423 | int i; |
| 1424 | u16 temp; |
| 1425 | struct aper_size_info_16 *values; |
| 1426 | |
| 1427 | pci_read_config_word(agp_bridge->dev, INTEL_APSIZE, &temp); |
| 1428 | values = A_SIZE_16(agp_bridge->driver->aperture_sizes); |
| 1429 | |
| 1430 | for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) { |
| 1431 | if (temp == values[i].size_value) { |
| 1432 | agp_bridge->previous_size = agp_bridge->current_size = (void *) (values + i); |
| 1433 | agp_bridge->aperture_size_idx = i; |
| 1434 | return values[i].size; |
| 1435 | } |
| 1436 | } |
| 1437 | |
| 1438 | return 0; |
| 1439 | } |
| 1440 | |
| 1441 | static int __intel_8xx_fetch_size(u8 temp) |
| 1442 | { |
| 1443 | int i; |
| 1444 | struct aper_size_info_8 *values; |
| 1445 | |
| 1446 | values = A_SIZE_8(agp_bridge->driver->aperture_sizes); |
| 1447 | |
| 1448 | for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) { |
| 1449 | if (temp == values[i].size_value) { |
| 1450 | agp_bridge->previous_size = |
| 1451 | agp_bridge->current_size = (void *) (values + i); |
| 1452 | agp_bridge->aperture_size_idx = i; |
| 1453 | return values[i].size; |
| 1454 | } |
| 1455 | } |
| 1456 | return 0; |
| 1457 | } |
| 1458 | |
| 1459 | static int intel_8xx_fetch_size(void) |
| 1460 | { |
| 1461 | u8 temp; |
| 1462 | |
| 1463 | pci_read_config_byte(agp_bridge->dev, INTEL_APSIZE, &temp); |
| 1464 | return __intel_8xx_fetch_size(temp); |
| 1465 | } |
| 1466 | |
| 1467 | static int intel_815_fetch_size(void) |
| 1468 | { |
| 1469 | u8 temp; |
| 1470 | |
| 1471 | /* Intel 815 chipsets have a _weird_ APSIZE register with only |
| 1472 | * one non-reserved bit, so mask the others out ... */ |
| 1473 | pci_read_config_byte(agp_bridge->dev, INTEL_APSIZE, &temp); |
| 1474 | temp &= (1 << 3); |
| 1475 | |
| 1476 | return __intel_8xx_fetch_size(temp); |
| 1477 | } |
| 1478 | |
| 1479 | static void intel_tlbflush(struct agp_memory *mem) |
| 1480 | { |
| 1481 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2200); |
| 1482 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2280); |
| 1483 | } |
| 1484 | |
| 1485 | |
| 1486 | static void intel_8xx_tlbflush(struct agp_memory *mem) |
| 1487 | { |
| 1488 | u32 temp; |
| 1489 | pci_read_config_dword(agp_bridge->dev, INTEL_AGPCTRL, &temp); |
| 1490 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, temp & ~(1 << 7)); |
| 1491 | pci_read_config_dword(agp_bridge->dev, INTEL_AGPCTRL, &temp); |
| 1492 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, temp | (1 << 7)); |
| 1493 | } |
| 1494 | |
| 1495 | |
| 1496 | static void intel_cleanup(void) |
| 1497 | { |
| 1498 | u16 temp; |
| 1499 | struct aper_size_info_16 *previous_size; |
| 1500 | |
| 1501 | previous_size = A_SIZE_16(agp_bridge->previous_size); |
| 1502 | pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp); |
| 1503 | pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp & ~(1 << 9)); |
| 1504 | pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, previous_size->size_value); |
| 1505 | } |
| 1506 | |
| 1507 | |
| 1508 | static void intel_8xx_cleanup(void) |
| 1509 | { |
| 1510 | u16 temp; |
| 1511 | struct aper_size_info_8 *previous_size; |
| 1512 | |
| 1513 | previous_size = A_SIZE_8(agp_bridge->previous_size); |
| 1514 | pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp); |
| 1515 | pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp & ~(1 << 9)); |
| 1516 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, previous_size->size_value); |
| 1517 | } |
| 1518 | |
| 1519 | |
| 1520 | static int intel_configure(void) |
| 1521 | { |
| 1522 | u32 temp; |
| 1523 | u16 temp2; |
| 1524 | struct aper_size_info_16 *current_size; |
| 1525 | |
| 1526 | current_size = A_SIZE_16(agp_bridge->current_size); |
| 1527 | |
| 1528 | /* aperture size */ |
| 1529 | pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 1530 | |
| 1531 | /* address to map to */ |
| 1532 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 1533 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1534 | |
| 1535 | /* attbase - aperture base */ |
| 1536 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 1537 | |
| 1538 | /* agpctrl */ |
| 1539 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2280); |
| 1540 | |
| 1541 | /* paccfg/nbxcfg */ |
| 1542 | pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp2); |
| 1543 | pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, |
| 1544 | (temp2 & ~(1 << 10)) | (1 << 9)); |
| 1545 | /* clear any possible error conditions */ |
| 1546 | pci_write_config_byte(agp_bridge->dev, INTEL_ERRSTS + 1, 7); |
| 1547 | return 0; |
| 1548 | } |
| 1549 | |
| 1550 | static int intel_815_configure(void) |
| 1551 | { |
| 1552 | u32 temp, addr; |
| 1553 | u8 temp2; |
| 1554 | struct aper_size_info_8 *current_size; |
| 1555 | |
| 1556 | /* attbase - aperture base */ |
| 1557 | /* the Intel 815 chipset spec. says that bits 29-31 in the |
| 1558 | * ATTBASE register are reserved -> try not to write them */ |
| 1559 | if (agp_bridge->gatt_bus_addr & INTEL_815_ATTBASE_MASK) { |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 1560 | dev_emerg(&agp_bridge->dev->dev, "gatt bus addr too high"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1561 | return -EINVAL; |
| 1562 | } |
| 1563 | |
| 1564 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 1565 | |
| 1566 | /* aperture size */ |
| 1567 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, |
| 1568 | current_size->size_value); |
| 1569 | |
| 1570 | /* address to map to */ |
| 1571 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 1572 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1573 | |
| 1574 | pci_read_config_dword(agp_bridge->dev, INTEL_ATTBASE, &addr); |
| 1575 | addr &= INTEL_815_ATTBASE_MASK; |
| 1576 | addr |= agp_bridge->gatt_bus_addr; |
| 1577 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, addr); |
| 1578 | |
| 1579 | /* agpctrl */ |
| 1580 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 1581 | |
| 1582 | /* apcont */ |
| 1583 | pci_read_config_byte(agp_bridge->dev, INTEL_815_APCONT, &temp2); |
| 1584 | pci_write_config_byte(agp_bridge->dev, INTEL_815_APCONT, temp2 | (1 << 1)); |
| 1585 | |
| 1586 | /* clear any possible error conditions */ |
| 1587 | /* Oddness : this chipset seems to have no ERRSTS register ! */ |
| 1588 | return 0; |
| 1589 | } |
| 1590 | |
| 1591 | static void intel_820_tlbflush(struct agp_memory *mem) |
| 1592 | { |
| 1593 | return; |
| 1594 | } |
| 1595 | |
| 1596 | static void intel_820_cleanup(void) |
| 1597 | { |
| 1598 | u8 temp; |
| 1599 | struct aper_size_info_8 *previous_size; |
| 1600 | |
| 1601 | previous_size = A_SIZE_8(agp_bridge->previous_size); |
| 1602 | pci_read_config_byte(agp_bridge->dev, INTEL_I820_RDCR, &temp); |
| 1603 | pci_write_config_byte(agp_bridge->dev, INTEL_I820_RDCR, |
| 1604 | temp & ~(1 << 1)); |
| 1605 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, |
| 1606 | previous_size->size_value); |
| 1607 | } |
| 1608 | |
| 1609 | |
| 1610 | static int intel_820_configure(void) |
| 1611 | { |
| 1612 | u32 temp; |
| 1613 | u8 temp2; |
| 1614 | struct aper_size_info_8 *current_size; |
| 1615 | |
| 1616 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 1617 | |
| 1618 | /* aperture size */ |
| 1619 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 1620 | |
| 1621 | /* address to map to */ |
| 1622 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 1623 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1624 | |
| 1625 | /* attbase - aperture base */ |
| 1626 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 1627 | |
| 1628 | /* agpctrl */ |
| 1629 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 1630 | |
| 1631 | /* global enable aperture access */ |
| 1632 | /* This flag is not accessed through MCHCFG register as in */ |
| 1633 | /* i850 chipset. */ |
| 1634 | pci_read_config_byte(agp_bridge->dev, INTEL_I820_RDCR, &temp2); |
| 1635 | pci_write_config_byte(agp_bridge->dev, INTEL_I820_RDCR, temp2 | (1 << 1)); |
| 1636 | /* clear any possible AGP-related error conditions */ |
| 1637 | pci_write_config_word(agp_bridge->dev, INTEL_I820_ERRSTS, 0x001c); |
| 1638 | return 0; |
| 1639 | } |
| 1640 | |
| 1641 | static int intel_840_configure(void) |
| 1642 | { |
| 1643 | u32 temp; |
| 1644 | u16 temp2; |
| 1645 | struct aper_size_info_8 *current_size; |
| 1646 | |
| 1647 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 1648 | |
| 1649 | /* aperture size */ |
| 1650 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 1651 | |
| 1652 | /* address to map to */ |
| 1653 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 1654 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1655 | |
| 1656 | /* attbase - aperture base */ |
| 1657 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 1658 | |
| 1659 | /* agpctrl */ |
| 1660 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 1661 | |
| 1662 | /* mcgcfg */ |
| 1663 | pci_read_config_word(agp_bridge->dev, INTEL_I840_MCHCFG, &temp2); |
| 1664 | pci_write_config_word(agp_bridge->dev, INTEL_I840_MCHCFG, temp2 | (1 << 9)); |
| 1665 | /* clear any possible error conditions */ |
| 1666 | pci_write_config_word(agp_bridge->dev, INTEL_I840_ERRSTS, 0xc000); |
| 1667 | return 0; |
| 1668 | } |
| 1669 | |
| 1670 | static int intel_845_configure(void) |
| 1671 | { |
| 1672 | u32 temp; |
| 1673 | u8 temp2; |
| 1674 | struct aper_size_info_8 *current_size; |
| 1675 | |
| 1676 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 1677 | |
| 1678 | /* aperture size */ |
| 1679 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 1680 | |
Matthew Garrett | b082548 | 2005-07-29 14:03:39 -0700 | [diff] [blame] | 1681 | if (agp_bridge->apbase_config != 0) { |
| 1682 | pci_write_config_dword(agp_bridge->dev, AGP_APBASE, |
| 1683 | agp_bridge->apbase_config); |
| 1684 | } else { |
| 1685 | /* address to map to */ |
| 1686 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 1687 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1688 | agp_bridge->apbase_config = temp; |
| 1689 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1690 | |
| 1691 | /* attbase - aperture base */ |
| 1692 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 1693 | |
| 1694 | /* agpctrl */ |
| 1695 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 1696 | |
| 1697 | /* agpm */ |
| 1698 | pci_read_config_byte(agp_bridge->dev, INTEL_I845_AGPM, &temp2); |
| 1699 | pci_write_config_byte(agp_bridge->dev, INTEL_I845_AGPM, temp2 | (1 << 1)); |
| 1700 | /* clear any possible error conditions */ |
| 1701 | pci_write_config_word(agp_bridge->dev, INTEL_I845_ERRSTS, 0x001c); |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 1702 | |
| 1703 | intel_i830_setup_flush(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1704 | return 0; |
| 1705 | } |
| 1706 | |
| 1707 | static int intel_850_configure(void) |
| 1708 | { |
| 1709 | u32 temp; |
| 1710 | u16 temp2; |
| 1711 | struct aper_size_info_8 *current_size; |
| 1712 | |
| 1713 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 1714 | |
| 1715 | /* aperture size */ |
| 1716 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 1717 | |
| 1718 | /* address to map to */ |
| 1719 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 1720 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1721 | |
| 1722 | /* attbase - aperture base */ |
| 1723 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 1724 | |
| 1725 | /* agpctrl */ |
| 1726 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 1727 | |
| 1728 | /* mcgcfg */ |
| 1729 | pci_read_config_word(agp_bridge->dev, INTEL_I850_MCHCFG, &temp2); |
| 1730 | pci_write_config_word(agp_bridge->dev, INTEL_I850_MCHCFG, temp2 | (1 << 9)); |
| 1731 | /* clear any possible AGP-related error conditions */ |
| 1732 | pci_write_config_word(agp_bridge->dev, INTEL_I850_ERRSTS, 0x001c); |
| 1733 | return 0; |
| 1734 | } |
| 1735 | |
| 1736 | static int intel_860_configure(void) |
| 1737 | { |
| 1738 | u32 temp; |
| 1739 | u16 temp2; |
| 1740 | struct aper_size_info_8 *current_size; |
| 1741 | |
| 1742 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 1743 | |
| 1744 | /* aperture size */ |
| 1745 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 1746 | |
| 1747 | /* address to map to */ |
| 1748 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 1749 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1750 | |
| 1751 | /* attbase - aperture base */ |
| 1752 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 1753 | |
| 1754 | /* agpctrl */ |
| 1755 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 1756 | |
| 1757 | /* mcgcfg */ |
| 1758 | pci_read_config_word(agp_bridge->dev, INTEL_I860_MCHCFG, &temp2); |
| 1759 | pci_write_config_word(agp_bridge->dev, INTEL_I860_MCHCFG, temp2 | (1 << 9)); |
| 1760 | /* clear any possible AGP-related error conditions */ |
| 1761 | pci_write_config_word(agp_bridge->dev, INTEL_I860_ERRSTS, 0xf700); |
| 1762 | return 0; |
| 1763 | } |
| 1764 | |
| 1765 | static int intel_830mp_configure(void) |
| 1766 | { |
| 1767 | u32 temp; |
| 1768 | u16 temp2; |
| 1769 | struct aper_size_info_8 *current_size; |
| 1770 | |
| 1771 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 1772 | |
| 1773 | /* aperture size */ |
| 1774 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 1775 | |
| 1776 | /* address to map to */ |
| 1777 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 1778 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1779 | |
| 1780 | /* attbase - aperture base */ |
| 1781 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 1782 | |
| 1783 | /* agpctrl */ |
| 1784 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 1785 | |
| 1786 | /* gmch */ |
| 1787 | pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp2); |
| 1788 | pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp2 | (1 << 9)); |
| 1789 | /* clear any possible AGP-related error conditions */ |
| 1790 | pci_write_config_word(agp_bridge->dev, INTEL_I830_ERRSTS, 0x1c); |
| 1791 | return 0; |
| 1792 | } |
| 1793 | |
| 1794 | static int intel_7505_configure(void) |
| 1795 | { |
| 1796 | u32 temp; |
| 1797 | u16 temp2; |
| 1798 | struct aper_size_info_8 *current_size; |
| 1799 | |
| 1800 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 1801 | |
| 1802 | /* aperture size */ |
| 1803 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 1804 | |
| 1805 | /* address to map to */ |
| 1806 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 1807 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1808 | |
| 1809 | /* attbase - aperture base */ |
| 1810 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 1811 | |
| 1812 | /* agpctrl */ |
| 1813 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 1814 | |
| 1815 | /* mchcfg */ |
| 1816 | pci_read_config_word(agp_bridge->dev, INTEL_I7505_MCHCFG, &temp2); |
| 1817 | pci_write_config_word(agp_bridge->dev, INTEL_I7505_MCHCFG, temp2 | (1 << 9)); |
| 1818 | |
| 1819 | return 0; |
| 1820 | } |
| 1821 | |
| 1822 | /* Setup function */ |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1823 | static const struct gatt_mask intel_generic_masks[] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1824 | { |
| 1825 | {.mask = 0x00000017, .type = 0} |
| 1826 | }; |
| 1827 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1828 | static const struct aper_size_info_8 intel_815_sizes[2] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1829 | { |
| 1830 | {64, 16384, 4, 0}, |
| 1831 | {32, 8192, 3, 8}, |
| 1832 | }; |
| 1833 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1834 | static const struct aper_size_info_8 intel_8xx_sizes[7] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1835 | { |
| 1836 | {256, 65536, 6, 0}, |
| 1837 | {128, 32768, 5, 32}, |
| 1838 | {64, 16384, 4, 48}, |
| 1839 | {32, 8192, 3, 56}, |
| 1840 | {16, 4096, 2, 60}, |
| 1841 | {8, 2048, 1, 62}, |
| 1842 | {4, 1024, 0, 63} |
| 1843 | }; |
| 1844 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1845 | static const struct aper_size_info_16 intel_generic_sizes[7] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1846 | { |
| 1847 | {256, 65536, 6, 0}, |
| 1848 | {128, 32768, 5, 32}, |
| 1849 | {64, 16384, 4, 48}, |
| 1850 | {32, 8192, 3, 56}, |
| 1851 | {16, 4096, 2, 60}, |
| 1852 | {8, 2048, 1, 62}, |
| 1853 | {4, 1024, 0, 63} |
| 1854 | }; |
| 1855 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1856 | static const struct aper_size_info_8 intel_830mp_sizes[4] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1857 | { |
| 1858 | {256, 65536, 6, 0}, |
| 1859 | {128, 32768, 5, 32}, |
| 1860 | {64, 16384, 4, 48}, |
| 1861 | {32, 8192, 3, 56} |
| 1862 | }; |
| 1863 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1864 | static const struct agp_bridge_driver intel_generic_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1865 | .owner = THIS_MODULE, |
| 1866 | .aperture_sizes = intel_generic_sizes, |
| 1867 | .size_type = U16_APER_SIZE, |
| 1868 | .num_aperture_sizes = 7, |
| 1869 | .configure = intel_configure, |
| 1870 | .fetch_size = intel_fetch_size, |
| 1871 | .cleanup = intel_cleanup, |
| 1872 | .tlb_flush = intel_tlbflush, |
| 1873 | .mask_memory = agp_generic_mask_memory, |
| 1874 | .masks = intel_generic_masks, |
| 1875 | .agp_enable = agp_generic_enable, |
| 1876 | .cache_flush = global_cache_flush, |
| 1877 | .create_gatt_table = agp_generic_create_gatt_table, |
| 1878 | .free_gatt_table = agp_generic_free_gatt_table, |
| 1879 | .insert_memory = agp_generic_insert_memory, |
| 1880 | .remove_memory = agp_generic_remove_memory, |
| 1881 | .alloc_by_type = agp_generic_alloc_by_type, |
| 1882 | .free_by_type = agp_generic_free_by_type, |
| 1883 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 1884 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1885 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 1886 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1887 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1888 | }; |
| 1889 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1890 | static const struct agp_bridge_driver intel_810_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1891 | .owner = THIS_MODULE, |
| 1892 | .aperture_sizes = intel_i810_sizes, |
| 1893 | .size_type = FIXED_APER_SIZE, |
| 1894 | .num_aperture_sizes = 2, |
Joe Perches | c725801 | 2008-03-26 14:10:02 -0700 | [diff] [blame] | 1895 | .needs_scratch_page = true, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1896 | .configure = intel_i810_configure, |
| 1897 | .fetch_size = intel_i810_fetch_size, |
| 1898 | .cleanup = intel_i810_cleanup, |
| 1899 | .tlb_flush = intel_i810_tlbflush, |
| 1900 | .mask_memory = intel_i810_mask_memory, |
| 1901 | .masks = intel_i810_masks, |
| 1902 | .agp_enable = intel_i810_agp_enable, |
| 1903 | .cache_flush = global_cache_flush, |
| 1904 | .create_gatt_table = agp_generic_create_gatt_table, |
| 1905 | .free_gatt_table = agp_generic_free_gatt_table, |
| 1906 | .insert_memory = intel_i810_insert_entries, |
| 1907 | .remove_memory = intel_i810_remove_entries, |
| 1908 | .alloc_by_type = intel_i810_alloc_by_type, |
| 1909 | .free_by_type = intel_i810_free_by_type, |
| 1910 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 1911 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1912 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 1913 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1914 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1915 | }; |
| 1916 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1917 | static const struct agp_bridge_driver intel_815_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1918 | .owner = THIS_MODULE, |
| 1919 | .aperture_sizes = intel_815_sizes, |
| 1920 | .size_type = U8_APER_SIZE, |
| 1921 | .num_aperture_sizes = 2, |
| 1922 | .configure = intel_815_configure, |
| 1923 | .fetch_size = intel_815_fetch_size, |
| 1924 | .cleanup = intel_8xx_cleanup, |
| 1925 | .tlb_flush = intel_8xx_tlbflush, |
| 1926 | .mask_memory = agp_generic_mask_memory, |
| 1927 | .masks = intel_generic_masks, |
| 1928 | .agp_enable = agp_generic_enable, |
| 1929 | .cache_flush = global_cache_flush, |
| 1930 | .create_gatt_table = agp_generic_create_gatt_table, |
| 1931 | .free_gatt_table = agp_generic_free_gatt_table, |
| 1932 | .insert_memory = agp_generic_insert_memory, |
| 1933 | .remove_memory = agp_generic_remove_memory, |
| 1934 | .alloc_by_type = agp_generic_alloc_by_type, |
| 1935 | .free_by_type = agp_generic_free_by_type, |
| 1936 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 1937 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1938 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 1939 | .agp_destroy_pages = agp_generic_destroy_pages, |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1940 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1941 | }; |
| 1942 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1943 | static const struct agp_bridge_driver intel_830_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1944 | .owner = THIS_MODULE, |
| 1945 | .aperture_sizes = intel_i830_sizes, |
| 1946 | .size_type = FIXED_APER_SIZE, |
Dave Jones | c14635e | 2006-09-06 11:59:35 -0400 | [diff] [blame] | 1947 | .num_aperture_sizes = 4, |
Joe Perches | c725801 | 2008-03-26 14:10:02 -0700 | [diff] [blame] | 1948 | .needs_scratch_page = true, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1949 | .configure = intel_i830_configure, |
| 1950 | .fetch_size = intel_i830_fetch_size, |
| 1951 | .cleanup = intel_i830_cleanup, |
| 1952 | .tlb_flush = intel_i810_tlbflush, |
| 1953 | .mask_memory = intel_i810_mask_memory, |
| 1954 | .masks = intel_i810_masks, |
| 1955 | .agp_enable = intel_i810_agp_enable, |
| 1956 | .cache_flush = global_cache_flush, |
| 1957 | .create_gatt_table = intel_i830_create_gatt_table, |
| 1958 | .free_gatt_table = intel_i830_free_gatt_table, |
| 1959 | .insert_memory = intel_i830_insert_entries, |
| 1960 | .remove_memory = intel_i830_remove_entries, |
| 1961 | .alloc_by_type = intel_i830_alloc_by_type, |
| 1962 | .free_by_type = intel_i810_free_by_type, |
| 1963 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 1964 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1965 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 1966 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1967 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 1968 | .chipset_flush = intel_i830_chipset_flush, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1969 | }; |
| 1970 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1971 | static const struct agp_bridge_driver intel_820_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1972 | .owner = THIS_MODULE, |
| 1973 | .aperture_sizes = intel_8xx_sizes, |
| 1974 | .size_type = U8_APER_SIZE, |
| 1975 | .num_aperture_sizes = 7, |
| 1976 | .configure = intel_820_configure, |
| 1977 | .fetch_size = intel_8xx_fetch_size, |
| 1978 | .cleanup = intel_820_cleanup, |
| 1979 | .tlb_flush = intel_820_tlbflush, |
| 1980 | .mask_memory = agp_generic_mask_memory, |
| 1981 | .masks = intel_generic_masks, |
| 1982 | .agp_enable = agp_generic_enable, |
| 1983 | .cache_flush = global_cache_flush, |
| 1984 | .create_gatt_table = agp_generic_create_gatt_table, |
| 1985 | .free_gatt_table = agp_generic_free_gatt_table, |
| 1986 | .insert_memory = agp_generic_insert_memory, |
| 1987 | .remove_memory = agp_generic_remove_memory, |
| 1988 | .alloc_by_type = agp_generic_alloc_by_type, |
| 1989 | .free_by_type = agp_generic_free_by_type, |
| 1990 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 1991 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1992 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 1993 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1994 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1995 | }; |
| 1996 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1997 | static const struct agp_bridge_driver intel_830mp_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1998 | .owner = THIS_MODULE, |
| 1999 | .aperture_sizes = intel_830mp_sizes, |
| 2000 | .size_type = U8_APER_SIZE, |
| 2001 | .num_aperture_sizes = 4, |
| 2002 | .configure = intel_830mp_configure, |
| 2003 | .fetch_size = intel_8xx_fetch_size, |
| 2004 | .cleanup = intel_8xx_cleanup, |
| 2005 | .tlb_flush = intel_8xx_tlbflush, |
| 2006 | .mask_memory = agp_generic_mask_memory, |
| 2007 | .masks = intel_generic_masks, |
| 2008 | .agp_enable = agp_generic_enable, |
| 2009 | .cache_flush = global_cache_flush, |
| 2010 | .create_gatt_table = agp_generic_create_gatt_table, |
| 2011 | .free_gatt_table = agp_generic_free_gatt_table, |
| 2012 | .insert_memory = agp_generic_insert_memory, |
| 2013 | .remove_memory = agp_generic_remove_memory, |
| 2014 | .alloc_by_type = agp_generic_alloc_by_type, |
| 2015 | .free_by_type = agp_generic_free_by_type, |
| 2016 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 2017 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2018 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 2019 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 2020 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2021 | }; |
| 2022 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 2023 | static const struct agp_bridge_driver intel_840_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2024 | .owner = THIS_MODULE, |
| 2025 | .aperture_sizes = intel_8xx_sizes, |
| 2026 | .size_type = U8_APER_SIZE, |
| 2027 | .num_aperture_sizes = 7, |
| 2028 | .configure = intel_840_configure, |
| 2029 | .fetch_size = intel_8xx_fetch_size, |
| 2030 | .cleanup = intel_8xx_cleanup, |
| 2031 | .tlb_flush = intel_8xx_tlbflush, |
| 2032 | .mask_memory = agp_generic_mask_memory, |
| 2033 | .masks = intel_generic_masks, |
| 2034 | .agp_enable = agp_generic_enable, |
| 2035 | .cache_flush = global_cache_flush, |
| 2036 | .create_gatt_table = agp_generic_create_gatt_table, |
| 2037 | .free_gatt_table = agp_generic_free_gatt_table, |
| 2038 | .insert_memory = agp_generic_insert_memory, |
| 2039 | .remove_memory = agp_generic_remove_memory, |
| 2040 | .alloc_by_type = agp_generic_alloc_by_type, |
| 2041 | .free_by_type = agp_generic_free_by_type, |
| 2042 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 2043 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2044 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 2045 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 2046 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2047 | }; |
| 2048 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 2049 | static const struct agp_bridge_driver intel_845_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2050 | .owner = THIS_MODULE, |
| 2051 | .aperture_sizes = intel_8xx_sizes, |
| 2052 | .size_type = U8_APER_SIZE, |
| 2053 | .num_aperture_sizes = 7, |
| 2054 | .configure = intel_845_configure, |
| 2055 | .fetch_size = intel_8xx_fetch_size, |
| 2056 | .cleanup = intel_8xx_cleanup, |
| 2057 | .tlb_flush = intel_8xx_tlbflush, |
| 2058 | .mask_memory = agp_generic_mask_memory, |
| 2059 | .masks = intel_generic_masks, |
| 2060 | .agp_enable = agp_generic_enable, |
| 2061 | .cache_flush = global_cache_flush, |
| 2062 | .create_gatt_table = agp_generic_create_gatt_table, |
| 2063 | .free_gatt_table = agp_generic_free_gatt_table, |
| 2064 | .insert_memory = agp_generic_insert_memory, |
| 2065 | .remove_memory = agp_generic_remove_memory, |
| 2066 | .alloc_by_type = agp_generic_alloc_by_type, |
| 2067 | .free_by_type = agp_generic_free_by_type, |
| 2068 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 2069 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2070 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 2071 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 2072 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 2073 | .chipset_flush = intel_i830_chipset_flush, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2074 | }; |
| 2075 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 2076 | static const struct agp_bridge_driver intel_850_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2077 | .owner = THIS_MODULE, |
| 2078 | .aperture_sizes = intel_8xx_sizes, |
| 2079 | .size_type = U8_APER_SIZE, |
| 2080 | .num_aperture_sizes = 7, |
| 2081 | .configure = intel_850_configure, |
| 2082 | .fetch_size = intel_8xx_fetch_size, |
| 2083 | .cleanup = intel_8xx_cleanup, |
| 2084 | .tlb_flush = intel_8xx_tlbflush, |
| 2085 | .mask_memory = agp_generic_mask_memory, |
| 2086 | .masks = intel_generic_masks, |
| 2087 | .agp_enable = agp_generic_enable, |
| 2088 | .cache_flush = global_cache_flush, |
| 2089 | .create_gatt_table = agp_generic_create_gatt_table, |
| 2090 | .free_gatt_table = agp_generic_free_gatt_table, |
| 2091 | .insert_memory = agp_generic_insert_memory, |
| 2092 | .remove_memory = agp_generic_remove_memory, |
| 2093 | .alloc_by_type = agp_generic_alloc_by_type, |
| 2094 | .free_by_type = agp_generic_free_by_type, |
| 2095 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 2096 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2097 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 2098 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 2099 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2100 | }; |
| 2101 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 2102 | static const struct agp_bridge_driver intel_860_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2103 | .owner = THIS_MODULE, |
| 2104 | .aperture_sizes = intel_8xx_sizes, |
| 2105 | .size_type = U8_APER_SIZE, |
| 2106 | .num_aperture_sizes = 7, |
| 2107 | .configure = intel_860_configure, |
| 2108 | .fetch_size = intel_8xx_fetch_size, |
| 2109 | .cleanup = intel_8xx_cleanup, |
| 2110 | .tlb_flush = intel_8xx_tlbflush, |
| 2111 | .mask_memory = agp_generic_mask_memory, |
| 2112 | .masks = intel_generic_masks, |
| 2113 | .agp_enable = agp_generic_enable, |
| 2114 | .cache_flush = global_cache_flush, |
| 2115 | .create_gatt_table = agp_generic_create_gatt_table, |
| 2116 | .free_gatt_table = agp_generic_free_gatt_table, |
| 2117 | .insert_memory = agp_generic_insert_memory, |
| 2118 | .remove_memory = agp_generic_remove_memory, |
| 2119 | .alloc_by_type = agp_generic_alloc_by_type, |
| 2120 | .free_by_type = agp_generic_free_by_type, |
| 2121 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 2122 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2123 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 2124 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 2125 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2126 | }; |
| 2127 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 2128 | static const struct agp_bridge_driver intel_915_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2129 | .owner = THIS_MODULE, |
| 2130 | .aperture_sizes = intel_i830_sizes, |
| 2131 | .size_type = FIXED_APER_SIZE, |
Dave Jones | c14635e | 2006-09-06 11:59:35 -0400 | [diff] [blame] | 2132 | .num_aperture_sizes = 4, |
Joe Perches | c725801 | 2008-03-26 14:10:02 -0700 | [diff] [blame] | 2133 | .needs_scratch_page = true, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2134 | .configure = intel_i915_configure, |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 2135 | .fetch_size = intel_i9xx_fetch_size, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2136 | .cleanup = intel_i915_cleanup, |
| 2137 | .tlb_flush = intel_i810_tlbflush, |
| 2138 | .mask_memory = intel_i810_mask_memory, |
| 2139 | .masks = intel_i810_masks, |
| 2140 | .agp_enable = intel_i810_agp_enable, |
| 2141 | .cache_flush = global_cache_flush, |
| 2142 | .create_gatt_table = intel_i915_create_gatt_table, |
| 2143 | .free_gatt_table = intel_i830_free_gatt_table, |
| 2144 | .insert_memory = intel_i915_insert_entries, |
| 2145 | .remove_memory = intel_i915_remove_entries, |
| 2146 | .alloc_by_type = intel_i830_alloc_by_type, |
| 2147 | .free_by_type = intel_i810_free_by_type, |
| 2148 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 2149 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2150 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 2151 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 2152 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 2153 | .chipset_flush = intel_i915_chipset_flush, |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 2154 | #ifdef USE_PCI_DMA_API |
| 2155 | .agp_map_page = intel_agp_map_page, |
| 2156 | .agp_unmap_page = intel_agp_unmap_page, |
| 2157 | .agp_map_memory = intel_agp_map_memory, |
| 2158 | .agp_unmap_memory = intel_agp_unmap_memory, |
| 2159 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2160 | }; |
| 2161 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 2162 | static const struct agp_bridge_driver intel_i965_driver = { |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 2163 | .owner = THIS_MODULE, |
| 2164 | .aperture_sizes = intel_i830_sizes, |
| 2165 | .size_type = FIXED_APER_SIZE, |
| 2166 | .num_aperture_sizes = 4, |
| 2167 | .needs_scratch_page = true, |
Dave Airlie | 0e480e5 | 2008-06-19 14:57:31 +1000 | [diff] [blame] | 2168 | .configure = intel_i915_configure, |
| 2169 | .fetch_size = intel_i9xx_fetch_size, |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 2170 | .cleanup = intel_i915_cleanup, |
| 2171 | .tlb_flush = intel_i810_tlbflush, |
| 2172 | .mask_memory = intel_i965_mask_memory, |
| 2173 | .masks = intel_i810_masks, |
| 2174 | .agp_enable = intel_i810_agp_enable, |
| 2175 | .cache_flush = global_cache_flush, |
| 2176 | .create_gatt_table = intel_i965_create_gatt_table, |
| 2177 | .free_gatt_table = intel_i830_free_gatt_table, |
| 2178 | .insert_memory = intel_i915_insert_entries, |
| 2179 | .remove_memory = intel_i915_remove_entries, |
| 2180 | .alloc_by_type = intel_i830_alloc_by_type, |
| 2181 | .free_by_type = intel_i810_free_by_type, |
| 2182 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 2183 | .agp_alloc_pages = agp_generic_alloc_pages, |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 2184 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 2185 | .agp_destroy_pages = agp_generic_destroy_pages, |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 2186 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 2187 | .chipset_flush = intel_i915_chipset_flush, |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 2188 | #ifdef USE_PCI_DMA_API |
| 2189 | .agp_map_page = intel_agp_map_page, |
| 2190 | .agp_unmap_page = intel_agp_unmap_page, |
| 2191 | .agp_map_memory = intel_agp_map_memory, |
| 2192 | .agp_unmap_memory = intel_agp_unmap_memory, |
| 2193 | #endif |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 2194 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2195 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 2196 | static const struct agp_bridge_driver intel_7505_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2197 | .owner = THIS_MODULE, |
| 2198 | .aperture_sizes = intel_8xx_sizes, |
| 2199 | .size_type = U8_APER_SIZE, |
| 2200 | .num_aperture_sizes = 7, |
| 2201 | .configure = intel_7505_configure, |
| 2202 | .fetch_size = intel_8xx_fetch_size, |
| 2203 | .cleanup = intel_8xx_cleanup, |
| 2204 | .tlb_flush = intel_8xx_tlbflush, |
| 2205 | .mask_memory = agp_generic_mask_memory, |
| 2206 | .masks = intel_generic_masks, |
| 2207 | .agp_enable = agp_generic_enable, |
| 2208 | .cache_flush = global_cache_flush, |
| 2209 | .create_gatt_table = agp_generic_create_gatt_table, |
| 2210 | .free_gatt_table = agp_generic_free_gatt_table, |
| 2211 | .insert_memory = agp_generic_insert_memory, |
| 2212 | .remove_memory = agp_generic_remove_memory, |
| 2213 | .alloc_by_type = agp_generic_alloc_by_type, |
| 2214 | .free_by_type = agp_generic_free_by_type, |
| 2215 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 2216 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2217 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 2218 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 2219 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2220 | }; |
| 2221 | |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 2222 | static const struct agp_bridge_driver intel_g33_driver = { |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 2223 | .owner = THIS_MODULE, |
| 2224 | .aperture_sizes = intel_i830_sizes, |
| 2225 | .size_type = FIXED_APER_SIZE, |
| 2226 | .num_aperture_sizes = 4, |
| 2227 | .needs_scratch_page = true, |
| 2228 | .configure = intel_i915_configure, |
| 2229 | .fetch_size = intel_i9xx_fetch_size, |
| 2230 | .cleanup = intel_i915_cleanup, |
| 2231 | .tlb_flush = intel_i810_tlbflush, |
| 2232 | .mask_memory = intel_i965_mask_memory, |
| 2233 | .masks = intel_i810_masks, |
| 2234 | .agp_enable = intel_i810_agp_enable, |
| 2235 | .cache_flush = global_cache_flush, |
| 2236 | .create_gatt_table = intel_i915_create_gatt_table, |
| 2237 | .free_gatt_table = intel_i830_free_gatt_table, |
| 2238 | .insert_memory = intel_i915_insert_entries, |
| 2239 | .remove_memory = intel_i915_remove_entries, |
| 2240 | .alloc_by_type = intel_i830_alloc_by_type, |
| 2241 | .free_by_type = intel_i810_free_by_type, |
| 2242 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 2243 | .agp_alloc_pages = agp_generic_alloc_pages, |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 2244 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 2245 | .agp_destroy_pages = agp_generic_destroy_pages, |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 2246 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 2247 | .chipset_flush = intel_i915_chipset_flush, |
Zhenyu Wang | 1766168 | 2009-07-27 12:59:57 +0100 | [diff] [blame] | 2248 | #ifdef USE_PCI_DMA_API |
| 2249 | .agp_map_page = intel_agp_map_page, |
| 2250 | .agp_unmap_page = intel_agp_unmap_page, |
| 2251 | .agp_map_memory = intel_agp_map_memory, |
| 2252 | .agp_unmap_memory = intel_agp_unmap_memory, |
| 2253 | #endif |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 2254 | }; |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2255 | |
| 2256 | static int find_gmch(u16 device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2257 | { |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2258 | struct pci_dev *gmch_device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2259 | |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2260 | gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL); |
| 2261 | if (gmch_device && PCI_FUNC(gmch_device->devfn) != 0) { |
| 2262 | gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL, |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 2263 | device, gmch_device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2264 | } |
| 2265 | |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2266 | if (!gmch_device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2267 | return 0; |
| 2268 | |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2269 | intel_private.pcidev = gmch_device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2270 | return 1; |
| 2271 | } |
| 2272 | |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2273 | /* Table to describe Intel GMCH and AGP/PCIE GART drivers. At least one of |
| 2274 | * driver and gmch_driver must be non-null, and find_gmch will determine |
| 2275 | * which one should be used if a gmch_chip_id is present. |
| 2276 | */ |
| 2277 | static const struct intel_driver_description { |
| 2278 | unsigned int chip_id; |
| 2279 | unsigned int gmch_chip_id; |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2280 | unsigned int multi_gmch_chip; /* if we have more gfx chip type on this HB. */ |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2281 | char *name; |
| 2282 | const struct agp_bridge_driver *driver; |
| 2283 | const struct agp_bridge_driver *gmch_driver; |
| 2284 | } intel_agp_chipsets[] = { |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2285 | { PCI_DEVICE_ID_INTEL_82443LX_0, 0, 0, "440LX", &intel_generic_driver, NULL }, |
| 2286 | { PCI_DEVICE_ID_INTEL_82443BX_0, 0, 0, "440BX", &intel_generic_driver, NULL }, |
| 2287 | { PCI_DEVICE_ID_INTEL_82443GX_0, 0, 0, "440GX", &intel_generic_driver, NULL }, |
| 2288 | { PCI_DEVICE_ID_INTEL_82810_MC1, PCI_DEVICE_ID_INTEL_82810_IG1, 0, "i810", |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2289 | NULL, &intel_810_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2290 | { PCI_DEVICE_ID_INTEL_82810_MC3, PCI_DEVICE_ID_INTEL_82810_IG3, 0, "i810", |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2291 | NULL, &intel_810_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2292 | { PCI_DEVICE_ID_INTEL_82810E_MC, PCI_DEVICE_ID_INTEL_82810E_IG, 0, "i810", |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2293 | NULL, &intel_810_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2294 | { PCI_DEVICE_ID_INTEL_82815_MC, PCI_DEVICE_ID_INTEL_82815_CGC, 0, "i815", |
| 2295 | &intel_815_driver, &intel_810_driver }, |
| 2296 | { PCI_DEVICE_ID_INTEL_82820_HB, 0, 0, "i820", &intel_820_driver, NULL }, |
| 2297 | { PCI_DEVICE_ID_INTEL_82820_UP_HB, 0, 0, "i820", &intel_820_driver, NULL }, |
| 2298 | { PCI_DEVICE_ID_INTEL_82830_HB, PCI_DEVICE_ID_INTEL_82830_CGC, 0, "830M", |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2299 | &intel_830mp_driver, &intel_830_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2300 | { PCI_DEVICE_ID_INTEL_82840_HB, 0, 0, "i840", &intel_840_driver, NULL }, |
| 2301 | { PCI_DEVICE_ID_INTEL_82845_HB, 0, 0, "845G", &intel_845_driver, NULL }, |
| 2302 | { PCI_DEVICE_ID_INTEL_82845G_HB, PCI_DEVICE_ID_INTEL_82845G_IG, 0, "830M", |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2303 | &intel_845_driver, &intel_830_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2304 | { PCI_DEVICE_ID_INTEL_82850_HB, 0, 0, "i850", &intel_850_driver, NULL }, |
Stefan Husemann | 347486b | 2009-04-13 14:40:10 -0700 | [diff] [blame] | 2305 | { PCI_DEVICE_ID_INTEL_82854_HB, PCI_DEVICE_ID_INTEL_82854_IG, 0, "854", |
| 2306 | &intel_845_driver, &intel_830_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2307 | { PCI_DEVICE_ID_INTEL_82855PM_HB, 0, 0, "855PM", &intel_845_driver, NULL }, |
| 2308 | { PCI_DEVICE_ID_INTEL_82855GM_HB, PCI_DEVICE_ID_INTEL_82855GM_IG, 0, "855GM", |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2309 | &intel_845_driver, &intel_830_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2310 | { PCI_DEVICE_ID_INTEL_82860_HB, 0, 0, "i860", &intel_860_driver, NULL }, |
| 2311 | { PCI_DEVICE_ID_INTEL_82865_HB, PCI_DEVICE_ID_INTEL_82865_IG, 0, "865", |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2312 | &intel_845_driver, &intel_830_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2313 | { PCI_DEVICE_ID_INTEL_82875_HB, 0, 0, "i875", &intel_845_driver, NULL }, |
Carlos Martín | e914a36 | 2008-01-24 10:34:09 +1000 | [diff] [blame] | 2314 | { PCI_DEVICE_ID_INTEL_E7221_HB, PCI_DEVICE_ID_INTEL_E7221_IG, 0, "E7221 (i915)", |
| 2315 | NULL, &intel_915_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2316 | { PCI_DEVICE_ID_INTEL_82915G_HB, PCI_DEVICE_ID_INTEL_82915G_IG, 0, "915G", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2317 | NULL, &intel_915_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2318 | { PCI_DEVICE_ID_INTEL_82915GM_HB, PCI_DEVICE_ID_INTEL_82915GM_IG, 0, "915GM", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2319 | NULL, &intel_915_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2320 | { PCI_DEVICE_ID_INTEL_82945G_HB, PCI_DEVICE_ID_INTEL_82945G_IG, 0, "945G", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2321 | NULL, &intel_915_driver }, |
Zhenyu Wang | dde4787 | 2007-07-26 09:18:09 +0800 | [diff] [blame] | 2322 | { PCI_DEVICE_ID_INTEL_82945GM_HB, PCI_DEVICE_ID_INTEL_82945GM_IG, 0, "945GM", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2323 | NULL, &intel_915_driver }, |
Zhenyu Wang | dde4787 | 2007-07-26 09:18:09 +0800 | [diff] [blame] | 2324 | { PCI_DEVICE_ID_INTEL_82945GME_HB, PCI_DEVICE_ID_INTEL_82945GME_IG, 0, "945GME", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2325 | NULL, &intel_915_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2326 | { PCI_DEVICE_ID_INTEL_82946GZ_HB, PCI_DEVICE_ID_INTEL_82946GZ_IG, 0, "946GZ", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2327 | NULL, &intel_i965_driver }, |
Zhenyu Wang | 9119f85 | 2008-01-23 15:49:26 +1000 | [diff] [blame] | 2328 | { PCI_DEVICE_ID_INTEL_82G35_HB, PCI_DEVICE_ID_INTEL_82G35_IG, 0, "G35", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2329 | NULL, &intel_i965_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2330 | { PCI_DEVICE_ID_INTEL_82965Q_HB, PCI_DEVICE_ID_INTEL_82965Q_IG, 0, "965Q", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2331 | NULL, &intel_i965_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2332 | { PCI_DEVICE_ID_INTEL_82965G_HB, PCI_DEVICE_ID_INTEL_82965G_IG, 0, "965G", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2333 | NULL, &intel_i965_driver }, |
Zhenyu Wang | dde4787 | 2007-07-26 09:18:09 +0800 | [diff] [blame] | 2334 | { PCI_DEVICE_ID_INTEL_82965GM_HB, PCI_DEVICE_ID_INTEL_82965GM_IG, 0, "965GM", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2335 | NULL, &intel_i965_driver }, |
Zhenyu Wang | dde4787 | 2007-07-26 09:18:09 +0800 | [diff] [blame] | 2336 | { PCI_DEVICE_ID_INTEL_82965GME_HB, PCI_DEVICE_ID_INTEL_82965GME_IG, 0, "965GME/GLE", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2337 | NULL, &intel_i965_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2338 | { PCI_DEVICE_ID_INTEL_7505_0, 0, 0, "E7505", &intel_7505_driver, NULL }, |
| 2339 | { PCI_DEVICE_ID_INTEL_7205_0, 0, 0, "E7205", &intel_7505_driver, NULL }, |
| 2340 | { PCI_DEVICE_ID_INTEL_G33_HB, PCI_DEVICE_ID_INTEL_G33_IG, 0, "G33", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2341 | NULL, &intel_g33_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2342 | { PCI_DEVICE_ID_INTEL_Q35_HB, PCI_DEVICE_ID_INTEL_Q35_IG, 0, "Q35", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2343 | NULL, &intel_g33_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2344 | { PCI_DEVICE_ID_INTEL_Q33_HB, PCI_DEVICE_ID_INTEL_Q33_IG, 0, "Q33", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2345 | NULL, &intel_g33_driver }, |
Shaohua Li | 2177832 | 2009-02-23 15:19:16 +0800 | [diff] [blame] | 2346 | { PCI_DEVICE_ID_INTEL_IGDGM_HB, PCI_DEVICE_ID_INTEL_IGDGM_IG, 0, "IGD", |
| 2347 | NULL, &intel_g33_driver }, |
| 2348 | { PCI_DEVICE_ID_INTEL_IGDG_HB, PCI_DEVICE_ID_INTEL_IGDG_IG, 0, "IGD", |
| 2349 | NULL, &intel_g33_driver }, |
Zhenyu Wang | 99d32bd | 2008-07-30 12:26:50 -0700 | [diff] [blame] | 2350 | { PCI_DEVICE_ID_INTEL_GM45_HB, PCI_DEVICE_ID_INTEL_GM45_IG, 0, |
Eric Anholt | b854b2a | 2008-12-22 18:56:27 -0800 | [diff] [blame] | 2351 | "Mobile Intel® GM45 Express", NULL, &intel_i965_driver }, |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 2352 | { PCI_DEVICE_ID_INTEL_IGD_E_HB, PCI_DEVICE_ID_INTEL_IGD_E_IG, 0, |
| 2353 | "Intel Integrated Graphics Device", NULL, &intel_i965_driver }, |
| 2354 | { PCI_DEVICE_ID_INTEL_Q45_HB, PCI_DEVICE_ID_INTEL_Q45_IG, 0, |
| 2355 | "Q45/Q43", NULL, &intel_i965_driver }, |
| 2356 | { PCI_DEVICE_ID_INTEL_G45_HB, PCI_DEVICE_ID_INTEL_G45_IG, 0, |
| 2357 | "G45/G43", NULL, &intel_i965_driver }, |
Fabian Henze | 38d8a95 | 2009-09-08 00:59:58 +0800 | [diff] [blame] | 2358 | { PCI_DEVICE_ID_INTEL_B43_HB, PCI_DEVICE_ID_INTEL_B43_IG, 0, |
| 2359 | "B43", NULL, &intel_i965_driver }, |
Zhenyu Wang | a50ccc6 | 2008-11-17 14:39:00 +0800 | [diff] [blame] | 2360 | { PCI_DEVICE_ID_INTEL_G41_HB, PCI_DEVICE_ID_INTEL_G41_IG, 0, |
| 2361 | "G41", NULL, &intel_i965_driver }, |
Zhenyu Wang | 32cb055 | 2009-06-05 15:38:36 +0800 | [diff] [blame] | 2362 | { PCI_DEVICE_ID_INTEL_IGDNG_D_HB, PCI_DEVICE_ID_INTEL_IGDNG_D_IG, 0, |
| 2363 | "IGDNG/D", NULL, &intel_i965_driver }, |
| 2364 | { PCI_DEVICE_ID_INTEL_IGDNG_M_HB, PCI_DEVICE_ID_INTEL_IGDNG_M_IG, 0, |
| 2365 | "IGDNG/M", NULL, &intel_i965_driver }, |
Zhenyu Wang | 07fb611 | 2009-08-13 18:57:29 +0800 | [diff] [blame] | 2366 | { PCI_DEVICE_ID_INTEL_IGDNG_MA_HB, PCI_DEVICE_ID_INTEL_IGDNG_M_IG, 0, |
| 2367 | "IGDNG/MA", NULL, &intel_i965_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2368 | { 0, 0, 0, NULL, NULL, NULL } |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2369 | }; |
| 2370 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2371 | static int __devinit agp_intel_probe(struct pci_dev *pdev, |
| 2372 | const struct pci_device_id *ent) |
| 2373 | { |
| 2374 | struct agp_bridge_data *bridge; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2375 | u8 cap_ptr = 0; |
| 2376 | struct resource *r; |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2377 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2378 | |
| 2379 | cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP); |
| 2380 | |
| 2381 | bridge = agp_alloc_bridge(); |
| 2382 | if (!bridge) |
| 2383 | return -ENOMEM; |
| 2384 | |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2385 | for (i = 0; intel_agp_chipsets[i].name != NULL; i++) { |
| 2386 | /* In case that multiple models of gfx chip may |
| 2387 | stand on same host bridge type, this can be |
| 2388 | sure we detect the right IGD. */ |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2389 | if (pdev->device == intel_agp_chipsets[i].chip_id) { |
| 2390 | if ((intel_agp_chipsets[i].gmch_chip_id != 0) && |
| 2391 | find_gmch(intel_agp_chipsets[i].gmch_chip_id)) { |
| 2392 | bridge->driver = |
| 2393 | intel_agp_chipsets[i].gmch_driver; |
| 2394 | break; |
| 2395 | } else if (intel_agp_chipsets[i].multi_gmch_chip) { |
| 2396 | continue; |
| 2397 | } else { |
| 2398 | bridge->driver = intel_agp_chipsets[i].driver; |
| 2399 | break; |
| 2400 | } |
| 2401 | } |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2402 | } |
| 2403 | |
| 2404 | if (intel_agp_chipsets[i].name == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2405 | if (cap_ptr) |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 2406 | dev_warn(&pdev->dev, "unsupported Intel chipset [%04x/%04x]\n", |
| 2407 | pdev->vendor, pdev->device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2408 | agp_put_bridge(bridge); |
| 2409 | return -ENODEV; |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2410 | } |
| 2411 | |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2412 | if (bridge->driver == NULL) { |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2413 | /* bridge has no AGP and no IGD detected */ |
| 2414 | if (cap_ptr) |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 2415 | dev_warn(&pdev->dev, "can't find bridge device (chip_id: %04x)\n", |
| 2416 | intel_agp_chipsets[i].gmch_chip_id); |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2417 | agp_put_bridge(bridge); |
| 2418 | return -ENODEV; |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 2419 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2420 | |
| 2421 | bridge->dev = pdev; |
| 2422 | bridge->capndx = cap_ptr; |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 2423 | bridge->dev_private_data = &intel_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2424 | |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 2425 | dev_info(&pdev->dev, "Intel %s Chipset\n", intel_agp_chipsets[i].name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2426 | |
| 2427 | /* |
| 2428 | * The following fixes the case where the BIOS has "forgotten" to |
| 2429 | * provide an address range for the GART. |
| 2430 | * 20030610 - hamish@zot.org |
| 2431 | */ |
| 2432 | r = &pdev->resource[0]; |
| 2433 | if (!r->start && r->end) { |
Dave Jones | 6a92a4e | 2006-02-28 00:54:25 -0500 | [diff] [blame] | 2434 | if (pci_assign_resource(pdev, 0)) { |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 2435 | dev_err(&pdev->dev, "can't assign resource 0\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2436 | agp_put_bridge(bridge); |
| 2437 | return -ENODEV; |
| 2438 | } |
| 2439 | } |
| 2440 | |
| 2441 | /* |
| 2442 | * If the device has not been properly setup, the following will catch |
| 2443 | * the problem and should stop the system from crashing. |
| 2444 | * 20030610 - hamish@zot.org |
| 2445 | */ |
| 2446 | if (pci_enable_device(pdev)) { |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 2447 | dev_err(&pdev->dev, "can't enable PCI device\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2448 | agp_put_bridge(bridge); |
| 2449 | return -ENODEV; |
| 2450 | } |
| 2451 | |
| 2452 | /* Fill in the mode register */ |
| 2453 | if (cap_ptr) { |
| 2454 | pci_read_config_dword(pdev, |
| 2455 | bridge->capndx+PCI_AGP_STATUS, |
| 2456 | &bridge->mode); |
| 2457 | } |
| 2458 | |
| 2459 | pci_set_drvdata(pdev, bridge); |
| 2460 | return agp_add_bridge(bridge); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2461 | } |
| 2462 | |
| 2463 | static void __devexit agp_intel_remove(struct pci_dev *pdev) |
| 2464 | { |
| 2465 | struct agp_bridge_data *bridge = pci_get_drvdata(pdev); |
| 2466 | |
| 2467 | agp_remove_bridge(bridge); |
| 2468 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 2469 | if (intel_private.pcidev) |
| 2470 | pci_dev_put(intel_private.pcidev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2471 | |
| 2472 | agp_put_bridge(bridge); |
| 2473 | } |
| 2474 | |
Alexey Dobriyan | 85be7d6 | 2006-08-12 02:02:02 +0400 | [diff] [blame] | 2475 | #ifdef CONFIG_PM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2476 | static int agp_intel_resume(struct pci_dev *pdev) |
| 2477 | { |
| 2478 | struct agp_bridge_data *bridge = pci_get_drvdata(pdev); |
Keith Packard | a8c84df | 2008-07-31 15:48:07 +1000 | [diff] [blame] | 2479 | int ret_val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2480 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2481 | if (bridge->driver == &intel_generic_driver) |
| 2482 | intel_configure(); |
| 2483 | else if (bridge->driver == &intel_850_driver) |
| 2484 | intel_850_configure(); |
| 2485 | else if (bridge->driver == &intel_845_driver) |
| 2486 | intel_845_configure(); |
| 2487 | else if (bridge->driver == &intel_830mp_driver) |
| 2488 | intel_830mp_configure(); |
| 2489 | else if (bridge->driver == &intel_915_driver) |
| 2490 | intel_i915_configure(); |
| 2491 | else if (bridge->driver == &intel_830_driver) |
| 2492 | intel_i830_configure(); |
| 2493 | else if (bridge->driver == &intel_810_driver) |
| 2494 | intel_i810_configure(); |
Dave Jones | 08da3f4 | 2006-09-10 21:09:26 -0400 | [diff] [blame] | 2495 | else if (bridge->driver == &intel_i965_driver) |
| 2496 | intel_i915_configure(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2497 | |
Keith Packard | a8c84df | 2008-07-31 15:48:07 +1000 | [diff] [blame] | 2498 | ret_val = agp_rebind_memory(); |
| 2499 | if (ret_val != 0) |
| 2500 | return ret_val; |
| 2501 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2502 | return 0; |
| 2503 | } |
Alexey Dobriyan | 85be7d6 | 2006-08-12 02:02:02 +0400 | [diff] [blame] | 2504 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2505 | |
| 2506 | static struct pci_device_id agp_intel_pci_table[] = { |
| 2507 | #define ID(x) \ |
| 2508 | { \ |
| 2509 | .class = (PCI_CLASS_BRIDGE_HOST << 8), \ |
| 2510 | .class_mask = ~0, \ |
| 2511 | .vendor = PCI_VENDOR_ID_INTEL, \ |
| 2512 | .device = x, \ |
| 2513 | .subvendor = PCI_ANY_ID, \ |
| 2514 | .subdevice = PCI_ANY_ID, \ |
| 2515 | } |
| 2516 | ID(PCI_DEVICE_ID_INTEL_82443LX_0), |
| 2517 | ID(PCI_DEVICE_ID_INTEL_82443BX_0), |
| 2518 | ID(PCI_DEVICE_ID_INTEL_82443GX_0), |
| 2519 | ID(PCI_DEVICE_ID_INTEL_82810_MC1), |
| 2520 | ID(PCI_DEVICE_ID_INTEL_82810_MC3), |
| 2521 | ID(PCI_DEVICE_ID_INTEL_82810E_MC), |
| 2522 | ID(PCI_DEVICE_ID_INTEL_82815_MC), |
| 2523 | ID(PCI_DEVICE_ID_INTEL_82820_HB), |
| 2524 | ID(PCI_DEVICE_ID_INTEL_82820_UP_HB), |
| 2525 | ID(PCI_DEVICE_ID_INTEL_82830_HB), |
| 2526 | ID(PCI_DEVICE_ID_INTEL_82840_HB), |
| 2527 | ID(PCI_DEVICE_ID_INTEL_82845_HB), |
| 2528 | ID(PCI_DEVICE_ID_INTEL_82845G_HB), |
| 2529 | ID(PCI_DEVICE_ID_INTEL_82850_HB), |
Stefan Husemann | 347486b | 2009-04-13 14:40:10 -0700 | [diff] [blame] | 2530 | ID(PCI_DEVICE_ID_INTEL_82854_HB), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2531 | ID(PCI_DEVICE_ID_INTEL_82855PM_HB), |
| 2532 | ID(PCI_DEVICE_ID_INTEL_82855GM_HB), |
| 2533 | ID(PCI_DEVICE_ID_INTEL_82860_HB), |
| 2534 | ID(PCI_DEVICE_ID_INTEL_82865_HB), |
| 2535 | ID(PCI_DEVICE_ID_INTEL_82875_HB), |
| 2536 | ID(PCI_DEVICE_ID_INTEL_7505_0), |
| 2537 | ID(PCI_DEVICE_ID_INTEL_7205_0), |
Carlos Martín | e914a36 | 2008-01-24 10:34:09 +1000 | [diff] [blame] | 2538 | ID(PCI_DEVICE_ID_INTEL_E7221_HB), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2539 | ID(PCI_DEVICE_ID_INTEL_82915G_HB), |
| 2540 | ID(PCI_DEVICE_ID_INTEL_82915GM_HB), |
Alan Hourihane | d0de98f | 2005-05-31 19:50:49 +0100 | [diff] [blame] | 2541 | ID(PCI_DEVICE_ID_INTEL_82945G_HB), |
Alan Hourihane | 3b0e8ea | 2006-01-19 14:08:40 +0000 | [diff] [blame] | 2542 | ID(PCI_DEVICE_ID_INTEL_82945GM_HB), |
Zhenyu Wang | dde4787 | 2007-07-26 09:18:09 +0800 | [diff] [blame] | 2543 | ID(PCI_DEVICE_ID_INTEL_82945GME_HB), |
Shaohua Li | 2177832 | 2009-02-23 15:19:16 +0800 | [diff] [blame] | 2544 | ID(PCI_DEVICE_ID_INTEL_IGDGM_HB), |
| 2545 | ID(PCI_DEVICE_ID_INTEL_IGDG_HB), |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 2546 | ID(PCI_DEVICE_ID_INTEL_82946GZ_HB), |
Zhenyu Wang | 9119f85 | 2008-01-23 15:49:26 +1000 | [diff] [blame] | 2547 | ID(PCI_DEVICE_ID_INTEL_82G35_HB), |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 2548 | ID(PCI_DEVICE_ID_INTEL_82965Q_HB), |
| 2549 | ID(PCI_DEVICE_ID_INTEL_82965G_HB), |
Wang Zhenyu | 4598af3 | 2007-04-09 08:51:36 +0800 | [diff] [blame] | 2550 | ID(PCI_DEVICE_ID_INTEL_82965GM_HB), |
Zhenyu Wang | dde4787 | 2007-07-26 09:18:09 +0800 | [diff] [blame] | 2551 | ID(PCI_DEVICE_ID_INTEL_82965GME_HB), |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 2552 | ID(PCI_DEVICE_ID_INTEL_G33_HB), |
| 2553 | ID(PCI_DEVICE_ID_INTEL_Q35_HB), |
| 2554 | ID(PCI_DEVICE_ID_INTEL_Q33_HB), |
Zhenyu Wang | 99d32bd | 2008-07-30 12:26:50 -0700 | [diff] [blame] | 2555 | ID(PCI_DEVICE_ID_INTEL_GM45_HB), |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 2556 | ID(PCI_DEVICE_ID_INTEL_IGD_E_HB), |
| 2557 | ID(PCI_DEVICE_ID_INTEL_Q45_HB), |
| 2558 | ID(PCI_DEVICE_ID_INTEL_G45_HB), |
Zhenyu Wang | a50ccc6 | 2008-11-17 14:39:00 +0800 | [diff] [blame] | 2559 | ID(PCI_DEVICE_ID_INTEL_G41_HB), |
Fabian Henze | 38d8a95 | 2009-09-08 00:59:58 +0800 | [diff] [blame] | 2560 | ID(PCI_DEVICE_ID_INTEL_B43_HB), |
Zhenyu Wang | 32cb055 | 2009-06-05 15:38:36 +0800 | [diff] [blame] | 2561 | ID(PCI_DEVICE_ID_INTEL_IGDNG_D_HB), |
| 2562 | ID(PCI_DEVICE_ID_INTEL_IGDNG_M_HB), |
Zhenyu Wang | 07fb611 | 2009-08-13 18:57:29 +0800 | [diff] [blame] | 2563 | ID(PCI_DEVICE_ID_INTEL_IGDNG_MA_HB), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2564 | { } |
| 2565 | }; |
| 2566 | |
| 2567 | MODULE_DEVICE_TABLE(pci, agp_intel_pci_table); |
| 2568 | |
| 2569 | static struct pci_driver agp_intel_pci_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2570 | .name = "agpgart-intel", |
| 2571 | .id_table = agp_intel_pci_table, |
| 2572 | .probe = agp_intel_probe, |
| 2573 | .remove = __devexit_p(agp_intel_remove), |
Alexey Dobriyan | 85be7d6 | 2006-08-12 02:02:02 +0400 | [diff] [blame] | 2574 | #ifdef CONFIG_PM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2575 | .resume = agp_intel_resume, |
Alexey Dobriyan | 85be7d6 | 2006-08-12 02:02:02 +0400 | [diff] [blame] | 2576 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2577 | }; |
| 2578 | |
| 2579 | static int __init agp_intel_init(void) |
| 2580 | { |
| 2581 | if (agp_off) |
| 2582 | return -EINVAL; |
| 2583 | return pci_register_driver(&agp_intel_pci_driver); |
| 2584 | } |
| 2585 | |
| 2586 | static void __exit agp_intel_cleanup(void) |
| 2587 | { |
| 2588 | pci_unregister_driver(&agp_intel_pci_driver); |
| 2589 | } |
| 2590 | |
| 2591 | module_init(agp_intel_init); |
| 2592 | module_exit(agp_intel_cleanup); |
| 2593 | |
Dave Jones | f4432c5 | 2008-10-20 13:31:45 -0400 | [diff] [blame] | 2594 | MODULE_AUTHOR("Dave Jones <davej@redhat.com>"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2595 | MODULE_LICENSE("GPL and additional rights"); |