diff options
-rw-r--r-- | drivers/char/agp/intel-agp.c | 163 |
1 files changed, 152 insertions, 11 deletions
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c index 42a1cb871992..a425f27af9ea 100644 --- a/drivers/char/agp/intel-agp.c +++ b/drivers/char/agp/intel-agp.c | |||
@@ -2,14 +2,6 @@ | |||
2 | * Intel AGPGART routines. | 2 | * Intel AGPGART routines. |
3 | */ | 3 | */ |
4 | 4 | ||
5 | /* | ||
6 | * Intel(R) 855GM/852GM and 865G support added by David Dawes | ||
7 | * <dawes@tungstengraphics.com>. | ||
8 | * | ||
9 | * Intel(R) 915G/915GM support added by Alan Hourihane | ||
10 | * <alanh@tungstengraphics.com>. | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | 5 | #include <linux/module.h> |
14 | #include <linux/pci.h> | 6 | #include <linux/pci.h> |
15 | #include <linux/init.h> | 7 | #include <linux/init.h> |
@@ -17,6 +9,21 @@ | |||
17 | #include <linux/agp_backend.h> | 9 | #include <linux/agp_backend.h> |
18 | #include "agp.h" | 10 | #include "agp.h" |
19 | 11 | ||
12 | #define PCI_DEVICE_ID_INTEL_82946GZ_HB 0x2970 | ||
13 | #define PCI_DEVICE_ID_INTEL_82946GZ_IG 0x2972 | ||
14 | #define PCI_DEVICE_ID_INTEL_82965G_1_HB 0x2980 | ||
15 | #define PCI_DEVICE_ID_INTEL_82965G_1_IG 0x2982 | ||
16 | #define PCI_DEVICE_ID_INTEL_82965Q_HB 0x2990 | ||
17 | #define PCI_DEVICE_ID_INTEL_82965Q_IG 0x2992 | ||
18 | #define PCI_DEVICE_ID_INTEL_82965G_HB 0x29A0 | ||
19 | #define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2 | ||
20 | |||
21 | #define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \ | ||
22 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_1_HB || \ | ||
23 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965Q_HB || \ | ||
24 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB) | ||
25 | |||
26 | |||
20 | /* Intel 815 register */ | 27 | /* Intel 815 register */ |
21 | #define INTEL_815_APCONT 0x51 | 28 | #define INTEL_815_APCONT 0x51 |
22 | #define INTEL_815_ATTBASE_MASK ~0x1FFFFFFF | 29 | #define INTEL_815_ATTBASE_MASK ~0x1FFFFFFF |
@@ -40,6 +47,8 @@ | |||
40 | #define I915_GMCH_GMS_STOLEN_48M (0x6 << 4) | 47 | #define I915_GMCH_GMS_STOLEN_48M (0x6 << 4) |
41 | #define I915_GMCH_GMS_STOLEN_64M (0x7 << 4) | 48 | #define I915_GMCH_GMS_STOLEN_64M (0x7 << 4) |
42 | 49 | ||
50 | /* Intel 965G registers */ | ||
51 | #define I965_MSAC 0x62 | ||
43 | 52 | ||
44 | /* Intel 7505 registers */ | 53 | /* Intel 7505 registers */ |
45 | #define INTEL_I7505_APSIZE 0x74 | 54 | #define INTEL_I7505_APSIZE 0x74 |
@@ -354,6 +363,7 @@ static struct aper_size_info_fixed intel_i830_sizes[] = | |||
354 | /* The 64M mode still requires a 128k gatt */ | 363 | /* The 64M mode still requires a 128k gatt */ |
355 | {64, 16384, 5}, | 364 | {64, 16384, 5}, |
356 | {256, 65536, 6}, | 365 | {256, 65536, 6}, |
366 | {512, 131072, 7}, | ||
357 | }; | 367 | }; |
358 | 368 | ||
359 | static struct _intel_i830_private { | 369 | static struct _intel_i830_private { |
@@ -377,7 +387,11 @@ static void intel_i830_init_gtt_entries(void) | |||
377 | /* We obtain the size of the GTT, which is also stored (for some | 387 | /* We obtain the size of the GTT, which is also stored (for some |
378 | * reason) at the top of stolen memory. Then we add 4KB to that | 388 | * reason) at the top of stolen memory. Then we add 4KB to that |
379 | * for the video BIOS popup, which is also stored in there. */ | 389 | * for the video BIOS popup, which is also stored in there. */ |
380 | size = agp_bridge->driver->fetch_size() + 4; | 390 | |
391 | if (IS_I965) | ||
392 | size = 512 + 4; | ||
393 | else | ||
394 | size = agp_bridge->driver->fetch_size() + 4; | ||
381 | 395 | ||
382 | if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82830_HB || | 396 | if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82830_HB || |
383 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) { | 397 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) { |
@@ -423,7 +437,7 @@ static void intel_i830_init_gtt_entries(void) | |||
423 | if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || | 437 | if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || |
424 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || | 438 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || |
425 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || | 439 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || |
426 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB) | 440 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || IS_I965 ) |
427 | gtt_entries = MB(48) - KB(size); | 441 | gtt_entries = MB(48) - KB(size); |
428 | else | 442 | else |
429 | gtt_entries = 0; | 443 | gtt_entries = 0; |
@@ -433,7 +447,7 @@ static void intel_i830_init_gtt_entries(void) | |||
433 | if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || | 447 | if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || |
434 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || | 448 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || |
435 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || | 449 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || |
436 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB) | 450 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || IS_I965) |
437 | gtt_entries = MB(64) - KB(size); | 451 | gtt_entries = MB(64) - KB(size); |
438 | else | 452 | else |
439 | gtt_entries = 0; | 453 | gtt_entries = 0; |
@@ -791,6 +805,77 @@ static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge) | |||
791 | 805 | ||
792 | return 0; | 806 | return 0; |
793 | } | 807 | } |
808 | static int intel_i965_fetch_size(void) | ||
809 | { | ||
810 | struct aper_size_info_fixed *values; | ||
811 | u32 offset = 0; | ||
812 | u8 temp; | ||
813 | |||
814 | #define I965_512MB_ADDRESS_MASK (3<<1) | ||
815 | |||
816 | values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes); | ||
817 | |||
818 | pci_read_config_byte(intel_i830_private.i830_dev, I965_MSAC, &temp); | ||
819 | temp &= I965_512MB_ADDRESS_MASK; | ||
820 | switch (temp) { | ||
821 | case 0x00: | ||
822 | offset = 0; /* 128MB */ | ||
823 | break; | ||
824 | case 0x06: | ||
825 | offset = 3; /* 512MB */ | ||
826 | break; | ||
827 | default: | ||
828 | case 0x02: | ||
829 | offset = 2; /* 256MB */ | ||
830 | break; | ||
831 | } | ||
832 | |||
833 | agp_bridge->previous_size = agp_bridge->current_size = (void *)(values + offset); | ||
834 | |||
835 | return values[offset].size; | ||
836 | } | ||
837 | |||
838 | /* The intel i965 automatically initializes the agp aperture during POST. | ||
839 | + * Use the memory already set aside for in the GTT. | ||
840 | + */ | ||
841 | static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge) | ||
842 | { | ||
843 | int page_order; | ||
844 | struct aper_size_info_fixed *size; | ||
845 | int num_entries; | ||
846 | u32 temp; | ||
847 | |||
848 | size = agp_bridge->current_size; | ||
849 | page_order = size->page_order; | ||
850 | num_entries = size->num_entries; | ||
851 | agp_bridge->gatt_table_real = NULL; | ||
852 | |||
853 | pci_read_config_dword(intel_i830_private.i830_dev, I915_MMADDR, &temp); | ||
854 | |||
855 | temp &= 0xfff00000; | ||
856 | intel_i830_private.gtt = ioremap((temp + (512 * 1024)) , 512 * 1024); | ||
857 | |||
858 | if (!intel_i830_private.gtt) | ||
859 | return -ENOMEM; | ||
860 | |||
861 | |||
862 | intel_i830_private.registers = ioremap(temp,128 * 4096); | ||
863 | if (!intel_i830_private.registers) | ||
864 | return -ENOMEM; | ||
865 | |||
866 | temp = readl(intel_i830_private.registers+I810_PGETBL_CTL) & 0xfffff000; | ||
867 | global_cache_flush(); /* FIXME: ? */ | ||
868 | |||
869 | /* we have to call this as early as possible after the MMIO base address is known */ | ||
870 | intel_i830_init_gtt_entries(); | ||
871 | |||
872 | agp_bridge->gatt_table = NULL; | ||
873 | |||
874 | agp_bridge->gatt_bus_addr = temp; | ||
875 | |||
876 | return 0; | ||
877 | } | ||
878 | |||
794 | 879 | ||
795 | static int intel_fetch_size(void) | 880 | static int intel_fetch_size(void) |
796 | { | 881 | { |
@@ -1489,6 +1574,29 @@ static struct agp_bridge_driver intel_915_driver = { | |||
1489 | .agp_destroy_page = agp_generic_destroy_page, | 1574 | .agp_destroy_page = agp_generic_destroy_page, |
1490 | }; | 1575 | }; |
1491 | 1576 | ||
1577 | static struct agp_bridge_driver intel_i965_driver = { | ||
1578 | .owner = THIS_MODULE, | ||
1579 | .aperture_sizes = intel_i830_sizes, | ||
1580 | .size_type = FIXED_APER_SIZE, | ||
1581 | .num_aperture_sizes = 4, | ||
1582 | .needs_scratch_page = TRUE, | ||
1583 | .configure = intel_i915_configure, | ||
1584 | .fetch_size = intel_i965_fetch_size, | ||
1585 | .cleanup = intel_i915_cleanup, | ||
1586 | .tlb_flush = intel_i810_tlbflush, | ||
1587 | .mask_memory = intel_i810_mask_memory, | ||
1588 | .masks = intel_i810_masks, | ||
1589 | .agp_enable = intel_i810_agp_enable, | ||
1590 | .cache_flush = global_cache_flush, | ||
1591 | .create_gatt_table = intel_i965_create_gatt_table, | ||
1592 | .free_gatt_table = intel_i830_free_gatt_table, | ||
1593 | .insert_memory = intel_i915_insert_entries, | ||
1594 | .remove_memory = intel_i915_remove_entries, | ||
1595 | .alloc_by_type = intel_i830_alloc_by_type, | ||
1596 | .free_by_type = intel_i810_free_by_type, | ||
1597 | .agp_alloc_page = agp_generic_alloc_page, | ||
1598 | .agp_destroy_page = agp_generic_destroy_page, | ||
1599 | }; | ||
1492 | 1600 | ||
1493 | static struct agp_bridge_driver intel_7505_driver = { | 1601 | static struct agp_bridge_driver intel_7505_driver = { |
1494 | .owner = THIS_MODULE, | 1602 | .owner = THIS_MODULE, |
@@ -1684,6 +1792,35 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev, | |||
1684 | bridge->driver = &intel_845_driver; | 1792 | bridge->driver = &intel_845_driver; |
1685 | name = "945GM"; | 1793 | name = "945GM"; |
1686 | break; | 1794 | break; |
1795 | case PCI_DEVICE_ID_INTEL_82946GZ_HB: | ||
1796 | if (find_i830(PCI_DEVICE_ID_INTEL_82946GZ_IG)) | ||
1797 | bridge->driver = &intel_i965_driver; | ||
1798 | else | ||
1799 | bridge->driver = &intel_845_driver; | ||
1800 | name = "946GZ"; | ||
1801 | break; | ||
1802 | case PCI_DEVICE_ID_INTEL_82965G_1_HB: | ||
1803 | if (find_i830(PCI_DEVICE_ID_INTEL_82965G_1_IG)) | ||
1804 | bridge->driver = &intel_i965_driver; | ||
1805 | else | ||
1806 | bridge->driver = &intel_845_driver; | ||
1807 | name = "965G"; | ||
1808 | break; | ||
1809 | case PCI_DEVICE_ID_INTEL_82965Q_HB: | ||
1810 | if (find_i830(PCI_DEVICE_ID_INTEL_82965Q_IG)) | ||
1811 | bridge->driver = &intel_i965_driver; | ||
1812 | else | ||
1813 | bridge->driver = &intel_845_driver; | ||
1814 | name = "965Q"; | ||
1815 | break; | ||
1816 | case PCI_DEVICE_ID_INTEL_82965G_HB: | ||
1817 | if (find_i830(PCI_DEVICE_ID_INTEL_82965G_IG)) | ||
1818 | bridge->driver = &intel_i965_driver; | ||
1819 | else | ||
1820 | bridge->driver = &intel_845_driver; | ||
1821 | name = "965G"; | ||
1822 | break; | ||
1823 | |||
1687 | case PCI_DEVICE_ID_INTEL_7505_0: | 1824 | case PCI_DEVICE_ID_INTEL_7505_0: |
1688 | bridge->driver = &intel_7505_driver; | 1825 | bridge->driver = &intel_7505_driver; |
1689 | name = "E7505"; | 1826 | name = "E7505"; |
@@ -1827,6 +1964,10 @@ static struct pci_device_id agp_intel_pci_table[] = { | |||
1827 | ID(PCI_DEVICE_ID_INTEL_82915GM_HB), | 1964 | ID(PCI_DEVICE_ID_INTEL_82915GM_HB), |
1828 | ID(PCI_DEVICE_ID_INTEL_82945G_HB), | 1965 | ID(PCI_DEVICE_ID_INTEL_82945G_HB), |
1829 | ID(PCI_DEVICE_ID_INTEL_82945GM_HB), | 1966 | ID(PCI_DEVICE_ID_INTEL_82945GM_HB), |
1967 | ID(PCI_DEVICE_ID_INTEL_82946GZ_HB), | ||
1968 | ID(PCI_DEVICE_ID_INTEL_82965G_1_HB), | ||
1969 | ID(PCI_DEVICE_ID_INTEL_82965Q_HB), | ||
1970 | ID(PCI_DEVICE_ID_INTEL_82965G_HB), | ||
1830 | { } | 1971 | { } |
1831 | }; | 1972 | }; |
1832 | 1973 | ||