ata-dma.c (53721) | ata-dma.c (54270) |
---|---|
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 * | 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 53721 1999-11-26 20:05:11Z sos $ | 28 * $FreeBSD: head/sys/dev/ata/ata-dma.c 54270 1999-12-07 22:07:18Z 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> 37#include <sys/bus.h> | 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> 37#include <sys/bus.h> |
38#include <sys/disk.h> 39#include <sys/devicestat.h> |
|
38#include <vm/vm.h> 39#include <vm/pmap.h> 40#if NPCI > 0 41#include <pci/pcivar.h> 42#endif 43#if NAPM > 0 44#include <machine/apm_bios.h> 45#endif 46#include <dev/ata/ata-all.h> | 40#include <vm/vm.h> 41#include <vm/pmap.h> 42#if NPCI > 0 43#include <pci/pcivar.h> 44#endif 45#if NAPM > 0 46#include <machine/apm_bios.h> 47#endif 48#include <dev/ata/ata-all.h> |
49#include <dev/ata/ata-disk.h> |
|
47 48/* prototypes */ 49static void hpt366_timing(struct ata_softc *, int32_t, int32_t); 50 51/* misc defines */ 52#define MIN(a,b) ((a)>(b)?(b):(a)) 53#ifdef __alpha__ 54#undef vtophys --- 165 unchanged lines hidden (view full) --- 220 scp->flags |= ATA_ATAPI_DMA_RO; 221 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_WDMA2; 222 return 0; 223 } 224 } 225 /* we could set PIO mode timings, but we assume the BIOS did that */ 226 break; 227 | 50 51/* prototypes */ 52static void hpt366_timing(struct ata_softc *, int32_t, int32_t); 53 54/* misc defines */ 55#define MIN(a,b) ((a)>(b)?(b):(a)) 56#ifdef __alpha__ 57#undef vtophys --- 165 unchanged lines hidden (view full) --- 223 scp->flags |= ATA_ATAPI_DMA_RO; 224 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_WDMA2; 225 return 0; 226 } 227 } 228 /* we could set PIO mode timings, but we assume the BIOS did that */ 229 break; 230 |
228 case 0x05711106: /* VIA Apollo 82c586 / 82c686 */ | 231 case 0x05711106: /* VIA Apollo 82c571 / 82c586 / 82c686 */ |
229 devno = (scp->unit << 1) + ((device == ATA_MASTER) ? 0 : 1); | 232 devno = (scp->unit << 1) + ((device == ATA_MASTER) ? 0 : 1); |
230 if (udmamode >= 2 && pci_read_config(scp->dev, 0x0d, 1) >= 0x20) { | 233 234 /* UDMA4 mode only on rev 6 (VT82C686) hardware */ 235 if (udmamode >= 4 && pci_read_config(scp->dev, 0x08, 1) == 0x06) { |
231 int8_t byte = pci_read_config(scp->dev, 0x53 - devno, 1); 232 233 /* enable UDMA transfer modes setting by SETFEATURES cmd */ 234 pci_write_config(scp->dev, 0x53 - devno, (byte & 0x1c) | 0x40, 1); | 236 int8_t byte = pci_read_config(scp->dev, 0x53 - devno, 1); 237 238 /* enable UDMA transfer modes setting by SETFEATURES cmd */ 239 pci_write_config(scp->dev, 0x53 - devno, (byte & 0x1c) | 0x40, 1); |
235 236 if (udmamode >= 4) { 237 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, | 240 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, |
238 ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY); | 241 ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY); |
239 if (bootverbose) 240 printf("ata%d: %s: %s setting up UDMA4 mode on VIA chip\n", 241 scp->lun, (device == ATA_MASTER) ? "master":"slave", 242 (error) ? "failed" : "success"); 243 if (!error) { 244 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA4; 245 return 0; 246 } | 242 if (bootverbose) 243 printf("ata%d: %s: %s setting up UDMA4 mode on VIA chip\n", 244 scp->lun, (device == ATA_MASTER) ? "master":"slave", 245 (error) ? "failed" : "success"); 246 if (!error) { 247 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA4; 248 return 0; |
247 } | 249 } |
250 pci_write_config(scp->dev, 0x53 - devno, byte, 1); 251 } 252 253 /* UDMA2 mode only on rev 1 and up (VT82C586, VT82C686) hardware */ 254 if (udmamode >= 2 && pci_read_config(scp->dev, 0x08, 1) >= 0x01) { 255 int8_t byte = pci_read_config(scp->dev, 0x53 - devno, 1); 256 257 /* enable UDMA transfer modes setting by SETFEATURES cmd */ 258 pci_write_config(scp->dev, 0x53 - devno, (byte & 0x1c) | 0x40, 1); |
|
248 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 249 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); 250 if (bootverbose) 251 printf("ata%d: %s: %s setting up UDMA2 mode on VIA chip\n", 252 scp->lun, (device == ATA_MASTER) ? "master" : "slave", 253 (error) ? "failed" : "success"); 254 if (!error) { | 259 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 260 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); 261 if (bootverbose) 262 printf("ata%d: %s: %s setting up UDMA2 mode on VIA chip\n", 263 scp->lun, (device == ATA_MASTER) ? "master" : "slave", 264 (error) ? "failed" : "success"); 265 if (!error) { |
266 if ((device == ATA_MASTER && scp->devices & ATA_ATA_MASTER) || 267 (device == ATA_SLAVE && scp->devices & ATA_ATA_SLAVE)) { 268 struct ata_params *ap = ((struct ad_softc *) 269 (scp->dev_softc[(device==ATA_MASTER)?0:1]))->ata_parm; 270 271 if ((pci_read_config(scp->dev, 0x08, 1) == 0x06) && 272 (ap->udmamodes & 0x10) && !ap->cblid) { 273 pci_write_config(scp->dev, 0x53 - devno, 274 (byte & 0x1c) | 0x42, 1); 275 } 276 } |
|
255 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA2; 256 return 0; 257 } 258 pci_write_config(scp->dev, 0x53 - devno, byte, 1); 259 } 260 if (wdmamode >= 2 && apiomode >= 4) { 261 /* set WDMA2 mode timing */ 262 pci_write_config(scp->dev, 0x4b - devno, 0x31 , 1); --- 62 unchanged lines hidden (view full) --- 325 } 326 } 327 if (bootverbose) 328 printf("ata%d: %s: setting PIO mode on Promise chip\n", 329 scp->lun, (device == ATA_MASTER) ? "master" : "slave"); 330 pci_write_config(scp->dev, 0x60 + (devno << 2), 0x004fe924, 4); 331 break; 332 | 277 scp->mode[(device == ATA_MASTER) ? 0 : 1] = ATA_MODE_UDMA2; 278 return 0; 279 } 280 pci_write_config(scp->dev, 0x53 - devno, byte, 1); 281 } 282 if (wdmamode >= 2 && apiomode >= 4) { 283 /* set WDMA2 mode timing */ 284 pci_write_config(scp->dev, 0x4b - devno, 0x31 , 1); --- 62 unchanged lines hidden (view full) --- 347 } 348 } 349 if (bootverbose) 350 printf("ata%d: %s: setting PIO mode on Promise chip\n", 351 scp->lun, (device == ATA_MASTER) ? "master" : "slave"); 352 pci_write_config(scp->dev, 0x60 + (devno << 2), 0x004fe924, 4); 353 break; 354 |
333 case 0x00041103: /* HighPoint HPT366 IDE controller */ | 355 case 0x00041103: /* HighPoint HPT366 controller */ |
334 /* no ATAPI devices for now */ 335 if ((device == ATA_MASTER && scp->devices & ATA_ATAPI_MASTER) || 336 (device == ATA_SLAVE && scp->devices & ATA_ATAPI_SLAVE)) 337 break; 338 339 devno = (device == ATA_MASTER) ? 0 : 1; 340 if (udmamode >=4 && !(pci_read_config(scp->dev, 0x5a, 1) & 0x2)) { 341 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, --- 248 unchanged lines hidden --- | 356 /* no ATAPI devices for now */ 357 if ((device == ATA_MASTER && scp->devices & ATA_ATAPI_MASTER) || 358 (device == ATA_SLAVE && scp->devices & ATA_ATAPI_SLAVE)) 359 break; 360 361 devno = (device == ATA_MASTER) ? 0 : 1; 362 if (udmamode >=4 && !(pci_read_config(scp->dev, 0x5a, 1) & 0x2)) { 363 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, --- 248 unchanged lines hidden --- |