Deleted Added
full compact
ata-dma.c (100380) ata-dma.c (103255)
1/*-
2 * Copyright (c) 1998,1999,2000,2001,2002 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,2002 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 100380 2002-07-19 22:14:54Z jhb $
28 * $FreeBSD: head/sys/dev/ata/ata-dma.c 103255 2002-09-12 15:25:59Z sos $
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/ata.h>
34#include <sys/bio.h>
35#include <sys/endian.h>
36#include <sys/malloc.h>

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

733 pci_write_config(parent, 0x40 + (devno << 1), 0x0301, 2);
734 ata_dmacreate(atadev, apiomode, ATA_WDMA2);
735 return;
736 }
737 }
738 /* we could set PIO mode timings, but we assume the BIOS did that */
739 break;
740
29 */
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/ata.h>
34#include <sys/bio.h>
35#include <sys/endian.h>
36#include <sys/malloc.h>

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

733 pci_write_config(parent, 0x40 + (devno << 1), 0x0301, 2);
734 ata_dmacreate(atadev, apiomode, ATA_WDMA2);
735 return;
736 }
737 }
738 /* we could set PIO mode timings, but we assume the BIOS did that */
739 break;
740
741 case 0x06801095: /* Sil 0680 ATA133 controller */
742 {
743 u_int8_t ureg = 0xac + (device * 0x02) + (channel * 0x10);
744 u_int8_t uval = pci_read_config(parent, ureg, 1);
745 u_int8_t mreg = channel ? 0x84 : 0x80;
746 u_int8_t mask = device ? 0x30 : 0x03;
747 u_int8_t mode = pci_read_config(parent, mreg, 1);
748
749 /* enable UDMA mode */
750 pci_write_config(parent, mreg,
751 (mode & ~mask) | (device ? 0x30 : 0x03), 1);
752 if (udmamode >= 6) {
753 error = ata_command(atadev, ATA_C_SETFEATURES, 0,
754 ATA_UDMA6, ATA_C_F_SETXFER, ATA_WAIT_READY);
755 if (bootverbose)
756 ata_prtdev(atadev, "%s setting UDMA6 on Sil chip\n",
757 (error) ? "failed" : "success");
758 if (!error) {
759 pci_write_config(parent, ureg, (uval & 0x3f) | 0x01, 1);
760 ata_dmacreate(atadev, apiomode, ATA_UDMA6);
761 return;
762 }
763 }
764 if (udmamode >= 5) {
765 error = ata_command(atadev, ATA_C_SETFEATURES, 0,
766 ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY);
767 if (bootverbose)
768 ata_prtdev(atadev, "%s setting UDMA5 on Sil chip\n",
769 (error) ? "failed" : "success");
770 if (!error) {
771 pci_write_config(parent, ureg, (uval & 0x3f) | 0x02, 1);
772 ata_dmacreate(atadev, apiomode, ATA_UDMA5);
773 return;
774 }
775 }
776 if (udmamode >= 4) {
777 error = ata_command(atadev, ATA_C_SETFEATURES, 0,
778 ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY);
779 if (bootverbose)
780 ata_prtdev(atadev, "%s setting UDMA4 on Sil chip\n",
781 (error) ? "failed" : "success");
782 if (!error) {
783 pci_write_config(parent, ureg, (uval & 0x3f) | 0x03, 1);
784 ata_dmacreate(atadev, apiomode, ATA_UDMA4);
785 return;
786 }
787 }
788 if (udmamode >= 2) {
789 error = ata_command(atadev, ATA_C_SETFEATURES, 0,
790 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
791 if (bootverbose)
792 ata_prtdev(atadev, "%s setting UDMA2 on Sil chip\n",
793 (error) ? "failed" : "success");
794 if (!error) {
795 pci_write_config(parent, ureg, (uval & 0x3f) | 0x07, 1);
796 ata_dmacreate(atadev, apiomode, ATA_UDMA2);
797 return;
798 }
799 }
800
801 /* disable UDMA mode and enable WDMA mode */
802 pci_write_config(parent, mreg,
803 (mode & ~mask) | (device ? 0x20 : 0x02), 1);
804 if (wdmamode >= 2 && apiomode >= 4) {
805 error = ata_command(atadev, ATA_C_SETFEATURES, 0,
806 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY);
807 if (bootverbose)
808 ata_prtdev(atadev, "%s setting WDMA2 on Sil chip\n",
809 (error) ? "failed" : "success");
810 if (!error) {
811 pci_write_config(parent, ureg - 0x4, 0x10c1, 2);
812 ata_dmacreate(atadev, apiomode, ATA_WDMA2);
813 return;
814 }
815 }
816
817 /* restore PIO mode */
818 pci_write_config(parent, mreg, mode, 1);
819 }
820 /* we could set PIO mode timings, but we assume the BIOS did that */
821 break;
822
741 case 0x06491095: /* CMD 649 ATA100 controller */
742 if (udmamode >= 5) {
743 u_int8_t umode;
744
745 error = ata_command(atadev, ATA_C_SETFEATURES, 0,
746 ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY);
747 if (bootverbose)
748 ata_prtdev(atadev, "%s setting UDMA5 on CMD chip\n",

--- 796 unchanged lines hidden ---
823 case 0x06491095: /* CMD 649 ATA100 controller */
824 if (udmamode >= 5) {
825 u_int8_t umode;
826
827 error = ata_command(atadev, ATA_C_SETFEATURES, 0,
828 ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY);
829 if (bootverbose)
830 ata_prtdev(atadev, "%s setting UDMA5 on CMD chip\n",

--- 796 unchanged lines hidden ---