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>
13 #define PCI_DEVICE_ID_INTEL_E7221_HB 0x2588
14 #define PCI_DEVICE_ID_INTEL_E7221_IG 0x258a
15 #define PCI_DEVICE_ID_INTEL_82946GZ_HB 0x2970
16 #define PCI_DEVICE_ID_INTEL_82946GZ_IG 0x2972
17 #define PCI_DEVICE_ID_INTEL_82965G_1_HB 0x2980
18 #define PCI_DEVICE_ID_INTEL_82965G_1_IG 0x2982
19 #define PCI_DEVICE_ID_INTEL_82965Q_HB 0x2990
20 #define PCI_DEVICE_ID_INTEL_82965Q_IG 0x2992
21 #define PCI_DEVICE_ID_INTEL_82965G_HB 0x29A0
22 #define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2
23 #define PCI_DEVICE_ID_INTEL_82965GM_HB 0x2A00
24 #define PCI_DEVICE_ID_INTEL_82965GM_IG 0x2A02
25 #define PCI_DEVICE_ID_INTEL_82965GME_HB 0x2A10
26 #define PCI_DEVICE_ID_INTEL_82965GME_IG 0x2A12
27 #define PCI_DEVICE_ID_INTEL_82945GME_HB 0x27AC
28 #define PCI_DEVICE_ID_INTEL_82945GME_IG 0x27AE
29 #define PCI_DEVICE_ID_INTEL_G33_HB 0x29C0
30 #define PCI_DEVICE_ID_INTEL_G33_IG 0x29C2
31 #define PCI_DEVICE_ID_INTEL_Q35_HB 0x29B0
32 #define PCI_DEVICE_ID_INTEL_Q35_IG 0x29B2
33 #define PCI_DEVICE_ID_INTEL_Q33_HB 0x29D0
34 #define PCI_DEVICE_ID_INTEL_Q33_IG 0x29D2
36 #define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \
37 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_1_HB || \
38 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965Q_HB || \
39 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \
40 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB || \
41 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GME_HB)
43 #define IS_G33 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G33_HB || \
44 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q35_HB || \
45 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q33_HB)
47 extern int agp_memory_reserved;
50 /* Intel 815 register */
51 #define INTEL_815_APCONT 0x51
52 #define INTEL_815_ATTBASE_MASK ~0x1FFFFFFF
54 /* Intel i820 registers */
55 #define INTEL_I820_RDCR 0x51
56 #define INTEL_I820_ERRSTS 0xc8
58 /* Intel i840 registers */
59 #define INTEL_I840_MCHCFG 0x50
60 #define INTEL_I840_ERRSTS 0xc8
62 /* Intel i850 registers */
63 #define INTEL_I850_MCHCFG 0x50
64 #define INTEL_I850_ERRSTS 0xc8
66 /* intel 915G registers */
67 #define I915_GMADDR 0x18
68 #define I915_MMADDR 0x10
69 #define I915_PTEADDR 0x1C
70 #define I915_GMCH_GMS_STOLEN_48M (0x6 << 4)
71 #define I915_GMCH_GMS_STOLEN_64M (0x7 << 4)
72 #define G33_GMCH_GMS_STOLEN_128M (0x8 << 4)
73 #define G33_GMCH_GMS_STOLEN_256M (0x9 << 4)
75 /* Intel 965G registers */
76 #define I965_MSAC 0x62
78 /* Intel 7505 registers */
79 #define INTEL_I7505_APSIZE 0x74
80 #define INTEL_I7505_NCAPID 0x60
81 #define INTEL_I7505_NISTAT 0x6c
82 #define INTEL_I7505_ATTBASE 0x78
83 #define INTEL_I7505_ERRSTS 0x42
84 #define INTEL_I7505_AGPCTRL 0x70
85 #define INTEL_I7505_MCHCFG 0x50
87 static const struct aper_size_info_fixed intel_i810_sizes[] =
90 /* The 32M mode still requires a 64k gatt */
94 #define AGP_DCACHE_MEMORY 1
95 #define AGP_PHYS_MEMORY 2
96 #define INTEL_AGP_CACHED_MEMORY 3
98 static struct gatt_mask intel_i810_masks[] =
100 {.mask = I810_PTE_VALID, .type = 0},
101 {.mask = (I810_PTE_VALID | I810_PTE_LOCAL), .type = AGP_DCACHE_MEMORY},
102 {.mask = I810_PTE_VALID, .type = 0},
103 {.mask = I810_PTE_VALID | I830_PTE_SYSTEM_CACHED,
104 .type = INTEL_AGP_CACHED_MEMORY}
107 static struct _intel_private {
108 struct pci_dev *pcidev; /* device one */
109 u8 __iomem *registers;
110 u32 __iomem *gtt; /* I915G */
111 int num_dcache_entries;
112 /* gtt_entries is the number of gtt entries that are already mapped
113 * to stolen memory. Stolen memory is larger than the memory mapped
114 * through gtt_entries, as it includes some reserved space for the BIOS
115 * popup and for the GTT.
117 int gtt_entries; /* i830+ */
120 static int intel_i810_fetch_size(void)
123 struct aper_size_info_fixed *values;
125 pci_read_config_dword(agp_bridge->dev, I810_SMRAM_MISCC, &smram_miscc);
126 values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes);
128 if ((smram_miscc & I810_GMS) == I810_GMS_DISABLE) {
129 printk(KERN_WARNING PFX "i810 is disabled\n");
132 if ((smram_miscc & I810_GFX_MEM_WIN_SIZE) == I810_GFX_MEM_WIN_32M) {
133 agp_bridge->previous_size =
134 agp_bridge->current_size = (void *) (values + 1);
135 agp_bridge->aperture_size_idx = 1;
136 return values[1].size;
138 agp_bridge->previous_size =
139 agp_bridge->current_size = (void *) (values);
140 agp_bridge->aperture_size_idx = 0;
141 return values[0].size;
147 static int intel_i810_configure(void)
149 struct aper_size_info_fixed *current_size;
153 current_size = A_SIZE_FIX(agp_bridge->current_size);
155 if (!intel_private.registers) {
156 pci_read_config_dword(intel_private.pcidev, I810_MMADDR, &temp);
159 intel_private.registers = ioremap(temp, 128 * 4096);
160 if (!intel_private.registers) {
161 printk(KERN_ERR PFX "Unable to remap memory.\n");
166 if ((readl(intel_private.registers+I810_DRAM_CTL)
167 & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) {
168 /* This will need to be dynamically assigned */
169 printk(KERN_INFO PFX "detected 4MB dedicated video ram.\n");
170 intel_private.num_dcache_entries = 1024;
172 pci_read_config_dword(intel_private.pcidev, I810_GMADDR, &temp);
173 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
174 writel(agp_bridge->gatt_bus_addr | I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL);
175 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
177 if (agp_bridge->driver->needs_scratch_page) {
178 for (i = 0; i < current_size->num_entries; i++) {
179 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
180 readl(intel_private.registers+I810_PTE_BASE+(i*4)); /* PCI posting. */
183 global_cache_flush();
187 static void intel_i810_cleanup(void)
189 writel(0, intel_private.registers+I810_PGETBL_CTL);
190 readl(intel_private.registers); /* PCI Posting. */
191 iounmap(intel_private.registers);
194 static void intel_i810_tlbflush(struct agp_memory *mem)
199 static void intel_i810_agp_enable(struct agp_bridge_data *bridge, u32 mode)
204 /* Exists to support ARGB cursors */
205 static void *i8xx_alloc_pages(void)
209 page = alloc_pages(GFP_KERNEL | GFP_DMA32, 2);
213 if (change_page_attr(page, 4, PAGE_KERNEL_NOCACHE) < 0) {
214 change_page_attr(page, 4, PAGE_KERNEL);
216 __free_pages(page, 2);
221 atomic_inc(&agp_bridge->current_memory_agp);
222 return page_address(page);
225 static void i8xx_destroy_pages(void *addr)
232 page = virt_to_page(addr);
233 change_page_attr(page, 4, PAGE_KERNEL);
236 __free_pages(page, 2);
237 atomic_dec(&agp_bridge->current_memory_agp);
240 static int intel_i830_type_to_mask_type(struct agp_bridge_data *bridge,
243 if (type < AGP_USER_TYPES)
245 else if (type == AGP_USER_CACHED_MEMORY)
246 return INTEL_AGP_CACHED_MEMORY;
251 static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
254 int i, j, num_entries;
259 if (mem->page_count == 0)
262 temp = agp_bridge->current_size;
263 num_entries = A_SIZE_FIX(temp)->num_entries;
265 if ((pg_start + mem->page_count) > num_entries)
269 for (j = pg_start; j < (pg_start + mem->page_count); j++) {
270 if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+j))) {
276 if (type != mem->type)
279 mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
282 case AGP_DCACHE_MEMORY:
283 if (!mem->is_flushed)
284 global_cache_flush();
285 for (i = pg_start; i < (pg_start + mem->page_count); i++) {
286 writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID,
287 intel_private.registers+I810_PTE_BASE+(i*4));
289 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4));
291 case AGP_PHYS_MEMORY:
292 case AGP_NORMAL_MEMORY:
293 if (!mem->is_flushed)
294 global_cache_flush();
295 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
296 writel(agp_bridge->driver->mask_memory(agp_bridge,
299 intel_private.registers+I810_PTE_BASE+(j*4));
301 readl(intel_private.registers+I810_PTE_BASE+((j-1)*4));
307 agp_bridge->driver->tlb_flush(mem);
315 static int intel_i810_remove_entries(struct agp_memory *mem, off_t pg_start,
320 if (mem->page_count == 0)
323 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
324 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
326 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4));
328 agp_bridge->driver->tlb_flush(mem);
333 * The i810/i830 requires a physical address to program its mouse
334 * pointer into hardware.
335 * However the Xserver still writes to it through the agp aperture.
337 static struct agp_memory *alloc_agpphysmem_i8xx(size_t pg_count, int type)
339 struct agp_memory *new;
343 case 1: addr = agp_bridge->driver->agp_alloc_page(agp_bridge);
347 /* kludge to get 4 physical pages for ARGB cursor */
348 addr = i8xx_alloc_pages();
357 new = agp_create_memory(pg_count);
361 new->memory[0] = virt_to_gart(addr);
363 /* kludge to get 4 physical pages for ARGB cursor */
364 new->memory[1] = new->memory[0] + PAGE_SIZE;
365 new->memory[2] = new->memory[1] + PAGE_SIZE;
366 new->memory[3] = new->memory[2] + PAGE_SIZE;
368 new->page_count = pg_count;
369 new->num_scratch_pages = pg_count;
370 new->type = AGP_PHYS_MEMORY;
371 new->physical = new->memory[0];
375 static struct agp_memory *intel_i810_alloc_by_type(size_t pg_count, int type)
377 struct agp_memory *new;
379 if (type == AGP_DCACHE_MEMORY) {
380 if (pg_count != intel_private.num_dcache_entries)
383 new = agp_create_memory(1);
387 new->type = AGP_DCACHE_MEMORY;
388 new->page_count = pg_count;
389 new->num_scratch_pages = 0;
390 agp_free_page_array(new);
393 if (type == AGP_PHYS_MEMORY)
394 return alloc_agpphysmem_i8xx(pg_count, type);
398 static void intel_i810_free_by_type(struct agp_memory *curr)
400 agp_free_key(curr->key);
401 if (curr->type == AGP_PHYS_MEMORY) {
402 if (curr->page_count == 4)
403 i8xx_destroy_pages(gart_to_virt(curr->memory[0]));
405 agp_bridge->driver->agp_destroy_page(gart_to_virt(curr->memory[0]),
406 AGP_PAGE_DESTROY_UNMAP);
408 agp_bridge->driver->agp_destroy_page(gart_to_virt(curr->memory[0]),
409 AGP_PAGE_DESTROY_FREE);
411 agp_free_page_array(curr);
416 static unsigned long intel_i810_mask_memory(struct agp_bridge_data *bridge,
417 unsigned long addr, int type)
419 /* Type checking must be done elsewhere */
420 return addr | bridge->driver->masks[type].mask;
423 static struct aper_size_info_fixed intel_i830_sizes[] =
426 /* The 64M mode still requires a 128k gatt */
432 static void intel_i830_init_gtt_entries(void)
438 static const int ddt[4] = { 0, 16, 32, 64 };
439 int size; /* reserved space (in kb) at the top of stolen memory */
441 pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl);
445 pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL);
447 /* The 965 has a field telling us the size of the GTT,
448 * which may be larger than what is necessary to map the
451 switch (pgetbl_ctl & I965_PGETBL_SIZE_MASK) {
452 case I965_PGETBL_SIZE_128KB:
455 case I965_PGETBL_SIZE_256KB:
458 case I965_PGETBL_SIZE_512KB:
462 printk(KERN_INFO PFX "Unknown page table size, "
466 size += 4; /* add in BIOS popup space */
468 /* G33's GTT size defined in gmch_ctrl */
469 switch (gmch_ctrl & G33_PGETBL_SIZE_MASK) {
470 case G33_PGETBL_SIZE_1M:
473 case G33_PGETBL_SIZE_2M:
477 printk(KERN_INFO PFX "Unknown page table size 0x%x, "
479 (gmch_ctrl & G33_PGETBL_SIZE_MASK));
484 /* On previous hardware, the GTT size was just what was
485 * required to map the aperture.
487 size = agp_bridge->driver->fetch_size() + 4;
490 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82830_HB ||
491 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) {
492 switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
493 case I830_GMCH_GMS_STOLEN_512:
494 gtt_entries = KB(512) - KB(size);
496 case I830_GMCH_GMS_STOLEN_1024:
497 gtt_entries = MB(1) - KB(size);
499 case I830_GMCH_GMS_STOLEN_8192:
500 gtt_entries = MB(8) - KB(size);
502 case I830_GMCH_GMS_LOCAL:
503 rdct = readb(intel_private.registers+I830_RDRAM_CHANNEL_TYPE);
504 gtt_entries = (I830_RDRAM_ND(rdct) + 1) *
505 MB(ddt[I830_RDRAM_DDT(rdct)]);
513 switch (gmch_ctrl & I855_GMCH_GMS_MASK) {
514 case I855_GMCH_GMS_STOLEN_1M:
515 gtt_entries = MB(1) - KB(size);
517 case I855_GMCH_GMS_STOLEN_4M:
518 gtt_entries = MB(4) - KB(size);
520 case I855_GMCH_GMS_STOLEN_8M:
521 gtt_entries = MB(8) - KB(size);
523 case I855_GMCH_GMS_STOLEN_16M:
524 gtt_entries = MB(16) - KB(size);
526 case I855_GMCH_GMS_STOLEN_32M:
527 gtt_entries = MB(32) - KB(size);
529 case I915_GMCH_GMS_STOLEN_48M:
530 /* Check it's really I915G */
531 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_E7221_HB ||
532 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
533 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
534 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
535 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB ||
536 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GME_HB ||
538 gtt_entries = MB(48) - KB(size);
542 case I915_GMCH_GMS_STOLEN_64M:
543 /* Check it's really I915G */
544 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_E7221_HB ||
545 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
546 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
547 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
548 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB ||
549 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GME_HB ||
551 gtt_entries = MB(64) - KB(size);
555 case G33_GMCH_GMS_STOLEN_128M:
557 gtt_entries = MB(128) - KB(size);
561 case G33_GMCH_GMS_STOLEN_256M:
563 gtt_entries = MB(256) - KB(size);
573 printk(KERN_INFO PFX "Detected %dK %s memory.\n",
574 gtt_entries / KB(1), local ? "local" : "stolen");
577 "No pre-allocated video memory detected.\n");
578 gtt_entries /= KB(4);
580 intel_private.gtt_entries = gtt_entries;
583 /* The intel i830 automatically initializes the agp aperture during POST.
584 * Use the memory already set aside for in the GTT.
586 static int intel_i830_create_gatt_table(struct agp_bridge_data *bridge)
589 struct aper_size_info_fixed *size;
593 size = agp_bridge->current_size;
594 page_order = size->page_order;
595 num_entries = size->num_entries;
596 agp_bridge->gatt_table_real = NULL;
598 pci_read_config_dword(intel_private.pcidev,I810_MMADDR,&temp);
601 intel_private.registers = ioremap(temp,128 * 4096);
602 if (!intel_private.registers)
605 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
606 global_cache_flush(); /* FIXME: ?? */
608 /* we have to call this as early as possible after the MMIO base address is known */
609 intel_i830_init_gtt_entries();
611 agp_bridge->gatt_table = NULL;
613 agp_bridge->gatt_bus_addr = temp;
618 /* Return the gatt table to a sane state. Use the top of stolen
619 * memory for the GTT.
621 static int intel_i830_free_gatt_table(struct agp_bridge_data *bridge)
626 static int intel_i830_fetch_size(void)
629 struct aper_size_info_fixed *values;
631 values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes);
633 if (agp_bridge->dev->device != PCI_DEVICE_ID_INTEL_82830_HB &&
634 agp_bridge->dev->device != PCI_DEVICE_ID_INTEL_82845G_HB) {
635 /* 855GM/852GM/865G has 128MB aperture size */
636 agp_bridge->previous_size = agp_bridge->current_size = (void *) values;
637 agp_bridge->aperture_size_idx = 0;
638 return values[0].size;
641 pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl);
643 if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_128M) {
644 agp_bridge->previous_size = agp_bridge->current_size = (void *) values;
645 agp_bridge->aperture_size_idx = 0;
646 return values[0].size;
648 agp_bridge->previous_size = agp_bridge->current_size = (void *) (values + 1);
649 agp_bridge->aperture_size_idx = 1;
650 return values[1].size;
656 static int intel_i830_configure(void)
658 struct aper_size_info_fixed *current_size;
663 current_size = A_SIZE_FIX(agp_bridge->current_size);
665 pci_read_config_dword(intel_private.pcidev,I810_GMADDR,&temp);
666 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
668 pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl);
669 gmch_ctrl |= I830_GMCH_ENABLED;
670 pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl);
672 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL);
673 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
675 if (agp_bridge->driver->needs_scratch_page) {
676 for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) {
677 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
678 readl(intel_private.registers+I810_PTE_BASE+(i*4)); /* PCI Posting. */
682 global_cache_flush();
686 static void intel_i830_cleanup(void)
688 iounmap(intel_private.registers);
691 static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int type)
698 if (mem->page_count == 0)
701 temp = agp_bridge->current_size;
702 num_entries = A_SIZE_FIX(temp)->num_entries;
704 if (pg_start < intel_private.gtt_entries) {
705 printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_private.gtt_entries == 0x%.8x\n",
706 pg_start,intel_private.gtt_entries);
708 printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n");
712 if ((pg_start + mem->page_count) > num_entries)
715 /* The i830 can't check the GTT for entries since its read only,
716 * depend on the caller to make the correct offset decisions.
719 if (type != mem->type)
722 mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
724 if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY &&
725 mask_type != INTEL_AGP_CACHED_MEMORY)
728 if (!mem->is_flushed)
729 global_cache_flush();
731 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
732 writel(agp_bridge->driver->mask_memory(agp_bridge,
733 mem->memory[i], mask_type),
734 intel_private.registers+I810_PTE_BASE+(j*4));
736 readl(intel_private.registers+I810_PTE_BASE+((j-1)*4));
737 agp_bridge->driver->tlb_flush(mem);
746 static int intel_i830_remove_entries(struct agp_memory *mem,off_t pg_start,
751 if (mem->page_count == 0)
754 if (pg_start < intel_private.gtt_entries) {
755 printk (KERN_INFO PFX "Trying to disable local/stolen memory\n");
759 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
760 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
762 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4));
764 agp_bridge->driver->tlb_flush(mem);
768 static struct agp_memory *intel_i830_alloc_by_type(size_t pg_count,int type)
770 if (type == AGP_PHYS_MEMORY)
771 return alloc_agpphysmem_i8xx(pg_count, type);
772 /* always return NULL for other allocation types for now */
776 static int intel_i915_configure(void)
778 struct aper_size_info_fixed *current_size;
783 current_size = A_SIZE_FIX(agp_bridge->current_size);
785 pci_read_config_dword(intel_private.pcidev, I915_GMADDR, &temp);
787 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
789 pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl);
790 gmch_ctrl |= I830_GMCH_ENABLED;
791 pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl);
793 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL);
794 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
796 if (agp_bridge->driver->needs_scratch_page) {
797 for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) {
798 writel(agp_bridge->scratch_page, intel_private.gtt+i);
799 readl(intel_private.gtt+i); /* PCI Posting. */
803 global_cache_flush();
807 static void intel_i915_cleanup(void)
809 iounmap(intel_private.gtt);
810 iounmap(intel_private.registers);
813 static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start,
821 if (mem->page_count == 0)
824 temp = agp_bridge->current_size;
825 num_entries = A_SIZE_FIX(temp)->num_entries;
827 if (pg_start < intel_private.gtt_entries) {
828 printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_private.gtt_entries == 0x%.8x\n",
829 pg_start,intel_private.gtt_entries);
831 printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n");
835 if ((pg_start + mem->page_count) > num_entries)
838 /* The i915 can't check the GTT for entries since its read only,
839 * depend on the caller to make the correct offset decisions.
842 if (type != mem->type)
845 mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
847 if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY &&
848 mask_type != INTEL_AGP_CACHED_MEMORY)
851 if (!mem->is_flushed)
852 global_cache_flush();
854 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
855 writel(agp_bridge->driver->mask_memory(agp_bridge,
856 mem->memory[i], mask_type), intel_private.gtt+j);
859 readl(intel_private.gtt+j-1);
860 agp_bridge->driver->tlb_flush(mem);
869 static int intel_i915_remove_entries(struct agp_memory *mem,off_t pg_start,
874 if (mem->page_count == 0)
877 if (pg_start < intel_private.gtt_entries) {
878 printk (KERN_INFO PFX "Trying to disable local/stolen memory\n");
882 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
883 writel(agp_bridge->scratch_page, intel_private.gtt+i);
885 readl(intel_private.gtt+i-1);
887 agp_bridge->driver->tlb_flush(mem);
891 /* Return the aperture size by just checking the resource length. The effect
892 * described in the spec of the MSAC registers is just changing of the
895 static int intel_i9xx_fetch_size(void)
897 int num_sizes = ARRAY_SIZE(intel_i830_sizes);
898 int aper_size; /* size in megabytes */
901 aper_size = pci_resource_len(intel_private.pcidev, 2) / MB(1);
903 for (i = 0; i < num_sizes; i++) {
904 if (aper_size == intel_i830_sizes[i].size) {
905 agp_bridge->current_size = intel_i830_sizes + i;
906 agp_bridge->previous_size = agp_bridge->current_size;
914 /* The intel i915 automatically initializes the agp aperture during POST.
915 * Use the memory already set aside for in the GTT.
917 static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge)
920 struct aper_size_info_fixed *size;
923 int gtt_map_size = 256 * 1024;
925 size = agp_bridge->current_size;
926 page_order = size->page_order;
927 num_entries = size->num_entries;
928 agp_bridge->gatt_table_real = NULL;
930 pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &temp);
931 pci_read_config_dword(intel_private.pcidev, I915_PTEADDR,&temp2);
934 gtt_map_size = 1024 * 1024; /* 1M on G33 */
935 intel_private.gtt = ioremap(temp2, gtt_map_size);
936 if (!intel_private.gtt)
941 intel_private.registers = ioremap(temp,128 * 4096);
942 if (!intel_private.registers) {
943 iounmap(intel_private.gtt);
947 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
948 global_cache_flush(); /* FIXME: ? */
950 /* we have to call this as early as possible after the MMIO base address is known */
951 intel_i830_init_gtt_entries();
953 agp_bridge->gatt_table = NULL;
955 agp_bridge->gatt_bus_addr = temp;
961 * The i965 supports 36-bit physical addresses, but to keep
962 * the format of the GTT the same, the bits that don't fit
963 * in a 32-bit word are shifted down to bits 4..7.
965 * Gcc is smart enough to notice that "(addr >> 28) & 0xf0"
966 * is always zero on 32-bit architectures, so no need to make
969 static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge,
970 unsigned long addr, int type)
972 /* Shift high bits down */
973 addr |= (addr >> 28) & 0xf0;
975 /* Type checking must be done elsewhere */
976 return addr | bridge->driver->masks[type].mask;
979 /* The intel i965 automatically initializes the agp aperture during POST.
980 * Use the memory already set aside for in the GTT.
982 static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge)
985 struct aper_size_info_fixed *size;
989 size = agp_bridge->current_size;
990 page_order = size->page_order;
991 num_entries = size->num_entries;
992 agp_bridge->gatt_table_real = NULL;
994 pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &temp);
997 intel_private.gtt = ioremap((temp + (512 * 1024)) , 512 * 1024);
999 if (!intel_private.gtt)
1003 intel_private.registers = ioremap(temp,128 * 4096);
1004 if (!intel_private.registers) {
1005 iounmap(intel_private.gtt);
1009 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
1010 global_cache_flush(); /* FIXME: ? */
1012 /* we have to call this as early as possible after the MMIO base address is known */
1013 intel_i830_init_gtt_entries();
1015 agp_bridge->gatt_table = NULL;
1017 agp_bridge->gatt_bus_addr = temp;
1023 static int intel_fetch_size(void)
1027 struct aper_size_info_16 *values;
1029 pci_read_config_word(agp_bridge->dev, INTEL_APSIZE, &temp);
1030 values = A_SIZE_16(agp_bridge->driver->aperture_sizes);
1032 for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) {
1033 if (temp == values[i].size_value) {
1034 agp_bridge->previous_size = agp_bridge->current_size = (void *) (values + i);
1035 agp_bridge->aperture_size_idx = i;
1036 return values[i].size;
1043 static int __intel_8xx_fetch_size(u8 temp)
1046 struct aper_size_info_8 *values;
1048 values = A_SIZE_8(agp_bridge->driver->aperture_sizes);
1050 for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) {
1051 if (temp == values[i].size_value) {
1052 agp_bridge->previous_size =
1053 agp_bridge->current_size = (void *) (values + i);
1054 agp_bridge->aperture_size_idx = i;
1055 return values[i].size;
1061 static int intel_8xx_fetch_size(void)
1065 pci_read_config_byte(agp_bridge->dev, INTEL_APSIZE, &temp);
1066 return __intel_8xx_fetch_size(temp);
1069 static int intel_815_fetch_size(void)
1073 /* Intel 815 chipsets have a _weird_ APSIZE register with only
1074 * one non-reserved bit, so mask the others out ... */
1075 pci_read_config_byte(agp_bridge->dev, INTEL_APSIZE, &temp);
1078 return __intel_8xx_fetch_size(temp);
1081 static void intel_tlbflush(struct agp_memory *mem)
1083 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2200);
1084 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2280);
1088 static void intel_8xx_tlbflush(struct agp_memory *mem)
1091 pci_read_config_dword(agp_bridge->dev, INTEL_AGPCTRL, &temp);
1092 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, temp & ~(1 << 7));
1093 pci_read_config_dword(agp_bridge->dev, INTEL_AGPCTRL, &temp);
1094 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, temp | (1 << 7));
1098 static void intel_cleanup(void)
1101 struct aper_size_info_16 *previous_size;
1103 previous_size = A_SIZE_16(agp_bridge->previous_size);
1104 pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp);
1105 pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp & ~(1 << 9));
1106 pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, previous_size->size_value);
1110 static void intel_8xx_cleanup(void)
1113 struct aper_size_info_8 *previous_size;
1115 previous_size = A_SIZE_8(agp_bridge->previous_size);
1116 pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp);
1117 pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp & ~(1 << 9));
1118 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, previous_size->size_value);
1122 static int intel_configure(void)
1126 struct aper_size_info_16 *current_size;
1128 current_size = A_SIZE_16(agp_bridge->current_size);
1131 pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1133 /* address to map to */
1134 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1135 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1137 /* attbase - aperture base */
1138 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1141 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2280);
1144 pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp2);
1145 pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG,
1146 (temp2 & ~(1 << 10)) | (1 << 9));
1147 /* clear any possible error conditions */
1148 pci_write_config_byte(agp_bridge->dev, INTEL_ERRSTS + 1, 7);
1152 static int intel_815_configure(void)
1156 struct aper_size_info_8 *current_size;
1158 /* attbase - aperture base */
1159 /* the Intel 815 chipset spec. says that bits 29-31 in the
1160 * ATTBASE register are reserved -> try not to write them */
1161 if (agp_bridge->gatt_bus_addr & INTEL_815_ATTBASE_MASK) {
1162 printk (KERN_EMERG PFX "gatt bus addr too high");
1166 current_size = A_SIZE_8(agp_bridge->current_size);
1169 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE,
1170 current_size->size_value);
1172 /* address to map to */
1173 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1174 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1176 pci_read_config_dword(agp_bridge->dev, INTEL_ATTBASE, &addr);
1177 addr &= INTEL_815_ATTBASE_MASK;
1178 addr |= agp_bridge->gatt_bus_addr;
1179 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, addr);
1182 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1185 pci_read_config_byte(agp_bridge->dev, INTEL_815_APCONT, &temp2);
1186 pci_write_config_byte(agp_bridge->dev, INTEL_815_APCONT, temp2 | (1 << 1));
1188 /* clear any possible error conditions */
1189 /* Oddness : this chipset seems to have no ERRSTS register ! */
1193 static void intel_820_tlbflush(struct agp_memory *mem)
1198 static void intel_820_cleanup(void)
1201 struct aper_size_info_8 *previous_size;
1203 previous_size = A_SIZE_8(agp_bridge->previous_size);
1204 pci_read_config_byte(agp_bridge->dev, INTEL_I820_RDCR, &temp);
1205 pci_write_config_byte(agp_bridge->dev, INTEL_I820_RDCR,
1207 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE,
1208 previous_size->size_value);
1212 static int intel_820_configure(void)
1216 struct aper_size_info_8 *current_size;
1218 current_size = A_SIZE_8(agp_bridge->current_size);
1221 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1223 /* address to map to */
1224 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1225 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1227 /* attbase - aperture base */
1228 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1231 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1233 /* global enable aperture access */
1234 /* This flag is not accessed through MCHCFG register as in */
1236 pci_read_config_byte(agp_bridge->dev, INTEL_I820_RDCR, &temp2);
1237 pci_write_config_byte(agp_bridge->dev, INTEL_I820_RDCR, temp2 | (1 << 1));
1238 /* clear any possible AGP-related error conditions */
1239 pci_write_config_word(agp_bridge->dev, INTEL_I820_ERRSTS, 0x001c);
1243 static int intel_840_configure(void)
1247 struct aper_size_info_8 *current_size;
1249 current_size = A_SIZE_8(agp_bridge->current_size);
1252 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1254 /* address to map to */
1255 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1256 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1258 /* attbase - aperture base */
1259 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1262 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1265 pci_read_config_word(agp_bridge->dev, INTEL_I840_MCHCFG, &temp2);
1266 pci_write_config_word(agp_bridge->dev, INTEL_I840_MCHCFG, temp2 | (1 << 9));
1267 /* clear any possible error conditions */
1268 pci_write_config_word(agp_bridge->dev, INTEL_I840_ERRSTS, 0xc000);
1272 static int intel_845_configure(void)
1276 struct aper_size_info_8 *current_size;
1278 current_size = A_SIZE_8(agp_bridge->current_size);
1281 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1283 if (agp_bridge->apbase_config != 0) {
1284 pci_write_config_dword(agp_bridge->dev, AGP_APBASE,
1285 agp_bridge->apbase_config);
1287 /* address to map to */
1288 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1289 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1290 agp_bridge->apbase_config = temp;
1293 /* attbase - aperture base */
1294 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1297 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1300 pci_read_config_byte(agp_bridge->dev, INTEL_I845_AGPM, &temp2);
1301 pci_write_config_byte(agp_bridge->dev, INTEL_I845_AGPM, temp2 | (1 << 1));
1302 /* clear any possible error conditions */
1303 pci_write_config_word(agp_bridge->dev, INTEL_I845_ERRSTS, 0x001c);
1307 static int intel_850_configure(void)
1311 struct aper_size_info_8 *current_size;
1313 current_size = A_SIZE_8(agp_bridge->current_size);
1316 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1318 /* address to map to */
1319 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1320 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1322 /* attbase - aperture base */
1323 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1326 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1329 pci_read_config_word(agp_bridge->dev, INTEL_I850_MCHCFG, &temp2);
1330 pci_write_config_word(agp_bridge->dev, INTEL_I850_MCHCFG, temp2 | (1 << 9));
1331 /* clear any possible AGP-related error conditions */
1332 pci_write_config_word(agp_bridge->dev, INTEL_I850_ERRSTS, 0x001c);
1336 static int intel_860_configure(void)
1340 struct aper_size_info_8 *current_size;
1342 current_size = A_SIZE_8(agp_bridge->current_size);
1345 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1347 /* address to map to */
1348 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1349 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1351 /* attbase - aperture base */
1352 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1355 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1358 pci_read_config_word(agp_bridge->dev, INTEL_I860_MCHCFG, &temp2);
1359 pci_write_config_word(agp_bridge->dev, INTEL_I860_MCHCFG, temp2 | (1 << 9));
1360 /* clear any possible AGP-related error conditions */
1361 pci_write_config_word(agp_bridge->dev, INTEL_I860_ERRSTS, 0xf700);
1365 static int intel_830mp_configure(void)
1369 struct aper_size_info_8 *current_size;
1371 current_size = A_SIZE_8(agp_bridge->current_size);
1374 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1376 /* address to map to */
1377 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1378 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1380 /* attbase - aperture base */
1381 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1384 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1387 pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp2);
1388 pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp2 | (1 << 9));
1389 /* clear any possible AGP-related error conditions */
1390 pci_write_config_word(agp_bridge->dev, INTEL_I830_ERRSTS, 0x1c);
1394 static int intel_7505_configure(void)
1398 struct aper_size_info_8 *current_size;
1400 current_size = A_SIZE_8(agp_bridge->current_size);
1403 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1405 /* address to map to */
1406 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1407 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1409 /* attbase - aperture base */
1410 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1413 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1416 pci_read_config_word(agp_bridge->dev, INTEL_I7505_MCHCFG, &temp2);
1417 pci_write_config_word(agp_bridge->dev, INTEL_I7505_MCHCFG, temp2 | (1 << 9));
1422 /* Setup function */
1423 static const struct gatt_mask intel_generic_masks[] =
1425 {.mask = 0x00000017, .type = 0}
1428 static const struct aper_size_info_8 intel_815_sizes[2] =
1434 static const struct aper_size_info_8 intel_8xx_sizes[7] =
1437 {128, 32768, 5, 32},
1445 static const struct aper_size_info_16 intel_generic_sizes[7] =
1448 {128, 32768, 5, 32},
1456 static const struct aper_size_info_8 intel_830mp_sizes[4] =
1459 {128, 32768, 5, 32},
1464 static const struct agp_bridge_driver intel_generic_driver = {
1465 .owner = THIS_MODULE,
1466 .aperture_sizes = intel_generic_sizes,
1467 .size_type = U16_APER_SIZE,
1468 .num_aperture_sizes = 7,
1469 .configure = intel_configure,
1470 .fetch_size = intel_fetch_size,
1471 .cleanup = intel_cleanup,
1472 .tlb_flush = intel_tlbflush,
1473 .mask_memory = agp_generic_mask_memory,
1474 .masks = intel_generic_masks,
1475 .agp_enable = agp_generic_enable,
1476 .cache_flush = global_cache_flush,
1477 .create_gatt_table = agp_generic_create_gatt_table,
1478 .free_gatt_table = agp_generic_free_gatt_table,
1479 .insert_memory = agp_generic_insert_memory,
1480 .remove_memory = agp_generic_remove_memory,
1481 .alloc_by_type = agp_generic_alloc_by_type,
1482 .free_by_type = agp_generic_free_by_type,
1483 .agp_alloc_page = agp_generic_alloc_page,
1484 .agp_destroy_page = agp_generic_destroy_page,
1485 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1488 static const struct agp_bridge_driver intel_810_driver = {
1489 .owner = THIS_MODULE,
1490 .aperture_sizes = intel_i810_sizes,
1491 .size_type = FIXED_APER_SIZE,
1492 .num_aperture_sizes = 2,
1493 .needs_scratch_page = TRUE,
1494 .configure = intel_i810_configure,
1495 .fetch_size = intel_i810_fetch_size,
1496 .cleanup = intel_i810_cleanup,
1497 .tlb_flush = intel_i810_tlbflush,
1498 .mask_memory = intel_i810_mask_memory,
1499 .masks = intel_i810_masks,
1500 .agp_enable = intel_i810_agp_enable,
1501 .cache_flush = global_cache_flush,
1502 .create_gatt_table = agp_generic_create_gatt_table,
1503 .free_gatt_table = agp_generic_free_gatt_table,
1504 .insert_memory = intel_i810_insert_entries,
1505 .remove_memory = intel_i810_remove_entries,
1506 .alloc_by_type = intel_i810_alloc_by_type,
1507 .free_by_type = intel_i810_free_by_type,
1508 .agp_alloc_page = agp_generic_alloc_page,
1509 .agp_destroy_page = agp_generic_destroy_page,
1510 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1513 static const struct agp_bridge_driver intel_815_driver = {
1514 .owner = THIS_MODULE,
1515 .aperture_sizes = intel_815_sizes,
1516 .size_type = U8_APER_SIZE,
1517 .num_aperture_sizes = 2,
1518 .configure = intel_815_configure,
1519 .fetch_size = intel_815_fetch_size,
1520 .cleanup = intel_8xx_cleanup,
1521 .tlb_flush = intel_8xx_tlbflush,
1522 .mask_memory = agp_generic_mask_memory,
1523 .masks = intel_generic_masks,
1524 .agp_enable = agp_generic_enable,
1525 .cache_flush = global_cache_flush,
1526 .create_gatt_table = agp_generic_create_gatt_table,
1527 .free_gatt_table = agp_generic_free_gatt_table,
1528 .insert_memory = agp_generic_insert_memory,
1529 .remove_memory = agp_generic_remove_memory,
1530 .alloc_by_type = agp_generic_alloc_by_type,
1531 .free_by_type = agp_generic_free_by_type,
1532 .agp_alloc_page = agp_generic_alloc_page,
1533 .agp_destroy_page = agp_generic_destroy_page,
1534 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1537 static const struct agp_bridge_driver intel_830_driver = {
1538 .owner = THIS_MODULE,
1539 .aperture_sizes = intel_i830_sizes,
1540 .size_type = FIXED_APER_SIZE,
1541 .num_aperture_sizes = 4,
1542 .needs_scratch_page = TRUE,
1543 .configure = intel_i830_configure,
1544 .fetch_size = intel_i830_fetch_size,
1545 .cleanup = intel_i830_cleanup,
1546 .tlb_flush = intel_i810_tlbflush,
1547 .mask_memory = intel_i810_mask_memory,
1548 .masks = intel_i810_masks,
1549 .agp_enable = intel_i810_agp_enable,
1550 .cache_flush = global_cache_flush,
1551 .create_gatt_table = intel_i830_create_gatt_table,
1552 .free_gatt_table = intel_i830_free_gatt_table,
1553 .insert_memory = intel_i830_insert_entries,
1554 .remove_memory = intel_i830_remove_entries,
1555 .alloc_by_type = intel_i830_alloc_by_type,
1556 .free_by_type = intel_i810_free_by_type,
1557 .agp_alloc_page = agp_generic_alloc_page,
1558 .agp_destroy_page = agp_generic_destroy_page,
1559 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
1562 static const struct agp_bridge_driver intel_820_driver = {
1563 .owner = THIS_MODULE,
1564 .aperture_sizes = intel_8xx_sizes,
1565 .size_type = U8_APER_SIZE,
1566 .num_aperture_sizes = 7,
1567 .configure = intel_820_configure,
1568 .fetch_size = intel_8xx_fetch_size,
1569 .cleanup = intel_820_cleanup,
1570 .tlb_flush = intel_820_tlbflush,
1571 .mask_memory = agp_generic_mask_memory,
1572 .masks = intel_generic_masks,
1573 .agp_enable = agp_generic_enable,
1574 .cache_flush = global_cache_flush,
1575 .create_gatt_table = agp_generic_create_gatt_table,
1576 .free_gatt_table = agp_generic_free_gatt_table,
1577 .insert_memory = agp_generic_insert_memory,
1578 .remove_memory = agp_generic_remove_memory,
1579 .alloc_by_type = agp_generic_alloc_by_type,
1580 .free_by_type = agp_generic_free_by_type,
1581 .agp_alloc_page = agp_generic_alloc_page,
1582 .agp_destroy_page = agp_generic_destroy_page,
1583 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1586 static const struct agp_bridge_driver intel_830mp_driver = {
1587 .owner = THIS_MODULE,
1588 .aperture_sizes = intel_830mp_sizes,
1589 .size_type = U8_APER_SIZE,
1590 .num_aperture_sizes = 4,
1591 .configure = intel_830mp_configure,
1592 .fetch_size = intel_8xx_fetch_size,
1593 .cleanup = intel_8xx_cleanup,
1594 .tlb_flush = intel_8xx_tlbflush,
1595 .mask_memory = agp_generic_mask_memory,
1596 .masks = intel_generic_masks,
1597 .agp_enable = agp_generic_enable,
1598 .cache_flush = global_cache_flush,
1599 .create_gatt_table = agp_generic_create_gatt_table,
1600 .free_gatt_table = agp_generic_free_gatt_table,
1601 .insert_memory = agp_generic_insert_memory,
1602 .remove_memory = agp_generic_remove_memory,
1603 .alloc_by_type = agp_generic_alloc_by_type,
1604 .free_by_type = agp_generic_free_by_type,
1605 .agp_alloc_page = agp_generic_alloc_page,
1606 .agp_destroy_page = agp_generic_destroy_page,
1607 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1610 static const struct agp_bridge_driver intel_840_driver = {
1611 .owner = THIS_MODULE,
1612 .aperture_sizes = intel_8xx_sizes,
1613 .size_type = U8_APER_SIZE,
1614 .num_aperture_sizes = 7,
1615 .configure = intel_840_configure,
1616 .fetch_size = intel_8xx_fetch_size,
1617 .cleanup = intel_8xx_cleanup,
1618 .tlb_flush = intel_8xx_tlbflush,
1619 .mask_memory = agp_generic_mask_memory,
1620 .masks = intel_generic_masks,
1621 .agp_enable = agp_generic_enable,
1622 .cache_flush = global_cache_flush,
1623 .create_gatt_table = agp_generic_create_gatt_table,
1624 .free_gatt_table = agp_generic_free_gatt_table,
1625 .insert_memory = agp_generic_insert_memory,
1626 .remove_memory = agp_generic_remove_memory,
1627 .alloc_by_type = agp_generic_alloc_by_type,
1628 .free_by_type = agp_generic_free_by_type,
1629 .agp_alloc_page = agp_generic_alloc_page,
1630 .agp_destroy_page = agp_generic_destroy_page,
1631 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1634 static const struct agp_bridge_driver intel_845_driver = {
1635 .owner = THIS_MODULE,
1636 .aperture_sizes = intel_8xx_sizes,
1637 .size_type = U8_APER_SIZE,
1638 .num_aperture_sizes = 7,
1639 .configure = intel_845_configure,
1640 .fetch_size = intel_8xx_fetch_size,
1641 .cleanup = intel_8xx_cleanup,
1642 .tlb_flush = intel_8xx_tlbflush,
1643 .mask_memory = agp_generic_mask_memory,
1644 .masks = intel_generic_masks,
1645 .agp_enable = agp_generic_enable,
1646 .cache_flush = global_cache_flush,
1647 .create_gatt_table = agp_generic_create_gatt_table,
1648 .free_gatt_table = agp_generic_free_gatt_table,
1649 .insert_memory = agp_generic_insert_memory,
1650 .remove_memory = agp_generic_remove_memory,
1651 .alloc_by_type = agp_generic_alloc_by_type,
1652 .free_by_type = agp_generic_free_by_type,
1653 .agp_alloc_page = agp_generic_alloc_page,
1654 .agp_destroy_page = agp_generic_destroy_page,
1655 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1658 static const struct agp_bridge_driver intel_850_driver = {
1659 .owner = THIS_MODULE,
1660 .aperture_sizes = intel_8xx_sizes,
1661 .size_type = U8_APER_SIZE,
1662 .num_aperture_sizes = 7,
1663 .configure = intel_850_configure,
1664 .fetch_size = intel_8xx_fetch_size,
1665 .cleanup = intel_8xx_cleanup,
1666 .tlb_flush = intel_8xx_tlbflush,
1667 .mask_memory = agp_generic_mask_memory,
1668 .masks = intel_generic_masks,
1669 .agp_enable = agp_generic_enable,
1670 .cache_flush = global_cache_flush,
1671 .create_gatt_table = agp_generic_create_gatt_table,
1672 .free_gatt_table = agp_generic_free_gatt_table,
1673 .insert_memory = agp_generic_insert_memory,
1674 .remove_memory = agp_generic_remove_memory,
1675 .alloc_by_type = agp_generic_alloc_by_type,
1676 .free_by_type = agp_generic_free_by_type,
1677 .agp_alloc_page = agp_generic_alloc_page,
1678 .agp_destroy_page = agp_generic_destroy_page,
1679 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1682 static const struct agp_bridge_driver intel_860_driver = {
1683 .owner = THIS_MODULE,
1684 .aperture_sizes = intel_8xx_sizes,
1685 .size_type = U8_APER_SIZE,
1686 .num_aperture_sizes = 7,
1687 .configure = intel_860_configure,
1688 .fetch_size = intel_8xx_fetch_size,
1689 .cleanup = intel_8xx_cleanup,
1690 .tlb_flush = intel_8xx_tlbflush,
1691 .mask_memory = agp_generic_mask_memory,
1692 .masks = intel_generic_masks,
1693 .agp_enable = agp_generic_enable,
1694 .cache_flush = global_cache_flush,
1695 .create_gatt_table = agp_generic_create_gatt_table,
1696 .free_gatt_table = agp_generic_free_gatt_table,
1697 .insert_memory = agp_generic_insert_memory,
1698 .remove_memory = agp_generic_remove_memory,
1699 .alloc_by_type = agp_generic_alloc_by_type,
1700 .free_by_type = agp_generic_free_by_type,
1701 .agp_alloc_page = agp_generic_alloc_page,
1702 .agp_destroy_page = agp_generic_destroy_page,
1703 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1706 static const struct agp_bridge_driver intel_915_driver = {
1707 .owner = THIS_MODULE,
1708 .aperture_sizes = intel_i830_sizes,
1709 .size_type = FIXED_APER_SIZE,
1710 .num_aperture_sizes = 4,
1711 .needs_scratch_page = TRUE,
1712 .configure = intel_i915_configure,
1713 .fetch_size = intel_i9xx_fetch_size,
1714 .cleanup = intel_i915_cleanup,
1715 .tlb_flush = intel_i810_tlbflush,
1716 .mask_memory = intel_i810_mask_memory,
1717 .masks = intel_i810_masks,
1718 .agp_enable = intel_i810_agp_enable,
1719 .cache_flush = global_cache_flush,
1720 .create_gatt_table = intel_i915_create_gatt_table,
1721 .free_gatt_table = intel_i830_free_gatt_table,
1722 .insert_memory = intel_i915_insert_entries,
1723 .remove_memory = intel_i915_remove_entries,
1724 .alloc_by_type = intel_i830_alloc_by_type,
1725 .free_by_type = intel_i810_free_by_type,
1726 .agp_alloc_page = agp_generic_alloc_page,
1727 .agp_destroy_page = agp_generic_destroy_page,
1728 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
1731 static const struct agp_bridge_driver intel_i965_driver = {
1732 .owner = THIS_MODULE,
1733 .aperture_sizes = intel_i830_sizes,
1734 .size_type = FIXED_APER_SIZE,
1735 .num_aperture_sizes = 4,
1736 .needs_scratch_page = TRUE,
1737 .configure = intel_i915_configure,
1738 .fetch_size = intel_i9xx_fetch_size,
1739 .cleanup = intel_i915_cleanup,
1740 .tlb_flush = intel_i810_tlbflush,
1741 .mask_memory = intel_i965_mask_memory,
1742 .masks = intel_i810_masks,
1743 .agp_enable = intel_i810_agp_enable,
1744 .cache_flush = global_cache_flush,
1745 .create_gatt_table = intel_i965_create_gatt_table,
1746 .free_gatt_table = intel_i830_free_gatt_table,
1747 .insert_memory = intel_i915_insert_entries,
1748 .remove_memory = intel_i915_remove_entries,
1749 .alloc_by_type = intel_i830_alloc_by_type,
1750 .free_by_type = intel_i810_free_by_type,
1751 .agp_alloc_page = agp_generic_alloc_page,
1752 .agp_destroy_page = agp_generic_destroy_page,
1753 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
1756 static const struct agp_bridge_driver intel_7505_driver = {
1757 .owner = THIS_MODULE,
1758 .aperture_sizes = intel_8xx_sizes,
1759 .size_type = U8_APER_SIZE,
1760 .num_aperture_sizes = 7,
1761 .configure = intel_7505_configure,
1762 .fetch_size = intel_8xx_fetch_size,
1763 .cleanup = intel_8xx_cleanup,
1764 .tlb_flush = intel_8xx_tlbflush,
1765 .mask_memory = agp_generic_mask_memory,
1766 .masks = intel_generic_masks,
1767 .agp_enable = agp_generic_enable,
1768 .cache_flush = global_cache_flush,
1769 .create_gatt_table = agp_generic_create_gatt_table,
1770 .free_gatt_table = agp_generic_free_gatt_table,
1771 .insert_memory = agp_generic_insert_memory,
1772 .remove_memory = agp_generic_remove_memory,
1773 .alloc_by_type = agp_generic_alloc_by_type,
1774 .free_by_type = agp_generic_free_by_type,
1775 .agp_alloc_page = agp_generic_alloc_page,
1776 .agp_destroy_page = agp_generic_destroy_page,
1777 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1780 static const struct agp_bridge_driver intel_g33_driver = {
1781 .owner = THIS_MODULE,
1782 .aperture_sizes = intel_i830_sizes,
1783 .size_type = FIXED_APER_SIZE,
1784 .num_aperture_sizes = 4,
1785 .needs_scratch_page = TRUE,
1786 .configure = intel_i915_configure,
1787 .fetch_size = intel_i9xx_fetch_size,
1788 .cleanup = intel_i915_cleanup,
1789 .tlb_flush = intel_i810_tlbflush,
1790 .mask_memory = intel_i965_mask_memory,
1791 .masks = intel_i810_masks,
1792 .agp_enable = intel_i810_agp_enable,
1793 .cache_flush = global_cache_flush,
1794 .create_gatt_table = intel_i915_create_gatt_table,
1795 .free_gatt_table = intel_i830_free_gatt_table,
1796 .insert_memory = intel_i915_insert_entries,
1797 .remove_memory = intel_i915_remove_entries,
1798 .alloc_by_type = intel_i830_alloc_by_type,
1799 .free_by_type = intel_i810_free_by_type,
1800 .agp_alloc_page = agp_generic_alloc_page,
1801 .agp_destroy_page = agp_generic_destroy_page,
1802 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
1805 static int find_gmch(u16 device)
1807 struct pci_dev *gmch_device;
1809 gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL);
1810 if (gmch_device && PCI_FUNC(gmch_device->devfn) != 0) {
1811 gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL,
1812 device, gmch_device);
1818 intel_private.pcidev = gmch_device;
1822 /* Table to describe Intel GMCH and AGP/PCIE GART drivers. At least one of
1823 * driver and gmch_driver must be non-null, and find_gmch will determine
1824 * which one should be used if a gmch_chip_id is present.
1826 static const struct intel_driver_description {
1827 unsigned int chip_id;
1828 unsigned int gmch_chip_id;
1829 unsigned int multi_gmch_chip; /* if we have more gfx chip type on this HB. */
1831 const struct agp_bridge_driver *driver;
1832 const struct agp_bridge_driver *gmch_driver;
1833 } intel_agp_chipsets[] = {
1834 { PCI_DEVICE_ID_INTEL_82443LX_0, 0, 0, "440LX", &intel_generic_driver, NULL },
1835 { PCI_DEVICE_ID_INTEL_82443BX_0, 0, 0, "440BX", &intel_generic_driver, NULL },
1836 { PCI_DEVICE_ID_INTEL_82443GX_0, 0, 0, "440GX", &intel_generic_driver, NULL },
1837 { PCI_DEVICE_ID_INTEL_82810_MC1, PCI_DEVICE_ID_INTEL_82810_IG1, 0, "i810",
1838 NULL, &intel_810_driver },
1839 { PCI_DEVICE_ID_INTEL_82810_MC3, PCI_DEVICE_ID_INTEL_82810_IG3, 0, "i810",
1840 NULL, &intel_810_driver },
1841 { PCI_DEVICE_ID_INTEL_82810E_MC, PCI_DEVICE_ID_INTEL_82810E_IG, 0, "i810",
1842 NULL, &intel_810_driver },
1843 { PCI_DEVICE_ID_INTEL_82815_MC, PCI_DEVICE_ID_INTEL_82815_CGC, 0, "i815",
1844 &intel_815_driver, &intel_810_driver },
1845 { PCI_DEVICE_ID_INTEL_82820_HB, 0, 0, "i820", &intel_820_driver, NULL },
1846 { PCI_DEVICE_ID_INTEL_82820_UP_HB, 0, 0, "i820", &intel_820_driver, NULL },
1847 { PCI_DEVICE_ID_INTEL_82830_HB, PCI_DEVICE_ID_INTEL_82830_CGC, 0, "830M",
1848 &intel_830mp_driver, &intel_830_driver },
1849 { PCI_DEVICE_ID_INTEL_82840_HB, 0, 0, "i840", &intel_840_driver, NULL },
1850 { PCI_DEVICE_ID_INTEL_82845_HB, 0, 0, "845G", &intel_845_driver, NULL },
1851 { PCI_DEVICE_ID_INTEL_82845G_HB, PCI_DEVICE_ID_INTEL_82845G_IG, 0, "830M",
1852 &intel_845_driver, &intel_830_driver },
1853 { PCI_DEVICE_ID_INTEL_82850_HB, 0, 0, "i850", &intel_850_driver, NULL },
1854 { PCI_DEVICE_ID_INTEL_82855PM_HB, 0, 0, "855PM", &intel_845_driver, NULL },
1855 { PCI_DEVICE_ID_INTEL_82855GM_HB, PCI_DEVICE_ID_INTEL_82855GM_IG, 0, "855GM",
1856 &intel_845_driver, &intel_830_driver },
1857 { PCI_DEVICE_ID_INTEL_82860_HB, 0, 0, "i860", &intel_860_driver, NULL },
1858 { PCI_DEVICE_ID_INTEL_82865_HB, PCI_DEVICE_ID_INTEL_82865_IG, 0, "865",
1859 &intel_845_driver, &intel_830_driver },
1860 { PCI_DEVICE_ID_INTEL_82875_HB, 0, 0, "i875", &intel_845_driver, NULL },
1861 { PCI_DEVICE_ID_INTEL_E7221_HB, PCI_DEVICE_ID_INTEL_E7221_IG, 0, "E7221 (i915)",
1862 NULL, &intel_915_driver },
1863 { PCI_DEVICE_ID_INTEL_82915G_HB, PCI_DEVICE_ID_INTEL_82915G_IG, 0, "915G",
1864 NULL, &intel_915_driver },
1865 { PCI_DEVICE_ID_INTEL_82915GM_HB, PCI_DEVICE_ID_INTEL_82915GM_IG, 0, "915GM",
1866 NULL, &intel_915_driver },
1867 { PCI_DEVICE_ID_INTEL_82945G_HB, PCI_DEVICE_ID_INTEL_82945G_IG, 0, "945G",
1868 NULL, &intel_915_driver },
1869 { PCI_DEVICE_ID_INTEL_82945GM_HB, PCI_DEVICE_ID_INTEL_82945GM_IG, 0, "945GM",
1870 NULL, &intel_915_driver },
1871 { PCI_DEVICE_ID_INTEL_82945GME_HB, PCI_DEVICE_ID_INTEL_82945GME_IG, 0, "945GME",
1872 NULL, &intel_915_driver },
1873 { PCI_DEVICE_ID_INTEL_82946GZ_HB, PCI_DEVICE_ID_INTEL_82946GZ_IG, 0, "946GZ",
1874 NULL, &intel_i965_driver },
1875 { PCI_DEVICE_ID_INTEL_82965G_1_HB, PCI_DEVICE_ID_INTEL_82965G_1_IG, 0, "965G",
1876 NULL, &intel_i965_driver },
1877 { PCI_DEVICE_ID_INTEL_82965Q_HB, PCI_DEVICE_ID_INTEL_82965Q_IG, 0, "965Q",
1878 NULL, &intel_i965_driver },
1879 { PCI_DEVICE_ID_INTEL_82965G_HB, PCI_DEVICE_ID_INTEL_82965G_IG, 0, "965G",
1880 NULL, &intel_i965_driver },
1881 { PCI_DEVICE_ID_INTEL_82965GM_HB, PCI_DEVICE_ID_INTEL_82965GM_IG, 0, "965GM",
1882 NULL, &intel_i965_driver },
1883 { PCI_DEVICE_ID_INTEL_82965GME_HB, PCI_DEVICE_ID_INTEL_82965GME_IG, 0, "965GME/GLE",
1884 NULL, &intel_i965_driver },
1885 { PCI_DEVICE_ID_INTEL_7505_0, 0, 0, "E7505", &intel_7505_driver, NULL },
1886 { PCI_DEVICE_ID_INTEL_7205_0, 0, 0, "E7205", &intel_7505_driver, NULL },
1887 { PCI_DEVICE_ID_INTEL_G33_HB, PCI_DEVICE_ID_INTEL_G33_IG, 0, "G33",
1888 NULL, &intel_g33_driver },
1889 { PCI_DEVICE_ID_INTEL_Q35_HB, PCI_DEVICE_ID_INTEL_Q35_IG, 0, "Q35",
1890 NULL, &intel_g33_driver },
1891 { PCI_DEVICE_ID_INTEL_Q33_HB, PCI_DEVICE_ID_INTEL_Q33_IG, 0, "Q33",
1892 NULL, &intel_g33_driver },
1893 { 0, 0, 0, NULL, NULL, NULL }
1896 static int __devinit agp_intel_probe(struct pci_dev *pdev,
1897 const struct pci_device_id *ent)
1899 struct agp_bridge_data *bridge;
1904 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
1906 bridge = agp_alloc_bridge();
1910 for (i = 0; intel_agp_chipsets[i].name != NULL; i++) {
1911 /* In case that multiple models of gfx chip may
1912 stand on same host bridge type, this can be
1913 sure we detect the right IGD. */
1914 if (pdev->device == intel_agp_chipsets[i].chip_id) {
1915 if ((intel_agp_chipsets[i].gmch_chip_id != 0) &&
1916 find_gmch(intel_agp_chipsets[i].gmch_chip_id)) {
1918 intel_agp_chipsets[i].gmch_driver;
1920 } else if (intel_agp_chipsets[i].multi_gmch_chip) {
1923 bridge->driver = intel_agp_chipsets[i].driver;
1929 if (intel_agp_chipsets[i].name == NULL) {
1931 printk(KERN_WARNING PFX "Unsupported Intel chipset"
1932 "(device id: %04x)\n", pdev->device);
1933 agp_put_bridge(bridge);
1937 if (bridge->driver == NULL) {
1938 /* bridge has no AGP and no IGD detected */
1940 printk(KERN_WARNING PFX "Failed to find bridge device "
1941 "(chip_id: %04x)\n",
1942 intel_agp_chipsets[i].gmch_chip_id);
1943 agp_put_bridge(bridge);
1948 bridge->capndx = cap_ptr;
1949 bridge->dev_private_data = &intel_private;
1951 printk(KERN_INFO PFX "Detected an Intel %s Chipset.\n",
1952 intel_agp_chipsets[i].name);
1955 * The following fixes the case where the BIOS has "forgotten" to
1956 * provide an address range for the GART.
1957 * 20030610 - hamish@zot.org
1959 r = &pdev->resource[0];
1960 if (!r->start && r->end) {
1961 if (pci_assign_resource(pdev, 0)) {
1962 printk(KERN_ERR PFX "could not assign resource 0\n");
1963 agp_put_bridge(bridge);
1969 * If the device has not been properly setup, the following will catch
1970 * the problem and should stop the system from crashing.
1971 * 20030610 - hamish@zot.org
1973 if (pci_enable_device(pdev)) {
1974 printk(KERN_ERR PFX "Unable to Enable PCI device\n");
1975 agp_put_bridge(bridge);
1979 /* Fill in the mode register */
1981 pci_read_config_dword(pdev,
1982 bridge->capndx+PCI_AGP_STATUS,
1986 pci_set_drvdata(pdev, bridge);
1987 return agp_add_bridge(bridge);
1990 static void __devexit agp_intel_remove(struct pci_dev *pdev)
1992 struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
1994 agp_remove_bridge(bridge);
1996 if (intel_private.pcidev)
1997 pci_dev_put(intel_private.pcidev);
1999 agp_put_bridge(bridge);
2003 static int agp_intel_resume(struct pci_dev *pdev)
2005 struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
2007 pci_restore_state(pdev);
2009 /* We should restore our graphics device's config space,
2010 * as host bridge (00:00) resumes before graphics device (02:00),
2011 * then our access to its pci space can work right.
2013 if (intel_private.pcidev)
2014 pci_restore_state(intel_private.pcidev);
2016 if (bridge->driver == &intel_generic_driver)
2018 else if (bridge->driver == &intel_850_driver)
2019 intel_850_configure();
2020 else if (bridge->driver == &intel_845_driver)
2021 intel_845_configure();
2022 else if (bridge->driver == &intel_830mp_driver)
2023 intel_830mp_configure();
2024 else if (bridge->driver == &intel_915_driver)
2025 intel_i915_configure();
2026 else if (bridge->driver == &intel_830_driver)
2027 intel_i830_configure();
2028 else if (bridge->driver == &intel_810_driver)
2029 intel_i810_configure();
2030 else if (bridge->driver == &intel_i965_driver)
2031 intel_i915_configure();
2037 static struct pci_device_id agp_intel_pci_table[] = {
2040 .class = (PCI_CLASS_BRIDGE_HOST << 8), \
2042 .vendor = PCI_VENDOR_ID_INTEL, \
2044 .subvendor = PCI_ANY_ID, \
2045 .subdevice = PCI_ANY_ID, \
2047 ID(PCI_DEVICE_ID_INTEL_82443LX_0),
2048 ID(PCI_DEVICE_ID_INTEL_82443BX_0),
2049 ID(PCI_DEVICE_ID_INTEL_82443GX_0),
2050 ID(PCI_DEVICE_ID_INTEL_82810_MC1),
2051 ID(PCI_DEVICE_ID_INTEL_82810_MC3),
2052 ID(PCI_DEVICE_ID_INTEL_82810E_MC),
2053 ID(PCI_DEVICE_ID_INTEL_82815_MC),
2054 ID(PCI_DEVICE_ID_INTEL_82820_HB),
2055 ID(PCI_DEVICE_ID_INTEL_82820_UP_HB),
2056 ID(PCI_DEVICE_ID_INTEL_82830_HB),
2057 ID(PCI_DEVICE_ID_INTEL_82840_HB),
2058 ID(PCI_DEVICE_ID_INTEL_82845_HB),
2059 ID(PCI_DEVICE_ID_INTEL_82845G_HB),
2060 ID(PCI_DEVICE_ID_INTEL_82850_HB),
2061 ID(PCI_DEVICE_ID_INTEL_82855PM_HB),
2062 ID(PCI_DEVICE_ID_INTEL_82855GM_HB),
2063 ID(PCI_DEVICE_ID_INTEL_82860_HB),
2064 ID(PCI_DEVICE_ID_INTEL_82865_HB),
2065 ID(PCI_DEVICE_ID_INTEL_82875_HB),
2066 ID(PCI_DEVICE_ID_INTEL_7505_0),
2067 ID(PCI_DEVICE_ID_INTEL_7205_0),
2068 ID(PCI_DEVICE_ID_INTEL_E7221_HB),
2069 ID(PCI_DEVICE_ID_INTEL_82915G_HB),
2070 ID(PCI_DEVICE_ID_INTEL_82915GM_HB),
2071 ID(PCI_DEVICE_ID_INTEL_82945G_HB),
2072 ID(PCI_DEVICE_ID_INTEL_82945GM_HB),
2073 ID(PCI_DEVICE_ID_INTEL_82945GME_HB),
2074 ID(PCI_DEVICE_ID_INTEL_82946GZ_HB),
2075 ID(PCI_DEVICE_ID_INTEL_82965G_1_HB),
2076 ID(PCI_DEVICE_ID_INTEL_82965Q_HB),
2077 ID(PCI_DEVICE_ID_INTEL_82965G_HB),
2078 ID(PCI_DEVICE_ID_INTEL_82965GM_HB),
2079 ID(PCI_DEVICE_ID_INTEL_82965GME_HB),
2080 ID(PCI_DEVICE_ID_INTEL_G33_HB),
2081 ID(PCI_DEVICE_ID_INTEL_Q35_HB),
2082 ID(PCI_DEVICE_ID_INTEL_Q33_HB),
2086 MODULE_DEVICE_TABLE(pci, agp_intel_pci_table);
2088 static struct pci_driver agp_intel_pci_driver = {
2089 .name = "agpgart-intel",
2090 .id_table = agp_intel_pci_table,
2091 .probe = agp_intel_probe,
2092 .remove = __devexit_p(agp_intel_remove),
2094 .resume = agp_intel_resume,
2098 static int __init agp_intel_init(void)
2102 return pci_register_driver(&agp_intel_pci_driver);
2105 static void __exit agp_intel_cleanup(void)
2107 pci_unregister_driver(&agp_intel_pci_driver);
2110 module_init(agp_intel_init);
2111 module_exit(agp_intel_cleanup);
2113 MODULE_AUTHOR("Dave Jones <davej@codemonkey.org.uk>");
2114 MODULE_LICENSE("GPL and additional rights");