ata-dma.c (75516) | ata-dma.c (75553) |
---|---|
1/*- 2 * Copyright (c) 1998,1999,2000,2001 S�ren Schmidt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * | 1/*- 2 * Copyright (c) 1998,1999,2000,2001 S�ren Schmidt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/sys/dev/ata/ata-dma.c 75516 2001-04-14 18:33:08Z sos $ | 28 * $FreeBSD: head/sys/dev/ata/ata-dma.c 75553 2001-04-16 21:22:34Z sos $ |
29 */ 30 31#include "pci.h" 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/ata.h> 35#include <sys/bio.h> 36#include <sys/malloc.h> --- 65 unchanged lines hidden (view full) --- 102 if (udmamode > 2 && !ATA_PARAM(scp, device)->cblid) { 103 ata_printf(scp, device, 104 "DMA limited to UDMA33, non-ATA66 compliant cable\n"); 105 udmamode = 2; 106 } 107 108 switch (scp->chiptype) { 109 | 29 */ 30 31#include "pci.h" 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/ata.h> 35#include <sys/bio.h> 36#include <sys/malloc.h> --- 65 unchanged lines hidden (view full) --- 102 if (udmamode > 2 && !ATA_PARAM(scp, device)->cblid) { 103 ata_printf(scp, device, 104 "DMA limited to UDMA33, non-ATA66 compliant cable\n"); 105 udmamode = 2; 106 } 107 108 switch (scp->chiptype) { 109 |
110 case 0x244a8086: /* Intel ICH2 mobile */ |
|
110 case 0x244b8086: /* Intel ICH2 */ 111 if (udmamode >= 5) { 112 int32_t mask48, new48; 113 int16_t word54; 114 115 word54 = pci_read_config(parent, 0x54, 2); 116 if (word54 & (0x10 << devno)) { 117 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 118 ATA_UDMA5, ATA_C_F_SETXFER,ATA_WAIT_READY); 119 if (bootverbose) 120 ata_printf(scp, device, | 111 case 0x244b8086: /* Intel ICH2 */ 112 if (udmamode >= 5) { 113 int32_t mask48, new48; 114 int16_t word54; 115 116 word54 = pci_read_config(parent, 0x54, 2); 117 if (word54 & (0x10 << devno)) { 118 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 119 ATA_UDMA5, ATA_C_F_SETXFER,ATA_WAIT_READY); 120 if (bootverbose) 121 ata_printf(scp, device, |
121 "%s setting UDMA5 on ICH2 chip\n", | 122 "%s setting UDMA5 on Intel chip\n", |
122 (error) ? "failed" : "success"); 123 if (!error) { 124 mask48 = (1 << devno) + (3 << (16 + (devno << 2))); 125 new48 = (1 << devno) + (1 << (16 + (devno << 2))); 126 pci_write_config(parent, 0x48, 127 (pci_read_config(parent, 0x48, 4) & 128 ~mask48) | new48, 4); 129 pci_write_config(parent, 0x54, word54 | (0x1000<<devno), 2); --- 13 unchanged lines hidden (view full) --- 143 int16_t word54; 144 145 word54 = pci_read_config(parent, 0x54, 2); 146 if (word54 & (0x10 << devno)) { 147 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 148 ATA_UDMA4, ATA_C_F_SETXFER,ATA_WAIT_READY); 149 if (bootverbose) 150 ata_printf(scp, device, | 123 (error) ? "failed" : "success"); 124 if (!error) { 125 mask48 = (1 << devno) + (3 << (16 + (devno << 2))); 126 new48 = (1 << devno) + (1 << (16 + (devno << 2))); 127 pci_write_config(parent, 0x48, 128 (pci_read_config(parent, 0x48, 4) & 129 ~mask48) | new48, 4); 130 pci_write_config(parent, 0x54, word54 | (0x1000<<devno), 2); --- 13 unchanged lines hidden (view full) --- 144 int16_t word54; 145 146 word54 = pci_read_config(parent, 0x54, 2); 147 if (word54 & (0x10 << devno)) { 148 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 149 ATA_UDMA4, ATA_C_F_SETXFER,ATA_WAIT_READY); 150 if (bootverbose) 151 ata_printf(scp, device, |
151 "%s setting UDMA4 on ICH%s chip\n", 152 (error) ? "failed" : "success", 153 (scp->chiptype == 0x244b8086) ? "2" : ""); | 152 "%s setting UDMA4 on Intel chip\n", 153 (error) ? "failed" : "success"); |
154 if (!error) { 155 mask48 = (1 << devno) + (3 << (16 + (devno << 2))); 156 new48 = (1 << devno) + (2 << (16 + (devno << 2))); 157 pci_write_config(parent, 0x48, 158 (pci_read_config(parent, 0x48, 4) & 159 ~mask48) | new48, 4); 160 pci_write_config(parent, 0x54, word54 | (1 << devno), 2); 161 scp->mode[ATA_DEV(device)] = ATA_UDMA4; --- 10 unchanged lines hidden (view full) --- 172 case 0x71998086: /* Intel PIIX4e */ 173 case 0x24218086: /* Intel ICH0 */ 174 if (udmamode >= 2) { 175 int32_t mask48, new48; 176 177 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 178 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); 179 if (bootverbose) | 154 if (!error) { 155 mask48 = (1 << devno) + (3 << (16 + (devno << 2))); 156 new48 = (1 << devno) + (2 << (16 + (devno << 2))); 157 pci_write_config(parent, 0x48, 158 (pci_read_config(parent, 0x48, 4) & 159 ~mask48) | new48, 4); 160 pci_write_config(parent, 0x54, word54 | (1 << devno), 2); 161 scp->mode[ATA_DEV(device)] = ATA_UDMA4; --- 10 unchanged lines hidden (view full) --- 172 case 0x71998086: /* Intel PIIX4e */ 173 case 0x24218086: /* Intel ICH0 */ 174 if (udmamode >= 2) { 175 int32_t mask48, new48; 176 177 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 178 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); 179 if (bootverbose) |
180 ata_printf(scp, device, "%s setting UDMA2 on %s chip\n", 181 (error) ? "failed" : "success", 182 (scp->chiptype == 0x244b8086) ? "ICH2" : 183 (scp->chiptype == 0x24118086) ? "ICH" : 184 (scp->chiptype == 0x24218086) ? "ICH0" :"PIIX4"); | 180 ata_printf(scp, device, "%s setting UDMA2 on Intel chip\n", 181 (error) ? "failed" : "success"); |
185 if (!error) { 186 mask48 = (1 << devno) + (3 << (16 + (devno << 2))); 187 new48 = (1 << devno) + (2 << (16 + (devno << 2))); 188 pci_write_config(parent, 0x48, 189 (pci_read_config(parent, 0x48, 4) & 190 ~mask48) | new48, 4); 191 scp->mode[ATA_DEV(device)] = ATA_UDMA2; 192 return; --- 22 unchanged lines hidden (view full) --- 215 } 216 new40 |= 0x40004000; 217 pci_write_config(parent, 0x40, new40, 4); 218 pci_write_config(parent, 0x44, new44, 4); 219 } 220 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 221 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); 222 if (bootverbose) | 182 if (!error) { 183 mask48 = (1 << devno) + (3 << (16 + (devno << 2))); 184 new48 = (1 << devno) + (2 << (16 + (devno << 2))); 185 pci_write_config(parent, 0x48, 186 (pci_read_config(parent, 0x48, 4) & 187 ~mask48) | new48, 4); 188 scp->mode[ATA_DEV(device)] = ATA_UDMA2; 189 return; --- 22 unchanged lines hidden (view full) --- 212 } 213 new40 |= 0x40004000; 214 pci_write_config(parent, 0x40, new40, 4); 215 pci_write_config(parent, 0x44, new44, 4); 216 } 217 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 218 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); 219 if (bootverbose) |
223 ata_printf(scp, device, "%s setting WDMA2 on %s chip\n", 224 (error) ? "failed" : "success", 225 (scp->chiptype == 0x244b8086) ? "ICH2" : 226 (scp->chiptype == 0x24118086) ? "ICH" : 227 (scp->chiptype == 0x24218086) ? "ICH0" : 228 (scp->chiptype == 0x70108086) ? "PIIX3":"PIIX4"); | 220 ata_printf(scp, device, "%s setting WDMA2 on Intel chip\n", 221 (error) ? "failed" : "success"); |
229 if (!error) { 230 if (device == ATA_MASTER) { 231 mask40 = 0x0000330f; 232 new40 = 0x00002307; 233 mask44 = 0; 234 new44 = 0; 235 } 236 else { --- 32 unchanged lines hidden (view full) --- 269 if (!((word40 & 0x3300) == 0x2300 && 270 ((word40 >> (device == ATA_MASTER ? 0 : 4)) & 1) == 1)) 271 break; 272 273 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 274 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); 275 if (bootverbose) 276 ata_printf(scp, device, | 222 if (!error) { 223 if (device == ATA_MASTER) { 224 mask40 = 0x0000330f; 225 new40 = 0x00002307; 226 mask44 = 0; 227 new44 = 0; 228 } 229 else { --- 32 unchanged lines hidden (view full) --- 262 if (!((word40 & 0x3300) == 0x2300 && 263 ((word40 >> (device == ATA_MASTER ? 0 : 4)) & 1) == 1)) 264 break; 265 266 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 267 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); 268 if (bootverbose) 269 ata_printf(scp, device, |
277 "%s setting WDMA2 on PIIX chip\n", | 270 "%s setting WDMA2 on Intel chip\n", |
278 (error) ? "failed" : "success"); 279 if (!error) { 280 scp->mode[ATA_DEV(device)] = ATA_WDMA2; 281 return; 282 } 283 } 284 break; 285 --- 5 unchanged lines hidden (view full) --- 291 "Aladdin: two atapi devices on this channel, no DMA\n"); 292 break; 293 } 294 if (udmamode >= 5 && pci_get_revid(parent) >= 0xC4) { 295 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 296 ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY); 297 if (bootverbose) 298 ata_printf(scp, device, | 271 (error) ? "failed" : "success"); 272 if (!error) { 273 scp->mode[ATA_DEV(device)] = ATA_WDMA2; 274 return; 275 } 276 } 277 break; 278 --- 5 unchanged lines hidden (view full) --- 284 "Aladdin: two atapi devices on this channel, no DMA\n"); 285 break; 286 } 287 if (udmamode >= 5 && pci_get_revid(parent) >= 0xC4) { 288 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 289 ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY); 290 if (bootverbose) 291 ata_printf(scp, device, |
299 "%s setting UDMA5 on Aladdin chip\n", | 292 "%s setting UDMA5 on Acer chip\n", |
300 (error) ? "failed" : "success"); 301 if (!error) { 302 int32_t word54 = pci_read_config(parent, 0x54, 4); 303 304 pci_write_config(parent, 0x4b, 305 pci_read_config(parent, 0x4b, 1) | 0x01, 1); 306 word54 &= ~(0x000f000f << (devno << 2)); 307 word54 |= (0x000f0005 << (devno << 2)); --- 4 unchanged lines hidden (view full) --- 312 return; 313 } 314 } 315 if (udmamode >= 4 && pci_get_revid(parent) >= 0xC2) { 316 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 317 ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY); 318 if (bootverbose) 319 ata_printf(scp, device, | 293 (error) ? "failed" : "success"); 294 if (!error) { 295 int32_t word54 = pci_read_config(parent, 0x54, 4); 296 297 pci_write_config(parent, 0x4b, 298 pci_read_config(parent, 0x4b, 1) | 0x01, 1); 299 word54 &= ~(0x000f000f << (devno << 2)); 300 word54 |= (0x000f0005 << (devno << 2)); --- 4 unchanged lines hidden (view full) --- 305 return; 306 } 307 } 308 if (udmamode >= 4 && pci_get_revid(parent) >= 0xC2) { 309 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 310 ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY); 311 if (bootverbose) 312 ata_printf(scp, device, |
320 "%s setting UDMA4 on Aladdin chip\n", | 313 "%s setting UDMA4 on Acer chip\n", |
321 (error) ? "failed" : "success"); 322 if (!error) { 323 int32_t word54 = pci_read_config(parent, 0x54, 4); 324 325 pci_write_config(parent, 0x4b, 326 pci_read_config(parent, 0x4b, 1) | 0x01, 1); 327 word54 &= ~(0x000f000f << (devno << 2)); 328 word54 |= (0x00080005 << (devno << 2)); --- 4 unchanged lines hidden (view full) --- 333 return; 334 } 335 } 336 if (udmamode >= 2 && pci_get_revid(parent) >= 0x20) { 337 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 338 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); 339 if (bootverbose) 340 ata_printf(scp, device, | 314 (error) ? "failed" : "success"); 315 if (!error) { 316 int32_t word54 = pci_read_config(parent, 0x54, 4); 317 318 pci_write_config(parent, 0x4b, 319 pci_read_config(parent, 0x4b, 1) | 0x01, 1); 320 word54 &= ~(0x000f000f << (devno << 2)); 321 word54 |= (0x00080005 << (devno << 2)); --- 4 unchanged lines hidden (view full) --- 326 return; 327 } 328 } 329 if (udmamode >= 2 && pci_get_revid(parent) >= 0x20) { 330 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 331 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); 332 if (bootverbose) 333 ata_printf(scp, device, |
341 "%s setting UDMA2 on Aladdin chip\n", | 334 "%s setting UDMA2 on Acer chip\n", |
342 (error) ? "failed" : "success"); 343 if (!error) { 344 int32_t word54 = pci_read_config(parent, 0x54, 4); 345 346 word54 &= ~(0x000f000f << (devno << 2)); 347 word54 |= (0x000a0005 << (devno << 2)); 348 pci_write_config(parent, 0x54, word54, 4); 349 pci_write_config(parent, 0x53, --- 8 unchanged lines hidden (view full) --- 358 pci_write_config(parent, 0x56, pci_read_config(parent, 0x56, 2) & 359 ~(0x0008 << (devno << 2)), 2); 360 361 if (wdmamode >= 2 && apiomode >= 4) { 362 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 363 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); 364 if (bootverbose) 365 ata_printf(scp, device, | 335 (error) ? "failed" : "success"); 336 if (!error) { 337 int32_t word54 = pci_read_config(parent, 0x54, 4); 338 339 word54 &= ~(0x000f000f << (devno << 2)); 340 word54 |= (0x000a0005 << (devno << 2)); 341 pci_write_config(parent, 0x54, word54, 4); 342 pci_write_config(parent, 0x53, --- 8 unchanged lines hidden (view full) --- 351 pci_write_config(parent, 0x56, pci_read_config(parent, 0x56, 2) & 352 ~(0x0008 << (devno << 2)), 2); 353 354 if (wdmamode >= 2 && apiomode >= 4) { 355 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 356 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); 357 if (bootverbose) 358 ata_printf(scp, device, |
366 "%s setting WDMA2 on Aladdin chip\n", | 359 "%s setting WDMA2 on Acer chip\n", |
367 (error) ? "failed" : "success"); 368 if (!error) { 369 pci_write_config(parent, 0x53, 370 pci_read_config(parent, 0x53, 1) | 0x03, 1); 371 scp->flags |= ATA_ATAPI_DMA_RO; 372 scp->mode[ATA_DEV(device)] = ATA_WDMA2; 373 return; 374 } --- 747 unchanged lines hidden --- | 360 (error) ? "failed" : "success"); 361 if (!error) { 362 pci_write_config(parent, 0x53, 363 pci_read_config(parent, 0x53, 1) | 0x03, 1); 364 scp->flags |= ATA_ATAPI_DMA_RO; 365 scp->mode[ATA_DEV(device)] = ATA_WDMA2; 366 return; 367 } --- 747 unchanged lines hidden --- |