Deleted Added
full compact
ata-dma.c (87198) ata-dma.c (87951)
1/*-
2 * Copyright (c) 1998,1999,2000,2001 S�ren Schmidt <sos@FreeBSD.org>
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 <sos@FreeBSD.org>
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 87198 2001-12-02 10:48:52Z sos $
28 * $FreeBSD: head/sys/dev/ata/ata-dma.c 87951 2001-12-14 21:28:49Z 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>

--- 245 unchanged lines hidden (view full) ---

282 scp->mode[ATA_DEV(device)] = ATA_WDMA2;
283 return;
284 }
285 }
286 break;
287
288 case 0x522910b9: /* AcerLabs Aladdin IV/V */
289 /* the older Aladdin doesn't support ATAPI DMA on both master & slave */
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>

--- 245 unchanged lines hidden (view full) ---

282 scp->mode[ATA_DEV(device)] = ATA_WDMA2;
283 return;
284 }
285 }
286 break;
287
288 case 0x522910b9: /* AcerLabs Aladdin IV/V */
289 /* the older Aladdin doesn't support ATAPI DMA on both master & slave */
290 if (pci_get_revid(parent) < 0xC2 &&
290 if (pci_get_revid(parent) < 0xc2 &&
291 scp->devices & ATA_ATAPI_MASTER && scp->devices & ATA_ATAPI_SLAVE) {
292 ata_printf(scp, device,
293 "Aladdin: two atapi devices on this channel, no DMA\n");
294 break;
295 }
291 scp->devices & ATA_ATAPI_MASTER && scp->devices & ATA_ATAPI_SLAVE) {
292 ata_printf(scp, device,
293 "Aladdin: two atapi devices on this channel, no DMA\n");
294 break;
295 }
296 if (udmamode >= 5 && pci_get_revid(parent) >= 0xC4) {
296 if (udmamode >= 5 && pci_get_revid(parent) >= 0xc4) {
297 error = ata_command(scp, device, ATA_C_SETFEATURES, 0,
298 ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY);
299 if (bootverbose)
300 ata_printf(scp, device,
301 "%s setting UDMA5 on Acer chip\n",
302 (error) ? "failed" : "success");
303 if (!error) {
304 int32_t word54 = pci_read_config(parent, 0x54, 4);

--- 4 unchanged lines hidden (view full) ---

309 word54 |= (0x000f0005 << (devno << 2));
310 pci_write_config(parent, 0x54, word54, 4);
311 pci_write_config(parent, 0x53,
312 pci_read_config(parent, 0x53, 1) | 0x03, 1);
313 scp->mode[ATA_DEV(device)] = ATA_UDMA5;
314 return;
315 }
316 }
297 error = ata_command(scp, device, ATA_C_SETFEATURES, 0,
298 ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY);
299 if (bootverbose)
300 ata_printf(scp, device,
301 "%s setting UDMA5 on Acer chip\n",
302 (error) ? "failed" : "success");
303 if (!error) {
304 int32_t word54 = pci_read_config(parent, 0x54, 4);

--- 4 unchanged lines hidden (view full) ---

309 word54 |= (0x000f0005 << (devno << 2));
310 pci_write_config(parent, 0x54, word54, 4);
311 pci_write_config(parent, 0x53,
312 pci_read_config(parent, 0x53, 1) | 0x03, 1);
313 scp->mode[ATA_DEV(device)] = ATA_UDMA5;
314 return;
315 }
316 }
317 if (udmamode >= 4 && pci_get_revid(parent) >= 0xC2) {
317 if (udmamode >= 4 && pci_get_revid(parent) >= 0xc2) {
318 error = ata_command(scp, device, ATA_C_SETFEATURES, 0,
319 ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY);
320 if (bootverbose)
321 ata_printf(scp, device,
322 "%s setting UDMA4 on Acer chip\n",
323 (error) ? "failed" : "success");
324 if (!error) {
325 int32_t word54 = pci_read_config(parent, 0x54, 4);

--- 193 unchanged lines hidden (view full) ---

519 }
520 /* we could set PIO mode timings, but we assume the BIOS did that */
521 break;
522
523 case 0x55131039: /* SiS 5591 */
524 if (ata_find_dev(parent, 0x06301039, 0x30) || /* SiS 630 */
525 ata_find_dev(parent, 0x06331039, 0x00) || /* SiS 633 */
526 ata_find_dev(parent, 0x06351039, 0x00) || /* SiS 635 */
318 error = ata_command(scp, device, ATA_C_SETFEATURES, 0,
319 ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY);
320 if (bootverbose)
321 ata_printf(scp, device,
322 "%s setting UDMA4 on Acer chip\n",
323 (error) ? "failed" : "success");
324 if (!error) {
325 int32_t word54 = pci_read_config(parent, 0x54, 4);

--- 193 unchanged lines hidden (view full) ---

519 }
520 /* we could set PIO mode timings, but we assume the BIOS did that */
521 break;
522
523 case 0x55131039: /* SiS 5591 */
524 if (ata_find_dev(parent, 0x06301039, 0x30) || /* SiS 630 */
525 ata_find_dev(parent, 0x06331039, 0x00) || /* SiS 633 */
526 ata_find_dev(parent, 0x06351039, 0x00) || /* SiS 635 */
527 ata_find_dev(parent, 0x06451039, 0x00) || /* SiS 635 */
527 ata_find_dev(parent, 0x07301039, 0x00) || /* SiS 730 */
528 ata_find_dev(parent, 0x07331039, 0x00) || /* SiS 733 */
529 ata_find_dev(parent, 0x07351039, 0x00)) { /* SiS 735 */
530 int8_t reg = 0x40 + (devno << 1);
528 ata_find_dev(parent, 0x07301039, 0x00) || /* SiS 730 */
529 ata_find_dev(parent, 0x07331039, 0x00) || /* SiS 733 */
530 ata_find_dev(parent, 0x07351039, 0x00)) { /* SiS 735 */
531 int8_t reg = 0x40 + (devno << 1);
531 int16_t val = pci_read_config(parent, reg, 2) & 0x00ff;
532 int16_t val = pci_read_config(parent, reg, 2) & 0x0fff;
532
533 if (udmamode >= 5) {
534 error = ata_command(scp, device, ATA_C_SETFEATURES, 0,
535 ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY);
536 if (bootverbose)
537 ata_printf(scp, device,
538 "%s setting UDMA5 on SiS chip\n",
539 (error) ? "failed" : "success");
540 if (!error) {
533
534 if (udmamode >= 5) {
535 error = ata_command(scp, device, ATA_C_SETFEATURES, 0,
536 ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY);
537 if (bootverbose)
538 ata_printf(scp, device,
539 "%s setting UDMA5 on SiS chip\n",
540 (error) ? "failed" : "success");
541 if (!error) {
541 pci_write_config(parent, reg, val | 0x8100, 2);
542 pci_write_config(parent, reg, val | 0x8000, 2);
542 scp->mode[ATA_DEV(device)] = ATA_UDMA5;
543 return;
544 }
545 }
546 if (udmamode >= 4) {
547 error = ata_command(scp, device, ATA_C_SETFEATURES, 0,
548 ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY);
549 if (bootverbose)
550 ata_printf(scp, device,
551 "%s setting UDMA4 on SiS chip\n",
552 (error) ? "failed" : "success");
553 if (!error) {
543 scp->mode[ATA_DEV(device)] = ATA_UDMA5;
544 return;
545 }
546 }
547 if (udmamode >= 4) {
548 error = ata_command(scp, device, ATA_C_SETFEATURES, 0,
549 ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY);
550 if (bootverbose)
551 ata_printf(scp, device,
552 "%s setting UDMA4 on SiS chip\n",
553 (error) ? "failed" : "success");
554 if (!error) {
554 pci_write_config(parent, reg, val | 0x8200, 2);
555 pci_write_config(parent, reg, val | 0x9000, 2);
555 scp->mode[ATA_DEV(device)] = ATA_UDMA4;
556 return;
557 }
558 }
559 if (udmamode >= 2) {
560 error = ata_command(scp, device, ATA_C_SETFEATURES, 0,
561 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
562 if (bootverbose)
563 ata_printf(scp, device,
564 "%s setting UDMA2 on SiS chip\n",
565 (error) ? "failed" : "success");
566 if (!error) {
556 scp->mode[ATA_DEV(device)] = ATA_UDMA4;
557 return;
558 }
559 }
560 if (udmamode >= 2) {
561 error = ata_command(scp, device, ATA_C_SETFEATURES, 0,
562 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
563 if (bootverbose)
564 ata_printf(scp, device,
565 "%s setting UDMA2 on SiS chip\n",
566 (error) ? "failed" : "success");
567 if (!error) {
567 pci_write_config(parent, reg, val | 0x8500, 2);
568 pci_write_config(parent, reg, val | 0xb000, 2);
568 scp->mode[ATA_DEV(device)] = ATA_UDMA2;
569 return;
570 }
571 }
572 } else if (ata_find_dev(parent, 0x05301039, 0) || /* SiS 530 */
573 ata_find_dev(parent, 0x05401039, 0) || /* SiS 540 */
574 ata_find_dev(parent, 0x06201039, 0) || /* SiS 620 */
575 ata_find_dev(parent, 0x06301039, 0)) { /* SiS 630 */

--- 16 unchanged lines hidden (view full) ---

592 if (udmamode >= 2) {
593 error = ata_command(scp, device, ATA_C_SETFEATURES, 0,
594 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
595 if (bootverbose)
596 ata_printf(scp, device,
597 "%s setting UDMA2 on SiS chip\n",
598 (error) ? "failed" : "success");
599 if (!error) {
569 scp->mode[ATA_DEV(device)] = ATA_UDMA2;
570 return;
571 }
572 }
573 } else if (ata_find_dev(parent, 0x05301039, 0) || /* SiS 530 */
574 ata_find_dev(parent, 0x05401039, 0) || /* SiS 540 */
575 ata_find_dev(parent, 0x06201039, 0) || /* SiS 620 */
576 ata_find_dev(parent, 0x06301039, 0)) { /* SiS 630 */

--- 16 unchanged lines hidden (view full) ---

593 if (udmamode >= 2) {
594 error = ata_command(scp, device, ATA_C_SETFEATURES, 0,
595 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
596 if (bootverbose)
597 ata_printf(scp, device,
598 "%s setting UDMA2 on SiS chip\n",
599 (error) ? "failed" : "success");
600 if (!error) {
600 pci_write_config(parent, reg, val | 0xb000, 2);
601 pci_write_config(parent, reg, val | 0xa000, 2);
601 scp->mode[ATA_DEV(device)] = ATA_UDMA2;
602 return;
603 }
604 }
605 } else { /* SiS 5591 */
606 if (udmamode >= 2 && pci_get_revid(parent) > 0xc1) {
607 error = ata_command(scp, device, ATA_C_SETFEATURES, 0,
608 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);

--- 682 unchanged lines hidden ---
602 scp->mode[ATA_DEV(device)] = ATA_UDMA2;
603 return;
604 }
605 }
606 } else { /* SiS 5591 */
607 if (udmamode >= 2 && pci_get_revid(parent) > 0xc1) {
608 error = ata_command(scp, device, ATA_C_SETFEATURES, 0,
609 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);

--- 682 unchanged lines hidden ---