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
24 #define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \
25 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_1_HB || \
26 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965Q_HB || \
27 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \
28 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB)
31 extern int agp_memory_reserved;
34 /* Intel 815 register */
35 #define INTEL_815_APCONT 0x51
36 #define INTEL_815_ATTBASE_MASK ~0x1FFFFFFF
38 /* Intel i820 registers */
39 #define INTEL_I820_RDCR 0x51
40 #define INTEL_I820_ERRSTS 0xc8
42 /* Intel i840 registers */
43 #define INTEL_I840_MCHCFG 0x50
44 #define INTEL_I840_ERRSTS 0xc8
46 /* Intel i850 registers */
47 #define INTEL_I850_MCHCFG 0x50
48 #define INTEL_I850_ERRSTS 0xc8
50 /* intel 915G registers */
51 #define I915_GMADDR 0x18
52 #define I915_MMADDR 0x10
53 #define I915_PTEADDR 0x1C
54 #define I915_GMCH_GMS_STOLEN_48M (0x6 << 4)
55 #define I915_GMCH_GMS_STOLEN_64M (0x7 << 4)
57 /* Intel 965G registers */
58 #define I965_MSAC 0x62
60 /* Intel 7505 registers */
61 #define INTEL_I7505_APSIZE 0x74
62 #define INTEL_I7505_NCAPID 0x60
63 #define INTEL_I7505_NISTAT 0x6c
64 #define INTEL_I7505_ATTBASE 0x78
65 #define INTEL_I7505_ERRSTS 0x42
66 #define INTEL_I7505_AGPCTRL 0x70
67 #define INTEL_I7505_MCHCFG 0x50
69 static const struct aper_size_info_fixed intel_i810_sizes[] =
72 /* The 32M mode still requires a 64k gatt */
76 #define AGP_DCACHE_MEMORY 1
77 #define AGP_PHYS_MEMORY 2
78 #define INTEL_AGP_CACHED_MEMORY 3
80 static struct gatt_mask intel_i810_masks[] =
82 {.mask = I810_PTE_VALID, .type = 0},
83 {.mask = (I810_PTE_VALID | I810_PTE_LOCAL), .type = AGP_DCACHE_MEMORY},
84 {.mask = I810_PTE_VALID, .type = 0},
85 {.mask = I810_PTE_VALID | I830_PTE_SYSTEM_CACHED,
86 .type = INTEL_AGP_CACHED_MEMORY}
89 static struct _intel_i810_private {
90 struct pci_dev *i810_dev; /* device one */
91 volatile u8 __iomem *registers;
92 int num_dcache_entries;
95 static int intel_i810_fetch_size(void)
98 struct aper_size_info_fixed *values;
100 pci_read_config_dword(agp_bridge->dev, I810_SMRAM_MISCC, &smram_miscc);
101 values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes);
103 if ((smram_miscc & I810_GMS) == I810_GMS_DISABLE) {
104 printk(KERN_WARNING PFX "i810 is disabled\n");
107 if ((smram_miscc & I810_GFX_MEM_WIN_SIZE) == I810_GFX_MEM_WIN_32M) {
108 agp_bridge->previous_size =
109 agp_bridge->current_size = (void *) (values + 1);
110 agp_bridge->aperture_size_idx = 1;
111 return values[1].size;
113 agp_bridge->previous_size =
114 agp_bridge->current_size = (void *) (values);
115 agp_bridge->aperture_size_idx = 0;
116 return values[0].size;
122 static int intel_i810_configure(void)
124 struct aper_size_info_fixed *current_size;
128 current_size = A_SIZE_FIX(agp_bridge->current_size);
130 if (!intel_i810_private.registers) {
131 pci_read_config_dword(intel_i810_private.i810_dev, I810_MMADDR, &temp);
134 intel_i810_private.registers = ioremap(temp, 128 * 4096);
135 if (!intel_i810_private.registers) {
136 printk(KERN_ERR PFX "Unable to remap memory.\n");
141 if ((readl(intel_i810_private.registers+I810_DRAM_CTL)
142 & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) {
143 /* This will need to be dynamically assigned */
144 printk(KERN_INFO PFX "detected 4MB dedicated video ram.\n");
145 intel_i810_private.num_dcache_entries = 1024;
147 pci_read_config_dword(intel_i810_private.i810_dev, I810_GMADDR, &temp);
148 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
149 writel(agp_bridge->gatt_bus_addr | I810_PGETBL_ENABLED, intel_i810_private.registers+I810_PGETBL_CTL);
150 readl(intel_i810_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
152 if (agp_bridge->driver->needs_scratch_page) {
153 for (i = 0; i < current_size->num_entries; i++) {
154 writel(agp_bridge->scratch_page, intel_i810_private.registers+I810_PTE_BASE+(i*4));
155 readl(intel_i810_private.registers+I810_PTE_BASE+(i*4)); /* PCI posting. */
158 global_cache_flush();
162 static void intel_i810_cleanup(void)
164 writel(0, intel_i810_private.registers+I810_PGETBL_CTL);
165 readl(intel_i810_private.registers); /* PCI Posting. */
166 iounmap(intel_i810_private.registers);
169 static void intel_i810_tlbflush(struct agp_memory *mem)
174 static void intel_i810_agp_enable(struct agp_bridge_data *bridge, u32 mode)
179 /* Exists to support ARGB cursors */
180 static void *i8xx_alloc_pages(void)
184 page = alloc_pages(GFP_KERNEL | GFP_DMA32, 2);
188 if (change_page_attr(page, 4, PAGE_KERNEL_NOCACHE) < 0) {
189 change_page_attr(page, 4, PAGE_KERNEL);
191 __free_pages(page, 2);
197 atomic_inc(&agp_bridge->current_memory_agp);
198 return page_address(page);
201 static void i8xx_destroy_pages(void *addr)
208 page = virt_to_page(addr);
209 change_page_attr(page, 4, PAGE_KERNEL);
213 __free_pages(page, 2);
214 atomic_dec(&agp_bridge->current_memory_agp);
217 static int intel_i830_type_to_mask_type(struct agp_bridge_data *bridge,
220 if (type < AGP_USER_TYPES)
222 else if (type == AGP_USER_CACHED_MEMORY)
223 return INTEL_AGP_CACHED_MEMORY;
228 static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
231 int i, j, num_entries;
236 if (mem->page_count == 0)
239 temp = agp_bridge->current_size;
240 num_entries = A_SIZE_FIX(temp)->num_entries;
242 if ((pg_start + mem->page_count) > num_entries)
246 for (j = pg_start; j < (pg_start + mem->page_count); j++) {
247 if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+j))) {
253 if (type != mem->type)
256 mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
259 case AGP_DCACHE_MEMORY:
260 if (!mem->is_flushed)
261 global_cache_flush();
262 for (i = pg_start; i < (pg_start + mem->page_count); i++) {
263 writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID,
264 intel_i810_private.registers+I810_PTE_BASE+(i*4));
266 readl(intel_i810_private.registers+I810_PTE_BASE+((i-1)*4));
268 case AGP_PHYS_MEMORY:
269 case AGP_NORMAL_MEMORY:
270 if (!mem->is_flushed)
271 global_cache_flush();
272 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
273 writel(agp_bridge->driver->mask_memory(agp_bridge,
276 intel_i810_private.registers+I810_PTE_BASE+(j*4));
278 readl(intel_i810_private.registers+I810_PTE_BASE+((j-1)*4));
284 agp_bridge->driver->tlb_flush(mem);
292 static int intel_i810_remove_entries(struct agp_memory *mem, off_t pg_start,
297 if (mem->page_count == 0)
300 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
301 writel(agp_bridge->scratch_page, intel_i810_private.registers+I810_PTE_BASE+(i*4));
303 readl(intel_i810_private.registers+I810_PTE_BASE+((i-1)*4));
305 agp_bridge->driver->tlb_flush(mem);
310 * The i810/i830 requires a physical address to program its mouse
311 * pointer into hardware.
312 * However the Xserver still writes to it through the agp aperture.
314 static struct agp_memory *alloc_agpphysmem_i8xx(size_t pg_count, int type)
316 struct agp_memory *new;
320 case 1: addr = agp_bridge->driver->agp_alloc_page(agp_bridge);
324 /* kludge to get 4 physical pages for ARGB cursor */
325 addr = i8xx_alloc_pages();
334 new = agp_create_memory(pg_count);
338 new->memory[0] = virt_to_gart(addr);
340 /* kludge to get 4 physical pages for ARGB cursor */
341 new->memory[1] = new->memory[0] + PAGE_SIZE;
342 new->memory[2] = new->memory[1] + PAGE_SIZE;
343 new->memory[3] = new->memory[2] + PAGE_SIZE;
345 new->page_count = pg_count;
346 new->num_scratch_pages = pg_count;
347 new->type = AGP_PHYS_MEMORY;
348 new->physical = new->memory[0];
352 static struct agp_memory *intel_i810_alloc_by_type(size_t pg_count, int type)
354 struct agp_memory *new;
356 if (type == AGP_DCACHE_MEMORY) {
357 if (pg_count != intel_i810_private.num_dcache_entries)
360 new = agp_create_memory(1);
364 new->type = AGP_DCACHE_MEMORY;
365 new->page_count = pg_count;
366 new->num_scratch_pages = 0;
367 agp_free_page_array(new);
370 if (type == AGP_PHYS_MEMORY)
371 return alloc_agpphysmem_i8xx(pg_count, type);
375 static void intel_i810_free_by_type(struct agp_memory *curr)
377 agp_free_key(curr->key);
378 if (curr->type == AGP_PHYS_MEMORY) {
379 if (curr->page_count == 4)
380 i8xx_destroy_pages(gart_to_virt(curr->memory[0]));
382 agp_bridge->driver->agp_destroy_page(
383 gart_to_virt(curr->memory[0]));
386 agp_free_page_array(curr);
391 static unsigned long intel_i810_mask_memory(struct agp_bridge_data *bridge,
392 unsigned long addr, int type)
394 /* Type checking must be done elsewhere */
395 return addr | bridge->driver->masks[type].mask;
398 static struct aper_size_info_fixed intel_i830_sizes[] =
401 /* The 64M mode still requires a 128k gatt */
407 static struct _intel_i830_private {
408 struct pci_dev *i830_dev; /* device one */
409 volatile u8 __iomem *registers;
410 volatile u32 __iomem *gtt; /* I915G */
411 /* gtt_entries is the number of gtt entries that are already mapped
412 * to stolen memory. Stolen memory is larger than the memory mapped
413 * through gtt_entries, as it includes some reserved space for the BIOS
414 * popup and for the GTT.
417 } intel_i830_private;
419 static void intel_i830_init_gtt_entries(void)
425 static const int ddt[4] = { 0, 16, 32, 64 };
426 int size; /* reserved space (in kb) at the top of stolen memory */
428 pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl);
432 pgetbl_ctl = readl(intel_i830_private.registers+I810_PGETBL_CTL);
434 /* The 965 has a field telling us the size of the GTT,
435 * which may be larger than what is necessary to map the
438 switch (pgetbl_ctl & I965_PGETBL_SIZE_MASK) {
439 case I965_PGETBL_SIZE_128KB:
442 case I965_PGETBL_SIZE_256KB:
445 case I965_PGETBL_SIZE_512KB:
449 printk(KERN_INFO PFX "Unknown page table size, "
453 size += 4; /* add in BIOS popup space */
455 /* On previous hardware, the GTT size was just what was
456 * required to map the aperture.
458 size = agp_bridge->driver->fetch_size() + 4;
461 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82830_HB ||
462 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) {
463 switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
464 case I830_GMCH_GMS_STOLEN_512:
465 gtt_entries = KB(512) - KB(size);
467 case I830_GMCH_GMS_STOLEN_1024:
468 gtt_entries = MB(1) - KB(size);
470 case I830_GMCH_GMS_STOLEN_8192:
471 gtt_entries = MB(8) - KB(size);
473 case I830_GMCH_GMS_LOCAL:
474 rdct = readb(intel_i830_private.registers+I830_RDRAM_CHANNEL_TYPE);
475 gtt_entries = (I830_RDRAM_ND(rdct) + 1) *
476 MB(ddt[I830_RDRAM_DDT(rdct)]);
484 switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
485 case I855_GMCH_GMS_STOLEN_1M:
486 gtt_entries = MB(1) - KB(size);
488 case I855_GMCH_GMS_STOLEN_4M:
489 gtt_entries = MB(4) - KB(size);
491 case I855_GMCH_GMS_STOLEN_8M:
492 gtt_entries = MB(8) - KB(size);
494 case I855_GMCH_GMS_STOLEN_16M:
495 gtt_entries = MB(16) - KB(size);
497 case I855_GMCH_GMS_STOLEN_32M:
498 gtt_entries = MB(32) - KB(size);
500 case I915_GMCH_GMS_STOLEN_48M:
501 /* Check it's really I915G */
502 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
503 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
504 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
505 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || IS_I965 )
506 gtt_entries = MB(48) - KB(size);
510 case I915_GMCH_GMS_STOLEN_64M:
511 /* Check it's really I915G */
512 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
513 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
514 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
515 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || IS_I965)
516 gtt_entries = MB(64) - KB(size);
525 printk(KERN_INFO PFX "Detected %dK %s memory.\n",
526 gtt_entries / KB(1), local ? "local" : "stolen");
529 "No pre-allocated video memory detected.\n");
530 gtt_entries /= KB(4);
532 intel_i830_private.gtt_entries = gtt_entries;
535 /* The intel i830 automatically initializes the agp aperture during POST.
536 * Use the memory already set aside for in the GTT.
538 static int intel_i830_create_gatt_table(struct agp_bridge_data *bridge)
541 struct aper_size_info_fixed *size;
545 size = agp_bridge->current_size;
546 page_order = size->page_order;
547 num_entries = size->num_entries;
548 agp_bridge->gatt_table_real = NULL;
550 pci_read_config_dword(intel_i830_private.i830_dev,I810_MMADDR,&temp);
553 intel_i830_private.registers = ioremap(temp,128 * 4096);
554 if (!intel_i830_private.registers)
557 temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000;
558 global_cache_flush(); /* FIXME: ?? */
560 /* we have to call this as early as possible after the MMIO base address is known */
561 intel_i830_init_gtt_entries();
563 agp_bridge->gatt_table = NULL;
565 agp_bridge->gatt_bus_addr = temp;
570 /* Return the gatt table to a sane state. Use the top of stolen
571 * memory for the GTT.
573 static int intel_i830_free_gatt_table(struct agp_bridge_data *bridge)
578 static int intel_i830_fetch_size(void)
581 struct aper_size_info_fixed *values;
583 values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes);
585 if (agp_bridge->dev->device != PCI_DEVICE_ID_INTEL_82830_HB &&
586 agp_bridge->dev->device != PCI_DEVICE_ID_INTEL_82845G_HB) {
587 /* 855GM/852GM/865G has 128MB aperture size */
588 agp_bridge->previous_size = agp_bridge->current_size = (void *) values;
589 agp_bridge->aperture_size_idx = 0;
590 return values[0].size;
593 pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl);
595 if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_128M) {
596 agp_bridge->previous_size = agp_bridge->current_size = (void *) values;
597 agp_bridge->aperture_size_idx = 0;
598 return values[0].size;
600 agp_bridge->previous_size = agp_bridge->current_size = (void *) (values + 1);
601 agp_bridge->aperture_size_idx = 1;
602 return values[1].size;
608 static int intel_i830_configure(void)
610 struct aper_size_info_fixed *current_size;
615 current_size = A_SIZE_FIX(agp_bridge->current_size);
617 pci_read_config_dword(intel_i830_private.i830_dev,I810_GMADDR,&temp);
618 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
620 pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl);
621 gmch_ctrl |= I830_GMCH_ENABLED;
622 pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl);
624 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_i830_private.registers+I810_PGETBL_CTL);
625 readl(intel_i830_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
627 if (agp_bridge->driver->needs_scratch_page) {
628 for (i = intel_i830_private.gtt_entries; i < current_size->num_entries; i++) {
629 writel(agp_bridge->scratch_page, intel_i830_private.registers+I810_PTE_BASE+(i*4));
630 readl(intel_i830_private.registers+I810_PTE_BASE+(i*4)); /* PCI Posting. */
634 global_cache_flush();
638 static void intel_i830_cleanup(void)
640 iounmap(intel_i830_private.registers);
643 static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int type)
650 if (mem->page_count == 0)
653 temp = agp_bridge->current_size;
654 num_entries = A_SIZE_FIX(temp)->num_entries;
656 if (pg_start < intel_i830_private.gtt_entries) {
657 printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_i830_private.gtt_entries == 0x%.8x\n",
658 pg_start,intel_i830_private.gtt_entries);
660 printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n");
664 if ((pg_start + mem->page_count) > num_entries)
667 /* The i830 can't check the GTT for entries since its read only,
668 * depend on the caller to make the correct offset decisions.
671 if (type != mem->type)
674 mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
676 if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY &&
677 mask_type != INTEL_AGP_CACHED_MEMORY)
680 if (!mem->is_flushed)
681 global_cache_flush();
683 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
684 writel(agp_bridge->driver->mask_memory(agp_bridge,
685 mem->memory[i], mask_type),
686 intel_i830_private.registers+I810_PTE_BASE+(j*4));
688 readl(intel_i830_private.registers+I810_PTE_BASE+((j-1)*4));
689 agp_bridge->driver->tlb_flush(mem);
698 static int intel_i830_remove_entries(struct agp_memory *mem,off_t pg_start,
703 if (mem->page_count == 0)
706 if (pg_start < intel_i830_private.gtt_entries) {
707 printk (KERN_INFO PFX "Trying to disable local/stolen memory\n");
711 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
712 writel(agp_bridge->scratch_page, intel_i830_private.registers+I810_PTE_BASE+(i*4));
714 readl(intel_i830_private.registers+I810_PTE_BASE+((i-1)*4));
716 agp_bridge->driver->tlb_flush(mem);
720 static struct agp_memory *intel_i830_alloc_by_type(size_t pg_count,int type)
722 if (type == AGP_PHYS_MEMORY)
723 return alloc_agpphysmem_i8xx(pg_count, type);
724 /* always return NULL for other allocation types for now */
728 static int intel_i915_configure(void)
730 struct aper_size_info_fixed *current_size;
735 current_size = A_SIZE_FIX(agp_bridge->current_size);
737 pci_read_config_dword(intel_i830_private.i830_dev, I915_GMADDR, &temp);
739 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
741 pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl);
742 gmch_ctrl |= I830_GMCH_ENABLED;
743 pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl);
745 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_i830_private.registers+I810_PGETBL_CTL);
746 readl(intel_i830_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
748 if (agp_bridge->driver->needs_scratch_page) {
749 for (i = intel_i830_private.gtt_entries; i < current_size->num_entries; i++) {
750 writel(agp_bridge->scratch_page, intel_i830_private.gtt+i);
751 readl(intel_i830_private.gtt+i); /* PCI Posting. */
755 global_cache_flush();
759 static void intel_i915_cleanup(void)
761 iounmap(intel_i830_private.gtt);
762 iounmap(intel_i830_private.registers);
765 static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start,
773 if (mem->page_count == 0)
776 temp = agp_bridge->current_size;
777 num_entries = A_SIZE_FIX(temp)->num_entries;
779 if (pg_start < intel_i830_private.gtt_entries) {
780 printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_i830_private.gtt_entries == 0x%.8x\n",
781 pg_start,intel_i830_private.gtt_entries);
783 printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n");
787 if ((pg_start + mem->page_count) > num_entries)
790 /* The i915 can't check the GTT for entries since its read only,
791 * depend on the caller to make the correct offset decisions.
794 if (type != mem->type)
797 mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
799 if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY &&
800 mask_type != INTEL_AGP_CACHED_MEMORY)
803 if (!mem->is_flushed)
804 global_cache_flush();
806 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
807 writel(agp_bridge->driver->mask_memory(agp_bridge,
808 mem->memory[i], mask_type), intel_i830_private.gtt+j);
811 readl(intel_i830_private.gtt+j-1);
812 agp_bridge->driver->tlb_flush(mem);
821 static int intel_i915_remove_entries(struct agp_memory *mem,off_t pg_start,
826 if (mem->page_count == 0)
829 if (pg_start < intel_i830_private.gtt_entries) {
830 printk (KERN_INFO PFX "Trying to disable local/stolen memory\n");
834 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
835 writel(agp_bridge->scratch_page, intel_i830_private.gtt+i);
837 readl(intel_i830_private.gtt+i-1);
839 agp_bridge->driver->tlb_flush(mem);
843 /* Return the aperture size by just checking the resource length. The effect
844 * described in the spec of the MSAC registers is just changing of the
847 static int intel_i9xx_fetch_size(void)
849 int num_sizes = ARRAY_SIZE(intel_i830_sizes);
850 int aper_size; /* size in megabytes */
853 aper_size = pci_resource_len(intel_i830_private.i830_dev, 2) / MB(1);
855 for (i = 0; i < num_sizes; i++) {
856 if (aper_size == intel_i830_sizes[i].size) {
857 agp_bridge->current_size = intel_i830_sizes + i;
858 agp_bridge->previous_size = agp_bridge->current_size;
866 /* The intel i915 automatically initializes the agp aperture during POST.
867 * Use the memory already set aside for in the GTT.
869 static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge)
872 struct aper_size_info_fixed *size;
876 size = agp_bridge->current_size;
877 page_order = size->page_order;
878 num_entries = size->num_entries;
879 agp_bridge->gatt_table_real = NULL;
881 pci_read_config_dword(intel_i830_private.i830_dev, I915_MMADDR, &temp);
882 pci_read_config_dword(intel_i830_private.i830_dev, I915_PTEADDR,&temp2);
884 intel_i830_private.gtt = ioremap(temp2, 256 * 1024);
885 if (!intel_i830_private.gtt)
890 intel_i830_private.registers = ioremap(temp,128 * 4096);
891 if (!intel_i830_private.registers)
894 temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000;
895 global_cache_flush(); /* FIXME: ? */
897 /* we have to call this as early as possible after the MMIO base address is known */
898 intel_i830_init_gtt_entries();
900 agp_bridge->gatt_table = NULL;
902 agp_bridge->gatt_bus_addr = temp;
908 * The i965 supports 36-bit physical addresses, but to keep
909 * the format of the GTT the same, the bits that don't fit
910 * in a 32-bit word are shifted down to bits 4..7.
912 * Gcc is smart enough to notice that "(addr >> 28) & 0xf0"
913 * is always zero on 32-bit architectures, so no need to make
916 static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge,
917 unsigned long addr, int type)
919 /* Shift high bits down */
920 addr |= (addr >> 28) & 0xf0;
922 /* Type checking must be done elsewhere */
923 return addr | bridge->driver->masks[type].mask;
926 /* The intel i965 automatically initializes the agp aperture during POST.
927 * Use the memory already set aside for in the GTT.
929 static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge)
932 struct aper_size_info_fixed *size;
936 size = agp_bridge->current_size;
937 page_order = size->page_order;
938 num_entries = size->num_entries;
939 agp_bridge->gatt_table_real = NULL;
941 pci_read_config_dword(intel_i830_private.i830_dev, I915_MMADDR, &temp);
944 intel_i830_private.gtt = ioremap((temp + (512 * 1024)) , 512 * 1024);
946 if (!intel_i830_private.gtt)
950 intel_i830_private.registers = ioremap(temp,128 * 4096);
951 if (!intel_i830_private.registers)
954 temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000;
955 global_cache_flush(); /* FIXME: ? */
957 /* we have to call this as early as possible after the MMIO base address is known */
958 intel_i830_init_gtt_entries();
960 agp_bridge->gatt_table = NULL;
962 agp_bridge->gatt_bus_addr = temp;
968 static int intel_fetch_size(void)
972 struct aper_size_info_16 *values;
974 pci_read_config_word(agp_bridge->dev, INTEL_APSIZE, &temp);
975 values = A_SIZE_16(agp_bridge->driver->aperture_sizes);
977 for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) {
978 if (temp == values[i].size_value) {
979 agp_bridge->previous_size = agp_bridge->current_size = (void *) (values + i);
980 agp_bridge->aperture_size_idx = i;
981 return values[i].size;
988 static int __intel_8xx_fetch_size(u8 temp)
991 struct aper_size_info_8 *values;
993 values = A_SIZE_8(agp_bridge->driver->aperture_sizes);
995 for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) {
996 if (temp == values[i].size_value) {
997 agp_bridge->previous_size =
998 agp_bridge->current_size = (void *) (values + i);
999 agp_bridge->aperture_size_idx = i;
1000 return values[i].size;
1006 static int intel_8xx_fetch_size(void)
1010 pci_read_config_byte(agp_bridge->dev, INTEL_APSIZE, &temp);
1011 return __intel_8xx_fetch_size(temp);
1014 static int intel_815_fetch_size(void)
1018 /* Intel 815 chipsets have a _weird_ APSIZE register with only
1019 * one non-reserved bit, so mask the others out ... */
1020 pci_read_config_byte(agp_bridge->dev, INTEL_APSIZE, &temp);
1023 return __intel_8xx_fetch_size(temp);
1026 static void intel_tlbflush(struct agp_memory *mem)
1028 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2200);
1029 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2280);
1033 static void intel_8xx_tlbflush(struct agp_memory *mem)
1036 pci_read_config_dword(agp_bridge->dev, INTEL_AGPCTRL, &temp);
1037 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, temp & ~(1 << 7));
1038 pci_read_config_dword(agp_bridge->dev, INTEL_AGPCTRL, &temp);
1039 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, temp | (1 << 7));
1043 static void intel_cleanup(void)
1046 struct aper_size_info_16 *previous_size;
1048 previous_size = A_SIZE_16(agp_bridge->previous_size);
1049 pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp);
1050 pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp & ~(1 << 9));
1051 pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, previous_size->size_value);
1055 static void intel_8xx_cleanup(void)
1058 struct aper_size_info_8 *previous_size;
1060 previous_size = A_SIZE_8(agp_bridge->previous_size);
1061 pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp);
1062 pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp & ~(1 << 9));
1063 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, previous_size->size_value);
1067 static int intel_configure(void)
1071 struct aper_size_info_16 *current_size;
1073 current_size = A_SIZE_16(agp_bridge->current_size);
1076 pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1078 /* address to map to */
1079 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1080 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1082 /* attbase - aperture base */
1083 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1086 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2280);
1089 pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp2);
1090 pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG,
1091 (temp2 & ~(1 << 10)) | (1 << 9));
1092 /* clear any possible error conditions */
1093 pci_write_config_byte(agp_bridge->dev, INTEL_ERRSTS + 1, 7);
1097 static int intel_815_configure(void)
1101 struct aper_size_info_8 *current_size;
1103 /* attbase - aperture base */
1104 /* the Intel 815 chipset spec. says that bits 29-31 in the
1105 * ATTBASE register are reserved -> try not to write them */
1106 if (agp_bridge->gatt_bus_addr & INTEL_815_ATTBASE_MASK) {
1107 printk (KERN_EMERG PFX "gatt bus addr too high");
1111 current_size = A_SIZE_8(agp_bridge->current_size);
1114 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE,
1115 current_size->size_value);
1117 /* address to map to */
1118 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1119 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1121 pci_read_config_dword(agp_bridge->dev, INTEL_ATTBASE, &addr);
1122 addr &= INTEL_815_ATTBASE_MASK;
1123 addr |= agp_bridge->gatt_bus_addr;
1124 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, addr);
1127 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1130 pci_read_config_byte(agp_bridge->dev, INTEL_815_APCONT, &temp2);
1131 pci_write_config_byte(agp_bridge->dev, INTEL_815_APCONT, temp2 | (1 << 1));
1133 /* clear any possible error conditions */
1134 /* Oddness : this chipset seems to have no ERRSTS register ! */
1138 static void intel_820_tlbflush(struct agp_memory *mem)
1143 static void intel_820_cleanup(void)
1146 struct aper_size_info_8 *previous_size;
1148 previous_size = A_SIZE_8(agp_bridge->previous_size);
1149 pci_read_config_byte(agp_bridge->dev, INTEL_I820_RDCR, &temp);
1150 pci_write_config_byte(agp_bridge->dev, INTEL_I820_RDCR,
1152 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE,
1153 previous_size->size_value);
1157 static int intel_820_configure(void)
1161 struct aper_size_info_8 *current_size;
1163 current_size = A_SIZE_8(agp_bridge->current_size);
1166 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1168 /* address to map to */
1169 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1170 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1172 /* attbase - aperture base */
1173 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1176 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1178 /* global enable aperture access */
1179 /* This flag is not accessed through MCHCFG register as in */
1181 pci_read_config_byte(agp_bridge->dev, INTEL_I820_RDCR, &temp2);
1182 pci_write_config_byte(agp_bridge->dev, INTEL_I820_RDCR, temp2 | (1 << 1));
1183 /* clear any possible AGP-related error conditions */
1184 pci_write_config_word(agp_bridge->dev, INTEL_I820_ERRSTS, 0x001c);
1188 static int intel_840_configure(void)
1192 struct aper_size_info_8 *current_size;
1194 current_size = A_SIZE_8(agp_bridge->current_size);
1197 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1199 /* address to map to */
1200 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1201 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1203 /* attbase - aperture base */
1204 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1207 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1210 pci_read_config_word(agp_bridge->dev, INTEL_I840_MCHCFG, &temp2);
1211 pci_write_config_word(agp_bridge->dev, INTEL_I840_MCHCFG, temp2 | (1 << 9));
1212 /* clear any possible error conditions */
1213 pci_write_config_word(agp_bridge->dev, INTEL_I840_ERRSTS, 0xc000);
1217 static int intel_845_configure(void)
1221 struct aper_size_info_8 *current_size;
1223 current_size = A_SIZE_8(agp_bridge->current_size);
1226 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1228 if (agp_bridge->apbase_config != 0) {
1229 pci_write_config_dword(agp_bridge->dev, AGP_APBASE,
1230 agp_bridge->apbase_config);
1232 /* address to map to */
1233 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1234 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1235 agp_bridge->apbase_config = temp;
1238 /* attbase - aperture base */
1239 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1242 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1245 pci_read_config_byte(agp_bridge->dev, INTEL_I845_AGPM, &temp2);
1246 pci_write_config_byte(agp_bridge->dev, INTEL_I845_AGPM, temp2 | (1 << 1));
1247 /* clear any possible error conditions */
1248 pci_write_config_word(agp_bridge->dev, INTEL_I845_ERRSTS, 0x001c);
1252 static int intel_850_configure(void)
1256 struct aper_size_info_8 *current_size;
1258 current_size = A_SIZE_8(agp_bridge->current_size);
1261 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1263 /* address to map to */
1264 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1265 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1267 /* attbase - aperture base */
1268 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1271 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1274 pci_read_config_word(agp_bridge->dev, INTEL_I850_MCHCFG, &temp2);
1275 pci_write_config_word(agp_bridge->dev, INTEL_I850_MCHCFG, temp2 | (1 << 9));
1276 /* clear any possible AGP-related error conditions */
1277 pci_write_config_word(agp_bridge->dev, INTEL_I850_ERRSTS, 0x001c);
1281 static int intel_860_configure(void)
1285 struct aper_size_info_8 *current_size;
1287 current_size = A_SIZE_8(agp_bridge->current_size);
1290 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1292 /* address to map to */
1293 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1294 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1296 /* attbase - aperture base */
1297 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1300 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1303 pci_read_config_word(agp_bridge->dev, INTEL_I860_MCHCFG, &temp2);
1304 pci_write_config_word(agp_bridge->dev, INTEL_I860_MCHCFG, temp2 | (1 << 9));
1305 /* clear any possible AGP-related error conditions */
1306 pci_write_config_word(agp_bridge->dev, INTEL_I860_ERRSTS, 0xf700);
1310 static int intel_830mp_configure(void)
1314 struct aper_size_info_8 *current_size;
1316 current_size = A_SIZE_8(agp_bridge->current_size);
1319 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1321 /* address to map to */
1322 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1323 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1325 /* attbase - aperture base */
1326 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1329 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1332 pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp2);
1333 pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp2 | (1 << 9));
1334 /* clear any possible AGP-related error conditions */
1335 pci_write_config_word(agp_bridge->dev, INTEL_I830_ERRSTS, 0x1c);
1339 static int intel_7505_configure(void)
1343 struct aper_size_info_8 *current_size;
1345 current_size = A_SIZE_8(agp_bridge->current_size);
1348 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1350 /* address to map to */
1351 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1352 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1354 /* attbase - aperture base */
1355 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1358 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1361 pci_read_config_word(agp_bridge->dev, INTEL_I7505_MCHCFG, &temp2);
1362 pci_write_config_word(agp_bridge->dev, INTEL_I7505_MCHCFG, temp2 | (1 << 9));
1367 /* Setup function */
1368 static const struct gatt_mask intel_generic_masks[] =
1370 {.mask = 0x00000017, .type = 0}
1373 static const struct aper_size_info_8 intel_815_sizes[2] =
1379 static const struct aper_size_info_8 intel_8xx_sizes[7] =
1382 {128, 32768, 5, 32},
1390 static const struct aper_size_info_16 intel_generic_sizes[7] =
1393 {128, 32768, 5, 32},
1401 static const struct aper_size_info_8 intel_830mp_sizes[4] =
1404 {128, 32768, 5, 32},
1409 static const struct agp_bridge_driver intel_generic_driver = {
1410 .owner = THIS_MODULE,
1411 .aperture_sizes = intel_generic_sizes,
1412 .size_type = U16_APER_SIZE,
1413 .num_aperture_sizes = 7,
1414 .configure = intel_configure,
1415 .fetch_size = intel_fetch_size,
1416 .cleanup = intel_cleanup,
1417 .tlb_flush = intel_tlbflush,
1418 .mask_memory = agp_generic_mask_memory,
1419 .masks = intel_generic_masks,
1420 .agp_enable = agp_generic_enable,
1421 .cache_flush = global_cache_flush,
1422 .create_gatt_table = agp_generic_create_gatt_table,
1423 .free_gatt_table = agp_generic_free_gatt_table,
1424 .insert_memory = agp_generic_insert_memory,
1425 .remove_memory = agp_generic_remove_memory,
1426 .alloc_by_type = agp_generic_alloc_by_type,
1427 .free_by_type = agp_generic_free_by_type,
1428 .agp_alloc_page = agp_generic_alloc_page,
1429 .agp_destroy_page = agp_generic_destroy_page,
1430 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1433 static const struct agp_bridge_driver intel_810_driver = {
1434 .owner = THIS_MODULE,
1435 .aperture_sizes = intel_i810_sizes,
1436 .size_type = FIXED_APER_SIZE,
1437 .num_aperture_sizes = 2,
1438 .needs_scratch_page = TRUE,
1439 .configure = intel_i810_configure,
1440 .fetch_size = intel_i810_fetch_size,
1441 .cleanup = intel_i810_cleanup,
1442 .tlb_flush = intel_i810_tlbflush,
1443 .mask_memory = intel_i810_mask_memory,
1444 .masks = intel_i810_masks,
1445 .agp_enable = intel_i810_agp_enable,
1446 .cache_flush = global_cache_flush,
1447 .create_gatt_table = agp_generic_create_gatt_table,
1448 .free_gatt_table = agp_generic_free_gatt_table,
1449 .insert_memory = intel_i810_insert_entries,
1450 .remove_memory = intel_i810_remove_entries,
1451 .alloc_by_type = intel_i810_alloc_by_type,
1452 .free_by_type = intel_i810_free_by_type,
1453 .agp_alloc_page = agp_generic_alloc_page,
1454 .agp_destroy_page = agp_generic_destroy_page,
1455 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1458 static const struct agp_bridge_driver intel_815_driver = {
1459 .owner = THIS_MODULE,
1460 .aperture_sizes = intel_815_sizes,
1461 .size_type = U8_APER_SIZE,
1462 .num_aperture_sizes = 2,
1463 .configure = intel_815_configure,
1464 .fetch_size = intel_815_fetch_size,
1465 .cleanup = intel_8xx_cleanup,
1466 .tlb_flush = intel_8xx_tlbflush,
1467 .mask_memory = agp_generic_mask_memory,
1468 .masks = intel_generic_masks,
1469 .agp_enable = agp_generic_enable,
1470 .cache_flush = global_cache_flush,
1471 .create_gatt_table = agp_generic_create_gatt_table,
1472 .free_gatt_table = agp_generic_free_gatt_table,
1473 .insert_memory = agp_generic_insert_memory,
1474 .remove_memory = agp_generic_remove_memory,
1475 .alloc_by_type = agp_generic_alloc_by_type,
1476 .free_by_type = agp_generic_free_by_type,
1477 .agp_alloc_page = agp_generic_alloc_page,
1478 .agp_destroy_page = agp_generic_destroy_page,
1479 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1482 static const struct agp_bridge_driver intel_830_driver = {
1483 .owner = THIS_MODULE,
1484 .aperture_sizes = intel_i830_sizes,
1485 .size_type = FIXED_APER_SIZE,
1486 .num_aperture_sizes = 4,
1487 .needs_scratch_page = TRUE,
1488 .configure = intel_i830_configure,
1489 .fetch_size = intel_i830_fetch_size,
1490 .cleanup = intel_i830_cleanup,
1491 .tlb_flush = intel_i810_tlbflush,
1492 .mask_memory = intel_i810_mask_memory,
1493 .masks = intel_i810_masks,
1494 .agp_enable = intel_i810_agp_enable,
1495 .cache_flush = global_cache_flush,
1496 .create_gatt_table = intel_i830_create_gatt_table,
1497 .free_gatt_table = intel_i830_free_gatt_table,
1498 .insert_memory = intel_i830_insert_entries,
1499 .remove_memory = intel_i830_remove_entries,
1500 .alloc_by_type = intel_i830_alloc_by_type,
1501 .free_by_type = intel_i810_free_by_type,
1502 .agp_alloc_page = agp_generic_alloc_page,
1503 .agp_destroy_page = agp_generic_destroy_page,
1504 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
1507 static const struct agp_bridge_driver intel_820_driver = {
1508 .owner = THIS_MODULE,
1509 .aperture_sizes = intel_8xx_sizes,
1510 .size_type = U8_APER_SIZE,
1511 .num_aperture_sizes = 7,
1512 .configure = intel_820_configure,
1513 .fetch_size = intel_8xx_fetch_size,
1514 .cleanup = intel_820_cleanup,
1515 .tlb_flush = intel_820_tlbflush,
1516 .mask_memory = agp_generic_mask_memory,
1517 .masks = intel_generic_masks,
1518 .agp_enable = agp_generic_enable,
1519 .cache_flush = global_cache_flush,
1520 .create_gatt_table = agp_generic_create_gatt_table,
1521 .free_gatt_table = agp_generic_free_gatt_table,
1522 .insert_memory = agp_generic_insert_memory,
1523 .remove_memory = agp_generic_remove_memory,
1524 .alloc_by_type = agp_generic_alloc_by_type,
1525 .free_by_type = agp_generic_free_by_type,
1526 .agp_alloc_page = agp_generic_alloc_page,
1527 .agp_destroy_page = agp_generic_destroy_page,
1528 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1531 static const struct agp_bridge_driver intel_830mp_driver = {
1532 .owner = THIS_MODULE,
1533 .aperture_sizes = intel_830mp_sizes,
1534 .size_type = U8_APER_SIZE,
1535 .num_aperture_sizes = 4,
1536 .configure = intel_830mp_configure,
1537 .fetch_size = intel_8xx_fetch_size,
1538 .cleanup = intel_8xx_cleanup,
1539 .tlb_flush = intel_8xx_tlbflush,
1540 .mask_memory = agp_generic_mask_memory,
1541 .masks = intel_generic_masks,
1542 .agp_enable = agp_generic_enable,
1543 .cache_flush = global_cache_flush,
1544 .create_gatt_table = agp_generic_create_gatt_table,
1545 .free_gatt_table = agp_generic_free_gatt_table,
1546 .insert_memory = agp_generic_insert_memory,
1547 .remove_memory = agp_generic_remove_memory,
1548 .alloc_by_type = agp_generic_alloc_by_type,
1549 .free_by_type = agp_generic_free_by_type,
1550 .agp_alloc_page = agp_generic_alloc_page,
1551 .agp_destroy_page = agp_generic_destroy_page,
1552 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1555 static const struct agp_bridge_driver intel_840_driver = {
1556 .owner = THIS_MODULE,
1557 .aperture_sizes = intel_8xx_sizes,
1558 .size_type = U8_APER_SIZE,
1559 .num_aperture_sizes = 7,
1560 .configure = intel_840_configure,
1561 .fetch_size = intel_8xx_fetch_size,
1562 .cleanup = intel_8xx_cleanup,
1563 .tlb_flush = intel_8xx_tlbflush,
1564 .mask_memory = agp_generic_mask_memory,
1565 .masks = intel_generic_masks,
1566 .agp_enable = agp_generic_enable,
1567 .cache_flush = global_cache_flush,
1568 .create_gatt_table = agp_generic_create_gatt_table,
1569 .free_gatt_table = agp_generic_free_gatt_table,
1570 .insert_memory = agp_generic_insert_memory,
1571 .remove_memory = agp_generic_remove_memory,
1572 .alloc_by_type = agp_generic_alloc_by_type,
1573 .free_by_type = agp_generic_free_by_type,
1574 .agp_alloc_page = agp_generic_alloc_page,
1575 .agp_destroy_page = agp_generic_destroy_page,
1576 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1579 static const struct agp_bridge_driver intel_845_driver = {
1580 .owner = THIS_MODULE,
1581 .aperture_sizes = intel_8xx_sizes,
1582 .size_type = U8_APER_SIZE,
1583 .num_aperture_sizes = 7,
1584 .configure = intel_845_configure,
1585 .fetch_size = intel_8xx_fetch_size,
1586 .cleanup = intel_8xx_cleanup,
1587 .tlb_flush = intel_8xx_tlbflush,
1588 .mask_memory = agp_generic_mask_memory,
1589 .masks = intel_generic_masks,
1590 .agp_enable = agp_generic_enable,
1591 .cache_flush = global_cache_flush,
1592 .create_gatt_table = agp_generic_create_gatt_table,
1593 .free_gatt_table = agp_generic_free_gatt_table,
1594 .insert_memory = agp_generic_insert_memory,
1595 .remove_memory = agp_generic_remove_memory,
1596 .alloc_by_type = agp_generic_alloc_by_type,
1597 .free_by_type = agp_generic_free_by_type,
1598 .agp_alloc_page = agp_generic_alloc_page,
1599 .agp_destroy_page = agp_generic_destroy_page,
1600 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1603 static const struct agp_bridge_driver intel_850_driver = {
1604 .owner = THIS_MODULE,
1605 .aperture_sizes = intel_8xx_sizes,
1606 .size_type = U8_APER_SIZE,
1607 .num_aperture_sizes = 7,
1608 .configure = intel_850_configure,
1609 .fetch_size = intel_8xx_fetch_size,
1610 .cleanup = intel_8xx_cleanup,
1611 .tlb_flush = intel_8xx_tlbflush,
1612 .mask_memory = agp_generic_mask_memory,
1613 .masks = intel_generic_masks,
1614 .agp_enable = agp_generic_enable,
1615 .cache_flush = global_cache_flush,
1616 .create_gatt_table = agp_generic_create_gatt_table,
1617 .free_gatt_table = agp_generic_free_gatt_table,
1618 .insert_memory = agp_generic_insert_memory,
1619 .remove_memory = agp_generic_remove_memory,
1620 .alloc_by_type = agp_generic_alloc_by_type,
1621 .free_by_type = agp_generic_free_by_type,
1622 .agp_alloc_page = agp_generic_alloc_page,
1623 .agp_destroy_page = agp_generic_destroy_page,
1624 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1627 static const struct agp_bridge_driver intel_860_driver = {
1628 .owner = THIS_MODULE,
1629 .aperture_sizes = intel_8xx_sizes,
1630 .size_type = U8_APER_SIZE,
1631 .num_aperture_sizes = 7,
1632 .configure = intel_860_configure,
1633 .fetch_size = intel_8xx_fetch_size,
1634 .cleanup = intel_8xx_cleanup,
1635 .tlb_flush = intel_8xx_tlbflush,
1636 .mask_memory = agp_generic_mask_memory,
1637 .masks = intel_generic_masks,
1638 .agp_enable = agp_generic_enable,
1639 .cache_flush = global_cache_flush,
1640 .create_gatt_table = agp_generic_create_gatt_table,
1641 .free_gatt_table = agp_generic_free_gatt_table,
1642 .insert_memory = agp_generic_insert_memory,
1643 .remove_memory = agp_generic_remove_memory,
1644 .alloc_by_type = agp_generic_alloc_by_type,
1645 .free_by_type = agp_generic_free_by_type,
1646 .agp_alloc_page = agp_generic_alloc_page,
1647 .agp_destroy_page = agp_generic_destroy_page,
1648 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1651 static const struct agp_bridge_driver intel_915_driver = {
1652 .owner = THIS_MODULE,
1653 .aperture_sizes = intel_i830_sizes,
1654 .size_type = FIXED_APER_SIZE,
1655 .num_aperture_sizes = 4,
1656 .needs_scratch_page = TRUE,
1657 .configure = intel_i915_configure,
1658 .fetch_size = intel_i9xx_fetch_size,
1659 .cleanup = intel_i915_cleanup,
1660 .tlb_flush = intel_i810_tlbflush,
1661 .mask_memory = intel_i810_mask_memory,
1662 .masks = intel_i810_masks,
1663 .agp_enable = intel_i810_agp_enable,
1664 .cache_flush = global_cache_flush,
1665 .create_gatt_table = intel_i915_create_gatt_table,
1666 .free_gatt_table = intel_i830_free_gatt_table,
1667 .insert_memory = intel_i915_insert_entries,
1668 .remove_memory = intel_i915_remove_entries,
1669 .alloc_by_type = intel_i830_alloc_by_type,
1670 .free_by_type = intel_i810_free_by_type,
1671 .agp_alloc_page = agp_generic_alloc_page,
1672 .agp_destroy_page = agp_generic_destroy_page,
1673 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
1676 static const struct agp_bridge_driver intel_i965_driver = {
1677 .owner = THIS_MODULE,
1678 .aperture_sizes = intel_i830_sizes,
1679 .size_type = FIXED_APER_SIZE,
1680 .num_aperture_sizes = 4,
1681 .needs_scratch_page = TRUE,
1682 .configure = intel_i915_configure,
1683 .fetch_size = intel_i9xx_fetch_size,
1684 .cleanup = intel_i915_cleanup,
1685 .tlb_flush = intel_i810_tlbflush,
1686 .mask_memory = intel_i965_mask_memory,
1687 .masks = intel_i810_masks,
1688 .agp_enable = intel_i810_agp_enable,
1689 .cache_flush = global_cache_flush,
1690 .create_gatt_table = intel_i965_create_gatt_table,
1691 .free_gatt_table = intel_i830_free_gatt_table,
1692 .insert_memory = intel_i915_insert_entries,
1693 .remove_memory = intel_i915_remove_entries,
1694 .alloc_by_type = intel_i830_alloc_by_type,
1695 .free_by_type = intel_i810_free_by_type,
1696 .agp_alloc_page = agp_generic_alloc_page,
1697 .agp_destroy_page = agp_generic_destroy_page,
1698 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
1701 static const struct agp_bridge_driver intel_7505_driver = {
1702 .owner = THIS_MODULE,
1703 .aperture_sizes = intel_8xx_sizes,
1704 .size_type = U8_APER_SIZE,
1705 .num_aperture_sizes = 7,
1706 .configure = intel_7505_configure,
1707 .fetch_size = intel_8xx_fetch_size,
1708 .cleanup = intel_8xx_cleanup,
1709 .tlb_flush = intel_8xx_tlbflush,
1710 .mask_memory = agp_generic_mask_memory,
1711 .masks = intel_generic_masks,
1712 .agp_enable = agp_generic_enable,
1713 .cache_flush = global_cache_flush,
1714 .create_gatt_table = agp_generic_create_gatt_table,
1715 .free_gatt_table = agp_generic_free_gatt_table,
1716 .insert_memory = agp_generic_insert_memory,
1717 .remove_memory = agp_generic_remove_memory,
1718 .alloc_by_type = agp_generic_alloc_by_type,
1719 .free_by_type = agp_generic_free_by_type,
1720 .agp_alloc_page = agp_generic_alloc_page,
1721 .agp_destroy_page = agp_generic_destroy_page,
1722 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1725 static int find_i810(u16 device)
1727 struct pci_dev *i810_dev;
1729 i810_dev = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL);
1732 intel_i810_private.i810_dev = i810_dev;
1736 static int find_i830(u16 device)
1738 struct pci_dev *i830_dev;
1740 i830_dev = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL);
1741 if (i830_dev && PCI_FUNC(i830_dev->devfn) != 0) {
1742 i830_dev = pci_get_device(PCI_VENDOR_ID_INTEL,
1749 intel_i830_private.i830_dev = i830_dev;
1753 static int __devinit agp_intel_probe(struct pci_dev *pdev,
1754 const struct pci_device_id *ent)
1756 struct agp_bridge_data *bridge;
1757 char *name = "(unknown)";
1761 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
1763 bridge = agp_alloc_bridge();
1767 switch (pdev->device) {
1768 case PCI_DEVICE_ID_INTEL_82443LX_0:
1769 bridge->driver = &intel_generic_driver;
1772 case PCI_DEVICE_ID_INTEL_82443BX_0:
1773 bridge->driver = &intel_generic_driver;
1776 case PCI_DEVICE_ID_INTEL_82443GX_0:
1777 bridge->driver = &intel_generic_driver;
1780 case PCI_DEVICE_ID_INTEL_82810_MC1:
1782 if (!find_i810(PCI_DEVICE_ID_INTEL_82810_IG1))
1784 bridge->driver = &intel_810_driver;
1786 case PCI_DEVICE_ID_INTEL_82810_MC3:
1787 name = "i810 DC100";
1788 if (!find_i810(PCI_DEVICE_ID_INTEL_82810_IG3))
1790 bridge->driver = &intel_810_driver;
1792 case PCI_DEVICE_ID_INTEL_82810E_MC:
1794 if (!find_i810(PCI_DEVICE_ID_INTEL_82810E_IG))
1796 bridge->driver = &intel_810_driver;
1798 case PCI_DEVICE_ID_INTEL_82815_MC:
1800 * The i815 can operate either as an i810 style
1801 * integrated device, or as an AGP4X motherboard.
1803 if (find_i810(PCI_DEVICE_ID_INTEL_82815_CGC))
1804 bridge->driver = &intel_810_driver;
1806 bridge->driver = &intel_815_driver;
1809 case PCI_DEVICE_ID_INTEL_82820_HB:
1810 case PCI_DEVICE_ID_INTEL_82820_UP_HB:
1811 bridge->driver = &intel_820_driver;
1814 case PCI_DEVICE_ID_INTEL_82830_HB:
1815 if (find_i830(PCI_DEVICE_ID_INTEL_82830_CGC))
1816 bridge->driver = &intel_830_driver;
1818 bridge->driver = &intel_830mp_driver;
1821 case PCI_DEVICE_ID_INTEL_82840_HB:
1822 bridge->driver = &intel_840_driver;
1825 case PCI_DEVICE_ID_INTEL_82845_HB:
1826 bridge->driver = &intel_845_driver;
1829 case PCI_DEVICE_ID_INTEL_82845G_HB:
1830 if (find_i830(PCI_DEVICE_ID_INTEL_82845G_IG))
1831 bridge->driver = &intel_830_driver;
1833 bridge->driver = &intel_845_driver;
1836 case PCI_DEVICE_ID_INTEL_82850_HB:
1837 bridge->driver = &intel_850_driver;
1840 case PCI_DEVICE_ID_INTEL_82855PM_HB:
1841 bridge->driver = &intel_845_driver;
1844 case PCI_DEVICE_ID_INTEL_82855GM_HB:
1845 if (find_i830(PCI_DEVICE_ID_INTEL_82855GM_IG)) {
1846 bridge->driver = &intel_830_driver;
1849 bridge->driver = &intel_845_driver;
1853 case PCI_DEVICE_ID_INTEL_82860_HB:
1854 bridge->driver = &intel_860_driver;
1857 case PCI_DEVICE_ID_INTEL_82865_HB:
1858 if (find_i830(PCI_DEVICE_ID_INTEL_82865_IG))
1859 bridge->driver = &intel_830_driver;
1861 bridge->driver = &intel_845_driver;
1864 case PCI_DEVICE_ID_INTEL_82875_HB:
1865 bridge->driver = &intel_845_driver;
1868 case PCI_DEVICE_ID_INTEL_82915G_HB:
1869 if (find_i830(PCI_DEVICE_ID_INTEL_82915G_IG))
1870 bridge->driver = &intel_915_driver;
1872 bridge->driver = &intel_845_driver;
1875 case PCI_DEVICE_ID_INTEL_82915GM_HB:
1876 if (find_i830(PCI_DEVICE_ID_INTEL_82915GM_IG))
1877 bridge->driver = &intel_915_driver;
1879 bridge->driver = &intel_845_driver;
1882 case PCI_DEVICE_ID_INTEL_82945G_HB:
1883 if (find_i830(PCI_DEVICE_ID_INTEL_82945G_IG))
1884 bridge->driver = &intel_915_driver;
1886 bridge->driver = &intel_845_driver;
1889 case PCI_DEVICE_ID_INTEL_82945GM_HB:
1890 if (find_i830(PCI_DEVICE_ID_INTEL_82945GM_IG))
1891 bridge->driver = &intel_915_driver;
1893 bridge->driver = &intel_845_driver;
1896 case PCI_DEVICE_ID_INTEL_82946GZ_HB:
1897 if (find_i830(PCI_DEVICE_ID_INTEL_82946GZ_IG))
1898 bridge->driver = &intel_i965_driver;
1900 bridge->driver = &intel_845_driver;
1903 case PCI_DEVICE_ID_INTEL_82965G_1_HB:
1904 if (find_i830(PCI_DEVICE_ID_INTEL_82965G_1_IG))
1905 bridge->driver = &intel_i965_driver;
1907 bridge->driver = &intel_845_driver;
1910 case PCI_DEVICE_ID_INTEL_82965Q_HB:
1911 if (find_i830(PCI_DEVICE_ID_INTEL_82965Q_IG))
1912 bridge->driver = &intel_i965_driver;
1914 bridge->driver = &intel_845_driver;
1917 case PCI_DEVICE_ID_INTEL_82965G_HB:
1918 if (find_i830(PCI_DEVICE_ID_INTEL_82965G_IG))
1919 bridge->driver = &intel_i965_driver;
1921 bridge->driver = &intel_845_driver;
1924 case PCI_DEVICE_ID_INTEL_82965GM_HB:
1925 if (find_i830(PCI_DEVICE_ID_INTEL_82965GM_IG))
1926 bridge->driver = &intel_i965_driver;
1928 bridge->driver = &intel_845_driver;
1931 case PCI_DEVICE_ID_INTEL_7505_0:
1932 bridge->driver = &intel_7505_driver;
1935 case PCI_DEVICE_ID_INTEL_7205_0:
1936 bridge->driver = &intel_7505_driver;
1941 printk(KERN_WARNING PFX "Unsupported Intel chipset (device id: %04x)\n",
1943 agp_put_bridge(bridge);
1948 bridge->capndx = cap_ptr;
1950 if (bridge->driver == &intel_810_driver)
1951 bridge->dev_private_data = &intel_i810_private;
1952 else if (bridge->driver == &intel_830_driver)
1953 bridge->dev_private_data = &intel_i830_private;
1955 printk(KERN_INFO PFX "Detected an Intel %s Chipset.\n", name);
1958 * The following fixes the case where the BIOS has "forgotten" to
1959 * provide an address range for the GART.
1960 * 20030610 - hamish@zot.org
1962 r = &pdev->resource[0];
1963 if (!r->start && r->end) {
1964 if (pci_assign_resource(pdev, 0)) {
1965 printk(KERN_ERR PFX "could not assign resource 0\n");
1966 agp_put_bridge(bridge);
1972 * If the device has not been properly setup, the following will catch
1973 * the problem and should stop the system from crashing.
1974 * 20030610 - hamish@zot.org
1976 if (pci_enable_device(pdev)) {
1977 printk(KERN_ERR PFX "Unable to Enable PCI device\n");
1978 agp_put_bridge(bridge);
1982 /* Fill in the mode register */
1984 pci_read_config_dword(pdev,
1985 bridge->capndx+PCI_AGP_STATUS,
1989 pci_set_drvdata(pdev, bridge);
1990 return agp_add_bridge(bridge);
1993 printk(KERN_ERR PFX "Detected an Intel %s chipset, "
1994 "but could not find the secondary device.\n", name);
1995 agp_put_bridge(bridge);
1999 static void __devexit agp_intel_remove(struct pci_dev *pdev)
2001 struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
2003 agp_remove_bridge(bridge);
2005 if (intel_i810_private.i810_dev)
2006 pci_dev_put(intel_i810_private.i810_dev);
2007 if (intel_i830_private.i830_dev)
2008 pci_dev_put(intel_i830_private.i830_dev);
2010 agp_put_bridge(bridge);
2014 static int agp_intel_resume(struct pci_dev *pdev)
2016 struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
2018 pci_restore_state(pdev);
2020 /* We should restore our graphics device's config space,
2021 * as host bridge (00:00) resumes before graphics device (02:00),
2022 * then our access to its pci space can work right.
2024 if (intel_i810_private.i810_dev)
2025 pci_restore_state(intel_i810_private.i810_dev);
2026 if (intel_i830_private.i830_dev)
2027 pci_restore_state(intel_i830_private.i830_dev);
2029 if (bridge->driver == &intel_generic_driver)
2031 else if (bridge->driver == &intel_850_driver)
2032 intel_850_configure();
2033 else if (bridge->driver == &intel_845_driver)
2034 intel_845_configure();
2035 else if (bridge->driver == &intel_830mp_driver)
2036 intel_830mp_configure();
2037 else if (bridge->driver == &intel_915_driver)
2038 intel_i915_configure();
2039 else if (bridge->driver == &intel_830_driver)
2040 intel_i830_configure();
2041 else if (bridge->driver == &intel_810_driver)
2042 intel_i810_configure();
2043 else if (bridge->driver == &intel_i965_driver)
2044 intel_i915_configure();
2050 static struct pci_device_id agp_intel_pci_table[] = {
2053 .class = (PCI_CLASS_BRIDGE_HOST << 8), \
2055 .vendor = PCI_VENDOR_ID_INTEL, \
2057 .subvendor = PCI_ANY_ID, \
2058 .subdevice = PCI_ANY_ID, \
2060 ID(PCI_DEVICE_ID_INTEL_82443LX_0),
2061 ID(PCI_DEVICE_ID_INTEL_82443BX_0),
2062 ID(PCI_DEVICE_ID_INTEL_82443GX_0),
2063 ID(PCI_DEVICE_ID_INTEL_82810_MC1),
2064 ID(PCI_DEVICE_ID_INTEL_82810_MC3),
2065 ID(PCI_DEVICE_ID_INTEL_82810E_MC),
2066 ID(PCI_DEVICE_ID_INTEL_82815_MC),
2067 ID(PCI_DEVICE_ID_INTEL_82820_HB),
2068 ID(PCI_DEVICE_ID_INTEL_82820_UP_HB),
2069 ID(PCI_DEVICE_ID_INTEL_82830_HB),
2070 ID(PCI_DEVICE_ID_INTEL_82840_HB),
2071 ID(PCI_DEVICE_ID_INTEL_82845_HB),
2072 ID(PCI_DEVICE_ID_INTEL_82845G_HB),
2073 ID(PCI_DEVICE_ID_INTEL_82850_HB),
2074 ID(PCI_DEVICE_ID_INTEL_82855PM_HB),
2075 ID(PCI_DEVICE_ID_INTEL_82855GM_HB),
2076 ID(PCI_DEVICE_ID_INTEL_82860_HB),
2077 ID(PCI_DEVICE_ID_INTEL_82865_HB),
2078 ID(PCI_DEVICE_ID_INTEL_82875_HB),
2079 ID(PCI_DEVICE_ID_INTEL_7505_0),
2080 ID(PCI_DEVICE_ID_INTEL_7205_0),
2081 ID(PCI_DEVICE_ID_INTEL_82915G_HB),
2082 ID(PCI_DEVICE_ID_INTEL_82915GM_HB),
2083 ID(PCI_DEVICE_ID_INTEL_82945G_HB),
2084 ID(PCI_DEVICE_ID_INTEL_82945GM_HB),
2085 ID(PCI_DEVICE_ID_INTEL_82946GZ_HB),
2086 ID(PCI_DEVICE_ID_INTEL_82965G_1_HB),
2087 ID(PCI_DEVICE_ID_INTEL_82965Q_HB),
2088 ID(PCI_DEVICE_ID_INTEL_82965G_HB),
2089 ID(PCI_DEVICE_ID_INTEL_82965GM_HB),
2093 MODULE_DEVICE_TABLE(pci, agp_intel_pci_table);
2095 static struct pci_driver agp_intel_pci_driver = {
2096 .name = "agpgart-intel",
2097 .id_table = agp_intel_pci_table,
2098 .probe = agp_intel_probe,
2099 .remove = __devexit_p(agp_intel_remove),
2101 .resume = agp_intel_resume,
2105 static int __init agp_intel_init(void)
2109 return pci_register_driver(&agp_intel_pci_driver);
2112 static void __exit agp_intel_cleanup(void)
2114 pci_unregister_driver(&agp_intel_pci_driver);
2117 module_init(agp_intel_init);
2118 module_exit(agp_intel_cleanup);
2120 MODULE_AUTHOR("Dave Jones <davej@codemonkey.org.uk>");
2121 MODULE_LICENSE("GPL and additional rights");