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_82946GZ_HB 0x2970
14 #define PCI_DEVICE_ID_INTEL_82946GZ_IG 0x2972
15 #define PCI_DEVICE_ID_INTEL_82965G_1_HB 0x2980
16 #define PCI_DEVICE_ID_INTEL_82965G_1_IG 0x2982
17 #define PCI_DEVICE_ID_INTEL_82965Q_HB 0x2990
18 #define PCI_DEVICE_ID_INTEL_82965Q_IG 0x2992
19 #define PCI_DEVICE_ID_INTEL_82965G_HB 0x29A0
20 #define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2
21 #define PCI_DEVICE_ID_INTEL_82965GM_HB 0x2A00
22 #define PCI_DEVICE_ID_INTEL_82965GM_IG 0x2A02
23 #define PCI_DEVICE_ID_INTEL_82965GME_HB 0x2A10
24 #define PCI_DEVICE_ID_INTEL_82965GME_IG 0x2A12
25 #define PCI_DEVICE_ID_INTEL_82945GME_HB 0x27AC
26 #define PCI_DEVICE_ID_INTEL_82945GME_IG 0x27AE
27 #define PCI_DEVICE_ID_INTEL_G33_HB 0x29C0
28 #define PCI_DEVICE_ID_INTEL_G33_IG 0x29C2
29 #define PCI_DEVICE_ID_INTEL_Q35_HB 0x29B0
30 #define PCI_DEVICE_ID_INTEL_Q35_IG 0x29B2
31 #define PCI_DEVICE_ID_INTEL_Q33_HB 0x29D0
32 #define PCI_DEVICE_ID_INTEL_Q33_IG 0x29D2
34 #define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \
35 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_1_HB || \
36 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965Q_HB || \
37 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \
38 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB || \
39 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GME_HB)
41 #define IS_G33 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G33_HB || \
42 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q35_HB || \
43 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q33_HB)
45 extern int agp_memory_reserved
;
48 /* Intel 815 register */
49 #define INTEL_815_APCONT 0x51
50 #define INTEL_815_ATTBASE_MASK ~0x1FFFFFFF
52 /* Intel i820 registers */
53 #define INTEL_I820_RDCR 0x51
54 #define INTEL_I820_ERRSTS 0xc8
56 /* Intel i840 registers */
57 #define INTEL_I840_MCHCFG 0x50
58 #define INTEL_I840_ERRSTS 0xc8
60 /* Intel i850 registers */
61 #define INTEL_I850_MCHCFG 0x50
62 #define INTEL_I850_ERRSTS 0xc8
64 /* intel 915G registers */
65 #define I915_GMADDR 0x18
66 #define I915_MMADDR 0x10
67 #define I915_PTEADDR 0x1C
68 #define I915_GMCH_GMS_STOLEN_48M (0x6 << 4)
69 #define I915_GMCH_GMS_STOLEN_64M (0x7 << 4)
70 #define G33_GMCH_GMS_STOLEN_128M (0x8 << 4)
71 #define G33_GMCH_GMS_STOLEN_256M (0x9 << 4)
73 /* Intel 965G registers */
74 #define I965_MSAC 0x62
76 /* Intel 7505 registers */
77 #define INTEL_I7505_APSIZE 0x74
78 #define INTEL_I7505_NCAPID 0x60
79 #define INTEL_I7505_NISTAT 0x6c
80 #define INTEL_I7505_ATTBASE 0x78
81 #define INTEL_I7505_ERRSTS 0x42
82 #define INTEL_I7505_AGPCTRL 0x70
83 #define INTEL_I7505_MCHCFG 0x50
85 static const struct aper_size_info_fixed intel_i810_sizes
[] =
88 /* The 32M mode still requires a 64k gatt */
92 #define AGP_DCACHE_MEMORY 1
93 #define AGP_PHYS_MEMORY 2
94 #define INTEL_AGP_CACHED_MEMORY 3
96 static struct gatt_mask intel_i810_masks
[] =
98 {.mask
= I810_PTE_VALID
, .type
= 0},
99 {.mask
= (I810_PTE_VALID
| I810_PTE_LOCAL
), .type
= AGP_DCACHE_MEMORY
},
100 {.mask
= I810_PTE_VALID
, .type
= 0},
101 {.mask
= I810_PTE_VALID
| I830_PTE_SYSTEM_CACHED
,
102 .type
= INTEL_AGP_CACHED_MEMORY
}
105 static struct _intel_private
{
106 struct pci_dev
*pcidev
; /* device one */
107 u8 __iomem
*registers
;
108 u32 __iomem
*gtt
; /* I915G */
109 int num_dcache_entries
;
110 /* gtt_entries is the number of gtt entries that are already mapped
111 * to stolen memory. Stolen memory is larger than the memory mapped
112 * through gtt_entries, as it includes some reserved space for the BIOS
113 * popup and for the GTT.
115 int gtt_entries
; /* i830+ */
118 static int intel_i810_fetch_size(void)
121 struct aper_size_info_fixed
*values
;
123 pci_read_config_dword(agp_bridge
->dev
, I810_SMRAM_MISCC
, &smram_miscc
);
124 values
= A_SIZE_FIX(agp_bridge
->driver
->aperture_sizes
);
126 if ((smram_miscc
& I810_GMS
) == I810_GMS_DISABLE
) {
127 printk(KERN_WARNING PFX
"i810 is disabled\n");
130 if ((smram_miscc
& I810_GFX_MEM_WIN_SIZE
) == I810_GFX_MEM_WIN_32M
) {
131 agp_bridge
->previous_size
=
132 agp_bridge
->current_size
= (void *) (values
+ 1);
133 agp_bridge
->aperture_size_idx
= 1;
134 return values
[1].size
;
136 agp_bridge
->previous_size
=
137 agp_bridge
->current_size
= (void *) (values
);
138 agp_bridge
->aperture_size_idx
= 0;
139 return values
[0].size
;
145 static int intel_i810_configure(void)
147 struct aper_size_info_fixed
*current_size
;
151 current_size
= A_SIZE_FIX(agp_bridge
->current_size
);
153 if (!intel_private
.registers
) {
154 pci_read_config_dword(intel_private
.pcidev
, I810_MMADDR
, &temp
);
157 intel_private
.registers
= ioremap(temp
, 128 * 4096);
158 if (!intel_private
.registers
) {
159 printk(KERN_ERR PFX
"Unable to remap memory.\n");
164 if ((readl(intel_private
.registers
+I810_DRAM_CTL
)
165 & I810_DRAM_ROW_0
) == I810_DRAM_ROW_0_SDRAM
) {
166 /* This will need to be dynamically assigned */
167 printk(KERN_INFO PFX
"detected 4MB dedicated video ram.\n");
168 intel_private
.num_dcache_entries
= 1024;
170 pci_read_config_dword(intel_private
.pcidev
, I810_GMADDR
, &temp
);
171 agp_bridge
->gart_bus_addr
= (temp
& PCI_BASE_ADDRESS_MEM_MASK
);
172 writel(agp_bridge
->gatt_bus_addr
| I810_PGETBL_ENABLED
, intel_private
.registers
+I810_PGETBL_CTL
);
173 readl(intel_private
.registers
+I810_PGETBL_CTL
); /* PCI Posting. */
175 if (agp_bridge
->driver
->needs_scratch_page
) {
176 for (i
= 0; i
< current_size
->num_entries
; i
++) {
177 writel(agp_bridge
->scratch_page
, intel_private
.registers
+I810_PTE_BASE
+(i
*4));
178 readl(intel_private
.registers
+I810_PTE_BASE
+(i
*4)); /* PCI posting. */
181 global_cache_flush();
185 static void intel_i810_cleanup(void)
187 writel(0, intel_private
.registers
+I810_PGETBL_CTL
);
188 readl(intel_private
.registers
); /* PCI Posting. */
189 iounmap(intel_private
.registers
);
192 static void intel_i810_tlbflush(struct agp_memory
*mem
)
197 static void intel_i810_agp_enable(struct agp_bridge_data
*bridge
, u32 mode
)
202 /* Exists to support ARGB cursors */
203 static void *i8xx_alloc_pages(void)
207 page
= alloc_pages(GFP_KERNEL
| GFP_DMA32
, 2);
211 if (change_page_attr(page
, 4, PAGE_KERNEL_NOCACHE
) < 0) {
212 change_page_attr(page
, 4, PAGE_KERNEL
);
214 __free_pages(page
, 2);
219 atomic_inc(&agp_bridge
->current_memory_agp
);
220 return page_address(page
);
223 static void i8xx_destroy_pages(void *addr
)
230 page
= virt_to_page(addr
);
231 change_page_attr(page
, 4, PAGE_KERNEL
);
234 __free_pages(page
, 2);
235 atomic_dec(&agp_bridge
->current_memory_agp
);
238 static int intel_i830_type_to_mask_type(struct agp_bridge_data
*bridge
,
241 if (type
< AGP_USER_TYPES
)
243 else if (type
== AGP_USER_CACHED_MEMORY
)
244 return INTEL_AGP_CACHED_MEMORY
;
249 static int intel_i810_insert_entries(struct agp_memory
*mem
, off_t pg_start
,
252 int i
, j
, num_entries
;
257 if (mem
->page_count
== 0)
260 temp
= agp_bridge
->current_size
;
261 num_entries
= A_SIZE_FIX(temp
)->num_entries
;
263 if ((pg_start
+ mem
->page_count
) > num_entries
)
267 for (j
= pg_start
; j
< (pg_start
+ mem
->page_count
); j
++) {
268 if (!PGE_EMPTY(agp_bridge
, readl(agp_bridge
->gatt_table
+j
))) {
274 if (type
!= mem
->type
)
277 mask_type
= agp_bridge
->driver
->agp_type_to_mask_type(agp_bridge
, type
);
280 case AGP_DCACHE_MEMORY
:
281 if (!mem
->is_flushed
)
282 global_cache_flush();
283 for (i
= pg_start
; i
< (pg_start
+ mem
->page_count
); i
++) {
284 writel((i
*4096)|I810_PTE_LOCAL
|I810_PTE_VALID
,
285 intel_private
.registers
+I810_PTE_BASE
+(i
*4));
287 readl(intel_private
.registers
+I810_PTE_BASE
+((i
-1)*4));
289 case AGP_PHYS_MEMORY
:
290 case AGP_NORMAL_MEMORY
:
291 if (!mem
->is_flushed
)
292 global_cache_flush();
293 for (i
= 0, j
= pg_start
; i
< mem
->page_count
; i
++, j
++) {
294 writel(agp_bridge
->driver
->mask_memory(agp_bridge
,
297 intel_private
.registers
+I810_PTE_BASE
+(j
*4));
299 readl(intel_private
.registers
+I810_PTE_BASE
+((j
-1)*4));
305 agp_bridge
->driver
->tlb_flush(mem
);
313 static int intel_i810_remove_entries(struct agp_memory
*mem
, off_t pg_start
,
318 if (mem
->page_count
== 0)
321 for (i
= pg_start
; i
< (mem
->page_count
+ pg_start
); i
++) {
322 writel(agp_bridge
->scratch_page
, intel_private
.registers
+I810_PTE_BASE
+(i
*4));
324 readl(intel_private
.registers
+I810_PTE_BASE
+((i
-1)*4));
326 agp_bridge
->driver
->tlb_flush(mem
);
331 * The i810/i830 requires a physical address to program its mouse
332 * pointer into hardware.
333 * However the Xserver still writes to it through the agp aperture.
335 static struct agp_memory
*alloc_agpphysmem_i8xx(size_t pg_count
, int type
)
337 struct agp_memory
*new;
341 case 1: addr
= agp_bridge
->driver
->agp_alloc_page(agp_bridge
);
345 /* kludge to get 4 physical pages for ARGB cursor */
346 addr
= i8xx_alloc_pages();
355 new = agp_create_memory(pg_count
);
359 new->memory
[0] = virt_to_gart(addr
);
361 /* kludge to get 4 physical pages for ARGB cursor */
362 new->memory
[1] = new->memory
[0] + PAGE_SIZE
;
363 new->memory
[2] = new->memory
[1] + PAGE_SIZE
;
364 new->memory
[3] = new->memory
[2] + PAGE_SIZE
;
366 new->page_count
= pg_count
;
367 new->num_scratch_pages
= pg_count
;
368 new->type
= AGP_PHYS_MEMORY
;
369 new->physical
= new->memory
[0];
373 static struct agp_memory
*intel_i810_alloc_by_type(size_t pg_count
, int type
)
375 struct agp_memory
*new;
377 if (type
== AGP_DCACHE_MEMORY
) {
378 if (pg_count
!= intel_private
.num_dcache_entries
)
381 new = agp_create_memory(1);
385 new->type
= AGP_DCACHE_MEMORY
;
386 new->page_count
= pg_count
;
387 new->num_scratch_pages
= 0;
388 agp_free_page_array(new);
391 if (type
== AGP_PHYS_MEMORY
)
392 return alloc_agpphysmem_i8xx(pg_count
, type
);
396 static void intel_i810_free_by_type(struct agp_memory
*curr
)
398 agp_free_key(curr
->key
);
399 if (curr
->type
== AGP_PHYS_MEMORY
) {
400 if (curr
->page_count
== 4)
401 i8xx_destroy_pages(gart_to_virt(curr
->memory
[0]));
403 agp_bridge
->driver
->agp_destroy_page(
404 gart_to_virt(curr
->memory
[0]));
407 agp_free_page_array(curr
);
412 static unsigned long intel_i810_mask_memory(struct agp_bridge_data
*bridge
,
413 unsigned long addr
, int type
)
415 /* Type checking must be done elsewhere */
416 return addr
| bridge
->driver
->masks
[type
].mask
;
419 static struct aper_size_info_fixed intel_i830_sizes
[] =
422 /* The 64M mode still requires a 128k gatt */
428 static void intel_i830_init_gtt_entries(void)
434 static const int ddt
[4] = { 0, 16, 32, 64 };
435 int size
; /* reserved space (in kb) at the top of stolen memory */
437 pci_read_config_word(agp_bridge
->dev
,I830_GMCH_CTRL
,&gmch_ctrl
);
441 pgetbl_ctl
= readl(intel_private
.registers
+I810_PGETBL_CTL
);
443 /* The 965 has a field telling us the size of the GTT,
444 * which may be larger than what is necessary to map the
447 switch (pgetbl_ctl
& I965_PGETBL_SIZE_MASK
) {
448 case I965_PGETBL_SIZE_128KB
:
451 case I965_PGETBL_SIZE_256KB
:
454 case I965_PGETBL_SIZE_512KB
:
458 printk(KERN_INFO PFX
"Unknown page table size, "
462 size
+= 4; /* add in BIOS popup space */
464 /* G33's GTT size defined in gmch_ctrl */
465 switch (gmch_ctrl
& G33_PGETBL_SIZE_MASK
) {
466 case G33_PGETBL_SIZE_1M
:
469 case G33_PGETBL_SIZE_2M
:
473 printk(KERN_INFO PFX
"Unknown page table size 0x%x, "
475 (gmch_ctrl
& G33_PGETBL_SIZE_MASK
));
480 /* On previous hardware, the GTT size was just what was
481 * required to map the aperture.
483 size
= agp_bridge
->driver
->fetch_size() + 4;
486 if (agp_bridge
->dev
->device
== PCI_DEVICE_ID_INTEL_82830_HB
||
487 agp_bridge
->dev
->device
== PCI_DEVICE_ID_INTEL_82845G_HB
) {
488 switch (gmch_ctrl
& I830_GMCH_GMS_MASK
) {
489 case I830_GMCH_GMS_STOLEN_512
:
490 gtt_entries
= KB(512) - KB(size
);
492 case I830_GMCH_GMS_STOLEN_1024
:
493 gtt_entries
= MB(1) - KB(size
);
495 case I830_GMCH_GMS_STOLEN_8192
:
496 gtt_entries
= MB(8) - KB(size
);
498 case I830_GMCH_GMS_LOCAL
:
499 rdct
= readb(intel_private
.registers
+I830_RDRAM_CHANNEL_TYPE
);
500 gtt_entries
= (I830_RDRAM_ND(rdct
) + 1) *
501 MB(ddt
[I830_RDRAM_DDT(rdct
)]);
509 switch (gmch_ctrl
& I830_GMCH_GMS_MASK
) {
510 case I855_GMCH_GMS_STOLEN_1M
:
511 gtt_entries
= MB(1) - KB(size
);
513 case I855_GMCH_GMS_STOLEN_4M
:
514 gtt_entries
= MB(4) - KB(size
);
516 case I855_GMCH_GMS_STOLEN_8M
:
517 gtt_entries
= MB(8) - KB(size
);
519 case I855_GMCH_GMS_STOLEN_16M
:
520 gtt_entries
= MB(16) - KB(size
);
522 case I855_GMCH_GMS_STOLEN_32M
:
523 gtt_entries
= MB(32) - KB(size
);
525 case I915_GMCH_GMS_STOLEN_48M
:
526 /* Check it's really I915G */
527 if (agp_bridge
->dev
->device
== PCI_DEVICE_ID_INTEL_82915G_HB
||
528 agp_bridge
->dev
->device
== PCI_DEVICE_ID_INTEL_82915GM_HB
||
529 agp_bridge
->dev
->device
== PCI_DEVICE_ID_INTEL_82945G_HB
||
530 agp_bridge
->dev
->device
== PCI_DEVICE_ID_INTEL_82945GM_HB
||
531 agp_bridge
->dev
->device
== PCI_DEVICE_ID_INTEL_82945GME_HB
||
533 gtt_entries
= MB(48) - KB(size
);
537 case I915_GMCH_GMS_STOLEN_64M
:
538 /* Check it's really I915G */
539 if (agp_bridge
->dev
->device
== PCI_DEVICE_ID_INTEL_82915G_HB
||
540 agp_bridge
->dev
->device
== PCI_DEVICE_ID_INTEL_82915GM_HB
||
541 agp_bridge
->dev
->device
== PCI_DEVICE_ID_INTEL_82945G_HB
||
542 agp_bridge
->dev
->device
== PCI_DEVICE_ID_INTEL_82945GM_HB
||
543 agp_bridge
->dev
->device
== PCI_DEVICE_ID_INTEL_82945GME_HB
||
545 gtt_entries
= MB(64) - KB(size
);
549 case G33_GMCH_GMS_STOLEN_128M
:
551 gtt_entries
= MB(128) - KB(size
);
555 case G33_GMCH_GMS_STOLEN_256M
:
557 gtt_entries
= MB(256) - KB(size
);
567 printk(KERN_INFO PFX
"Detected %dK %s memory.\n",
568 gtt_entries
/ KB(1), local
? "local" : "stolen");
571 "No pre-allocated video memory detected.\n");
572 gtt_entries
/= KB(4);
574 intel_private
.gtt_entries
= gtt_entries
;
577 /* The intel i830 automatically initializes the agp aperture during POST.
578 * Use the memory already set aside for in the GTT.
580 static int intel_i830_create_gatt_table(struct agp_bridge_data
*bridge
)
583 struct aper_size_info_fixed
*size
;
587 size
= agp_bridge
->current_size
;
588 page_order
= size
->page_order
;
589 num_entries
= size
->num_entries
;
590 agp_bridge
->gatt_table_real
= NULL
;
592 pci_read_config_dword(intel_private
.pcidev
,I810_MMADDR
,&temp
);
595 intel_private
.registers
= ioremap(temp
,128 * 4096);
596 if (!intel_private
.registers
)
599 temp
= readl(intel_private
.registers
+I810_PGETBL_CTL
) & 0xfffff000;
600 global_cache_flush(); /* FIXME: ?? */
602 /* we have to call this as early as possible after the MMIO base address is known */
603 intel_i830_init_gtt_entries();
605 agp_bridge
->gatt_table
= NULL
;
607 agp_bridge
->gatt_bus_addr
= temp
;
612 /* Return the gatt table to a sane state. Use the top of stolen
613 * memory for the GTT.
615 static int intel_i830_free_gatt_table(struct agp_bridge_data
*bridge
)
620 static int intel_i830_fetch_size(void)
623 struct aper_size_info_fixed
*values
;
625 values
= A_SIZE_FIX(agp_bridge
->driver
->aperture_sizes
);
627 if (agp_bridge
->dev
->device
!= PCI_DEVICE_ID_INTEL_82830_HB
&&
628 agp_bridge
->dev
->device
!= PCI_DEVICE_ID_INTEL_82845G_HB
) {
629 /* 855GM/852GM/865G has 128MB aperture size */
630 agp_bridge
->previous_size
= agp_bridge
->current_size
= (void *) values
;
631 agp_bridge
->aperture_size_idx
= 0;
632 return values
[0].size
;
635 pci_read_config_word(agp_bridge
->dev
,I830_GMCH_CTRL
,&gmch_ctrl
);
637 if ((gmch_ctrl
& I830_GMCH_MEM_MASK
) == I830_GMCH_MEM_128M
) {
638 agp_bridge
->previous_size
= agp_bridge
->current_size
= (void *) values
;
639 agp_bridge
->aperture_size_idx
= 0;
640 return values
[0].size
;
642 agp_bridge
->previous_size
= agp_bridge
->current_size
= (void *) (values
+ 1);
643 agp_bridge
->aperture_size_idx
= 1;
644 return values
[1].size
;
650 static int intel_i830_configure(void)
652 struct aper_size_info_fixed
*current_size
;
657 current_size
= A_SIZE_FIX(agp_bridge
->current_size
);
659 pci_read_config_dword(intel_private
.pcidev
,I810_GMADDR
,&temp
);
660 agp_bridge
->gart_bus_addr
= (temp
& PCI_BASE_ADDRESS_MEM_MASK
);
662 pci_read_config_word(agp_bridge
->dev
,I830_GMCH_CTRL
,&gmch_ctrl
);
663 gmch_ctrl
|= I830_GMCH_ENABLED
;
664 pci_write_config_word(agp_bridge
->dev
,I830_GMCH_CTRL
,gmch_ctrl
);
666 writel(agp_bridge
->gatt_bus_addr
|I810_PGETBL_ENABLED
, intel_private
.registers
+I810_PGETBL_CTL
);
667 readl(intel_private
.registers
+I810_PGETBL_CTL
); /* PCI Posting. */
669 if (agp_bridge
->driver
->needs_scratch_page
) {
670 for (i
= intel_private
.gtt_entries
; i
< current_size
->num_entries
; i
++) {
671 writel(agp_bridge
->scratch_page
, intel_private
.registers
+I810_PTE_BASE
+(i
*4));
672 readl(intel_private
.registers
+I810_PTE_BASE
+(i
*4)); /* PCI Posting. */
676 global_cache_flush();
680 static void intel_i830_cleanup(void)
682 iounmap(intel_private
.registers
);
685 static int intel_i830_insert_entries(struct agp_memory
*mem
,off_t pg_start
, int type
)
692 if (mem
->page_count
== 0)
695 temp
= agp_bridge
->current_size
;
696 num_entries
= A_SIZE_FIX(temp
)->num_entries
;
698 if (pg_start
< intel_private
.gtt_entries
) {
699 printk (KERN_DEBUG PFX
"pg_start == 0x%.8lx,intel_private.gtt_entries == 0x%.8x\n",
700 pg_start
,intel_private
.gtt_entries
);
702 printk (KERN_INFO PFX
"Trying to insert into local/stolen memory\n");
706 if ((pg_start
+ mem
->page_count
) > num_entries
)
709 /* The i830 can't check the GTT for entries since its read only,
710 * depend on the caller to make the correct offset decisions.
713 if (type
!= mem
->type
)
716 mask_type
= agp_bridge
->driver
->agp_type_to_mask_type(agp_bridge
, type
);
718 if (mask_type
!= 0 && mask_type
!= AGP_PHYS_MEMORY
&&
719 mask_type
!= INTEL_AGP_CACHED_MEMORY
)
722 if (!mem
->is_flushed
)
723 global_cache_flush();
725 for (i
= 0, j
= pg_start
; i
< mem
->page_count
; i
++, j
++) {
726 writel(agp_bridge
->driver
->mask_memory(agp_bridge
,
727 mem
->memory
[i
], mask_type
),
728 intel_private
.registers
+I810_PTE_BASE
+(j
*4));
730 readl(intel_private
.registers
+I810_PTE_BASE
+((j
-1)*4));
731 agp_bridge
->driver
->tlb_flush(mem
);
740 static int intel_i830_remove_entries(struct agp_memory
*mem
,off_t pg_start
,
745 if (mem
->page_count
== 0)
748 if (pg_start
< intel_private
.gtt_entries
) {
749 printk (KERN_INFO PFX
"Trying to disable local/stolen memory\n");
753 for (i
= pg_start
; i
< (mem
->page_count
+ pg_start
); i
++) {
754 writel(agp_bridge
->scratch_page
, intel_private
.registers
+I810_PTE_BASE
+(i
*4));
756 readl(intel_private
.registers
+I810_PTE_BASE
+((i
-1)*4));
758 agp_bridge
->driver
->tlb_flush(mem
);
762 static struct agp_memory
*intel_i830_alloc_by_type(size_t pg_count
,int type
)
764 if (type
== AGP_PHYS_MEMORY
)
765 return alloc_agpphysmem_i8xx(pg_count
, type
);
766 /* always return NULL for other allocation types for now */
770 static int intel_i915_configure(void)
772 struct aper_size_info_fixed
*current_size
;
777 current_size
= A_SIZE_FIX(agp_bridge
->current_size
);
779 pci_read_config_dword(intel_private
.pcidev
, I915_GMADDR
, &temp
);
781 agp_bridge
->gart_bus_addr
= (temp
& PCI_BASE_ADDRESS_MEM_MASK
);
783 pci_read_config_word(agp_bridge
->dev
,I830_GMCH_CTRL
,&gmch_ctrl
);
784 gmch_ctrl
|= I830_GMCH_ENABLED
;
785 pci_write_config_word(agp_bridge
->dev
,I830_GMCH_CTRL
,gmch_ctrl
);
787 writel(agp_bridge
->gatt_bus_addr
|I810_PGETBL_ENABLED
, intel_private
.registers
+I810_PGETBL_CTL
);
788 readl(intel_private
.registers
+I810_PGETBL_CTL
); /* PCI Posting. */
790 if (agp_bridge
->driver
->needs_scratch_page
) {
791 for (i
= intel_private
.gtt_entries
; i
< current_size
->num_entries
; i
++) {
792 writel(agp_bridge
->scratch_page
, intel_private
.gtt
+i
);
793 readl(intel_private
.gtt
+i
); /* PCI Posting. */
797 global_cache_flush();
801 static void intel_i915_cleanup(void)
803 iounmap(intel_private
.gtt
);
804 iounmap(intel_private
.registers
);
807 static int intel_i915_insert_entries(struct agp_memory
*mem
,off_t pg_start
,
815 if (mem
->page_count
== 0)
818 temp
= agp_bridge
->current_size
;
819 num_entries
= A_SIZE_FIX(temp
)->num_entries
;
821 if (pg_start
< intel_private
.gtt_entries
) {
822 printk (KERN_DEBUG PFX
"pg_start == 0x%.8lx,intel_private.gtt_entries == 0x%.8x\n",
823 pg_start
,intel_private
.gtt_entries
);
825 printk (KERN_INFO PFX
"Trying to insert into local/stolen memory\n");
829 if ((pg_start
+ mem
->page_count
) > num_entries
)
832 /* The i915 can't check the GTT for entries since its read only,
833 * depend on the caller to make the correct offset decisions.
836 if (type
!= mem
->type
)
839 mask_type
= agp_bridge
->driver
->agp_type_to_mask_type(agp_bridge
, type
);
841 if (mask_type
!= 0 && mask_type
!= AGP_PHYS_MEMORY
&&
842 mask_type
!= INTEL_AGP_CACHED_MEMORY
)
845 if (!mem
->is_flushed
)
846 global_cache_flush();
848 for (i
= 0, j
= pg_start
; i
< mem
->page_count
; i
++, j
++) {
849 writel(agp_bridge
->driver
->mask_memory(agp_bridge
,
850 mem
->memory
[i
], mask_type
), intel_private
.gtt
+j
);
853 readl(intel_private
.gtt
+j
-1);
854 agp_bridge
->driver
->tlb_flush(mem
);
863 static int intel_i915_remove_entries(struct agp_memory
*mem
,off_t pg_start
,
868 if (mem
->page_count
== 0)
871 if (pg_start
< intel_private
.gtt_entries
) {
872 printk (KERN_INFO PFX
"Trying to disable local/stolen memory\n");
876 for (i
= pg_start
; i
< (mem
->page_count
+ pg_start
); i
++) {
877 writel(agp_bridge
->scratch_page
, intel_private
.gtt
+i
);
879 readl(intel_private
.gtt
+i
-1);
881 agp_bridge
->driver
->tlb_flush(mem
);
885 /* Return the aperture size by just checking the resource length. The effect
886 * described in the spec of the MSAC registers is just changing of the
889 static int intel_i9xx_fetch_size(void)
891 int num_sizes
= ARRAY_SIZE(intel_i830_sizes
);
892 int aper_size
; /* size in megabytes */
895 aper_size
= pci_resource_len(intel_private
.pcidev
, 2) / MB(1);
897 for (i
= 0; i
< num_sizes
; i
++) {
898 if (aper_size
== intel_i830_sizes
[i
].size
) {
899 agp_bridge
->current_size
= intel_i830_sizes
+ i
;
900 agp_bridge
->previous_size
= agp_bridge
->current_size
;
908 /* The intel i915 automatically initializes the agp aperture during POST.
909 * Use the memory already set aside for in the GTT.
911 static int intel_i915_create_gatt_table(struct agp_bridge_data
*bridge
)
914 struct aper_size_info_fixed
*size
;
918 size
= agp_bridge
->current_size
;
919 page_order
= size
->page_order
;
920 num_entries
= size
->num_entries
;
921 agp_bridge
->gatt_table_real
= NULL
;
923 pci_read_config_dword(intel_private
.pcidev
, I915_MMADDR
, &temp
);
924 pci_read_config_dword(intel_private
.pcidev
, I915_PTEADDR
,&temp2
);
926 intel_private
.gtt
= ioremap(temp2
, 256 * 1024);
927 if (!intel_private
.gtt
)
932 intel_private
.registers
= ioremap(temp
,128 * 4096);
933 if (!intel_private
.registers
) {
934 iounmap(intel_private
.gtt
);
938 temp
= readl(intel_private
.registers
+I810_PGETBL_CTL
) & 0xfffff000;
939 global_cache_flush(); /* FIXME: ? */
941 /* we have to call this as early as possible after the MMIO base address is known */
942 intel_i830_init_gtt_entries();
944 agp_bridge
->gatt_table
= NULL
;
946 agp_bridge
->gatt_bus_addr
= temp
;
952 * The i965 supports 36-bit physical addresses, but to keep
953 * the format of the GTT the same, the bits that don't fit
954 * in a 32-bit word are shifted down to bits 4..7.
956 * Gcc is smart enough to notice that "(addr >> 28) & 0xf0"
957 * is always zero on 32-bit architectures, so no need to make
960 static unsigned long intel_i965_mask_memory(struct agp_bridge_data
*bridge
,
961 unsigned long addr
, int type
)
963 /* Shift high bits down */
964 addr
|= (addr
>> 28) & 0xf0;
966 /* Type checking must be done elsewhere */
967 return addr
| bridge
->driver
->masks
[type
].mask
;
970 /* The intel i965 automatically initializes the agp aperture during POST.
971 * Use the memory already set aside for in the GTT.
973 static int intel_i965_create_gatt_table(struct agp_bridge_data
*bridge
)
976 struct aper_size_info_fixed
*size
;
980 size
= agp_bridge
->current_size
;
981 page_order
= size
->page_order
;
982 num_entries
= size
->num_entries
;
983 agp_bridge
->gatt_table_real
= NULL
;
985 pci_read_config_dword(intel_private
.pcidev
, I915_MMADDR
, &temp
);
988 intel_private
.gtt
= ioremap((temp
+ (512 * 1024)) , 512 * 1024);
990 if (!intel_private
.gtt
)
994 intel_private
.registers
= ioremap(temp
,128 * 4096);
995 if (!intel_private
.registers
) {
996 iounmap(intel_private
.gtt
);
1000 temp
= readl(intel_private
.registers
+I810_PGETBL_CTL
) & 0xfffff000;
1001 global_cache_flush(); /* FIXME: ? */
1003 /* we have to call this as early as possible after the MMIO base address is known */
1004 intel_i830_init_gtt_entries();
1006 agp_bridge
->gatt_table
= NULL
;
1008 agp_bridge
->gatt_bus_addr
= temp
;
1014 static int intel_fetch_size(void)
1018 struct aper_size_info_16
*values
;
1020 pci_read_config_word(agp_bridge
->dev
, INTEL_APSIZE
, &temp
);
1021 values
= A_SIZE_16(agp_bridge
->driver
->aperture_sizes
);
1023 for (i
= 0; i
< agp_bridge
->driver
->num_aperture_sizes
; i
++) {
1024 if (temp
== values
[i
].size_value
) {
1025 agp_bridge
->previous_size
= agp_bridge
->current_size
= (void *) (values
+ i
);
1026 agp_bridge
->aperture_size_idx
= i
;
1027 return values
[i
].size
;
1034 static int __intel_8xx_fetch_size(u8 temp
)
1037 struct aper_size_info_8
*values
;
1039 values
= A_SIZE_8(agp_bridge
->driver
->aperture_sizes
);
1041 for (i
= 0; i
< agp_bridge
->driver
->num_aperture_sizes
; i
++) {
1042 if (temp
== values
[i
].size_value
) {
1043 agp_bridge
->previous_size
=
1044 agp_bridge
->current_size
= (void *) (values
+ i
);
1045 agp_bridge
->aperture_size_idx
= i
;
1046 return values
[i
].size
;
1052 static int intel_8xx_fetch_size(void)
1056 pci_read_config_byte(agp_bridge
->dev
, INTEL_APSIZE
, &temp
);
1057 return __intel_8xx_fetch_size(temp
);
1060 static int intel_815_fetch_size(void)
1064 /* Intel 815 chipsets have a _weird_ APSIZE register with only
1065 * one non-reserved bit, so mask the others out ... */
1066 pci_read_config_byte(agp_bridge
->dev
, INTEL_APSIZE
, &temp
);
1069 return __intel_8xx_fetch_size(temp
);
1072 static void intel_tlbflush(struct agp_memory
*mem
)
1074 pci_write_config_dword(agp_bridge
->dev
, INTEL_AGPCTRL
, 0x2200);
1075 pci_write_config_dword(agp_bridge
->dev
, INTEL_AGPCTRL
, 0x2280);
1079 static void intel_8xx_tlbflush(struct agp_memory
*mem
)
1082 pci_read_config_dword(agp_bridge
->dev
, INTEL_AGPCTRL
, &temp
);
1083 pci_write_config_dword(agp_bridge
->dev
, INTEL_AGPCTRL
, temp
& ~(1 << 7));
1084 pci_read_config_dword(agp_bridge
->dev
, INTEL_AGPCTRL
, &temp
);
1085 pci_write_config_dword(agp_bridge
->dev
, INTEL_AGPCTRL
, temp
| (1 << 7));
1089 static void intel_cleanup(void)
1092 struct aper_size_info_16
*previous_size
;
1094 previous_size
= A_SIZE_16(agp_bridge
->previous_size
);
1095 pci_read_config_word(agp_bridge
->dev
, INTEL_NBXCFG
, &temp
);
1096 pci_write_config_word(agp_bridge
->dev
, INTEL_NBXCFG
, temp
& ~(1 << 9));
1097 pci_write_config_word(agp_bridge
->dev
, INTEL_APSIZE
, previous_size
->size_value
);
1101 static void intel_8xx_cleanup(void)
1104 struct aper_size_info_8
*previous_size
;
1106 previous_size
= A_SIZE_8(agp_bridge
->previous_size
);
1107 pci_read_config_word(agp_bridge
->dev
, INTEL_NBXCFG
, &temp
);
1108 pci_write_config_word(agp_bridge
->dev
, INTEL_NBXCFG
, temp
& ~(1 << 9));
1109 pci_write_config_byte(agp_bridge
->dev
, INTEL_APSIZE
, previous_size
->size_value
);
1113 static int intel_configure(void)
1117 struct aper_size_info_16
*current_size
;
1119 current_size
= A_SIZE_16(agp_bridge
->current_size
);
1122 pci_write_config_word(agp_bridge
->dev
, INTEL_APSIZE
, current_size
->size_value
);
1124 /* address to map to */
1125 pci_read_config_dword(agp_bridge
->dev
, AGP_APBASE
, &temp
);
1126 agp_bridge
->gart_bus_addr
= (temp
& PCI_BASE_ADDRESS_MEM_MASK
);
1128 /* attbase - aperture base */
1129 pci_write_config_dword(agp_bridge
->dev
, INTEL_ATTBASE
, agp_bridge
->gatt_bus_addr
);
1132 pci_write_config_dword(agp_bridge
->dev
, INTEL_AGPCTRL
, 0x2280);
1135 pci_read_config_word(agp_bridge
->dev
, INTEL_NBXCFG
, &temp2
);
1136 pci_write_config_word(agp_bridge
->dev
, INTEL_NBXCFG
,
1137 (temp2
& ~(1 << 10)) | (1 << 9));
1138 /* clear any possible error conditions */
1139 pci_write_config_byte(agp_bridge
->dev
, INTEL_ERRSTS
+ 1, 7);
1143 static int intel_815_configure(void)
1147 struct aper_size_info_8
*current_size
;
1149 /* attbase - aperture base */
1150 /* the Intel 815 chipset spec. says that bits 29-31 in the
1151 * ATTBASE register are reserved -> try not to write them */
1152 if (agp_bridge
->gatt_bus_addr
& INTEL_815_ATTBASE_MASK
) {
1153 printk (KERN_EMERG PFX
"gatt bus addr too high");
1157 current_size
= A_SIZE_8(agp_bridge
->current_size
);
1160 pci_write_config_byte(agp_bridge
->dev
, INTEL_APSIZE
,
1161 current_size
->size_value
);
1163 /* address to map to */
1164 pci_read_config_dword(agp_bridge
->dev
, AGP_APBASE
, &temp
);
1165 agp_bridge
->gart_bus_addr
= (temp
& PCI_BASE_ADDRESS_MEM_MASK
);
1167 pci_read_config_dword(agp_bridge
->dev
, INTEL_ATTBASE
, &addr
);
1168 addr
&= INTEL_815_ATTBASE_MASK
;
1169 addr
|= agp_bridge
->gatt_bus_addr
;
1170 pci_write_config_dword(agp_bridge
->dev
, INTEL_ATTBASE
, addr
);
1173 pci_write_config_dword(agp_bridge
->dev
, INTEL_AGPCTRL
, 0x0000);
1176 pci_read_config_byte(agp_bridge
->dev
, INTEL_815_APCONT
, &temp2
);
1177 pci_write_config_byte(agp_bridge
->dev
, INTEL_815_APCONT
, temp2
| (1 << 1));
1179 /* clear any possible error conditions */
1180 /* Oddness : this chipset seems to have no ERRSTS register ! */
1184 static void intel_820_tlbflush(struct agp_memory
*mem
)
1189 static void intel_820_cleanup(void)
1192 struct aper_size_info_8
*previous_size
;
1194 previous_size
= A_SIZE_8(agp_bridge
->previous_size
);
1195 pci_read_config_byte(agp_bridge
->dev
, INTEL_I820_RDCR
, &temp
);
1196 pci_write_config_byte(agp_bridge
->dev
, INTEL_I820_RDCR
,
1198 pci_write_config_byte(agp_bridge
->dev
, INTEL_APSIZE
,
1199 previous_size
->size_value
);
1203 static int intel_820_configure(void)
1207 struct aper_size_info_8
*current_size
;
1209 current_size
= A_SIZE_8(agp_bridge
->current_size
);
1212 pci_write_config_byte(agp_bridge
->dev
, INTEL_APSIZE
, current_size
->size_value
);
1214 /* address to map to */
1215 pci_read_config_dword(agp_bridge
->dev
, AGP_APBASE
, &temp
);
1216 agp_bridge
->gart_bus_addr
= (temp
& PCI_BASE_ADDRESS_MEM_MASK
);
1218 /* attbase - aperture base */
1219 pci_write_config_dword(agp_bridge
->dev
, INTEL_ATTBASE
, agp_bridge
->gatt_bus_addr
);
1222 pci_write_config_dword(agp_bridge
->dev
, INTEL_AGPCTRL
, 0x0000);
1224 /* global enable aperture access */
1225 /* This flag is not accessed through MCHCFG register as in */
1227 pci_read_config_byte(agp_bridge
->dev
, INTEL_I820_RDCR
, &temp2
);
1228 pci_write_config_byte(agp_bridge
->dev
, INTEL_I820_RDCR
, temp2
| (1 << 1));
1229 /* clear any possible AGP-related error conditions */
1230 pci_write_config_word(agp_bridge
->dev
, INTEL_I820_ERRSTS
, 0x001c);
1234 static int intel_840_configure(void)
1238 struct aper_size_info_8
*current_size
;
1240 current_size
= A_SIZE_8(agp_bridge
->current_size
);
1243 pci_write_config_byte(agp_bridge
->dev
, INTEL_APSIZE
, current_size
->size_value
);
1245 /* address to map to */
1246 pci_read_config_dword(agp_bridge
->dev
, AGP_APBASE
, &temp
);
1247 agp_bridge
->gart_bus_addr
= (temp
& PCI_BASE_ADDRESS_MEM_MASK
);
1249 /* attbase - aperture base */
1250 pci_write_config_dword(agp_bridge
->dev
, INTEL_ATTBASE
, agp_bridge
->gatt_bus_addr
);
1253 pci_write_config_dword(agp_bridge
->dev
, INTEL_AGPCTRL
, 0x0000);
1256 pci_read_config_word(agp_bridge
->dev
, INTEL_I840_MCHCFG
, &temp2
);
1257 pci_write_config_word(agp_bridge
->dev
, INTEL_I840_MCHCFG
, temp2
| (1 << 9));
1258 /* clear any possible error conditions */
1259 pci_write_config_word(agp_bridge
->dev
, INTEL_I840_ERRSTS
, 0xc000);
1263 static int intel_845_configure(void)
1267 struct aper_size_info_8
*current_size
;
1269 current_size
= A_SIZE_8(agp_bridge
->current_size
);
1272 pci_write_config_byte(agp_bridge
->dev
, INTEL_APSIZE
, current_size
->size_value
);
1274 if (agp_bridge
->apbase_config
!= 0) {
1275 pci_write_config_dword(agp_bridge
->dev
, AGP_APBASE
,
1276 agp_bridge
->apbase_config
);
1278 /* address to map to */
1279 pci_read_config_dword(agp_bridge
->dev
, AGP_APBASE
, &temp
);
1280 agp_bridge
->gart_bus_addr
= (temp
& PCI_BASE_ADDRESS_MEM_MASK
);
1281 agp_bridge
->apbase_config
= temp
;
1284 /* attbase - aperture base */
1285 pci_write_config_dword(agp_bridge
->dev
, INTEL_ATTBASE
, agp_bridge
->gatt_bus_addr
);
1288 pci_write_config_dword(agp_bridge
->dev
, INTEL_AGPCTRL
, 0x0000);
1291 pci_read_config_byte(agp_bridge
->dev
, INTEL_I845_AGPM
, &temp2
);
1292 pci_write_config_byte(agp_bridge
->dev
, INTEL_I845_AGPM
, temp2
| (1 << 1));
1293 /* clear any possible error conditions */
1294 pci_write_config_word(agp_bridge
->dev
, INTEL_I845_ERRSTS
, 0x001c);
1298 static int intel_850_configure(void)
1302 struct aper_size_info_8
*current_size
;
1304 current_size
= A_SIZE_8(agp_bridge
->current_size
);
1307 pci_write_config_byte(agp_bridge
->dev
, INTEL_APSIZE
, current_size
->size_value
);
1309 /* address to map to */
1310 pci_read_config_dword(agp_bridge
->dev
, AGP_APBASE
, &temp
);
1311 agp_bridge
->gart_bus_addr
= (temp
& PCI_BASE_ADDRESS_MEM_MASK
);
1313 /* attbase - aperture base */
1314 pci_write_config_dword(agp_bridge
->dev
, INTEL_ATTBASE
, agp_bridge
->gatt_bus_addr
);
1317 pci_write_config_dword(agp_bridge
->dev
, INTEL_AGPCTRL
, 0x0000);
1320 pci_read_config_word(agp_bridge
->dev
, INTEL_I850_MCHCFG
, &temp2
);
1321 pci_write_config_word(agp_bridge
->dev
, INTEL_I850_MCHCFG
, temp2
| (1 << 9));
1322 /* clear any possible AGP-related error conditions */
1323 pci_write_config_word(agp_bridge
->dev
, INTEL_I850_ERRSTS
, 0x001c);
1327 static int intel_860_configure(void)
1331 struct aper_size_info_8
*current_size
;
1333 current_size
= A_SIZE_8(agp_bridge
->current_size
);
1336 pci_write_config_byte(agp_bridge
->dev
, INTEL_APSIZE
, current_size
->size_value
);
1338 /* address to map to */
1339 pci_read_config_dword(agp_bridge
->dev
, AGP_APBASE
, &temp
);
1340 agp_bridge
->gart_bus_addr
= (temp
& PCI_BASE_ADDRESS_MEM_MASK
);
1342 /* attbase - aperture base */
1343 pci_write_config_dword(agp_bridge
->dev
, INTEL_ATTBASE
, agp_bridge
->gatt_bus_addr
);
1346 pci_write_config_dword(agp_bridge
->dev
, INTEL_AGPCTRL
, 0x0000);
1349 pci_read_config_word(agp_bridge
->dev
, INTEL_I860_MCHCFG
, &temp2
);
1350 pci_write_config_word(agp_bridge
->dev
, INTEL_I860_MCHCFG
, temp2
| (1 << 9));
1351 /* clear any possible AGP-related error conditions */
1352 pci_write_config_word(agp_bridge
->dev
, INTEL_I860_ERRSTS
, 0xf700);
1356 static int intel_830mp_configure(void)
1360 struct aper_size_info_8
*current_size
;
1362 current_size
= A_SIZE_8(agp_bridge
->current_size
);
1365 pci_write_config_byte(agp_bridge
->dev
, INTEL_APSIZE
, current_size
->size_value
);
1367 /* address to map to */
1368 pci_read_config_dword(agp_bridge
->dev
, AGP_APBASE
, &temp
);
1369 agp_bridge
->gart_bus_addr
= (temp
& PCI_BASE_ADDRESS_MEM_MASK
);
1371 /* attbase - aperture base */
1372 pci_write_config_dword(agp_bridge
->dev
, INTEL_ATTBASE
, agp_bridge
->gatt_bus_addr
);
1375 pci_write_config_dword(agp_bridge
->dev
, INTEL_AGPCTRL
, 0x0000);
1378 pci_read_config_word(agp_bridge
->dev
, INTEL_NBXCFG
, &temp2
);
1379 pci_write_config_word(agp_bridge
->dev
, INTEL_NBXCFG
, temp2
| (1 << 9));
1380 /* clear any possible AGP-related error conditions */
1381 pci_write_config_word(agp_bridge
->dev
, INTEL_I830_ERRSTS
, 0x1c);
1385 static int intel_7505_configure(void)
1389 struct aper_size_info_8
*current_size
;
1391 current_size
= A_SIZE_8(agp_bridge
->current_size
);
1394 pci_write_config_byte(agp_bridge
->dev
, INTEL_APSIZE
, current_size
->size_value
);
1396 /* address to map to */
1397 pci_read_config_dword(agp_bridge
->dev
, AGP_APBASE
, &temp
);
1398 agp_bridge
->gart_bus_addr
= (temp
& PCI_BASE_ADDRESS_MEM_MASK
);
1400 /* attbase - aperture base */
1401 pci_write_config_dword(agp_bridge
->dev
, INTEL_ATTBASE
, agp_bridge
->gatt_bus_addr
);
1404 pci_write_config_dword(agp_bridge
->dev
, INTEL_AGPCTRL
, 0x0000);
1407 pci_read_config_word(agp_bridge
->dev
, INTEL_I7505_MCHCFG
, &temp2
);
1408 pci_write_config_word(agp_bridge
->dev
, INTEL_I7505_MCHCFG
, temp2
| (1 << 9));
1413 /* Setup function */
1414 static const struct gatt_mask intel_generic_masks
[] =
1416 {.mask
= 0x00000017, .type
= 0}
1419 static const struct aper_size_info_8 intel_815_sizes
[2] =
1425 static const struct aper_size_info_8 intel_8xx_sizes
[7] =
1428 {128, 32768, 5, 32},
1436 static const struct aper_size_info_16 intel_generic_sizes
[7] =
1439 {128, 32768, 5, 32},
1447 static const struct aper_size_info_8 intel_830mp_sizes
[4] =
1450 {128, 32768, 5, 32},
1455 static const struct agp_bridge_driver intel_generic_driver
= {
1456 .owner
= THIS_MODULE
,
1457 .aperture_sizes
= intel_generic_sizes
,
1458 .size_type
= U16_APER_SIZE
,
1459 .num_aperture_sizes
= 7,
1460 .configure
= intel_configure
,
1461 .fetch_size
= intel_fetch_size
,
1462 .cleanup
= intel_cleanup
,
1463 .tlb_flush
= intel_tlbflush
,
1464 .mask_memory
= agp_generic_mask_memory
,
1465 .masks
= intel_generic_masks
,
1466 .agp_enable
= agp_generic_enable
,
1467 .cache_flush
= global_cache_flush
,
1468 .create_gatt_table
= agp_generic_create_gatt_table
,
1469 .free_gatt_table
= agp_generic_free_gatt_table
,
1470 .insert_memory
= agp_generic_insert_memory
,
1471 .remove_memory
= agp_generic_remove_memory
,
1472 .alloc_by_type
= agp_generic_alloc_by_type
,
1473 .free_by_type
= agp_generic_free_by_type
,
1474 .agp_alloc_page
= agp_generic_alloc_page
,
1475 .agp_destroy_page
= agp_generic_destroy_page
,
1476 .agp_type_to_mask_type
= agp_generic_type_to_mask_type
,
1479 static const struct agp_bridge_driver intel_810_driver
= {
1480 .owner
= THIS_MODULE
,
1481 .aperture_sizes
= intel_i810_sizes
,
1482 .size_type
= FIXED_APER_SIZE
,
1483 .num_aperture_sizes
= 2,
1484 .needs_scratch_page
= TRUE
,
1485 .configure
= intel_i810_configure
,
1486 .fetch_size
= intel_i810_fetch_size
,
1487 .cleanup
= intel_i810_cleanup
,
1488 .tlb_flush
= intel_i810_tlbflush
,
1489 .mask_memory
= intel_i810_mask_memory
,
1490 .masks
= intel_i810_masks
,
1491 .agp_enable
= intel_i810_agp_enable
,
1492 .cache_flush
= global_cache_flush
,
1493 .create_gatt_table
= agp_generic_create_gatt_table
,
1494 .free_gatt_table
= agp_generic_free_gatt_table
,
1495 .insert_memory
= intel_i810_insert_entries
,
1496 .remove_memory
= intel_i810_remove_entries
,
1497 .alloc_by_type
= intel_i810_alloc_by_type
,
1498 .free_by_type
= intel_i810_free_by_type
,
1499 .agp_alloc_page
= agp_generic_alloc_page
,
1500 .agp_destroy_page
= agp_generic_destroy_page
,
1501 .agp_type_to_mask_type
= agp_generic_type_to_mask_type
,
1504 static const struct agp_bridge_driver intel_815_driver
= {
1505 .owner
= THIS_MODULE
,
1506 .aperture_sizes
= intel_815_sizes
,
1507 .size_type
= U8_APER_SIZE
,
1508 .num_aperture_sizes
= 2,
1509 .configure
= intel_815_configure
,
1510 .fetch_size
= intel_815_fetch_size
,
1511 .cleanup
= intel_8xx_cleanup
,
1512 .tlb_flush
= intel_8xx_tlbflush
,
1513 .mask_memory
= agp_generic_mask_memory
,
1514 .masks
= intel_generic_masks
,
1515 .agp_enable
= agp_generic_enable
,
1516 .cache_flush
= global_cache_flush
,
1517 .create_gatt_table
= agp_generic_create_gatt_table
,
1518 .free_gatt_table
= agp_generic_free_gatt_table
,
1519 .insert_memory
= agp_generic_insert_memory
,
1520 .remove_memory
= agp_generic_remove_memory
,
1521 .alloc_by_type
= agp_generic_alloc_by_type
,
1522 .free_by_type
= agp_generic_free_by_type
,
1523 .agp_alloc_page
= agp_generic_alloc_page
,
1524 .agp_destroy_page
= agp_generic_destroy_page
,
1525 .agp_type_to_mask_type
= agp_generic_type_to_mask_type
,
1528 static const struct agp_bridge_driver intel_830_driver
= {
1529 .owner
= THIS_MODULE
,
1530 .aperture_sizes
= intel_i830_sizes
,
1531 .size_type
= FIXED_APER_SIZE
,
1532 .num_aperture_sizes
= 4,
1533 .needs_scratch_page
= TRUE
,
1534 .configure
= intel_i830_configure
,
1535 .fetch_size
= intel_i830_fetch_size
,
1536 .cleanup
= intel_i830_cleanup
,
1537 .tlb_flush
= intel_i810_tlbflush
,
1538 .mask_memory
= intel_i810_mask_memory
,
1539 .masks
= intel_i810_masks
,
1540 .agp_enable
= intel_i810_agp_enable
,
1541 .cache_flush
= global_cache_flush
,
1542 .create_gatt_table
= intel_i830_create_gatt_table
,
1543 .free_gatt_table
= intel_i830_free_gatt_table
,
1544 .insert_memory
= intel_i830_insert_entries
,
1545 .remove_memory
= intel_i830_remove_entries
,
1546 .alloc_by_type
= intel_i830_alloc_by_type
,
1547 .free_by_type
= intel_i810_free_by_type
,
1548 .agp_alloc_page
= agp_generic_alloc_page
,
1549 .agp_destroy_page
= agp_generic_destroy_page
,
1550 .agp_type_to_mask_type
= intel_i830_type_to_mask_type
,
1553 static const struct agp_bridge_driver intel_820_driver
= {
1554 .owner
= THIS_MODULE
,
1555 .aperture_sizes
= intel_8xx_sizes
,
1556 .size_type
= U8_APER_SIZE
,
1557 .num_aperture_sizes
= 7,
1558 .configure
= intel_820_configure
,
1559 .fetch_size
= intel_8xx_fetch_size
,
1560 .cleanup
= intel_820_cleanup
,
1561 .tlb_flush
= intel_820_tlbflush
,
1562 .mask_memory
= agp_generic_mask_memory
,
1563 .masks
= intel_generic_masks
,
1564 .agp_enable
= agp_generic_enable
,
1565 .cache_flush
= global_cache_flush
,
1566 .create_gatt_table
= agp_generic_create_gatt_table
,
1567 .free_gatt_table
= agp_generic_free_gatt_table
,
1568 .insert_memory
= agp_generic_insert_memory
,
1569 .remove_memory
= agp_generic_remove_memory
,
1570 .alloc_by_type
= agp_generic_alloc_by_type
,
1571 .free_by_type
= agp_generic_free_by_type
,
1572 .agp_alloc_page
= agp_generic_alloc_page
,
1573 .agp_destroy_page
= agp_generic_destroy_page
,
1574 .agp_type_to_mask_type
= agp_generic_type_to_mask_type
,
1577 static const struct agp_bridge_driver intel_830mp_driver
= {
1578 .owner
= THIS_MODULE
,
1579 .aperture_sizes
= intel_830mp_sizes
,
1580 .size_type
= U8_APER_SIZE
,
1581 .num_aperture_sizes
= 4,
1582 .configure
= intel_830mp_configure
,
1583 .fetch_size
= intel_8xx_fetch_size
,
1584 .cleanup
= intel_8xx_cleanup
,
1585 .tlb_flush
= intel_8xx_tlbflush
,
1586 .mask_memory
= agp_generic_mask_memory
,
1587 .masks
= intel_generic_masks
,
1588 .agp_enable
= agp_generic_enable
,
1589 .cache_flush
= global_cache_flush
,
1590 .create_gatt_table
= agp_generic_create_gatt_table
,
1591 .free_gatt_table
= agp_generic_free_gatt_table
,
1592 .insert_memory
= agp_generic_insert_memory
,
1593 .remove_memory
= agp_generic_remove_memory
,
1594 .alloc_by_type
= agp_generic_alloc_by_type
,
1595 .free_by_type
= agp_generic_free_by_type
,
1596 .agp_alloc_page
= agp_generic_alloc_page
,
1597 .agp_destroy_page
= agp_generic_destroy_page
,
1598 .agp_type_to_mask_type
= agp_generic_type_to_mask_type
,
1601 static const struct agp_bridge_driver intel_840_driver
= {
1602 .owner
= THIS_MODULE
,
1603 .aperture_sizes
= intel_8xx_sizes
,
1604 .size_type
= U8_APER_SIZE
,
1605 .num_aperture_sizes
= 7,
1606 .configure
= intel_840_configure
,
1607 .fetch_size
= intel_8xx_fetch_size
,
1608 .cleanup
= intel_8xx_cleanup
,
1609 .tlb_flush
= intel_8xx_tlbflush
,
1610 .mask_memory
= agp_generic_mask_memory
,
1611 .masks
= intel_generic_masks
,
1612 .agp_enable
= agp_generic_enable
,
1613 .cache_flush
= global_cache_flush
,
1614 .create_gatt_table
= agp_generic_create_gatt_table
,
1615 .free_gatt_table
= agp_generic_free_gatt_table
,
1616 .insert_memory
= agp_generic_insert_memory
,
1617 .remove_memory
= agp_generic_remove_memory
,
1618 .alloc_by_type
= agp_generic_alloc_by_type
,
1619 .free_by_type
= agp_generic_free_by_type
,
1620 .agp_alloc_page
= agp_generic_alloc_page
,
1621 .agp_destroy_page
= agp_generic_destroy_page
,
1622 .agp_type_to_mask_type
= agp_generic_type_to_mask_type
,
1625 static const struct agp_bridge_driver intel_845_driver
= {
1626 .owner
= THIS_MODULE
,
1627 .aperture_sizes
= intel_8xx_sizes
,
1628 .size_type
= U8_APER_SIZE
,
1629 .num_aperture_sizes
= 7,
1630 .configure
= intel_845_configure
,
1631 .fetch_size
= intel_8xx_fetch_size
,
1632 .cleanup
= intel_8xx_cleanup
,
1633 .tlb_flush
= intel_8xx_tlbflush
,
1634 .mask_memory
= agp_generic_mask_memory
,
1635 .masks
= intel_generic_masks
,
1636 .agp_enable
= agp_generic_enable
,
1637 .cache_flush
= global_cache_flush
,
1638 .create_gatt_table
= agp_generic_create_gatt_table
,
1639 .free_gatt_table
= agp_generic_free_gatt_table
,
1640 .insert_memory
= agp_generic_insert_memory
,
1641 .remove_memory
= agp_generic_remove_memory
,
1642 .alloc_by_type
= agp_generic_alloc_by_type
,
1643 .free_by_type
= agp_generic_free_by_type
,
1644 .agp_alloc_page
= agp_generic_alloc_page
,
1645 .agp_destroy_page
= agp_generic_destroy_page
,
1646 .agp_type_to_mask_type
= agp_generic_type_to_mask_type
,
1649 static const struct agp_bridge_driver intel_850_driver
= {
1650 .owner
= THIS_MODULE
,
1651 .aperture_sizes
= intel_8xx_sizes
,
1652 .size_type
= U8_APER_SIZE
,
1653 .num_aperture_sizes
= 7,
1654 .configure
= intel_850_configure
,
1655 .fetch_size
= intel_8xx_fetch_size
,
1656 .cleanup
= intel_8xx_cleanup
,
1657 .tlb_flush
= intel_8xx_tlbflush
,
1658 .mask_memory
= agp_generic_mask_memory
,
1659 .masks
= intel_generic_masks
,
1660 .agp_enable
= agp_generic_enable
,
1661 .cache_flush
= global_cache_flush
,
1662 .create_gatt_table
= agp_generic_create_gatt_table
,
1663 .free_gatt_table
= agp_generic_free_gatt_table
,
1664 .insert_memory
= agp_generic_insert_memory
,
1665 .remove_memory
= agp_generic_remove_memory
,
1666 .alloc_by_type
= agp_generic_alloc_by_type
,
1667 .free_by_type
= agp_generic_free_by_type
,
1668 .agp_alloc_page
= agp_generic_alloc_page
,
1669 .agp_destroy_page
= agp_generic_destroy_page
,
1670 .agp_type_to_mask_type
= agp_generic_type_to_mask_type
,
1673 static const struct agp_bridge_driver intel_860_driver
= {
1674 .owner
= THIS_MODULE
,
1675 .aperture_sizes
= intel_8xx_sizes
,
1676 .size_type
= U8_APER_SIZE
,
1677 .num_aperture_sizes
= 7,
1678 .configure
= intel_860_configure
,
1679 .fetch_size
= intel_8xx_fetch_size
,
1680 .cleanup
= intel_8xx_cleanup
,
1681 .tlb_flush
= intel_8xx_tlbflush
,
1682 .mask_memory
= agp_generic_mask_memory
,
1683 .masks
= intel_generic_masks
,
1684 .agp_enable
= agp_generic_enable
,
1685 .cache_flush
= global_cache_flush
,
1686 .create_gatt_table
= agp_generic_create_gatt_table
,
1687 .free_gatt_table
= agp_generic_free_gatt_table
,
1688 .insert_memory
= agp_generic_insert_memory
,
1689 .remove_memory
= agp_generic_remove_memory
,
1690 .alloc_by_type
= agp_generic_alloc_by_type
,
1691 .free_by_type
= agp_generic_free_by_type
,
1692 .agp_alloc_page
= agp_generic_alloc_page
,
1693 .agp_destroy_page
= agp_generic_destroy_page
,
1694 .agp_type_to_mask_type
= agp_generic_type_to_mask_type
,
1697 static const struct agp_bridge_driver intel_915_driver
= {
1698 .owner
= THIS_MODULE
,
1699 .aperture_sizes
= intel_i830_sizes
,
1700 .size_type
= FIXED_APER_SIZE
,
1701 .num_aperture_sizes
= 4,
1702 .needs_scratch_page
= TRUE
,
1703 .configure
= intel_i915_configure
,
1704 .fetch_size
= intel_i9xx_fetch_size
,
1705 .cleanup
= intel_i915_cleanup
,
1706 .tlb_flush
= intel_i810_tlbflush
,
1707 .mask_memory
= intel_i810_mask_memory
,
1708 .masks
= intel_i810_masks
,
1709 .agp_enable
= intel_i810_agp_enable
,
1710 .cache_flush
= global_cache_flush
,
1711 .create_gatt_table
= intel_i915_create_gatt_table
,
1712 .free_gatt_table
= intel_i830_free_gatt_table
,
1713 .insert_memory
= intel_i915_insert_entries
,
1714 .remove_memory
= intel_i915_remove_entries
,
1715 .alloc_by_type
= intel_i830_alloc_by_type
,
1716 .free_by_type
= intel_i810_free_by_type
,
1717 .agp_alloc_page
= agp_generic_alloc_page
,
1718 .agp_destroy_page
= agp_generic_destroy_page
,
1719 .agp_type_to_mask_type
= intel_i830_type_to_mask_type
,
1722 static const struct agp_bridge_driver intel_i965_driver
= {
1723 .owner
= THIS_MODULE
,
1724 .aperture_sizes
= intel_i830_sizes
,
1725 .size_type
= FIXED_APER_SIZE
,
1726 .num_aperture_sizes
= 4,
1727 .needs_scratch_page
= TRUE
,
1728 .configure
= intel_i915_configure
,
1729 .fetch_size
= intel_i9xx_fetch_size
,
1730 .cleanup
= intel_i915_cleanup
,
1731 .tlb_flush
= intel_i810_tlbflush
,
1732 .mask_memory
= intel_i965_mask_memory
,
1733 .masks
= intel_i810_masks
,
1734 .agp_enable
= intel_i810_agp_enable
,
1735 .cache_flush
= global_cache_flush
,
1736 .create_gatt_table
= intel_i965_create_gatt_table
,
1737 .free_gatt_table
= intel_i830_free_gatt_table
,
1738 .insert_memory
= intel_i915_insert_entries
,
1739 .remove_memory
= intel_i915_remove_entries
,
1740 .alloc_by_type
= intel_i830_alloc_by_type
,
1741 .free_by_type
= intel_i810_free_by_type
,
1742 .agp_alloc_page
= agp_generic_alloc_page
,
1743 .agp_destroy_page
= agp_generic_destroy_page
,
1744 .agp_type_to_mask_type
= intel_i830_type_to_mask_type
,
1747 static const struct agp_bridge_driver intel_7505_driver
= {
1748 .owner
= THIS_MODULE
,
1749 .aperture_sizes
= intel_8xx_sizes
,
1750 .size_type
= U8_APER_SIZE
,
1751 .num_aperture_sizes
= 7,
1752 .configure
= intel_7505_configure
,
1753 .fetch_size
= intel_8xx_fetch_size
,
1754 .cleanup
= intel_8xx_cleanup
,
1755 .tlb_flush
= intel_8xx_tlbflush
,
1756 .mask_memory
= agp_generic_mask_memory
,
1757 .masks
= intel_generic_masks
,
1758 .agp_enable
= agp_generic_enable
,
1759 .cache_flush
= global_cache_flush
,
1760 .create_gatt_table
= agp_generic_create_gatt_table
,
1761 .free_gatt_table
= agp_generic_free_gatt_table
,
1762 .insert_memory
= agp_generic_insert_memory
,
1763 .remove_memory
= agp_generic_remove_memory
,
1764 .alloc_by_type
= agp_generic_alloc_by_type
,
1765 .free_by_type
= agp_generic_free_by_type
,
1766 .agp_alloc_page
= agp_generic_alloc_page
,
1767 .agp_destroy_page
= agp_generic_destroy_page
,
1768 .agp_type_to_mask_type
= agp_generic_type_to_mask_type
,
1771 static const struct agp_bridge_driver intel_g33_driver
= {
1772 .owner
= THIS_MODULE
,
1773 .aperture_sizes
= intel_i830_sizes
,
1774 .size_type
= FIXED_APER_SIZE
,
1775 .num_aperture_sizes
= 4,
1776 .needs_scratch_page
= TRUE
,
1777 .configure
= intel_i915_configure
,
1778 .fetch_size
= intel_i9xx_fetch_size
,
1779 .cleanup
= intel_i915_cleanup
,
1780 .tlb_flush
= intel_i810_tlbflush
,
1781 .mask_memory
= intel_i965_mask_memory
,
1782 .masks
= intel_i810_masks
,
1783 .agp_enable
= intel_i810_agp_enable
,
1784 .cache_flush
= global_cache_flush
,
1785 .create_gatt_table
= intel_i915_create_gatt_table
,
1786 .free_gatt_table
= intel_i830_free_gatt_table
,
1787 .insert_memory
= intel_i915_insert_entries
,
1788 .remove_memory
= intel_i915_remove_entries
,
1789 .alloc_by_type
= intel_i830_alloc_by_type
,
1790 .free_by_type
= intel_i810_free_by_type
,
1791 .agp_alloc_page
= agp_generic_alloc_page
,
1792 .agp_destroy_page
= agp_generic_destroy_page
,
1793 .agp_type_to_mask_type
= intel_i830_type_to_mask_type
,
1796 static int find_gmch(u16 device
)
1798 struct pci_dev
*gmch_device
;
1800 gmch_device
= pci_get_device(PCI_VENDOR_ID_INTEL
, device
, NULL
);
1801 if (gmch_device
&& PCI_FUNC(gmch_device
->devfn
) != 0) {
1802 gmch_device
= pci_get_device(PCI_VENDOR_ID_INTEL
,
1803 device
, gmch_device
);
1809 intel_private
.pcidev
= gmch_device
;
1813 /* Table to describe Intel GMCH and AGP/PCIE GART drivers. At least one of
1814 * driver and gmch_driver must be non-null, and find_gmch will determine
1815 * which one should be used if a gmch_chip_id is present.
1817 static const struct intel_driver_description
{
1818 unsigned int chip_id
;
1819 unsigned int gmch_chip_id
;
1820 unsigned int multi_gmch_chip
; /* if we have more gfx chip type on this HB. */
1822 const struct agp_bridge_driver
*driver
;
1823 const struct agp_bridge_driver
*gmch_driver
;
1824 } intel_agp_chipsets
[] = {
1825 { PCI_DEVICE_ID_INTEL_82443LX_0
, 0, 0, "440LX", &intel_generic_driver
, NULL
},
1826 { PCI_DEVICE_ID_INTEL_82443BX_0
, 0, 0, "440BX", &intel_generic_driver
, NULL
},
1827 { PCI_DEVICE_ID_INTEL_82443GX_0
, 0, 0, "440GX", &intel_generic_driver
, NULL
},
1828 { PCI_DEVICE_ID_INTEL_82810_MC1
, PCI_DEVICE_ID_INTEL_82810_IG1
, 0, "i810",
1829 NULL
, &intel_810_driver
},
1830 { PCI_DEVICE_ID_INTEL_82810_MC3
, PCI_DEVICE_ID_INTEL_82810_IG3
, 0, "i810",
1831 NULL
, &intel_810_driver
},
1832 { PCI_DEVICE_ID_INTEL_82810E_MC
, PCI_DEVICE_ID_INTEL_82810E_IG
, 0, "i810",
1833 NULL
, &intel_810_driver
},
1834 { PCI_DEVICE_ID_INTEL_82815_MC
, PCI_DEVICE_ID_INTEL_82815_CGC
, 0, "i815",
1835 &intel_815_driver
, &intel_810_driver
},
1836 { PCI_DEVICE_ID_INTEL_82820_HB
, 0, 0, "i820", &intel_820_driver
, NULL
},
1837 { PCI_DEVICE_ID_INTEL_82820_UP_HB
, 0, 0, "i820", &intel_820_driver
, NULL
},
1838 { PCI_DEVICE_ID_INTEL_82830_HB
, PCI_DEVICE_ID_INTEL_82830_CGC
, 0, "830M",
1839 &intel_830mp_driver
, &intel_830_driver
},
1840 { PCI_DEVICE_ID_INTEL_82840_HB
, 0, 0, "i840", &intel_840_driver
, NULL
},
1841 { PCI_DEVICE_ID_INTEL_82845_HB
, 0, 0, "845G", &intel_845_driver
, NULL
},
1842 { PCI_DEVICE_ID_INTEL_82845G_HB
, PCI_DEVICE_ID_INTEL_82845G_IG
, 0, "830M",
1843 &intel_845_driver
, &intel_830_driver
},
1844 { PCI_DEVICE_ID_INTEL_82850_HB
, 0, 0, "i850", &intel_850_driver
, NULL
},
1845 { PCI_DEVICE_ID_INTEL_82855PM_HB
, 0, 0, "855PM", &intel_845_driver
, NULL
},
1846 { PCI_DEVICE_ID_INTEL_82855GM_HB
, PCI_DEVICE_ID_INTEL_82855GM_IG
, 0, "855GM",
1847 &intel_845_driver
, &intel_830_driver
},
1848 { PCI_DEVICE_ID_INTEL_82860_HB
, 0, 0, "i860", &intel_860_driver
, NULL
},
1849 { PCI_DEVICE_ID_INTEL_82865_HB
, PCI_DEVICE_ID_INTEL_82865_IG
, 0, "865",
1850 &intel_845_driver
, &intel_830_driver
},
1851 { PCI_DEVICE_ID_INTEL_82875_HB
, 0, 0, "i875", &intel_845_driver
, NULL
},
1852 { PCI_DEVICE_ID_INTEL_82915G_HB
, PCI_DEVICE_ID_INTEL_82915G_IG
, 0, "915G",
1853 NULL
, &intel_915_driver
},
1854 { PCI_DEVICE_ID_INTEL_82915GM_HB
, PCI_DEVICE_ID_INTEL_82915GM_IG
, 0, "915GM",
1855 NULL
, &intel_915_driver
},
1856 { PCI_DEVICE_ID_INTEL_82945G_HB
, PCI_DEVICE_ID_INTEL_82945G_IG
, 0, "945G",
1857 NULL
, &intel_915_driver
},
1858 { PCI_DEVICE_ID_INTEL_82945GM_HB
, PCI_DEVICE_ID_INTEL_82945GM_IG
, 0, "945GM",
1859 NULL
, &intel_915_driver
},
1860 { PCI_DEVICE_ID_INTEL_82945GME_HB
, PCI_DEVICE_ID_INTEL_82945GME_IG
, 0, "945GME",
1861 NULL
, &intel_915_driver
},
1862 { PCI_DEVICE_ID_INTEL_82946GZ_HB
, PCI_DEVICE_ID_INTEL_82946GZ_IG
, 0, "946GZ",
1863 NULL
, &intel_i965_driver
},
1864 { PCI_DEVICE_ID_INTEL_82965G_1_HB
, PCI_DEVICE_ID_INTEL_82965G_1_IG
, 0, "965G",
1865 NULL
, &intel_i965_driver
},
1866 { PCI_DEVICE_ID_INTEL_82965Q_HB
, PCI_DEVICE_ID_INTEL_82965Q_IG
, 0, "965Q",
1867 NULL
, &intel_i965_driver
},
1868 { PCI_DEVICE_ID_INTEL_82965G_HB
, PCI_DEVICE_ID_INTEL_82965G_IG
, 0, "965G",
1869 NULL
, &intel_i965_driver
},
1870 { PCI_DEVICE_ID_INTEL_82965GM_HB
, PCI_DEVICE_ID_INTEL_82965GM_IG
, 0, "965GM",
1871 NULL
, &intel_i965_driver
},
1872 { PCI_DEVICE_ID_INTEL_82965GME_HB
, PCI_DEVICE_ID_INTEL_82965GME_IG
, 0, "965GME/GLE",
1873 NULL
, &intel_i965_driver
},
1874 { PCI_DEVICE_ID_INTEL_7505_0
, 0, 0, "E7505", &intel_7505_driver
, NULL
},
1875 { PCI_DEVICE_ID_INTEL_7205_0
, 0, 0, "E7205", &intel_7505_driver
, NULL
},
1876 { PCI_DEVICE_ID_INTEL_G33_HB
, PCI_DEVICE_ID_INTEL_G33_IG
, 0, "G33",
1877 NULL
, &intel_g33_driver
},
1878 { PCI_DEVICE_ID_INTEL_Q35_HB
, PCI_DEVICE_ID_INTEL_Q35_IG
, 0, "Q35",
1879 NULL
, &intel_g33_driver
},
1880 { PCI_DEVICE_ID_INTEL_Q33_HB
, PCI_DEVICE_ID_INTEL_Q33_IG
, 0, "Q33",
1881 NULL
, &intel_g33_driver
},
1882 { 0, 0, 0, NULL
, NULL
, NULL
}
1885 static int __devinit
agp_intel_probe(struct pci_dev
*pdev
,
1886 const struct pci_device_id
*ent
)
1888 struct agp_bridge_data
*bridge
;
1893 cap_ptr
= pci_find_capability(pdev
, PCI_CAP_ID_AGP
);
1895 bridge
= agp_alloc_bridge();
1899 for (i
= 0; intel_agp_chipsets
[i
].name
!= NULL
; i
++) {
1900 /* In case that multiple models of gfx chip may
1901 stand on same host bridge type, this can be
1902 sure we detect the right IGD. */
1903 if (pdev
->device
== intel_agp_chipsets
[i
].chip_id
) {
1904 if ((intel_agp_chipsets
[i
].gmch_chip_id
!= 0) &&
1905 find_gmch(intel_agp_chipsets
[i
].gmch_chip_id
)) {
1907 intel_agp_chipsets
[i
].gmch_driver
;
1909 } else if (intel_agp_chipsets
[i
].multi_gmch_chip
) {
1912 bridge
->driver
= intel_agp_chipsets
[i
].driver
;
1918 if (intel_agp_chipsets
[i
].name
== NULL
) {
1920 printk(KERN_WARNING PFX
"Unsupported Intel chipset"
1921 "(device id: %04x)\n", pdev
->device
);
1922 agp_put_bridge(bridge
);
1926 if (bridge
->driver
== NULL
) {
1927 /* bridge has no AGP and no IGD detected */
1929 printk(KERN_WARNING PFX
"Failed to find bridge device "
1930 "(chip_id: %04x)\n",
1931 intel_agp_chipsets
[i
].gmch_chip_id
);
1932 agp_put_bridge(bridge
);
1937 bridge
->capndx
= cap_ptr
;
1938 bridge
->dev_private_data
= &intel_private
;
1940 printk(KERN_INFO PFX
"Detected an Intel %s Chipset.\n",
1941 intel_agp_chipsets
[i
].name
);
1944 * The following fixes the case where the BIOS has "forgotten" to
1945 * provide an address range for the GART.
1946 * 20030610 - hamish@zot.org
1948 r
= &pdev
->resource
[0];
1949 if (!r
->start
&& r
->end
) {
1950 if (pci_assign_resource(pdev
, 0)) {
1951 printk(KERN_ERR PFX
"could not assign resource 0\n");
1952 agp_put_bridge(bridge
);
1958 * If the device has not been properly setup, the following will catch
1959 * the problem and should stop the system from crashing.
1960 * 20030610 - hamish@zot.org
1962 if (pci_enable_device(pdev
)) {
1963 printk(KERN_ERR PFX
"Unable to Enable PCI device\n");
1964 agp_put_bridge(bridge
);
1968 /* Fill in the mode register */
1970 pci_read_config_dword(pdev
,
1971 bridge
->capndx
+PCI_AGP_STATUS
,
1975 pci_set_drvdata(pdev
, bridge
);
1976 return agp_add_bridge(bridge
);
1979 static void __devexit
agp_intel_remove(struct pci_dev
*pdev
)
1981 struct agp_bridge_data
*bridge
= pci_get_drvdata(pdev
);
1983 agp_remove_bridge(bridge
);
1985 if (intel_private
.pcidev
)
1986 pci_dev_put(intel_private
.pcidev
);
1988 agp_put_bridge(bridge
);
1992 static int agp_intel_resume(struct pci_dev
*pdev
)
1994 struct agp_bridge_data
*bridge
= pci_get_drvdata(pdev
);
1996 pci_restore_state(pdev
);
1998 /* We should restore our graphics device's config space,
1999 * as host bridge (00:00) resumes before graphics device (02:00),
2000 * then our access to its pci space can work right.
2002 if (intel_private
.pcidev
)
2003 pci_restore_state(intel_private
.pcidev
);
2005 if (bridge
->driver
== &intel_generic_driver
)
2007 else if (bridge
->driver
== &intel_850_driver
)
2008 intel_850_configure();
2009 else if (bridge
->driver
== &intel_845_driver
)
2010 intel_845_configure();
2011 else if (bridge
->driver
== &intel_830mp_driver
)
2012 intel_830mp_configure();
2013 else if (bridge
->driver
== &intel_915_driver
)
2014 intel_i915_configure();
2015 else if (bridge
->driver
== &intel_830_driver
)
2016 intel_i830_configure();
2017 else if (bridge
->driver
== &intel_810_driver
)
2018 intel_i810_configure();
2019 else if (bridge
->driver
== &intel_i965_driver
)
2020 intel_i915_configure();
2026 static struct pci_device_id agp_intel_pci_table
[] = {
2029 .class = (PCI_CLASS_BRIDGE_HOST << 8), \
2031 .vendor = PCI_VENDOR_ID_INTEL, \
2033 .subvendor = PCI_ANY_ID, \
2034 .subdevice = PCI_ANY_ID, \
2036 ID(PCI_DEVICE_ID_INTEL_82443LX_0
),
2037 ID(PCI_DEVICE_ID_INTEL_82443BX_0
),
2038 ID(PCI_DEVICE_ID_INTEL_82443GX_0
),
2039 ID(PCI_DEVICE_ID_INTEL_82810_MC1
),
2040 ID(PCI_DEVICE_ID_INTEL_82810_MC3
),
2041 ID(PCI_DEVICE_ID_INTEL_82810E_MC
),
2042 ID(PCI_DEVICE_ID_INTEL_82815_MC
),
2043 ID(PCI_DEVICE_ID_INTEL_82820_HB
),
2044 ID(PCI_DEVICE_ID_INTEL_82820_UP_HB
),
2045 ID(PCI_DEVICE_ID_INTEL_82830_HB
),
2046 ID(PCI_DEVICE_ID_INTEL_82840_HB
),
2047 ID(PCI_DEVICE_ID_INTEL_82845_HB
),
2048 ID(PCI_DEVICE_ID_INTEL_82845G_HB
),
2049 ID(PCI_DEVICE_ID_INTEL_82850_HB
),
2050 ID(PCI_DEVICE_ID_INTEL_82855PM_HB
),
2051 ID(PCI_DEVICE_ID_INTEL_82855GM_HB
),
2052 ID(PCI_DEVICE_ID_INTEL_82860_HB
),
2053 ID(PCI_DEVICE_ID_INTEL_82865_HB
),
2054 ID(PCI_DEVICE_ID_INTEL_82875_HB
),
2055 ID(PCI_DEVICE_ID_INTEL_7505_0
),
2056 ID(PCI_DEVICE_ID_INTEL_7205_0
),
2057 ID(PCI_DEVICE_ID_INTEL_82915G_HB
),
2058 ID(PCI_DEVICE_ID_INTEL_82915GM_HB
),
2059 ID(PCI_DEVICE_ID_INTEL_82945G_HB
),
2060 ID(PCI_DEVICE_ID_INTEL_82945GM_HB
),
2061 ID(PCI_DEVICE_ID_INTEL_82945GME_HB
),
2062 ID(PCI_DEVICE_ID_INTEL_82946GZ_HB
),
2063 ID(PCI_DEVICE_ID_INTEL_82965G_1_HB
),
2064 ID(PCI_DEVICE_ID_INTEL_82965Q_HB
),
2065 ID(PCI_DEVICE_ID_INTEL_82965G_HB
),
2066 ID(PCI_DEVICE_ID_INTEL_82965GM_HB
),
2067 ID(PCI_DEVICE_ID_INTEL_82965GME_HB
),
2068 ID(PCI_DEVICE_ID_INTEL_G33_HB
),
2069 ID(PCI_DEVICE_ID_INTEL_Q35_HB
),
2070 ID(PCI_DEVICE_ID_INTEL_Q33_HB
),
2074 MODULE_DEVICE_TABLE(pci
, agp_intel_pci_table
);
2076 static struct pci_driver agp_intel_pci_driver
= {
2077 .name
= "agpgart-intel",
2078 .id_table
= agp_intel_pci_table
,
2079 .probe
= agp_intel_probe
,
2080 .remove
= __devexit_p(agp_intel_remove
),
2082 .resume
= agp_intel_resume
,
2086 static int __init
agp_intel_init(void)
2090 return pci_register_driver(&agp_intel_pci_driver
);
2093 static void __exit
agp_intel_cleanup(void)
2095 pci_unregister_driver(&agp_intel_pci_driver
);
2098 module_init(agp_intel_init
);
2099 module_exit(agp_intel_cleanup
);
2101 MODULE_AUTHOR("Dave Jones <davej@codemonkey.org.uk>");
2102 MODULE_LICENSE("GPL and additional rights");