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 82053 2001-08-21 11:35:47Z 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> --- 12 unchanged lines hidden (view full) --- 49static void promise_timing(struct ata_softc *, int, int); 50static void hpt_timing(struct ata_softc *, int, int); 51 52/* misc defines */ 53#ifdef __alpha__ 54#undef vtophys 55#define vtophys(va) alpha_XXX_dmamap((vm_offset_t)va) 56#endif |
57#define ATAPI_DEVICE(scp, device) \ 58 ((device == ATA_MASTER && scp->devices & ATA_ATAPI_MASTER) || \ 59 (device == ATA_SLAVE && scp->devices & ATA_ATAPI_SLAVE)) |
60 |
61 |
62void * 63ata_dmaalloc(struct ata_softc *scp, int device) 64{ 65 void *dmatab; 66 67 if ((dmatab = malloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT))) { 68 if (((uintptr_t)dmatab >> PAGE_SHIFT) ^ 69 (((uintptr_t)dmatab + PAGE_SIZE - 1) >> PAGE_SHIFT)) { --- 647 unchanged lines hidden (view full) --- 717 pci_write_config(parent, 0x44, 0x20, 4); 718 scp->mode[ATA_DEV(device)] = ATA_WDMA2; 719 return; 720 } 721 } 722 /* we could set PIO mode timings, but we assume the BIOS did that */ 723 break; 724 |
725 case 0x4d30105a: /* Promise Ultra/FastTrak 100 controllers */ 726 case 0x0d30105a: /* Promise OEM ATA100 controllers */ 727 case 0x4d68105a: /* Promise TX2 ATA100 controllers */ |
728 case 0x6268105a: /* Promise TX2v2 ATA100 controllers */ 729 if (!ATAPI_DEVICE(scp, device) && udmamode >= 5 && |
730 !(pci_read_config(parent, 0x50, 2)&(scp->channel ? 1<<11 : 1<<10))){ 731 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 732 ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY); 733 if (bootverbose) 734 ata_printf(scp, device, 735 "%s setting UDMA5 on Promise chip\n", 736 (error) ? "failed" : "success"); 737 if (!error) { 738 promise_timing(scp, devno, ATA_UDMA5); 739 scp->mode[ATA_DEV(device)] = ATA_UDMA5; 740 return; 741 } 742 } |
743 /* FALLTHROUGH */ 744 745 case 0x4d38105a: /* Promise Ultra/FastTrak 66 controllers */ 746 if (!ATAPI_DEVICE(scp, device) && udmamode >= 4 && |
747 !(pci_read_config(parent, 0x50, 2)&(scp->channel ? 1<<11 : 1<<10))){ 748 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 749 ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY); 750 if (bootverbose) 751 ata_printf(scp, device, 752 "%s setting UDMA4 on Promise chip\n", 753 (error) ? "failed" : "success"); 754 if (!error) { 755 promise_timing(scp, devno, ATA_UDMA4); 756 scp->mode[ATA_DEV(device)] = ATA_UDMA4; 757 return; 758 } 759 } |
760 /* FALLTHROUGH */ 761 762 case 0x4d33105a: /* Promise Ultra/FastTrak 33 controllers */ 763 if (!ATAPI_DEVICE(scp, device) && udmamode >= 2) { |
764 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 765 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); 766 if (bootverbose) 767 ata_printf(scp, device, 768 "%s setting UDMA2 on Promise chip\n", 769 (error) ? "failed" : "success"); 770 if (!error) { 771 promise_timing(scp, devno, ATA_UDMA2); 772 scp->mode[ATA_DEV(device)] = ATA_UDMA2; 773 return; 774 } 775 } |
776 if (!ATAPI_DEVICE(scp, device) && wdmamode >= 2 && apiomode >= 4) { |
777 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 778 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); 779 if (bootverbose) 780 ata_printf(scp, device, 781 "%s setting WDMA2 on Promise chip\n", 782 (error) ? "failed" : "success"); 783 if (!error) { 784 promise_timing(scp, devno, ATA_WDMA2); --- 9 unchanged lines hidden (view full) --- 794 "%s setting PIO%d on Promise chip\n", 795 (error) ? "failed" : "success", 796 (apiomode >= 0) ? apiomode : 0); 797 promise_timing(scp, devno, ata_pio2mode(apiomode)); 798 scp->mode[ATA_DEV(device)] = ata_pio2mode(apiomode); 799 return; 800 801 case 0x00041103: /* HighPoint HPT366/368/370 controllers */ |
802 if (!ATAPI_DEVICE(scp, device) && 803 udmamode >=5 && pci_get_revid(parent) >= 0x03 && |
804 !(pci_read_config(parent, 0x5a, 1) & (scp->channel ? 0x01:0x02))) { 805 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 806 ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY); 807 if (bootverbose) 808 ata_printf(scp, device, 809 "%s setting UDMA5 on HighPoint chip\n", 810 (error) ? "failed" : "success"); 811 if (!error) { 812 hpt_timing(scp, devno, ATA_UDMA5); 813 scp->mode[ATA_DEV(device)] = ATA_UDMA5; 814 return; 815 } 816 } |
817 if (!ATAPI_DEVICE(scp, device) && udmamode >=4 && |
818 !(pci_read_config(parent, 0x5a, 1) & (scp->channel ? 0x01:0x02))) { 819 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 820 ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY); 821 if (bootverbose) 822 ata_printf(scp, device, 823 "%s setting UDMA4 on HighPoint chip\n", 824 (error) ? "failed" : "success"); 825 if (!error) { 826 hpt_timing(scp, devno, ATA_UDMA4); 827 scp->mode[ATA_DEV(device)] = ATA_UDMA4; 828 return; 829 } 830 } |
831 if (!ATAPI_DEVICE(scp, device) && udmamode >= 2) { |
832 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 833 ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); 834 if (bootverbose) 835 ata_printf(scp, device, 836 "%s setting UDMA2 on HighPoint chip\n", 837 (error) ? "failed" : "success"); 838 if (!error) { 839 hpt_timing(scp, devno, ATA_UDMA2); 840 scp->mode[ATA_DEV(device)] = ATA_UDMA2; 841 return; 842 } 843 } |
844 if (!ATAPI_DEVICE(scp, device) && wdmamode >= 2 && apiomode >= 4) { |
845 error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, 846 ATA_WDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); 847 if (bootverbose) 848 ata_printf(scp, device, 849 "%s setting WDMA2 on HighPoint chip\n", 850 (error) ? "failed" : "success"); 851 if (!error) { 852 hpt_timing(scp, devno, ATA_WDMA2); --- 187 unchanged lines hidden (view full) --- 1040 case ATA_UDMA2: t->pa = 3; t->pb = 7; t->mb = 1; t->mc = 1; break; 1041 } 1042 break; 1043 1044 case 0x4d38105a: /* Promise Ultra/Fasttrak 66 */ 1045 case 0x4d30105a: /* Promise Ultra/Fasttrak 100 */ 1046 case 0x0d30105a: /* Promise OEM ATA 100 */ 1047 case 0x4d68105a: /* Promise TX2 ATA 100 */ |
1048 case 0x6268105a: /* Promise TX2v2 ATA 100 */ |
1049 switch (mode) { 1050 default: 1051 case ATA_PIO0: t->pa = 15; t->pb = 31; t->mb = 7; t->mc = 15; break; 1052 case ATA_PIO1: t->pa = 10; t->pb = 24; t->mb = 7; t->mc = 15; break; 1053 case ATA_PIO2: t->pa = 6; t->pb = 16; t->mb = 7; t->mc = 15; break; 1054 case ATA_PIO3: t->pa = 4; t->pb = 12; t->mb = 7; t->mc = 15; break; 1055 case ATA_PIO4: t->pa = 2; t->pb = 8; t->mb = 7; t->mc = 15; break; 1056 case ATA_WDMA2: t->pa = 6; t->pb = 14; t->mb = 6; t->mc = 6; break; --- 76 unchanged lines hidden --- |