blob: fd977aa4a17dc0828b12692cff1bd78622d68a6d [file] [log] [blame]
Daniel Vetterf51b7662010-04-14 00:29:52 +02001/*
2 * Intel GTT (Graphics Translation Table) routines
3 *
4 * Caveat: This driver implements the linux agp interface, but this is far from
5 * a agp driver! GTT support ended up here for purely historical reasons: The
6 * old userspace intel graphics drivers needed an interface to map memory into
7 * the GTT. And the drm provides a default interface for graphic devices sitting
8 * on an agp port. So it made sense to fake the GTT support as an agp port to
9 * avoid having to create a new api.
10 *
11 * With gem this does not make much sense anymore, just needlessly complicates
12 * the code. But as long as the old graphics stack is still support, it's stuck
13 * here.
14 *
15 * /fairy-tale-mode off
16 */
17
Daniel Vettere2404e72010-09-08 17:29:51 +020018#include <linux/module.h>
19#include <linux/pci.h>
20#include <linux/init.h>
21#include <linux/kernel.h>
22#include <linux/pagemap.h>
23#include <linux/agp_backend.h>
24#include <asm/smp.h>
25#include "agp.h"
26#include "intel-agp.h"
27#include <linux/intel-gtt.h>
Daniel Vetter0ade6382010-08-24 22:18:41 +020028#include <drm/intel-gtt.h>
Daniel Vettere2404e72010-09-08 17:29:51 +020029
Daniel Vetterf51b7662010-04-14 00:29:52 +020030/*
31 * If we have Intel graphics, we're not going to have anything other than
32 * an Intel IOMMU. So make the correct use of the PCI DMA API contingent
33 * on the Intel IOMMU support (CONFIG_DMAR).
34 * Only newer chipsets need to bother with this, of course.
35 */
36#ifdef CONFIG_DMAR
37#define USE_PCI_DMA_API 1
38#endif
39
Jesse Barnesd1d6ca72010-07-08 09:22:46 -070040/* Max amount of stolen space, anything above will be returned to Linux */
41int intel_max_stolen = 32 * 1024 * 1024;
42EXPORT_SYMBOL(intel_max_stolen);
43
Daniel Vetterf51b7662010-04-14 00:29:52 +020044static const struct aper_size_info_fixed intel_i810_sizes[] =
45{
46 {64, 16384, 4},
47 /* The 32M mode still requires a 64k gatt */
48 {32, 8192, 4}
49};
50
51#define AGP_DCACHE_MEMORY 1
52#define AGP_PHYS_MEMORY 2
53#define INTEL_AGP_CACHED_MEMORY 3
54
55static struct gatt_mask intel_i810_masks[] =
56{
57 {.mask = I810_PTE_VALID, .type = 0},
58 {.mask = (I810_PTE_VALID | I810_PTE_LOCAL), .type = AGP_DCACHE_MEMORY},
59 {.mask = I810_PTE_VALID, .type = 0},
60 {.mask = I810_PTE_VALID | I830_PTE_SYSTEM_CACHED,
61 .type = INTEL_AGP_CACHED_MEMORY}
62};
63
Zhenyu Wangf8f235e2010-08-27 11:08:57 +080064#define INTEL_AGP_UNCACHED_MEMORY 0
65#define INTEL_AGP_CACHED_MEMORY_LLC 1
66#define INTEL_AGP_CACHED_MEMORY_LLC_GFDT 2
67#define INTEL_AGP_CACHED_MEMORY_LLC_MLC 3
68#define INTEL_AGP_CACHED_MEMORY_LLC_MLC_GFDT 4
69
70static struct gatt_mask intel_gen6_masks[] =
71{
72 {.mask = I810_PTE_VALID | GEN6_PTE_UNCACHED,
73 .type = INTEL_AGP_UNCACHED_MEMORY },
74 {.mask = I810_PTE_VALID | GEN6_PTE_LLC,
75 .type = INTEL_AGP_CACHED_MEMORY_LLC },
76 {.mask = I810_PTE_VALID | GEN6_PTE_LLC | GEN6_PTE_GFDT,
77 .type = INTEL_AGP_CACHED_MEMORY_LLC_GFDT },
78 {.mask = I810_PTE_VALID | GEN6_PTE_LLC_MLC,
79 .type = INTEL_AGP_CACHED_MEMORY_LLC_MLC },
80 {.mask = I810_PTE_VALID | GEN6_PTE_LLC_MLC | GEN6_PTE_GFDT,
81 .type = INTEL_AGP_CACHED_MEMORY_LLC_MLC_GFDT },
82};
83
Daniel Vetter1a997ff2010-09-08 21:18:53 +020084struct intel_gtt_driver {
85 unsigned int gen : 8;
86 unsigned int is_g33 : 1;
87 unsigned int is_pineview : 1;
88 unsigned int is_ironlake : 1;
Daniel Vetter73800422010-08-29 17:29:50 +020089 /* Chipset specific GTT setup */
90 int (*setup)(void);
Daniel Vetter1a997ff2010-09-08 21:18:53 +020091};
92
Daniel Vetterf51b7662010-04-14 00:29:52 +020093static struct _intel_private {
Daniel Vetter0ade6382010-08-24 22:18:41 +020094 struct intel_gtt base;
Daniel Vetter1a997ff2010-09-08 21:18:53 +020095 const struct intel_gtt_driver *driver;
Daniel Vetterf51b7662010-04-14 00:29:52 +020096 struct pci_dev *pcidev; /* device one */
Daniel Vetterd7cca2f2010-08-24 23:06:19 +020097 struct pci_dev *bridge_dev;
Daniel Vetterf51b7662010-04-14 00:29:52 +020098 u8 __iomem *registers;
Daniel Vetterf67eab62010-08-29 17:27:36 +020099 phys_addr_t gtt_bus_addr;
Daniel Vetter73800422010-08-29 17:29:50 +0200100 phys_addr_t gma_bus_addr;
Daniel Vetterf51b7662010-04-14 00:29:52 +0200101 u32 __iomem *gtt; /* I915G */
102 int num_dcache_entries;
Daniel Vetterf51b7662010-04-14 00:29:52 +0200103 union {
104 void __iomem *i9xx_flush_page;
105 void *i8xx_flush_page;
106 };
107 struct page *i8xx_page;
108 struct resource ifp_resource;
109 int resource_valid;
110} intel_private;
111
Daniel Vetter1a997ff2010-09-08 21:18:53 +0200112#define INTEL_GTT_GEN intel_private.driver->gen
113#define IS_G33 intel_private.driver->is_g33
114#define IS_PINEVIEW intel_private.driver->is_pineview
115#define IS_IRONLAKE intel_private.driver->is_ironlake
116
Daniel Vetterf51b7662010-04-14 00:29:52 +0200117#ifdef USE_PCI_DMA_API
118static int intel_agp_map_page(struct page *page, dma_addr_t *ret)
119{
120 *ret = pci_map_page(intel_private.pcidev, page, 0,
121 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
122 if (pci_dma_mapping_error(intel_private.pcidev, *ret))
123 return -EINVAL;
124 return 0;
125}
126
127static void intel_agp_unmap_page(struct page *page, dma_addr_t dma)
128{
129 pci_unmap_page(intel_private.pcidev, dma,
130 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
131}
132
133static void intel_agp_free_sglist(struct agp_memory *mem)
134{
135 struct sg_table st;
136
137 st.sgl = mem->sg_list;
138 st.orig_nents = st.nents = mem->page_count;
139
140 sg_free_table(&st);
141
142 mem->sg_list = NULL;
143 mem->num_sg = 0;
144}
145
146static int intel_agp_map_memory(struct agp_memory *mem)
147{
148 struct sg_table st;
149 struct scatterlist *sg;
150 int i;
151
152 DBG("try mapping %lu pages\n", (unsigned long)mem->page_count);
153
154 if (sg_alloc_table(&st, mem->page_count, GFP_KERNEL))
Chris Wilson831cd442010-07-24 18:29:37 +0100155 goto err;
Daniel Vetterf51b7662010-04-14 00:29:52 +0200156
157 mem->sg_list = sg = st.sgl;
158
159 for (i = 0 ; i < mem->page_count; i++, sg = sg_next(sg))
160 sg_set_page(sg, mem->pages[i], PAGE_SIZE, 0);
161
162 mem->num_sg = pci_map_sg(intel_private.pcidev, mem->sg_list,
163 mem->page_count, PCI_DMA_BIDIRECTIONAL);
Chris Wilson831cd442010-07-24 18:29:37 +0100164 if (unlikely(!mem->num_sg))
165 goto err;
166
Daniel Vetterf51b7662010-04-14 00:29:52 +0200167 return 0;
Chris Wilson831cd442010-07-24 18:29:37 +0100168
169err:
170 sg_free_table(&st);
171 return -ENOMEM;
Daniel Vetterf51b7662010-04-14 00:29:52 +0200172}
173
174static void intel_agp_unmap_memory(struct agp_memory *mem)
175{
176 DBG("try unmapping %lu pages\n", (unsigned long)mem->page_count);
177
178 pci_unmap_sg(intel_private.pcidev, mem->sg_list,
179 mem->page_count, PCI_DMA_BIDIRECTIONAL);
180 intel_agp_free_sglist(mem);
181}
182
183static void intel_agp_insert_sg_entries(struct agp_memory *mem,
184 off_t pg_start, int mask_type)
185{
186 struct scatterlist *sg;
187 int i, j;
188
189 j = pg_start;
190
191 WARN_ON(!mem->num_sg);
192
193 if (mem->num_sg == mem->page_count) {
194 for_each_sg(mem->sg_list, sg, mem->page_count, i) {
195 writel(agp_bridge->driver->mask_memory(agp_bridge,
196 sg_dma_address(sg), mask_type),
197 intel_private.gtt+j);
198 j++;
199 }
200 } else {
201 /* sg may merge pages, but we have to separate
202 * per-page addr for GTT */
203 unsigned int len, m;
204
205 for_each_sg(mem->sg_list, sg, mem->num_sg, i) {
206 len = sg_dma_len(sg) / PAGE_SIZE;
207 for (m = 0; m < len; m++) {
208 writel(agp_bridge->driver->mask_memory(agp_bridge,
209 sg_dma_address(sg) + m * PAGE_SIZE,
210 mask_type),
211 intel_private.gtt+j);
212 j++;
213 }
214 }
215 }
216 readl(intel_private.gtt+j-1);
217}
218
219#else
220
221static void intel_agp_insert_sg_entries(struct agp_memory *mem,
222 off_t pg_start, int mask_type)
223{
224 int i, j;
Daniel Vetterf51b7662010-04-14 00:29:52 +0200225
226 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
227 writel(agp_bridge->driver->mask_memory(agp_bridge,
228 page_to_phys(mem->pages[i]), mask_type),
229 intel_private.gtt+j);
230 }
231
232 readl(intel_private.gtt+j-1);
233}
234
235#endif
236
237static int intel_i810_fetch_size(void)
238{
239 u32 smram_miscc;
240 struct aper_size_info_fixed *values;
241
Daniel Vetterd7cca2f2010-08-24 23:06:19 +0200242 pci_read_config_dword(intel_private.bridge_dev,
243 I810_SMRAM_MISCC, &smram_miscc);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200244 values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes);
245
246 if ((smram_miscc & I810_GMS) == I810_GMS_DISABLE) {
Daniel Vetterd7cca2f2010-08-24 23:06:19 +0200247 dev_warn(&intel_private.bridge_dev->dev, "i810 is disabled\n");
Daniel Vetterf51b7662010-04-14 00:29:52 +0200248 return 0;
249 }
250 if ((smram_miscc & I810_GFX_MEM_WIN_SIZE) == I810_GFX_MEM_WIN_32M) {
Daniel Vettere1583162010-04-14 00:29:58 +0200251 agp_bridge->current_size = (void *) (values + 1);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200252 agp_bridge->aperture_size_idx = 1;
253 return values[1].size;
254 } else {
Daniel Vettere1583162010-04-14 00:29:58 +0200255 agp_bridge->current_size = (void *) (values);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200256 agp_bridge->aperture_size_idx = 0;
257 return values[0].size;
258 }
259
260 return 0;
261}
262
263static int intel_i810_configure(void)
264{
265 struct aper_size_info_fixed *current_size;
266 u32 temp;
267 int i;
268
269 current_size = A_SIZE_FIX(agp_bridge->current_size);
270
271 if (!intel_private.registers) {
272 pci_read_config_dword(intel_private.pcidev, I810_MMADDR, &temp);
273 temp &= 0xfff80000;
274
275 intel_private.registers = ioremap(temp, 128 * 4096);
276 if (!intel_private.registers) {
277 dev_err(&intel_private.pcidev->dev,
278 "can't remap memory\n");
279 return -ENOMEM;
280 }
281 }
282
283 if ((readl(intel_private.registers+I810_DRAM_CTL)
284 & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) {
285 /* This will need to be dynamically assigned */
286 dev_info(&intel_private.pcidev->dev,
287 "detected 4MB dedicated video ram\n");
288 intel_private.num_dcache_entries = 1024;
289 }
290 pci_read_config_dword(intel_private.pcidev, I810_GMADDR, &temp);
291 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
292 writel(agp_bridge->gatt_bus_addr | I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL);
293 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
294
295 if (agp_bridge->driver->needs_scratch_page) {
296 for (i = 0; i < current_size->num_entries; i++) {
297 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
298 }
299 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4)); /* PCI posting. */
300 }
301 global_cache_flush();
302 return 0;
303}
304
305static void intel_i810_cleanup(void)
306{
307 writel(0, intel_private.registers+I810_PGETBL_CTL);
308 readl(intel_private.registers); /* PCI Posting. */
309 iounmap(intel_private.registers);
310}
311
Daniel Vetterffdd7512010-08-27 17:51:29 +0200312static void intel_fake_agp_enable(struct agp_bridge_data *bridge, u32 mode)
Daniel Vetterf51b7662010-04-14 00:29:52 +0200313{
314 return;
315}
316
317/* Exists to support ARGB cursors */
318static struct page *i8xx_alloc_pages(void)
319{
320 struct page *page;
321
322 page = alloc_pages(GFP_KERNEL | GFP_DMA32, 2);
323 if (page == NULL)
324 return NULL;
325
326 if (set_pages_uc(page, 4) < 0) {
327 set_pages_wb(page, 4);
328 __free_pages(page, 2);
329 return NULL;
330 }
331 get_page(page);
332 atomic_inc(&agp_bridge->current_memory_agp);
333 return page;
334}
335
336static void i8xx_destroy_pages(struct page *page)
337{
338 if (page == NULL)
339 return;
340
341 set_pages_wb(page, 4);
342 put_page(page);
343 __free_pages(page, 2);
344 atomic_dec(&agp_bridge->current_memory_agp);
345}
346
347static int intel_i830_type_to_mask_type(struct agp_bridge_data *bridge,
348 int type)
349{
350 if (type < AGP_USER_TYPES)
351 return type;
352 else if (type == AGP_USER_CACHED_MEMORY)
353 return INTEL_AGP_CACHED_MEMORY;
354 else
355 return 0;
356}
357
Zhenyu Wangf8f235e2010-08-27 11:08:57 +0800358static int intel_gen6_type_to_mask_type(struct agp_bridge_data *bridge,
359 int type)
360{
361 unsigned int type_mask = type & ~AGP_USER_CACHED_MEMORY_GFDT;
362 unsigned int gfdt = type & AGP_USER_CACHED_MEMORY_GFDT;
363
364 if (type_mask == AGP_USER_UNCACHED_MEMORY)
365 return INTEL_AGP_UNCACHED_MEMORY;
366 else if (type_mask == AGP_USER_CACHED_MEMORY_LLC_MLC)
367 return gfdt ? INTEL_AGP_CACHED_MEMORY_LLC_MLC_GFDT :
368 INTEL_AGP_CACHED_MEMORY_LLC_MLC;
369 else /* set 'normal'/'cached' to LLC by default */
370 return gfdt ? INTEL_AGP_CACHED_MEMORY_LLC_GFDT :
371 INTEL_AGP_CACHED_MEMORY_LLC;
372}
373
374
Daniel Vetterf51b7662010-04-14 00:29:52 +0200375static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
376 int type)
377{
378 int i, j, num_entries;
379 void *temp;
380 int ret = -EINVAL;
381 int mask_type;
382
383 if (mem->page_count == 0)
384 goto out;
385
386 temp = agp_bridge->current_size;
387 num_entries = A_SIZE_FIX(temp)->num_entries;
388
389 if ((pg_start + mem->page_count) > num_entries)
390 goto out_err;
391
392
393 for (j = pg_start; j < (pg_start + mem->page_count); j++) {
394 if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+j))) {
395 ret = -EBUSY;
396 goto out_err;
397 }
398 }
399
400 if (type != mem->type)
401 goto out_err;
402
403 mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
404
405 switch (mask_type) {
406 case AGP_DCACHE_MEMORY:
407 if (!mem->is_flushed)
408 global_cache_flush();
409 for (i = pg_start; i < (pg_start + mem->page_count); i++) {
410 writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID,
411 intel_private.registers+I810_PTE_BASE+(i*4));
412 }
413 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4));
414 break;
415 case AGP_PHYS_MEMORY:
416 case AGP_NORMAL_MEMORY:
417 if (!mem->is_flushed)
418 global_cache_flush();
419 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
420 writel(agp_bridge->driver->mask_memory(agp_bridge,
421 page_to_phys(mem->pages[i]), mask_type),
422 intel_private.registers+I810_PTE_BASE+(j*4));
423 }
424 readl(intel_private.registers+I810_PTE_BASE+((j-1)*4));
425 break;
426 default:
427 goto out_err;
428 }
429
Daniel Vetterf51b7662010-04-14 00:29:52 +0200430out:
431 ret = 0;
432out_err:
433 mem->is_flushed = true;
434 return ret;
435}
436
437static int intel_i810_remove_entries(struct agp_memory *mem, off_t pg_start,
438 int type)
439{
440 int i;
441
442 if (mem->page_count == 0)
443 return 0;
444
445 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
446 writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4));
447 }
448 readl(intel_private.registers+I810_PTE_BASE+((i-1)*4));
449
Daniel Vetterf51b7662010-04-14 00:29:52 +0200450 return 0;
451}
452
453/*
454 * The i810/i830 requires a physical address to program its mouse
455 * pointer into hardware.
456 * However the Xserver still writes to it through the agp aperture.
457 */
458static struct agp_memory *alloc_agpphysmem_i8xx(size_t pg_count, int type)
459{
460 struct agp_memory *new;
461 struct page *page;
462
463 switch (pg_count) {
464 case 1: page = agp_bridge->driver->agp_alloc_page(agp_bridge);
465 break;
466 case 4:
467 /* kludge to get 4 physical pages for ARGB cursor */
468 page = i8xx_alloc_pages();
469 break;
470 default:
471 return NULL;
472 }
473
474 if (page == NULL)
475 return NULL;
476
477 new = agp_create_memory(pg_count);
478 if (new == NULL)
479 return NULL;
480
481 new->pages[0] = page;
482 if (pg_count == 4) {
483 /* kludge to get 4 physical pages for ARGB cursor */
484 new->pages[1] = new->pages[0] + 1;
485 new->pages[2] = new->pages[1] + 1;
486 new->pages[3] = new->pages[2] + 1;
487 }
488 new->page_count = pg_count;
489 new->num_scratch_pages = pg_count;
490 new->type = AGP_PHYS_MEMORY;
491 new->physical = page_to_phys(new->pages[0]);
492 return new;
493}
494
495static struct agp_memory *intel_i810_alloc_by_type(size_t pg_count, int type)
496{
497 struct agp_memory *new;
498
499 if (type == AGP_DCACHE_MEMORY) {
500 if (pg_count != intel_private.num_dcache_entries)
501 return NULL;
502
503 new = agp_create_memory(1);
504 if (new == NULL)
505 return NULL;
506
507 new->type = AGP_DCACHE_MEMORY;
508 new->page_count = pg_count;
509 new->num_scratch_pages = 0;
510 agp_free_page_array(new);
511 return new;
512 }
513 if (type == AGP_PHYS_MEMORY)
514 return alloc_agpphysmem_i8xx(pg_count, type);
515 return NULL;
516}
517
518static void intel_i810_free_by_type(struct agp_memory *curr)
519{
520 agp_free_key(curr->key);
521 if (curr->type == AGP_PHYS_MEMORY) {
522 if (curr->page_count == 4)
523 i8xx_destroy_pages(curr->pages[0]);
524 else {
525 agp_bridge->driver->agp_destroy_page(curr->pages[0],
526 AGP_PAGE_DESTROY_UNMAP);
527 agp_bridge->driver->agp_destroy_page(curr->pages[0],
528 AGP_PAGE_DESTROY_FREE);
529 }
530 agp_free_page_array(curr);
531 }
532 kfree(curr);
533}
534
535static unsigned long intel_i810_mask_memory(struct agp_bridge_data *bridge,
536 dma_addr_t addr, int type)
537{
538 /* Type checking must be done elsewhere */
539 return addr | bridge->driver->masks[type].mask;
540}
541
Daniel Vetterffdd7512010-08-27 17:51:29 +0200542static struct aper_size_info_fixed intel_fake_agp_sizes[] =
Daniel Vetterf51b7662010-04-14 00:29:52 +0200543{
544 {128, 32768, 5},
545 /* The 64M mode still requires a 128k gatt */
546 {64, 16384, 5},
547 {256, 65536, 6},
548 {512, 131072, 7},
549};
550
Daniel Vetterbfde0672010-08-24 23:07:59 +0200551static unsigned int intel_gtt_stolen_entries(void)
Daniel Vetterf51b7662010-04-14 00:29:52 +0200552{
553 u16 gmch_ctrl;
Daniel Vetterf51b7662010-04-14 00:29:52 +0200554 u8 rdct;
555 int local = 0;
556 static const int ddt[4] = { 0, 16, 32, 64 };
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200557 unsigned int overhead_entries, stolen_entries;
558 unsigned int stolen_size = 0;
Daniel Vetterf51b7662010-04-14 00:29:52 +0200559
Daniel Vetterd7cca2f2010-08-24 23:06:19 +0200560 pci_read_config_word(intel_private.bridge_dev,
561 I830_GMCH_CTRL, &gmch_ctrl);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200562
Daniel Vetter1a997ff2010-09-08 21:18:53 +0200563 if (INTEL_GTT_GEN > 4 || IS_PINEVIEW)
Daniel Vetterfbe40782010-08-27 17:12:41 +0200564 overhead_entries = 0;
565 else
566 overhead_entries = intel_private.base.gtt_mappable_entries
567 / 1024;
Daniel Vetterf51b7662010-04-14 00:29:52 +0200568
Daniel Vetterfbe40782010-08-27 17:12:41 +0200569 overhead_entries += 1; /* BIOS popup */
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200570
Daniel Vetterd7cca2f2010-08-24 23:06:19 +0200571 if (intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82830_HB ||
572 intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) {
Daniel Vetterf51b7662010-04-14 00:29:52 +0200573 switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
574 case I830_GMCH_GMS_STOLEN_512:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200575 stolen_size = KB(512);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200576 break;
577 case I830_GMCH_GMS_STOLEN_1024:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200578 stolen_size = MB(1);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200579 break;
580 case I830_GMCH_GMS_STOLEN_8192:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200581 stolen_size = MB(8);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200582 break;
583 case I830_GMCH_GMS_LOCAL:
584 rdct = readb(intel_private.registers+I830_RDRAM_CHANNEL_TYPE);
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200585 stolen_size = (I830_RDRAM_ND(rdct) + 1) *
Daniel Vetterf51b7662010-04-14 00:29:52 +0200586 MB(ddt[I830_RDRAM_DDT(rdct)]);
587 local = 1;
588 break;
589 default:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200590 stolen_size = 0;
Daniel Vetterf51b7662010-04-14 00:29:52 +0200591 break;
592 }
Daniel Vetter1a997ff2010-09-08 21:18:53 +0200593 } else if (INTEL_GTT_GEN == 6) {
Daniel Vetterf51b7662010-04-14 00:29:52 +0200594 /*
595 * SandyBridge has new memory control reg at 0x50.w
596 */
597 u16 snb_gmch_ctl;
598 pci_read_config_word(intel_private.pcidev, SNB_GMCH_CTRL, &snb_gmch_ctl);
599 switch (snb_gmch_ctl & SNB_GMCH_GMS_STOLEN_MASK) {
600 case SNB_GMCH_GMS_STOLEN_32M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200601 stolen_size = MB(32);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200602 break;
603 case SNB_GMCH_GMS_STOLEN_64M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200604 stolen_size = MB(64);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200605 break;
606 case SNB_GMCH_GMS_STOLEN_96M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200607 stolen_size = MB(96);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200608 break;
609 case SNB_GMCH_GMS_STOLEN_128M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200610 stolen_size = MB(128);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200611 break;
612 case SNB_GMCH_GMS_STOLEN_160M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200613 stolen_size = MB(160);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200614 break;
615 case SNB_GMCH_GMS_STOLEN_192M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200616 stolen_size = MB(192);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200617 break;
618 case SNB_GMCH_GMS_STOLEN_224M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200619 stolen_size = MB(224);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200620 break;
621 case SNB_GMCH_GMS_STOLEN_256M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200622 stolen_size = MB(256);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200623 break;
624 case SNB_GMCH_GMS_STOLEN_288M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200625 stolen_size = MB(288);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200626 break;
627 case SNB_GMCH_GMS_STOLEN_320M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200628 stolen_size = MB(320);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200629 break;
630 case SNB_GMCH_GMS_STOLEN_352M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200631 stolen_size = MB(352);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200632 break;
633 case SNB_GMCH_GMS_STOLEN_384M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200634 stolen_size = MB(384);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200635 break;
636 case SNB_GMCH_GMS_STOLEN_416M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200637 stolen_size = MB(416);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200638 break;
639 case SNB_GMCH_GMS_STOLEN_448M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200640 stolen_size = MB(448);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200641 break;
642 case SNB_GMCH_GMS_STOLEN_480M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200643 stolen_size = MB(480);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200644 break;
645 case SNB_GMCH_GMS_STOLEN_512M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200646 stolen_size = MB(512);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200647 break;
648 }
649 } else {
650 switch (gmch_ctrl & I855_GMCH_GMS_MASK) {
651 case I855_GMCH_GMS_STOLEN_1M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200652 stolen_size = MB(1);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200653 break;
654 case I855_GMCH_GMS_STOLEN_4M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200655 stolen_size = MB(4);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200656 break;
657 case I855_GMCH_GMS_STOLEN_8M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200658 stolen_size = MB(8);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200659 break;
660 case I855_GMCH_GMS_STOLEN_16M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200661 stolen_size = MB(16);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200662 break;
663 case I855_GMCH_GMS_STOLEN_32M:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200664 stolen_size = MB(32);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200665 break;
666 case I915_GMCH_GMS_STOLEN_48M:
Daniel Vetter77ad4982010-08-27 16:25:54 +0200667 stolen_size = MB(48);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200668 break;
669 case I915_GMCH_GMS_STOLEN_64M:
Daniel Vetter77ad4982010-08-27 16:25:54 +0200670 stolen_size = MB(64);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200671 break;
672 case G33_GMCH_GMS_STOLEN_128M:
Daniel Vetter77ad4982010-08-27 16:25:54 +0200673 stolen_size = MB(128);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200674 break;
675 case G33_GMCH_GMS_STOLEN_256M:
Daniel Vetter77ad4982010-08-27 16:25:54 +0200676 stolen_size = MB(256);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200677 break;
678 case INTEL_GMCH_GMS_STOLEN_96M:
Daniel Vetter77ad4982010-08-27 16:25:54 +0200679 stolen_size = MB(96);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200680 break;
681 case INTEL_GMCH_GMS_STOLEN_160M:
Daniel Vetter77ad4982010-08-27 16:25:54 +0200682 stolen_size = MB(160);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200683 break;
684 case INTEL_GMCH_GMS_STOLEN_224M:
Daniel Vetter77ad4982010-08-27 16:25:54 +0200685 stolen_size = MB(224);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200686 break;
687 case INTEL_GMCH_GMS_STOLEN_352M:
Daniel Vetter77ad4982010-08-27 16:25:54 +0200688 stolen_size = MB(352);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200689 break;
690 default:
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200691 stolen_size = 0;
Daniel Vetterf51b7662010-04-14 00:29:52 +0200692 break;
693 }
694 }
Daniel Vetter1784a5f2010-09-08 21:01:04 +0200695
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200696 if (!local && stolen_size > intel_max_stolen) {
Daniel Vetterd7cca2f2010-08-24 23:06:19 +0200697 dev_info(&intel_private.bridge_dev->dev,
Jesse Barnesd1d6ca72010-07-08 09:22:46 -0700698 "detected %dK stolen memory, trimming to %dK\n",
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200699 stolen_size / KB(1), intel_max_stolen / KB(1));
700 stolen_size = intel_max_stolen;
701 } else if (stolen_size > 0) {
Daniel Vetterd7cca2f2010-08-24 23:06:19 +0200702 dev_info(&intel_private.bridge_dev->dev, "detected %dK %s memory\n",
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200703 stolen_size / KB(1), local ? "local" : "stolen");
Daniel Vetterf51b7662010-04-14 00:29:52 +0200704 } else {
Daniel Vetterd7cca2f2010-08-24 23:06:19 +0200705 dev_info(&intel_private.bridge_dev->dev,
Daniel Vetterf51b7662010-04-14 00:29:52 +0200706 "no pre-allocated video memory detected\n");
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200707 stolen_size = 0;
Daniel Vetterf51b7662010-04-14 00:29:52 +0200708 }
709
Daniel Vetterd8d9abc2010-08-27 16:13:52 +0200710 stolen_entries = stolen_size/KB(4) - overhead_entries;
711
712 return stolen_entries;
Daniel Vetterf51b7662010-04-14 00:29:52 +0200713}
714
Daniel Vetterfbe40782010-08-27 17:12:41 +0200715static unsigned int intel_gtt_total_entries(void)
716{
717 int size;
Daniel Vetterfbe40782010-08-27 17:12:41 +0200718
Daniel Vetter210b23c2010-08-28 16:14:32 +0200719 if (IS_G33 || INTEL_GTT_GEN == 4 || INTEL_GTT_GEN == 5) {
Daniel Vetterfbe40782010-08-27 17:12:41 +0200720 u32 pgetbl_ctl;
721 pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL);
722
Daniel Vetterfbe40782010-08-27 17:12:41 +0200723 switch (pgetbl_ctl & I965_PGETBL_SIZE_MASK) {
724 case I965_PGETBL_SIZE_128KB:
Daniel Vettere5e408f2010-08-28 11:04:32 +0200725 size = KB(128);
Daniel Vetterfbe40782010-08-27 17:12:41 +0200726 break;
727 case I965_PGETBL_SIZE_256KB:
Daniel Vettere5e408f2010-08-28 11:04:32 +0200728 size = KB(256);
Daniel Vetterfbe40782010-08-27 17:12:41 +0200729 break;
730 case I965_PGETBL_SIZE_512KB:
Daniel Vettere5e408f2010-08-28 11:04:32 +0200731 size = KB(512);
Daniel Vetterfbe40782010-08-27 17:12:41 +0200732 break;
733 case I965_PGETBL_SIZE_1MB:
Daniel Vettere5e408f2010-08-28 11:04:32 +0200734 size = KB(1024);
Daniel Vetterfbe40782010-08-27 17:12:41 +0200735 break;
736 case I965_PGETBL_SIZE_2MB:
Daniel Vettere5e408f2010-08-28 11:04:32 +0200737 size = KB(2048);
Daniel Vetterfbe40782010-08-27 17:12:41 +0200738 break;
739 case I965_PGETBL_SIZE_1_5MB:
Daniel Vettere5e408f2010-08-28 11:04:32 +0200740 size = KB(1024 + 512);
Daniel Vetterfbe40782010-08-27 17:12:41 +0200741 break;
742 default:
743 dev_info(&intel_private.pcidev->dev,
744 "unknown page table size, assuming 512KB\n");
Daniel Vettere5e408f2010-08-28 11:04:32 +0200745 size = KB(512);
Daniel Vetterfbe40782010-08-27 17:12:41 +0200746 }
Daniel Vettere5e408f2010-08-28 11:04:32 +0200747
748 return size/4;
Daniel Vetter210b23c2010-08-28 16:14:32 +0200749 } else if (INTEL_GTT_GEN == 6) {
750 u16 snb_gmch_ctl;
751
752 pci_read_config_word(intel_private.pcidev, SNB_GMCH_CTRL, &snb_gmch_ctl);
753 switch (snb_gmch_ctl & SNB_GTT_SIZE_MASK) {
754 default:
755 case SNB_GTT_SIZE_0M:
756 printk(KERN_ERR "Bad GTT size mask: 0x%04x.\n", snb_gmch_ctl);
757 size = MB(0);
758 break;
759 case SNB_GTT_SIZE_1M:
760 size = MB(1);
761 break;
762 case SNB_GTT_SIZE_2M:
763 size = MB(2);
764 break;
765 }
766 return size/4;
Daniel Vetterfbe40782010-08-27 17:12:41 +0200767 } else {
768 /* On previous hardware, the GTT size was just what was
769 * required to map the aperture.
770 */
Daniel Vettere5e408f2010-08-28 11:04:32 +0200771 return intel_private.base.gtt_mappable_entries;
Daniel Vetterfbe40782010-08-27 17:12:41 +0200772 }
Daniel Vetterfbe40782010-08-27 17:12:41 +0200773}
Daniel Vetterfbe40782010-08-27 17:12:41 +0200774
Daniel Vetter1784a5f2010-09-08 21:01:04 +0200775static unsigned int intel_gtt_mappable_entries(void)
776{
777 unsigned int aperture_size;
778 u16 gmch_ctrl;
779
780 aperture_size = 1024 * 1024;
781
782 pci_read_config_word(intel_private.bridge_dev,
783 I830_GMCH_CTRL, &gmch_ctrl);
784
785 switch (intel_private.pcidev->device) {
786 case PCI_DEVICE_ID_INTEL_82830_CGC:
787 case PCI_DEVICE_ID_INTEL_82845G_IG:
788 case PCI_DEVICE_ID_INTEL_82855GM_IG:
789 case PCI_DEVICE_ID_INTEL_82865_IG:
790 if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_64M)
791 aperture_size *= 64;
792 else
793 aperture_size *= 128;
794 break;
795 default:
796 /* 9xx supports large sizes, just look at the length */
797 aperture_size = pci_resource_len(intel_private.pcidev, 2);
798 break;
799 }
800
801 return aperture_size >> PAGE_SHIFT;
802}
803
804static int intel_gtt_init(void)
805{
Daniel Vetterf67eab62010-08-29 17:27:36 +0200806 u32 gtt_map_size;
807
808 intel_private.base.gtt_mappable_entries = intel_gtt_mappable_entries();
809 intel_private.base.gtt_total_entries = intel_gtt_total_entries();
810
811 gtt_map_size = intel_private.base.gtt_total_entries * 4;
812
813 intel_private.gtt = ioremap(intel_private.gtt_bus_addr,
814 gtt_map_size);
815 if (!intel_private.gtt) {
816 iounmap(intel_private.registers);
817 return -ENOMEM;
818 }
819
820 global_cache_flush(); /* FIXME: ? */
821
Daniel Vetter1784a5f2010-09-08 21:01:04 +0200822 /* we have to call this as early as possible after the MMIO base address is known */
823 intel_private.base.gtt_stolen_entries = intel_gtt_stolen_entries();
824 if (intel_private.base.gtt_stolen_entries == 0) {
825 iounmap(intel_private.registers);
Daniel Vetterf67eab62010-08-29 17:27:36 +0200826 iounmap(intel_private.gtt);
Daniel Vetter1784a5f2010-09-08 21:01:04 +0200827 return -ENOMEM;
828 }
829
830 return 0;
831}
832
Daniel Vetter3e921f92010-08-27 15:33:26 +0200833static int intel_fake_agp_fetch_size(void)
834{
835 unsigned int aper_size;
836 int i;
Daniel Vetterffdd7512010-08-27 17:51:29 +0200837 int num_sizes = ARRAY_SIZE(intel_fake_agp_sizes);
Daniel Vetter3e921f92010-08-27 15:33:26 +0200838
839 aper_size = (intel_private.base.gtt_mappable_entries << PAGE_SHIFT)
840 / MB(1);
841
842 for (i = 0; i < num_sizes; i++) {
Daniel Vetterffdd7512010-08-27 17:51:29 +0200843 if (aper_size == intel_fake_agp_sizes[i].size) {
844 agp_bridge->current_size = intel_fake_agp_sizes + i;
Daniel Vetter3e921f92010-08-27 15:33:26 +0200845 return aper_size;
846 }
847 }
848
849 return 0;
850}
851
Daniel Vetterf51b7662010-04-14 00:29:52 +0200852static void intel_i830_fini_flush(void)
853{
854 kunmap(intel_private.i8xx_page);
855 intel_private.i8xx_flush_page = NULL;
856 unmap_page_from_agp(intel_private.i8xx_page);
857
858 __free_page(intel_private.i8xx_page);
859 intel_private.i8xx_page = NULL;
860}
861
862static void intel_i830_setup_flush(void)
863{
864 /* return if we've already set the flush mechanism up */
865 if (intel_private.i8xx_page)
866 return;
867
868 intel_private.i8xx_page = alloc_page(GFP_KERNEL | __GFP_ZERO | GFP_DMA32);
869 if (!intel_private.i8xx_page)
870 return;
871
872 intel_private.i8xx_flush_page = kmap(intel_private.i8xx_page);
873 if (!intel_private.i8xx_flush_page)
874 intel_i830_fini_flush();
875}
876
877/* The chipset_flush interface needs to get data that has already been
878 * flushed out of the CPU all the way out to main memory, because the GPU
879 * doesn't snoop those buffers.
880 *
881 * The 8xx series doesn't have the same lovely interface for flushing the
882 * chipset write buffers that the later chips do. According to the 865
883 * specs, it's 64 octwords, or 1KB. So, to get those previous things in
884 * that buffer out, we just fill 1KB and clflush it out, on the assumption
885 * that it'll push whatever was in there out. It appears to work.
886 */
887static void intel_i830_chipset_flush(struct agp_bridge_data *bridge)
888{
889 unsigned int *pg = intel_private.i8xx_flush_page;
890
891 memset(pg, 0, 1024);
892
893 if (cpu_has_clflush)
894 clflush_cache_range(pg, 1024);
895 else if (wbinvd_on_all_cpus() != 0)
896 printk(KERN_ERR "Timed out waiting for cache flush.\n");
897}
898
Daniel Vetter73800422010-08-29 17:29:50 +0200899static void intel_enable_gtt(void)
900{
901 u32 ptetbl_addr, gma_addr;
902 u16 gmch_ctrl;
903
904 ptetbl_addr = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
905
906 pci_read_config_dword(intel_private.pcidev, I810_GMADDR, &gma_addr);
907 intel_private.gma_bus_addr = (gma_addr & PCI_BASE_ADDRESS_MEM_MASK);
908
909 pci_read_config_word(intel_private.bridge_dev, I830_GMCH_CTRL, &gmch_ctrl);
910 gmch_ctrl |= I830_GMCH_ENABLED;
911 pci_write_config_word(intel_private.bridge_dev, I830_GMCH_CTRL, gmch_ctrl);
912
913 writel(ptetbl_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL);
914 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
915}
916
917static int i830_setup(void)
918{
919 u32 reg_addr;
920
921 pci_read_config_dword(intel_private.pcidev, I810_MMADDR, &reg_addr);
922 reg_addr &= 0xfff80000;
923
924 intel_private.registers = ioremap(reg_addr, KB(64));
925 if (!intel_private.registers)
926 return -ENOMEM;
927
928 intel_private.gtt_bus_addr = reg_addr + I810_PTE_BASE;
929
930 intel_i830_setup_flush();
931
932 return 0;
933}
934
Daniel Vetterf51b7662010-04-14 00:29:52 +0200935/* The intel i830 automatically initializes the agp aperture during POST.
936 * Use the memory already set aside for in the GTT.
937 */
938static int intel_i830_create_gatt_table(struct agp_bridge_data *bridge)
939{
Daniel Vetter73800422010-08-29 17:29:50 +0200940 int ret;
Daniel Vetterf51b7662010-04-14 00:29:52 +0200941
Daniel Vetter73800422010-08-29 17:29:50 +0200942 ret = intel_private.driver->setup();
943 if (ret != 0)
944 return ret;
Daniel Vetterf51b7662010-04-14 00:29:52 +0200945
Daniel Vetter1784a5f2010-09-08 21:01:04 +0200946 ret = intel_gtt_init();
947 if (ret != 0)
948 return ret;
Daniel Vetterf51b7662010-04-14 00:29:52 +0200949
Daniel Vetter73800422010-08-29 17:29:50 +0200950 agp_bridge->gatt_table_real = NULL;
Daniel Vetterf51b7662010-04-14 00:29:52 +0200951 agp_bridge->gatt_table = NULL;
Daniel Vetter73800422010-08-29 17:29:50 +0200952 agp_bridge->gatt_bus_addr = 0;
Daniel Vetterf51b7662010-04-14 00:29:52 +0200953
954 return 0;
955}
956
957/* Return the gatt table to a sane state. Use the top of stolen
958 * memory for the GTT.
959 */
Daniel Vetterffdd7512010-08-27 17:51:29 +0200960static int intel_fake_agp_free_gatt_table(struct agp_bridge_data *bridge)
Daniel Vetterf51b7662010-04-14 00:29:52 +0200961{
962 return 0;
963}
964
Daniel Vetterf51b7662010-04-14 00:29:52 +0200965static int intel_i830_configure(void)
966{
Daniel Vetterf51b7662010-04-14 00:29:52 +0200967 int i;
968
Daniel Vetter73800422010-08-29 17:29:50 +0200969 intel_enable_gtt();
Daniel Vetterf51b7662010-04-14 00:29:52 +0200970
Daniel Vetter73800422010-08-29 17:29:50 +0200971 agp_bridge->gart_bus_addr = intel_private.gma_bus_addr;
Daniel Vetterf51b7662010-04-14 00:29:52 +0200972
973 if (agp_bridge->driver->needs_scratch_page) {
Daniel Vetter73800422010-08-29 17:29:50 +0200974 for (i = intel_private.base.gtt_stolen_entries;
975 i < intel_private.base.gtt_total_entries; i++) {
Daniel Vetterfdfb58a2010-08-29 00:15:03 +0200976 writel(agp_bridge->scratch_page, intel_private.gtt+i);
Daniel Vetterf51b7662010-04-14 00:29:52 +0200977 }
Daniel Vetterfdfb58a2010-08-29 00:15:03 +0200978 readl(intel_private.gtt+i-1); /* PCI Posting. */
Daniel Vetterf51b7662010-04-14 00:29:52 +0200979 }
980
981 global_cache_flush();
982
Daniel Vetterf51b7662010-04-14 00:29:52 +0200983 return 0;
984}
985
Daniel Vetterf51b7662010-04-14 00:29:52 +0200986static int intel_i830_insert_entries(struct agp_memory *mem, off_t pg_start,
987 int type)
988{
989 int i, j, num_entries;
990 void *temp;
991 int ret = -EINVAL;
992 int mask_type;
993
994 if (mem->page_count == 0)
995 goto out;
996
997 temp = agp_bridge->current_size;
998 num_entries = A_SIZE_FIX(temp)->num_entries;
999
Daniel Vetter0ade6382010-08-24 22:18:41 +02001000 if (pg_start < intel_private.base.gtt_stolen_entries) {
Daniel Vetterf51b7662010-04-14 00:29:52 +02001001 dev_printk(KERN_DEBUG, &intel_private.pcidev->dev,
Daniel Vetter0ade6382010-08-24 22:18:41 +02001002 "pg_start == 0x%.8lx, gtt_stolen_entries == 0x%.8x\n",
1003 pg_start, intel_private.base.gtt_stolen_entries);
Daniel Vetterf51b7662010-04-14 00:29:52 +02001004
1005 dev_info(&intel_private.pcidev->dev,
1006 "trying to insert into local/stolen memory\n");
1007 goto out_err;
1008 }
1009
1010 if ((pg_start + mem->page_count) > num_entries)
1011 goto out_err;
1012
1013 /* The i830 can't check the GTT for entries since its read only,
1014 * depend on the caller to make the correct offset decisions.
1015 */
1016
1017 if (type != mem->type)
1018 goto out_err;
1019
1020 mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
1021
1022 if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY &&
1023 mask_type != INTEL_AGP_CACHED_MEMORY)
1024 goto out_err;
1025
1026 if (!mem->is_flushed)
1027 global_cache_flush();
1028
1029 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
1030 writel(agp_bridge->driver->mask_memory(agp_bridge,
1031 page_to_phys(mem->pages[i]), mask_type),
Daniel Vetterfdfb58a2010-08-29 00:15:03 +02001032 intel_private.gtt+j);
Daniel Vetterf51b7662010-04-14 00:29:52 +02001033 }
Daniel Vetterfdfb58a2010-08-29 00:15:03 +02001034 readl(intel_private.gtt+j-1);
Daniel Vetterf51b7662010-04-14 00:29:52 +02001035
1036out:
1037 ret = 0;
1038out_err:
1039 mem->is_flushed = true;
1040 return ret;
1041}
1042
1043static int intel_i830_remove_entries(struct agp_memory *mem, off_t pg_start,
1044 int type)
1045{
1046 int i;
1047
1048 if (mem->page_count == 0)
1049 return 0;
1050
Daniel Vetter0ade6382010-08-24 22:18:41 +02001051 if (pg_start < intel_private.base.gtt_stolen_entries) {
Daniel Vetterf51b7662010-04-14 00:29:52 +02001052 dev_info(&intel_private.pcidev->dev,
1053 "trying to disable local/stolen memory\n");
1054 return -EINVAL;
1055 }
1056
1057 for (i = pg_start; i < (mem->page_count + pg_start); i++) {
Daniel Vetterfdfb58a2010-08-29 00:15:03 +02001058 writel(agp_bridge->scratch_page, intel_private.gtt+i);
Daniel Vetterf51b7662010-04-14 00:29:52 +02001059 }
Daniel Vetterfdfb58a2010-08-29 00:15:03 +02001060 readl(intel_private.gtt+i-1);
Daniel Vetterf51b7662010-04-14 00:29:52 +02001061
Daniel Vetterf51b7662010-04-14 00:29:52 +02001062 return 0;
1063}
1064
Daniel Vetterffdd7512010-08-27 17:51:29 +02001065static struct agp_memory *intel_fake_agp_alloc_by_type(size_t pg_count,
1066 int type)
Daniel Vetterf51b7662010-04-14 00:29:52 +02001067{
1068 if (type == AGP_PHYS_MEMORY)
1069 return alloc_agpphysmem_i8xx(pg_count, type);
1070 /* always return NULL for other allocation types for now */
1071 return NULL;
1072}
1073
1074static int intel_alloc_chipset_flush_resource(void)
1075{
1076 int ret;
Daniel Vetterd7cca2f2010-08-24 23:06:19 +02001077 ret = pci_bus_alloc_resource(intel_private.bridge_dev->bus, &intel_private.ifp_resource, PAGE_SIZE,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001078 PAGE_SIZE, PCIBIOS_MIN_MEM, 0,
Daniel Vetterd7cca2f2010-08-24 23:06:19 +02001079 pcibios_align_resource, intel_private.bridge_dev);
Daniel Vetterf51b7662010-04-14 00:29:52 +02001080
1081 return ret;
1082}
1083
1084static void intel_i915_setup_chipset_flush(void)
1085{
1086 int ret;
1087 u32 temp;
1088
Daniel Vetterd7cca2f2010-08-24 23:06:19 +02001089 pci_read_config_dword(intel_private.bridge_dev, I915_IFPADDR, &temp);
Daniel Vetterf51b7662010-04-14 00:29:52 +02001090 if (!(temp & 0x1)) {
1091 intel_alloc_chipset_flush_resource();
1092 intel_private.resource_valid = 1;
Daniel Vetterd7cca2f2010-08-24 23:06:19 +02001093 pci_write_config_dword(intel_private.bridge_dev, I915_IFPADDR, (intel_private.ifp_resource.start & 0xffffffff) | 0x1);
Daniel Vetterf51b7662010-04-14 00:29:52 +02001094 } else {
1095 temp &= ~1;
1096
1097 intel_private.resource_valid = 1;
1098 intel_private.ifp_resource.start = temp;
1099 intel_private.ifp_resource.end = temp + PAGE_SIZE;
1100 ret = request_resource(&iomem_resource, &intel_private.ifp_resource);
1101 /* some BIOSes reserve this area in a pnp some don't */
1102 if (ret)
1103 intel_private.resource_valid = 0;
1104 }
1105}
1106
1107static void intel_i965_g33_setup_chipset_flush(void)
1108{
1109 u32 temp_hi, temp_lo;
1110 int ret;
1111
Daniel Vetterd7cca2f2010-08-24 23:06:19 +02001112 pci_read_config_dword(intel_private.bridge_dev, I965_IFPADDR + 4, &temp_hi);
1113 pci_read_config_dword(intel_private.bridge_dev, I965_IFPADDR, &temp_lo);
Daniel Vetterf51b7662010-04-14 00:29:52 +02001114
1115 if (!(temp_lo & 0x1)) {
1116
1117 intel_alloc_chipset_flush_resource();
1118
1119 intel_private.resource_valid = 1;
Daniel Vetterd7cca2f2010-08-24 23:06:19 +02001120 pci_write_config_dword(intel_private.bridge_dev, I965_IFPADDR + 4,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001121 upper_32_bits(intel_private.ifp_resource.start));
Daniel Vetterd7cca2f2010-08-24 23:06:19 +02001122 pci_write_config_dword(intel_private.bridge_dev, I965_IFPADDR, (intel_private.ifp_resource.start & 0xffffffff) | 0x1);
Daniel Vetterf51b7662010-04-14 00:29:52 +02001123 } else {
1124 u64 l64;
1125
1126 temp_lo &= ~0x1;
1127 l64 = ((u64)temp_hi << 32) | temp_lo;
1128
1129 intel_private.resource_valid = 1;
1130 intel_private.ifp_resource.start = l64;
1131 intel_private.ifp_resource.end = l64 + PAGE_SIZE;
1132 ret = request_resource(&iomem_resource, &intel_private.ifp_resource);
1133 /* some BIOSes reserve this area in a pnp some don't */
1134 if (ret)
1135 intel_private.resource_valid = 0;
1136 }
1137}
1138
1139static void intel_i9xx_setup_flush(void)
1140{
1141 /* return if already configured */
1142 if (intel_private.ifp_resource.start)
1143 return;
1144
Daniel Vetter1a997ff2010-09-08 21:18:53 +02001145 if (INTEL_GTT_GEN == 6)
Daniel Vetterf51b7662010-04-14 00:29:52 +02001146 return;
1147
1148 /* setup a resource for this object */
1149 intel_private.ifp_resource.name = "Intel Flush Page";
1150 intel_private.ifp_resource.flags = IORESOURCE_MEM;
1151
1152 /* Setup chipset flush for 915 */
Daniel Vetter1a997ff2010-09-08 21:18:53 +02001153 if (IS_G33 || INTEL_GTT_GEN >= 4) {
Daniel Vetterf51b7662010-04-14 00:29:52 +02001154 intel_i965_g33_setup_chipset_flush();
1155 } else {
1156 intel_i915_setup_chipset_flush();
1157 }
1158
Chris Wilsondf51e7a2010-09-04 14:57:27 +01001159 if (intel_private.ifp_resource.start)
Daniel Vetterf51b7662010-04-14 00:29:52 +02001160 intel_private.i9xx_flush_page = ioremap_nocache(intel_private.ifp_resource.start, PAGE_SIZE);
Chris Wilsondf51e7a2010-09-04 14:57:27 +01001161 if (!intel_private.i9xx_flush_page)
1162 dev_err(&intel_private.pcidev->dev,
1163 "can't ioremap flush page - no chipset flushing\n");
Daniel Vetterf51b7662010-04-14 00:29:52 +02001164}
1165
Chris Wilsonf1befe72010-05-18 12:24:51 +01001166static int intel_i9xx_configure(void)
Daniel Vetterf51b7662010-04-14 00:29:52 +02001167{
1168 struct aper_size_info_fixed *current_size;
1169 u32 temp;
1170 u16 gmch_ctrl;
1171 int i;
1172
1173 current_size = A_SIZE_FIX(agp_bridge->current_size);
1174
1175 pci_read_config_dword(intel_private.pcidev, I915_GMADDR, &temp);
1176
1177 agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK);
1178
Daniel Vetterd7cca2f2010-08-24 23:06:19 +02001179 pci_read_config_word(intel_private.bridge_dev, I830_GMCH_CTRL, &gmch_ctrl);
Daniel Vetterf51b7662010-04-14 00:29:52 +02001180 gmch_ctrl |= I830_GMCH_ENABLED;
Daniel Vetterd7cca2f2010-08-24 23:06:19 +02001181 pci_write_config_word(intel_private.bridge_dev, I830_GMCH_CTRL, gmch_ctrl);
Daniel Vetterf51b7662010-04-14 00:29:52 +02001182
1183 writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL);
1184 readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */
1185
1186 if (agp_bridge->driver->needs_scratch_page) {
Daniel Vetter0ade6382010-08-24 22:18:41 +02001187 for (i = intel_private.base.gtt_stolen_entries; i <
1188 intel_private.base.gtt_total_entries; i++) {
Daniel Vetterf51b7662010-04-14 00:29:52 +02001189 writel(agp_bridge->scratch_page, intel_private.gtt+i);
1190 }
1191 readl(intel_private.gtt+i-1); /* PCI Posting. */
1192 }
1193
1194 global_cache_flush();
1195
1196 intel_i9xx_setup_flush();
1197
1198 return 0;
1199}
1200
Daniel Vetterfdfb58a2010-08-29 00:15:03 +02001201static void intel_gtt_cleanup(void)
Daniel Vetterf51b7662010-04-14 00:29:52 +02001202{
1203 if (intel_private.i9xx_flush_page)
1204 iounmap(intel_private.i9xx_flush_page);
1205 if (intel_private.resource_valid)
1206 release_resource(&intel_private.ifp_resource);
1207 intel_private.ifp_resource.start = 0;
1208 intel_private.resource_valid = 0;
1209 iounmap(intel_private.gtt);
1210 iounmap(intel_private.registers);
1211}
1212
1213static void intel_i915_chipset_flush(struct agp_bridge_data *bridge)
1214{
1215 if (intel_private.i9xx_flush_page)
1216 writel(1, intel_private.i9xx_flush_page);
1217}
1218
1219static int intel_i915_insert_entries(struct agp_memory *mem, off_t pg_start,
1220 int type)
1221{
1222 int num_entries;
1223 void *temp;
1224 int ret = -EINVAL;
1225 int mask_type;
1226
1227 if (mem->page_count == 0)
1228 goto out;
1229
1230 temp = agp_bridge->current_size;
1231 num_entries = A_SIZE_FIX(temp)->num_entries;
1232
Daniel Vetter0ade6382010-08-24 22:18:41 +02001233 if (pg_start < intel_private.base.gtt_stolen_entries) {
Daniel Vetterf51b7662010-04-14 00:29:52 +02001234 dev_printk(KERN_DEBUG, &intel_private.pcidev->dev,
Daniel Vetter0ade6382010-08-24 22:18:41 +02001235 "pg_start == 0x%.8lx, gtt_stolen_entries == 0x%.8x\n",
1236 pg_start, intel_private.base.gtt_stolen_entries);
Daniel Vetterf51b7662010-04-14 00:29:52 +02001237
1238 dev_info(&intel_private.pcidev->dev,
1239 "trying to insert into local/stolen memory\n");
1240 goto out_err;
1241 }
1242
1243 if ((pg_start + mem->page_count) > num_entries)
1244 goto out_err;
1245
1246 /* The i915 can't check the GTT for entries since it's read only;
1247 * depend on the caller to make the correct offset decisions.
1248 */
1249
1250 if (type != mem->type)
1251 goto out_err;
1252
1253 mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
1254
Daniel Vetter1a997ff2010-09-08 21:18:53 +02001255 if (INTEL_GTT_GEN != 6 && mask_type != 0 &&
1256 mask_type != AGP_PHYS_MEMORY &&
Daniel Vetterf51b7662010-04-14 00:29:52 +02001257 mask_type != INTEL_AGP_CACHED_MEMORY)
1258 goto out_err;
1259
1260 if (!mem->is_flushed)
1261 global_cache_flush();
1262
1263 intel_agp_insert_sg_entries(mem, pg_start, mask_type);
Daniel Vetterf51b7662010-04-14 00:29:52 +02001264
1265 out:
1266 ret = 0;
1267 out_err:
1268 mem->is_flushed = true;
1269 return ret;
1270}
1271
1272static int intel_i915_remove_entries(struct agp_memory *mem, off_t pg_start,
1273 int type)
1274{
1275 int i;
1276
1277 if (mem->page_count == 0)
1278 return 0;
1279
Daniel Vetter0ade6382010-08-24 22:18:41 +02001280 if (pg_start < intel_private.base.gtt_stolen_entries) {
Daniel Vetterf51b7662010-04-14 00:29:52 +02001281 dev_info(&intel_private.pcidev->dev,
1282 "trying to disable local/stolen memory\n");
1283 return -EINVAL;
1284 }
1285
1286 for (i = pg_start; i < (mem->page_count + pg_start); i++)
1287 writel(agp_bridge->scratch_page, intel_private.gtt+i);
1288
1289 readl(intel_private.gtt+i-1);
1290
Daniel Vetterf51b7662010-04-14 00:29:52 +02001291 return 0;
1292}
1293
Daniel Vetterf51b7662010-04-14 00:29:52 +02001294/* The intel i915 automatically initializes the agp aperture during POST.
1295 * Use the memory already set aside for in the GTT.
1296 */
1297static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge)
1298{
Daniel Vetter1784a5f2010-09-08 21:01:04 +02001299 int page_order, ret;
Daniel Vetterf51b7662010-04-14 00:29:52 +02001300 struct aper_size_info_fixed *size;
1301 int num_entries;
1302 u32 temp, temp2;
Daniel Vetterf51b7662010-04-14 00:29:52 +02001303
1304 size = agp_bridge->current_size;
1305 page_order = size->page_order;
1306 num_entries = size->num_entries;
1307 agp_bridge->gatt_table_real = NULL;
1308
1309 pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &temp);
1310 pci_read_config_dword(intel_private.pcidev, I915_PTEADDR, &temp2);
1311
Daniel Vetterf51b7662010-04-14 00:29:52 +02001312 temp &= 0xfff80000;
1313
1314 intel_private.registers = ioremap(temp, 128 * 4096);
Daniel Vetterccc4e672010-09-08 21:20:12 +02001315 if (!intel_private.registers)
1316 return -ENOMEM;
1317
Daniel Vetterf67eab62010-08-29 17:27:36 +02001318 intel_private.gtt_bus_addr = temp2;
Daniel Vetterf51b7662010-04-14 00:29:52 +02001319 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
Daniel Vetterf51b7662010-04-14 00:29:52 +02001320
Daniel Vetter1784a5f2010-09-08 21:01:04 +02001321 ret = intel_gtt_init();
Daniel Vetterf67eab62010-08-29 17:27:36 +02001322 if (ret != 0)
Daniel Vetter1784a5f2010-09-08 21:01:04 +02001323 return ret;
Daniel Vetterf51b7662010-04-14 00:29:52 +02001324
1325 agp_bridge->gatt_table = NULL;
1326
1327 agp_bridge->gatt_bus_addr = temp;
1328
1329 return 0;
1330}
1331
1332/*
1333 * The i965 supports 36-bit physical addresses, but to keep
1334 * the format of the GTT the same, the bits that don't fit
1335 * in a 32-bit word are shifted down to bits 4..7.
1336 *
1337 * Gcc is smart enough to notice that "(addr >> 28) & 0xf0"
1338 * is always zero on 32-bit architectures, so no need to make
1339 * this conditional.
1340 */
1341static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge,
1342 dma_addr_t addr, int type)
1343{
1344 /* Shift high bits down */
1345 addr |= (addr >> 28) & 0xf0;
1346
1347 /* Type checking must be done elsewhere */
1348 return addr | bridge->driver->masks[type].mask;
1349}
1350
Zhenyu Wang3869d4a2010-07-09 10:40:58 -07001351static unsigned long intel_gen6_mask_memory(struct agp_bridge_data *bridge,
1352 dma_addr_t addr, int type)
1353{
Zhenyu Wang8dfc2b12010-08-23 14:37:52 +08001354 /* gen6 has bit11-4 for physical addr bit39-32 */
1355 addr |= (addr >> 28) & 0xff0;
Zhenyu Wang3869d4a2010-07-09 10:40:58 -07001356
1357 /* Type checking must be done elsewhere */
1358 return addr | bridge->driver->masks[type].mask;
1359}
1360
Daniel Vetterf67eab62010-08-29 17:27:36 +02001361static void intel_i965_get_gtt_range(int *gtt_offset)
Daniel Vetterf51b7662010-04-14 00:29:52 +02001362{
Daniel Vetter210b23c2010-08-28 16:14:32 +02001363 switch (INTEL_GTT_GEN) {
1364 case 5:
1365 case 6:
Daniel Vetterf51b7662010-04-14 00:29:52 +02001366 *gtt_offset = MB(2);
Daniel Vetterf51b7662010-04-14 00:29:52 +02001367 break;
Daniel Vetter210b23c2010-08-28 16:14:32 +02001368 case 4:
Daniel Vetterf51b7662010-04-14 00:29:52 +02001369 default:
Daniel Vetter210b23c2010-08-28 16:14:32 +02001370 *gtt_offset = KB(512);
1371 break;
Daniel Vetterf51b7662010-04-14 00:29:52 +02001372 }
1373}
1374
1375/* The intel i965 automatically initializes the agp aperture during POST.
1376 * Use the memory already set aside for in the GTT.
1377 */
1378static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge)
1379{
Daniel Vetter1784a5f2010-09-08 21:01:04 +02001380 int page_order, ret;
Daniel Vetterf51b7662010-04-14 00:29:52 +02001381 struct aper_size_info_fixed *size;
1382 int num_entries;
1383 u32 temp;
Daniel Vetterf67eab62010-08-29 17:27:36 +02001384 int gtt_offset;
Daniel Vetterf51b7662010-04-14 00:29:52 +02001385
1386 size = agp_bridge->current_size;
1387 page_order = size->page_order;
1388 num_entries = size->num_entries;
1389 agp_bridge->gatt_table_real = NULL;
1390
1391 pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &temp);
1392
1393 temp &= 0xfff00000;
1394
Daniel Vetter210b23c2010-08-28 16:14:32 +02001395 intel_private.registers = ioremap(temp, 128 * 4096);
1396 if (!intel_private.registers)
1397 return -ENOMEM;
1398
Daniel Vetterf67eab62010-08-29 17:27:36 +02001399 intel_i965_get_gtt_range(&gtt_offset);
1400 intel_private.gtt_bus_addr = temp + gtt_offset;
Daniel Vetterf51b7662010-04-14 00:29:52 +02001401 temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
Daniel Vetterf51b7662010-04-14 00:29:52 +02001402
Daniel Vetter1784a5f2010-09-08 21:01:04 +02001403 ret = intel_gtt_init();
Daniel Vetterf67eab62010-08-29 17:27:36 +02001404 if (ret != 0)
Daniel Vetter1784a5f2010-09-08 21:01:04 +02001405 return ret;
Daniel Vetterf51b7662010-04-14 00:29:52 +02001406
1407 agp_bridge->gatt_table = NULL;
1408
1409 agp_bridge->gatt_bus_addr = temp;
1410
1411 return 0;
1412}
1413
1414static const struct agp_bridge_driver intel_810_driver = {
1415 .owner = THIS_MODULE,
1416 .aperture_sizes = intel_i810_sizes,
1417 .size_type = FIXED_APER_SIZE,
1418 .num_aperture_sizes = 2,
1419 .needs_scratch_page = true,
1420 .configure = intel_i810_configure,
1421 .fetch_size = intel_i810_fetch_size,
1422 .cleanup = intel_i810_cleanup,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001423 .mask_memory = intel_i810_mask_memory,
1424 .masks = intel_i810_masks,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001425 .agp_enable = intel_fake_agp_enable,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001426 .cache_flush = global_cache_flush,
1427 .create_gatt_table = agp_generic_create_gatt_table,
1428 .free_gatt_table = agp_generic_free_gatt_table,
1429 .insert_memory = intel_i810_insert_entries,
1430 .remove_memory = intel_i810_remove_entries,
1431 .alloc_by_type = intel_i810_alloc_by_type,
1432 .free_by_type = intel_i810_free_by_type,
1433 .agp_alloc_page = agp_generic_alloc_page,
1434 .agp_alloc_pages = agp_generic_alloc_pages,
1435 .agp_destroy_page = agp_generic_destroy_page,
1436 .agp_destroy_pages = agp_generic_destroy_pages,
1437 .agp_type_to_mask_type = agp_generic_type_to_mask_type,
1438};
1439
1440static const struct agp_bridge_driver intel_830_driver = {
1441 .owner = THIS_MODULE,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001442 .aperture_sizes = intel_fake_agp_sizes,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001443 .size_type = FIXED_APER_SIZE,
1444 .num_aperture_sizes = 4,
1445 .needs_scratch_page = true,
1446 .configure = intel_i830_configure,
Daniel Vetter3e921f92010-08-27 15:33:26 +02001447 .fetch_size = intel_fake_agp_fetch_size,
Daniel Vetterfdfb58a2010-08-29 00:15:03 +02001448 .cleanup = intel_gtt_cleanup,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001449 .mask_memory = intel_i810_mask_memory,
1450 .masks = intel_i810_masks,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001451 .agp_enable = intel_fake_agp_enable,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001452 .cache_flush = global_cache_flush,
1453 .create_gatt_table = intel_i830_create_gatt_table,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001454 .free_gatt_table = intel_fake_agp_free_gatt_table,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001455 .insert_memory = intel_i830_insert_entries,
1456 .remove_memory = intel_i830_remove_entries,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001457 .alloc_by_type = intel_fake_agp_alloc_by_type,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001458 .free_by_type = intel_i810_free_by_type,
1459 .agp_alloc_page = agp_generic_alloc_page,
1460 .agp_alloc_pages = agp_generic_alloc_pages,
1461 .agp_destroy_page = agp_generic_destroy_page,
1462 .agp_destroy_pages = agp_generic_destroy_pages,
1463 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
1464 .chipset_flush = intel_i830_chipset_flush,
1465};
1466
1467static const struct agp_bridge_driver intel_915_driver = {
1468 .owner = THIS_MODULE,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001469 .aperture_sizes = intel_fake_agp_sizes,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001470 .size_type = FIXED_APER_SIZE,
1471 .num_aperture_sizes = 4,
1472 .needs_scratch_page = true,
Chris Wilsonf1befe72010-05-18 12:24:51 +01001473 .configure = intel_i9xx_configure,
Daniel Vetter3e921f92010-08-27 15:33:26 +02001474 .fetch_size = intel_fake_agp_fetch_size,
Daniel Vetterfdfb58a2010-08-29 00:15:03 +02001475 .cleanup = intel_gtt_cleanup,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001476 .mask_memory = intel_i810_mask_memory,
1477 .masks = intel_i810_masks,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001478 .agp_enable = intel_fake_agp_enable,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001479 .cache_flush = global_cache_flush,
1480 .create_gatt_table = intel_i915_create_gatt_table,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001481 .free_gatt_table = intel_fake_agp_free_gatt_table,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001482 .insert_memory = intel_i915_insert_entries,
1483 .remove_memory = intel_i915_remove_entries,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001484 .alloc_by_type = intel_fake_agp_alloc_by_type,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001485 .free_by_type = intel_i810_free_by_type,
1486 .agp_alloc_page = agp_generic_alloc_page,
1487 .agp_alloc_pages = agp_generic_alloc_pages,
1488 .agp_destroy_page = agp_generic_destroy_page,
1489 .agp_destroy_pages = agp_generic_destroy_pages,
1490 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
1491 .chipset_flush = intel_i915_chipset_flush,
1492#ifdef USE_PCI_DMA_API
1493 .agp_map_page = intel_agp_map_page,
1494 .agp_unmap_page = intel_agp_unmap_page,
1495 .agp_map_memory = intel_agp_map_memory,
1496 .agp_unmap_memory = intel_agp_unmap_memory,
1497#endif
1498};
1499
1500static const struct agp_bridge_driver intel_i965_driver = {
1501 .owner = THIS_MODULE,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001502 .aperture_sizes = intel_fake_agp_sizes,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001503 .size_type = FIXED_APER_SIZE,
1504 .num_aperture_sizes = 4,
1505 .needs_scratch_page = true,
Chris Wilsonf1befe72010-05-18 12:24:51 +01001506 .configure = intel_i9xx_configure,
Daniel Vetter3e921f92010-08-27 15:33:26 +02001507 .fetch_size = intel_fake_agp_fetch_size,
Daniel Vetterfdfb58a2010-08-29 00:15:03 +02001508 .cleanup = intel_gtt_cleanup,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001509 .mask_memory = intel_i965_mask_memory,
1510 .masks = intel_i810_masks,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001511 .agp_enable = intel_fake_agp_enable,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001512 .cache_flush = global_cache_flush,
1513 .create_gatt_table = intel_i965_create_gatt_table,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001514 .free_gatt_table = intel_fake_agp_free_gatt_table,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001515 .insert_memory = intel_i915_insert_entries,
1516 .remove_memory = intel_i915_remove_entries,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001517 .alloc_by_type = intel_fake_agp_alloc_by_type,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001518 .free_by_type = intel_i810_free_by_type,
1519 .agp_alloc_page = agp_generic_alloc_page,
1520 .agp_alloc_pages = agp_generic_alloc_pages,
1521 .agp_destroy_page = agp_generic_destroy_page,
1522 .agp_destroy_pages = agp_generic_destroy_pages,
1523 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
1524 .chipset_flush = intel_i915_chipset_flush,
1525#ifdef USE_PCI_DMA_API
1526 .agp_map_page = intel_agp_map_page,
1527 .agp_unmap_page = intel_agp_unmap_page,
1528 .agp_map_memory = intel_agp_map_memory,
1529 .agp_unmap_memory = intel_agp_unmap_memory,
1530#endif
1531};
1532
Zhenyu Wang3869d4a2010-07-09 10:40:58 -07001533static const struct agp_bridge_driver intel_gen6_driver = {
1534 .owner = THIS_MODULE,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001535 .aperture_sizes = intel_fake_agp_sizes,
Zhenyu Wang3869d4a2010-07-09 10:40:58 -07001536 .size_type = FIXED_APER_SIZE,
1537 .num_aperture_sizes = 4,
1538 .needs_scratch_page = true,
1539 .configure = intel_i9xx_configure,
Daniel Vetter3e921f92010-08-27 15:33:26 +02001540 .fetch_size = intel_fake_agp_fetch_size,
Daniel Vetterfdfb58a2010-08-29 00:15:03 +02001541 .cleanup = intel_gtt_cleanup,
Zhenyu Wang3869d4a2010-07-09 10:40:58 -07001542 .mask_memory = intel_gen6_mask_memory,
Zhenyu Wangf8f235e2010-08-27 11:08:57 +08001543 .masks = intel_gen6_masks,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001544 .agp_enable = intel_fake_agp_enable,
Zhenyu Wang3869d4a2010-07-09 10:40:58 -07001545 .cache_flush = global_cache_flush,
1546 .create_gatt_table = intel_i965_create_gatt_table,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001547 .free_gatt_table = intel_fake_agp_free_gatt_table,
Zhenyu Wang3869d4a2010-07-09 10:40:58 -07001548 .insert_memory = intel_i915_insert_entries,
1549 .remove_memory = intel_i915_remove_entries,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001550 .alloc_by_type = intel_fake_agp_alloc_by_type,
Zhenyu Wang3869d4a2010-07-09 10:40:58 -07001551 .free_by_type = intel_i810_free_by_type,
1552 .agp_alloc_page = agp_generic_alloc_page,
1553 .agp_alloc_pages = agp_generic_alloc_pages,
1554 .agp_destroy_page = agp_generic_destroy_page,
1555 .agp_destroy_pages = agp_generic_destroy_pages,
Zhenyu Wangf8f235e2010-08-27 11:08:57 +08001556 .agp_type_to_mask_type = intel_gen6_type_to_mask_type,
Zhenyu Wang3869d4a2010-07-09 10:40:58 -07001557 .chipset_flush = intel_i915_chipset_flush,
1558#ifdef USE_PCI_DMA_API
1559 .agp_map_page = intel_agp_map_page,
1560 .agp_unmap_page = intel_agp_unmap_page,
1561 .agp_map_memory = intel_agp_map_memory,
1562 .agp_unmap_memory = intel_agp_unmap_memory,
1563#endif
1564};
1565
Daniel Vetterf51b7662010-04-14 00:29:52 +02001566static const struct agp_bridge_driver intel_g33_driver = {
1567 .owner = THIS_MODULE,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001568 .aperture_sizes = intel_fake_agp_sizes,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001569 .size_type = FIXED_APER_SIZE,
1570 .num_aperture_sizes = 4,
1571 .needs_scratch_page = true,
Chris Wilsonf1befe72010-05-18 12:24:51 +01001572 .configure = intel_i9xx_configure,
Daniel Vetter3e921f92010-08-27 15:33:26 +02001573 .fetch_size = intel_fake_agp_fetch_size,
Daniel Vetterfdfb58a2010-08-29 00:15:03 +02001574 .cleanup = intel_gtt_cleanup,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001575 .mask_memory = intel_i965_mask_memory,
1576 .masks = intel_i810_masks,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001577 .agp_enable = intel_fake_agp_enable,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001578 .cache_flush = global_cache_flush,
1579 .create_gatt_table = intel_i915_create_gatt_table,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001580 .free_gatt_table = intel_fake_agp_free_gatt_table,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001581 .insert_memory = intel_i915_insert_entries,
1582 .remove_memory = intel_i915_remove_entries,
Daniel Vetterffdd7512010-08-27 17:51:29 +02001583 .alloc_by_type = intel_fake_agp_alloc_by_type,
Daniel Vetterf51b7662010-04-14 00:29:52 +02001584 .free_by_type = intel_i810_free_by_type,
1585 .agp_alloc_page = agp_generic_alloc_page,
1586 .agp_alloc_pages = agp_generic_alloc_pages,
1587 .agp_destroy_page = agp_generic_destroy_page,
1588 .agp_destroy_pages = agp_generic_destroy_pages,
1589 .agp_type_to_mask_type = intel_i830_type_to_mask_type,
1590 .chipset_flush = intel_i915_chipset_flush,
1591#ifdef USE_PCI_DMA_API
1592 .agp_map_page = intel_agp_map_page,
1593 .agp_unmap_page = intel_agp_unmap_page,
1594 .agp_map_memory = intel_agp_map_memory,
1595 .agp_unmap_memory = intel_agp_unmap_memory,
1596#endif
1597};
Daniel Vetter02c026c2010-08-24 19:39:48 +02001598
Daniel Vetter1a997ff2010-09-08 21:18:53 +02001599static const struct intel_gtt_driver i8xx_gtt_driver = {
1600 .gen = 2,
Daniel Vetter73800422010-08-29 17:29:50 +02001601 .setup = i830_setup,
Daniel Vetter1a997ff2010-09-08 21:18:53 +02001602};
1603static const struct intel_gtt_driver i915_gtt_driver = {
1604 .gen = 3,
1605};
1606static const struct intel_gtt_driver g33_gtt_driver = {
1607 .gen = 3,
1608 .is_g33 = 1,
1609};
1610static const struct intel_gtt_driver pineview_gtt_driver = {
1611 .gen = 3,
1612 .is_pineview = 1, .is_g33 = 1,
1613};
1614static const struct intel_gtt_driver i965_gtt_driver = {
1615 .gen = 4,
1616};
1617static const struct intel_gtt_driver g4x_gtt_driver = {
1618 .gen = 5,
1619};
1620static const struct intel_gtt_driver ironlake_gtt_driver = {
1621 .gen = 5,
1622 .is_ironlake = 1,
1623};
1624static const struct intel_gtt_driver sandybridge_gtt_driver = {
1625 .gen = 6,
1626};
1627
Daniel Vetter02c026c2010-08-24 19:39:48 +02001628/* Table to describe Intel GMCH and AGP/PCIE GART drivers. At least one of
1629 * driver and gmch_driver must be non-null, and find_gmch will determine
1630 * which one should be used if a gmch_chip_id is present.
1631 */
1632static const struct intel_gtt_driver_description {
1633 unsigned int gmch_chip_id;
1634 char *name;
1635 const struct agp_bridge_driver *gmch_driver;
Daniel Vetter1a997ff2010-09-08 21:18:53 +02001636 const struct intel_gtt_driver *gtt_driver;
Daniel Vetter02c026c2010-08-24 19:39:48 +02001637} intel_gtt_chipsets[] = {
Daniel Vetter1a997ff2010-09-08 21:18:53 +02001638 { PCI_DEVICE_ID_INTEL_82810_IG1, "i810", &intel_810_driver , NULL},
1639 { PCI_DEVICE_ID_INTEL_82810_IG3, "i810", &intel_810_driver , NULL},
1640 { PCI_DEVICE_ID_INTEL_82810E_IG, "i810", &intel_810_driver , NULL},
1641 { PCI_DEVICE_ID_INTEL_82815_CGC, "i815", &intel_810_driver , NULL},
1642 { PCI_DEVICE_ID_INTEL_82830_CGC, "830M",
1643 &intel_830_driver , &i8xx_gtt_driver},
1644 { PCI_DEVICE_ID_INTEL_82845G_IG, "830M",
1645 &intel_830_driver , &i8xx_gtt_driver},
1646 { PCI_DEVICE_ID_INTEL_82854_IG, "854",
1647 &intel_830_driver , &i8xx_gtt_driver},
1648 { PCI_DEVICE_ID_INTEL_82855GM_IG, "855GM",
1649 &intel_830_driver , &i8xx_gtt_driver},
1650 { PCI_DEVICE_ID_INTEL_82865_IG, "865",
1651 &intel_830_driver , &i8xx_gtt_driver},
1652 { PCI_DEVICE_ID_INTEL_E7221_IG, "E7221 (i915)",
1653 &intel_915_driver , &i915_gtt_driver },
1654 { PCI_DEVICE_ID_INTEL_82915G_IG, "915G",
1655 &intel_915_driver , &i915_gtt_driver },
1656 { PCI_DEVICE_ID_INTEL_82915GM_IG, "915GM",
1657 &intel_915_driver , &i915_gtt_driver },
1658 { PCI_DEVICE_ID_INTEL_82945G_IG, "945G",
1659 &intel_915_driver , &i915_gtt_driver },
1660 { PCI_DEVICE_ID_INTEL_82945GM_IG, "945GM",
1661 &intel_915_driver , &i915_gtt_driver },
1662 { PCI_DEVICE_ID_INTEL_82945GME_IG, "945GME",
1663 &intel_915_driver , &i915_gtt_driver },
1664 { PCI_DEVICE_ID_INTEL_82946GZ_IG, "946GZ",
1665 &intel_i965_driver , &i965_gtt_driver },
1666 { PCI_DEVICE_ID_INTEL_82G35_IG, "G35",
1667 &intel_i965_driver , &i965_gtt_driver },
1668 { PCI_DEVICE_ID_INTEL_82965Q_IG, "965Q",
1669 &intel_i965_driver , &i965_gtt_driver },
1670 { PCI_DEVICE_ID_INTEL_82965G_IG, "965G",
1671 &intel_i965_driver , &i965_gtt_driver },
1672 { PCI_DEVICE_ID_INTEL_82965GM_IG, "965GM",
1673 &intel_i965_driver , &i965_gtt_driver },
1674 { PCI_DEVICE_ID_INTEL_82965GME_IG, "965GME/GLE",
1675 &intel_i965_driver , &i965_gtt_driver },
1676 { PCI_DEVICE_ID_INTEL_G33_IG, "G33",
1677 &intel_g33_driver , &g33_gtt_driver },
1678 { PCI_DEVICE_ID_INTEL_Q35_IG, "Q35",
1679 &intel_g33_driver , &g33_gtt_driver },
1680 { PCI_DEVICE_ID_INTEL_Q33_IG, "Q33",
1681 &intel_g33_driver , &g33_gtt_driver },
1682 { PCI_DEVICE_ID_INTEL_PINEVIEW_M_IG, "GMA3150",
1683 &intel_g33_driver , &pineview_gtt_driver },
1684 { PCI_DEVICE_ID_INTEL_PINEVIEW_IG, "GMA3150",
1685 &intel_g33_driver , &pineview_gtt_driver },
1686 { PCI_DEVICE_ID_INTEL_GM45_IG, "GM45",
1687 &intel_i965_driver , &g4x_gtt_driver },
1688 { PCI_DEVICE_ID_INTEL_EAGLELAKE_IG, "Eaglelake",
1689 &intel_i965_driver , &g4x_gtt_driver },
1690 { PCI_DEVICE_ID_INTEL_Q45_IG, "Q45/Q43",
1691 &intel_i965_driver , &g4x_gtt_driver },
1692 { PCI_DEVICE_ID_INTEL_G45_IG, "G45/G43",
1693 &intel_i965_driver , &g4x_gtt_driver },
1694 { PCI_DEVICE_ID_INTEL_B43_IG, "B43",
1695 &intel_i965_driver , &g4x_gtt_driver },
1696 { PCI_DEVICE_ID_INTEL_G41_IG, "G41",
1697 &intel_i965_driver , &g4x_gtt_driver },
Daniel Vetter02c026c2010-08-24 19:39:48 +02001698 { PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG,
Daniel Vetter1a997ff2010-09-08 21:18:53 +02001699 "HD Graphics", &intel_i965_driver , &ironlake_gtt_driver },
Daniel Vetter02c026c2010-08-24 19:39:48 +02001700 { PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG,
Daniel Vetter1a997ff2010-09-08 21:18:53 +02001701 "HD Graphics", &intel_i965_driver , &ironlake_gtt_driver },
Daniel Vetter02c026c2010-08-24 19:39:48 +02001702 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT1_IG,
Daniel Vetter1a997ff2010-09-08 21:18:53 +02001703 "Sandybridge", &intel_gen6_driver , &sandybridge_gtt_driver },
Daniel Vetter02c026c2010-08-24 19:39:48 +02001704 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_IG,
Daniel Vetter1a997ff2010-09-08 21:18:53 +02001705 "Sandybridge", &intel_gen6_driver , &sandybridge_gtt_driver },
Daniel Vetter02c026c2010-08-24 19:39:48 +02001706 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_PLUS_IG,
Daniel Vetter1a997ff2010-09-08 21:18:53 +02001707 "Sandybridge", &intel_gen6_driver , &sandybridge_gtt_driver },
Daniel Vetter02c026c2010-08-24 19:39:48 +02001708 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT1_IG,
Daniel Vetter1a997ff2010-09-08 21:18:53 +02001709 "Sandybridge", &intel_gen6_driver , &sandybridge_gtt_driver },
Daniel Vetter02c026c2010-08-24 19:39:48 +02001710 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_IG,
Daniel Vetter1a997ff2010-09-08 21:18:53 +02001711 "Sandybridge", &intel_gen6_driver , &sandybridge_gtt_driver },
Daniel Vetter02c026c2010-08-24 19:39:48 +02001712 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_PLUS_IG,
Daniel Vetter1a997ff2010-09-08 21:18:53 +02001713 "Sandybridge", &intel_gen6_driver , &sandybridge_gtt_driver },
Daniel Vetter02c026c2010-08-24 19:39:48 +02001714 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_IG,
Daniel Vetter1a997ff2010-09-08 21:18:53 +02001715 "Sandybridge", &intel_gen6_driver , &sandybridge_gtt_driver },
Daniel Vetter02c026c2010-08-24 19:39:48 +02001716 { 0, NULL, NULL }
1717};
1718
1719static int find_gmch(u16 device)
1720{
1721 struct pci_dev *gmch_device;
1722
1723 gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL);
1724 if (gmch_device && PCI_FUNC(gmch_device->devfn) != 0) {
1725 gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL,
1726 device, gmch_device);
1727 }
1728
1729 if (!gmch_device)
1730 return 0;
1731
1732 intel_private.pcidev = gmch_device;
1733 return 1;
1734}
1735
Daniel Vettere2404e72010-09-08 17:29:51 +02001736int intel_gmch_probe(struct pci_dev *pdev,
Daniel Vetter02c026c2010-08-24 19:39:48 +02001737 struct agp_bridge_data *bridge)
1738{
1739 int i, mask;
1740 bridge->driver = NULL;
1741
1742 for (i = 0; intel_gtt_chipsets[i].name != NULL; i++) {
1743 if (find_gmch(intel_gtt_chipsets[i].gmch_chip_id)) {
1744 bridge->driver =
1745 intel_gtt_chipsets[i].gmch_driver;
Daniel Vetter1a997ff2010-09-08 21:18:53 +02001746 intel_private.driver =
1747 intel_gtt_chipsets[i].gtt_driver;
Daniel Vetter02c026c2010-08-24 19:39:48 +02001748 break;
1749 }
1750 }
1751
1752 if (!bridge->driver)
1753 return 0;
1754
1755 bridge->dev_private_data = &intel_private;
1756 bridge->dev = pdev;
1757
Daniel Vetterd7cca2f2010-08-24 23:06:19 +02001758 intel_private.bridge_dev = pci_dev_get(pdev);
1759
Daniel Vetter02c026c2010-08-24 19:39:48 +02001760 dev_info(&pdev->dev, "Intel %s Chipset\n", intel_gtt_chipsets[i].name);
1761
1762 if (bridge->driver->mask_memory == intel_gen6_mask_memory)
1763 mask = 40;
1764 else if (bridge->driver->mask_memory == intel_i965_mask_memory)
1765 mask = 36;
1766 else
1767 mask = 32;
1768
1769 if (pci_set_dma_mask(intel_private.pcidev, DMA_BIT_MASK(mask)))
1770 dev_err(&intel_private.pcidev->dev,
1771 "set gfx device dma mask %d-bit failed!\n", mask);
1772 else
1773 pci_set_consistent_dma_mask(intel_private.pcidev,
1774 DMA_BIT_MASK(mask));
1775
Daniel Vetter1784a5f2010-09-08 21:01:04 +02001776 if (bridge->driver == &intel_810_driver)
1777 return 1;
1778
1779 intel_private.base.gtt_mappable_entries = intel_gtt_mappable_entries();
1780
Daniel Vetter02c026c2010-08-24 19:39:48 +02001781 return 1;
1782}
Daniel Vettere2404e72010-09-08 17:29:51 +02001783EXPORT_SYMBOL(intel_gmch_probe);
Daniel Vetter02c026c2010-08-24 19:39:48 +02001784
Daniel Vettere2404e72010-09-08 17:29:51 +02001785void intel_gmch_remove(struct pci_dev *pdev)
Daniel Vetter02c026c2010-08-24 19:39:48 +02001786{
1787 if (intel_private.pcidev)
1788 pci_dev_put(intel_private.pcidev);
Daniel Vetterd7cca2f2010-08-24 23:06:19 +02001789 if (intel_private.bridge_dev)
1790 pci_dev_put(intel_private.bridge_dev);
Daniel Vetter02c026c2010-08-24 19:39:48 +02001791}
Daniel Vettere2404e72010-09-08 17:29:51 +02001792EXPORT_SYMBOL(intel_gmch_remove);
1793
1794MODULE_AUTHOR("Dave Jones <davej@redhat.com>");
1795MODULE_LICENSE("GPL and additional rights");