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