Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Intel AGPGART routines. |
| 3 | */ |
| 4 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | #include <linux/module.h> |
| 6 | #include <linux/pci.h> |
| 7 | #include <linux/init.h> |
Ahmed S. Darwish | 1eaf122 | 2007-02-06 18:08:28 +0200 | [diff] [blame] | 8 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include <linux/pagemap.h> |
| 10 | #include <linux/agp_backend.h> |
| 11 | #include "agp.h" |
| 12 | |
Carlos Martín | e914a36 | 2008-01-24 10:34:09 +1000 | [diff] [blame] | 13 | #define PCI_DEVICE_ID_INTEL_E7221_HB 0x2588 |
| 14 | #define PCI_DEVICE_ID_INTEL_E7221_IG 0x258a |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 15 | #define PCI_DEVICE_ID_INTEL_82946GZ_HB 0x2970 |
| 16 | #define PCI_DEVICE_ID_INTEL_82946GZ_IG 0x2972 |
Zhenyu Wang | 9119f85 | 2008-01-23 15:49:26 +1000 | [diff] [blame] | 17 | #define PCI_DEVICE_ID_INTEL_82G35_HB 0x2980 |
| 18 | #define PCI_DEVICE_ID_INTEL_82G35_IG 0x2982 |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 19 | #define PCI_DEVICE_ID_INTEL_82965Q_HB 0x2990 |
| 20 | #define PCI_DEVICE_ID_INTEL_82965Q_IG 0x2992 |
| 21 | #define PCI_DEVICE_ID_INTEL_82965G_HB 0x29A0 |
| 22 | #define PCI_DEVICE_ID_INTEL_82965G_IG 0x29A2 |
Wang Zhenyu | 4598af3 | 2007-04-09 08:51:36 +0800 | [diff] [blame] | 23 | #define PCI_DEVICE_ID_INTEL_82965GM_HB 0x2A00 |
| 24 | #define PCI_DEVICE_ID_INTEL_82965GM_IG 0x2A02 |
Zhenyu Wang | dde4787 | 2007-07-26 09:18:09 +0800 | [diff] [blame] | 25 | #define PCI_DEVICE_ID_INTEL_82965GME_HB 0x2A10 |
Wang Zhenyu | c8eebfd | 2007-05-31 11:34:06 +0800 | [diff] [blame] | 26 | #define PCI_DEVICE_ID_INTEL_82965GME_IG 0x2A12 |
Zhenyu Wang | dde4787 | 2007-07-26 09:18:09 +0800 | [diff] [blame] | 27 | #define PCI_DEVICE_ID_INTEL_82945GME_HB 0x27AC |
Wang Zhenyu | df80b14 | 2007-05-31 11:51:12 +0800 | [diff] [blame] | 28 | #define PCI_DEVICE_ID_INTEL_82945GME_IG 0x27AE |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 29 | #define PCI_DEVICE_ID_INTEL_G33_HB 0x29C0 |
| 30 | #define PCI_DEVICE_ID_INTEL_G33_IG 0x29C2 |
| 31 | #define PCI_DEVICE_ID_INTEL_Q35_HB 0x29B0 |
| 32 | #define PCI_DEVICE_ID_INTEL_Q35_IG 0x29B2 |
| 33 | #define PCI_DEVICE_ID_INTEL_Q33_HB 0x29D0 |
| 34 | #define PCI_DEVICE_ID_INTEL_Q33_IG 0x29D2 |
Zhenyu Wang | 4e8b6e2 | 2008-01-23 14:54:37 +1000 | [diff] [blame] | 35 | #define PCI_DEVICE_ID_INTEL_IGD_HB 0x2A40 |
| 36 | #define PCI_DEVICE_ID_INTEL_IGD_IG 0x2A42 |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 37 | #define PCI_DEVICE_ID_INTEL_IGD_E_HB 0x2E00 |
| 38 | #define PCI_DEVICE_ID_INTEL_IGD_E_IG 0x2E02 |
| 39 | #define PCI_DEVICE_ID_INTEL_Q45_HB 0x2E10 |
| 40 | #define PCI_DEVICE_ID_INTEL_Q45_IG 0x2E12 |
| 41 | #define PCI_DEVICE_ID_INTEL_G45_HB 0x2E20 |
| 42 | #define PCI_DEVICE_ID_INTEL_G45_IG 0x2E22 |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 43 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 44 | /* cover 915 and 945 variants */ |
| 45 | #define IS_I915 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_E7221_HB || \ |
| 46 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915G_HB || \ |
| 47 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB || \ |
| 48 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945G_HB || \ |
| 49 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GM_HB || \ |
| 50 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82945GME_HB) |
| 51 | |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 52 | #define IS_I965 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82946GZ_HB || \ |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 53 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82G35_HB || \ |
| 54 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965Q_HB || \ |
| 55 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965G_HB || \ |
| 56 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GM_HB || \ |
Zhenyu Wang | 4e8b6e2 | 2008-01-23 14:54:37 +1000 | [diff] [blame] | 57 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82965GME_HB || \ |
| 58 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGD_HB) |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 59 | |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 60 | #define IS_G33 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G33_HB || \ |
| 61 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q35_HB || \ |
| 62 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q33_HB) |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 63 | |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 64 | #define IS_G4X (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGD_E_HB || \ |
| 65 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q45_HB || \ |
| 66 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G45_HB) |
| 67 | |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 68 | extern int agp_memory_reserved; |
| 69 | |
| 70 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | /* Intel 815 register */ |
| 72 | #define INTEL_815_APCONT 0x51 |
| 73 | #define INTEL_815_ATTBASE_MASK ~0x1FFFFFFF |
| 74 | |
| 75 | /* Intel i820 registers */ |
| 76 | #define INTEL_I820_RDCR 0x51 |
| 77 | #define INTEL_I820_ERRSTS 0xc8 |
| 78 | |
| 79 | /* Intel i840 registers */ |
| 80 | #define INTEL_I840_MCHCFG 0x50 |
| 81 | #define INTEL_I840_ERRSTS 0xc8 |
| 82 | |
| 83 | /* Intel i850 registers */ |
| 84 | #define INTEL_I850_MCHCFG 0x50 |
| 85 | #define INTEL_I850_ERRSTS 0xc8 |
| 86 | |
| 87 | /* intel 915G registers */ |
| 88 | #define I915_GMADDR 0x18 |
| 89 | #define I915_MMADDR 0x10 |
| 90 | #define I915_PTEADDR 0x1C |
| 91 | #define I915_GMCH_GMS_STOLEN_48M (0x6 << 4) |
| 92 | #define I915_GMCH_GMS_STOLEN_64M (0x7 << 4) |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 93 | #define G33_GMCH_GMS_STOLEN_128M (0x8 << 4) |
| 94 | #define G33_GMCH_GMS_STOLEN_256M (0x9 << 4) |
| 95 | #define INTEL_GMCH_GMS_STOLEN_96M (0xa << 4) |
| 96 | #define INTEL_GMCH_GMS_STOLEN_160M (0xb << 4) |
| 97 | #define INTEL_GMCH_GMS_STOLEN_224M (0xc << 4) |
| 98 | #define INTEL_GMCH_GMS_STOLEN_352M (0xd << 4) |
| 99 | |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 100 | #define I915_IFPADDR 0x60 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 102 | /* Intel 965G registers */ |
| 103 | #define I965_MSAC 0x62 |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 104 | #define I965_IFPADDR 0x70 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | |
| 106 | /* Intel 7505 registers */ |
| 107 | #define INTEL_I7505_APSIZE 0x74 |
| 108 | #define INTEL_I7505_NCAPID 0x60 |
| 109 | #define INTEL_I7505_NISTAT 0x6c |
| 110 | #define INTEL_I7505_ATTBASE 0x78 |
| 111 | #define INTEL_I7505_ERRSTS 0x42 |
| 112 | #define INTEL_I7505_AGPCTRL 0x70 |
| 113 | #define INTEL_I7505_MCHCFG 0x50 |
| 114 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 115 | static const struct aper_size_info_fixed intel_i810_sizes[] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | { |
| 117 | {64, 16384, 4}, |
| 118 | /* The 32M mode still requires a 64k gatt */ |
| 119 | {32, 8192, 4} |
| 120 | }; |
| 121 | |
| 122 | #define AGP_DCACHE_MEMORY 1 |
| 123 | #define AGP_PHYS_MEMORY 2 |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 124 | #define INTEL_AGP_CACHED_MEMORY 3 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | |
| 126 | static struct gatt_mask intel_i810_masks[] = |
| 127 | { |
| 128 | {.mask = I810_PTE_VALID, .type = 0}, |
| 129 | {.mask = (I810_PTE_VALID | I810_PTE_LOCAL), .type = AGP_DCACHE_MEMORY}, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 130 | {.mask = I810_PTE_VALID, .type = 0}, |
| 131 | {.mask = I810_PTE_VALID | I830_PTE_SYSTEM_CACHED, |
| 132 | .type = INTEL_AGP_CACHED_MEMORY} |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | }; |
| 134 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 135 | static struct _intel_private { |
| 136 | struct pci_dev *pcidev; /* device one */ |
| 137 | u8 __iomem *registers; |
| 138 | u32 __iomem *gtt; /* I915G */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | int num_dcache_entries; |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 140 | /* gtt_entries is the number of gtt entries that are already mapped |
| 141 | * to stolen memory. Stolen memory is larger than the memory mapped |
| 142 | * through gtt_entries, as it includes some reserved space for the BIOS |
| 143 | * popup and for the GTT. |
| 144 | */ |
| 145 | int gtt_entries; /* i830+ */ |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 146 | union { |
| 147 | void __iomem *i9xx_flush_page; |
| 148 | void *i8xx_flush_page; |
| 149 | }; |
| 150 | struct page *i8xx_page; |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 151 | struct resource ifp_resource; |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 152 | int resource_valid; |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 153 | } intel_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | |
| 155 | static int intel_i810_fetch_size(void) |
| 156 | { |
| 157 | u32 smram_miscc; |
| 158 | struct aper_size_info_fixed *values; |
| 159 | |
| 160 | pci_read_config_dword(agp_bridge->dev, I810_SMRAM_MISCC, &smram_miscc); |
| 161 | values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes); |
| 162 | |
| 163 | if ((smram_miscc & I810_GMS) == I810_GMS_DISABLE) { |
| 164 | printk(KERN_WARNING PFX "i810 is disabled\n"); |
| 165 | return 0; |
| 166 | } |
| 167 | if ((smram_miscc & I810_GFX_MEM_WIN_SIZE) == I810_GFX_MEM_WIN_32M) { |
| 168 | agp_bridge->previous_size = |
| 169 | agp_bridge->current_size = (void *) (values + 1); |
| 170 | agp_bridge->aperture_size_idx = 1; |
| 171 | return values[1].size; |
| 172 | } else { |
| 173 | agp_bridge->previous_size = |
| 174 | agp_bridge->current_size = (void *) (values); |
| 175 | agp_bridge->aperture_size_idx = 0; |
| 176 | return values[0].size; |
| 177 | } |
| 178 | |
| 179 | return 0; |
| 180 | } |
| 181 | |
| 182 | static int intel_i810_configure(void) |
| 183 | { |
| 184 | struct aper_size_info_fixed *current_size; |
| 185 | u32 temp; |
| 186 | int i; |
| 187 | |
| 188 | current_size = A_SIZE_FIX(agp_bridge->current_size); |
| 189 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 190 | if (!intel_private.registers) { |
| 191 | pci_read_config_dword(intel_private.pcidev, I810_MMADDR, &temp); |
Dave Jones | e4ac5e4 | 2007-02-04 17:37:42 -0500 | [diff] [blame] | 192 | temp &= 0xfff80000; |
| 193 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 194 | intel_private.registers = ioremap(temp, 128 * 4096); |
| 195 | if (!intel_private.registers) { |
Dave Jones | e4ac5e4 | 2007-02-04 17:37:42 -0500 | [diff] [blame] | 196 | printk(KERN_ERR PFX "Unable to remap memory.\n"); |
| 197 | return -ENOMEM; |
| 198 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | } |
| 200 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 201 | if ((readl(intel_private.registers+I810_DRAM_CTL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) { |
| 203 | /* This will need to be dynamically assigned */ |
| 204 | printk(KERN_INFO PFX "detected 4MB dedicated video ram.\n"); |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 205 | intel_private.num_dcache_entries = 1024; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | } |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 207 | pci_read_config_dword(intel_private.pcidev, I810_GMADDR, &temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 209 | writel(agp_bridge->gatt_bus_addr | I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL); |
| 210 | readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | |
| 212 | if (agp_bridge->driver->needs_scratch_page) { |
| 213 | for (i = 0; i < current_size->num_entries; i++) { |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 214 | writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4)); |
| 215 | readl(intel_private.registers+I810_PTE_BASE+(i*4)); /* PCI posting. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | } |
| 217 | } |
| 218 | global_cache_flush(); |
| 219 | return 0; |
| 220 | } |
| 221 | |
| 222 | static void intel_i810_cleanup(void) |
| 223 | { |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 224 | writel(0, intel_private.registers+I810_PGETBL_CTL); |
| 225 | readl(intel_private.registers); /* PCI Posting. */ |
| 226 | iounmap(intel_private.registers); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | static void intel_i810_tlbflush(struct agp_memory *mem) |
| 230 | { |
| 231 | return; |
| 232 | } |
| 233 | |
| 234 | static void intel_i810_agp_enable(struct agp_bridge_data *bridge, u32 mode) |
| 235 | { |
| 236 | return; |
| 237 | } |
| 238 | |
| 239 | /* Exists to support ARGB cursors */ |
| 240 | static void *i8xx_alloc_pages(void) |
| 241 | { |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 242 | struct page *page; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | |
Linus Torvalds | 66c669b | 2006-11-22 14:55:29 -0800 | [diff] [blame] | 244 | page = alloc_pages(GFP_KERNEL | GFP_DMA32, 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | if (page == NULL) |
| 246 | return NULL; |
| 247 | |
Arjan van de Ven | 6d238cc | 2008-01-30 13:34:06 +0100 | [diff] [blame] | 248 | if (set_pages_uc(page, 4) < 0) { |
| 249 | set_pages_wb(page, 4); |
Jan Beulich | 89cf7cc | 2007-04-02 14:50:14 +0100 | [diff] [blame] | 250 | __free_pages(page, 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | return NULL; |
| 252 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | get_page(page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | atomic_inc(&agp_bridge->current_memory_agp); |
| 255 | return page_address(page); |
| 256 | } |
| 257 | |
| 258 | static void i8xx_destroy_pages(void *addr) |
| 259 | { |
| 260 | struct page *page; |
| 261 | |
| 262 | if (addr == NULL) |
| 263 | return; |
| 264 | |
| 265 | page = virt_to_page(addr); |
Arjan van de Ven | 6d238cc | 2008-01-30 13:34:06 +0100 | [diff] [blame] | 266 | set_pages_wb(page, 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | put_page(page); |
Jan Beulich | 89cf7cc | 2007-04-02 14:50:14 +0100 | [diff] [blame] | 268 | __free_pages(page, 2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | atomic_dec(&agp_bridge->current_memory_agp); |
| 270 | } |
| 271 | |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 272 | static int intel_i830_type_to_mask_type(struct agp_bridge_data *bridge, |
| 273 | int type) |
| 274 | { |
| 275 | if (type < AGP_USER_TYPES) |
| 276 | return type; |
| 277 | else if (type == AGP_USER_CACHED_MEMORY) |
| 278 | return INTEL_AGP_CACHED_MEMORY; |
| 279 | else |
| 280 | return 0; |
| 281 | } |
| 282 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start, |
| 284 | int type) |
| 285 | { |
| 286 | int i, j, num_entries; |
| 287 | void *temp; |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 288 | int ret = -EINVAL; |
| 289 | int mask_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 291 | if (mem->page_count == 0) |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 292 | goto out; |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 293 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | temp = agp_bridge->current_size; |
| 295 | num_entries = A_SIZE_FIX(temp)->num_entries; |
| 296 | |
Dave Jones | 6a92a4e | 2006-02-28 00:54:25 -0500 | [diff] [blame] | 297 | if ((pg_start + mem->page_count) > num_entries) |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 298 | goto out_err; |
| 299 | |
Dave Jones | 6a92a4e | 2006-02-28 00:54:25 -0500 | [diff] [blame] | 300 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | for (j = pg_start; j < (pg_start + mem->page_count); j++) { |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 302 | if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+j))) { |
| 303 | ret = -EBUSY; |
| 304 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | } |
| 307 | |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 308 | if (type != mem->type) |
| 309 | goto out_err; |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 310 | |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 311 | mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type); |
| 312 | |
| 313 | switch (mask_type) { |
| 314 | case AGP_DCACHE_MEMORY: |
| 315 | if (!mem->is_flushed) |
| 316 | global_cache_flush(); |
| 317 | for (i = pg_start; i < (pg_start + mem->page_count); i++) { |
| 318 | writel((i*4096)|I810_PTE_LOCAL|I810_PTE_VALID, |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 319 | intel_private.registers+I810_PTE_BASE+(i*4)); |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 320 | } |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 321 | readl(intel_private.registers+I810_PTE_BASE+((i-1)*4)); |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 322 | break; |
| 323 | case AGP_PHYS_MEMORY: |
| 324 | case AGP_NORMAL_MEMORY: |
| 325 | if (!mem->is_flushed) |
| 326 | global_cache_flush(); |
| 327 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { |
| 328 | writel(agp_bridge->driver->mask_memory(agp_bridge, |
| 329 | mem->memory[i], |
| 330 | mask_type), |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 331 | intel_private.registers+I810_PTE_BASE+(j*4)); |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 332 | } |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 333 | readl(intel_private.registers+I810_PTE_BASE+((j-1)*4)); |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 334 | break; |
| 335 | default: |
| 336 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | |
| 339 | agp_bridge->driver->tlb_flush(mem); |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 340 | out: |
| 341 | ret = 0; |
| 342 | out_err: |
Dave Airlie | 9516b03 | 2008-06-19 10:42:17 +1000 | [diff] [blame] | 343 | mem->is_flushed = true; |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 344 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | static int intel_i810_remove_entries(struct agp_memory *mem, off_t pg_start, |
| 348 | int type) |
| 349 | { |
| 350 | int i; |
| 351 | |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 352 | if (mem->page_count == 0) |
| 353 | return 0; |
| 354 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | for (i = pg_start; i < (mem->page_count + pg_start); i++) { |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 356 | writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | } |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 358 | readl(intel_private.registers+I810_PTE_BASE+((i-1)*4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | agp_bridge->driver->tlb_flush(mem); |
| 361 | return 0; |
| 362 | } |
| 363 | |
| 364 | /* |
| 365 | * The i810/i830 requires a physical address to program its mouse |
| 366 | * pointer into hardware. |
| 367 | * However the Xserver still writes to it through the agp aperture. |
| 368 | */ |
| 369 | static struct agp_memory *alloc_agpphysmem_i8xx(size_t pg_count, int type) |
| 370 | { |
| 371 | struct agp_memory *new; |
| 372 | void *addr; |
| 373 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | switch (pg_count) { |
| 375 | case 1: addr = agp_bridge->driver->agp_alloc_page(agp_bridge); |
| 376 | break; |
| 377 | case 4: |
| 378 | /* kludge to get 4 physical pages for ARGB cursor */ |
| 379 | addr = i8xx_alloc_pages(); |
| 380 | break; |
| 381 | default: |
| 382 | return NULL; |
| 383 | } |
| 384 | |
| 385 | if (addr == NULL) |
| 386 | return NULL; |
| 387 | |
| 388 | new = agp_create_memory(pg_count); |
| 389 | if (new == NULL) |
| 390 | return NULL; |
| 391 | |
Keir Fraser | 07eee78 | 2005-03-30 13:17:04 -0800 | [diff] [blame] | 392 | new->memory[0] = virt_to_gart(addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | if (pg_count == 4) { |
| 394 | /* kludge to get 4 physical pages for ARGB cursor */ |
| 395 | new->memory[1] = new->memory[0] + PAGE_SIZE; |
| 396 | new->memory[2] = new->memory[1] + PAGE_SIZE; |
| 397 | new->memory[3] = new->memory[2] + PAGE_SIZE; |
| 398 | } |
| 399 | new->page_count = pg_count; |
| 400 | new->num_scratch_pages = pg_count; |
| 401 | new->type = AGP_PHYS_MEMORY; |
| 402 | new->physical = new->memory[0]; |
| 403 | return new; |
| 404 | } |
| 405 | |
| 406 | static struct agp_memory *intel_i810_alloc_by_type(size_t pg_count, int type) |
| 407 | { |
| 408 | struct agp_memory *new; |
| 409 | |
| 410 | if (type == AGP_DCACHE_MEMORY) { |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 411 | if (pg_count != intel_private.num_dcache_entries) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 412 | return NULL; |
| 413 | |
| 414 | new = agp_create_memory(1); |
| 415 | if (new == NULL) |
| 416 | return NULL; |
| 417 | |
| 418 | new->type = AGP_DCACHE_MEMORY; |
| 419 | new->page_count = pg_count; |
| 420 | new->num_scratch_pages = 0; |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 421 | agp_free_page_array(new); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | return new; |
| 423 | } |
| 424 | if (type == AGP_PHYS_MEMORY) |
| 425 | return alloc_agpphysmem_i8xx(pg_count, type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | return NULL; |
| 427 | } |
| 428 | |
| 429 | static void intel_i810_free_by_type(struct agp_memory *curr) |
| 430 | { |
| 431 | agp_free_key(curr->key); |
Dave Jones | 6a92a4e | 2006-02-28 00:54:25 -0500 | [diff] [blame] | 432 | if (curr->type == AGP_PHYS_MEMORY) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | if (curr->page_count == 4) |
Keir Fraser | 07eee78 | 2005-03-30 13:17:04 -0800 | [diff] [blame] | 434 | i8xx_destroy_pages(gart_to_virt(curr->memory[0])); |
Alan Hourihane | 88d5196 | 2005-11-06 23:35:34 -0800 | [diff] [blame] | 435 | else { |
Jan Beulich | da503fa | 2008-06-18 09:28:00 +0100 | [diff] [blame] | 436 | void *va = gart_to_virt(curr->memory[0]); |
| 437 | |
| 438 | agp_bridge->driver->agp_destroy_page(va, |
Dave Airlie | a2721e9 | 2007-10-15 10:19:16 +1000 | [diff] [blame] | 439 | AGP_PAGE_DESTROY_UNMAP); |
Jan Beulich | da503fa | 2008-06-18 09:28:00 +0100 | [diff] [blame] | 440 | agp_bridge->driver->agp_destroy_page(va, |
Dave Airlie | a2721e9 | 2007-10-15 10:19:16 +1000 | [diff] [blame] | 441 | AGP_PAGE_DESTROY_FREE); |
Alan Hourihane | 88d5196 | 2005-11-06 23:35:34 -0800 | [diff] [blame] | 442 | } |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 443 | agp_free_page_array(curr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | } |
| 445 | kfree(curr); |
| 446 | } |
| 447 | |
| 448 | static unsigned long intel_i810_mask_memory(struct agp_bridge_data *bridge, |
| 449 | unsigned long addr, int type) |
| 450 | { |
| 451 | /* Type checking must be done elsewhere */ |
| 452 | return addr | bridge->driver->masks[type].mask; |
| 453 | } |
| 454 | |
| 455 | static struct aper_size_info_fixed intel_i830_sizes[] = |
| 456 | { |
| 457 | {128, 32768, 5}, |
| 458 | /* The 64M mode still requires a 128k gatt */ |
| 459 | {64, 16384, 5}, |
| 460 | {256, 65536, 6}, |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 461 | {512, 131072, 7}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | }; |
| 463 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | static void intel_i830_init_gtt_entries(void) |
| 465 | { |
| 466 | u16 gmch_ctrl; |
| 467 | int gtt_entries; |
| 468 | u8 rdct; |
| 469 | int local = 0; |
| 470 | static const int ddt[4] = { 0, 16, 32, 64 }; |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 471 | int size; /* reserved space (in kb) at the top of stolen memory */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 473 | pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 475 | if (IS_I965) { |
| 476 | u32 pgetbl_ctl; |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 477 | pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL); |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 478 | |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 479 | /* The 965 has a field telling us the size of the GTT, |
| 480 | * which may be larger than what is necessary to map the |
| 481 | * aperture. |
| 482 | */ |
| 483 | switch (pgetbl_ctl & I965_PGETBL_SIZE_MASK) { |
| 484 | case I965_PGETBL_SIZE_128KB: |
| 485 | size = 128; |
| 486 | break; |
| 487 | case I965_PGETBL_SIZE_256KB: |
| 488 | size = 256; |
| 489 | break; |
| 490 | case I965_PGETBL_SIZE_512KB: |
| 491 | size = 512; |
| 492 | break; |
Zhenyu Wang | 4e8b6e2 | 2008-01-23 14:54:37 +1000 | [diff] [blame] | 493 | case I965_PGETBL_SIZE_1MB: |
| 494 | size = 1024; |
| 495 | break; |
| 496 | case I965_PGETBL_SIZE_2MB: |
| 497 | size = 2048; |
| 498 | break; |
| 499 | case I965_PGETBL_SIZE_1_5MB: |
| 500 | size = 1024 + 512; |
| 501 | break; |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 502 | default: |
| 503 | printk(KERN_INFO PFX "Unknown page table size, " |
| 504 | "assuming 512KB\n"); |
| 505 | size = 512; |
| 506 | } |
| 507 | size += 4; /* add in BIOS popup space */ |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 508 | } else if (IS_G33) { |
| 509 | /* G33's GTT size defined in gmch_ctrl */ |
| 510 | switch (gmch_ctrl & G33_PGETBL_SIZE_MASK) { |
| 511 | case G33_PGETBL_SIZE_1M: |
| 512 | size = 1024; |
| 513 | break; |
| 514 | case G33_PGETBL_SIZE_2M: |
| 515 | size = 2048; |
| 516 | break; |
| 517 | default: |
| 518 | printk(KERN_INFO PFX "Unknown page table size 0x%x, " |
| 519 | "assuming 512KB\n", |
| 520 | (gmch_ctrl & G33_PGETBL_SIZE_MASK)); |
| 521 | size = 512; |
| 522 | } |
| 523 | size += 4; |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 524 | } else if (IS_G4X) { |
| 525 | /* On 4 series hardware, GTT stolen is separate from graphics |
| 526 | * stolen, ignore it in stolen gtt entries counting */ |
| 527 | size = 0; |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 528 | } else { |
| 529 | /* On previous hardware, the GTT size was just what was |
| 530 | * required to map the aperture. |
| 531 | */ |
| 532 | size = agp_bridge->driver->fetch_size() + 4; |
| 533 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | |
| 535 | if (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82830_HB || |
| 536 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) { |
| 537 | switch (gmch_ctrl & I830_GMCH_GMS_MASK) { |
| 538 | case I830_GMCH_GMS_STOLEN_512: |
| 539 | gtt_entries = KB(512) - KB(size); |
| 540 | break; |
| 541 | case I830_GMCH_GMS_STOLEN_1024: |
| 542 | gtt_entries = MB(1) - KB(size); |
| 543 | break; |
| 544 | case I830_GMCH_GMS_STOLEN_8192: |
| 545 | gtt_entries = MB(8) - KB(size); |
| 546 | break; |
| 547 | case I830_GMCH_GMS_LOCAL: |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 548 | rdct = readb(intel_private.registers+I830_RDRAM_CHANNEL_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | gtt_entries = (I830_RDRAM_ND(rdct) + 1) * |
| 550 | MB(ddt[I830_RDRAM_DDT(rdct)]); |
| 551 | local = 1; |
| 552 | break; |
| 553 | default: |
| 554 | gtt_entries = 0; |
| 555 | break; |
| 556 | } |
| 557 | } else { |
Dave Airlie | e67aa27 | 2007-09-18 22:46:35 -0700 | [diff] [blame] | 558 | switch (gmch_ctrl & I855_GMCH_GMS_MASK) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 559 | case I855_GMCH_GMS_STOLEN_1M: |
| 560 | gtt_entries = MB(1) - KB(size); |
| 561 | break; |
| 562 | case I855_GMCH_GMS_STOLEN_4M: |
| 563 | gtt_entries = MB(4) - KB(size); |
| 564 | break; |
| 565 | case I855_GMCH_GMS_STOLEN_8M: |
| 566 | gtt_entries = MB(8) - KB(size); |
| 567 | break; |
| 568 | case I855_GMCH_GMS_STOLEN_16M: |
| 569 | gtt_entries = MB(16) - KB(size); |
| 570 | break; |
| 571 | case I855_GMCH_GMS_STOLEN_32M: |
| 572 | gtt_entries = MB(32) - KB(size); |
| 573 | break; |
| 574 | case I915_GMCH_GMS_STOLEN_48M: |
| 575 | /* Check it's really I915G */ |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 576 | if (IS_I915 || IS_I965 || IS_G33 || IS_G4X) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | gtt_entries = MB(48) - KB(size); |
| 578 | else |
| 579 | gtt_entries = 0; |
| 580 | break; |
| 581 | case I915_GMCH_GMS_STOLEN_64M: |
| 582 | /* Check it's really I915G */ |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 583 | if (IS_I915 || IS_I965 || IS_G33 || IS_G4X) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | gtt_entries = MB(64) - KB(size); |
| 585 | else |
| 586 | gtt_entries = 0; |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 587 | break; |
| 588 | case G33_GMCH_GMS_STOLEN_128M: |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 589 | if (IS_G33 || IS_I965 || IS_G4X) |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 590 | gtt_entries = MB(128) - KB(size); |
| 591 | else |
| 592 | gtt_entries = 0; |
| 593 | break; |
| 594 | case G33_GMCH_GMS_STOLEN_256M: |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 595 | if (IS_G33 || IS_I965 || IS_G4X) |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 596 | gtt_entries = MB(256) - KB(size); |
| 597 | else |
| 598 | gtt_entries = 0; |
| 599 | break; |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 600 | case INTEL_GMCH_GMS_STOLEN_96M: |
| 601 | if (IS_I965 || IS_G4X) |
| 602 | gtt_entries = MB(96) - KB(size); |
| 603 | else |
| 604 | gtt_entries = 0; |
| 605 | break; |
| 606 | case INTEL_GMCH_GMS_STOLEN_160M: |
| 607 | if (IS_I965 || IS_G4X) |
| 608 | gtt_entries = MB(160) - KB(size); |
| 609 | else |
| 610 | gtt_entries = 0; |
| 611 | break; |
| 612 | case INTEL_GMCH_GMS_STOLEN_224M: |
| 613 | if (IS_I965 || IS_G4X) |
| 614 | gtt_entries = MB(224) - KB(size); |
| 615 | else |
| 616 | gtt_entries = 0; |
| 617 | break; |
| 618 | case INTEL_GMCH_GMS_STOLEN_352M: |
| 619 | if (IS_I965 || IS_G4X) |
| 620 | gtt_entries = MB(352) - KB(size); |
| 621 | else |
| 622 | gtt_entries = 0; |
| 623 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | default: |
| 625 | gtt_entries = 0; |
| 626 | break; |
| 627 | } |
| 628 | } |
| 629 | if (gtt_entries > 0) |
| 630 | printk(KERN_INFO PFX "Detected %dK %s memory.\n", |
| 631 | gtt_entries / KB(1), local ? "local" : "stolen"); |
| 632 | else |
| 633 | printk(KERN_INFO PFX |
| 634 | "No pre-allocated video memory detected.\n"); |
| 635 | gtt_entries /= KB(4); |
| 636 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 637 | intel_private.gtt_entries = gtt_entries; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | } |
| 639 | |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 640 | static void intel_i830_fini_flush(void) |
| 641 | { |
| 642 | kunmap(intel_private.i8xx_page); |
| 643 | intel_private.i8xx_flush_page = NULL; |
| 644 | unmap_page_from_agp(intel_private.i8xx_page); |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 645 | |
| 646 | __free_page(intel_private.i8xx_page); |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 647 | intel_private.i8xx_page = NULL; |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 648 | } |
| 649 | |
| 650 | static void intel_i830_setup_flush(void) |
| 651 | { |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 652 | /* return if we've already set the flush mechanism up */ |
| 653 | if (intel_private.i8xx_page) |
| 654 | return; |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 655 | |
| 656 | intel_private.i8xx_page = alloc_page(GFP_KERNEL | __GFP_ZERO | GFP_DMA32); |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 657 | if (!intel_private.i8xx_page) |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 658 | return; |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 659 | |
| 660 | /* make page uncached */ |
| 661 | map_page_into_agp(intel_private.i8xx_page); |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 662 | |
| 663 | intel_private.i8xx_flush_page = kmap(intel_private.i8xx_page); |
| 664 | if (!intel_private.i8xx_flush_page) |
| 665 | intel_i830_fini_flush(); |
| 666 | } |
| 667 | |
| 668 | static void intel_i830_chipset_flush(struct agp_bridge_data *bridge) |
| 669 | { |
| 670 | unsigned int *pg = intel_private.i8xx_flush_page; |
| 671 | int i; |
| 672 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 673 | for (i = 0; i < 256; i += 2) |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 674 | *(pg + i) = i; |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 675 | |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 676 | wmb(); |
| 677 | } |
| 678 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | /* The intel i830 automatically initializes the agp aperture during POST. |
| 680 | * Use the memory already set aside for in the GTT. |
| 681 | */ |
| 682 | static int intel_i830_create_gatt_table(struct agp_bridge_data *bridge) |
| 683 | { |
| 684 | int page_order; |
| 685 | struct aper_size_info_fixed *size; |
| 686 | int num_entries; |
| 687 | u32 temp; |
| 688 | |
| 689 | size = agp_bridge->current_size; |
| 690 | page_order = size->page_order; |
| 691 | num_entries = size->num_entries; |
| 692 | agp_bridge->gatt_table_real = NULL; |
| 693 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 694 | pci_read_config_dword(intel_private.pcidev, I810_MMADDR, &temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 695 | temp &= 0xfff80000; |
| 696 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 697 | intel_private.registers = ioremap(temp, 128 * 4096); |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 698 | if (!intel_private.registers) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | return -ENOMEM; |
| 700 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 701 | temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | global_cache_flush(); /* FIXME: ?? */ |
| 703 | |
| 704 | /* we have to call this as early as possible after the MMIO base address is known */ |
| 705 | intel_i830_init_gtt_entries(); |
| 706 | |
| 707 | agp_bridge->gatt_table = NULL; |
| 708 | |
| 709 | agp_bridge->gatt_bus_addr = temp; |
| 710 | |
| 711 | return 0; |
| 712 | } |
| 713 | |
| 714 | /* Return the gatt table to a sane state. Use the top of stolen |
| 715 | * memory for the GTT. |
| 716 | */ |
| 717 | static int intel_i830_free_gatt_table(struct agp_bridge_data *bridge) |
| 718 | { |
| 719 | return 0; |
| 720 | } |
| 721 | |
| 722 | static int intel_i830_fetch_size(void) |
| 723 | { |
| 724 | u16 gmch_ctrl; |
| 725 | struct aper_size_info_fixed *values; |
| 726 | |
| 727 | values = A_SIZE_FIX(agp_bridge->driver->aperture_sizes); |
| 728 | |
| 729 | if (agp_bridge->dev->device != PCI_DEVICE_ID_INTEL_82830_HB && |
| 730 | agp_bridge->dev->device != PCI_DEVICE_ID_INTEL_82845G_HB) { |
| 731 | /* 855GM/852GM/865G has 128MB aperture size */ |
| 732 | agp_bridge->previous_size = agp_bridge->current_size = (void *) values; |
| 733 | agp_bridge->aperture_size_idx = 0; |
| 734 | return values[0].size; |
| 735 | } |
| 736 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 737 | pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 738 | |
| 739 | if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_128M) { |
| 740 | agp_bridge->previous_size = agp_bridge->current_size = (void *) values; |
| 741 | agp_bridge->aperture_size_idx = 0; |
| 742 | return values[0].size; |
| 743 | } else { |
| 744 | agp_bridge->previous_size = agp_bridge->current_size = (void *) (values + 1); |
| 745 | agp_bridge->aperture_size_idx = 1; |
| 746 | return values[1].size; |
| 747 | } |
| 748 | |
| 749 | return 0; |
| 750 | } |
| 751 | |
| 752 | static int intel_i830_configure(void) |
| 753 | { |
| 754 | struct aper_size_info_fixed *current_size; |
| 755 | u32 temp; |
| 756 | u16 gmch_ctrl; |
| 757 | int i; |
| 758 | |
| 759 | current_size = A_SIZE_FIX(agp_bridge->current_size); |
| 760 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 761 | pci_read_config_dword(intel_private.pcidev, I810_GMADDR, &temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 762 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 763 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 764 | pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | gmch_ctrl |= I830_GMCH_ENABLED; |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 766 | pci_write_config_word(agp_bridge->dev, I830_GMCH_CTRL, gmch_ctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 767 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 768 | writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL); |
| 769 | readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 770 | |
| 771 | if (agp_bridge->driver->needs_scratch_page) { |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 772 | for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) { |
| 773 | writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4)); |
| 774 | readl(intel_private.registers+I810_PTE_BASE+(i*4)); /* PCI Posting. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 775 | } |
| 776 | } |
| 777 | |
| 778 | global_cache_flush(); |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 779 | |
| 780 | intel_i830_setup_flush(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 781 | return 0; |
| 782 | } |
| 783 | |
| 784 | static void intel_i830_cleanup(void) |
| 785 | { |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 786 | iounmap(intel_private.registers); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | } |
| 788 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 789 | static int intel_i830_insert_entries(struct agp_memory *mem, off_t pg_start, |
| 790 | int type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 791 | { |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 792 | int i, j, num_entries; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 793 | void *temp; |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 794 | int ret = -EINVAL; |
| 795 | int mask_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 797 | if (mem->page_count == 0) |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 798 | goto out; |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 799 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 800 | temp = agp_bridge->current_size; |
| 801 | num_entries = A_SIZE_FIX(temp)->num_entries; |
| 802 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 803 | if (pg_start < intel_private.gtt_entries) { |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 804 | printk(KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_private.gtt_entries == 0x%.8x\n", |
| 805 | pg_start, intel_private.gtt_entries); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 807 | printk(KERN_INFO PFX "Trying to insert into local/stolen memory\n"); |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 808 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 809 | } |
| 810 | |
| 811 | if ((pg_start + mem->page_count) > num_entries) |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 812 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | |
| 814 | /* The i830 can't check the GTT for entries since its read only, |
| 815 | * depend on the caller to make the correct offset decisions. |
| 816 | */ |
| 817 | |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 818 | if (type != mem->type) |
| 819 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 820 | |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 821 | mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type); |
| 822 | |
| 823 | if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY && |
| 824 | mask_type != INTEL_AGP_CACHED_MEMORY) |
| 825 | goto out_err; |
| 826 | |
| 827 | if (!mem->is_flushed) |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 828 | global_cache_flush(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 829 | |
| 830 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { |
| 831 | writel(agp_bridge->driver->mask_memory(agp_bridge, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 832 | mem->memory[i], mask_type), |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 833 | intel_private.registers+I810_PTE_BASE+(j*4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 834 | } |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 835 | readl(intel_private.registers+I810_PTE_BASE+((j-1)*4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | agp_bridge->driver->tlb_flush(mem); |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 837 | |
| 838 | out: |
| 839 | ret = 0; |
| 840 | out_err: |
Dave Airlie | 9516b03 | 2008-06-19 10:42:17 +1000 | [diff] [blame] | 841 | mem->is_flushed = true; |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 842 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | } |
| 844 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 845 | static int intel_i830_remove_entries(struct agp_memory *mem, off_t pg_start, |
| 846 | int type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | { |
| 848 | int i; |
| 849 | |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 850 | if (mem->page_count == 0) |
| 851 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 852 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 853 | if (pg_start < intel_private.gtt_entries) { |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 854 | printk(KERN_INFO PFX "Trying to disable local/stolen memory\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 855 | return -EINVAL; |
| 856 | } |
| 857 | |
| 858 | for (i = pg_start; i < (mem->page_count + pg_start); i++) { |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 859 | writel(agp_bridge->scratch_page, intel_private.registers+I810_PTE_BASE+(i*4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 860 | } |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 861 | readl(intel_private.registers+I810_PTE_BASE+((i-1)*4)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 863 | agp_bridge->driver->tlb_flush(mem); |
| 864 | return 0; |
| 865 | } |
| 866 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 867 | static struct agp_memory *intel_i830_alloc_by_type(size_t pg_count, int type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 868 | { |
| 869 | if (type == AGP_PHYS_MEMORY) |
| 870 | return alloc_agpphysmem_i8xx(pg_count, type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | /* always return NULL for other allocation types for now */ |
| 872 | return NULL; |
| 873 | } |
| 874 | |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 875 | static int intel_alloc_chipset_flush_resource(void) |
| 876 | { |
| 877 | int ret; |
| 878 | ret = pci_bus_alloc_resource(agp_bridge->dev->bus, &intel_private.ifp_resource, PAGE_SIZE, |
| 879 | PAGE_SIZE, PCIBIOS_MIN_MEM, 0, |
| 880 | pcibios_align_resource, agp_bridge->dev); |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 881 | |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 882 | return ret; |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 883 | } |
| 884 | |
| 885 | static void intel_i915_setup_chipset_flush(void) |
| 886 | { |
| 887 | int ret; |
| 888 | u32 temp; |
| 889 | |
| 890 | pci_read_config_dword(agp_bridge->dev, I915_IFPADDR, &temp); |
| 891 | if (!(temp & 0x1)) { |
| 892 | intel_alloc_chipset_flush_resource(); |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 893 | intel_private.resource_valid = 1; |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 894 | pci_write_config_dword(agp_bridge->dev, I915_IFPADDR, (intel_private.ifp_resource.start & 0xffffffff) | 0x1); |
| 895 | } else { |
| 896 | temp &= ~1; |
| 897 | |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 898 | intel_private.resource_valid = 1; |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 899 | intel_private.ifp_resource.start = temp; |
| 900 | intel_private.ifp_resource.end = temp + PAGE_SIZE; |
| 901 | ret = request_resource(&iomem_resource, &intel_private.ifp_resource); |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 902 | /* some BIOSes reserve this area in a pnp some don't */ |
| 903 | if (ret) |
| 904 | intel_private.resource_valid = 0; |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 905 | } |
| 906 | } |
| 907 | |
| 908 | static void intel_i965_g33_setup_chipset_flush(void) |
| 909 | { |
| 910 | u32 temp_hi, temp_lo; |
| 911 | int ret; |
| 912 | |
| 913 | pci_read_config_dword(agp_bridge->dev, I965_IFPADDR + 4, &temp_hi); |
| 914 | pci_read_config_dword(agp_bridge->dev, I965_IFPADDR, &temp_lo); |
| 915 | |
| 916 | if (!(temp_lo & 0x1)) { |
| 917 | |
| 918 | intel_alloc_chipset_flush_resource(); |
| 919 | |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 920 | intel_private.resource_valid = 1; |
Andrew Morton | 1fa4db7 | 2007-11-29 10:00:48 +1000 | [diff] [blame] | 921 | pci_write_config_dword(agp_bridge->dev, I965_IFPADDR + 4, |
| 922 | upper_32_bits(intel_private.ifp_resource.start)); |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 923 | pci_write_config_dword(agp_bridge->dev, I965_IFPADDR, (intel_private.ifp_resource.start & 0xffffffff) | 0x1); |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 924 | } else { |
| 925 | u64 l64; |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 926 | |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 927 | temp_lo &= ~0x1; |
| 928 | l64 = ((u64)temp_hi << 32) | temp_lo; |
| 929 | |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 930 | intel_private.resource_valid = 1; |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 931 | intel_private.ifp_resource.start = l64; |
| 932 | intel_private.ifp_resource.end = l64 + PAGE_SIZE; |
| 933 | ret = request_resource(&iomem_resource, &intel_private.ifp_resource); |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 934 | /* some BIOSes reserve this area in a pnp some don't */ |
| 935 | if (ret) |
| 936 | intel_private.resource_valid = 0; |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 937 | } |
| 938 | } |
| 939 | |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 940 | static void intel_i9xx_setup_flush(void) |
| 941 | { |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 942 | /* return if already configured */ |
| 943 | if (intel_private.ifp_resource.start) |
| 944 | return; |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 945 | |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 946 | /* setup a resource for this object */ |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 947 | intel_private.ifp_resource.name = "Intel Flush Page"; |
| 948 | intel_private.ifp_resource.flags = IORESOURCE_MEM; |
| 949 | |
| 950 | /* Setup chipset flush for 915 */ |
Zhenyu Wang | 7d15ddf | 2008-06-20 11:48:06 +1000 | [diff] [blame] | 951 | if (IS_I965 || IS_G33 || IS_G4X) { |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 952 | intel_i965_g33_setup_chipset_flush(); |
| 953 | } else { |
| 954 | intel_i915_setup_chipset_flush(); |
| 955 | } |
| 956 | |
| 957 | if (intel_private.ifp_resource.start) { |
| 958 | intel_private.i9xx_flush_page = ioremap_nocache(intel_private.ifp_resource.start, PAGE_SIZE); |
| 959 | if (!intel_private.i9xx_flush_page) |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 960 | printk(KERN_INFO "unable to ioremap flush page - no chipset flushing"); |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 961 | } |
| 962 | } |
| 963 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 964 | static int intel_i915_configure(void) |
| 965 | { |
| 966 | struct aper_size_info_fixed *current_size; |
| 967 | u32 temp; |
| 968 | u16 gmch_ctrl; |
| 969 | int i; |
| 970 | |
| 971 | current_size = A_SIZE_FIX(agp_bridge->current_size); |
| 972 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 973 | pci_read_config_dword(intel_private.pcidev, I915_GMADDR, &temp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 974 | |
| 975 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 976 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 977 | pci_read_config_word(agp_bridge->dev, I830_GMCH_CTRL, &gmch_ctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 978 | gmch_ctrl |= I830_GMCH_ENABLED; |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 979 | pci_write_config_word(agp_bridge->dev, I830_GMCH_CTRL, gmch_ctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 980 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 981 | writel(agp_bridge->gatt_bus_addr|I810_PGETBL_ENABLED, intel_private.registers+I810_PGETBL_CTL); |
| 982 | readl(intel_private.registers+I810_PGETBL_CTL); /* PCI Posting. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | |
| 984 | if (agp_bridge->driver->needs_scratch_page) { |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 985 | for (i = intel_private.gtt_entries; i < current_size->num_entries; i++) { |
| 986 | writel(agp_bridge->scratch_page, intel_private.gtt+i); |
| 987 | readl(intel_private.gtt+i); /* PCI Posting. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 | } |
| 989 | } |
| 990 | |
| 991 | global_cache_flush(); |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 992 | |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 993 | intel_i9xx_setup_flush(); |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 994 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 995 | return 0; |
| 996 | } |
| 997 | |
| 998 | static void intel_i915_cleanup(void) |
| 999 | { |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 1000 | if (intel_private.i9xx_flush_page) |
| 1001 | iounmap(intel_private.i9xx_flush_page); |
Dave Airlie | 4d64dd9 | 2008-01-23 15:34:29 +1000 | [diff] [blame] | 1002 | if (intel_private.resource_valid) |
| 1003 | release_resource(&intel_private.ifp_resource); |
| 1004 | intel_private.ifp_resource.start = 0; |
| 1005 | intel_private.resource_valid = 0; |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1006 | iounmap(intel_private.gtt); |
| 1007 | iounmap(intel_private.registers); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1008 | } |
| 1009 | |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 1010 | static void intel_i915_chipset_flush(struct agp_bridge_data *bridge) |
| 1011 | { |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 1012 | if (intel_private.i9xx_flush_page) |
| 1013 | writel(1, intel_private.i9xx_flush_page); |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 1014 | } |
| 1015 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1016 | static int intel_i915_insert_entries(struct agp_memory *mem, off_t pg_start, |
| 1017 | int type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1018 | { |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1019 | int i, j, num_entries; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1020 | void *temp; |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1021 | int ret = -EINVAL; |
| 1022 | int mask_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1023 | |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 1024 | if (mem->page_count == 0) |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1025 | goto out; |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 1026 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | temp = agp_bridge->current_size; |
| 1028 | num_entries = A_SIZE_FIX(temp)->num_entries; |
| 1029 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1030 | if (pg_start < intel_private.gtt_entries) { |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1031 | printk(KERN_DEBUG PFX "pg_start == 0x%.8lx,intel_private.gtt_entries == 0x%.8x\n", |
| 1032 | pg_start, intel_private.gtt_entries); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1033 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1034 | printk(KERN_INFO PFX "Trying to insert into local/stolen memory\n"); |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1035 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1036 | } |
| 1037 | |
| 1038 | if ((pg_start + mem->page_count) > num_entries) |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1039 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1040 | |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1041 | /* The i915 can't check the GTT for entries since its read only, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1042 | * depend on the caller to make the correct offset decisions. |
| 1043 | */ |
| 1044 | |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1045 | if (type != mem->type) |
| 1046 | goto out_err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1047 | |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1048 | mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type); |
| 1049 | |
| 1050 | if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY && |
| 1051 | mask_type != INTEL_AGP_CACHED_MEMORY) |
| 1052 | goto out_err; |
| 1053 | |
| 1054 | if (!mem->is_flushed) |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 1055 | global_cache_flush(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1056 | |
| 1057 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { |
| 1058 | writel(agp_bridge->driver->mask_memory(agp_bridge, |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1059 | mem->memory[i], mask_type), intel_private.gtt+j); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1060 | } |
| 1061 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1062 | readl(intel_private.gtt+j-1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | agp_bridge->driver->tlb_flush(mem); |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1064 | |
| 1065 | out: |
| 1066 | ret = 0; |
| 1067 | out_err: |
Dave Airlie | 9516b03 | 2008-06-19 10:42:17 +1000 | [diff] [blame] | 1068 | mem->is_flushed = true; |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1069 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1070 | } |
| 1071 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1072 | static int intel_i915_remove_entries(struct agp_memory *mem, off_t pg_start, |
| 1073 | int type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1074 | { |
| 1075 | int i; |
| 1076 | |
Thomas Hellstrom | 5aa80c7 | 2006-12-20 16:33:41 +0100 | [diff] [blame] | 1077 | if (mem->page_count == 0) |
| 1078 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1079 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1080 | if (pg_start < intel_private.gtt_entries) { |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1081 | printk(KERN_INFO PFX "Trying to disable local/stolen memory\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1082 | return -EINVAL; |
| 1083 | } |
| 1084 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1085 | for (i = pg_start; i < (mem->page_count + pg_start); i++) |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1086 | writel(agp_bridge->scratch_page, intel_private.gtt+i); |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1087 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1088 | readl(intel_private.gtt+i-1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1089 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1090 | agp_bridge->driver->tlb_flush(mem); |
| 1091 | return 0; |
| 1092 | } |
| 1093 | |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 1094 | /* Return the aperture size by just checking the resource length. The effect |
| 1095 | * described in the spec of the MSAC registers is just changing of the |
| 1096 | * resource size. |
| 1097 | */ |
| 1098 | static int intel_i9xx_fetch_size(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1099 | { |
Ahmed S. Darwish | 1eaf122 | 2007-02-06 18:08:28 +0200 | [diff] [blame] | 1100 | int num_sizes = ARRAY_SIZE(intel_i830_sizes); |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 1101 | int aper_size; /* size in megabytes */ |
| 1102 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1103 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1104 | aper_size = pci_resource_len(intel_private.pcidev, 2) / MB(1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1105 | |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 1106 | for (i = 0; i < num_sizes; i++) { |
| 1107 | if (aper_size == intel_i830_sizes[i].size) { |
| 1108 | agp_bridge->current_size = intel_i830_sizes + i; |
| 1109 | agp_bridge->previous_size = agp_bridge->current_size; |
| 1110 | return aper_size; |
| 1111 | } |
| 1112 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1113 | |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 1114 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1115 | } |
| 1116 | |
| 1117 | /* The intel i915 automatically initializes the agp aperture during POST. |
| 1118 | * Use the memory already set aside for in the GTT. |
| 1119 | */ |
| 1120 | static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge) |
| 1121 | { |
| 1122 | int page_order; |
| 1123 | struct aper_size_info_fixed *size; |
| 1124 | int num_entries; |
| 1125 | u32 temp, temp2; |
Zhenyu Wang | 4740622 | 2007-09-11 15:23:58 -0700 | [diff] [blame] | 1126 | int gtt_map_size = 256 * 1024; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1127 | |
| 1128 | size = agp_bridge->current_size; |
| 1129 | page_order = size->page_order; |
| 1130 | num_entries = size->num_entries; |
| 1131 | agp_bridge->gatt_table_real = NULL; |
| 1132 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1133 | pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &temp); |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1134 | pci_read_config_dword(intel_private.pcidev, I915_PTEADDR, &temp2); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1135 | |
Zhenyu Wang | 4740622 | 2007-09-11 15:23:58 -0700 | [diff] [blame] | 1136 | if (IS_G33) |
| 1137 | gtt_map_size = 1024 * 1024; /* 1M on G33 */ |
| 1138 | intel_private.gtt = ioremap(temp2, gtt_map_size); |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1139 | if (!intel_private.gtt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1140 | return -ENOMEM; |
| 1141 | |
| 1142 | temp &= 0xfff80000; |
| 1143 | |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1144 | intel_private.registers = ioremap(temp, 128 * 4096); |
Scott Thompson | 5bdbc7d | 2007-08-25 18:14:00 +1000 | [diff] [blame] | 1145 | if (!intel_private.registers) { |
| 1146 | iounmap(intel_private.gtt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1147 | return -ENOMEM; |
Scott Thompson | 5bdbc7d | 2007-08-25 18:14:00 +1000 | [diff] [blame] | 1148 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1149 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 1150 | temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1151 | global_cache_flush(); /* FIXME: ? */ |
| 1152 | |
| 1153 | /* we have to call this as early as possible after the MMIO base address is known */ |
| 1154 | intel_i830_init_gtt_entries(); |
| 1155 | |
| 1156 | agp_bridge->gatt_table = NULL; |
| 1157 | |
| 1158 | agp_bridge->gatt_bus_addr = temp; |
| 1159 | |
| 1160 | return 0; |
| 1161 | } |
Linus Torvalds | 7d915a3 | 2006-11-22 09:37:54 -0800 | [diff] [blame] | 1162 | |
| 1163 | /* |
| 1164 | * The i965 supports 36-bit physical addresses, but to keep |
| 1165 | * the format of the GTT the same, the bits that don't fit |
| 1166 | * in a 32-bit word are shifted down to bits 4..7. |
| 1167 | * |
| 1168 | * Gcc is smart enough to notice that "(addr >> 28) & 0xf0" |
| 1169 | * is always zero on 32-bit architectures, so no need to make |
| 1170 | * this conditional. |
| 1171 | */ |
| 1172 | static unsigned long intel_i965_mask_memory(struct agp_bridge_data *bridge, |
| 1173 | unsigned long addr, int type) |
| 1174 | { |
| 1175 | /* Shift high bits down */ |
| 1176 | addr |= (addr >> 28) & 0xf0; |
| 1177 | |
| 1178 | /* Type checking must be done elsewhere */ |
| 1179 | return addr | bridge->driver->masks[type].mask; |
| 1180 | } |
| 1181 | |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 1182 | static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size) |
| 1183 | { |
| 1184 | switch (agp_bridge->dev->device) { |
| 1185 | case PCI_DEVICE_ID_INTEL_IGD_HB: |
| 1186 | case PCI_DEVICE_ID_INTEL_IGD_E_HB: |
| 1187 | case PCI_DEVICE_ID_INTEL_Q45_HB: |
| 1188 | case PCI_DEVICE_ID_INTEL_G45_HB: |
| 1189 | *gtt_offset = *gtt_size = MB(2); |
| 1190 | break; |
| 1191 | default: |
| 1192 | *gtt_offset = *gtt_size = KB(512); |
| 1193 | } |
| 1194 | } |
| 1195 | |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1196 | /* The intel i965 automatically initializes the agp aperture during POST. |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 1197 | * Use the memory already set aside for in the GTT. |
| 1198 | */ |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1199 | static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge) |
| 1200 | { |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1201 | int page_order; |
| 1202 | struct aper_size_info_fixed *size; |
| 1203 | int num_entries; |
| 1204 | u32 temp; |
| 1205 | int gtt_offset, gtt_size; |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1206 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1207 | size = agp_bridge->current_size; |
| 1208 | page_order = size->page_order; |
| 1209 | num_entries = size->num_entries; |
| 1210 | agp_bridge->gatt_table_real = NULL; |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1211 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1212 | pci_read_config_dword(intel_private.pcidev, I915_MMADDR, &temp); |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1213 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1214 | temp &= 0xfff00000; |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1215 | |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 1216 | intel_i965_get_gtt_range(>t_offset, >t_size); |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1217 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1218 | intel_private.gtt = ioremap((temp + gtt_offset) , gtt_size); |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1219 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1220 | if (!intel_private.gtt) |
| 1221 | return -ENOMEM; |
Zhenyu Wang | 4e8b6e2 | 2008-01-23 14:54:37 +1000 | [diff] [blame] | 1222 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1223 | intel_private.registers = ioremap(temp, 128 * 4096); |
| 1224 | if (!intel_private.registers) { |
Scott Thompson | 5bdbc7d | 2007-08-25 18:14:00 +1000 | [diff] [blame] | 1225 | iounmap(intel_private.gtt); |
| 1226 | return -ENOMEM; |
| 1227 | } |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1228 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1229 | temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000; |
| 1230 | global_cache_flush(); /* FIXME: ? */ |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1231 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1232 | /* we have to call this as early as possible after the MMIO base address is known */ |
| 1233 | intel_i830_init_gtt_entries(); |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1234 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1235 | agp_bridge->gatt_table = NULL; |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1236 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1237 | agp_bridge->gatt_bus_addr = temp; |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1238 | |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1239 | return 0; |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 1240 | } |
| 1241 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1242 | |
| 1243 | static int intel_fetch_size(void) |
| 1244 | { |
| 1245 | int i; |
| 1246 | u16 temp; |
| 1247 | struct aper_size_info_16 *values; |
| 1248 | |
| 1249 | pci_read_config_word(agp_bridge->dev, INTEL_APSIZE, &temp); |
| 1250 | values = A_SIZE_16(agp_bridge->driver->aperture_sizes); |
| 1251 | |
| 1252 | for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) { |
| 1253 | if (temp == values[i].size_value) { |
| 1254 | agp_bridge->previous_size = agp_bridge->current_size = (void *) (values + i); |
| 1255 | agp_bridge->aperture_size_idx = i; |
| 1256 | return values[i].size; |
| 1257 | } |
| 1258 | } |
| 1259 | |
| 1260 | return 0; |
| 1261 | } |
| 1262 | |
| 1263 | static int __intel_8xx_fetch_size(u8 temp) |
| 1264 | { |
| 1265 | int i; |
| 1266 | struct aper_size_info_8 *values; |
| 1267 | |
| 1268 | values = A_SIZE_8(agp_bridge->driver->aperture_sizes); |
| 1269 | |
| 1270 | for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) { |
| 1271 | if (temp == values[i].size_value) { |
| 1272 | agp_bridge->previous_size = |
| 1273 | agp_bridge->current_size = (void *) (values + i); |
| 1274 | agp_bridge->aperture_size_idx = i; |
| 1275 | return values[i].size; |
| 1276 | } |
| 1277 | } |
| 1278 | return 0; |
| 1279 | } |
| 1280 | |
| 1281 | static int intel_8xx_fetch_size(void) |
| 1282 | { |
| 1283 | u8 temp; |
| 1284 | |
| 1285 | pci_read_config_byte(agp_bridge->dev, INTEL_APSIZE, &temp); |
| 1286 | return __intel_8xx_fetch_size(temp); |
| 1287 | } |
| 1288 | |
| 1289 | static int intel_815_fetch_size(void) |
| 1290 | { |
| 1291 | u8 temp; |
| 1292 | |
| 1293 | /* Intel 815 chipsets have a _weird_ APSIZE register with only |
| 1294 | * one non-reserved bit, so mask the others out ... */ |
| 1295 | pci_read_config_byte(agp_bridge->dev, INTEL_APSIZE, &temp); |
| 1296 | temp &= (1 << 3); |
| 1297 | |
| 1298 | return __intel_8xx_fetch_size(temp); |
| 1299 | } |
| 1300 | |
| 1301 | static void intel_tlbflush(struct agp_memory *mem) |
| 1302 | { |
| 1303 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2200); |
| 1304 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2280); |
| 1305 | } |
| 1306 | |
| 1307 | |
| 1308 | static void intel_8xx_tlbflush(struct agp_memory *mem) |
| 1309 | { |
| 1310 | u32 temp; |
| 1311 | pci_read_config_dword(agp_bridge->dev, INTEL_AGPCTRL, &temp); |
| 1312 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, temp & ~(1 << 7)); |
| 1313 | pci_read_config_dword(agp_bridge->dev, INTEL_AGPCTRL, &temp); |
| 1314 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, temp | (1 << 7)); |
| 1315 | } |
| 1316 | |
| 1317 | |
| 1318 | static void intel_cleanup(void) |
| 1319 | { |
| 1320 | u16 temp; |
| 1321 | struct aper_size_info_16 *previous_size; |
| 1322 | |
| 1323 | previous_size = A_SIZE_16(agp_bridge->previous_size); |
| 1324 | pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp); |
| 1325 | pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp & ~(1 << 9)); |
| 1326 | pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, previous_size->size_value); |
| 1327 | } |
| 1328 | |
| 1329 | |
| 1330 | static void intel_8xx_cleanup(void) |
| 1331 | { |
| 1332 | u16 temp; |
| 1333 | struct aper_size_info_8 *previous_size; |
| 1334 | |
| 1335 | previous_size = A_SIZE_8(agp_bridge->previous_size); |
| 1336 | pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp); |
| 1337 | pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp & ~(1 << 9)); |
| 1338 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, previous_size->size_value); |
| 1339 | } |
| 1340 | |
| 1341 | |
| 1342 | static int intel_configure(void) |
| 1343 | { |
| 1344 | u32 temp; |
| 1345 | u16 temp2; |
| 1346 | struct aper_size_info_16 *current_size; |
| 1347 | |
| 1348 | current_size = A_SIZE_16(agp_bridge->current_size); |
| 1349 | |
| 1350 | /* aperture size */ |
| 1351 | pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 1352 | |
| 1353 | /* address to map to */ |
| 1354 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 1355 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1356 | |
| 1357 | /* attbase - aperture base */ |
| 1358 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 1359 | |
| 1360 | /* agpctrl */ |
| 1361 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2280); |
| 1362 | |
| 1363 | /* paccfg/nbxcfg */ |
| 1364 | pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp2); |
| 1365 | pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, |
| 1366 | (temp2 & ~(1 << 10)) | (1 << 9)); |
| 1367 | /* clear any possible error conditions */ |
| 1368 | pci_write_config_byte(agp_bridge->dev, INTEL_ERRSTS + 1, 7); |
| 1369 | return 0; |
| 1370 | } |
| 1371 | |
| 1372 | static int intel_815_configure(void) |
| 1373 | { |
| 1374 | u32 temp, addr; |
| 1375 | u8 temp2; |
| 1376 | struct aper_size_info_8 *current_size; |
| 1377 | |
| 1378 | /* attbase - aperture base */ |
| 1379 | /* the Intel 815 chipset spec. says that bits 29-31 in the |
| 1380 | * ATTBASE register are reserved -> try not to write them */ |
| 1381 | if (agp_bridge->gatt_bus_addr & INTEL_815_ATTBASE_MASK) { |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 1382 | printk(KERN_EMERG PFX "gatt bus addr too high"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1383 | return -EINVAL; |
| 1384 | } |
| 1385 | |
| 1386 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 1387 | |
| 1388 | /* aperture size */ |
| 1389 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, |
| 1390 | current_size->size_value); |
| 1391 | |
| 1392 | /* address to map to */ |
| 1393 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 1394 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1395 | |
| 1396 | pci_read_config_dword(agp_bridge->dev, INTEL_ATTBASE, &addr); |
| 1397 | addr &= INTEL_815_ATTBASE_MASK; |
| 1398 | addr |= agp_bridge->gatt_bus_addr; |
| 1399 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, addr); |
| 1400 | |
| 1401 | /* agpctrl */ |
| 1402 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 1403 | |
| 1404 | /* apcont */ |
| 1405 | pci_read_config_byte(agp_bridge->dev, INTEL_815_APCONT, &temp2); |
| 1406 | pci_write_config_byte(agp_bridge->dev, INTEL_815_APCONT, temp2 | (1 << 1)); |
| 1407 | |
| 1408 | /* clear any possible error conditions */ |
| 1409 | /* Oddness : this chipset seems to have no ERRSTS register ! */ |
| 1410 | return 0; |
| 1411 | } |
| 1412 | |
| 1413 | static void intel_820_tlbflush(struct agp_memory *mem) |
| 1414 | { |
| 1415 | return; |
| 1416 | } |
| 1417 | |
| 1418 | static void intel_820_cleanup(void) |
| 1419 | { |
| 1420 | u8 temp; |
| 1421 | struct aper_size_info_8 *previous_size; |
| 1422 | |
| 1423 | previous_size = A_SIZE_8(agp_bridge->previous_size); |
| 1424 | pci_read_config_byte(agp_bridge->dev, INTEL_I820_RDCR, &temp); |
| 1425 | pci_write_config_byte(agp_bridge->dev, INTEL_I820_RDCR, |
| 1426 | temp & ~(1 << 1)); |
| 1427 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, |
| 1428 | previous_size->size_value); |
| 1429 | } |
| 1430 | |
| 1431 | |
| 1432 | static int intel_820_configure(void) |
| 1433 | { |
| 1434 | u32 temp; |
| 1435 | u8 temp2; |
| 1436 | struct aper_size_info_8 *current_size; |
| 1437 | |
| 1438 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 1439 | |
| 1440 | /* aperture size */ |
| 1441 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 1442 | |
| 1443 | /* address to map to */ |
| 1444 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 1445 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1446 | |
| 1447 | /* attbase - aperture base */ |
| 1448 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 1449 | |
| 1450 | /* agpctrl */ |
| 1451 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 1452 | |
| 1453 | /* global enable aperture access */ |
| 1454 | /* This flag is not accessed through MCHCFG register as in */ |
| 1455 | /* i850 chipset. */ |
| 1456 | pci_read_config_byte(agp_bridge->dev, INTEL_I820_RDCR, &temp2); |
| 1457 | pci_write_config_byte(agp_bridge->dev, INTEL_I820_RDCR, temp2 | (1 << 1)); |
| 1458 | /* clear any possible AGP-related error conditions */ |
| 1459 | pci_write_config_word(agp_bridge->dev, INTEL_I820_ERRSTS, 0x001c); |
| 1460 | return 0; |
| 1461 | } |
| 1462 | |
| 1463 | static int intel_840_configure(void) |
| 1464 | { |
| 1465 | u32 temp; |
| 1466 | u16 temp2; |
| 1467 | struct aper_size_info_8 *current_size; |
| 1468 | |
| 1469 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 1470 | |
| 1471 | /* aperture size */ |
| 1472 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 1473 | |
| 1474 | /* address to map to */ |
| 1475 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 1476 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1477 | |
| 1478 | /* attbase - aperture base */ |
| 1479 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 1480 | |
| 1481 | /* agpctrl */ |
| 1482 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 1483 | |
| 1484 | /* mcgcfg */ |
| 1485 | pci_read_config_word(agp_bridge->dev, INTEL_I840_MCHCFG, &temp2); |
| 1486 | pci_write_config_word(agp_bridge->dev, INTEL_I840_MCHCFG, temp2 | (1 << 9)); |
| 1487 | /* clear any possible error conditions */ |
| 1488 | pci_write_config_word(agp_bridge->dev, INTEL_I840_ERRSTS, 0xc000); |
| 1489 | return 0; |
| 1490 | } |
| 1491 | |
| 1492 | static int intel_845_configure(void) |
| 1493 | { |
| 1494 | u32 temp; |
| 1495 | u8 temp2; |
| 1496 | struct aper_size_info_8 *current_size; |
| 1497 | |
| 1498 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 1499 | |
| 1500 | /* aperture size */ |
| 1501 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 1502 | |
Matthew Garrett | b082548 | 2005-07-29 14:03:39 -0700 | [diff] [blame] | 1503 | if (agp_bridge->apbase_config != 0) { |
| 1504 | pci_write_config_dword(agp_bridge->dev, AGP_APBASE, |
| 1505 | agp_bridge->apbase_config); |
| 1506 | } else { |
| 1507 | /* address to map to */ |
| 1508 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 1509 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1510 | agp_bridge->apbase_config = temp; |
| 1511 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1512 | |
| 1513 | /* attbase - aperture base */ |
| 1514 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 1515 | |
| 1516 | /* agpctrl */ |
| 1517 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 1518 | |
| 1519 | /* agpm */ |
| 1520 | pci_read_config_byte(agp_bridge->dev, INTEL_I845_AGPM, &temp2); |
| 1521 | pci_write_config_byte(agp_bridge->dev, INTEL_I845_AGPM, temp2 | (1 << 1)); |
| 1522 | /* clear any possible error conditions */ |
| 1523 | pci_write_config_word(agp_bridge->dev, INTEL_I845_ERRSTS, 0x001c); |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 1524 | |
| 1525 | intel_i830_setup_flush(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1526 | return 0; |
| 1527 | } |
| 1528 | |
| 1529 | static int intel_850_configure(void) |
| 1530 | { |
| 1531 | u32 temp; |
| 1532 | u16 temp2; |
| 1533 | struct aper_size_info_8 *current_size; |
| 1534 | |
| 1535 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 1536 | |
| 1537 | /* aperture size */ |
| 1538 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 1539 | |
| 1540 | /* address to map to */ |
| 1541 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 1542 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1543 | |
| 1544 | /* attbase - aperture base */ |
| 1545 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 1546 | |
| 1547 | /* agpctrl */ |
| 1548 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 1549 | |
| 1550 | /* mcgcfg */ |
| 1551 | pci_read_config_word(agp_bridge->dev, INTEL_I850_MCHCFG, &temp2); |
| 1552 | pci_write_config_word(agp_bridge->dev, INTEL_I850_MCHCFG, temp2 | (1 << 9)); |
| 1553 | /* clear any possible AGP-related error conditions */ |
| 1554 | pci_write_config_word(agp_bridge->dev, INTEL_I850_ERRSTS, 0x001c); |
| 1555 | return 0; |
| 1556 | } |
| 1557 | |
| 1558 | static int intel_860_configure(void) |
| 1559 | { |
| 1560 | u32 temp; |
| 1561 | u16 temp2; |
| 1562 | struct aper_size_info_8 *current_size; |
| 1563 | |
| 1564 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 1565 | |
| 1566 | /* aperture size */ |
| 1567 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 1568 | |
| 1569 | /* address to map to */ |
| 1570 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 1571 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1572 | |
| 1573 | /* attbase - aperture base */ |
| 1574 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 1575 | |
| 1576 | /* agpctrl */ |
| 1577 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 1578 | |
| 1579 | /* mcgcfg */ |
| 1580 | pci_read_config_word(agp_bridge->dev, INTEL_I860_MCHCFG, &temp2); |
| 1581 | pci_write_config_word(agp_bridge->dev, INTEL_I860_MCHCFG, temp2 | (1 << 9)); |
| 1582 | /* clear any possible AGP-related error conditions */ |
| 1583 | pci_write_config_word(agp_bridge->dev, INTEL_I860_ERRSTS, 0xf700); |
| 1584 | return 0; |
| 1585 | } |
| 1586 | |
| 1587 | static int intel_830mp_configure(void) |
| 1588 | { |
| 1589 | u32 temp; |
| 1590 | u16 temp2; |
| 1591 | struct aper_size_info_8 *current_size; |
| 1592 | |
| 1593 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 1594 | |
| 1595 | /* aperture size */ |
| 1596 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 1597 | |
| 1598 | /* address to map to */ |
| 1599 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 1600 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1601 | |
| 1602 | /* attbase - aperture base */ |
| 1603 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 1604 | |
| 1605 | /* agpctrl */ |
| 1606 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 1607 | |
| 1608 | /* gmch */ |
| 1609 | pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp2); |
| 1610 | pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp2 | (1 << 9)); |
| 1611 | /* clear any possible AGP-related error conditions */ |
| 1612 | pci_write_config_word(agp_bridge->dev, INTEL_I830_ERRSTS, 0x1c); |
| 1613 | return 0; |
| 1614 | } |
| 1615 | |
| 1616 | static int intel_7505_configure(void) |
| 1617 | { |
| 1618 | u32 temp; |
| 1619 | u16 temp2; |
| 1620 | struct aper_size_info_8 *current_size; |
| 1621 | |
| 1622 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 1623 | |
| 1624 | /* aperture size */ |
| 1625 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 1626 | |
| 1627 | /* address to map to */ |
| 1628 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 1629 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 1630 | |
| 1631 | /* attbase - aperture base */ |
| 1632 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 1633 | |
| 1634 | /* agpctrl */ |
| 1635 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 1636 | |
| 1637 | /* mchcfg */ |
| 1638 | pci_read_config_word(agp_bridge->dev, INTEL_I7505_MCHCFG, &temp2); |
| 1639 | pci_write_config_word(agp_bridge->dev, INTEL_I7505_MCHCFG, temp2 | (1 << 9)); |
| 1640 | |
| 1641 | return 0; |
| 1642 | } |
| 1643 | |
| 1644 | /* Setup function */ |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1645 | static const struct gatt_mask intel_generic_masks[] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1646 | { |
| 1647 | {.mask = 0x00000017, .type = 0} |
| 1648 | }; |
| 1649 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1650 | static const struct aper_size_info_8 intel_815_sizes[2] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1651 | { |
| 1652 | {64, 16384, 4, 0}, |
| 1653 | {32, 8192, 3, 8}, |
| 1654 | }; |
| 1655 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1656 | static const struct aper_size_info_8 intel_8xx_sizes[7] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1657 | { |
| 1658 | {256, 65536, 6, 0}, |
| 1659 | {128, 32768, 5, 32}, |
| 1660 | {64, 16384, 4, 48}, |
| 1661 | {32, 8192, 3, 56}, |
| 1662 | {16, 4096, 2, 60}, |
| 1663 | {8, 2048, 1, 62}, |
| 1664 | {4, 1024, 0, 63} |
| 1665 | }; |
| 1666 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1667 | static const struct aper_size_info_16 intel_generic_sizes[7] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1668 | { |
| 1669 | {256, 65536, 6, 0}, |
| 1670 | {128, 32768, 5, 32}, |
| 1671 | {64, 16384, 4, 48}, |
| 1672 | {32, 8192, 3, 56}, |
| 1673 | {16, 4096, 2, 60}, |
| 1674 | {8, 2048, 1, 62}, |
| 1675 | {4, 1024, 0, 63} |
| 1676 | }; |
| 1677 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1678 | static const struct aper_size_info_8 intel_830mp_sizes[4] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1679 | { |
| 1680 | {256, 65536, 6, 0}, |
| 1681 | {128, 32768, 5, 32}, |
| 1682 | {64, 16384, 4, 48}, |
| 1683 | {32, 8192, 3, 56} |
| 1684 | }; |
| 1685 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1686 | static const struct agp_bridge_driver intel_generic_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1687 | .owner = THIS_MODULE, |
| 1688 | .aperture_sizes = intel_generic_sizes, |
| 1689 | .size_type = U16_APER_SIZE, |
| 1690 | .num_aperture_sizes = 7, |
| 1691 | .configure = intel_configure, |
| 1692 | .fetch_size = intel_fetch_size, |
| 1693 | .cleanup = intel_cleanup, |
| 1694 | .tlb_flush = intel_tlbflush, |
| 1695 | .mask_memory = agp_generic_mask_memory, |
| 1696 | .masks = intel_generic_masks, |
| 1697 | .agp_enable = agp_generic_enable, |
| 1698 | .cache_flush = global_cache_flush, |
| 1699 | .create_gatt_table = agp_generic_create_gatt_table, |
| 1700 | .free_gatt_table = agp_generic_free_gatt_table, |
| 1701 | .insert_memory = agp_generic_insert_memory, |
| 1702 | .remove_memory = agp_generic_remove_memory, |
| 1703 | .alloc_by_type = agp_generic_alloc_by_type, |
| 1704 | .free_by_type = agp_generic_free_by_type, |
| 1705 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 1706 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1707 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame^] | 1708 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1709 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1710 | }; |
| 1711 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1712 | static const struct agp_bridge_driver intel_810_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1713 | .owner = THIS_MODULE, |
| 1714 | .aperture_sizes = intel_i810_sizes, |
| 1715 | .size_type = FIXED_APER_SIZE, |
| 1716 | .num_aperture_sizes = 2, |
Joe Perches | c725801 | 2008-03-26 14:10:02 -0700 | [diff] [blame] | 1717 | .needs_scratch_page = true, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1718 | .configure = intel_i810_configure, |
| 1719 | .fetch_size = intel_i810_fetch_size, |
| 1720 | .cleanup = intel_i810_cleanup, |
| 1721 | .tlb_flush = intel_i810_tlbflush, |
| 1722 | .mask_memory = intel_i810_mask_memory, |
| 1723 | .masks = intel_i810_masks, |
| 1724 | .agp_enable = intel_i810_agp_enable, |
| 1725 | .cache_flush = global_cache_flush, |
| 1726 | .create_gatt_table = agp_generic_create_gatt_table, |
| 1727 | .free_gatt_table = agp_generic_free_gatt_table, |
| 1728 | .insert_memory = intel_i810_insert_entries, |
| 1729 | .remove_memory = intel_i810_remove_entries, |
| 1730 | .alloc_by_type = intel_i810_alloc_by_type, |
| 1731 | .free_by_type = intel_i810_free_by_type, |
| 1732 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 1733 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1734 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame^] | 1735 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1736 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1737 | }; |
| 1738 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1739 | static const struct agp_bridge_driver intel_815_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1740 | .owner = THIS_MODULE, |
| 1741 | .aperture_sizes = intel_815_sizes, |
| 1742 | .size_type = U8_APER_SIZE, |
| 1743 | .num_aperture_sizes = 2, |
| 1744 | .configure = intel_815_configure, |
| 1745 | .fetch_size = intel_815_fetch_size, |
| 1746 | .cleanup = intel_8xx_cleanup, |
| 1747 | .tlb_flush = intel_8xx_tlbflush, |
| 1748 | .mask_memory = agp_generic_mask_memory, |
| 1749 | .masks = intel_generic_masks, |
| 1750 | .agp_enable = agp_generic_enable, |
| 1751 | .cache_flush = global_cache_flush, |
| 1752 | .create_gatt_table = agp_generic_create_gatt_table, |
| 1753 | .free_gatt_table = agp_generic_free_gatt_table, |
| 1754 | .insert_memory = agp_generic_insert_memory, |
| 1755 | .remove_memory = agp_generic_remove_memory, |
| 1756 | .alloc_by_type = agp_generic_alloc_by_type, |
| 1757 | .free_by_type = agp_generic_free_by_type, |
| 1758 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 1759 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1760 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame^] | 1761 | .agp_destroy_pages = agp_generic_destroy_pages, |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1762 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1763 | }; |
| 1764 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1765 | static const struct agp_bridge_driver intel_830_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1766 | .owner = THIS_MODULE, |
| 1767 | .aperture_sizes = intel_i830_sizes, |
| 1768 | .size_type = FIXED_APER_SIZE, |
Dave Jones | c14635e | 2006-09-06 11:59:35 -0400 | [diff] [blame] | 1769 | .num_aperture_sizes = 4, |
Joe Perches | c725801 | 2008-03-26 14:10:02 -0700 | [diff] [blame] | 1770 | .needs_scratch_page = true, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1771 | .configure = intel_i830_configure, |
| 1772 | .fetch_size = intel_i830_fetch_size, |
| 1773 | .cleanup = intel_i830_cleanup, |
| 1774 | .tlb_flush = intel_i810_tlbflush, |
| 1775 | .mask_memory = intel_i810_mask_memory, |
| 1776 | .masks = intel_i810_masks, |
| 1777 | .agp_enable = intel_i810_agp_enable, |
| 1778 | .cache_flush = global_cache_flush, |
| 1779 | .create_gatt_table = intel_i830_create_gatt_table, |
| 1780 | .free_gatt_table = intel_i830_free_gatt_table, |
| 1781 | .insert_memory = intel_i830_insert_entries, |
| 1782 | .remove_memory = intel_i830_remove_entries, |
| 1783 | .alloc_by_type = intel_i830_alloc_by_type, |
| 1784 | .free_by_type = intel_i810_free_by_type, |
| 1785 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 1786 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1787 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame^] | 1788 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1789 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 1790 | .chipset_flush = intel_i830_chipset_flush, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1791 | }; |
| 1792 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1793 | static const struct agp_bridge_driver intel_820_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1794 | .owner = THIS_MODULE, |
| 1795 | .aperture_sizes = intel_8xx_sizes, |
| 1796 | .size_type = U8_APER_SIZE, |
| 1797 | .num_aperture_sizes = 7, |
| 1798 | .configure = intel_820_configure, |
| 1799 | .fetch_size = intel_8xx_fetch_size, |
| 1800 | .cleanup = intel_820_cleanup, |
| 1801 | .tlb_flush = intel_820_tlbflush, |
| 1802 | .mask_memory = agp_generic_mask_memory, |
| 1803 | .masks = intel_generic_masks, |
| 1804 | .agp_enable = agp_generic_enable, |
| 1805 | .cache_flush = global_cache_flush, |
| 1806 | .create_gatt_table = agp_generic_create_gatt_table, |
| 1807 | .free_gatt_table = agp_generic_free_gatt_table, |
| 1808 | .insert_memory = agp_generic_insert_memory, |
| 1809 | .remove_memory = agp_generic_remove_memory, |
| 1810 | .alloc_by_type = agp_generic_alloc_by_type, |
| 1811 | .free_by_type = agp_generic_free_by_type, |
| 1812 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 1813 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1814 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame^] | 1815 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1816 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1817 | }; |
| 1818 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1819 | static const struct agp_bridge_driver intel_830mp_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1820 | .owner = THIS_MODULE, |
| 1821 | .aperture_sizes = intel_830mp_sizes, |
| 1822 | .size_type = U8_APER_SIZE, |
| 1823 | .num_aperture_sizes = 4, |
| 1824 | .configure = intel_830mp_configure, |
| 1825 | .fetch_size = intel_8xx_fetch_size, |
| 1826 | .cleanup = intel_8xx_cleanup, |
| 1827 | .tlb_flush = intel_8xx_tlbflush, |
| 1828 | .mask_memory = agp_generic_mask_memory, |
| 1829 | .masks = intel_generic_masks, |
| 1830 | .agp_enable = agp_generic_enable, |
| 1831 | .cache_flush = global_cache_flush, |
| 1832 | .create_gatt_table = agp_generic_create_gatt_table, |
| 1833 | .free_gatt_table = agp_generic_free_gatt_table, |
| 1834 | .insert_memory = agp_generic_insert_memory, |
| 1835 | .remove_memory = agp_generic_remove_memory, |
| 1836 | .alloc_by_type = agp_generic_alloc_by_type, |
| 1837 | .free_by_type = agp_generic_free_by_type, |
| 1838 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 1839 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1840 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame^] | 1841 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1842 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1843 | }; |
| 1844 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1845 | static const struct agp_bridge_driver intel_840_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1846 | .owner = THIS_MODULE, |
| 1847 | .aperture_sizes = intel_8xx_sizes, |
| 1848 | .size_type = U8_APER_SIZE, |
| 1849 | .num_aperture_sizes = 7, |
| 1850 | .configure = intel_840_configure, |
| 1851 | .fetch_size = intel_8xx_fetch_size, |
| 1852 | .cleanup = intel_8xx_cleanup, |
| 1853 | .tlb_flush = intel_8xx_tlbflush, |
| 1854 | .mask_memory = agp_generic_mask_memory, |
| 1855 | .masks = intel_generic_masks, |
| 1856 | .agp_enable = agp_generic_enable, |
| 1857 | .cache_flush = global_cache_flush, |
| 1858 | .create_gatt_table = agp_generic_create_gatt_table, |
| 1859 | .free_gatt_table = agp_generic_free_gatt_table, |
| 1860 | .insert_memory = agp_generic_insert_memory, |
| 1861 | .remove_memory = agp_generic_remove_memory, |
| 1862 | .alloc_by_type = agp_generic_alloc_by_type, |
| 1863 | .free_by_type = agp_generic_free_by_type, |
| 1864 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 1865 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1866 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame^] | 1867 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1868 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1869 | }; |
| 1870 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1871 | static const struct agp_bridge_driver intel_845_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1872 | .owner = THIS_MODULE, |
| 1873 | .aperture_sizes = intel_8xx_sizes, |
| 1874 | .size_type = U8_APER_SIZE, |
| 1875 | .num_aperture_sizes = 7, |
| 1876 | .configure = intel_845_configure, |
| 1877 | .fetch_size = intel_8xx_fetch_size, |
| 1878 | .cleanup = intel_8xx_cleanup, |
| 1879 | .tlb_flush = intel_8xx_tlbflush, |
| 1880 | .mask_memory = agp_generic_mask_memory, |
| 1881 | .masks = intel_generic_masks, |
| 1882 | .agp_enable = agp_generic_enable, |
| 1883 | .cache_flush = global_cache_flush, |
| 1884 | .create_gatt_table = agp_generic_create_gatt_table, |
| 1885 | .free_gatt_table = agp_generic_free_gatt_table, |
| 1886 | .insert_memory = agp_generic_insert_memory, |
| 1887 | .remove_memory = agp_generic_remove_memory, |
| 1888 | .alloc_by_type = agp_generic_alloc_by_type, |
| 1889 | .free_by_type = agp_generic_free_by_type, |
| 1890 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 1891 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1892 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame^] | 1893 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1894 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Dave Airlie | 2162e6a | 2007-11-21 16:36:31 +1000 | [diff] [blame] | 1895 | .chipset_flush = intel_i830_chipset_flush, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1896 | }; |
| 1897 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1898 | static const struct agp_bridge_driver intel_850_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1899 | .owner = THIS_MODULE, |
| 1900 | .aperture_sizes = intel_8xx_sizes, |
| 1901 | .size_type = U8_APER_SIZE, |
| 1902 | .num_aperture_sizes = 7, |
| 1903 | .configure = intel_850_configure, |
| 1904 | .fetch_size = intel_8xx_fetch_size, |
| 1905 | .cleanup = intel_8xx_cleanup, |
| 1906 | .tlb_flush = intel_8xx_tlbflush, |
| 1907 | .mask_memory = agp_generic_mask_memory, |
| 1908 | .masks = intel_generic_masks, |
| 1909 | .agp_enable = agp_generic_enable, |
| 1910 | .cache_flush = global_cache_flush, |
| 1911 | .create_gatt_table = agp_generic_create_gatt_table, |
| 1912 | .free_gatt_table = agp_generic_free_gatt_table, |
| 1913 | .insert_memory = agp_generic_insert_memory, |
| 1914 | .remove_memory = agp_generic_remove_memory, |
| 1915 | .alloc_by_type = agp_generic_alloc_by_type, |
| 1916 | .free_by_type = agp_generic_free_by_type, |
| 1917 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 1918 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1919 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame^] | 1920 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1921 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1922 | }; |
| 1923 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1924 | static const struct agp_bridge_driver intel_860_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1925 | .owner = THIS_MODULE, |
| 1926 | .aperture_sizes = intel_8xx_sizes, |
| 1927 | .size_type = U8_APER_SIZE, |
| 1928 | .num_aperture_sizes = 7, |
| 1929 | .configure = intel_860_configure, |
| 1930 | .fetch_size = intel_8xx_fetch_size, |
| 1931 | .cleanup = intel_8xx_cleanup, |
| 1932 | .tlb_flush = intel_8xx_tlbflush, |
| 1933 | .mask_memory = agp_generic_mask_memory, |
| 1934 | .masks = intel_generic_masks, |
| 1935 | .agp_enable = agp_generic_enable, |
| 1936 | .cache_flush = global_cache_flush, |
| 1937 | .create_gatt_table = agp_generic_create_gatt_table, |
| 1938 | .free_gatt_table = agp_generic_free_gatt_table, |
| 1939 | .insert_memory = agp_generic_insert_memory, |
| 1940 | .remove_memory = agp_generic_remove_memory, |
| 1941 | .alloc_by_type = agp_generic_alloc_by_type, |
| 1942 | .free_by_type = agp_generic_free_by_type, |
| 1943 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 1944 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1945 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame^] | 1946 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1947 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1948 | }; |
| 1949 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1950 | static const struct agp_bridge_driver intel_915_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1951 | .owner = THIS_MODULE, |
| 1952 | .aperture_sizes = intel_i830_sizes, |
| 1953 | .size_type = FIXED_APER_SIZE, |
Dave Jones | c14635e | 2006-09-06 11:59:35 -0400 | [diff] [blame] | 1954 | .num_aperture_sizes = 4, |
Joe Perches | c725801 | 2008-03-26 14:10:02 -0700 | [diff] [blame] | 1955 | .needs_scratch_page = true, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1956 | .configure = intel_i915_configure, |
Eric Anholt | c41e0de | 2006-12-19 12:57:24 -0800 | [diff] [blame] | 1957 | .fetch_size = intel_i9xx_fetch_size, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1958 | .cleanup = intel_i915_cleanup, |
| 1959 | .tlb_flush = intel_i810_tlbflush, |
| 1960 | .mask_memory = intel_i810_mask_memory, |
| 1961 | .masks = intel_i810_masks, |
| 1962 | .agp_enable = intel_i810_agp_enable, |
| 1963 | .cache_flush = global_cache_flush, |
| 1964 | .create_gatt_table = intel_i915_create_gatt_table, |
| 1965 | .free_gatt_table = intel_i830_free_gatt_table, |
| 1966 | .insert_memory = intel_i915_insert_entries, |
| 1967 | .remove_memory = intel_i915_remove_entries, |
| 1968 | .alloc_by_type = intel_i830_alloc_by_type, |
| 1969 | .free_by_type = intel_i810_free_by_type, |
| 1970 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 1971 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1972 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame^] | 1973 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 1974 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 1975 | .chipset_flush = intel_i915_chipset_flush, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1976 | }; |
| 1977 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 1978 | static const struct agp_bridge_driver intel_i965_driver = { |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1979 | .owner = THIS_MODULE, |
| 1980 | .aperture_sizes = intel_i830_sizes, |
| 1981 | .size_type = FIXED_APER_SIZE, |
| 1982 | .num_aperture_sizes = 4, |
| 1983 | .needs_scratch_page = true, |
Dave Airlie | 0e480e5 | 2008-06-19 14:57:31 +1000 | [diff] [blame] | 1984 | .configure = intel_i915_configure, |
| 1985 | .fetch_size = intel_i9xx_fetch_size, |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 1986 | .cleanup = intel_i915_cleanup, |
| 1987 | .tlb_flush = intel_i810_tlbflush, |
| 1988 | .mask_memory = intel_i965_mask_memory, |
| 1989 | .masks = intel_i810_masks, |
| 1990 | .agp_enable = intel_i810_agp_enable, |
| 1991 | .cache_flush = global_cache_flush, |
| 1992 | .create_gatt_table = intel_i965_create_gatt_table, |
| 1993 | .free_gatt_table = intel_i830_free_gatt_table, |
| 1994 | .insert_memory = intel_i915_insert_entries, |
| 1995 | .remove_memory = intel_i915_remove_entries, |
| 1996 | .alloc_by_type = intel_i830_alloc_by_type, |
| 1997 | .free_by_type = intel_i810_free_by_type, |
| 1998 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 1999 | .agp_alloc_pages = agp_generic_alloc_pages, |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 2000 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame^] | 2001 | .agp_destroy_pages = agp_generic_destroy_pages, |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 2002 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 2003 | .chipset_flush = intel_i915_chipset_flush, |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 2004 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2005 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 2006 | static const struct agp_bridge_driver intel_7505_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2007 | .owner = THIS_MODULE, |
| 2008 | .aperture_sizes = intel_8xx_sizes, |
| 2009 | .size_type = U8_APER_SIZE, |
| 2010 | .num_aperture_sizes = 7, |
| 2011 | .configure = intel_7505_configure, |
| 2012 | .fetch_size = intel_8xx_fetch_size, |
| 2013 | .cleanup = intel_8xx_cleanup, |
| 2014 | .tlb_flush = intel_8xx_tlbflush, |
| 2015 | .mask_memory = agp_generic_mask_memory, |
| 2016 | .masks = intel_generic_masks, |
| 2017 | .agp_enable = agp_generic_enable, |
| 2018 | .cache_flush = global_cache_flush, |
| 2019 | .create_gatt_table = agp_generic_create_gatt_table, |
| 2020 | .free_gatt_table = agp_generic_free_gatt_table, |
| 2021 | .insert_memory = agp_generic_insert_memory, |
| 2022 | .remove_memory = agp_generic_remove_memory, |
| 2023 | .alloc_by_type = agp_generic_alloc_by_type, |
| 2024 | .free_by_type = agp_generic_free_by_type, |
| 2025 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 2026 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2027 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame^] | 2028 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 2029 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2030 | }; |
| 2031 | |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 2032 | static const struct agp_bridge_driver intel_g33_driver = { |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 2033 | .owner = THIS_MODULE, |
| 2034 | .aperture_sizes = intel_i830_sizes, |
| 2035 | .size_type = FIXED_APER_SIZE, |
| 2036 | .num_aperture_sizes = 4, |
| 2037 | .needs_scratch_page = true, |
| 2038 | .configure = intel_i915_configure, |
| 2039 | .fetch_size = intel_i9xx_fetch_size, |
| 2040 | .cleanup = intel_i915_cleanup, |
| 2041 | .tlb_flush = intel_i810_tlbflush, |
| 2042 | .mask_memory = intel_i965_mask_memory, |
| 2043 | .masks = intel_i810_masks, |
| 2044 | .agp_enable = intel_i810_agp_enable, |
| 2045 | .cache_flush = global_cache_flush, |
| 2046 | .create_gatt_table = intel_i915_create_gatt_table, |
| 2047 | .free_gatt_table = intel_i830_free_gatt_table, |
| 2048 | .insert_memory = intel_i915_insert_entries, |
| 2049 | .remove_memory = intel_i915_remove_entries, |
| 2050 | .alloc_by_type = intel_i830_alloc_by_type, |
| 2051 | .free_by_type = intel_i810_free_by_type, |
| 2052 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 2053 | .agp_alloc_pages = agp_generic_alloc_pages, |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 2054 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame^] | 2055 | .agp_destroy_pages = agp_generic_destroy_pages, |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 2056 | .agp_type_to_mask_type = intel_i830_type_to_mask_type, |
Dave Airlie | 6c00a61 | 2007-10-29 18:06:10 +1000 | [diff] [blame] | 2057 | .chipset_flush = intel_i915_chipset_flush, |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 2058 | }; |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2059 | |
| 2060 | static int find_gmch(u16 device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2061 | { |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2062 | struct pci_dev *gmch_device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2063 | |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2064 | gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL); |
| 2065 | if (gmch_device && PCI_FUNC(gmch_device->devfn) != 0) { |
| 2066 | gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL, |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 2067 | device, gmch_device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2068 | } |
| 2069 | |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2070 | if (!gmch_device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2071 | return 0; |
| 2072 | |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2073 | intel_private.pcidev = gmch_device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2074 | return 1; |
| 2075 | } |
| 2076 | |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2077 | /* Table to describe Intel GMCH and AGP/PCIE GART drivers. At least one of |
| 2078 | * driver and gmch_driver must be non-null, and find_gmch will determine |
| 2079 | * which one should be used if a gmch_chip_id is present. |
| 2080 | */ |
| 2081 | static const struct intel_driver_description { |
| 2082 | unsigned int chip_id; |
| 2083 | unsigned int gmch_chip_id; |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2084 | unsigned int multi_gmch_chip; /* if we have more gfx chip type on this HB. */ |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2085 | char *name; |
| 2086 | const struct agp_bridge_driver *driver; |
| 2087 | const struct agp_bridge_driver *gmch_driver; |
| 2088 | } intel_agp_chipsets[] = { |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2089 | { PCI_DEVICE_ID_INTEL_82443LX_0, 0, 0, "440LX", &intel_generic_driver, NULL }, |
| 2090 | { PCI_DEVICE_ID_INTEL_82443BX_0, 0, 0, "440BX", &intel_generic_driver, NULL }, |
| 2091 | { PCI_DEVICE_ID_INTEL_82443GX_0, 0, 0, "440GX", &intel_generic_driver, NULL }, |
| 2092 | { PCI_DEVICE_ID_INTEL_82810_MC1, PCI_DEVICE_ID_INTEL_82810_IG1, 0, "i810", |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2093 | NULL, &intel_810_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2094 | { PCI_DEVICE_ID_INTEL_82810_MC3, PCI_DEVICE_ID_INTEL_82810_IG3, 0, "i810", |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2095 | NULL, &intel_810_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2096 | { PCI_DEVICE_ID_INTEL_82810E_MC, PCI_DEVICE_ID_INTEL_82810E_IG, 0, "i810", |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2097 | NULL, &intel_810_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2098 | { PCI_DEVICE_ID_INTEL_82815_MC, PCI_DEVICE_ID_INTEL_82815_CGC, 0, "i815", |
| 2099 | &intel_815_driver, &intel_810_driver }, |
| 2100 | { PCI_DEVICE_ID_INTEL_82820_HB, 0, 0, "i820", &intel_820_driver, NULL }, |
| 2101 | { PCI_DEVICE_ID_INTEL_82820_UP_HB, 0, 0, "i820", &intel_820_driver, NULL }, |
| 2102 | { PCI_DEVICE_ID_INTEL_82830_HB, PCI_DEVICE_ID_INTEL_82830_CGC, 0, "830M", |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2103 | &intel_830mp_driver, &intel_830_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2104 | { PCI_DEVICE_ID_INTEL_82840_HB, 0, 0, "i840", &intel_840_driver, NULL }, |
| 2105 | { PCI_DEVICE_ID_INTEL_82845_HB, 0, 0, "845G", &intel_845_driver, NULL }, |
| 2106 | { PCI_DEVICE_ID_INTEL_82845G_HB, PCI_DEVICE_ID_INTEL_82845G_IG, 0, "830M", |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2107 | &intel_845_driver, &intel_830_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2108 | { PCI_DEVICE_ID_INTEL_82850_HB, 0, 0, "i850", &intel_850_driver, NULL }, |
| 2109 | { PCI_DEVICE_ID_INTEL_82855PM_HB, 0, 0, "855PM", &intel_845_driver, NULL }, |
| 2110 | { PCI_DEVICE_ID_INTEL_82855GM_HB, PCI_DEVICE_ID_INTEL_82855GM_IG, 0, "855GM", |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2111 | &intel_845_driver, &intel_830_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2112 | { PCI_DEVICE_ID_INTEL_82860_HB, 0, 0, "i860", &intel_860_driver, NULL }, |
| 2113 | { PCI_DEVICE_ID_INTEL_82865_HB, PCI_DEVICE_ID_INTEL_82865_IG, 0, "865", |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2114 | &intel_845_driver, &intel_830_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2115 | { PCI_DEVICE_ID_INTEL_82875_HB, 0, 0, "i875", &intel_845_driver, NULL }, |
Carlos Martín | e914a36 | 2008-01-24 10:34:09 +1000 | [diff] [blame] | 2116 | { PCI_DEVICE_ID_INTEL_E7221_HB, PCI_DEVICE_ID_INTEL_E7221_IG, 0, "E7221 (i915)", |
| 2117 | NULL, &intel_915_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2118 | { PCI_DEVICE_ID_INTEL_82915G_HB, PCI_DEVICE_ID_INTEL_82915G_IG, 0, "915G", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2119 | NULL, &intel_915_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2120 | { PCI_DEVICE_ID_INTEL_82915GM_HB, PCI_DEVICE_ID_INTEL_82915GM_IG, 0, "915GM", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2121 | NULL, &intel_915_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2122 | { PCI_DEVICE_ID_INTEL_82945G_HB, PCI_DEVICE_ID_INTEL_82945G_IG, 0, "945G", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2123 | NULL, &intel_915_driver }, |
Zhenyu Wang | dde4787 | 2007-07-26 09:18:09 +0800 | [diff] [blame] | 2124 | { PCI_DEVICE_ID_INTEL_82945GM_HB, PCI_DEVICE_ID_INTEL_82945GM_IG, 0, "945GM", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2125 | NULL, &intel_915_driver }, |
Zhenyu Wang | dde4787 | 2007-07-26 09:18:09 +0800 | [diff] [blame] | 2126 | { PCI_DEVICE_ID_INTEL_82945GME_HB, PCI_DEVICE_ID_INTEL_82945GME_IG, 0, "945GME", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2127 | NULL, &intel_915_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2128 | { PCI_DEVICE_ID_INTEL_82946GZ_HB, PCI_DEVICE_ID_INTEL_82946GZ_IG, 0, "946GZ", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2129 | NULL, &intel_i965_driver }, |
Zhenyu Wang | 9119f85 | 2008-01-23 15:49:26 +1000 | [diff] [blame] | 2130 | { PCI_DEVICE_ID_INTEL_82G35_HB, PCI_DEVICE_ID_INTEL_82G35_IG, 0, "G35", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2131 | NULL, &intel_i965_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2132 | { PCI_DEVICE_ID_INTEL_82965Q_HB, PCI_DEVICE_ID_INTEL_82965Q_IG, 0, "965Q", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2133 | NULL, &intel_i965_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2134 | { PCI_DEVICE_ID_INTEL_82965G_HB, PCI_DEVICE_ID_INTEL_82965G_IG, 0, "965G", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2135 | NULL, &intel_i965_driver }, |
Zhenyu Wang | dde4787 | 2007-07-26 09:18:09 +0800 | [diff] [blame] | 2136 | { PCI_DEVICE_ID_INTEL_82965GM_HB, PCI_DEVICE_ID_INTEL_82965GM_IG, 0, "965GM", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2137 | NULL, &intel_i965_driver }, |
Zhenyu Wang | dde4787 | 2007-07-26 09:18:09 +0800 | [diff] [blame] | 2138 | { PCI_DEVICE_ID_INTEL_82965GME_HB, PCI_DEVICE_ID_INTEL_82965GME_IG, 0, "965GME/GLE", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2139 | NULL, &intel_i965_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2140 | { PCI_DEVICE_ID_INTEL_7505_0, 0, 0, "E7505", &intel_7505_driver, NULL }, |
| 2141 | { PCI_DEVICE_ID_INTEL_7205_0, 0, 0, "E7205", &intel_7505_driver, NULL }, |
| 2142 | { PCI_DEVICE_ID_INTEL_G33_HB, PCI_DEVICE_ID_INTEL_G33_IG, 0, "G33", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2143 | NULL, &intel_g33_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2144 | { PCI_DEVICE_ID_INTEL_Q35_HB, PCI_DEVICE_ID_INTEL_Q35_IG, 0, "Q35", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2145 | NULL, &intel_g33_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2146 | { PCI_DEVICE_ID_INTEL_Q33_HB, PCI_DEVICE_ID_INTEL_Q33_IG, 0, "Q33", |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2147 | NULL, &intel_g33_driver }, |
Zhenyu Wang | 4e8b6e2 | 2008-01-23 14:54:37 +1000 | [diff] [blame] | 2148 | { PCI_DEVICE_ID_INTEL_IGD_HB, PCI_DEVICE_ID_INTEL_IGD_IG, 0, |
| 2149 | "Intel Integrated Graphics Device", NULL, &intel_i965_driver }, |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 2150 | { PCI_DEVICE_ID_INTEL_IGD_E_HB, PCI_DEVICE_ID_INTEL_IGD_E_IG, 0, |
| 2151 | "Intel Integrated Graphics Device", NULL, &intel_i965_driver }, |
| 2152 | { PCI_DEVICE_ID_INTEL_Q45_HB, PCI_DEVICE_ID_INTEL_Q45_IG, 0, |
| 2153 | "Q45/Q43", NULL, &intel_i965_driver }, |
| 2154 | { PCI_DEVICE_ID_INTEL_G45_HB, PCI_DEVICE_ID_INTEL_G45_IG, 0, |
| 2155 | "G45/G43", NULL, &intel_i965_driver }, |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2156 | { 0, 0, 0, NULL, NULL, NULL } |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2157 | }; |
| 2158 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2159 | static int __devinit agp_intel_probe(struct pci_dev *pdev, |
| 2160 | const struct pci_device_id *ent) |
| 2161 | { |
| 2162 | struct agp_bridge_data *bridge; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2163 | u8 cap_ptr = 0; |
| 2164 | struct resource *r; |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2165 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2166 | |
| 2167 | cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP); |
| 2168 | |
| 2169 | bridge = agp_alloc_bridge(); |
| 2170 | if (!bridge) |
| 2171 | return -ENOMEM; |
| 2172 | |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2173 | for (i = 0; intel_agp_chipsets[i].name != NULL; i++) { |
| 2174 | /* In case that multiple models of gfx chip may |
| 2175 | stand on same host bridge type, this can be |
| 2176 | sure we detect the right IGD. */ |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 2177 | if (pdev->device == intel_agp_chipsets[i].chip_id) { |
| 2178 | if ((intel_agp_chipsets[i].gmch_chip_id != 0) && |
| 2179 | find_gmch(intel_agp_chipsets[i].gmch_chip_id)) { |
| 2180 | bridge->driver = |
| 2181 | intel_agp_chipsets[i].gmch_driver; |
| 2182 | break; |
| 2183 | } else if (intel_agp_chipsets[i].multi_gmch_chip) { |
| 2184 | continue; |
| 2185 | } else { |
| 2186 | bridge->driver = intel_agp_chipsets[i].driver; |
| 2187 | break; |
| 2188 | } |
| 2189 | } |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2190 | } |
| 2191 | |
| 2192 | if (intel_agp_chipsets[i].name == NULL) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2193 | if (cap_ptr) |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2194 | printk(KERN_WARNING PFX "Unsupported Intel chipset" |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 2195 | "(device id: %04x)\n", pdev->device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2196 | agp_put_bridge(bridge); |
| 2197 | return -ENODEV; |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2198 | } |
| 2199 | |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2200 | if (bridge->driver == NULL) { |
Wang Zhenyu | 47d4637 | 2007-06-21 13:43:18 +0800 | [diff] [blame] | 2201 | /* bridge has no AGP and no IGD detected */ |
| 2202 | if (cap_ptr) |
| 2203 | printk(KERN_WARNING PFX "Failed to find bridge device " |
| 2204 | "(chip_id: %04x)\n", |
| 2205 | intel_agp_chipsets[i].gmch_chip_id); |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2206 | agp_put_bridge(bridge); |
| 2207 | return -ENODEV; |
Dave Airlie | f011ae7 | 2008-01-25 11:23:04 +1000 | [diff] [blame] | 2208 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2209 | |
| 2210 | bridge->dev = pdev; |
| 2211 | bridge->capndx = cap_ptr; |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 2212 | bridge->dev_private_data = &intel_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2213 | |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 2214 | printk(KERN_INFO PFX "Detected an Intel %s Chipset.\n", |
| 2215 | intel_agp_chipsets[i].name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2216 | |
| 2217 | /* |
| 2218 | * The following fixes the case where the BIOS has "forgotten" to |
| 2219 | * provide an address range for the GART. |
| 2220 | * 20030610 - hamish@zot.org |
| 2221 | */ |
| 2222 | r = &pdev->resource[0]; |
| 2223 | if (!r->start && r->end) { |
Dave Jones | 6a92a4e | 2006-02-28 00:54:25 -0500 | [diff] [blame] | 2224 | if (pci_assign_resource(pdev, 0)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2225 | printk(KERN_ERR PFX "could not assign resource 0\n"); |
| 2226 | agp_put_bridge(bridge); |
| 2227 | return -ENODEV; |
| 2228 | } |
| 2229 | } |
| 2230 | |
| 2231 | /* |
| 2232 | * If the device has not been properly setup, the following will catch |
| 2233 | * the problem and should stop the system from crashing. |
| 2234 | * 20030610 - hamish@zot.org |
| 2235 | */ |
| 2236 | if (pci_enable_device(pdev)) { |
| 2237 | printk(KERN_ERR PFX "Unable to Enable PCI device\n"); |
| 2238 | agp_put_bridge(bridge); |
| 2239 | return -ENODEV; |
| 2240 | } |
| 2241 | |
| 2242 | /* Fill in the mode register */ |
| 2243 | if (cap_ptr) { |
| 2244 | pci_read_config_dword(pdev, |
| 2245 | bridge->capndx+PCI_AGP_STATUS, |
| 2246 | &bridge->mode); |
| 2247 | } |
| 2248 | |
| 2249 | pci_set_drvdata(pdev, bridge); |
| 2250 | return agp_add_bridge(bridge); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2251 | } |
| 2252 | |
| 2253 | static void __devexit agp_intel_remove(struct pci_dev *pdev) |
| 2254 | { |
| 2255 | struct agp_bridge_data *bridge = pci_get_drvdata(pdev); |
| 2256 | |
| 2257 | agp_remove_bridge(bridge); |
| 2258 | |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 2259 | if (intel_private.pcidev) |
| 2260 | pci_dev_put(intel_private.pcidev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2261 | |
| 2262 | agp_put_bridge(bridge); |
| 2263 | } |
| 2264 | |
Alexey Dobriyan | 85be7d6 | 2006-08-12 02:02:02 +0400 | [diff] [blame] | 2265 | #ifdef CONFIG_PM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2266 | static int agp_intel_resume(struct pci_dev *pdev) |
| 2267 | { |
| 2268 | struct agp_bridge_data *bridge = pci_get_drvdata(pdev); |
| 2269 | |
| 2270 | pci_restore_state(pdev); |
| 2271 | |
Wang Zhenyu | 4b95320 | 2007-01-17 11:07:54 +0800 | [diff] [blame] | 2272 | /* We should restore our graphics device's config space, |
| 2273 | * as host bridge (00:00) resumes before graphics device (02:00), |
| 2274 | * then our access to its pci space can work right. |
| 2275 | */ |
Wang Zhenyu | c4ca881 | 2007-05-30 09:40:46 +0800 | [diff] [blame] | 2276 | if (intel_private.pcidev) |
| 2277 | pci_restore_state(intel_private.pcidev); |
Wang Zhenyu | 4b95320 | 2007-01-17 11:07:54 +0800 | [diff] [blame] | 2278 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2279 | if (bridge->driver == &intel_generic_driver) |
| 2280 | intel_configure(); |
| 2281 | else if (bridge->driver == &intel_850_driver) |
| 2282 | intel_850_configure(); |
| 2283 | else if (bridge->driver == &intel_845_driver) |
| 2284 | intel_845_configure(); |
| 2285 | else if (bridge->driver == &intel_830mp_driver) |
| 2286 | intel_830mp_configure(); |
| 2287 | else if (bridge->driver == &intel_915_driver) |
| 2288 | intel_i915_configure(); |
| 2289 | else if (bridge->driver == &intel_830_driver) |
| 2290 | intel_i830_configure(); |
| 2291 | else if (bridge->driver == &intel_810_driver) |
| 2292 | intel_i810_configure(); |
Dave Jones | 08da3f4 | 2006-09-10 21:09:26 -0400 | [diff] [blame] | 2293 | else if (bridge->driver == &intel_i965_driver) |
| 2294 | intel_i915_configure(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2295 | |
| 2296 | return 0; |
| 2297 | } |
Alexey Dobriyan | 85be7d6 | 2006-08-12 02:02:02 +0400 | [diff] [blame] | 2298 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2299 | |
| 2300 | static struct pci_device_id agp_intel_pci_table[] = { |
| 2301 | #define ID(x) \ |
| 2302 | { \ |
| 2303 | .class = (PCI_CLASS_BRIDGE_HOST << 8), \ |
| 2304 | .class_mask = ~0, \ |
| 2305 | .vendor = PCI_VENDOR_ID_INTEL, \ |
| 2306 | .device = x, \ |
| 2307 | .subvendor = PCI_ANY_ID, \ |
| 2308 | .subdevice = PCI_ANY_ID, \ |
| 2309 | } |
| 2310 | ID(PCI_DEVICE_ID_INTEL_82443LX_0), |
| 2311 | ID(PCI_DEVICE_ID_INTEL_82443BX_0), |
| 2312 | ID(PCI_DEVICE_ID_INTEL_82443GX_0), |
| 2313 | ID(PCI_DEVICE_ID_INTEL_82810_MC1), |
| 2314 | ID(PCI_DEVICE_ID_INTEL_82810_MC3), |
| 2315 | ID(PCI_DEVICE_ID_INTEL_82810E_MC), |
| 2316 | ID(PCI_DEVICE_ID_INTEL_82815_MC), |
| 2317 | ID(PCI_DEVICE_ID_INTEL_82820_HB), |
| 2318 | ID(PCI_DEVICE_ID_INTEL_82820_UP_HB), |
| 2319 | ID(PCI_DEVICE_ID_INTEL_82830_HB), |
| 2320 | ID(PCI_DEVICE_ID_INTEL_82840_HB), |
| 2321 | ID(PCI_DEVICE_ID_INTEL_82845_HB), |
| 2322 | ID(PCI_DEVICE_ID_INTEL_82845G_HB), |
| 2323 | ID(PCI_DEVICE_ID_INTEL_82850_HB), |
| 2324 | ID(PCI_DEVICE_ID_INTEL_82855PM_HB), |
| 2325 | ID(PCI_DEVICE_ID_INTEL_82855GM_HB), |
| 2326 | ID(PCI_DEVICE_ID_INTEL_82860_HB), |
| 2327 | ID(PCI_DEVICE_ID_INTEL_82865_HB), |
| 2328 | ID(PCI_DEVICE_ID_INTEL_82875_HB), |
| 2329 | ID(PCI_DEVICE_ID_INTEL_7505_0), |
| 2330 | ID(PCI_DEVICE_ID_INTEL_7205_0), |
Carlos Martín | e914a36 | 2008-01-24 10:34:09 +1000 | [diff] [blame] | 2331 | ID(PCI_DEVICE_ID_INTEL_E7221_HB), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2332 | ID(PCI_DEVICE_ID_INTEL_82915G_HB), |
| 2333 | ID(PCI_DEVICE_ID_INTEL_82915GM_HB), |
Alan Hourihane | d0de98f | 2005-05-31 19:50:49 +0100 | [diff] [blame] | 2334 | ID(PCI_DEVICE_ID_INTEL_82945G_HB), |
Alan Hourihane | 3b0e8ea | 2006-01-19 14:08:40 +0000 | [diff] [blame] | 2335 | ID(PCI_DEVICE_ID_INTEL_82945GM_HB), |
Zhenyu Wang | dde4787 | 2007-07-26 09:18:09 +0800 | [diff] [blame] | 2336 | ID(PCI_DEVICE_ID_INTEL_82945GME_HB), |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 2337 | ID(PCI_DEVICE_ID_INTEL_82946GZ_HB), |
Zhenyu Wang | 9119f85 | 2008-01-23 15:49:26 +1000 | [diff] [blame] | 2338 | ID(PCI_DEVICE_ID_INTEL_82G35_HB), |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 2339 | ID(PCI_DEVICE_ID_INTEL_82965Q_HB), |
| 2340 | ID(PCI_DEVICE_ID_INTEL_82965G_HB), |
Wang Zhenyu | 4598af3 | 2007-04-09 08:51:36 +0800 | [diff] [blame] | 2341 | ID(PCI_DEVICE_ID_INTEL_82965GM_HB), |
Zhenyu Wang | dde4787 | 2007-07-26 09:18:09 +0800 | [diff] [blame] | 2342 | ID(PCI_DEVICE_ID_INTEL_82965GME_HB), |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 2343 | ID(PCI_DEVICE_ID_INTEL_G33_HB), |
| 2344 | ID(PCI_DEVICE_ID_INTEL_Q35_HB), |
| 2345 | ID(PCI_DEVICE_ID_INTEL_Q33_HB), |
Zhenyu Wang | 4e8b6e2 | 2008-01-23 14:54:37 +1000 | [diff] [blame] | 2346 | ID(PCI_DEVICE_ID_INTEL_IGD_HB), |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 2347 | ID(PCI_DEVICE_ID_INTEL_IGD_E_HB), |
| 2348 | ID(PCI_DEVICE_ID_INTEL_Q45_HB), |
| 2349 | ID(PCI_DEVICE_ID_INTEL_G45_HB), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2350 | { } |
| 2351 | }; |
| 2352 | |
| 2353 | MODULE_DEVICE_TABLE(pci, agp_intel_pci_table); |
| 2354 | |
| 2355 | static struct pci_driver agp_intel_pci_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2356 | .name = "agpgart-intel", |
| 2357 | .id_table = agp_intel_pci_table, |
| 2358 | .probe = agp_intel_probe, |
| 2359 | .remove = __devexit_p(agp_intel_remove), |
Alexey Dobriyan | 85be7d6 | 2006-08-12 02:02:02 +0400 | [diff] [blame] | 2360 | #ifdef CONFIG_PM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2361 | .resume = agp_intel_resume, |
Alexey Dobriyan | 85be7d6 | 2006-08-12 02:02:02 +0400 | [diff] [blame] | 2362 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2363 | }; |
| 2364 | |
| 2365 | static int __init agp_intel_init(void) |
| 2366 | { |
| 2367 | if (agp_off) |
| 2368 | return -EINVAL; |
| 2369 | return pci_register_driver(&agp_intel_pci_driver); |
| 2370 | } |
| 2371 | |
| 2372 | static void __exit agp_intel_cleanup(void) |
| 2373 | { |
| 2374 | pci_unregister_driver(&agp_intel_pci_driver); |
| 2375 | } |
| 2376 | |
| 2377 | module_init(agp_intel_init); |
| 2378 | module_exit(agp_intel_cleanup); |
| 2379 | |
| 2380 | MODULE_AUTHOR("Dave Jones <davej@codemonkey.org.uk>"); |
| 2381 | MODULE_LICENSE("GPL and additional rights"); |