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) {
196 atomic_inc(&agp_bridge->current_memory_agp);
197 return page_address(page);
200 static void i8xx_destroy_pages(void *addr)
207 page = virt_to_page(addr);
208 change_page_attr(page, 4, PAGE_KERNEL);
212 free_pages((unsigned long)addr, 2);
213 atomic_dec(&agp_bridge->current_memory_agp);
216 static int intel_i830_type_to_mask_type(struct agp_bridge_data *bridge,
219 if (type < AGP_USER_TYPES)
221 else if (type == AGP_USER_CACHED_MEMORY)
222 return INTEL_AGP_CACHED_MEMORY;
227 static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
230 int i, j, num_entries;
235 if (mem->page_count == 0)
238 temp = agp_bridge->current_size;
239 num_entries = A_SIZE_FIX(temp)->num_entries;
241 if ((pg_start + mem->page_count) > num_entries)
245 for (j = pg_start; j < (pg_start + mem->page_count); j++) {
246 if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+j))) {
252 if (type != mem->type)
255 mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
258 case AGP_DCACHE_MEMORY:
259 if (!mem->is_flushed)
260 global_cache_flush();
261 for (i = pg_start; i < (pg_start + mem->page_count); i++) {
262 writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID,
263 intel_i810_private.registers+I810_PTE_BASE+(i*4));
265 readl(intel_i810_private.registers+I810_PTE_BASE+((i-1)*4));
267 case AGP_PHYS_MEMORY:
268 case AGP_NORMAL_MEMORY:
269 if (!mem->is_flushed)
270 global_cache_flush();
271 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
272 writel(agp_bridge->driver->mask_memory(agp_bridge,
275 intel_i810_private.registers+I810_PTE_BASE+(j*4));
277 readl(intel_i810_private.registers+I810_PTE_BASE+((j-1)*4));
283 agp_bridge->driver->tlb_flush(mem);
291 static int intel_i810_remove_entries(struct agp_memory *mem, off_t pg_start,
296 if (mem->page_count == 0)
299 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
300 writel(agp_bridge->scratch_page, intel_i810_private.registers+I810_PTE_BASE+(i*4));
302 readl(intel_i810_private.registers+I810_PTE_BASE+((i-1)*4));
304 agp_bridge->driver->tlb_flush(mem);
309 * The i810/i830 requires a physical address to program its mouse
310 * pointer into hardware.
311 * However the Xserver still writes to it through the agp aperture.
313 static struct agp_memory *alloc_agpphysmem_i8xx(size_t pg_count, int type)
315 struct agp_memory *new;
318 if (pg_count != 1 && pg_count != 4)
322 case 1: addr = agp_bridge->driver->agp_alloc_page(agp_bridge);
326 /* kludge to get 4 physical pages for ARGB cursor */
327 addr = i8xx_alloc_pages();
336 new = agp_create_memory(pg_count);
340 new->memory[0] = virt_to_gart(addr);
342 /* kludge to get 4 physical pages for ARGB cursor */
343 new->memory[1] = new->memory[0] + PAGE_SIZE;
344 new->memory[2] = new->memory[1] + PAGE_SIZE;
345 new->memory[3] = new->memory[2] + PAGE_SIZE;
347 new->page_count = pg_count;
348 new->num_scratch_pages = pg_count;
349 new->type = AGP_PHYS_MEMORY;
350 new->physical = new->memory[0];
354 static struct agp_memory *intel_i810_alloc_by_type(size_t pg_count, int type)
356 struct agp_memory *new;
358 if (type == AGP_DCACHE_MEMORY) {
359 if (pg_count != intel_i810_private.num_dcache_entries)
362 new = agp_create_memory(1);
366 new->type = AGP_DCACHE_MEMORY;
367 new->page_count = pg_count;
368 new->num_scratch_pages = 0;
369 agp_free_page_array(new);
372 if (type == AGP_PHYS_MEMORY)
373 return alloc_agpphysmem_i8xx(pg_count, type);
377 static void intel_i810_free_by_type(struct agp_memory *curr)
379 agp_free_key(curr->key);
380 if (curr->type == AGP_PHYS_MEMORY) {
381 if (curr->page_count == 4)
382 i8xx_destroy_pages(gart_to_virt(curr->memory[0]));
384 agp_bridge->driver->agp_destroy_page(
385 gart_to_virt(curr->memory[0]));
388 agp_free_page_array(curr);
393 static unsigned long intel_i810_mask_memory(struct agp_bridge_data *bridge,
394 unsigned long addr, int type)
396 /* Type checking must be done elsewhere */
397 return addr | bridge->driver->masks[type].mask;
400 static struct aper_size_info_fixed intel_i830_sizes[] =
403 /* The 64M mode still requires a 128k gatt */
409 static struct _intel_i830_private {
410 struct pci_dev *i830_dev; /* device one */
411 volatile u8 __iomem *registers;
412 volatile u32 __iomem *gtt; /* I915G */
413 /* gtt_entries is the number of gtt entries that are already mapped
414 * to stolen memory. Stolen memory is larger than the memory mapped
415 * through gtt_entries, as it includes some reserved space for the BIOS
416 * popup and for the GTT.
419 } intel_i830_private;
421 static void intel_i830_init_gtt_entries(void)
427 static const int ddt[4] = { 0, 16, 32, 64 };
428 int size; /* reserved space (in kb) at the top of stolen memory */
430 pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl);
434 pgetbl_ctl = readl(intel_i830_private.registers+I810_PGETBL_CTL);
436 /* The 965 has a field telling us the size of the GTT,
437 * which may be larger than what is necessary to map the
440 switch (pgetbl_ctl & I965_PGETBL_SIZE_MASK) {
441 case I965_PGETBL_SIZE_128KB:
444 case I965_PGETBL_SIZE_256KB:
447 case I965_PGETBL_SIZE_512KB:
451 printk(KERN_INFO PFX "Unknown page table size, "
455 size += 4; /* add in BIOS popup space */
457 /* On previous hardware, the GTT size was just what was
458 * required to map the aperture.
460 size = agp_bridge->driver->fetch_size() + 4;
463 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82830_HB ||
464 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) {
465 switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
466 case I830_GMCH_GMS_STOLEN_512:
467 gtt_entries = KB(512) - KB(size);
469 case I830_GMCH_GMS_STOLEN_1024:
470 gtt_entries = MB(1) - KB(size);
472 case I830_GMCH_GMS_STOLEN_8192:
473 gtt_entries = MB(8) - KB(size);
475 case I830_GMCH_GMS_LOCAL:
476 rdct = readb(intel_i830_private.registers+I830_RDRAM_CHANNEL_TYPE);
477 gtt_entries = (I830_RDRAM_ND(rdct) + 1) *
478 MB(ddt[I830_RDRAM_DDT(rdct)]);
486 switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
487 case I855_GMCH_GMS_STOLEN_1M:
488 gtt_entries = MB(1) - KB(size);
490 case I855_GMCH_GMS_STOLEN_4M:
491 gtt_entries = MB(4) - KB(size);
493 case I855_GMCH_GMS_STOLEN_8M:
494 gtt_entries = MB(8) - KB(size);
496 case I855_GMCH_GMS_STOLEN_16M:
497 gtt_entries = MB(16) - KB(size);
499 case I855_GMCH_GMS_STOLEN_32M:
500 gtt_entries = MB(32) - KB(size);
502 case I915_GMCH_GMS_STOLEN_48M:
503 /* Check it's really I915G */
504 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
505 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
506 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
507 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || IS_I965 )
508 gtt_entries = MB(48) - KB(size);
512 case I915_GMCH_GMS_STOLEN_64M:
513 /* Check it's really I915G */
514 if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB ||
515 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB ||
516 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB ||
517 agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || IS_I965)
518 gtt_entries = MB(64) - KB(size);
527 printk(KERN_INFO PFX "Detected %dK %s memory.\n",
528 gtt_entries / KB(1), local ? "local" : "stolen");
531 "No pre-allocated video memory detected.\n");
532 gtt_entries /= KB(4);
534 intel_i830_private.gtt_entries = gtt_entries;
537 /* The intel i830 automatically initializes the agp aperture during POST.
538 * Use the memory already set aside for in the GTT.
540 static int intel_i830_create_gatt_table(struct agp_bridge_data *bridge)
543 struct aper_size_info_fixed *size;
547 size = agp_bridge->current_size;
548 page_order = size->page_order;
549 num_entries = size->num_entries;
550 agp_bridge->gatt_table_real = NULL;
552 pci_read_config_dword(intel_i830_private.i830_dev,I810_MMADDR,&temp);
555 intel_i830_private.registers = ioremap(temp,128 * 4096);
556 if (!intel_i830_private.registers)
559 temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000;
560 global_cache_flush(); /* FIXME: ?? */
562 /* we have to call this as early as possible after the MMIO base address is known */
563 intel_i830_init_gtt_entries();
565 agp_bridge->gatt_table = NULL;
567 agp_bridge->gatt_bus_addr = temp;
572 /* Return the gatt table to a sane state. Use the top of stolen
573 * memory for the GTT.
575 static int intel_i830_free_gatt_table(struct agp_bridge_data *bridge)
580 static int intel_i830_fetch_size(void)
583 struct aper_size_info_fixed *values;
585 values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes);
587 if (agp_bridge->dev->device != PCI_DEVICE_ID_INTEL_82830_HB &&
588 agp_bridge->dev->device != PCI_DEVICE_ID_INTEL_82845G_HB) {
589 /* 855GM/852GM/865G has 128MB aperture size */
590 agp_bridge->previous_size = agp_bridge->current_size = (void *) values;
591 agp_bridge->aperture_size_idx = 0;
592 return values[0].size;
595 pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl);
597 if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_128M) {
598 agp_bridge->previous_size = agp_bridge->current_size = (void *) values;
599 agp_bridge->aperture_size_idx = 0;
600 return values[0].size;
602 agp_bridge->previous_size = agp_bridge->current_size = (void *) (values + 1);
603 agp_bridge->aperture_size_idx = 1;
604 return values[1].size;
610 static int intel_i830_configure(void)
612 struct aper_size_info_fixed *current_size;
617 current_size = A_SIZE_FIX(agp_bridge->current_size);
619 pci_read_config_dword(intel_i830_private.i830_dev,I810_GMADDR,&temp);
620 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
622 pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl);
623 gmch_ctrl |= I830_GMCH_ENABLED;
624 pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl);
626 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_i830_private.registers+I810_PGETBL_CTL);
627 readl(intel_i830_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
629 if (agp_bridge->driver->needs_scratch_page) {
630 for (i = intel_i830_private.gtt_entries; i < current_size->num_entries; i++) {
631 writel(agp_bridge->scratch_page, intel_i830_private.registers+I810_PTE_BASE+(i*4));
632 readl(intel_i830_private.registers+I810_PTE_BASE+(i*4)); /* PCI Posting. */
636 global_cache_flush();
640 static void intel_i830_cleanup(void)
642 iounmap(intel_i830_private.registers);
645 static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int type)
652 if (mem->page_count == 0)
655 temp = agp_bridge->current_size;
656 num_entries = A_SIZE_FIX(temp)->num_entries;
658 if (pg_start < intel_i830_private.gtt_entries) {
659 printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_i830_private.gtt_entries == 0x%.8x\n",
660 pg_start,intel_i830_private.gtt_entries);
662 printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n");
666 if ((pg_start + mem->page_count) > num_entries)
669 /* The i830 can't check the GTT for entries since its read only,
670 * depend on the caller to make the correct offset decisions.
673 if (type != mem->type)
676 mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
678 if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY &&
679 mask_type != INTEL_AGP_CACHED_MEMORY)
682 if (!mem->is_flushed)
683 global_cache_flush();
685 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
686 writel(agp_bridge->driver->mask_memory(agp_bridge,
687 mem->memory[i], mask_type),
688 intel_i830_private.registers+I810_PTE_BASE+(j*4));
690 readl(intel_i830_private.registers+I810_PTE_BASE+((j-1)*4));
691 agp_bridge->driver->tlb_flush(mem);
700 static int intel_i830_remove_entries(struct agp_memory *mem,off_t pg_start,
705 if (mem->page_count == 0)
708 if (pg_start < intel_i830_private.gtt_entries) {
709 printk (KERN_INFO PFX "Trying to disable local/stolen memory\n");
713 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
714 writel(agp_bridge->scratch_page, intel_i830_private.registers+I810_PTE_BASE+(i*4));
716 readl(intel_i830_private.registers+I810_PTE_BASE+((i-1)*4));
718 agp_bridge->driver->tlb_flush(mem);
722 static struct agp_memory *intel_i830_alloc_by_type(size_t pg_count,int type)
724 if (type == AGP_PHYS_MEMORY)
725 return alloc_agpphysmem_i8xx(pg_count, type);
726 /* always return NULL for other allocation types for now */
730 static int intel_i915_configure(void)
732 struct aper_size_info_fixed *current_size;
737 current_size = A_SIZE_FIX(agp_bridge->current_size);
739 pci_read_config_dword(intel_i830_private.i830_dev, I915_GMADDR, &temp);
741 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
743 pci_read_config_word(agp_bridge->dev,I830_GMCH_CTRL,&gmch_ctrl);
744 gmch_ctrl |= I830_GMCH_ENABLED;
745 pci_write_config_word(agp_bridge->dev,I830_GMCH_CTRL,gmch_ctrl);
747 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_i830_private.registers+I810_PGETBL_CTL);
748 readl(intel_i830_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
750 if (agp_bridge->driver->needs_scratch_page) {
751 for (i = intel_i830_private.gtt_entries; i < current_size->num_entries; i++) {
752 writel(agp_bridge->scratch_page, intel_i830_private.gtt+i);
753 readl(intel_i830_private.gtt+i); /* PCI Posting. */
757 global_cache_flush();
761 static void intel_i915_cleanup(void)
763 iounmap(intel_i830_private.gtt);
764 iounmap(intel_i830_private.registers);
767 static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start,
775 if (mem->page_count == 0)
778 temp = agp_bridge->current_size;
779 num_entries = A_SIZE_FIX(temp)->num_entries;
781 if (pg_start < intel_i830_private.gtt_entries) {
782 printk (KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_i830_private.gtt_entries == 0x%.8x\n",
783 pg_start,intel_i830_private.gtt_entries);
785 printk (KERN_INFO PFX "Trying to insert into local/stolen memory\n");
789 if ((pg_start + mem->page_count) > num_entries)
792 /* The i915 can't check the GTT for entries since its read only,
793 * depend on the caller to make the correct offset decisions.
796 if (type != mem->type)
799 mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
801 if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY &&
802 mask_type != INTEL_AGP_CACHED_MEMORY)
805 if (!mem->is_flushed)
806 global_cache_flush();
808 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
809 writel(agp_bridge->driver->mask_memory(agp_bridge,
810 mem->memory[i], mask_type), intel_i830_private.gtt+j);
813 readl(intel_i830_private.gtt+j-1);
814 agp_bridge->driver->tlb_flush(mem);
823 static int intel_i915_remove_entries(struct agp_memory *mem,off_t pg_start,
828 if (mem->page_count == 0)
831 if (pg_start < intel_i830_private.gtt_entries) {
832 printk (KERN_INFO PFX "Trying to disable local/stolen memory\n");
836 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
837 writel(agp_bridge->scratch_page, intel_i830_private.gtt+i);
839 readl(intel_i830_private.gtt+i-1);
841 agp_bridge->driver->tlb_flush(mem);
845 /* Return the aperture size by just checking the resource length. The effect
846 * described in the spec of the MSAC registers is just changing of the
849 static int intel_i9xx_fetch_size(void)
851 int num_sizes = ARRAY_SIZE(intel_i830_sizes);
852 int aper_size; /* size in megabytes */
855 aper_size = pci_resource_len(intel_i830_private.i830_dev, 2) / MB(1);
857 for (i = 0; i < num_sizes; i++) {
858 if (aper_size == intel_i830_sizes[i].size) {
859 agp_bridge->current_size = intel_i830_sizes + i;
860 agp_bridge->previous_size = agp_bridge->current_size;
868 /* The intel i915 automatically initializes the agp aperture during POST.
869 * Use the memory already set aside for in the GTT.
871 static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge)
874 struct aper_size_info_fixed *size;
878 size = agp_bridge->current_size;
879 page_order = size->page_order;
880 num_entries = size->num_entries;
881 agp_bridge->gatt_table_real = NULL;
883 pci_read_config_dword(intel_i830_private.i830_dev, I915_MMADDR, &temp);
884 pci_read_config_dword(intel_i830_private.i830_dev, I915_PTEADDR,&temp2);
886 intel_i830_private.gtt = ioremap(temp2, 256 * 1024);
887 if (!intel_i830_private.gtt)
892 intel_i830_private.registers = ioremap(temp,128 * 4096);
893 if (!intel_i830_private.registers)
896 temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000;
897 global_cache_flush(); /* FIXME: ? */
899 /* we have to call this as early as possible after the MMIO base address is known */
900 intel_i830_init_gtt_entries();
902 agp_bridge->gatt_table = NULL;
904 agp_bridge->gatt_bus_addr = temp;
910 * The i965 supports 36-bit physical addresses, but to keep
911 * the format of the GTT the same, the bits that don't fit
912 * in a 32-bit word are shifted down to bits 4..7.
914 * Gcc is smart enough to notice that "(addr >> 28) & 0xf0"
915 * is always zero on 32-bit architectures, so no need to make
918 static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge,
919 unsigned long addr, int type)
921 /* Shift high bits down */
922 addr |= (addr >> 28) & 0xf0;
924 /* Type checking must be done elsewhere */
925 return addr | bridge->driver->masks[type].mask;
928 /* The intel i965 automatically initializes the agp aperture during POST.
929 * Use the memory already set aside for in the GTT.
931 static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge)
934 struct aper_size_info_fixed *size;
938 size = agp_bridge->current_size;
939 page_order = size->page_order;
940 num_entries = size->num_entries;
941 agp_bridge->gatt_table_real = NULL;
943 pci_read_config_dword(intel_i830_private.i830_dev, I915_MMADDR, &temp);
946 intel_i830_private.gtt = ioremap((temp + (512 * 1024)) , 512 * 1024);
948 if (!intel_i830_private.gtt)
952 intel_i830_private.registers = ioremap(temp,128 * 4096);
953 if (!intel_i830_private.registers)
956 temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000;
957 global_cache_flush(); /* FIXME: ? */
959 /* we have to call this as early as possible after the MMIO base address is known */
960 intel_i830_init_gtt_entries();
962 agp_bridge->gatt_table = NULL;
964 agp_bridge->gatt_bus_addr = temp;
970 static int intel_fetch_size(void)
974 struct aper_size_info_16 *values;
976 pci_read_config_word(agp_bridge->dev, INTEL_APSIZE, &temp);
977 values = A_SIZE_16(agp_bridge->driver->aperture_sizes);
979 for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) {
980 if (temp == values[i].size_value) {
981 agp_bridge->previous_size = agp_bridge->current_size = (void *) (values + i);
982 agp_bridge->aperture_size_idx = i;
983 return values[i].size;
990 static int __intel_8xx_fetch_size(u8 temp)
993 struct aper_size_info_8 *values;
995 values = A_SIZE_8(agp_bridge->driver->aperture_sizes);
997 for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) {
998 if (temp == values[i].size_value) {
999 agp_bridge->previous_size =
1000 agp_bridge->current_size = (void *) (values + i);
1001 agp_bridge->aperture_size_idx = i;
1002 return values[i].size;
1008 static int intel_8xx_fetch_size(void)
1012 pci_read_config_byte(agp_bridge->dev, INTEL_APSIZE, &temp);
1013 return __intel_8xx_fetch_size(temp);
1016 static int intel_815_fetch_size(void)
1020 /* Intel 815 chipsets have a _weird_ APSIZE register with only
1021 * one non-reserved bit, so mask the others out ... */
1022 pci_read_config_byte(agp_bridge->dev, INTEL_APSIZE, &temp);
1025 return __intel_8xx_fetch_size(temp);
1028 static void intel_tlbflush(struct agp_memory *mem)
1030 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2200);
1031 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2280);
1035 static void intel_8xx_tlbflush(struct agp_memory *mem)
1038 pci_read_config_dword(agp_bridge->dev, INTEL_AGPCTRL, &temp);
1039 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, temp & ~(1 << 7));
1040 pci_read_config_dword(agp_bridge->dev, INTEL_AGPCTRL, &temp);
1041 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, temp | (1 << 7));
1045 static void intel_cleanup(void)
1048 struct aper_size_info_16 *previous_size;
1050 previous_size = A_SIZE_16(agp_bridge->previous_size);
1051 pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp);
1052 pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp & ~(1 << 9));
1053 pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, previous_size->size_value);
1057 static void intel_8xx_cleanup(void)
1060 struct aper_size_info_8 *previous_size;
1062 previous_size = A_SIZE_8(agp_bridge->previous_size);
1063 pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp);
1064 pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp & ~(1 << 9));
1065 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, previous_size->size_value);
1069 static int intel_configure(void)
1073 struct aper_size_info_16 *current_size;
1075 current_size = A_SIZE_16(agp_bridge->current_size);
1078 pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1080 /* address to map to */
1081 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1082 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1084 /* attbase - aperture base */
1085 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1088 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2280);
1091 pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp2);
1092 pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG,
1093 (temp2 & ~(1 << 10)) | (1 << 9));
1094 /* clear any possible error conditions */
1095 pci_write_config_byte(agp_bridge->dev, INTEL_ERRSTS + 1, 7);
1099 static int intel_815_configure(void)
1103 struct aper_size_info_8 *current_size;
1105 /* attbase - aperture base */
1106 /* the Intel 815 chipset spec. says that bits 29-31 in the
1107 * ATTBASE register are reserved -> try not to write them */
1108 if (agp_bridge->gatt_bus_addr & INTEL_815_ATTBASE_MASK) {
1109 printk (KERN_EMERG PFX "gatt bus addr too high");
1113 current_size = A_SIZE_8(agp_bridge->current_size);
1116 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE,
1117 current_size->size_value);
1119 /* address to map to */
1120 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1121 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1123 pci_read_config_dword(agp_bridge->dev, INTEL_ATTBASE, &addr);
1124 addr &= INTEL_815_ATTBASE_MASK;
1125 addr |= agp_bridge->gatt_bus_addr;
1126 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, addr);
1129 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1132 pci_read_config_byte(agp_bridge->dev, INTEL_815_APCONT, &temp2);
1133 pci_write_config_byte(agp_bridge->dev, INTEL_815_APCONT, temp2 | (1 << 1));
1135 /* clear any possible error conditions */
1136 /* Oddness : this chipset seems to have no ERRSTS register ! */
1140 static void intel_820_tlbflush(struct agp_memory *mem)
1145 static void intel_820_cleanup(void)
1148 struct aper_size_info_8 *previous_size;
1150 previous_size = A_SIZE_8(agp_bridge->previous_size);
1151 pci_read_config_byte(agp_bridge->dev, INTEL_I820_RDCR, &temp);
1152 pci_write_config_byte(agp_bridge->dev, INTEL_I820_RDCR,
1154 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE,
1155 previous_size->size_value);
1159 static int intel_820_configure(void)
1163 struct aper_size_info_8 *current_size;
1165 current_size = A_SIZE_8(agp_bridge->current_size);
1168 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1170 /* address to map to */
1171 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1172 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1174 /* attbase - aperture base */
1175 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1178 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1180 /* global enable aperture access */
1181 /* This flag is not accessed through MCHCFG register as in */
1183 pci_read_config_byte(agp_bridge->dev, INTEL_I820_RDCR, &temp2);
1184 pci_write_config_byte(agp_bridge->dev, INTEL_I820_RDCR, temp2 | (1 << 1));
1185 /* clear any possible AGP-related error conditions */
1186 pci_write_config_word(agp_bridge->dev, INTEL_I820_ERRSTS, 0x001c);
1190 static int intel_840_configure(void)
1194 struct aper_size_info_8 *current_size;
1196 current_size = A_SIZE_8(agp_bridge->current_size);
1199 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1201 /* address to map to */
1202 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1203 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1205 /* attbase - aperture base */
1206 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1209 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1212 pci_read_config_word(agp_bridge->dev, INTEL_I840_MCHCFG, &temp2);
1213 pci_write_config_word(agp_bridge->dev, INTEL_I840_MCHCFG, temp2 | (1 << 9));
1214 /* clear any possible error conditions */
1215 pci_write_config_word(agp_bridge->dev, INTEL_I840_ERRSTS, 0xc000);
1219 static int intel_845_configure(void)
1223 struct aper_size_info_8 *current_size;
1225 current_size = A_SIZE_8(agp_bridge->current_size);
1228 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1230 if (agp_bridge->apbase_config != 0) {
1231 pci_write_config_dword(agp_bridge->dev, AGP_APBASE,
1232 agp_bridge->apbase_config);
1234 /* address to map to */
1235 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1236 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1237 agp_bridge->apbase_config = temp;
1240 /* attbase - aperture base */
1241 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1244 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1247 pci_read_config_byte(agp_bridge->dev, INTEL_I845_AGPM, &temp2);
1248 pci_write_config_byte(agp_bridge->dev, INTEL_I845_AGPM, temp2 | (1 << 1));
1249 /* clear any possible error conditions */
1250 pci_write_config_word(agp_bridge->dev, INTEL_I845_ERRSTS, 0x001c);
1254 static int intel_850_configure(void)
1258 struct aper_size_info_8 *current_size;
1260 current_size = A_SIZE_8(agp_bridge->current_size);
1263 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1265 /* address to map to */
1266 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1267 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1269 /* attbase - aperture base */
1270 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1273 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1276 pci_read_config_word(agp_bridge->dev, INTEL_I850_MCHCFG, &temp2);
1277 pci_write_config_word(agp_bridge->dev, INTEL_I850_MCHCFG, temp2 | (1 << 9));
1278 /* clear any possible AGP-related error conditions */
1279 pci_write_config_word(agp_bridge->dev, INTEL_I850_ERRSTS, 0x001c);
1283 static int intel_860_configure(void)
1287 struct aper_size_info_8 *current_size;
1289 current_size = A_SIZE_8(agp_bridge->current_size);
1292 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1294 /* address to map to */
1295 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1296 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1298 /* attbase - aperture base */
1299 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1302 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1305 pci_read_config_word(agp_bridge->dev, INTEL_I860_MCHCFG, &temp2);
1306 pci_write_config_word(agp_bridge->dev, INTEL_I860_MCHCFG, temp2 | (1 << 9));
1307 /* clear any possible AGP-related error conditions */
1308 pci_write_config_word(agp_bridge->dev, INTEL_I860_ERRSTS, 0xf700);
1312 static int intel_830mp_configure(void)
1316 struct aper_size_info_8 *current_size;
1318 current_size = A_SIZE_8(agp_bridge->current_size);
1321 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1323 /* address to map to */
1324 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1325 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1327 /* attbase - aperture base */
1328 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1331 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1334 pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp2);
1335 pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp2 | (1 << 9));
1336 /* clear any possible AGP-related error conditions */
1337 pci_write_config_word(agp_bridge->dev, INTEL_I830_ERRSTS, 0x1c);
1341 static int intel_7505_configure(void)
1345 struct aper_size_info_8 *current_size;
1347 current_size = A_SIZE_8(agp_bridge->current_size);
1350 pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value);
1352 /* address to map to */
1353 pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp);
1354 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1356 /* attbase - aperture base */
1357 pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr);
1360 pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000);
1363 pci_read_config_word(agp_bridge->dev, INTEL_I7505_MCHCFG, &temp2);
1364 pci_write_config_word(agp_bridge->dev, INTEL_I7505_MCHCFG, temp2 | (1 << 9));
1369 /* Setup function */
1370 static const struct gatt_mask intel_generic_masks[] =
1372 {.mask = 0x00000017, .type = 0}
1375 static const struct aper_size_info_8 intel_815_sizes[2] =
1381 static const struct aper_size_info_8 intel_8xx_sizes[7] =
1384 {128, 32768, 5, 32},
1392 static const struct aper_size_info_16 intel_generic_sizes[7] =
1395 {128, 32768, 5, 32},
1403 static const struct aper_size_info_8 intel_830mp_sizes[4] =
1406 {128, 32768, 5, 32},
1411 static const struct agp_bridge_driver intel_generic_driver = {
1412 .owner = THIS_MODULE,
1413 .aperture_sizes = intel_generic_sizes,
1414 .size_type = U16_APER_SIZE,
1415 .num_aperture_sizes = 7,
1416 .configure = intel_configure,
1417 .fetch_size = intel_fetch_size,
1418 .cleanup = intel_cleanup,
1419 .tlb_flush = intel_tlbflush,
1420 .mask_memory = agp_generic_mask_memory,
1421 .masks = intel_generic_masks,
1422 .agp_enable = agp_generic_enable,
1423 .cache_flush = global_cache_flush,
1424 .create_gatt_table = agp_generic_create_gatt_table,
1425 .free_gatt_table = agp_generic_free_gatt_table,
1426 .insert_memory = agp_generic_insert_memory,
1427 .remove_memory = agp_generic_remove_memory,
1428 .alloc_by_type = agp_generic_alloc_by_type,
1429 .free_by_type = agp_generic_free_by_type,
1430 .agp_alloc_page = agp_generic_alloc_page,
1431 .agp_destroy_page = agp_generic_destroy_page,
1432 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1435 static const struct agp_bridge_driver intel_810_driver = {
1436 .owner = THIS_MODULE,
1437 .aperture_sizes = intel_i810_sizes,
1438 .size_type = FIXED_APER_SIZE,
1439 .num_aperture_sizes = 2,
1440 .needs_scratch_page = TRUE,
1441 .configure = intel_i810_configure,
1442 .fetch_size = intel_i810_fetch_size,
1443 .cleanup = intel_i810_cleanup,
1444 .tlb_flush = intel_i810_tlbflush,
1445 .mask_memory = intel_i810_mask_memory,
1446 .masks = intel_i810_masks,
1447 .agp_enable = intel_i810_agp_enable,
1448 .cache_flush = global_cache_flush,
1449 .create_gatt_table = agp_generic_create_gatt_table,
1450 .free_gatt_table = agp_generic_free_gatt_table,
1451 .insert_memory = intel_i810_insert_entries,
1452 .remove_memory = intel_i810_remove_entries,
1453 .alloc_by_type = intel_i810_alloc_by_type,
1454 .free_by_type = intel_i810_free_by_type,
1455 .agp_alloc_page = agp_generic_alloc_page,
1456 .agp_destroy_page = agp_generic_destroy_page,
1457 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1460 static const struct agp_bridge_driver intel_815_driver = {
1461 .owner = THIS_MODULE,
1462 .aperture_sizes = intel_815_sizes,
1463 .size_type = U8_APER_SIZE,
1464 .num_aperture_sizes = 2,
1465 .configure = intel_815_configure,
1466 .fetch_size = intel_815_fetch_size,
1467 .cleanup = intel_8xx_cleanup,
1468 .tlb_flush = intel_8xx_tlbflush,
1469 .mask_memory = agp_generic_mask_memory,
1470 .masks = intel_generic_masks,
1471 .agp_enable = agp_generic_enable,
1472 .cache_flush = global_cache_flush,
1473 .create_gatt_table = agp_generic_create_gatt_table,
1474 .free_gatt_table = agp_generic_free_gatt_table,
1475 .insert_memory = agp_generic_insert_memory,
1476 .remove_memory = agp_generic_remove_memory,
1477 .alloc_by_type = agp_generic_alloc_by_type,
1478 .free_by_type = agp_generic_free_by_type,
1479 .agp_alloc_page = agp_generic_alloc_page,
1480 .agp_destroy_page = agp_generic_destroy_page,
1481 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1484 static const struct agp_bridge_driver intel_830_driver = {
1485 .owner = THIS_MODULE,
1486 .aperture_sizes = intel_i830_sizes,
1487 .size_type = FIXED_APER_SIZE,
1488 .num_aperture_sizes = 4,
1489 .needs_scratch_page = TRUE,
1490 .configure = intel_i830_configure,
1491 .fetch_size = intel_i830_fetch_size,
1492 .cleanup = intel_i830_cleanup,
1493 .tlb_flush = intel_i810_tlbflush,
1494 .mask_memory = intel_i810_mask_memory,
1495 .masks = intel_i810_masks,
1496 .agp_enable = intel_i810_agp_enable,
1497 .cache_flush = global_cache_flush,
1498 .create_gatt_table = intel_i830_create_gatt_table,
1499 .free_gatt_table = intel_i830_free_gatt_table,
1500 .insert_memory = intel_i830_insert_entries,
1501 .remove_memory = intel_i830_remove_entries,
1502 .alloc_by_type = intel_i830_alloc_by_type,
1503 .free_by_type = intel_i810_free_by_type,
1504 .agp_alloc_page = agp_generic_alloc_page,
1505 .agp_destroy_page = agp_generic_destroy_page,
1506 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
1509 static const struct agp_bridge_driver intel_820_driver = {
1510 .owner = THIS_MODULE,
1511 .aperture_sizes = intel_8xx_sizes,
1512 .size_type = U8_APER_SIZE,
1513 .num_aperture_sizes = 7,
1514 .configure = intel_820_configure,
1515 .fetch_size = intel_8xx_fetch_size,
1516 .cleanup = intel_820_cleanup,
1517 .tlb_flush = intel_820_tlbflush,
1518 .mask_memory = agp_generic_mask_memory,
1519 .masks = intel_generic_masks,
1520 .agp_enable = agp_generic_enable,
1521 .cache_flush = global_cache_flush,
1522 .create_gatt_table = agp_generic_create_gatt_table,
1523 .free_gatt_table = agp_generic_free_gatt_table,
1524 .insert_memory = agp_generic_insert_memory,
1525 .remove_memory = agp_generic_remove_memory,
1526 .alloc_by_type = agp_generic_alloc_by_type,
1527 .free_by_type = agp_generic_free_by_type,
1528 .agp_alloc_page = agp_generic_alloc_page,
1529 .agp_destroy_page = agp_generic_destroy_page,
1530 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1533 static const struct agp_bridge_driver intel_830mp_driver = {
1534 .owner = THIS_MODULE,
1535 .aperture_sizes = intel_830mp_sizes,
1536 .size_type = U8_APER_SIZE,
1537 .num_aperture_sizes = 4,
1538 .configure = intel_830mp_configure,
1539 .fetch_size = intel_8xx_fetch_size,
1540 .cleanup = intel_8xx_cleanup,
1541 .tlb_flush = intel_8xx_tlbflush,
1542 .mask_memory = agp_generic_mask_memory,
1543 .masks = intel_generic_masks,
1544 .agp_enable = agp_generic_enable,
1545 .cache_flush = global_cache_flush,
1546 .create_gatt_table = agp_generic_create_gatt_table,
1547 .free_gatt_table = agp_generic_free_gatt_table,
1548 .insert_memory = agp_generic_insert_memory,
1549 .remove_memory = agp_generic_remove_memory,
1550 .alloc_by_type = agp_generic_alloc_by_type,
1551 .free_by_type = agp_generic_free_by_type,
1552 .agp_alloc_page = agp_generic_alloc_page,
1553 .agp_destroy_page = agp_generic_destroy_page,
1554 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1557 static const struct agp_bridge_driver intel_840_driver = {
1558 .owner = THIS_MODULE,
1559 .aperture_sizes = intel_8xx_sizes,
1560 .size_type = U8_APER_SIZE,
1561 .num_aperture_sizes = 7,
1562 .configure = intel_840_configure,
1563 .fetch_size = intel_8xx_fetch_size,
1564 .cleanup = intel_8xx_cleanup,
1565 .tlb_flush = intel_8xx_tlbflush,
1566 .mask_memory = agp_generic_mask_memory,
1567 .masks = intel_generic_masks,
1568 .agp_enable = agp_generic_enable,
1569 .cache_flush = global_cache_flush,
1570 .create_gatt_table = agp_generic_create_gatt_table,
1571 .free_gatt_table = agp_generic_free_gatt_table,
1572 .insert_memory = agp_generic_insert_memory,
1573 .remove_memory = agp_generic_remove_memory,
1574 .alloc_by_type = agp_generic_alloc_by_type,
1575 .free_by_type = agp_generic_free_by_type,
1576 .agp_alloc_page = agp_generic_alloc_page,
1577 .agp_destroy_page = agp_generic_destroy_page,
1578 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1581 static const struct agp_bridge_driver intel_845_driver = {
1582 .owner = THIS_MODULE,
1583 .aperture_sizes = intel_8xx_sizes,
1584 .size_type = U8_APER_SIZE,
1585 .num_aperture_sizes = 7,
1586 .configure = intel_845_configure,
1587 .fetch_size = intel_8xx_fetch_size,
1588 .cleanup = intel_8xx_cleanup,
1589 .tlb_flush = intel_8xx_tlbflush,
1590 .mask_memory = agp_generic_mask_memory,
1591 .masks = intel_generic_masks,
1592 .agp_enable = agp_generic_enable,
1593 .cache_flush = global_cache_flush,
1594 .create_gatt_table = agp_generic_create_gatt_table,
1595 .free_gatt_table = agp_generic_free_gatt_table,
1596 .insert_memory = agp_generic_insert_memory,
1597 .remove_memory = agp_generic_remove_memory,
1598 .alloc_by_type = agp_generic_alloc_by_type,
1599 .free_by_type = agp_generic_free_by_type,
1600 .agp_alloc_page = agp_generic_alloc_page,
1601 .agp_destroy_page = agp_generic_destroy_page,
1602 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1605 static const struct agp_bridge_driver intel_850_driver = {
1606 .owner = THIS_MODULE,
1607 .aperture_sizes = intel_8xx_sizes,
1608 .size_type = U8_APER_SIZE,
1609 .num_aperture_sizes = 7,
1610 .configure = intel_850_configure,
1611 .fetch_size = intel_8xx_fetch_size,
1612 .cleanup = intel_8xx_cleanup,
1613 .tlb_flush = intel_8xx_tlbflush,
1614 .mask_memory = agp_generic_mask_memory,
1615 .masks = intel_generic_masks,
1616 .agp_enable = agp_generic_enable,
1617 .cache_flush = global_cache_flush,
1618 .create_gatt_table = agp_generic_create_gatt_table,
1619 .free_gatt_table = agp_generic_free_gatt_table,
1620 .insert_memory = agp_generic_insert_memory,
1621 .remove_memory = agp_generic_remove_memory,
1622 .alloc_by_type = agp_generic_alloc_by_type,
1623 .free_by_type = agp_generic_free_by_type,
1624 .agp_alloc_page = agp_generic_alloc_page,
1625 .agp_destroy_page = agp_generic_destroy_page,
1626 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1629 static const struct agp_bridge_driver intel_860_driver = {
1630 .owner = THIS_MODULE,
1631 .aperture_sizes = intel_8xx_sizes,
1632 .size_type = U8_APER_SIZE,
1633 .num_aperture_sizes = 7,
1634 .configure = intel_860_configure,
1635 .fetch_size = intel_8xx_fetch_size,
1636 .cleanup = intel_8xx_cleanup,
1637 .tlb_flush = intel_8xx_tlbflush,
1638 .mask_memory = agp_generic_mask_memory,
1639 .masks = intel_generic_masks,
1640 .agp_enable = agp_generic_enable,
1641 .cache_flush = global_cache_flush,
1642 .create_gatt_table = agp_generic_create_gatt_table,
1643 .free_gatt_table = agp_generic_free_gatt_table,
1644 .insert_memory = agp_generic_insert_memory,
1645 .remove_memory = agp_generic_remove_memory,
1646 .alloc_by_type = agp_generic_alloc_by_type,
1647 .free_by_type = agp_generic_free_by_type,
1648 .agp_alloc_page = agp_generic_alloc_page,
1649 .agp_destroy_page = agp_generic_destroy_page,
1650 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1653 static const struct agp_bridge_driver intel_915_driver = {
1654 .owner = THIS_MODULE,
1655 .aperture_sizes = intel_i830_sizes,
1656 .size_type = FIXED_APER_SIZE,
1657 .num_aperture_sizes = 4,
1658 .needs_scratch_page = TRUE,
1659 .configure = intel_i915_configure,
1660 .fetch_size = intel_i9xx_fetch_size,
1661 .cleanup = intel_i915_cleanup,
1662 .tlb_flush = intel_i810_tlbflush,
1663 .mask_memory = intel_i810_mask_memory,
1664 .masks = intel_i810_masks,
1665 .agp_enable = intel_i810_agp_enable,
1666 .cache_flush = global_cache_flush,
1667 .create_gatt_table = intel_i915_create_gatt_table,
1668 .free_gatt_table = intel_i830_free_gatt_table,
1669 .insert_memory = intel_i915_insert_entries,
1670 .remove_memory = intel_i915_remove_entries,
1671 .alloc_by_type = intel_i830_alloc_by_type,
1672 .free_by_type = intel_i810_free_by_type,
1673 .agp_alloc_page = agp_generic_alloc_page,
1674 .agp_destroy_page = agp_generic_destroy_page,
1675 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
1678 static const struct agp_bridge_driver intel_i965_driver = {
1679 .owner = THIS_MODULE,
1680 .aperture_sizes = intel_i830_sizes,
1681 .size_type = FIXED_APER_SIZE,
1682 .num_aperture_sizes = 4,
1683 .needs_scratch_page = TRUE,
1684 .configure = intel_i915_configure,
1685 .fetch_size = intel_i9xx_fetch_size,
1686 .cleanup = intel_i915_cleanup,
1687 .tlb_flush = intel_i810_tlbflush,
1688 .mask_memory = intel_i965_mask_memory,
1689 .masks = intel_i810_masks,
1690 .agp_enable = intel_i810_agp_enable,
1691 .cache_flush = global_cache_flush,
1692 .create_gatt_table = intel_i965_create_gatt_table,
1693 .free_gatt_table = intel_i830_free_gatt_table,
1694 .insert_memory = intel_i915_insert_entries,
1695 .remove_memory = intel_i915_remove_entries,
1696 .alloc_by_type = intel_i830_alloc_by_type,
1697 .free_by_type = intel_i810_free_by_type,
1698 .agp_alloc_page = agp_generic_alloc_page,
1699 .agp_destroy_page = agp_generic_destroy_page,
1700 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
1703 static const struct agp_bridge_driver intel_7505_driver = {
1704 .owner = THIS_MODULE,
1705 .aperture_sizes = intel_8xx_sizes,
1706 .size_type = U8_APER_SIZE,
1707 .num_aperture_sizes = 7,
1708 .configure = intel_7505_configure,
1709 .fetch_size = intel_8xx_fetch_size,
1710 .cleanup = intel_8xx_cleanup,
1711 .tlb_flush = intel_8xx_tlbflush,
1712 .mask_memory = agp_generic_mask_memory,
1713 .masks = intel_generic_masks,
1714 .agp_enable = agp_generic_enable,
1715 .cache_flush = global_cache_flush,
1716 .create_gatt_table = agp_generic_create_gatt_table,
1717 .free_gatt_table = agp_generic_free_gatt_table,
1718 .insert_memory = agp_generic_insert_memory,
1719 .remove_memory = agp_generic_remove_memory,
1720 .alloc_by_type = agp_generic_alloc_by_type,
1721 .free_by_type = agp_generic_free_by_type,
1722 .agp_alloc_page = agp_generic_alloc_page,
1723 .agp_destroy_page = agp_generic_destroy_page,
1724 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1727 static int find_i810(u16 device)
1729 struct pci_dev *i810_dev;
1731 i810_dev = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL);
1734 intel_i810_private.i810_dev = i810_dev;
1738 static int find_i830(u16 device)
1740 struct pci_dev *i830_dev;
1742 i830_dev = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL);
1743 if (i830_dev && PCI_FUNC(i830_dev->devfn) != 0) {
1744 i830_dev = pci_get_device(PCI_VENDOR_ID_INTEL,
1751 intel_i830_private.i830_dev = i830_dev;
1755 static int __devinit agp_intel_probe(struct pci_dev *pdev,
1756 const struct pci_device_id *ent)
1758 struct agp_bridge_data *bridge;
1759 char *name = "(unknown)";
1763 cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
1765 bridge = agp_alloc_bridge();
1769 switch (pdev->device) {
1770 case PCI_DEVICE_ID_INTEL_82443LX_0:
1771 bridge->driver = &intel_generic_driver;
1774 case PCI_DEVICE_ID_INTEL_82443BX_0:
1775 bridge->driver = &intel_generic_driver;
1778 case PCI_DEVICE_ID_INTEL_82443GX_0:
1779 bridge->driver = &intel_generic_driver;
1782 case PCI_DEVICE_ID_INTEL_82810_MC1:
1784 if (!find_i810(PCI_DEVICE_ID_INTEL_82810_IG1))
1786 bridge->driver = &intel_810_driver;
1788 case PCI_DEVICE_ID_INTEL_82810_MC3:
1789 name = "i810 DC100";
1790 if (!find_i810(PCI_DEVICE_ID_INTEL_82810_IG3))
1792 bridge->driver = &intel_810_driver;
1794 case PCI_DEVICE_ID_INTEL_82810E_MC:
1796 if (!find_i810(PCI_DEVICE_ID_INTEL_82810E_IG))
1798 bridge->driver = &intel_810_driver;
1800 case PCI_DEVICE_ID_INTEL_82815_MC:
1802 * The i815 can operate either as an i810 style
1803 * integrated device, or as an AGP4X motherboard.
1805 if (find_i810(PCI_DEVICE_ID_INTEL_82815_CGC))
1806 bridge->driver = &intel_810_driver;
1808 bridge->driver = &intel_815_driver;
1811 case PCI_DEVICE_ID_INTEL_82820_HB:
1812 case PCI_DEVICE_ID_INTEL_82820_UP_HB:
1813 bridge->driver = &intel_820_driver;
1816 case PCI_DEVICE_ID_INTEL_82830_HB:
1817 if (find_i830(PCI_DEVICE_ID_INTEL_82830_CGC))
1818 bridge->driver = &intel_830_driver;
1820 bridge->driver = &intel_830mp_driver;
1823 case PCI_DEVICE_ID_INTEL_82840_HB:
1824 bridge->driver = &intel_840_driver;
1827 case PCI_DEVICE_ID_INTEL_82845_HB:
1828 bridge->driver = &intel_845_driver;
1831 case PCI_DEVICE_ID_INTEL_82845G_HB:
1832 if (find_i830(PCI_DEVICE_ID_INTEL_82845G_IG))
1833 bridge->driver = &intel_830_driver;
1835 bridge->driver = &intel_845_driver;
1838 case PCI_DEVICE_ID_INTEL_82850_HB:
1839 bridge->driver = &intel_850_driver;
1842 case PCI_DEVICE_ID_INTEL_82855PM_HB:
1843 bridge->driver = &intel_845_driver;
1846 case PCI_DEVICE_ID_INTEL_82855GM_HB:
1847 if (find_i830(PCI_DEVICE_ID_INTEL_82855GM_IG)) {
1848 bridge->driver = &intel_830_driver;
1851 bridge->driver = &intel_845_driver;
1855 case PCI_DEVICE_ID_INTEL_82860_HB:
1856 bridge->driver = &intel_860_driver;
1859 case PCI_DEVICE_ID_INTEL_82865_HB:
1860 if (find_i830(PCI_DEVICE_ID_INTEL_82865_IG))
1861 bridge->driver = &intel_830_driver;
1863 bridge->driver = &intel_845_driver;
1866 case PCI_DEVICE_ID_INTEL_82875_HB:
1867 bridge->driver = &intel_845_driver;
1870 case PCI_DEVICE_ID_INTEL_82915G_HB:
1871 if (find_i830(PCI_DEVICE_ID_INTEL_82915G_IG))
1872 bridge->driver = &intel_915_driver;
1874 bridge->driver = &intel_845_driver;
1877 case PCI_DEVICE_ID_INTEL_82915GM_HB:
1878 if (find_i830(PCI_DEVICE_ID_INTEL_82915GM_IG))
1879 bridge->driver = &intel_915_driver;
1881 bridge->driver = &intel_845_driver;
1884 case PCI_DEVICE_ID_INTEL_82945G_HB:
1885 if (find_i830(PCI_DEVICE_ID_INTEL_82945G_IG))
1886 bridge->driver = &intel_915_driver;
1888 bridge->driver = &intel_845_driver;
1891 case PCI_DEVICE_ID_INTEL_82945GM_HB:
1892 if (find_i830(PCI_DEVICE_ID_INTEL_82945GM_IG))
1893 bridge->driver = &intel_915_driver;
1895 bridge->driver = &intel_845_driver;
1898 case PCI_DEVICE_ID_INTEL_82946GZ_HB:
1899 if (find_i830(PCI_DEVICE_ID_INTEL_82946GZ_IG))
1900 bridge->driver = &intel_i965_driver;
1902 bridge->driver = &intel_845_driver;
1905 case PCI_DEVICE_ID_INTEL_82965G_1_HB:
1906 if (find_i830(PCI_DEVICE_ID_INTEL_82965G_1_IG))
1907 bridge->driver = &intel_i965_driver;
1909 bridge->driver = &intel_845_driver;
1912 case PCI_DEVICE_ID_INTEL_82965Q_HB:
1913 if (find_i830(PCI_DEVICE_ID_INTEL_82965Q_IG))
1914 bridge->driver = &intel_i965_driver;
1916 bridge->driver = &intel_845_driver;
1919 case PCI_DEVICE_ID_INTEL_82965G_HB:
1920 if (find_i830(PCI_DEVICE_ID_INTEL_82965G_IG))
1921 bridge->driver = &intel_i965_driver;
1923 bridge->driver = &intel_845_driver;
1926 case PCI_DEVICE_ID_INTEL_82965GM_HB:
1927 if (find_i830(PCI_DEVICE_ID_INTEL_82965GM_IG))
1928 bridge->driver = &intel_i965_driver;
1930 bridge->driver = &intel_845_driver;
1933 case PCI_DEVICE_ID_INTEL_7505_0:
1934 bridge->driver = &intel_7505_driver;
1937 case PCI_DEVICE_ID_INTEL_7205_0:
1938 bridge->driver = &intel_7505_driver;
1943 printk(KERN_WARNING PFX "Unsupported Intel chipset (device id: %04x)\n",
1945 agp_put_bridge(bridge);
1950 bridge->capndx = cap_ptr;
1952 if (bridge->driver == &intel_810_driver)
1953 bridge->dev_private_data = &intel_i810_private;
1954 else if (bridge->driver == &intel_830_driver)
1955 bridge->dev_private_data = &intel_i830_private;
1957 printk(KERN_INFO PFX "Detected an Intel %s Chipset.\n", name);
1960 * The following fixes the case where the BIOS has "forgotten" to
1961 * provide an address range for the GART.
1962 * 20030610 - hamish@zot.org
1964 r = &pdev->resource[0];
1965 if (!r->start && r->end) {
1966 if (pci_assign_resource(pdev, 0)) {
1967 printk(KERN_ERR PFX "could not assign resource 0\n");
1968 agp_put_bridge(bridge);
1974 * If the device has not been properly setup, the following will catch
1975 * the problem and should stop the system from crashing.
1976 * 20030610 - hamish@zot.org
1978 if (pci_enable_device(pdev)) {
1979 printk(KERN_ERR PFX "Unable to Enable PCI device\n");
1980 agp_put_bridge(bridge);
1984 /* Fill in the mode register */
1986 pci_read_config_dword(pdev,
1987 bridge->capndx+PCI_AGP_STATUS,
1991 pci_set_drvdata(pdev, bridge);
1992 return agp_add_bridge(bridge);
1995 printk(KERN_ERR PFX "Detected an Intel %s chipset, "
1996 "but could not find the secondary device.\n", name);
1997 agp_put_bridge(bridge);
2001 static void __devexit agp_intel_remove(struct pci_dev *pdev)
2003 struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
2005 agp_remove_bridge(bridge);
2007 if (intel_i810_private.i810_dev)
2008 pci_dev_put(intel_i810_private.i810_dev);
2009 if (intel_i830_private.i830_dev)
2010 pci_dev_put(intel_i830_private.i830_dev);
2012 agp_put_bridge(bridge);
2016 static int agp_intel_resume(struct pci_dev *pdev)
2018 struct agp_bridge_data *bridge = pci_get_drvdata(pdev);
2020 pci_restore_state(pdev);
2022 /* We should restore our graphics device's config space,
2023 * as host bridge (00:00) resumes before graphics device (02:00),
2024 * then our access to its pci space can work right.
2026 if (intel_i810_private.i810_dev)
2027 pci_restore_state(intel_i810_private.i810_dev);
2028 if (intel_i830_private.i830_dev)
2029 pci_restore_state(intel_i830_private.i830_dev);
2031 if (bridge->driver == &intel_generic_driver)
2033 else if (bridge->driver == &intel_850_driver)
2034 intel_850_configure();
2035 else if (bridge->driver == &intel_845_driver)
2036 intel_845_configure();
2037 else if (bridge->driver == &intel_830mp_driver)
2038 intel_830mp_configure();
2039 else if (bridge->driver == &intel_915_driver)
2040 intel_i915_configure();
2041 else if (bridge->driver == &intel_830_driver)
2042 intel_i830_configure();
2043 else if (bridge->driver == &intel_810_driver)
2044 intel_i810_configure();
2045 else if (bridge->driver == &intel_i965_driver)
2046 intel_i915_configure();
2052 static struct pci_device_id agp_intel_pci_table[] = {
2055 .class = (PCI_CLASS_BRIDGE_HOST << 8), \
2057 .vendor = PCI_VENDOR_ID_INTEL, \
2059 .subvendor = PCI_ANY_ID, \
2060 .subdevice = PCI_ANY_ID, \
2062 ID(PCI_DEVICE_ID_INTEL_82443LX_0),
2063 ID(PCI_DEVICE_ID_INTEL_82443BX_0),
2064 ID(PCI_DEVICE_ID_INTEL_82443GX_0),
2065 ID(PCI_DEVICE_ID_INTEL_82810_MC1),
2066 ID(PCI_DEVICE_ID_INTEL_82810_MC3),
2067 ID(PCI_DEVICE_ID_INTEL_82810E_MC),
2068 ID(PCI_DEVICE_ID_INTEL_82815_MC),
2069 ID(PCI_DEVICE_ID_INTEL_82820_HB),
2070 ID(PCI_DEVICE_ID_INTEL_82820_UP_HB),
2071 ID(PCI_DEVICE_ID_INTEL_82830_HB),
2072 ID(PCI_DEVICE_ID_INTEL_82840_HB),
2073 ID(PCI_DEVICE_ID_INTEL_82845_HB),
2074 ID(PCI_DEVICE_ID_INTEL_82845G_HB),
2075 ID(PCI_DEVICE_ID_INTEL_82850_HB),
2076 ID(PCI_DEVICE_ID_INTEL_82855PM_HB),
2077 ID(PCI_DEVICE_ID_INTEL_82855GM_HB),
2078 ID(PCI_DEVICE_ID_INTEL_82860_HB),
2079 ID(PCI_DEVICE_ID_INTEL_82865_HB),
2080 ID(PCI_DEVICE_ID_INTEL_82875_HB),
2081 ID(PCI_DEVICE_ID_INTEL_7505_0),
2082 ID(PCI_DEVICE_ID_INTEL_7205_0),
2083 ID(PCI_DEVICE_ID_INTEL_82915G_HB),
2084 ID(PCI_DEVICE_ID_INTEL_82915GM_HB),
2085 ID(PCI_DEVICE_ID_INTEL_82945G_HB),
2086 ID(PCI_DEVICE_ID_INTEL_82945GM_HB),
2087 ID(PCI_DEVICE_ID_INTEL_82946GZ_HB),
2088 ID(PCI_DEVICE_ID_INTEL_82965G_1_HB),
2089 ID(PCI_DEVICE_ID_INTEL_82965Q_HB),
2090 ID(PCI_DEVICE_ID_INTEL_82965G_HB),
2091 ID(PCI_DEVICE_ID_INTEL_82965GM_HB),
2095 MODULE_DEVICE_TABLE(pci, agp_intel_pci_table);
2097 static struct pci_driver agp_intel_pci_driver = {
2098 .name = "agpgart-intel",
2099 .id_table = agp_intel_pci_table,
2100 .probe = agp_intel_probe,
2101 .remove = __devexit_p(agp_intel_remove),
2103 .resume = agp_intel_resume,
2107 static int __init agp_intel_init(void)
2111 return pci_register_driver(&agp_intel_pci_driver);
2114 static void __exit agp_intel_cleanup(void)
2116 pci_unregister_driver(&agp_intel_pci_driver);
2119 module_init(agp_intel_init);
2120 module_exit(agp_intel_cleanup);
2122 MODULE_AUTHOR("Dave Jones <davej@codemonkey.org.uk>");
2123 MODULE_LICENSE("GPL and additional rights");