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> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 7 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <linux/init.h> |
Ahmed S. Darwish | 1eaf122 | 2007-02-06 18:08:28 +0200 | [diff] [blame] | 9 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <linux/pagemap.h> |
| 11 | #include <linux/agp_backend.h> |
Borislav Petkov | 48a719c | 2010-01-22 16:01:04 +0100 | [diff] [blame] | 12 | #include <asm/smp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include "agp.h" |
Daniel Vetter | ff7cdd6 | 2010-04-14 00:29:51 +0200 | [diff] [blame] | 14 | #include "intel-agp.h" |
Daniel Vetter | 14be93d | 2012-06-08 15:55:40 +0200 | [diff] [blame] | 15 | #include <drm/intel-gtt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
Zhenyu Wang | 1f7a6e3 | 2010-02-23 14:05:24 +0800 | [diff] [blame] | 17 | int intel_agp_enabled; |
| 18 | EXPORT_SYMBOL(intel_agp_enabled); |
| 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | static int intel_fetch_size(void) |
| 21 | { |
| 22 | int i; |
| 23 | u16 temp; |
| 24 | struct aper_size_info_16 *values; |
| 25 | |
| 26 | pci_read_config_word(agp_bridge->dev, INTEL_APSIZE, &temp); |
| 27 | values = A_SIZE_16(agp_bridge->driver->aperture_sizes); |
| 28 | |
| 29 | for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) { |
| 30 | if (temp == values[i].size_value) { |
| 31 | agp_bridge->previous_size = agp_bridge->current_size = (void *) (values + i); |
| 32 | agp_bridge->aperture_size_idx = i; |
| 33 | return values[i].size; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | static int __intel_8xx_fetch_size(u8 temp) |
| 41 | { |
| 42 | int i; |
| 43 | struct aper_size_info_8 *values; |
| 44 | |
| 45 | values = A_SIZE_8(agp_bridge->driver->aperture_sizes); |
| 46 | |
| 47 | for (i = 0; i < agp_bridge->driver->num_aperture_sizes; i++) { |
| 48 | if (temp == values[i].size_value) { |
| 49 | agp_bridge->previous_size = |
| 50 | agp_bridge->current_size = (void *) (values + i); |
| 51 | agp_bridge->aperture_size_idx = i; |
| 52 | return values[i].size; |
| 53 | } |
| 54 | } |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | static int intel_8xx_fetch_size(void) |
| 59 | { |
| 60 | u8 temp; |
| 61 | |
| 62 | pci_read_config_byte(agp_bridge->dev, INTEL_APSIZE, &temp); |
| 63 | return __intel_8xx_fetch_size(temp); |
| 64 | } |
| 65 | |
| 66 | static int intel_815_fetch_size(void) |
| 67 | { |
| 68 | u8 temp; |
| 69 | |
| 70 | /* Intel 815 chipsets have a _weird_ APSIZE register with only |
| 71 | * one non-reserved bit, so mask the others out ... */ |
| 72 | pci_read_config_byte(agp_bridge->dev, INTEL_APSIZE, &temp); |
| 73 | temp &= (1 << 3); |
| 74 | |
| 75 | return __intel_8xx_fetch_size(temp); |
| 76 | } |
| 77 | |
| 78 | static void intel_tlbflush(struct agp_memory *mem) |
| 79 | { |
| 80 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2200); |
| 81 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2280); |
| 82 | } |
| 83 | |
| 84 | |
| 85 | static void intel_8xx_tlbflush(struct agp_memory *mem) |
| 86 | { |
| 87 | u32 temp; |
| 88 | pci_read_config_dword(agp_bridge->dev, INTEL_AGPCTRL, &temp); |
| 89 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, temp & ~(1 << 7)); |
| 90 | pci_read_config_dword(agp_bridge->dev, INTEL_AGPCTRL, &temp); |
| 91 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, temp | (1 << 7)); |
| 92 | } |
| 93 | |
| 94 | |
| 95 | static void intel_cleanup(void) |
| 96 | { |
| 97 | u16 temp; |
| 98 | struct aper_size_info_16 *previous_size; |
| 99 | |
| 100 | previous_size = A_SIZE_16(agp_bridge->previous_size); |
| 101 | pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp); |
| 102 | pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp & ~(1 << 9)); |
| 103 | pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, previous_size->size_value); |
| 104 | } |
| 105 | |
| 106 | |
| 107 | static void intel_8xx_cleanup(void) |
| 108 | { |
| 109 | u16 temp; |
| 110 | struct aper_size_info_8 *previous_size; |
| 111 | |
| 112 | previous_size = A_SIZE_8(agp_bridge->previous_size); |
| 113 | pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp); |
| 114 | pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp & ~(1 << 9)); |
| 115 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, previous_size->size_value); |
| 116 | } |
| 117 | |
| 118 | |
| 119 | static int intel_configure(void) |
| 120 | { |
| 121 | u32 temp; |
| 122 | u16 temp2; |
| 123 | struct aper_size_info_16 *current_size; |
| 124 | |
| 125 | current_size = A_SIZE_16(agp_bridge->current_size); |
| 126 | |
| 127 | /* aperture size */ |
| 128 | pci_write_config_word(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 129 | |
| 130 | /* address to map to */ |
| 131 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 132 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 133 | |
| 134 | /* attbase - aperture base */ |
| 135 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 136 | |
| 137 | /* agpctrl */ |
| 138 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x2280); |
| 139 | |
| 140 | /* paccfg/nbxcfg */ |
| 141 | pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp2); |
| 142 | pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, |
| 143 | (temp2 & ~(1 << 10)) | (1 << 9)); |
| 144 | /* clear any possible error conditions */ |
| 145 | pci_write_config_byte(agp_bridge->dev, INTEL_ERRSTS + 1, 7); |
| 146 | return 0; |
| 147 | } |
| 148 | |
| 149 | static int intel_815_configure(void) |
| 150 | { |
| 151 | u32 temp, addr; |
| 152 | u8 temp2; |
| 153 | struct aper_size_info_8 *current_size; |
| 154 | |
| 155 | /* attbase - aperture base */ |
| 156 | /* the Intel 815 chipset spec. says that bits 29-31 in the |
| 157 | * ATTBASE register are reserved -> try not to write them */ |
| 158 | if (agp_bridge->gatt_bus_addr & INTEL_815_ATTBASE_MASK) { |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 159 | dev_emerg(&agp_bridge->dev->dev, "gatt bus addr too high"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | return -EINVAL; |
| 161 | } |
| 162 | |
| 163 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 164 | |
| 165 | /* aperture size */ |
| 166 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, |
| 167 | current_size->size_value); |
| 168 | |
| 169 | /* address to map to */ |
| 170 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 171 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 172 | |
| 173 | pci_read_config_dword(agp_bridge->dev, INTEL_ATTBASE, &addr); |
| 174 | addr &= INTEL_815_ATTBASE_MASK; |
| 175 | addr |= agp_bridge->gatt_bus_addr; |
| 176 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, addr); |
| 177 | |
| 178 | /* agpctrl */ |
| 179 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 180 | |
| 181 | /* apcont */ |
| 182 | pci_read_config_byte(agp_bridge->dev, INTEL_815_APCONT, &temp2); |
| 183 | pci_write_config_byte(agp_bridge->dev, INTEL_815_APCONT, temp2 | (1 << 1)); |
| 184 | |
| 185 | /* clear any possible error conditions */ |
| 186 | /* Oddness : this chipset seems to have no ERRSTS register ! */ |
| 187 | return 0; |
| 188 | } |
| 189 | |
| 190 | static void intel_820_tlbflush(struct agp_memory *mem) |
| 191 | { |
| 192 | return; |
| 193 | } |
| 194 | |
| 195 | static void intel_820_cleanup(void) |
| 196 | { |
| 197 | u8 temp; |
| 198 | struct aper_size_info_8 *previous_size; |
| 199 | |
| 200 | previous_size = A_SIZE_8(agp_bridge->previous_size); |
| 201 | pci_read_config_byte(agp_bridge->dev, INTEL_I820_RDCR, &temp); |
| 202 | pci_write_config_byte(agp_bridge->dev, INTEL_I820_RDCR, |
| 203 | temp & ~(1 << 1)); |
| 204 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, |
| 205 | previous_size->size_value); |
| 206 | } |
| 207 | |
| 208 | |
| 209 | static int intel_820_configure(void) |
| 210 | { |
| 211 | u32 temp; |
| 212 | u8 temp2; |
| 213 | struct aper_size_info_8 *current_size; |
| 214 | |
| 215 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 216 | |
| 217 | /* aperture size */ |
| 218 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 219 | |
| 220 | /* address to map to */ |
| 221 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 222 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 223 | |
| 224 | /* attbase - aperture base */ |
| 225 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 226 | |
| 227 | /* agpctrl */ |
| 228 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 229 | |
| 230 | /* global enable aperture access */ |
| 231 | /* This flag is not accessed through MCHCFG register as in */ |
| 232 | /* i850 chipset. */ |
| 233 | pci_read_config_byte(agp_bridge->dev, INTEL_I820_RDCR, &temp2); |
| 234 | pci_write_config_byte(agp_bridge->dev, INTEL_I820_RDCR, temp2 | (1 << 1)); |
| 235 | /* clear any possible AGP-related error conditions */ |
| 236 | pci_write_config_word(agp_bridge->dev, INTEL_I820_ERRSTS, 0x001c); |
| 237 | return 0; |
| 238 | } |
| 239 | |
| 240 | static int intel_840_configure(void) |
| 241 | { |
| 242 | u32 temp; |
| 243 | u16 temp2; |
| 244 | struct aper_size_info_8 *current_size; |
| 245 | |
| 246 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 247 | |
| 248 | /* aperture size */ |
| 249 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 250 | |
| 251 | /* address to map to */ |
| 252 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 253 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 254 | |
| 255 | /* attbase - aperture base */ |
| 256 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 257 | |
| 258 | /* agpctrl */ |
| 259 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 260 | |
| 261 | /* mcgcfg */ |
| 262 | pci_read_config_word(agp_bridge->dev, INTEL_I840_MCHCFG, &temp2); |
| 263 | pci_write_config_word(agp_bridge->dev, INTEL_I840_MCHCFG, temp2 | (1 << 9)); |
| 264 | /* clear any possible error conditions */ |
| 265 | pci_write_config_word(agp_bridge->dev, INTEL_I840_ERRSTS, 0xc000); |
| 266 | return 0; |
| 267 | } |
| 268 | |
| 269 | static int intel_845_configure(void) |
| 270 | { |
| 271 | u32 temp; |
| 272 | u8 temp2; |
| 273 | struct aper_size_info_8 *current_size; |
| 274 | |
| 275 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 276 | |
| 277 | /* aperture size */ |
| 278 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 279 | |
Matthew Garrett | b082548 | 2005-07-29 14:03:39 -0700 | [diff] [blame] | 280 | if (agp_bridge->apbase_config != 0) { |
| 281 | pci_write_config_dword(agp_bridge->dev, AGP_APBASE, |
| 282 | agp_bridge->apbase_config); |
| 283 | } else { |
| 284 | /* address to map to */ |
| 285 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 286 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 287 | agp_bridge->apbase_config = temp; |
| 288 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | |
| 290 | /* attbase - aperture base */ |
| 291 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 292 | |
| 293 | /* agpctrl */ |
| 294 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 295 | |
| 296 | /* agpm */ |
| 297 | pci_read_config_byte(agp_bridge->dev, INTEL_I845_AGPM, &temp2); |
| 298 | pci_write_config_byte(agp_bridge->dev, INTEL_I845_AGPM, temp2 | (1 << 1)); |
| 299 | /* clear any possible error conditions */ |
| 300 | pci_write_config_word(agp_bridge->dev, INTEL_I845_ERRSTS, 0x001c); |
| 301 | return 0; |
| 302 | } |
| 303 | |
| 304 | static int intel_850_configure(void) |
| 305 | { |
| 306 | u32 temp; |
| 307 | u16 temp2; |
| 308 | struct aper_size_info_8 *current_size; |
| 309 | |
| 310 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 311 | |
| 312 | /* aperture size */ |
| 313 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 314 | |
| 315 | /* address to map to */ |
| 316 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 317 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 318 | |
| 319 | /* attbase - aperture base */ |
| 320 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 321 | |
| 322 | /* agpctrl */ |
| 323 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 324 | |
| 325 | /* mcgcfg */ |
| 326 | pci_read_config_word(agp_bridge->dev, INTEL_I850_MCHCFG, &temp2); |
| 327 | pci_write_config_word(agp_bridge->dev, INTEL_I850_MCHCFG, temp2 | (1 << 9)); |
| 328 | /* clear any possible AGP-related error conditions */ |
| 329 | pci_write_config_word(agp_bridge->dev, INTEL_I850_ERRSTS, 0x001c); |
| 330 | return 0; |
| 331 | } |
| 332 | |
| 333 | static int intel_860_configure(void) |
| 334 | { |
| 335 | u32 temp; |
| 336 | u16 temp2; |
| 337 | struct aper_size_info_8 *current_size; |
| 338 | |
| 339 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 340 | |
| 341 | /* aperture size */ |
| 342 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 343 | |
| 344 | /* address to map to */ |
| 345 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 346 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 347 | |
| 348 | /* attbase - aperture base */ |
| 349 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 350 | |
| 351 | /* agpctrl */ |
| 352 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 353 | |
| 354 | /* mcgcfg */ |
| 355 | pci_read_config_word(agp_bridge->dev, INTEL_I860_MCHCFG, &temp2); |
| 356 | pci_write_config_word(agp_bridge->dev, INTEL_I860_MCHCFG, temp2 | (1 << 9)); |
| 357 | /* clear any possible AGP-related error conditions */ |
| 358 | pci_write_config_word(agp_bridge->dev, INTEL_I860_ERRSTS, 0xf700); |
| 359 | return 0; |
| 360 | } |
| 361 | |
| 362 | static int intel_830mp_configure(void) |
| 363 | { |
| 364 | u32 temp; |
| 365 | u16 temp2; |
| 366 | struct aper_size_info_8 *current_size; |
| 367 | |
| 368 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 369 | |
| 370 | /* aperture size */ |
| 371 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 372 | |
| 373 | /* address to map to */ |
| 374 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 375 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 376 | |
| 377 | /* attbase - aperture base */ |
| 378 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 379 | |
| 380 | /* agpctrl */ |
| 381 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 382 | |
| 383 | /* gmch */ |
| 384 | pci_read_config_word(agp_bridge->dev, INTEL_NBXCFG, &temp2); |
| 385 | pci_write_config_word(agp_bridge->dev, INTEL_NBXCFG, temp2 | (1 << 9)); |
| 386 | /* clear any possible AGP-related error conditions */ |
| 387 | pci_write_config_word(agp_bridge->dev, INTEL_I830_ERRSTS, 0x1c); |
| 388 | return 0; |
| 389 | } |
| 390 | |
| 391 | static int intel_7505_configure(void) |
| 392 | { |
| 393 | u32 temp; |
| 394 | u16 temp2; |
| 395 | struct aper_size_info_8 *current_size; |
| 396 | |
| 397 | current_size = A_SIZE_8(agp_bridge->current_size); |
| 398 | |
| 399 | /* aperture size */ |
| 400 | pci_write_config_byte(agp_bridge->dev, INTEL_APSIZE, current_size->size_value); |
| 401 | |
| 402 | /* address to map to */ |
| 403 | pci_read_config_dword(agp_bridge->dev, AGP_APBASE, &temp); |
| 404 | agp_bridge->gart_bus_addr = (temp & PCI_BASE_ADDRESS_MEM_MASK); |
| 405 | |
| 406 | /* attbase - aperture base */ |
| 407 | pci_write_config_dword(agp_bridge->dev, INTEL_ATTBASE, agp_bridge->gatt_bus_addr); |
| 408 | |
| 409 | /* agpctrl */ |
| 410 | pci_write_config_dword(agp_bridge->dev, INTEL_AGPCTRL, 0x0000); |
| 411 | |
| 412 | /* mchcfg */ |
| 413 | pci_read_config_word(agp_bridge->dev, INTEL_I7505_MCHCFG, &temp2); |
| 414 | pci_write_config_word(agp_bridge->dev, INTEL_I7505_MCHCFG, temp2 | (1 << 9)); |
| 415 | |
| 416 | return 0; |
| 417 | } |
| 418 | |
| 419 | /* Setup function */ |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 420 | static const struct gatt_mask intel_generic_masks[] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | { |
| 422 | {.mask = 0x00000017, .type = 0} |
| 423 | }; |
| 424 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 425 | static const struct aper_size_info_8 intel_815_sizes[2] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | { |
| 427 | {64, 16384, 4, 0}, |
| 428 | {32, 8192, 3, 8}, |
| 429 | }; |
| 430 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 431 | static const struct aper_size_info_8 intel_8xx_sizes[7] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | { |
| 433 | {256, 65536, 6, 0}, |
| 434 | {128, 32768, 5, 32}, |
| 435 | {64, 16384, 4, 48}, |
| 436 | {32, 8192, 3, 56}, |
| 437 | {16, 4096, 2, 60}, |
| 438 | {8, 2048, 1, 62}, |
| 439 | {4, 1024, 0, 63} |
| 440 | }; |
| 441 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 442 | static const struct aper_size_info_16 intel_generic_sizes[7] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | { |
| 444 | {256, 65536, 6, 0}, |
| 445 | {128, 32768, 5, 32}, |
| 446 | {64, 16384, 4, 48}, |
| 447 | {32, 8192, 3, 56}, |
| 448 | {16, 4096, 2, 60}, |
| 449 | {8, 2048, 1, 62}, |
| 450 | {4, 1024, 0, 63} |
| 451 | }; |
| 452 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 453 | static const struct aper_size_info_8 intel_830mp_sizes[4] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | { |
| 455 | {256, 65536, 6, 0}, |
| 456 | {128, 32768, 5, 32}, |
| 457 | {64, 16384, 4, 48}, |
| 458 | {32, 8192, 3, 56} |
| 459 | }; |
| 460 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 461 | static const struct agp_bridge_driver intel_generic_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | .owner = THIS_MODULE, |
| 463 | .aperture_sizes = intel_generic_sizes, |
| 464 | .size_type = U16_APER_SIZE, |
| 465 | .num_aperture_sizes = 7, |
Jerome Glisse | 61cf059 | 2010-04-20 17:43:34 +0200 | [diff] [blame] | 466 | .needs_scratch_page = true, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | .configure = intel_configure, |
| 468 | .fetch_size = intel_fetch_size, |
| 469 | .cleanup = intel_cleanup, |
| 470 | .tlb_flush = intel_tlbflush, |
| 471 | .mask_memory = agp_generic_mask_memory, |
| 472 | .masks = intel_generic_masks, |
| 473 | .agp_enable = agp_generic_enable, |
| 474 | .cache_flush = global_cache_flush, |
| 475 | .create_gatt_table = agp_generic_create_gatt_table, |
| 476 | .free_gatt_table = agp_generic_free_gatt_table, |
| 477 | .insert_memory = agp_generic_insert_memory, |
| 478 | .remove_memory = agp_generic_remove_memory, |
| 479 | .alloc_by_type = agp_generic_alloc_by_type, |
| 480 | .free_by_type = agp_generic_free_by_type, |
| 481 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 482 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 484 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 485 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | }; |
| 487 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 488 | static const struct agp_bridge_driver intel_815_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | .owner = THIS_MODULE, |
| 490 | .aperture_sizes = intel_815_sizes, |
| 491 | .size_type = U8_APER_SIZE, |
| 492 | .num_aperture_sizes = 2, |
Jerome Glisse | 61cf059 | 2010-04-20 17:43:34 +0200 | [diff] [blame] | 493 | .needs_scratch_page = true, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | .configure = intel_815_configure, |
| 495 | .fetch_size = intel_815_fetch_size, |
| 496 | .cleanup = intel_8xx_cleanup, |
| 497 | .tlb_flush = intel_8xx_tlbflush, |
| 498 | .mask_memory = agp_generic_mask_memory, |
| 499 | .masks = intel_generic_masks, |
| 500 | .agp_enable = agp_generic_enable, |
| 501 | .cache_flush = global_cache_flush, |
| 502 | .create_gatt_table = agp_generic_create_gatt_table, |
| 503 | .free_gatt_table = agp_generic_free_gatt_table, |
| 504 | .insert_memory = agp_generic_insert_memory, |
| 505 | .remove_memory = agp_generic_remove_memory, |
| 506 | .alloc_by_type = agp_generic_alloc_by_type, |
| 507 | .free_by_type = agp_generic_free_by_type, |
| 508 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 509 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 511 | .agp_destroy_pages = agp_generic_destroy_pages, |
Dave Airlie | 62c96b9 | 2008-06-19 14:27:53 +1000 | [diff] [blame] | 512 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | }; |
| 514 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 515 | static const struct agp_bridge_driver intel_820_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | .owner = THIS_MODULE, |
| 517 | .aperture_sizes = intel_8xx_sizes, |
| 518 | .size_type = U8_APER_SIZE, |
| 519 | .num_aperture_sizes = 7, |
Jerome Glisse | 61cf059 | 2010-04-20 17:43:34 +0200 | [diff] [blame] | 520 | .needs_scratch_page = true, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | .configure = intel_820_configure, |
| 522 | .fetch_size = intel_8xx_fetch_size, |
| 523 | .cleanup = intel_820_cleanup, |
| 524 | .tlb_flush = intel_820_tlbflush, |
| 525 | .mask_memory = agp_generic_mask_memory, |
| 526 | .masks = intel_generic_masks, |
| 527 | .agp_enable = agp_generic_enable, |
| 528 | .cache_flush = global_cache_flush, |
| 529 | .create_gatt_table = agp_generic_create_gatt_table, |
| 530 | .free_gatt_table = agp_generic_free_gatt_table, |
| 531 | .insert_memory = agp_generic_insert_memory, |
| 532 | .remove_memory = agp_generic_remove_memory, |
| 533 | .alloc_by_type = agp_generic_alloc_by_type, |
| 534 | .free_by_type = agp_generic_free_by_type, |
| 535 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 536 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 538 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 539 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | }; |
| 541 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 542 | static const struct agp_bridge_driver intel_830mp_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | .owner = THIS_MODULE, |
| 544 | .aperture_sizes = intel_830mp_sizes, |
| 545 | .size_type = U8_APER_SIZE, |
| 546 | .num_aperture_sizes = 4, |
Jerome Glisse | 61cf059 | 2010-04-20 17:43:34 +0200 | [diff] [blame] | 547 | .needs_scratch_page = true, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | .configure = intel_830mp_configure, |
| 549 | .fetch_size = intel_8xx_fetch_size, |
| 550 | .cleanup = intel_8xx_cleanup, |
| 551 | .tlb_flush = intel_8xx_tlbflush, |
| 552 | .mask_memory = agp_generic_mask_memory, |
| 553 | .masks = intel_generic_masks, |
| 554 | .agp_enable = agp_generic_enable, |
| 555 | .cache_flush = global_cache_flush, |
| 556 | .create_gatt_table = agp_generic_create_gatt_table, |
| 557 | .free_gatt_table = agp_generic_free_gatt_table, |
| 558 | .insert_memory = agp_generic_insert_memory, |
| 559 | .remove_memory = agp_generic_remove_memory, |
| 560 | .alloc_by_type = agp_generic_alloc_by_type, |
| 561 | .free_by_type = agp_generic_free_by_type, |
| 562 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 563 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 565 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 566 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | }; |
| 568 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 569 | static const struct agp_bridge_driver intel_840_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | .owner = THIS_MODULE, |
| 571 | .aperture_sizes = intel_8xx_sizes, |
| 572 | .size_type = U8_APER_SIZE, |
| 573 | .num_aperture_sizes = 7, |
Jerome Glisse | 61cf059 | 2010-04-20 17:43:34 +0200 | [diff] [blame] | 574 | .needs_scratch_page = true, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | .configure = intel_840_configure, |
| 576 | .fetch_size = intel_8xx_fetch_size, |
| 577 | .cleanup = intel_8xx_cleanup, |
| 578 | .tlb_flush = intel_8xx_tlbflush, |
| 579 | .mask_memory = agp_generic_mask_memory, |
| 580 | .masks = intel_generic_masks, |
| 581 | .agp_enable = agp_generic_enable, |
| 582 | .cache_flush = global_cache_flush, |
| 583 | .create_gatt_table = agp_generic_create_gatt_table, |
| 584 | .free_gatt_table = agp_generic_free_gatt_table, |
| 585 | .insert_memory = agp_generic_insert_memory, |
| 586 | .remove_memory = agp_generic_remove_memory, |
| 587 | .alloc_by_type = agp_generic_alloc_by_type, |
| 588 | .free_by_type = agp_generic_free_by_type, |
| 589 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 590 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 592 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 593 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | }; |
| 595 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 596 | static const struct agp_bridge_driver intel_845_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | .owner = THIS_MODULE, |
| 598 | .aperture_sizes = intel_8xx_sizes, |
| 599 | .size_type = U8_APER_SIZE, |
| 600 | .num_aperture_sizes = 7, |
Jerome Glisse | 61cf059 | 2010-04-20 17:43:34 +0200 | [diff] [blame] | 601 | .needs_scratch_page = true, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | .configure = intel_845_configure, |
| 603 | .fetch_size = intel_8xx_fetch_size, |
| 604 | .cleanup = intel_8xx_cleanup, |
| 605 | .tlb_flush = intel_8xx_tlbflush, |
| 606 | .mask_memory = agp_generic_mask_memory, |
| 607 | .masks = intel_generic_masks, |
| 608 | .agp_enable = agp_generic_enable, |
| 609 | .cache_flush = global_cache_flush, |
| 610 | .create_gatt_table = agp_generic_create_gatt_table, |
| 611 | .free_gatt_table = agp_generic_free_gatt_table, |
| 612 | .insert_memory = agp_generic_insert_memory, |
| 613 | .remove_memory = agp_generic_remove_memory, |
| 614 | .alloc_by_type = agp_generic_alloc_by_type, |
| 615 | .free_by_type = agp_generic_free_by_type, |
| 616 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 617 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 619 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 620 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | }; |
| 622 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 623 | static const struct agp_bridge_driver intel_850_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | .owner = THIS_MODULE, |
| 625 | .aperture_sizes = intel_8xx_sizes, |
| 626 | .size_type = U8_APER_SIZE, |
| 627 | .num_aperture_sizes = 7, |
Jerome Glisse | 61cf059 | 2010-04-20 17:43:34 +0200 | [diff] [blame] | 628 | .needs_scratch_page = true, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 629 | .configure = intel_850_configure, |
| 630 | .fetch_size = intel_8xx_fetch_size, |
| 631 | .cleanup = intel_8xx_cleanup, |
| 632 | .tlb_flush = intel_8xx_tlbflush, |
| 633 | .mask_memory = agp_generic_mask_memory, |
| 634 | .masks = intel_generic_masks, |
| 635 | .agp_enable = agp_generic_enable, |
| 636 | .cache_flush = global_cache_flush, |
| 637 | .create_gatt_table = agp_generic_create_gatt_table, |
| 638 | .free_gatt_table = agp_generic_free_gatt_table, |
| 639 | .insert_memory = agp_generic_insert_memory, |
| 640 | .remove_memory = agp_generic_remove_memory, |
| 641 | .alloc_by_type = agp_generic_alloc_by_type, |
| 642 | .free_by_type = agp_generic_free_by_type, |
| 643 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 644 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 646 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 647 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | }; |
| 649 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 650 | static const struct agp_bridge_driver intel_860_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | .owner = THIS_MODULE, |
| 652 | .aperture_sizes = intel_8xx_sizes, |
| 653 | .size_type = U8_APER_SIZE, |
| 654 | .num_aperture_sizes = 7, |
Jerome Glisse | 61cf059 | 2010-04-20 17:43:34 +0200 | [diff] [blame] | 655 | .needs_scratch_page = true, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | .configure = intel_860_configure, |
| 657 | .fetch_size = intel_8xx_fetch_size, |
| 658 | .cleanup = intel_8xx_cleanup, |
| 659 | .tlb_flush = intel_8xx_tlbflush, |
| 660 | .mask_memory = agp_generic_mask_memory, |
| 661 | .masks = intel_generic_masks, |
| 662 | .agp_enable = agp_generic_enable, |
| 663 | .cache_flush = global_cache_flush, |
| 664 | .create_gatt_table = agp_generic_create_gatt_table, |
| 665 | .free_gatt_table = agp_generic_free_gatt_table, |
| 666 | .insert_memory = agp_generic_insert_memory, |
| 667 | .remove_memory = agp_generic_remove_memory, |
| 668 | .alloc_by_type = agp_generic_alloc_by_type, |
| 669 | .free_by_type = agp_generic_free_by_type, |
| 670 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 671 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 673 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 674 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | }; |
| 676 | |
Dave Jones | e5524f3 | 2007-02-22 18:41:28 -0500 | [diff] [blame] | 677 | static const struct agp_bridge_driver intel_7505_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | .owner = THIS_MODULE, |
| 679 | .aperture_sizes = intel_8xx_sizes, |
| 680 | .size_type = U8_APER_SIZE, |
| 681 | .num_aperture_sizes = 7, |
Jerome Glisse | 61cf059 | 2010-04-20 17:43:34 +0200 | [diff] [blame] | 682 | .needs_scratch_page = true, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | .configure = intel_7505_configure, |
| 684 | .fetch_size = intel_8xx_fetch_size, |
| 685 | .cleanup = intel_8xx_cleanup, |
| 686 | .tlb_flush = intel_8xx_tlbflush, |
| 687 | .mask_memory = agp_generic_mask_memory, |
| 688 | .masks = intel_generic_masks, |
| 689 | .agp_enable = agp_generic_enable, |
| 690 | .cache_flush = global_cache_flush, |
| 691 | .create_gatt_table = agp_generic_create_gatt_table, |
| 692 | .free_gatt_table = agp_generic_free_gatt_table, |
| 693 | .insert_memory = agp_generic_insert_memory, |
| 694 | .remove_memory = agp_generic_remove_memory, |
| 695 | .alloc_by_type = agp_generic_alloc_by_type, |
| 696 | .free_by_type = agp_generic_free_by_type, |
| 697 | .agp_alloc_page = agp_generic_alloc_page, |
Shaohua Li | 37acee1 | 2008-08-21 10:46:11 +0800 | [diff] [blame] | 698 | .agp_alloc_pages = agp_generic_alloc_pages, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | .agp_destroy_page = agp_generic_destroy_page, |
Shaohua Li | bd07928 | 2008-08-21 10:46:17 +0800 | [diff] [blame] | 700 | .agp_destroy_pages = agp_generic_destroy_pages, |
Thomas Hellstrom | a030ce4 | 2007-01-23 10:33:43 +0100 | [diff] [blame] | 701 | .agp_type_to_mask_type = agp_generic_type_to_mask_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | }; |
| 703 | |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 704 | /* Table to describe Intel GMCH and AGP/PCIE GART drivers. At least one of |
| 705 | * driver and gmch_driver must be non-null, and find_gmch will determine |
| 706 | * which one should be used if a gmch_chip_id is present. |
| 707 | */ |
Daniel Vetter | 02c026c | 2010-08-24 19:39:48 +0200 | [diff] [blame] | 708 | static const struct intel_agp_driver_description { |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 709 | unsigned int chip_id; |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 710 | char *name; |
| 711 | const struct agp_bridge_driver *driver; |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 712 | } intel_agp_chipsets[] = { |
Daniel Vetter | 02c026c | 2010-08-24 19:39:48 +0200 | [diff] [blame] | 713 | { PCI_DEVICE_ID_INTEL_82443LX_0, "440LX", &intel_generic_driver }, |
| 714 | { PCI_DEVICE_ID_INTEL_82443BX_0, "440BX", &intel_generic_driver }, |
| 715 | { PCI_DEVICE_ID_INTEL_82443GX_0, "440GX", &intel_generic_driver }, |
| 716 | { PCI_DEVICE_ID_INTEL_82815_MC, "i815", &intel_815_driver }, |
| 717 | { PCI_DEVICE_ID_INTEL_82820_HB, "i820", &intel_820_driver }, |
| 718 | { PCI_DEVICE_ID_INTEL_82820_UP_HB, "i820", &intel_820_driver }, |
| 719 | { PCI_DEVICE_ID_INTEL_82830_HB, "830M", &intel_830mp_driver }, |
| 720 | { PCI_DEVICE_ID_INTEL_82840_HB, "i840", &intel_840_driver }, |
Oswald Buddenhagen | 53371ed | 2010-06-19 23:08:37 +0200 | [diff] [blame] | 721 | { PCI_DEVICE_ID_INTEL_82845_HB, "i845", &intel_845_driver }, |
| 722 | { PCI_DEVICE_ID_INTEL_82845G_HB, "845G", &intel_845_driver }, |
Daniel Vetter | 02c026c | 2010-08-24 19:39:48 +0200 | [diff] [blame] | 723 | { PCI_DEVICE_ID_INTEL_82850_HB, "i850", &intel_850_driver }, |
| 724 | { PCI_DEVICE_ID_INTEL_82854_HB, "854", &intel_845_driver }, |
| 725 | { PCI_DEVICE_ID_INTEL_82855PM_HB, "855PM", &intel_845_driver }, |
| 726 | { PCI_DEVICE_ID_INTEL_82855GM_HB, "855GM", &intel_845_driver }, |
| 727 | { PCI_DEVICE_ID_INTEL_82860_HB, "i860", &intel_860_driver }, |
| 728 | { PCI_DEVICE_ID_INTEL_82865_HB, "865", &intel_845_driver }, |
| 729 | { PCI_DEVICE_ID_INTEL_82875_HB, "i875", &intel_845_driver }, |
| 730 | { PCI_DEVICE_ID_INTEL_7505_0, "E7505", &intel_7505_driver }, |
| 731 | { PCI_DEVICE_ID_INTEL_7205_0, "E7205", &intel_7505_driver }, |
| 732 | { 0, NULL, NULL } |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 733 | }; |
| 734 | |
Greg Kroah-Hartman | bcd2982 | 2012-12-21 15:12:08 -0800 | [diff] [blame] | 735 | static int agp_intel_probe(struct pci_dev *pdev, |
| 736 | const struct pci_device_id *ent) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 737 | { |
| 738 | struct agp_bridge_data *bridge; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 739 | u8 cap_ptr = 0; |
| 740 | struct resource *r; |
Zhenyu Wang | 1f7a6e3 | 2010-02-23 14:05:24 +0800 | [diff] [blame] | 741 | int i, err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | |
| 743 | cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP); |
| 744 | |
| 745 | bridge = agp_alloc_bridge(); |
| 746 | if (!bridge) |
| 747 | return -ENOMEM; |
| 748 | |
Daniel Vetter | 22dd82a | 2010-04-14 00:29:55 +0200 | [diff] [blame] | 749 | bridge->capndx = cap_ptr; |
| 750 | |
Daniel Vetter | 14be93d | 2012-06-08 15:55:40 +0200 | [diff] [blame] | 751 | if (intel_gmch_probe(pdev, NULL, bridge)) |
Daniel Vetter | 22dd82a | 2010-04-14 00:29:55 +0200 | [diff] [blame] | 752 | goto found_gmch; |
| 753 | |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 754 | for (i = 0; intel_agp_chipsets[i].name != NULL; i++) { |
| 755 | /* In case that multiple models of gfx chip may |
| 756 | stand on same host bridge type, this can be |
| 757 | sure we detect the right IGD. */ |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 758 | if (pdev->device == intel_agp_chipsets[i].chip_id) { |
Daniel Vetter | 22dd82a | 2010-04-14 00:29:55 +0200 | [diff] [blame] | 759 | bridge->driver = intel_agp_chipsets[i].driver; |
| 760 | break; |
Wang Zhenyu | 8888985 | 2007-06-14 10:01:04 +0800 | [diff] [blame] | 761 | } |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 762 | } |
| 763 | |
Daniel Vetter | 02c026c | 2010-08-24 19:39:48 +0200 | [diff] [blame] | 764 | if (!bridge->driver) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | if (cap_ptr) |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 766 | dev_warn(&pdev->dev, "unsupported Intel chipset [%04x/%04x]\n", |
| 767 | pdev->vendor, pdev->device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 768 | agp_put_bridge(bridge); |
| 769 | return -ENODEV; |
Wang Zhenyu | 9614ece | 2007-05-30 09:45:58 +0800 | [diff] [blame] | 770 | } |
| 771 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | bridge->dev = pdev; |
Daniel Vetter | 22dd82a | 2010-04-14 00:29:55 +0200 | [diff] [blame] | 773 | bridge->dev_private_data = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 774 | |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 775 | dev_info(&pdev->dev, "Intel %s Chipset\n", intel_agp_chipsets[i].name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 776 | |
| 777 | /* |
| 778 | * The following fixes the case where the BIOS has "forgotten" to |
| 779 | * provide an address range for the GART. |
| 780 | * 20030610 - hamish@zot.org |
Stephen Kitt | a70b95c | 2011-01-31 14:25:43 -0800 | [diff] [blame] | 781 | * This happens before pci_enable_device() intentionally; |
| 782 | * calling pci_enable_device() before assigning the resource |
| 783 | * will result in the GART being disabled on machines with such |
| 784 | * BIOSs (the GART ends up with a BAR starting at 0, which |
| 785 | * conflicts a lot of other devices). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 786 | */ |
| 787 | r = &pdev->resource[0]; |
| 788 | if (!r->start && r->end) { |
Dave Jones | 6a92a4e | 2006-02-28 00:54:25 -0500 | [diff] [blame] | 789 | if (pci_assign_resource(pdev, 0)) { |
Bjorn Helgaas | e3cf695 | 2008-07-30 12:26:51 -0700 | [diff] [blame] | 790 | dev_err(&pdev->dev, "can't assign resource 0\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 791 | agp_put_bridge(bridge); |
| 792 | return -ENODEV; |
| 793 | } |
| 794 | } |
| 795 | |
Stephen Kitt | a70b95c | 2011-01-31 14:25:43 -0800 | [diff] [blame] | 796 | /* |
| 797 | * If the device has not been properly setup, the following will catch |
| 798 | * the problem and should stop the system from crashing. |
| 799 | * 20030610 - hamish@zot.org |
| 800 | */ |
| 801 | if (pci_enable_device(pdev)) { |
| 802 | dev_err(&pdev->dev, "can't enable PCI device\n"); |
| 803 | agp_put_bridge(bridge); |
| 804 | return -ENODEV; |
| 805 | } |
| 806 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 807 | /* Fill in the mode register */ |
| 808 | if (cap_ptr) { |
| 809 | pci_read_config_dword(pdev, |
| 810 | bridge->capndx+PCI_AGP_STATUS, |
| 811 | &bridge->mode); |
| 812 | } |
| 813 | |
Daniel Vetter | 22dd82a | 2010-04-14 00:29:55 +0200 | [diff] [blame] | 814 | found_gmch: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 815 | pci_set_drvdata(pdev, bridge); |
Zhenyu Wang | 1f7a6e3 | 2010-02-23 14:05:24 +0800 | [diff] [blame] | 816 | err = agp_add_bridge(bridge); |
| 817 | if (!err) |
| 818 | intel_agp_enabled = 1; |
| 819 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 820 | } |
| 821 | |
Bill Pemberton | 39af33f | 2012-11-19 13:26:26 -0500 | [diff] [blame] | 822 | static void agp_intel_remove(struct pci_dev *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 823 | { |
| 824 | struct agp_bridge_data *bridge = pci_get_drvdata(pdev); |
| 825 | |
| 826 | agp_remove_bridge(bridge); |
| 827 | |
Daniel Vetter | 14be93d | 2012-06-08 15:55:40 +0200 | [diff] [blame] | 828 | intel_gmch_remove(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 829 | |
| 830 | agp_put_bridge(bridge); |
| 831 | } |
| 832 | |
Alexey Dobriyan | 85be7d6 | 2006-08-12 02:02:02 +0400 | [diff] [blame] | 833 | #ifdef CONFIG_PM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 834 | static int agp_intel_resume(struct pci_dev *pdev) |
| 835 | { |
| 836 | struct agp_bridge_data *bridge = pci_get_drvdata(pdev); |
| 837 | |
Daniel Vetter | e5a04d5 | 2010-04-14 00:29:53 +0200 | [diff] [blame] | 838 | bridge->driver->configure(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 839 | |
| 840 | return 0; |
| 841 | } |
Alexey Dobriyan | 85be7d6 | 2006-08-12 02:02:02 +0400 | [diff] [blame] | 842 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | |
| 844 | static struct pci_device_id agp_intel_pci_table[] = { |
| 845 | #define ID(x) \ |
| 846 | { \ |
| 847 | .class = (PCI_CLASS_BRIDGE_HOST << 8), \ |
| 848 | .class_mask = ~0, \ |
| 849 | .vendor = PCI_VENDOR_ID_INTEL, \ |
| 850 | .device = x, \ |
| 851 | .subvendor = PCI_ANY_ID, \ |
| 852 | .subdevice = PCI_ANY_ID, \ |
| 853 | } |
Ben Widawsky | 6b2d590 | 2012-01-04 14:04:33 -0800 | [diff] [blame] | 854 | ID(PCI_DEVICE_ID_INTEL_82441), /* for HAS2 support */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 855 | ID(PCI_DEVICE_ID_INTEL_82443LX_0), |
| 856 | ID(PCI_DEVICE_ID_INTEL_82443BX_0), |
| 857 | ID(PCI_DEVICE_ID_INTEL_82443GX_0), |
| 858 | ID(PCI_DEVICE_ID_INTEL_82810_MC1), |
| 859 | ID(PCI_DEVICE_ID_INTEL_82810_MC3), |
| 860 | ID(PCI_DEVICE_ID_INTEL_82810E_MC), |
| 861 | ID(PCI_DEVICE_ID_INTEL_82815_MC), |
| 862 | ID(PCI_DEVICE_ID_INTEL_82820_HB), |
| 863 | ID(PCI_DEVICE_ID_INTEL_82820_UP_HB), |
| 864 | ID(PCI_DEVICE_ID_INTEL_82830_HB), |
| 865 | ID(PCI_DEVICE_ID_INTEL_82840_HB), |
| 866 | ID(PCI_DEVICE_ID_INTEL_82845_HB), |
| 867 | ID(PCI_DEVICE_ID_INTEL_82845G_HB), |
| 868 | ID(PCI_DEVICE_ID_INTEL_82850_HB), |
Stefan Husemann | 347486b | 2009-04-13 14:40:10 -0700 | [diff] [blame] | 869 | ID(PCI_DEVICE_ID_INTEL_82854_HB), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | ID(PCI_DEVICE_ID_INTEL_82855PM_HB), |
| 871 | ID(PCI_DEVICE_ID_INTEL_82855GM_HB), |
| 872 | ID(PCI_DEVICE_ID_INTEL_82860_HB), |
| 873 | ID(PCI_DEVICE_ID_INTEL_82865_HB), |
| 874 | ID(PCI_DEVICE_ID_INTEL_82875_HB), |
| 875 | ID(PCI_DEVICE_ID_INTEL_7505_0), |
| 876 | ID(PCI_DEVICE_ID_INTEL_7205_0), |
Carlos MartÃn | e914a36 | 2008-01-24 10:34:09 +1000 | [diff] [blame] | 877 | ID(PCI_DEVICE_ID_INTEL_E7221_HB), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 878 | ID(PCI_DEVICE_ID_INTEL_82915G_HB), |
| 879 | ID(PCI_DEVICE_ID_INTEL_82915GM_HB), |
Alan Hourihane | d0de98f | 2005-05-31 19:50:49 +0100 | [diff] [blame] | 880 | ID(PCI_DEVICE_ID_INTEL_82945G_HB), |
Alan Hourihane | 3b0e8ea | 2006-01-19 14:08:40 +0000 | [diff] [blame] | 881 | ID(PCI_DEVICE_ID_INTEL_82945GM_HB), |
Zhenyu Wang | dde4787 | 2007-07-26 09:18:09 +0800 | [diff] [blame] | 882 | ID(PCI_DEVICE_ID_INTEL_82945GME_HB), |
Adam Jackson | 107f517 | 2009-12-03 17:14:41 -0500 | [diff] [blame] | 883 | ID(PCI_DEVICE_ID_INTEL_PINEVIEW_M_HB), |
| 884 | ID(PCI_DEVICE_ID_INTEL_PINEVIEW_HB), |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 885 | ID(PCI_DEVICE_ID_INTEL_82946GZ_HB), |
Zhenyu Wang | 9119f85 | 2008-01-23 15:49:26 +1000 | [diff] [blame] | 886 | ID(PCI_DEVICE_ID_INTEL_82G35_HB), |
Eric Anholt | 65c25aa | 2006-09-06 11:57:18 -0400 | [diff] [blame] | 887 | ID(PCI_DEVICE_ID_INTEL_82965Q_HB), |
| 888 | ID(PCI_DEVICE_ID_INTEL_82965G_HB), |
Wang Zhenyu | 4598af3 | 2007-04-09 08:51:36 +0800 | [diff] [blame] | 889 | ID(PCI_DEVICE_ID_INTEL_82965GM_HB), |
Zhenyu Wang | dde4787 | 2007-07-26 09:18:09 +0800 | [diff] [blame] | 890 | ID(PCI_DEVICE_ID_INTEL_82965GME_HB), |
Wang Zhenyu | 874808c6 | 2007-06-06 11:16:25 +0800 | [diff] [blame] | 891 | ID(PCI_DEVICE_ID_INTEL_G33_HB), |
| 892 | ID(PCI_DEVICE_ID_INTEL_Q35_HB), |
| 893 | ID(PCI_DEVICE_ID_INTEL_Q33_HB), |
Zhenyu Wang | 99d32bd | 2008-07-30 12:26:50 -0700 | [diff] [blame] | 894 | ID(PCI_DEVICE_ID_INTEL_GM45_HB), |
Adam Jackson | 107f517 | 2009-12-03 17:14:41 -0500 | [diff] [blame] | 895 | ID(PCI_DEVICE_ID_INTEL_EAGLELAKE_HB), |
Zhenyu Wang | 25ce77a | 2008-06-19 14:17:58 +1000 | [diff] [blame] | 896 | ID(PCI_DEVICE_ID_INTEL_Q45_HB), |
| 897 | ID(PCI_DEVICE_ID_INTEL_G45_HB), |
Zhenyu Wang | a50ccc6 | 2008-11-17 14:39:00 +0800 | [diff] [blame] | 898 | ID(PCI_DEVICE_ID_INTEL_G41_HB), |
Fabian Henze | 38d8a95 | 2009-09-08 00:59:58 +0800 | [diff] [blame] | 899 | ID(PCI_DEVICE_ID_INTEL_B43_HB), |
Chris Wilson | 3dde04b | 2010-10-14 16:30:41 +0100 | [diff] [blame] | 900 | ID(PCI_DEVICE_ID_INTEL_B43_1_HB), |
Adam Jackson | 107f517 | 2009-12-03 17:14:41 -0500 | [diff] [blame] | 901 | ID(PCI_DEVICE_ID_INTEL_IRONLAKE_D_HB), |
Eugeni Dodonov | 67384fe | 2012-06-06 11:59:06 -0300 | [diff] [blame] | 902 | ID(PCI_DEVICE_ID_INTEL_IRONLAKE_D2_HB), |
Adam Jackson | 107f517 | 2009-12-03 17:14:41 -0500 | [diff] [blame] | 903 | ID(PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB), |
| 904 | ID(PCI_DEVICE_ID_INTEL_IRONLAKE_MA_HB), |
Dave Airlie | 3ff9916 | 2009-12-08 14:03:47 +1000 | [diff] [blame] | 905 | ID(PCI_DEVICE_ID_INTEL_IRONLAKE_MC2_HB), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 906 | { } |
| 907 | }; |
| 908 | |
| 909 | MODULE_DEVICE_TABLE(pci, agp_intel_pci_table); |
| 910 | |
| 911 | static struct pci_driver agp_intel_pci_driver = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 912 | .name = "agpgart-intel", |
| 913 | .id_table = agp_intel_pci_table, |
| 914 | .probe = agp_intel_probe, |
Greg Kroah-Hartman | bcd2982 | 2012-12-21 15:12:08 -0800 | [diff] [blame] | 915 | .remove = agp_intel_remove, |
Alexey Dobriyan | 85be7d6 | 2006-08-12 02:02:02 +0400 | [diff] [blame] | 916 | #ifdef CONFIG_PM |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 917 | .resume = agp_intel_resume, |
Alexey Dobriyan | 85be7d6 | 2006-08-12 02:02:02 +0400 | [diff] [blame] | 918 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 919 | }; |
| 920 | |
| 921 | static int __init agp_intel_init(void) |
| 922 | { |
| 923 | if (agp_off) |
| 924 | return -EINVAL; |
| 925 | return pci_register_driver(&agp_intel_pci_driver); |
| 926 | } |
| 927 | |
| 928 | static void __exit agp_intel_cleanup(void) |
| 929 | { |
| 930 | pci_unregister_driver(&agp_intel_pci_driver); |
| 931 | } |
| 932 | |
| 933 | module_init(agp_intel_init); |
| 934 | module_exit(agp_intel_cleanup); |
| 935 | |
Dave Jones | f4432c5 | 2008-10-20 13:31:45 -0400 | [diff] [blame] | 936 | MODULE_AUTHOR("Dave Jones <davej@redhat.com>"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 937 | MODULE_LICENSE("GPL and additional rights"); |