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