1/*- 2 * Copyright (c) 1998,1999 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 53029 1999-11-08 21:36:00Z sos $ |
29 */ 30 31#include "pci.h" 32#include "apm.h" 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/buf.h> 36#include <sys/malloc.h> --- 58 unchanged lines hidden (view full) --- 95 96 switch (type = pci_get_devid(scp->dev)) { 97 98 case 0x71118086: /* Intel PIIX4 */ 99 if (udmamode >= 2) { 100 int32_t mask48, new48; 101 102 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, |
103 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); |
104 if (bootverbose) 105 printf("ata%d: %s: %s setting up UDMA2 mode on PIIX4 chip\n", 106 scp->lun, (device == ATA_MASTER) ? "master" : "slave", 107 (error) ? "failed" : "success"); 108 if (error) 109 break; 110 devno = (scp->unit << 1) + ((device == ATA_MASTER) ? 0 : 1); 111 mask48 = (1 << devno) + (3 << (16 + (devno << 2))); --- 22 unchanged lines hidden (view full) --- 134 new44 &= ~0x000000f0; 135 new44 |= ((new40&0x30000000)>>22)|((new40&0x03000000)>>20); 136 } 137 new40 |= 0x40004000; 138 pci_write_config(scp->dev, 0x40, new40, 4); 139 pci_write_config(scp->dev, 0x44, new44, 4); 140 } 141 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, |
142 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); |
143 if (bootverbose) 144 printf("ata%d: %s: %s setting up WDMA2 mode on PIIX4 chip\n", 145 scp->lun, (device == ATA_MASTER) ? "master" : "slave", 146 (error) ? "failed" : "success"); 147 if (error) 148 break; 149 if (device == ATA_MASTER) { 150 mask40 = 0x0000330f; --- 23 unchanged lines hidden (view full) --- 174 } 175 break; 176 177 case 0x12308086: /* Intel PIIX */ 178 /* probably not worth the trouble */ 179 break; 180 181 case 0x522910b9: /* AcerLabs Aladdin IV/V */ |
182 /* the Aladdin doesn't support ATAPI DMA on both master & slave */ 183 if (scp->devices & ATA_ATAPI_MASTER && scp->devices & ATA_ATAPI_SLAVE) { 184 printf("ata%d: Aladdin: two atapi devices on this channel, " 185 "DMA disabled\n", scp->lun); 186 break; |
187 } 188 if (udmamode >=2) { 189 int32_t word54 = pci_read_config(scp->dev, 0x54, 4); 190 191 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, |
192 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); |
193 if (bootverbose) 194 printf("ata%d: %s: %s setting up UDMA2 mode on Aladdin chip\n", 195 scp->lun, (device == ATA_MASTER) ? "master" : "slave", 196 (error) ? "failed" : "success"); 197 if (error) 198 break; 199 word54 |= 0x5555; 200 word54 |= (0x0a << (16 + (scp->unit << 3) + (device << 2))); 201 pci_write_config(scp->dev, 0x54, word54, 4); |
202 pci_write_config(scp->dev, 0x53, 203 pci_read_config(scp->dev, 0x53, 1) | 0x03, 1); 204 scp->flags |= ATA_ATAPI_DMA_RO; |
205 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA2; 206 return 0; 207 208 } 209 else if (wdmamode >= 2 && apiomode >= 4) { 210 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, |
211 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); |
212 if (bootverbose) 213 printf("ata%d: %s: %s setting up WDMA2 mode on Aladdin chip\n", 214 scp->lun, (device == ATA_MASTER) ? "master" : "slave", 215 (error) ? "failed" : "success"); 216 if (error) 217 break; |
218 pci_write_config(scp->dev, 0x53, 219 pci_read_config(scp->dev, 0x53, 1) | 0x03, 1); 220 scp->flags |= ATA_ATAPI_DMA_RO; |
221 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_WDMA2; 222 return 0; 223 } 224 break; 225 226 case 0x4d33105a: /* Promise Ultra33 / FastTrak33 controllers */ 227 case 0x4d38105a: /* Promise Ultra66 / FastTrak66 controllers */ 228 /* the Promise can only do DMA on ATA disks not on ATAPI devices */ 229 if ((device == ATA_MASTER && scp->devices & ATA_ATAPI_MASTER) || 230 (device == ATA_SLAVE && scp->devices & ATA_ATAPI_SLAVE)) 231 break; 232 233 devno = (scp->unit << 1) + ((device == ATA_MASTER) ? 0 : 1); 234 if (udmamode >=4 && type == 0x4d38105a && 235 !(pci_read_config(scp->dev, 0x50, 2)&(scp->unit ? 1<<11 : 1<<10))) { 236 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, |
237 ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY); |
238 if (bootverbose) 239 printf("ata%d: %s: %s setting up UDMA4 mode on Promise chip\n", 240 scp->lun, (device == ATA_MASTER) ? "master" : "slave", 241 (error) ? "failed" : "success"); 242 if (error) 243 break; 244 outb(scp->bmaddr + 0x11, inl(scp->bmaddr + 0x11) | scp->unit ? 8:2); 245 pci_write_config(scp->dev, 0x60 + (devno << 2), 0x004127f3, 4); 246 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA4; 247 return 0; 248 } 249 if (udmamode >=2) { 250 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, |
251 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); |
252 if (bootverbose) 253 printf("ata%d: %s: %s setting up UDMA2 mode on Promise chip\n", 254 scp->lun, (device == ATA_MASTER) ? "master" : "slave", 255 (error) ? "failed" : "success"); 256 if (error) 257 break; 258 pci_write_config(scp->dev, 0x60 + (devno << 2), 0x004127f3, 4); 259 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA2; 260 return 0; 261 } 262 else if (wdmamode >= 2 && apiomode >= 4) { 263 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, |
264 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); |
265 if (bootverbose) 266 printf("ata%d: %s: %s setting up WDMA2 mode on Promise chip\n", 267 scp->lun, (device == ATA_MASTER) ? "master" : "slave", 268 (error) ? "failed" : "success"); 269 if (error) 270 break; 271 pci_write_config(scp->dev, 0x60 + (devno << 2), 0x004367f3, 4); 272 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_WDMA2; --- 11 unchanged lines hidden (view full) --- 284 /* punt on ATAPI devices for now */ 285 if ((device == ATA_MASTER && scp->devices & ATA_ATAPI_MASTER) || 286 (device == ATA_SLAVE && scp->devices & ATA_ATAPI_SLAVE)) 287 break; 288 289 devno = (device == ATA_MASTER) ? 0 : 1; 290 if (udmamode >=4 && !(pci_read_config(scp->dev, 0x5a, 1) & 0x2)) { 291 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, |
292 ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY); |
293 if (bootverbose) 294 printf("ata%d: %s: %s setting up UDMA4 mode on HPT366 chip\n", 295 scp->lun, (device == ATA_MASTER) ? "master" : "slave", 296 (error) ? "failed" : "success"); 297 if (error) 298 break; 299 hpt366_timing(scp, device, ATA_MODE_UDMA4); 300 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA4; 301 return 0; 302 } 303 if (udmamode >=3 && !(pci_read_config(scp->dev, 0x5a, 1) & 0x2)) { 304 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, |
305 ATA_UDMA3, ATA_C_F_SETXFER, ATA_WAIT_READY); |
306 if (bootverbose) 307 printf("ata%d: %s: %s setting up UDMA3 mode on HPT366 chip\n", 308 scp->lun, (device == ATA_MASTER) ? "master" : "slave", 309 (error) ? "failed" : "success"); 310 if (error) 311 break; 312 hpt366_timing(scp, device, ATA_MODE_UDMA3); 313 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA3; 314 return 0; 315 } 316 if (udmamode >=2) { 317 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, |
318 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); |
319 if (bootverbose) 320 printf("ata%d: %s: %s setting up UDMA2 mode on HPT366 chip\n", 321 scp->lun, (device == ATA_MASTER) ? "master" : "slave", 322 (error) ? "failed" : "success"); 323 if (error) 324 break; 325 hpt366_timing(scp, device, ATA_MODE_UDMA2); 326 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA2; 327 return 0; 328 } 329 else if (wdmamode >= 2 && apiomode >= 4) { 330 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, |
331 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); |
332 if (bootverbose) 333 printf("ata%d: %s: %s setting up WDMA2 mode on HPT366 chip\n", 334 scp->lun, (device == ATA_MASTER) ? "master" : "slave", 335 (error) ? "failed" : "success"); 336 if (error) 337 break; 338 hpt366_timing(scp, device, ATA_MODE_WDMA2); 339 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_WDMA2; --- 14 unchanged lines hidden (view full) --- 354 break; 355 356 /* well, we have no support for this, but try anyways */ 357 if (((wdmamode >= 2 && apiomode >= 4) || udmamode >= 2) && 358 (inb(scp->bmaddr + ATA_BMSTAT_PORT) & 359 ((device == ATA_MASTER) ? 360 ATA_BMSTAT_DMA_SLAVE : ATA_BMSTAT_DMA_MASTER))) { 361 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, |
362 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); |
363 if (bootverbose) 364 printf("ata%d: %s: %s setting up WDMA2 mode on generic chip\n", 365 scp->lun, (device == ATA_MASTER) ? "master" : "slave", 366 (error) ? "failed" : "success"); 367 if (error) 368 break; 369 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_WDMA2; 370 return 0; --- 171 unchanged lines hidden --- |