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