2 * Intel AGPGART routines.
5 #include <linux/module.h>
7 #include <linux/init.h>
8 #include <linux/kernel.h>
9 #include <linux/pagemap.h>
10 #include <linux/agp_backend.h>
14 * If we have Intel graphics, we're not going to have anything other than
15 * an Intel IOMMU. So make the correct use of the PCI DMA API contingent
16 * on the Intel IOMMU support (CONFIG_DMAR).
17 * Only newer chipsets need to bother with this, of course.
20 #define USE_PCI_DMA_API 1
23 #define PCI_DEVICE_ID_INTEL_E7221_HB 0x2588
24 #define PCI_DEVICE_ID_INTEL_E7221_IG 0x258a
25 #define PCI_DEVICE_ID_INTEL_82946GZ_HB 0x2970
26 #define PCI_DEVICE_ID_INTEL_82946GZ_IG 0x2972
27 #define PCI_DEVICE_ID_INTEL_82G35_HB 0x2980
28 #define PCI_DEVICE_ID_INTEL_82G35_IG 0x2982
29 #define PCI_DEVICE_ID_INTEL_82965Q_HB 0x2990
30 #define PCI_DEVICE_ID_INTEL_82965Q_IG 0x2992
31 #define PCI_DEVICE_ID_INTEL_82965G_HB 0x29A0
32 #define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2
33 #define PCI_DEVICE_ID_INTEL_82965GM_HB 0x2A00
34 #define PCI_DEVICE_ID_INTEL_82965GM_IG 0x2A02
35 #define PCI_DEVICE_ID_INTEL_82965GME_HB 0x2A10
36 #define PCI_DEVICE_ID_INTEL_82965GME_IG 0x2A12
37 #define PCI_DEVICE_ID_INTEL_82945GME_HB 0x27AC
38 #define PCI_DEVICE_ID_INTEL_82945GME_IG 0x27AE
39 #define PCI_DEVICE_ID_INTEL_IGDGM_HB 0xA010
40 #define PCI_DEVICE_ID_INTEL_IGDGM_IG 0xA011
41 #define PCI_DEVICE_ID_INTEL_IGDG_HB 0xA000
42 #define PCI_DEVICE_ID_INTEL_IGDG_IG 0xA001
43 #define PCI_DEVICE_ID_INTEL_G33_HB 0x29C0
44 #define PCI_DEVICE_ID_INTEL_G33_IG 0x29C2
45 #define PCI_DEVICE_ID_INTEL_Q35_HB 0x29B0
46 #define PCI_DEVICE_ID_INTEL_Q35_IG 0x29B2
47 #define PCI_DEVICE_ID_INTEL_Q33_HB 0x29D0
48 #define PCI_DEVICE_ID_INTEL_Q33_IG 0x29D2
49 #define PCI_DEVICE_ID_INTEL_B43_HB 0x2E40
50 #define PCI_DEVICE_ID_INTEL_B43_IG 0x2E42
51 #define PCI_DEVICE_ID_INTEL_GM45_HB 0x2A40
52 #define PCI_DEVICE_ID_INTEL_GM45_IG 0x2A42
53 #define PCI_DEVICE_ID_INTEL_IGD_E_HB 0x2E00
54 #define PCI_DEVICE_ID_INTEL_IGD_E_IG 0x2E02
55 #define PCI_DEVICE_ID_INTEL_Q45_HB 0x2E10
56 #define PCI_DEVICE_ID_INTEL_Q45_IG 0x2E12
57 #define PCI_DEVICE_ID_INTEL_G45_HB 0x2E20
58 #define PCI_DEVICE_ID_INTEL_G45_IG 0x2E22
59 #define PCI_DEVICE_ID_INTEL_G41_HB 0x2E30
60 #define PCI_DEVICE_ID_INTEL_G41_IG 0x2E32
61 #define PCI_DEVICE_ID_INTEL_IGDNG_D_HB 0x0040
62 #define PCI_DEVICE_ID_INTEL_IGDNG_D_IG 0x0042
63 #define PCI_DEVICE_ID_INTEL_IGDNG_M_HB 0x0044
64 #define PCI_DEVICE_ID_INTEL_IGDNG_MA_HB 0x0062
65 #define PCI_DEVICE_ID_INTEL_IGDNG_M_IG 0x0046
67 /* cover 915 and 945 variants */
68 #define IS_I915 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_E7221_HB || \
69 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || \
70 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || \
71 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || \
72 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || \
73 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GME_HB)
75 #define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \
76 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82G35_HB || \
77 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965Q_HB || \
78 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \
79 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB || \
80 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GME_HB)
82 #define IS_G33 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G33_HB || \
83 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q35_HB || \
84 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q33_HB || \
85 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGDGM_HB || \
86 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGDG_HB)
88 #define IS_IGD (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGDGM_HB || \
89 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGDG_HB)
91 #define IS_G4X (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGD_E_HB || \
92 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q45_HB || \
93 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G45_HB || \
94 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_GM45_HB || \
95 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G41_HB || \
96 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_B43_HB || \
97 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGDNG_D_HB || \
98 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGDNG_M_HB || \
99 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGDNG_MA_HB)
101 extern int agp_memory_reserved;
104 /* Intel 815 register */
105 #define INTEL_815_APCONT 0x51
106 #define INTEL_815_ATTBASE_MASK ~0x1FFFFFFF
108 /* Intel i820 registers */
109 #define INTEL_I820_RDCR 0x51
110 #define INTEL_I820_ERRSTS 0xc8
112 /* Intel i840 registers */
113 #define INTEL_I840_MCHCFG 0x50
114 #define INTEL_I840_ERRSTS 0xc8
116 /* Intel i850 registers */
117 #define INTEL_I850_MCHCFG 0x50
118 #define INTEL_I850_ERRSTS 0xc8
120 /* intel 915G registers */
121 #define I915_GMADDR 0x18
122 #define I915_MMADDR 0x10
123 #define I915_PTEADDR 0x1C
124 #define I915_GMCH_GMS_STOLEN_48M (0x6 << 4)
125 #define I915_GMCH_GMS_STOLEN_64M (0x7 << 4)
126 #define G33_GMCH_GMS_STOLEN_128M (0x8 << 4)
127 #define G33_GMCH_GMS_STOLEN_256M (0x9 << 4)
128 #define INTEL_GMCH_GMS_STOLEN_96M (0xa << 4)
129 #define INTEL_GMCH_GMS_STOLEN_160M (0xb << 4)
130 #define INTEL_GMCH_GMS_STOLEN_224M (0xc << 4)
131 #define INTEL_GMCH_GMS_STOLEN_352M (0xd << 4)
133 #define I915_IFPADDR 0x60
135 /* Intel 965G registers */
136 #define I965_MSAC 0x62
137 #define I965_IFPADDR 0x70
139 /* Intel 7505 registers */
140 #define INTEL_I7505_APSIZE 0x74
141 #define INTEL_I7505_NCAPID 0x60
142 #define INTEL_I7505_NISTAT 0x6c
143 #define INTEL_I7505_ATTBASE 0x78
144 #define INTEL_I7505_ERRSTS 0x42
145 #define INTEL_I7505_AGPCTRL 0x70
146 #define INTEL_I7505_MCHCFG 0x50
148 static const struct aper_size_info_fixed intel_i810_sizes[] =
151 /* The 32M mode still requires a 64k gatt */
155 #define AGP_DCACHE_MEMORY 1
156 #define AGP_PHYS_MEMORY 2
157 #define INTEL_AGP_CACHED_MEMORY 3
159 static struct gatt_mask intel_i810_masks[] =
161 {.mask = I810_PTE_VALID, .type = 0},
162 {.mask = (I810_PTE_VALID | I810_PTE_LOCAL), .type = AGP_DCACHE_MEMORY},
163 {.mask = I810_PTE_VALID, .type = 0},
164 {.mask = I810_PTE_VALID | I830_PTE_SYSTEM_CACHED,
165 .type = INTEL_AGP_CACHED_MEMORY}
168 static struct _intel_private {
169 struct pci_dev *pcidev; /* device one */
170 u8 __iomem *registers;
171 u32 __iomem *gtt; /* I915G */
172 int num_dcache_entries;
173 /* gtt_entries is the number of gtt entries that are already mapped
174 * to stolen memory. Stolen memory is larger than the memory mapped
175 * through gtt_entries, as it includes some reserved space for the BIOS
176 * popup and for the GTT.
178 int gtt_entries; /* i830+ */
180 void __iomem *i9xx_flush_page;
181 void *i8xx_flush_page;
183 struct page *i8xx_page;
184 struct resource ifp_resource;
188 #ifdef USE_PCI_DMA_API
189 static int intel_agp_map_page(struct page *page, dma_addr_t *ret)
191 *ret = pci_map_page(intel_private.pcidev, page, 0,
192 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
193 if (pci_dma_mapping_error(intel_private.pcidev, *ret))
198 static void intel_agp_unmap_page(struct page *page, dma_addr_t dma)
200 pci_unmap_page(intel_private.pcidev, dma,
201 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
204 static void intel_agp_free_sglist(struct agp_memory *mem)
208 st.sgl = mem->sg_list;
209 st.orig_nents = st.nents = mem->page_count;
217 static int intel_agp_map_memory(struct agp_memory *mem)
220 struct scatterlist *sg;
223 DBG("try mapping %lu pages\n", (unsigned long)mem->page_count);
225 if (sg_alloc_table(&st, mem->page_count, GFP_KERNEL))
228 mem->sg_list = sg = st.sgl;
230 for (i = 0 ; i < mem->page_count; i++, sg = sg_next(sg))
231 sg_set_page(sg, mem->pages[i], PAGE_SIZE, 0);
233 mem->num_sg = pci_map_sg(intel_private.pcidev, mem->sg_list,
234 mem->page_count, PCI_DMA_BIDIRECTIONAL);
235 if (unlikely(!mem->num_sg)) {
236 intel_agp_free_sglist(mem);
242 static void intel_agp_unmap_memory(struct agp_memory *mem)
244 DBG("try unmapping %lu pages\n", (unsigned long)mem->page_count);
246 pci_unmap_sg(intel_private.pcidev, mem->sg_list,
247 mem->page_count, PCI_DMA_BIDIRECTIONAL);
248 intel_agp_free_sglist(mem);
251 static void intel_agp_insert_sg_entries(struct agp_memory *mem,
252 off_t pg_start, int mask_type)
254 struct scatterlist *sg;
259 WARN_ON(!mem->num_sg);
261 if (mem->num_sg == mem->page_count) {
262 for_each_sg(mem->sg_list, sg, mem->page_count, i) {
263 writel(agp_bridge->driver->mask_memory(agp_bridge,
264 sg_dma_address(sg), mask_type),
265 intel_private.gtt+j);
269 /* sg may merge pages, but we have to seperate
270 * per-page addr for GTT */
273 for_each_sg(mem->sg_list, sg, mem->num_sg, i) {
274 len = sg_dma_len(sg) / PAGE_SIZE;
275 for (m = 0; m < len; m++) {
276 writel(agp_bridge->driver->mask_memory(agp_bridge,
277 sg_dma_address(sg) + m * PAGE_SIZE,
279 intel_private.gtt+j);
284 readl(intel_private.gtt+j-1);
289 static void intel_agp_insert_sg_entries(struct agp_memory *mem,
290 off_t pg_start, int mask_type)
294 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
295 writel(agp_bridge->driver->mask_memory(agp_bridge,
296 page_to_phys(mem->pages[i]), mask_type),
297 intel_private.gtt+j);
300 readl(intel_private.gtt+j-1);
305 static int intel_i810_fetch_size(void)
308 struct aper_size_info_fixed *values;
310 pci_read_config_dword(agp_bridge->dev, I810_SMRAM_MISCC, &smram_miscc);
311 values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes);
313 if ((smram_miscc & I810_GMS) == I810_GMS_DISABLE) {
314 dev_warn(&agp_bridge->dev->dev, "i810 is disabled\n");
317 if ((smram_miscc & I810_GFX_MEM_WIN_SIZE) == I810_GFX_MEM_WIN_32M) {
318 agp_bridge->previous_size =
319 agp_bridge->current_size = (void *) (values + 1);
320 agp_bridge->aperture_size_idx = 1;
321 return values[1].size;
323 agp_bridge->previous_size =
324 agp_bridge->current_size = (void *) (values);
325 agp_bridge->aperture_size_idx = 0;
326 return values[0].size;
332 static int intel_i810_configure(void)
334 struct aper_size_info_fixed *current_size;
338 current_size = A_SIZE_FIX(agp_bridge->current_size);
340 if (!intel_private.registers) {
341 pci_read_config_dword(intel_private.pcidev, I810_MMADDR, &temp);
344 intel_private.registers = ioremap(temp, 128 * 4096);
345 if (!intel_private.registers) {
346 dev_err(&intel_private.pcidev->dev,
347 "can't remap memory\n");
352 if ((readl(intel_private.registers+I810_DRAM_CTL)
353 & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) {
354 /* This will need to be dynamically assigned */
355 dev_info(&intel_private.pcidev->dev,
356 "detected 4MB dedicated video ram\n");
357 intel_private.num_dcache_entries = 1024;
359 pci_read_config_dword(intel_private.pcidev, I810_GMADDR, &temp);
360 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
361 writel(agp_bridge->gatt_bus_addr | I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL);
362 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
364 if (agp_bridge->driver->needs_scratch_page) {
365 for (i = 0; i < current_size->num_entries; i++) {
366 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
368 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4)); /* PCI posting. */
370 global_cache_flush();
374 static void intel_i810_cleanup(void)
376 writel(0, intel_private.registers+I810_PGETBL_CTL);
377 readl(intel_private.registers); /* PCI Posting. */
378 iounmap(intel_private.registers);
381 static void intel_i810_tlbflush(struct agp_memory *mem)
386 static void intel_i810_agp_enable(struct agp_bridge_data *bridge, u32 mode)
391 /* Exists to support ARGB cursors */
392 static struct page *i8xx_alloc_pages(void)
396 page = alloc_pages(GFP_KERNEL | GFP_DMA32, 2);
400 if (set_pages_uc(page, 4) < 0) {
401 set_pages_wb(page, 4);
402 __free_pages(page, 2);
406 atomic_inc(&agp_bridge->current_memory_agp);
410 static void i8xx_destroy_pages(struct page *page)
415 set_pages_wb(page, 4);
417 __free_pages(page, 2);
418 atomic_dec(&agp_bridge->current_memory_agp);
421 static int intel_i830_type_to_mask_type(struct agp_bridge_data *bridge,
424 if (type < AGP_USER_TYPES)
426 else if (type == AGP_USER_CACHED_MEMORY)
427 return INTEL_AGP_CACHED_MEMORY;
432 static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
435 int i, j, num_entries;
440 if (mem->page_count == 0)
443 temp = agp_bridge->current_size;
444 num_entries = A_SIZE_FIX(temp)->num_entries;
446 if ((pg_start + mem->page_count) > num_entries)
450 for (j = pg_start; j < (pg_start + mem->page_count); j++) {
451 if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+j))) {
457 if (type != mem->type)
460 mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
463 case AGP_DCACHE_MEMORY:
464 if (!mem->is_flushed)
465 global_cache_flush();
466 for (i = pg_start; i < (pg_start + mem->page_count); i++) {
467 writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID,
468 intel_private.registers+I810_PTE_BASE+(i*4));
470 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4));
472 case AGP_PHYS_MEMORY:
473 case AGP_NORMAL_MEMORY:
474 if (!mem->is_flushed)
475 global_cache_flush();
476 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
477 writel(agp_bridge->driver->mask_memory(agp_bridge,
478 page_to_phys(mem->pages[i]), mask_type),
479 intel_private.registers+I810_PTE_BASE+(j*4));
481 readl(intel_private.registers+I810_PTE_BASE+((j-1)*4));
487 agp_bridge->driver->tlb_flush(mem);
491 mem->is_flushed = true;
495 static int intel_i810_remove_entries(struct agp_memory *mem, off_t pg_start,
500 if (mem->page_count == 0)
503 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
504 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
506 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4));
508 agp_bridge->driver->tlb_flush(mem);
513 * The i810/i830 requires a physical address to program its mouse
514 * pointer into hardware.
515 * However the Xserver still writes to it through the agp aperture.
517 static struct agp_memory *alloc_agpphysmem_i8xx(size_t pg_count, int type)
519 struct agp_memory *new;
523 case 1: page = agp_bridge->driver->agp_alloc_page(agp_bridge);
526 /* kludge to get 4 physical pages for ARGB cursor */
527 page = i8xx_alloc_pages();
536 new = agp_create_memory(pg_count);
540 new->pages[0] = page;
542 /* kludge to get 4 physical pages for ARGB cursor */
543 new->pages[1] = new->pages[0] + 1;
544 new->pages[2] = new->pages[1] + 1;
545 new->pages[3] = new->pages[2] + 1;
547 new->page_count = pg_count;
548 new->num_scratch_pages = pg_count;
549 new->type = AGP_PHYS_MEMORY;
550 new->physical = page_to_phys(new->pages[0]);
554 static struct agp_memory *intel_i810_alloc_by_type(size_t pg_count, int type)
556 struct agp_memory *new;
558 if (type == AGP_DCACHE_MEMORY) {
559 if (pg_count != intel_private.num_dcache_entries)
562 new = agp_create_memory(1);
566 new->type = AGP_DCACHE_MEMORY;
567 new->page_count = pg_count;
568 new->num_scratch_pages = 0;
569 agp_free_page_array(new);
572 if (type == AGP_PHYS_MEMORY)
573 return alloc_agpphysmem_i8xx(pg_count, type);
577 static void intel_i810_free_by_type(struct agp_memory *curr)
579 agp_free_key(curr->key);
580 if (curr->type == AGP_PHYS_MEMORY) {
581 if (curr->page_count == 4)
582 i8xx_destroy_pages(curr->pages[0]);
584 agp_bridge->driver->agp_destroy_page(curr->pages[0],
585 AGP_PAGE_DESTROY_UNMAP);
586 agp_bridge->driver->agp_destroy_page(curr->pages[0],
587 AGP_PAGE_DESTROY_FREE);
589 agp_free_page_array(curr);
594 static unsigned long intel_i810_mask_memory(struct agp_bridge_data *bridge,
595 dma_addr_t addr, int type)
597 /* Type checking must be done elsewhere */
598 return addr | bridge->driver->masks[type].mask;
601 static struct aper_size_info_fixed intel_i830_sizes[] =
604 /* The 64M mode still requires a 128k gatt */
610 static void intel_i830_init_gtt_entries(void)
616 static const int ddt[4] = { 0, 16, 32, 64 };
617 int size; /* reserved space (in kb) at the top of stolen memory */
619 pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl);
623 pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL);
625 /* The 965 has a field telling us the size of the GTT,
626 * which may be larger than what is necessary to map the
629 switch (pgetbl_ctl & I965_PGETBL_SIZE_MASK) {
630 case I965_PGETBL_SIZE_128KB:
633 case I965_PGETBL_SIZE_256KB:
636 case I965_PGETBL_SIZE_512KB:
639 case I965_PGETBL_SIZE_1MB:
642 case I965_PGETBL_SIZE_2MB:
645 case I965_PGETBL_SIZE_1_5MB:
649 dev_info(&intel_private.pcidev->dev,
650 "unknown page table size, assuming 512KB\n");
653 size += 4; /* add in BIOS popup space */
654 } else if (IS_G33 && !IS_IGD) {
655 /* G33's GTT size defined in gmch_ctrl */
656 switch (gmch_ctrl & G33_PGETBL_SIZE_MASK) {
657 case G33_PGETBL_SIZE_1M:
660 case G33_PGETBL_SIZE_2M:
664 dev_info(&agp_bridge->dev->dev,
665 "unknown page table size 0x%x, assuming 512KB\n",
666 (gmch_ctrl & G33_PGETBL_SIZE_MASK));
670 } else if (IS_G4X || IS_IGD) {
671 /* On 4 series hardware, GTT stolen is separate from graphics
672 * stolen, ignore it in stolen gtt entries counting. However,
673 * 4KB of the stolen memory doesn't get mapped to the GTT.
677 /* On previous hardware, the GTT size was just what was
678 * required to map the aperture.
680 size = agp_bridge->driver->fetch_size() + 4;
683 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82830_HB ||
684 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) {
685 switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
686 case I830_GMCH_GMS_STOLEN_512:
687 gtt_entries = KB(512) - KB(size);
689 case I830_GMCH_GMS_STOLEN_1024:
690 gtt_entries = MB(1) - KB(size);
692 case I830_GMCH_GMS_STOLEN_8192:
693 gtt_entries = MB(8) - KB(size);
695 case I830_GMCH_GMS_LOCAL:
696 rdct = readb(intel_private.registers+I830_RDRAM_CHANNEL_TYPE);
697 gtt_entries = (I830_RDRAM_ND(rdct) + 1) *
698 MB(ddt[I830_RDRAM_DDT(rdct)]);
706 switch (gmch_ctrl & I855_GMCH_GMS_MASK) {
707 case I855_GMCH_GMS_STOLEN_1M:
708 gtt_entries = MB(1) - KB(size);
710 case I855_GMCH_GMS_STOLEN_4M:
711 gtt_entries = MB(4) - KB(size);
713 case I855_GMCH_GMS_STOLEN_8M:
714 gtt_entries = MB(8) - KB(size);
716 case I855_GMCH_GMS_STOLEN_16M:
717 gtt_entries = MB(16) - KB(size);
719 case I855_GMCH_GMS_STOLEN_32M:
720 gtt_entries = MB(32) - KB(size);
722 case I915_GMCH_GMS_STOLEN_48M:
723 /* Check it's really I915G */
724 if (IS_I915 || IS_I965 || IS_G33 || IS_G4X)
725 gtt_entries = MB(48) - KB(size);
729 case I915_GMCH_GMS_STOLEN_64M:
730 /* Check it's really I915G */
731 if (IS_I915 || IS_I965 || IS_G33 || IS_G4X)
732 gtt_entries = MB(64) - KB(size);
736 case G33_GMCH_GMS_STOLEN_128M:
737 if (IS_G33 || IS_I965 || IS_G4X)
738 gtt_entries = MB(128) - KB(size);
742 case G33_GMCH_GMS_STOLEN_256M:
743 if (IS_G33 || IS_I965 || IS_G4X)
744 gtt_entries = MB(256) - KB(size);
748 case INTEL_GMCH_GMS_STOLEN_96M:
749 if (IS_I965 || IS_G4X)
750 gtt_entries = MB(96) - KB(size);
754 case INTEL_GMCH_GMS_STOLEN_160M:
755 if (IS_I965 || IS_G4X)
756 gtt_entries = MB(160) - KB(size);
760 case INTEL_GMCH_GMS_STOLEN_224M:
761 if (IS_I965 || IS_G4X)
762 gtt_entries = MB(224) - KB(size);
766 case INTEL_GMCH_GMS_STOLEN_352M:
767 if (IS_I965 || IS_G4X)
768 gtt_entries = MB(352) - KB(size);
777 if (gtt_entries > 0) {
778 dev_info(&agp_bridge->dev->dev, "detected %dK %s memory\n",
779 gtt_entries / KB(1), local ? "local" : "stolen");
780 gtt_entries /= KB(4);
782 dev_info(&agp_bridge->dev->dev,
783 "no pre-allocated video memory detected\n");
787 intel_private.gtt_entries = gtt_entries;
790 static void intel_i830_fini_flush(void)
792 kunmap(intel_private.i8xx_page);
793 intel_private.i8xx_flush_page = NULL;
794 unmap_page_from_agp(intel_private.i8xx_page);
796 __free_page(intel_private.i8xx_page);
797 intel_private.i8xx_page = NULL;
800 static void intel_i830_setup_flush(void)
802 /* return if we've already set the flush mechanism up */
803 if (intel_private.i8xx_page)
806 intel_private.i8xx_page = alloc_page(GFP_KERNEL | __GFP_ZERO | GFP_DMA32);
807 if (!intel_private.i8xx_page)
810 intel_private.i8xx_flush_page = kmap(intel_private.i8xx_page);
811 if (!intel_private.i8xx_flush_page)
812 intel_i830_fini_flush();
816 do_wbinvd(void *null)
821 /* The chipset_flush interface needs to get data that has already been
822 * flushed out of the CPU all the way out to main memory, because the GPU
823 * doesn't snoop those buffers.
825 * The 8xx series doesn't have the same lovely interface for flushing the
826 * chipset write buffers that the later chips do. According to the 865
827 * specs, it's 64 octwords, or 1KB. So, to get those previous things in
828 * that buffer out, we just fill 1KB and clflush it out, on the assumption
829 * that it'll push whatever was in there out. It appears to work.
831 static void intel_i830_chipset_flush(struct agp_bridge_data *bridge)
833 unsigned int *pg = intel_private.i8xx_flush_page;
837 if (cpu_has_clflush) {
838 clflush_cache_range(pg, 1024);
840 if (on_each_cpu(do_wbinvd, NULL, 1) != 0)
841 printk(KERN_ERR "Timed out waiting for cache flush.\n");
845 /* The intel i830 automatically initializes the agp aperture during POST.
846 * Use the memory already set aside for in the GTT.
848 static int intel_i830_create_gatt_table(struct agp_bridge_data *bridge)
851 struct aper_size_info_fixed *size;
855 size = agp_bridge->current_size;
856 page_order = size->page_order;
857 num_entries = size->num_entries;
858 agp_bridge->gatt_table_real = NULL;
860 pci_read_config_dword(intel_private.pcidev, I810_MMADDR, &temp);
863 intel_private.registers = ioremap(temp, 128 * 4096);
864 if (!intel_private.registers)
867 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
868 global_cache_flush(); /* FIXME: ?? */
870 /* we have to call this as early as possible after the MMIO base address is known */
871 intel_i830_init_gtt_entries();
873 agp_bridge->gatt_table = NULL;
875 agp_bridge->gatt_bus_addr = temp;
880 /* Return the gatt table to a sane state. Use the top of stolen
881 * memory for the GTT.
883 static int intel_i830_free_gatt_table(struct agp_bridge_data *bridge)
888 static int intel_i830_fetch_size(void)
891 struct aper_size_info_fixed *values;
893 values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes);
895 if (agp_bridge->dev->device != PCI_DEVICE_ID_INTEL_82830_HB &&
896 agp_bridge->dev->device != PCI_DEVICE_ID_INTEL_82845G_HB) {
897 /* 855GM/852GM/865G has 128MB aperture size */
898 agp_bridge->previous_size = agp_bridge->current_size = (void *) values;
899 agp_bridge->aperture_size_idx = 0;
900 return values[0].size;
903 pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl);
905 if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_128M) {
906 agp_bridge->previous_size = agp_bridge->current_size = (void *) values;
907 agp_bridge->aperture_size_idx = 0;
908 return values[0].size;
910 agp_bridge->previous_size = agp_bridge->current_size = (void *) (values + 1);
911 agp_bridge->aperture_size_idx = 1;
912 return values[1].size;
918 static int intel_i830_configure(void)
920 struct aper_size_info_fixed *current_size;
925 current_size = A_SIZE_FIX(agp_bridge->current_size);
927 pci_read_config_dword(intel_private.pcidev, I810_GMADDR, &temp);
928 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
930 pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl);
931 gmch_ctrl |= I830_GMCH_ENABLED;
932 pci_write_config_word(agp_bridge->dev, I830_GMCH_CTRL, gmch_ctrl);
934 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL);
935 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
937 if (agp_bridge->driver->needs_scratch_page) {
938 for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) {
939 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
941 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4)); /* PCI Posting. */
944 global_cache_flush();
946 intel_i830_setup_flush();
950 static void intel_i830_cleanup(void)
952 iounmap(intel_private.registers);
955 static int intel_i830_insert_entries(struct agp_memory *mem, off_t pg_start,
958 int i, j, num_entries;
963 if (mem->page_count == 0)
966 temp = agp_bridge->current_size;
967 num_entries = A_SIZE_FIX(temp)->num_entries;
969 if (pg_start < intel_private.gtt_entries) {
970 dev_printk(KERN_DEBUG, &intel_private.pcidev->dev,
971 "pg_start == 0x%.8lx, intel_private.gtt_entries == 0x%.8x\n",
972 pg_start, intel_private.gtt_entries);
974 dev_info(&intel_private.pcidev->dev,
975 "trying to insert into local/stolen memory\n");
979 if ((pg_start + mem->page_count) > num_entries)
982 /* The i830 can't check the GTT for entries since its read only,
983 * depend on the caller to make the correct offset decisions.
986 if (type != mem->type)
989 mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
991 if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY &&
992 mask_type != INTEL_AGP_CACHED_MEMORY)
995 if (!mem->is_flushed)
996 global_cache_flush();
998 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
999 writel(agp_bridge->driver->mask_memory(agp_bridge,
1000 page_to_phys(mem->pages[i]), mask_type),
1001 intel_private.registers+I810_PTE_BASE+(j*4));
1003 readl(intel_private.registers+I810_PTE_BASE+((j-1)*4));
1004 agp_bridge->driver->tlb_flush(mem);
1009 mem->is_flushed = true;
1013 static int intel_i830_remove_entries(struct agp_memory *mem, off_t pg_start,
1018 if (mem->page_count == 0)
1021 if (pg_start < intel_private.gtt_entries) {
1022 dev_info(&intel_private.pcidev->dev,
1023 "trying to disable local/stolen memory\n");
1027 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
1028 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
1030 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4));
1032 agp_bridge->driver->tlb_flush(mem);
1036 static struct agp_memory *intel_i830_alloc_by_type(size_t pg_count, int type)
1038 if (type == AGP_PHYS_MEMORY)
1039 return alloc_agpphysmem_i8xx(pg_count, type);
1040 /* always return NULL for other allocation types for now */
1044 static int intel_alloc_chipset_flush_resource(void)
1047 ret = pci_bus_alloc_resource(agp_bridge->dev->bus, &intel_private.ifp_resource, PAGE_SIZE,
1048 PAGE_SIZE, PCIBIOS_MIN_MEM, 0,
1049 pcibios_align_resource, agp_bridge->dev);
1054 static void intel_i915_setup_chipset_flush(void)
1059 pci_read_config_dword(agp_bridge->dev, I915_IFPADDR, &temp);
1060 if (!(temp & 0x1)) {
1061 intel_alloc_chipset_flush_resource();
1062 intel_private.resource_valid = 1;
1063 pci_write_config_dword(agp_bridge->dev, I915_IFPADDR, (intel_private.ifp_resource.start & 0xffffffff) | 0x1);
1067 intel_private.resource_valid = 1;
1068 intel_private.ifp_resource.start = temp;
1069 intel_private.ifp_resource.end = temp + PAGE_SIZE;
1070 ret = request_resource(&iomem_resource, &intel_private.ifp_resource);
1071 /* some BIOSes reserve this area in a pnp some don't */
1073 intel_private.resource_valid = 0;
1077 static void intel_i965_g33_setup_chipset_flush(void)
1079 u32 temp_hi, temp_lo;
1082 pci_read_config_dword(agp_bridge->dev, I965_IFPADDR + 4, &temp_hi);
1083 pci_read_config_dword(agp_bridge->dev, I965_IFPADDR, &temp_lo);
1085 if (!(temp_lo & 0x1)) {
1087 intel_alloc_chipset_flush_resource();
1089 intel_private.resource_valid = 1;
1090 pci_write_config_dword(agp_bridge->dev, I965_IFPADDR + 4,
1091 upper_32_bits(intel_private.ifp_resource.start));
1092 pci_write_config_dword(agp_bridge->dev, I965_IFPADDR, (intel_private.ifp_resource.start & 0xffffffff) | 0x1);
1097 l64 = ((u64)temp_hi << 32) | temp_lo;
1099 intel_private.resource_valid = 1;
1100 intel_private.ifp_resource.start = l64;
1101 intel_private.ifp_resource.end = l64 + PAGE_SIZE;
1102 ret = request_resource(&iomem_resource, &intel_private.ifp_resource);
1103 /* some BIOSes reserve this area in a pnp some don't */
1105 intel_private.resource_valid = 0;
1109 static void intel_i9xx_setup_flush(void)
1111 /* return if already configured */
1112 if (intel_private.ifp_resource.start)
1115 /* setup a resource for this object */
1116 intel_private.ifp_resource.name = "Intel Flush Page";
1117 intel_private.ifp_resource.flags = IORESOURCE_MEM;
1119 /* Setup chipset flush for 915 */
1120 if (IS_I965 || IS_G33 || IS_G4X) {
1121 intel_i965_g33_setup_chipset_flush();
1123 intel_i915_setup_chipset_flush();
1126 if (intel_private.ifp_resource.start) {
1127 intel_private.i9xx_flush_page = ioremap_nocache(intel_private.ifp_resource.start, PAGE_SIZE);
1128 if (!intel_private.i9xx_flush_page)
1129 dev_info(&intel_private.pcidev->dev, "can't ioremap flush page - no chipset flushing");
1133 static int intel_i915_configure(void)
1135 struct aper_size_info_fixed *current_size;
1140 current_size = A_SIZE_FIX(agp_bridge->current_size);
1142 pci_read_config_dword(intel_private.pcidev, I915_GMADDR, &temp);
1144 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1146 pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl);
1147 gmch_ctrl |= I830_GMCH_ENABLED;
1148 pci_write_config_word(agp_bridge->dev, I830_GMCH_CTRL, gmch_ctrl);
1150 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL);
1151 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
1153 if (agp_bridge->driver->needs_scratch_page) {
1154 for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) {
1155 writel(agp_bridge->scratch_page, intel_private.gtt+i);
1157 readl(intel_private.gtt+i-1); /* PCI Posting. */
1160 global_cache_flush();
1162 intel_i9xx_setup_flush();
1164 #ifdef USE_PCI_DMA_API
1165 if (pci_set_dma_mask(intel_private.pcidev, DMA_BIT_MASK(36)))
1166 dev_err(&intel_private.pcidev->dev,
1167 "set gfx device dma mask 36bit failed!\n");
1173 static void intel_i915_cleanup(void)
1175 if (intel_private.i9xx_flush_page)
1176 iounmap(intel_private.i9xx_flush_page);
1177 if (intel_private.resource_valid)
1178 release_resource(&intel_private.ifp_resource);
1179 intel_private.ifp_resource.start = 0;
1180 intel_private.resource_valid = 0;
1181 iounmap(intel_private.gtt);
1182 iounmap(intel_private.registers);
1185 static void intel_i915_chipset_flush(struct agp_bridge_data *bridge)
1187 if (intel_private.i9xx_flush_page)
1188 writel(1, intel_private.i9xx_flush_page);
1191 static int intel_i915_insert_entries(struct agp_memory *mem, off_t pg_start,
1199 if (mem->page_count == 0)
1202 temp = agp_bridge->current_size;
1203 num_entries = A_SIZE_FIX(temp)->num_entries;
1205 if (pg_start < intel_private.gtt_entries) {
1206 dev_printk(KERN_DEBUG, &intel_private.pcidev->dev,
1207 "pg_start == 0x%.8lx, intel_private.gtt_entries == 0x%.8x\n",
1208 pg_start, intel_private.gtt_entries);
1210 dev_info(&intel_private.pcidev->dev,
1211 "trying to insert into local/stolen memory\n");
1215 if ((pg_start + mem->page_count) > num_entries)
1218 /* The i915 can't check the GTT for entries since it's read only;
1219 * depend on the caller to make the correct offset decisions.
1222 if (type != mem->type)
1225 mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
1227 if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY &&
1228 mask_type != INTEL_AGP_CACHED_MEMORY)
1231 if (!mem->is_flushed)
1232 global_cache_flush();
1234 intel_agp_insert_sg_entries(mem, pg_start, mask_type);
1235 agp_bridge->driver->tlb_flush(mem);
1240 mem->is_flushed = true;
1244 static int intel_i915_remove_entries(struct agp_memory *mem, off_t pg_start,
1249 if (mem->page_count == 0)
1252 if (pg_start < intel_private.gtt_entries) {
1253 dev_info(&intel_private.pcidev->dev,
1254 "trying to disable local/stolen memory\n");
1258 for (i = pg_start; i < (mem->page_count + pg_start); i++)
1259 writel(agp_bridge->scratch_page, intel_private.gtt+i);
1261 readl(intel_private.gtt+i-1);
1263 agp_bridge->driver->tlb_flush(mem);
1267 /* Return the aperture size by just checking the resource length. The effect
1268 * described in the spec of the MSAC registers is just changing of the
1271 static int intel_i9xx_fetch_size(void)
1273 int num_sizes = ARRAY_SIZE(intel_i830_sizes);
1274 int aper_size; /* size in megabytes */
1277 aper_size = pci_resource_len(intel_private.pcidev, 2) / MB(1);
1279 for (i = 0; i < num_sizes; i++) {
1280 if (aper_size == intel_i830_sizes[i].size) {
1281 agp_bridge->current_size = intel_i830_sizes + i;
1282 agp_bridge->previous_size = agp_bridge->current_size;
1290 /* The intel i915 automatically initializes the agp aperture during POST.
1291 * Use the memory already set aside for in the GTT.
1293 static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge)
1296 struct aper_size_info_fixed *size;
1299 int gtt_map_size = 256 * 1024;
1301 size = agp_bridge->current_size;
1302 page_order = size->page_order;
1303 num_entries = size->num_entries;
1304 agp_bridge->gatt_table_real = NULL;
1306 pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &temp);
1307 pci_read_config_dword(intel_private.pcidev, I915_PTEADDR, &temp2);
1310 gtt_map_size = 1024 * 1024; /* 1M on G33 */
1311 intel_private.gtt = ioremap(temp2, gtt_map_size);
1312 if (!intel_private.gtt)
1317 intel_private.registers = ioremap(temp, 128 * 4096);
1318 if (!intel_private.registers) {
1319 iounmap(intel_private.gtt);
1323 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
1324 global_cache_flush(); /* FIXME: ? */
1326 /* we have to call this as early as possible after the MMIO base address is known */
1327 intel_i830_init_gtt_entries();
1329 agp_bridge->gatt_table = NULL;
1331 agp_bridge->gatt_bus_addr = temp;
1337 * The i965 supports 36-bit physical addresses, but to keep
1338 * the format of the GTT the same, the bits that don't fit
1339 * in a 32-bit word are shifted down to bits 4..7.
1341 * Gcc is smart enough to notice that "(addr >> 28) & 0xf0"
1342 * is always zero on 32-bit architectures, so no need to make
1345 static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge,
1346 dma_addr_t addr, int type)
1348 /* Shift high bits down */
1349 addr |= (addr >> 28) & 0xf0;
1351 /* Type checking must be done elsewhere */
1352 return addr | bridge->driver->masks[type].mask;
1355 static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size)
1357 switch (agp_bridge->dev->device) {
1358 case PCI_DEVICE_ID_INTEL_GM45_HB:
1359 case PCI_DEVICE_ID_INTEL_IGD_E_HB:
1360 case PCI_DEVICE_ID_INTEL_Q45_HB:
1361 case PCI_DEVICE_ID_INTEL_G45_HB:
1362 case PCI_DEVICE_ID_INTEL_G41_HB:
1363 case PCI_DEVICE_ID_INTEL_B43_HB:
1364 case PCI_DEVICE_ID_INTEL_IGDNG_D_HB:
1365 case PCI_DEVICE_ID_INTEL_IGDNG_M_HB:
1366 case PCI_DEVICE_ID_INTEL_IGDNG_MA_HB:
1367 *gtt_offset = *gtt_size = MB(2);
1370 *gtt_offset = *gtt_size = KB(512);
1374 /* The intel i965 automatically initializes the agp aperture during POST.
1375 * Use the memory already set aside for in the GTT.
1377 static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge)
1380 struct aper_size_info_fixed *size;
1383 int gtt_offset, gtt_size;
1385 size = agp_bridge->current_size;
1386 page_order = size->page_order;
1387 num_entries = size->num_entries;
1388 agp_bridge->gatt_table_real = NULL;
1390 pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &temp);
1394 intel_i965_get_gtt_range(>t_offset, >t_size);
1396 intel_private.gtt = ioremap((temp + gtt_offset) , gtt_size);
1398 if (!intel_private.gtt)
1401 intel_private.registers = ioremap(temp, 128 * 4096);
1402 if (!intel_private.registers) {
1403 iounmap(intel_private.gtt);
1407 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
1408 global_cache_flush(); /* FIXME: ? */
1410 /* we have to call this as early as possible after the MMIO base address is known */
1411 intel_i830_init_gtt_entries();
1413 agp_bridge->gatt_table = NULL;
1415 agp_bridge->gatt_bus_addr = temp;
1421 static int intel_fetch_size(void)
1425 struct aper_size_info_16 *values;
1427 pci_read_config_word(agp_bridge->dev, INTEL_APSIZE, &temp);
1428 values = A_SIZE_16(agp_bridge->driver->aperture_sizes);
1430 for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) {
1431 if (temp == values[i].size_value) {
1432 agp_bridge->previous_size = agp_bridge->current_size = (void *) (values + i);
1433 agp_bridge->aperture_size_idx = i;
1434 return values[i].size;
1441 static int __intel_8xx_fetch_size(u8 temp)
1444 struct aper_size_info_8 *values;
1446 values = A_SIZE_8(agp_bridge->driver->aperture_sizes);
1448 for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) {
1449 if (temp == values[i].size_value) {
1450 agp_bridge->previous_size =
1451 agp_bridge->current_size = (void *) (values + i);
1452 agp_bridge->aperture_size_idx = i;
1453 return values[i].size;
1459 static int intel_8xx_fetch_size(void)
1463 pci_read_config_byte(agp_bridge->dev, INTEL_APSIZE, &temp);
1464 return __intel_8xx_fetch_size(temp);
1467 static int intel_815_fetch_size(void)
1471 /* Intel 815 chipsets have a _weird_ APSIZE register with only
1472 * one non-reserved bit, so mask the others out ... */
1473 pci_read_config_byte(agp_bridge->dev, INTEL_APSIZE, &temp);
1476 return __intel_8xx_fetch_size(temp);
1479 static void intel_tlbflush(struct agp_memory *mem)
1481 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2200);
1482 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2280);
1486 static void intel_8xx_tlbflush(struct agp_memory *mem)
1489 pci_read_config_dword(agp_bridge->dev, INTEL_AGPCTRL, &temp);
1490 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, temp & ~(1 << 7));
1491 pci_read_config_dword(agp_bridge->dev, INTEL_AGPCTRL, &temp);
1492 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, temp | (1 << 7));
1496 static void intel_cleanup(void)
1499 struct aper_size_info_16 *previous_size;
1501 previous_size = A_SIZE_16(agp_bridge->previous_size);
1502 pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp);
1503 pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp & ~(1 << 9));
1504 pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, previous_size->size_value);
1508 static void intel_8xx_cleanup(void)
1511 struct aper_size_info_8 *previous_size;
1513 previous_size = A_SIZE_8(agp_bridge->previous_size);
1514 pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp);
1515 pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp & ~(1 << 9));
1516 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, previous_size->size_value);
1520 static int intel_configure(void)
1524 struct aper_size_info_16 *current_size;
1526 current_size = A_SIZE_16(agp_bridge->current_size);
1529 pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1531 /* address to map to */
1532 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1533 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1535 /* attbase - aperture base */
1536 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1539 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2280);
1542 pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp2);
1543 pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG,
1544 (temp2 & ~(1 << 10)) | (1 << 9));
1545 /* clear any possible error conditions */
1546 pci_write_config_byte(agp_bridge->dev, INTEL_ERRSTS + 1, 7);
1550 static int intel_815_configure(void)
1554 struct aper_size_info_8 *current_size;
1556 /* attbase - aperture base */
1557 /* the Intel 815 chipset spec. says that bits 29-31 in the
1558 * ATTBASE register are reserved -> try not to write them */
1559 if (agp_bridge->gatt_bus_addr & INTEL_815_ATTBASE_MASK) {
1560 dev_emerg(&agp_bridge->dev->dev, "gatt bus addr too high");
1564 current_size = A_SIZE_8(agp_bridge->current_size);
1567 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE,
1568 current_size->size_value);
1570 /* address to map to */
1571 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1572 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1574 pci_read_config_dword(agp_bridge->dev, INTEL_ATTBASE, &addr);
1575 addr &= INTEL_815_ATTBASE_MASK;
1576 addr |= agp_bridge->gatt_bus_addr;
1577 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, addr);
1580 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1583 pci_read_config_byte(agp_bridge->dev, INTEL_815_APCONT, &temp2);
1584 pci_write_config_byte(agp_bridge->dev, INTEL_815_APCONT, temp2 | (1 << 1));
1586 /* clear any possible error conditions */
1587 /* Oddness : this chipset seems to have no ERRSTS register ! */
1591 static void intel_820_tlbflush(struct agp_memory *mem)
1596 static void intel_820_cleanup(void)
1599 struct aper_size_info_8 *previous_size;
1601 previous_size = A_SIZE_8(agp_bridge->previous_size);
1602 pci_read_config_byte(agp_bridge->dev, INTEL_I820_RDCR, &temp);
1603 pci_write_config_byte(agp_bridge->dev, INTEL_I820_RDCR,
1605 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE,
1606 previous_size->size_value);
1610 static int intel_820_configure(void)
1614 struct aper_size_info_8 *current_size;
1616 current_size = A_SIZE_8(agp_bridge->current_size);
1619 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1621 /* address to map to */
1622 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1623 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1625 /* attbase - aperture base */
1626 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1629 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1631 /* global enable aperture access */
1632 /* This flag is not accessed through MCHCFG register as in */
1634 pci_read_config_byte(agp_bridge->dev, INTEL_I820_RDCR, &temp2);
1635 pci_write_config_byte(agp_bridge->dev, INTEL_I820_RDCR, temp2 | (1 << 1));
1636 /* clear any possible AGP-related error conditions */
1637 pci_write_config_word(agp_bridge->dev, INTEL_I820_ERRSTS, 0x001c);
1641 static int intel_840_configure(void)
1645 struct aper_size_info_8 *current_size;
1647 current_size = A_SIZE_8(agp_bridge->current_size);
1650 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1652 /* address to map to */
1653 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1654 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1656 /* attbase - aperture base */
1657 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1660 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1663 pci_read_config_word(agp_bridge->dev, INTEL_I840_MCHCFG, &temp2);
1664 pci_write_config_word(agp_bridge->dev, INTEL_I840_MCHCFG, temp2 | (1 << 9));
1665 /* clear any possible error conditions */
1666 pci_write_config_word(agp_bridge->dev, INTEL_I840_ERRSTS, 0xc000);
1670 static int intel_845_configure(void)
1674 struct aper_size_info_8 *current_size;
1676 current_size = A_SIZE_8(agp_bridge->current_size);
1679 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1681 if (agp_bridge->apbase_config != 0) {
1682 pci_write_config_dword(agp_bridge->dev, AGP_APBASE,
1683 agp_bridge->apbase_config);
1685 /* address to map to */
1686 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1687 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1688 agp_bridge->apbase_config = temp;
1691 /* attbase - aperture base */
1692 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1695 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1698 pci_read_config_byte(agp_bridge->dev, INTEL_I845_AGPM, &temp2);
1699 pci_write_config_byte(agp_bridge->dev, INTEL_I845_AGPM, temp2 | (1 << 1));
1700 /* clear any possible error conditions */
1701 pci_write_config_word(agp_bridge->dev, INTEL_I845_ERRSTS, 0x001c);
1703 intel_i830_setup_flush();
1707 static int intel_850_configure(void)
1711 struct aper_size_info_8 *current_size;
1713 current_size = A_SIZE_8(agp_bridge->current_size);
1716 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1718 /* address to map to */
1719 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1720 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1722 /* attbase - aperture base */
1723 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1726 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1729 pci_read_config_word(agp_bridge->dev, INTEL_I850_MCHCFG, &temp2);
1730 pci_write_config_word(agp_bridge->dev, INTEL_I850_MCHCFG, temp2 | (1 << 9));
1731 /* clear any possible AGP-related error conditions */
1732 pci_write_config_word(agp_bridge->dev, INTEL_I850_ERRSTS, 0x001c);
1736 static int intel_860_configure(void)
1740 struct aper_size_info_8 *current_size;
1742 current_size = A_SIZE_8(agp_bridge->current_size);
1745 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1747 /* address to map to */
1748 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1749 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1751 /* attbase - aperture base */
1752 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1755 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1758 pci_read_config_word(agp_bridge->dev, INTEL_I860_MCHCFG, &temp2);
1759 pci_write_config_word(agp_bridge->dev, INTEL_I860_MCHCFG, temp2 | (1 << 9));
1760 /* clear any possible AGP-related error conditions */
1761 pci_write_config_word(agp_bridge->dev, INTEL_I860_ERRSTS, 0xf700);
1765 static int intel_830mp_configure(void)
1769 struct aper_size_info_8 *current_size;
1771 current_size = A_SIZE_8(agp_bridge->current_size);
1774 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1776 /* address to map to */
1777 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1778 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1780 /* attbase - aperture base */
1781 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1784 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1787 pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp2);
1788 pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp2 | (1 << 9));
1789 /* clear any possible AGP-related error conditions */
1790 pci_write_config_word(agp_bridge->dev, INTEL_I830_ERRSTS, 0x1c);
1794 static int intel_7505_configure(void)
1798 struct aper_size_info_8 *current_size;
1800 current_size = A_SIZE_8(agp_bridge->current_size);
1803 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1805 /* address to map to */
1806 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1807 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1809 /* attbase - aperture base */
1810 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1813 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1816 pci_read_config_word(agp_bridge->dev, INTEL_I7505_MCHCFG, &temp2);
1817 pci_write_config_word(agp_bridge->dev, INTEL_I7505_MCHCFG, temp2 | (1 << 9));
1822 /* Setup function */
1823 static const struct gatt_mask intel_generic_masks[] =
1825 {.mask = 0x00000017, .type = 0}
1828 static const struct aper_size_info_8 intel_815_sizes[2] =
1834 static const struct aper_size_info_8 intel_8xx_sizes[7] =
1837 {128, 32768, 5, 32},
1845 static const struct aper_size_info_16 intel_generic_sizes[7] =
1848 {128, 32768, 5, 32},
1856 static const struct aper_size_info_8 intel_830mp_sizes[4] =
1859 {128, 32768, 5, 32},
1864 static const struct agp_bridge_driver intel_generic_driver = {
1865 .owner = THIS_MODULE,
1866 .aperture_sizes = intel_generic_sizes,
1867 .size_type = U16_APER_SIZE,
1868 .num_aperture_sizes = 7,
1869 .configure = intel_configure,
1870 .fetch_size = intel_fetch_size,
1871 .cleanup = intel_cleanup,
1872 .tlb_flush = intel_tlbflush,
1873 .mask_memory = agp_generic_mask_memory,
1874 .masks = intel_generic_masks,
1875 .agp_enable = agp_generic_enable,
1876 .cache_flush = global_cache_flush,
1877 .create_gatt_table = agp_generic_create_gatt_table,
1878 .free_gatt_table = agp_generic_free_gatt_table,
1879 .insert_memory = agp_generic_insert_memory,
1880 .remove_memory = agp_generic_remove_memory,
1881 .alloc_by_type = agp_generic_alloc_by_type,
1882 .free_by_type = agp_generic_free_by_type,
1883 .agp_alloc_page = agp_generic_alloc_page,
1884 .agp_alloc_pages = agp_generic_alloc_pages,
1885 .agp_destroy_page = agp_generic_destroy_page,
1886 .agp_destroy_pages = agp_generic_destroy_pages,
1887 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1890 static const struct agp_bridge_driver intel_810_driver = {
1891 .owner = THIS_MODULE,
1892 .aperture_sizes = intel_i810_sizes,
1893 .size_type = FIXED_APER_SIZE,
1894 .num_aperture_sizes = 2,
1895 .needs_scratch_page = true,
1896 .configure = intel_i810_configure,
1897 .fetch_size = intel_i810_fetch_size,
1898 .cleanup = intel_i810_cleanup,
1899 .tlb_flush = intel_i810_tlbflush,
1900 .mask_memory = intel_i810_mask_memory,
1901 .masks = intel_i810_masks,
1902 .agp_enable = intel_i810_agp_enable,
1903 .cache_flush = global_cache_flush,
1904 .create_gatt_table = agp_generic_create_gatt_table,
1905 .free_gatt_table = agp_generic_free_gatt_table,
1906 .insert_memory = intel_i810_insert_entries,
1907 .remove_memory = intel_i810_remove_entries,
1908 .alloc_by_type = intel_i810_alloc_by_type,
1909 .free_by_type = intel_i810_free_by_type,
1910 .agp_alloc_page = agp_generic_alloc_page,
1911 .agp_alloc_pages = agp_generic_alloc_pages,
1912 .agp_destroy_page = agp_generic_destroy_page,
1913 .agp_destroy_pages = agp_generic_destroy_pages,
1914 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1917 static const struct agp_bridge_driver intel_815_driver = {
1918 .owner = THIS_MODULE,
1919 .aperture_sizes = intel_815_sizes,
1920 .size_type = U8_APER_SIZE,
1921 .num_aperture_sizes = 2,
1922 .configure = intel_815_configure,
1923 .fetch_size = intel_815_fetch_size,
1924 .cleanup = intel_8xx_cleanup,
1925 .tlb_flush = intel_8xx_tlbflush,
1926 .mask_memory = agp_generic_mask_memory,
1927 .masks = intel_generic_masks,
1928 .agp_enable = agp_generic_enable,
1929 .cache_flush = global_cache_flush,
1930 .create_gatt_table = agp_generic_create_gatt_table,
1931 .free_gatt_table = agp_generic_free_gatt_table,
1932 .insert_memory = agp_generic_insert_memory,
1933 .remove_memory = agp_generic_remove_memory,
1934 .alloc_by_type = agp_generic_alloc_by_type,
1935 .free_by_type = agp_generic_free_by_type,
1936 .agp_alloc_page = agp_generic_alloc_page,
1937 .agp_alloc_pages = agp_generic_alloc_pages,
1938 .agp_destroy_page = agp_generic_destroy_page,
1939 .agp_destroy_pages = agp_generic_destroy_pages,
1940 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1943 static const struct agp_bridge_driver intel_830_driver = {
1944 .owner = THIS_MODULE,
1945 .aperture_sizes = intel_i830_sizes,
1946 .size_type = FIXED_APER_SIZE,
1947 .num_aperture_sizes = 4,
1948 .needs_scratch_page = true,
1949 .configure = intel_i830_configure,
1950 .fetch_size = intel_i830_fetch_size,
1951 .cleanup = intel_i830_cleanup,
1952 .tlb_flush = intel_i810_tlbflush,
1953 .mask_memory = intel_i810_mask_memory,
1954 .masks = intel_i810_masks,
1955 .agp_enable = intel_i810_agp_enable,
1956 .cache_flush = global_cache_flush,
1957 .create_gatt_table = intel_i830_create_gatt_table,
1958 .free_gatt_table = intel_i830_free_gatt_table,
1959 .insert_memory = intel_i830_insert_entries,
1960 .remove_memory = intel_i830_remove_entries,
1961 .alloc_by_type = intel_i830_alloc_by_type,
1962 .free_by_type = intel_i810_free_by_type,
1963 .agp_alloc_page = agp_generic_alloc_page,
1964 .agp_alloc_pages = agp_generic_alloc_pages,
1965 .agp_destroy_page = agp_generic_destroy_page,
1966 .agp_destroy_pages = agp_generic_destroy_pages,
1967 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
1968 .chipset_flush = intel_i830_chipset_flush,
1971 static const struct agp_bridge_driver intel_820_driver = {
1972 .owner = THIS_MODULE,
1973 .aperture_sizes = intel_8xx_sizes,
1974 .size_type = U8_APER_SIZE,
1975 .num_aperture_sizes = 7,
1976 .configure = intel_820_configure,
1977 .fetch_size = intel_8xx_fetch_size,
1978 .cleanup = intel_820_cleanup,
1979 .tlb_flush = intel_820_tlbflush,
1980 .mask_memory = agp_generic_mask_memory,
1981 .masks = intel_generic_masks,
1982 .agp_enable = agp_generic_enable,
1983 .cache_flush = global_cache_flush,
1984 .create_gatt_table = agp_generic_create_gatt_table,
1985 .free_gatt_table = agp_generic_free_gatt_table,
1986 .insert_memory = agp_generic_insert_memory,
1987 .remove_memory = agp_generic_remove_memory,
1988 .alloc_by_type = agp_generic_alloc_by_type,
1989 .free_by_type = agp_generic_free_by_type,
1990 .agp_alloc_page = agp_generic_alloc_page,
1991 .agp_alloc_pages = agp_generic_alloc_pages,
1992 .agp_destroy_page = agp_generic_destroy_page,
1993 .agp_destroy_pages = agp_generic_destroy_pages,
1994 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1997 static const struct agp_bridge_driver intel_830mp_driver = {
1998 .owner = THIS_MODULE,
1999 .aperture_sizes = intel_830mp_sizes,
2000 .size_type = U8_APER_SIZE,
2001 .num_aperture_sizes = 4,
2002 .configure = intel_830mp_configure,
2003 .fetch_size = intel_8xx_fetch_size,
2004 .cleanup = intel_8xx_cleanup,
2005 .tlb_flush = intel_8xx_tlbflush,
2006 .mask_memory = agp_generic_mask_memory,
2007 .masks = intel_generic_masks,
2008 .agp_enable = agp_generic_enable,
2009 .cache_flush = global_cache_flush,
2010 .create_gatt_table = agp_generic_create_gatt_table,
2011 .free_gatt_table = agp_generic_free_gatt_table,
2012 .insert_memory = agp_generic_insert_memory,
2013 .remove_memory = agp_generic_remove_memory,
2014 .alloc_by_type = agp_generic_alloc_by_type,
2015 .free_by_type = agp_generic_free_by_type,
2016 .agp_alloc_page = agp_generic_alloc_page,
2017 .agp_alloc_pages = agp_generic_alloc_pages,
2018 .agp_destroy_page = agp_generic_destroy_page,
2019 .agp_destroy_pages = agp_generic_destroy_pages,
2020 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
2023 static const struct agp_bridge_driver intel_840_driver = {
2024 .owner = THIS_MODULE,
2025 .aperture_sizes = intel_8xx_sizes,
2026 .size_type = U8_APER_SIZE,
2027 .num_aperture_sizes = 7,
2028 .configure = intel_840_configure,
2029 .fetch_size = intel_8xx_fetch_size,
2030 .cleanup = intel_8xx_cleanup,
2031 .tlb_flush = intel_8xx_tlbflush,
2032 .mask_memory = agp_generic_mask_memory,
2033 .masks = intel_generic_masks,
2034 .agp_enable = agp_generic_enable,
2035 .cache_flush = global_cache_flush,
2036 .create_gatt_table = agp_generic_create_gatt_table,
2037 .free_gatt_table = agp_generic_free_gatt_table,
2038 .insert_memory = agp_generic_insert_memory,
2039 .remove_memory = agp_generic_remove_memory,
2040 .alloc_by_type = agp_generic_alloc_by_type,
2041 .free_by_type = agp_generic_free_by_type,
2042 .agp_alloc_page = agp_generic_alloc_page,
2043 .agp_alloc_pages = agp_generic_alloc_pages,
2044 .agp_destroy_page = agp_generic_destroy_page,
2045 .agp_destroy_pages = agp_generic_destroy_pages,
2046 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
2049 static const struct agp_bridge_driver intel_845_driver = {
2050 .owner = THIS_MODULE,
2051 .aperture_sizes = intel_8xx_sizes,
2052 .size_type = U8_APER_SIZE,
2053 .num_aperture_sizes = 7,
2054 .configure = intel_845_configure,
2055 .fetch_size = intel_8xx_fetch_size,
2056 .cleanup = intel_8xx_cleanup,
2057 .tlb_flush = intel_8xx_tlbflush,
2058 .mask_memory = agp_generic_mask_memory,
2059 .masks = intel_generic_masks,
2060 .agp_enable = agp_generic_enable,
2061 .cache_flush = global_cache_flush,
2062 .create_gatt_table = agp_generic_create_gatt_table,
2063 .free_gatt_table = agp_generic_free_gatt_table,
2064 .insert_memory = agp_generic_insert_memory,
2065 .remove_memory = agp_generic_remove_memory,
2066 .alloc_by_type = agp_generic_alloc_by_type,
2067 .free_by_type = agp_generic_free_by_type,
2068 .agp_alloc_page = agp_generic_alloc_page,
2069 .agp_alloc_pages = agp_generic_alloc_pages,
2070 .agp_destroy_page = agp_generic_destroy_page,
2071 .agp_destroy_pages = agp_generic_destroy_pages,
2072 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
2073 .chipset_flush = intel_i830_chipset_flush,
2076 static const struct agp_bridge_driver intel_850_driver = {
2077 .owner = THIS_MODULE,
2078 .aperture_sizes = intel_8xx_sizes,
2079 .size_type = U8_APER_SIZE,
2080 .num_aperture_sizes = 7,
2081 .configure = intel_850_configure,
2082 .fetch_size = intel_8xx_fetch_size,
2083 .cleanup = intel_8xx_cleanup,
2084 .tlb_flush = intel_8xx_tlbflush,
2085 .mask_memory = agp_generic_mask_memory,
2086 .masks = intel_generic_masks,
2087 .agp_enable = agp_generic_enable,
2088 .cache_flush = global_cache_flush,
2089 .create_gatt_table = agp_generic_create_gatt_table,
2090 .free_gatt_table = agp_generic_free_gatt_table,
2091 .insert_memory = agp_generic_insert_memory,
2092 .remove_memory = agp_generic_remove_memory,
2093 .alloc_by_type = agp_generic_alloc_by_type,
2094 .free_by_type = agp_generic_free_by_type,
2095 .agp_alloc_page = agp_generic_alloc_page,
2096 .agp_alloc_pages = agp_generic_alloc_pages,
2097 .agp_destroy_page = agp_generic_destroy_page,
2098 .agp_destroy_pages = agp_generic_destroy_pages,
2099 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
2102 static const struct agp_bridge_driver intel_860_driver = {
2103 .owner = THIS_MODULE,
2104 .aperture_sizes = intel_8xx_sizes,
2105 .size_type = U8_APER_SIZE,
2106 .num_aperture_sizes = 7,
2107 .configure = intel_860_configure,
2108 .fetch_size = intel_8xx_fetch_size,
2109 .cleanup = intel_8xx_cleanup,
2110 .tlb_flush = intel_8xx_tlbflush,
2111 .mask_memory = agp_generic_mask_memory,
2112 .masks = intel_generic_masks,
2113 .agp_enable = agp_generic_enable,
2114 .cache_flush = global_cache_flush,
2115 .create_gatt_table = agp_generic_create_gatt_table,
2116 .free_gatt_table = agp_generic_free_gatt_table,
2117 .insert_memory = agp_generic_insert_memory,
2118 .remove_memory = agp_generic_remove_memory,
2119 .alloc_by_type = agp_generic_alloc_by_type,
2120 .free_by_type = agp_generic_free_by_type,
2121 .agp_alloc_page = agp_generic_alloc_page,
2122 .agp_alloc_pages = agp_generic_alloc_pages,
2123 .agp_destroy_page = agp_generic_destroy_page,
2124 .agp_destroy_pages = agp_generic_destroy_pages,
2125 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
2128 static const struct agp_bridge_driver intel_915_driver = {
2129 .owner = THIS_MODULE,
2130 .aperture_sizes = intel_i830_sizes,
2131 .size_type = FIXED_APER_SIZE,
2132 .num_aperture_sizes = 4,
2133 .needs_scratch_page = true,
2134 .configure = intel_i915_configure,
2135 .fetch_size = intel_i9xx_fetch_size,
2136 .cleanup = intel_i915_cleanup,
2137 .tlb_flush = intel_i810_tlbflush,
2138 .mask_memory = intel_i810_mask_memory,
2139 .masks = intel_i810_masks,
2140 .agp_enable = intel_i810_agp_enable,
2141 .cache_flush = global_cache_flush,
2142 .create_gatt_table = intel_i915_create_gatt_table,
2143 .free_gatt_table = intel_i830_free_gatt_table,
2144 .insert_memory = intel_i915_insert_entries,
2145 .remove_memory = intel_i915_remove_entries,
2146 .alloc_by_type = intel_i830_alloc_by_type,
2147 .free_by_type = intel_i810_free_by_type,
2148 .agp_alloc_page = agp_generic_alloc_page,
2149 .agp_alloc_pages = agp_generic_alloc_pages,
2150 .agp_destroy_page = agp_generic_destroy_page,
2151 .agp_destroy_pages = agp_generic_destroy_pages,
2152 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
2153 .chipset_flush = intel_i915_chipset_flush,
2154 #ifdef USE_PCI_DMA_API
2155 .agp_map_page = intel_agp_map_page,
2156 .agp_unmap_page = intel_agp_unmap_page,
2157 .agp_map_memory = intel_agp_map_memory,
2158 .agp_unmap_memory = intel_agp_unmap_memory,
2162 static const struct agp_bridge_driver intel_i965_driver = {
2163 .owner = THIS_MODULE,
2164 .aperture_sizes = intel_i830_sizes,
2165 .size_type = FIXED_APER_SIZE,
2166 .num_aperture_sizes = 4,
2167 .needs_scratch_page = true,
2168 .configure = intel_i915_configure,
2169 .fetch_size = intel_i9xx_fetch_size,
2170 .cleanup = intel_i915_cleanup,
2171 .tlb_flush = intel_i810_tlbflush,
2172 .mask_memory = intel_i965_mask_memory,
2173 .masks = intel_i810_masks,
2174 .agp_enable = intel_i810_agp_enable,
2175 .cache_flush = global_cache_flush,
2176 .create_gatt_table = intel_i965_create_gatt_table,
2177 .free_gatt_table = intel_i830_free_gatt_table,
2178 .insert_memory = intel_i915_insert_entries,
2179 .remove_memory = intel_i915_remove_entries,
2180 .alloc_by_type = intel_i830_alloc_by_type,
2181 .free_by_type = intel_i810_free_by_type,
2182 .agp_alloc_page = agp_generic_alloc_page,
2183 .agp_alloc_pages = agp_generic_alloc_pages,
2184 .agp_destroy_page = agp_generic_destroy_page,
2185 .agp_destroy_pages = agp_generic_destroy_pages,
2186 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
2187 .chipset_flush = intel_i915_chipset_flush,
2188 #ifdef USE_PCI_DMA_API
2189 .agp_map_page = intel_agp_map_page,
2190 .agp_unmap_page = intel_agp_unmap_page,
2191 .agp_map_memory = intel_agp_map_memory,
2192 .agp_unmap_memory = intel_agp_unmap_memory,
2196 static const struct agp_bridge_driver intel_7505_driver = {
2197 .owner = THIS_MODULE,
2198 .aperture_sizes = intel_8xx_sizes,
2199 .size_type = U8_APER_SIZE,
2200 .num_aperture_sizes = 7,
2201 .configure = intel_7505_configure,
2202 .fetch_size = intel_8xx_fetch_size,
2203 .cleanup = intel_8xx_cleanup,
2204 .tlb_flush = intel_8xx_tlbflush,
2205 .mask_memory = agp_generic_mask_memory,
2206 .masks = intel_generic_masks,
2207 .agp_enable = agp_generic_enable,
2208 .cache_flush = global_cache_flush,
2209 .create_gatt_table = agp_generic_create_gatt_table,
2210 .free_gatt_table = agp_generic_free_gatt_table,
2211 .insert_memory = agp_generic_insert_memory,
2212 .remove_memory = agp_generic_remove_memory,
2213 .alloc_by_type = agp_generic_alloc_by_type,
2214 .free_by_type = agp_generic_free_by_type,
2215 .agp_alloc_page = agp_generic_alloc_page,
2216 .agp_alloc_pages = agp_generic_alloc_pages,
2217 .agp_destroy_page = agp_generic_destroy_page,
2218 .agp_destroy_pages = agp_generic_destroy_pages,
2219 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
2222 static const struct agp_bridge_driver intel_g33_driver = {
2223 .owner = THIS_MODULE,
2224 .aperture_sizes = intel_i830_sizes,
2225 .size_type = FIXED_APER_SIZE,
2226 .num_aperture_sizes = 4,
2227 .needs_scratch_page = true,
2228 .configure = intel_i915_configure,
2229 .fetch_size = intel_i9xx_fetch_size,
2230 .cleanup = intel_i915_cleanup,
2231 .tlb_flush = intel_i810_tlbflush,
2232 .mask_memory = intel_i965_mask_memory,
2233 .masks = intel_i810_masks,
2234 .agp_enable = intel_i810_agp_enable,
2235 .cache_flush = global_cache_flush,
2236 .create_gatt_table = intel_i915_create_gatt_table,
2237 .free_gatt_table = intel_i830_free_gatt_table,
2238 .insert_memory = intel_i915_insert_entries,
2239 .remove_memory = intel_i915_remove_entries,
2240 .alloc_by_type = intel_i830_alloc_by_type,
2241 .free_by_type = intel_i810_free_by_type,
2242 .agp_alloc_page = agp_generic_alloc_page,
2243 .agp_alloc_pages = agp_generic_alloc_pages,
2244 .agp_destroy_page = agp_generic_destroy_page,
2245 .agp_destroy_pages = agp_generic_destroy_pages,
2246 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
2247 .chipset_flush = intel_i915_chipset_flush,
2248 #ifdef USE_PCI_DMA_API
2249 .agp_map_page = intel_agp_map_page,
2250 .agp_unmap_page = intel_agp_unmap_page,
2251 .agp_map_memory = intel_agp_map_memory,
2252 .agp_unmap_memory = intel_agp_unmap_memory,
2256 static int find_gmch(u16 device)
2258 struct pci_dev *gmch_device;
2260 gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL);
2261 if (gmch_device && PCI_FUNC(gmch_device->devfn) != 0) {
2262 gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL,
2263 device, gmch_device);
2269 intel_private.pcidev = gmch_device;
2273 /* Table to describe Intel GMCH and AGP/PCIE GART drivers. At least one of
2274 * driver and gmch_driver must be non-null, and find_gmch will determine
2275 * which one should be used if a gmch_chip_id is present.
2277 static const struct intel_driver_description {
2278 unsigned int chip_id;
2279 unsigned int gmch_chip_id;
2280 unsigned int multi_gmch_chip; /* if we have more gfx chip type on this HB. */
2282 const struct agp_bridge_driver *driver;
2283 const struct agp_bridge_driver *gmch_driver;
2284 } intel_agp_chipsets[] = {
2285 { PCI_DEVICE_ID_INTEL_82443LX_0, 0, 0, "440LX", &intel_generic_driver, NULL },
2286 { PCI_DEVICE_ID_INTEL_82443BX_0, 0, 0, "440BX", &intel_generic_driver, NULL },
2287 { PCI_DEVICE_ID_INTEL_82443GX_0, 0, 0, "440GX", &intel_generic_driver, NULL },
2288 { PCI_DEVICE_ID_INTEL_82810_MC1, PCI_DEVICE_ID_INTEL_82810_IG1, 0, "i810",
2289 NULL, &intel_810_driver },
2290 { PCI_DEVICE_ID_INTEL_82810_MC3, PCI_DEVICE_ID_INTEL_82810_IG3, 0, "i810",
2291 NULL, &intel_810_driver },
2292 { PCI_DEVICE_ID_INTEL_82810E_MC, PCI_DEVICE_ID_INTEL_82810E_IG, 0, "i810",
2293 NULL, &intel_810_driver },
2294 { PCI_DEVICE_ID_INTEL_82815_MC, PCI_DEVICE_ID_INTEL_82815_CGC, 0, "i815",
2295 &intel_815_driver, &intel_810_driver },
2296 { PCI_DEVICE_ID_INTEL_82820_HB, 0, 0, "i820", &intel_820_driver, NULL },
2297 { PCI_DEVICE_ID_INTEL_82820_UP_HB, 0, 0, "i820", &intel_820_driver, NULL },
2298 { PCI_DEVICE_ID_INTEL_82830_HB, PCI_DEVICE_ID_INTEL_82830_CGC, 0, "830M",
2299 &intel_830mp_driver, &intel_830_driver },
2300 { PCI_DEVICE_ID_INTEL_82840_HB, 0, 0, "i840", &intel_840_driver, NULL },
2301 { PCI_DEVICE_ID_INTEL_82845_HB, 0, 0, "845G", &intel_845_driver, NULL },
2302 { PCI_DEVICE_ID_INTEL_82845G_HB, PCI_DEVICE_ID_INTEL_82845G_IG, 0, "830M",
2303 &intel_845_driver, &intel_830_driver },
2304 { PCI_DEVICE_ID_INTEL_82850_HB, 0, 0, "i850", &intel_850_driver, NULL },
2305 { PCI_DEVICE_ID_INTEL_82854_HB, PCI_DEVICE_ID_INTEL_82854_IG, 0, "854",
2306 &intel_845_driver, &intel_830_driver },
2307 { PCI_DEVICE_ID_INTEL_82855PM_HB, 0, 0, "855PM", &intel_845_driver, NULL },
2308 { PCI_DEVICE_ID_INTEL_82855GM_HB, PCI_DEVICE_ID_INTEL_82855GM_IG, 0, "855GM",
2309 &intel_845_driver, &intel_830_driver },
2310 { PCI_DEVICE_ID_INTEL_82860_HB, 0, 0, "i860", &intel_860_driver, NULL },
2311 { PCI_DEVICE_ID_INTEL_82865_HB, PCI_DEVICE_ID_INTEL_82865_IG, 0, "865",
2312 &intel_845_driver, &intel_830_driver },
2313 { PCI_DEVICE_ID_INTEL_82875_HB, 0, 0, "i875", &intel_845_driver, NULL },
2314 { PCI_DEVICE_ID_INTEL_E7221_HB, PCI_DEVICE_ID_INTEL_E7221_IG, 0, "E7221 (i915)",
2315 NULL, &intel_915_driver },
2316 { PCI_DEVICE_ID_INTEL_82915G_HB, PCI_DEVICE_ID_INTEL_82915G_IG, 0, "915G",
2317 NULL, &intel_915_driver },
2318 { PCI_DEVICE_ID_INTEL_82915GM_HB, PCI_DEVICE_ID_INTEL_82915GM_IG, 0, "915GM",
2319 NULL, &intel_915_driver },
2320 { PCI_DEVICE_ID_INTEL_82945G_HB, PCI_DEVICE_ID_INTEL_82945G_IG, 0, "945G",
2321 NULL, &intel_915_driver },
2322 { PCI_DEVICE_ID_INTEL_82945GM_HB, PCI_DEVICE_ID_INTEL_82945GM_IG, 0, "945GM",
2323 NULL, &intel_915_driver },
2324 { PCI_DEVICE_ID_INTEL_82945GME_HB, PCI_DEVICE_ID_INTEL_82945GME_IG, 0, "945GME",
2325 NULL, &intel_915_driver },
2326 { PCI_DEVICE_ID_INTEL_82946GZ_HB, PCI_DEVICE_ID_INTEL_82946GZ_IG, 0, "946GZ",
2327 NULL, &intel_i965_driver },
2328 { PCI_DEVICE_ID_INTEL_82G35_HB, PCI_DEVICE_ID_INTEL_82G35_IG, 0, "G35",
2329 NULL, &intel_i965_driver },
2330 { PCI_DEVICE_ID_INTEL_82965Q_HB, PCI_DEVICE_ID_INTEL_82965Q_IG, 0, "965Q",
2331 NULL, &intel_i965_driver },
2332 { PCI_DEVICE_ID_INTEL_82965G_HB, PCI_DEVICE_ID_INTEL_82965G_IG, 0, "965G",
2333 NULL, &intel_i965_driver },
2334 { PCI_DEVICE_ID_INTEL_82965GM_HB, PCI_DEVICE_ID_INTEL_82965GM_IG, 0, "965GM",
2335 NULL, &intel_i965_driver },
2336 { PCI_DEVICE_ID_INTEL_82965GME_HB, PCI_DEVICE_ID_INTEL_82965GME_IG, 0, "965GME/GLE",
2337 NULL, &intel_i965_driver },
2338 { PCI_DEVICE_ID_INTEL_7505_0, 0, 0, "E7505", &intel_7505_driver, NULL },
2339 { PCI_DEVICE_ID_INTEL_7205_0, 0, 0, "E7205", &intel_7505_driver, NULL },
2340 { PCI_DEVICE_ID_INTEL_G33_HB, PCI_DEVICE_ID_INTEL_G33_IG, 0, "G33",
2341 NULL, &intel_g33_driver },
2342 { PCI_DEVICE_ID_INTEL_Q35_HB, PCI_DEVICE_ID_INTEL_Q35_IG, 0, "Q35",
2343 NULL, &intel_g33_driver },
2344 { PCI_DEVICE_ID_INTEL_Q33_HB, PCI_DEVICE_ID_INTEL_Q33_IG, 0, "Q33",
2345 NULL, &intel_g33_driver },
2346 { PCI_DEVICE_ID_INTEL_IGDGM_HB, PCI_DEVICE_ID_INTEL_IGDGM_IG, 0, "IGD",
2347 NULL, &intel_g33_driver },
2348 { PCI_DEVICE_ID_INTEL_IGDG_HB, PCI_DEVICE_ID_INTEL_IGDG_IG, 0, "IGD",
2349 NULL, &intel_g33_driver },
2350 { PCI_DEVICE_ID_INTEL_GM45_HB, PCI_DEVICE_ID_INTEL_GM45_IG, 0,
2351 "Mobile Intel® GM45 Express", NULL, &intel_i965_driver },
2352 { PCI_DEVICE_ID_INTEL_IGD_E_HB, PCI_DEVICE_ID_INTEL_IGD_E_IG, 0,
2353 "Intel Integrated Graphics Device", NULL, &intel_i965_driver },
2354 { PCI_DEVICE_ID_INTEL_Q45_HB, PCI_DEVICE_ID_INTEL_Q45_IG, 0,
2355 "Q45/Q43", NULL, &intel_i965_driver },
2356 { PCI_DEVICE_ID_INTEL_G45_HB, PCI_DEVICE_ID_INTEL_G45_IG, 0,
2357 "G45/G43", NULL, &intel_i965_driver },
2358 { PCI_DEVICE_ID_INTEL_B43_HB, PCI_DEVICE_ID_INTEL_B43_IG, 0,
2359 "B43", NULL, &intel_i965_driver },
2360 { PCI_DEVICE_ID_INTEL_G41_HB, PCI_DEVICE_ID_INTEL_G41_IG, 0,
2361 "G41", NULL, &intel_i965_driver },
2362 { PCI_DEVICE_ID_INTEL_IGDNG_D_HB, PCI_DEVICE_ID_INTEL_IGDNG_D_IG, 0,
2363 "IGDNG/D", NULL, &intel_i965_driver },
2364 { PCI_DEVICE_ID_INTEL_IGDNG_M_HB, PCI_DEVICE_ID_INTEL_IGDNG_M_IG, 0,
2365 "IGDNG/M", NULL, &intel_i965_driver },
2366 { PCI_DEVICE_ID_INTEL_IGDNG_MA_HB, PCI_DEVICE_ID_INTEL_IGDNG_M_IG, 0,
2367 "IGDNG/MA", NULL, &intel_i965_driver },
2368 { 0, 0, 0, NULL, NULL, NULL }
2371 static int __devinit agp_intel_probe(struct pci_dev *pdev,
2372 const struct pci_device_id *ent)
2374 struct agp_bridge_data *bridge;
2379 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
2381 bridge = agp_alloc_bridge();
2385 for (i = 0; intel_agp_chipsets[i].name != NULL; i++) {
2386 /* In case that multiple models of gfx chip may
2387 stand on same host bridge type, this can be
2388 sure we detect the right IGD. */
2389 if (pdev->device == intel_agp_chipsets[i].chip_id) {
2390 if ((intel_agp_chipsets[i].gmch_chip_id != 0) &&
2391 find_gmch(intel_agp_chipsets[i].gmch_chip_id)) {
2393 intel_agp_chipsets[i].gmch_driver;
2395 } else if (intel_agp_chipsets[i].multi_gmch_chip) {
2398 bridge->driver = intel_agp_chipsets[i].driver;
2404 if (intel_agp_chipsets[i].name == NULL) {
2406 dev_warn(&pdev->dev, "unsupported Intel chipset [%04x/%04x]\n",
2407 pdev->vendor, pdev->device);
2408 agp_put_bridge(bridge);
2412 if (bridge->driver == NULL) {
2413 /* bridge has no AGP and no IGD detected */
2415 dev_warn(&pdev->dev, "can't find bridge device (chip_id: %04x)\n",
2416 intel_agp_chipsets[i].gmch_chip_id);
2417 agp_put_bridge(bridge);
2422 bridge->capndx = cap_ptr;
2423 bridge->dev_private_data = &intel_private;
2425 dev_info(&pdev->dev, "Intel %s Chipset\n", intel_agp_chipsets[i].name);
2428 * The following fixes the case where the BIOS has "forgotten" to
2429 * provide an address range for the GART.
2430 * 20030610 - hamish@zot.org
2432 r = &pdev->resource[0];
2433 if (!r->start && r->end) {
2434 if (pci_assign_resource(pdev, 0)) {
2435 dev_err(&pdev->dev, "can't assign resource 0\n");
2436 agp_put_bridge(bridge);
2442 * If the device has not been properly setup, the following will catch
2443 * the problem and should stop the system from crashing.
2444 * 20030610 - hamish@zot.org
2446 if (pci_enable_device(pdev)) {
2447 dev_err(&pdev->dev, "can't enable PCI device\n");
2448 agp_put_bridge(bridge);
2452 /* Fill in the mode register */
2454 pci_read_config_dword(pdev,
2455 bridge->capndx+PCI_AGP_STATUS,
2459 pci_set_drvdata(pdev, bridge);
2460 return agp_add_bridge(bridge);
2463 static void __devexit agp_intel_remove(struct pci_dev *pdev)
2465 struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
2467 agp_remove_bridge(bridge);
2469 if (intel_private.pcidev)
2470 pci_dev_put(intel_private.pcidev);
2472 agp_put_bridge(bridge);
2476 static int agp_intel_resume(struct pci_dev *pdev)
2478 struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
2481 if (bridge->driver == &intel_generic_driver)
2483 else if (bridge->driver == &intel_850_driver)
2484 intel_850_configure();
2485 else if (bridge->driver == &intel_845_driver)
2486 intel_845_configure();
2487 else if (bridge->driver == &intel_830mp_driver)
2488 intel_830mp_configure();
2489 else if (bridge->driver == &intel_915_driver)
2490 intel_i915_configure();
2491 else if (bridge->driver == &intel_830_driver)
2492 intel_i830_configure();
2493 else if (bridge->driver == &intel_810_driver)
2494 intel_i810_configure();
2495 else if (bridge->driver == &intel_i965_driver)
2496 intel_i915_configure();
2498 ret_val = agp_rebind_memory();
2506 static struct pci_device_id agp_intel_pci_table[] = {
2509 .class = (PCI_CLASS_BRIDGE_HOST << 8), \
2511 .vendor = PCI_VENDOR_ID_INTEL, \
2513 .subvendor = PCI_ANY_ID, \
2514 .subdevice = PCI_ANY_ID, \
2516 ID(PCI_DEVICE_ID_INTEL_82443LX_0),
2517 ID(PCI_DEVICE_ID_INTEL_82443BX_0),
2518 ID(PCI_DEVICE_ID_INTEL_82443GX_0),
2519 ID(PCI_DEVICE_ID_INTEL_82810_MC1),
2520 ID(PCI_DEVICE_ID_INTEL_82810_MC3),
2521 ID(PCI_DEVICE_ID_INTEL_82810E_MC),
2522 ID(PCI_DEVICE_ID_INTEL_82815_MC),
2523 ID(PCI_DEVICE_ID_INTEL_82820_HB),
2524 ID(PCI_DEVICE_ID_INTEL_82820_UP_HB),
2525 ID(PCI_DEVICE_ID_INTEL_82830_HB),
2526 ID(PCI_DEVICE_ID_INTEL_82840_HB),
2527 ID(PCI_DEVICE_ID_INTEL_82845_HB),
2528 ID(PCI_DEVICE_ID_INTEL_82845G_HB),
2529 ID(PCI_DEVICE_ID_INTEL_82850_HB),
2530 ID(PCI_DEVICE_ID_INTEL_82854_HB),
2531 ID(PCI_DEVICE_ID_INTEL_82855PM_HB),
2532 ID(PCI_DEVICE_ID_INTEL_82855GM_HB),
2533 ID(PCI_DEVICE_ID_INTEL_82860_HB),
2534 ID(PCI_DEVICE_ID_INTEL_82865_HB),
2535 ID(PCI_DEVICE_ID_INTEL_82875_HB),
2536 ID(PCI_DEVICE_ID_INTEL_7505_0),
2537 ID(PCI_DEVICE_ID_INTEL_7205_0),
2538 ID(PCI_DEVICE_ID_INTEL_E7221_HB),
2539 ID(PCI_DEVICE_ID_INTEL_82915G_HB),
2540 ID(PCI_DEVICE_ID_INTEL_82915GM_HB),
2541 ID(PCI_DEVICE_ID_INTEL_82945G_HB),
2542 ID(PCI_DEVICE_ID_INTEL_82945GM_HB),
2543 ID(PCI_DEVICE_ID_INTEL_82945GME_HB),
2544 ID(PCI_DEVICE_ID_INTEL_IGDGM_HB),
2545 ID(PCI_DEVICE_ID_INTEL_IGDG_HB),
2546 ID(PCI_DEVICE_ID_INTEL_82946GZ_HB),
2547 ID(PCI_DEVICE_ID_INTEL_82G35_HB),
2548 ID(PCI_DEVICE_ID_INTEL_82965Q_HB),
2549 ID(PCI_DEVICE_ID_INTEL_82965G_HB),
2550 ID(PCI_DEVICE_ID_INTEL_82965GM_HB),
2551 ID(PCI_DEVICE_ID_INTEL_82965GME_HB),
2552 ID(PCI_DEVICE_ID_INTEL_G33_HB),
2553 ID(PCI_DEVICE_ID_INTEL_Q35_HB),
2554 ID(PCI_DEVICE_ID_INTEL_Q33_HB),
2555 ID(PCI_DEVICE_ID_INTEL_GM45_HB),
2556 ID(PCI_DEVICE_ID_INTEL_IGD_E_HB),
2557 ID(PCI_DEVICE_ID_INTEL_Q45_HB),
2558 ID(PCI_DEVICE_ID_INTEL_G45_HB),
2559 ID(PCI_DEVICE_ID_INTEL_G41_HB),
2560 ID(PCI_DEVICE_ID_INTEL_B43_HB),
2561 ID(PCI_DEVICE_ID_INTEL_IGDNG_D_HB),
2562 ID(PCI_DEVICE_ID_INTEL_IGDNG_M_HB),
2563 ID(PCI_DEVICE_ID_INTEL_IGDNG_MA_HB),
2567 MODULE_DEVICE_TABLE(pci, agp_intel_pci_table);
2569 static struct pci_driver agp_intel_pci_driver = {
2570 .name = "agpgart-intel",
2571 .id_table = agp_intel_pci_table,
2572 .probe = agp_intel_probe,
2573 .remove = __devexit_p(agp_intel_remove),
2575 .resume = agp_intel_resume,
2579 static int __init agp_intel_init(void)
2583 return pci_register_driver(&agp_intel_pci_driver);
2586 static void __exit agp_intel_cleanup(void)
2588 pci_unregister_driver(&agp_intel_pci_driver);
2591 module_init(agp_intel_init);
2592 module_exit(agp_intel_cleanup);
2594 MODULE_AUTHOR("Dave Jones <davej@redhat.com>");
2595 MODULE_LICENSE("GPL and additional rights");