|
|
| version 1.14, 2004/02/18 02:47:38 | version 1.15, 2004/02/18 04:08:49 |
|---|---|
| Line 138 ata_dmainit(struct ata_device *atadev, i | Line 138 ata_dmainit(struct ata_device *atadev, i |
| switch (chiptype) { | switch (chiptype) { |
| case 0x24db8086: /* Intel ICH5 */ | case 0x24db8086: /* Intel ICH5 */ |
| case 0x24d18086: /* Intel ICH5 SATA */ | |
| case 0x24ca8086: /* Intel ICH4 mobile */ | case 0x24ca8086: /* Intel ICH4 mobile */ |
| case 0x24cb8086: /* Intel ICH4 */ | case 0x24cb8086: /* Intel ICH4 */ |
| case 0x248a8086: /* Intel ICH3 mobile */ | case 0x248a8086: /* Intel ICH3 mobile */ |
| Line 318 ata_dmainit(struct ata_device *atadev, i | Line 319 ata_dmainit(struct ata_device *atadev, i |
| ata_prtdev(atadev, "two atapi devices on this channel, no DMA\n"); | ata_prtdev(atadev, "two atapi devices on this channel, no DMA\n"); |
| break; | break; |
| } | } |
| #if !defined(NO_ATANG) | |
| pci_write_config(parent, 0x58 + (channel << 2), 0x00310001, 4); | |
| #endif | |
| if (udmamode >= 5 && chiprev >= 0xc4) { | if (udmamode >= 5 && chiprev >= 0xc4) { |
| error = ata_command(atadev, ATA_C_SETFEATURES, 0, | error = ata_command(atadev, ATA_C_SETFEATURES, 0, |
| ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY); | ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY); |
| Line 398 ata_dmainit(struct ata_device *atadev, i | Line 402 ata_dmainit(struct ata_device *atadev, i |
| } | } |
| pci_write_config(parent, 0x53, | pci_write_config(parent, 0x53, |
| (pci_read_config(parent, 0x53, 1) & ~0x01) | 0x02, 1); | (pci_read_config(parent, 0x53, 1) & ~0x01) | 0x02, 1); |
| #if !defined(NO_ATANG) | |
| error = ata_command(atadev, ATA_C_SETFEATURES, 0, | |
| ATA_PIO0 + apiomode, | |
| ATA_C_F_SETXFER, ATA_WAIT_READY); | |
| if (bootverbose) | |
| ata_prtdev(atadev, "%s setting PIO%d on Acer chip\n", | |
| (error) ? "failed" : "success", | |
| (apiomode >= 0) ? apiomode : 0); | |
| if (!error) { | |
| int32_t word54 = pci_read_config(parent, 0x54, 4); | |
| int32_t timing; | |
| switch(ATA_PIO0 + apiomode) { | |
| case ATA_PIO0: timing = 0x006d0003; break; | |
| case ATA_PIO1: timing = 0x00580002; break; | |
| case ATA_PIO2: timing = 0x00440001; break; | |
| case ATA_PIO3: timing = 0x00330001; break; | |
| case ATA_PIO4: timing = 0x00310001; break; | |
| default: timing = 0x006d0003; break; | |
| } | |
| pci_write_config(parent, 0x58 + (channel << 2), timing, 4); | |
| word54 &= ~(0x000f000f << (devno << 2)); | |
| word54 |= (0x00000004 << (devno << 2)); | |
| pci_write_config(parent, 0x54, word54, 4); | |
| atadev->mode = ATA_PIO0 + apiomode; | |
| return; | |
| } | |
| #endif | |
| break; | |
| case 0x31491106: /* VIA 8237 SATA part */ | |
| if (udmamode) { | |
| error = ata_command(atadev, ATA_C_SETFEATURES, 0, | |
| ATA_UDMA + udmamode, | |
| ATA_C_F_SETXFER, ATA_WAIT_READY); | |
| if (bootverbose) | |
| ata_prtdev(atadev, "%s setting UDMA%d on VIA chip\n", | |
| (error) ? "failed" : "success", udmamode); | |
| if (!error) { | |
| ata_dmacreate(atadev, apiomode, ATA_UDMA + udmamode); | |
| return; | |
| } | |
| } | |
| /* we could set PIO mode timings, but we assume the BIOS did that */ | /* we could set PIO mode timings, but we assume the BIOS did that */ |
| break; | break; |
| case 0x01bc10de: /* NVIDIA nForce */ | case 0x01bc10de: /* NVIDIA nForce */ |
| case 0x006510de: /* NVIDIA nForce2 */ | case 0x006510de: /* NVIDIA nForce2 */ |
| case 0x74691022: /* AMD 8111 */ | |
| case 0x74411022: /* AMD 768 */ | case 0x74411022: /* AMD 768 */ |
| case 0x74111022: /* AMD 766 */ | case 0x74111022: /* AMD 766 */ |
| case 0x74091022: /* AMD 756 */ | case 0x74091022: /* AMD 756 */ |
| case 0x74691022: /* AMD 8111 */ | |
| case 0x05711106: /* VIA 82C571, 82C586, 82C596, 82C686, 8231,8233,8235 */ | case 0x05711106: /* VIA 82C571, 82C586, 82C596, 82C686, 8231,8233,8235 */ |
| { | { |
| int via_modes[5][7] = { | int via_modes[5][7] = { |
| { 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00 }, /* ATA33 */ | { 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00 }, /* VIA ATA33 */ |
| { 0x00, 0x00, 0xea, 0x00, 0xe8, 0x00, 0x00 }, /* ATA66 */ | { 0x00, 0x00, 0xea, 0x00, 0xe8, 0x00, 0x00 }, /* VIA ATA66 */ |
| { 0x00, 0x00, 0xf4, 0x00, 0xf1, 0xf0, 0x00 }, /* ATA100 */ | { 0x00, 0x00, 0xf4, 0x00, 0xf1, 0xf0, 0x00 }, /* VIA ATA100 */ |
| { 0x00, 0x00, 0xf6, 0x00, 0xf2, 0xf1, 0xf0 }, /* VIA ATA133 */ | { 0x00, 0x00, 0xf6, 0x00, 0xf2, 0xf1, 0xf0 }, /* VIA ATA133 */ |
| { 0x00, 0x00, 0xc0, 0x00, 0xc5, 0xc6, 0xc7 }}; /* AMD/NVIDIA */ | { 0x00, 0x00, 0xc0, 0x00, 0xc5, 0xc6, 0xc7 }}; /* AMD/NVIDIA */ |
| int *reg_val = NULL; | int *reg_val = NULL; |
| int reg_off = 0x53; | |
| char *chip = "VIA"; | char *chip = "VIA"; |
| if (ata_find_dev(parent, 0x31471106, 0) || /* 8233a */ | if (ata_find_dev(parent, 0x31471106, 0) || /* 8233a */ |
| ata_find_dev(parent, 0x31771106, 0)) { /* 8235 */ | ata_find_dev(parent, 0x31771106, 0) || /* 8235 */ |
| ata_find_dev(parent, 0x31491106, 0)) { /* 8237 */ | |
| udmamode = imin(udmamode, 6); | udmamode = imin(udmamode, 6); |
| reg_val = via_modes[3]; | reg_val = via_modes[3]; |
| } | } |
| Line 444 ata_dmainit(struct ata_device *atadev, i | Line 493 ata_dmainit(struct ata_device *atadev, i |
| udmamode = imin(udmamode, 2); | udmamode = imin(udmamode, 2); |
| reg_val = via_modes[0]; | reg_val = via_modes[0]; |
| } | } |
| else if (chiptype == 0x74411022 || /* AMD 768 */ | else if (chiptype == 0x74691022 || /* AMD 8111 */ |
| chiptype == 0x74411022 || /* AMD 768 */ | |
| chiptype == 0x74111022) { /* AMD 766 */ | chiptype == 0x74111022) { /* AMD 766 */ |
| udmamode = imin(udmamode, 5); | udmamode = imin(udmamode, 5); |
| reg_val = via_modes[4]; | reg_val = via_modes[4]; |
| chip = "AMD"; | chip = "AMD"; |
| } | } |
| else if (chiptype == 0x74691022) { /* AMD 8111 */ | |
| udmamode = imin(udmamode, 6); | |
| reg_val = via_modes[4]; | |
| chip = "AMD"; | |
| } | |
| else if (chiptype == 0x74091022) { /* AMD 756 */ | else if (chiptype == 0x74091022) { /* AMD 756 */ |
| udmamode = imin(udmamode, 4); | udmamode = imin(udmamode, 4); |
| reg_val = via_modes[4]; | reg_val = via_modes[4]; |
| Line 463 ata_dmainit(struct ata_device *atadev, i | Line 508 ata_dmainit(struct ata_device *atadev, i |
| else if (chiptype == 0x01bc10de) { /* nForce */ | else if (chiptype == 0x01bc10de) { /* nForce */ |
| udmamode = imin(udmamode, 5); | udmamode = imin(udmamode, 5); |
| reg_val = via_modes[4]; | reg_val = via_modes[4]; |
| chip = "NVIDIA"; | #if !defined(NO_ATANG) |
| reg_off += 0x10; | |
| #endif | |
| chip = "nVIDIA"; | |
| } | } |
| else if (chiptype == 0x006510de) { /* nForce2 */ | else if (chiptype == 0x006510de) { /* nForce2 */ |
| udmamode = imin(udmamode, 6); | udmamode = imin(udmamode, 6); |
| reg_val = via_modes[4]; | reg_val = via_modes[4]; |
| chip = "NVIDIA"; | #if !defined(NO_ATANG) |
| reg_off += 0x10; | |
| #endif | |
| chip = "nVIDIA"; | |
| } | } |
| else | else |
| udmamode = 0; | udmamode = 0; |
| Line 480 ata_dmainit(struct ata_device *atadev, i | Line 531 ata_dmainit(struct ata_device *atadev, i |
| ata_prtdev(atadev, "%s setting UDMA6 on %s chip\n", | ata_prtdev(atadev, "%s setting UDMA6 on %s chip\n", |
| (error) ? "failed" : "success", chip); | (error) ? "failed" : "success", chip); |
| if (!error) { | if (!error) { |
| pci_write_config(parent, 0x53 - devno, reg_val[6], 1); | pci_write_config(parent, reg_off - devno, reg_val[6], 1); |
| ata_dmacreate(atadev, apiomode, ATA_UDMA6); | ata_dmacreate(atadev, apiomode, ATA_UDMA6); |
| return; | return; |
| } | } |
| Line 492 ata_dmainit(struct ata_device *atadev, i | Line 543 ata_dmainit(struct ata_device *atadev, i |
| ata_prtdev(atadev, "%s setting UDMA5 on %s chip\n", | ata_prtdev(atadev, "%s setting UDMA5 on %s chip\n", |
| (error) ? "failed" : "success", chip); | (error) ? "failed" : "success", chip); |
| if (!error) { | if (!error) { |
| pci_write_config(parent, 0x53 - devno, reg_val[5], 1); | pci_write_config(parent, reg_off - devno, reg_val[5], 1); |
| ata_dmacreate(atadev, apiomode, ATA_UDMA5); | ata_dmacreate(atadev, apiomode, ATA_UDMA5); |
| return; | return; |
| } | } |
| Line 504 ata_dmainit(struct ata_device *atadev, i | Line 555 ata_dmainit(struct ata_device *atadev, i |
| ata_prtdev(atadev, "%s setting UDMA4 on %s chip\n", | ata_prtdev(atadev, "%s setting UDMA4 on %s chip\n", |
| (error) ? "failed" : "success", chip); | (error) ? "failed" : "success", chip); |
| if (!error) { | if (!error) { |
| pci_write_config(parent, 0x53 - devno, reg_val[4], 1); | pci_write_config(parent, reg_off - devno, reg_val[4], 1); |
| ata_dmacreate(atadev, apiomode, ATA_UDMA4); | ata_dmacreate(atadev, apiomode, ATA_UDMA4); |
| return; | return; |
| } | } |
| Line 516 ata_dmainit(struct ata_device *atadev, i | Line 567 ata_dmainit(struct ata_device *atadev, i |
| ata_prtdev(atadev, "%s setting UDMA2 on %s chip\n", | ata_prtdev(atadev, "%s setting UDMA2 on %s chip\n", |
| (error) ? "failed" : "success", chip); | (error) ? "failed" : "success", chip); |
| if (!error) { | if (!error) { |
| pci_write_config(parent, 0x53 - devno, reg_val[2], 1); | pci_write_config(parent, reg_off - devno, reg_val[2], 1); |
| ata_dmacreate(atadev, apiomode, ATA_UDMA2); | ata_dmacreate(atadev, apiomode, ATA_UDMA2); |
| return; | return; |
| } | } |
| Line 528 ata_dmainit(struct ata_device *atadev, i | Line 579 ata_dmainit(struct ata_device *atadev, i |
| ata_prtdev(atadev, "%s setting WDMA2 on %s chip\n", | ata_prtdev(atadev, "%s setting WDMA2 on %s chip\n", |
| (error) ? "failed" : "success", chip); | (error) ? "failed" : "success", chip); |
| if (!error) { | if (!error) { |
| pci_write_config(parent, 0x53 - devno, 0x0b, 1); | pci_write_config(parent, reg_off - devno, 0x0b, 1); |
| pci_write_config(parent, 0x4b - devno, 0x31, 1); | pci_write_config(parent, (reg_off - 8) - devno, 0x31, 1); |
| ata_dmacreate(atadev, apiomode, ATA_WDMA2); | ata_dmacreate(atadev, apiomode, ATA_WDMA2); |
| return; | return; |
| } | } |
| Line 669 ata_dmainit(struct ata_device *atadev, i | Line 720 ata_dmainit(struct ata_device *atadev, i |
| ata_prtdev(atadev, "%s setting UDMA6 on SiI chip\n", | ata_prtdev(atadev, "%s setting UDMA6 on SiI chip\n", |
| (error) ? "failed" : "success"); | (error) ? "failed" : "success"); |
| if (!error) { | if (!error) { |
| pci_write_config(parent, ureg, (uval & 0x3f) | 0x01, 1); | pci_write_config(parent, ureg, (uval & ~0x3f) | 0x01, 1); |
| ata_dmacreate(atadev, apiomode, ATA_UDMA6); | ata_dmacreate(atadev, apiomode, ATA_UDMA6); |
| return; | return; |
| } | } |
| Line 681 ata_dmainit(struct ata_device *atadev, i | Line 732 ata_dmainit(struct ata_device *atadev, i |
| ata_prtdev(atadev, "%s setting UDMA5 on SiI chip\n", | ata_prtdev(atadev, "%s setting UDMA5 on SiI chip\n", |
| (error) ? "failed" : "success"); | (error) ? "failed" : "success"); |
| if (!error) { | if (!error) { |
| pci_write_config(parent, ureg, (uval & 0x3f) | 0x02, 1); | pci_write_config(parent, ureg, (uval & ~0x3f) | 0x02, 1); |
| ata_dmacreate(atadev, apiomode, ATA_UDMA5); | ata_dmacreate(atadev, apiomode, ATA_UDMA5); |
| return; | return; |
| } | } |
| Line 693 ata_dmainit(struct ata_device *atadev, i | Line 744 ata_dmainit(struct ata_device *atadev, i |
| ata_prtdev(atadev, "%s setting UDMA4 on SiI chip\n", | ata_prtdev(atadev, "%s setting UDMA4 on SiI chip\n", |
| (error) ? "failed" : "success"); | (error) ? "failed" : "success"); |
| if (!error) { | if (!error) { |
| pci_write_config(parent, ureg, (uval & 0x3f) | 0x03, 1); | pci_write_config(parent, ureg, (uval & ~0x3f) | 0x03, 1); |
| ata_dmacreate(atadev, apiomode, ATA_UDMA4); | ata_dmacreate(atadev, apiomode, ATA_UDMA4); |
| return; | return; |
| } | } |
| Line 705 ata_dmainit(struct ata_device *atadev, i | Line 756 ata_dmainit(struct ata_device *atadev, i |
| ata_prtdev(atadev, "%s setting UDMA2 on SiI chip\n", | ata_prtdev(atadev, "%s setting UDMA2 on SiI chip\n", |
| (error) ? "failed" : "success"); | (error) ? "failed" : "success"); |
| if (!error) { | if (!error) { |
| pci_write_config(parent, ureg, (uval & 0x3f) | 0x07, 1); | pci_write_config(parent, ureg, (uval & ~0x3f) | 0x07, 1); |
| ata_dmacreate(atadev, apiomode, ATA_UDMA2); | ata_dmacreate(atadev, apiomode, ATA_UDMA2); |
| return; | return; |
| } | } |
| Line 733 ata_dmainit(struct ata_device *atadev, i | Line 784 ata_dmainit(struct ata_device *atadev, i |
| /* we could set PIO mode timings, but we assume the BIOS did that */ | /* we could set PIO mode timings, but we assume the BIOS did that */ |
| break; | break; |
| case 0x06491095: /* CMD 649 ATA100 controller */ | case 0x06491095: /* CMD 649 ATA100 controller */ |
| if (udmamode >= 5) { | if (udmamode >= 5) { |
| u_int8_t umode; | u_int8_t umode; |
| Line 792 ata_dmainit(struct ata_device *atadev, i | Line 842 ata_dmainit(struct ata_device *atadev, i |
| /* make sure eventual UDMA mode from the BIOS is disabled */ | /* make sure eventual UDMA mode from the BIOS is disabled */ |
| pci_write_config(parent, channel ? 0x7b : 0x73, | pci_write_config(parent, channel ? 0x7b : 0x73, |
| pci_read_config(parent, channel ? 0x7b : 0x73, 1)& | pci_read_config(parent, channel ? 0x7b : 0x73, 1)& |
| #if !defined(NO_ATANG) | |
| ~(device ? 0xca : 0x53), 1); | |
| #else | |
| ~(device ? 0xca : 0x35), 1); | ~(device ? 0xca : 0x35), 1); |
| #endif | |
| /* FALLTHROUGH */ | /* FALLTHROUGH */ |
| case 0x06461095: /* CMD 646 ATA controller */ | case 0x06461095: /* CMD 646 ATA controller */ |
| Line 867 ata_dmainit(struct ata_device *atadev, i | Line 921 ata_dmainit(struct ata_device *atadev, i |
| atadev->mode = ATA_PIO0 + apiomode; | atadev->mode = ATA_PIO0 + apiomode; |
| return; | return; |
| #if !defined(NO_ATANG) | |
| case 0x02131166: /* ServerWorks CSB6 ATA 100 controller (chan 0+1) */ | |
| #endif | |
| case 0x02121166: /* ServerWorks CSB5 ATA66/100 controller */ | case 0x02121166: /* ServerWorks CSB5 ATA66/100 controller */ |
| #if !defined(NO_ATANG) | |
| if (udmamode >= 5 && (chiptype == 0x02131166 || | |
| (chiptype == 0x02121166 && | |
| chiprev >= 0x92))) { | |
| #else | |
| if (udmamode >= 5 && chiprev >= 0x92) { | if (udmamode >= 5 && chiprev >= 0x92) { |
| #endif | |
| error = ata_command(atadev, ATA_C_SETFEATURES, 0, | error = ata_command(atadev, ATA_C_SETFEATURES, 0, |
| ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY); | ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY); |
| if (bootverbose) | if (bootverbose) |
| Line 888 ata_dmainit(struct ata_device *atadev, i | Line 951 ata_dmainit(struct ata_device *atadev, i |
| return; | return; |
| } | } |
| } | } |
| #if !defined(NO_ATANG) | |
| /* FALLTHROUGH */ | |
| case 0x02171166: /* Server Works CSB6 ATA 66 controller chan 2 */ | |
| #endif | |
| if (udmamode >= 4) { | if (udmamode >= 4) { |
| error = ata_command(atadev, ATA_C_SETFEATURES, 0, | error = ata_command(atadev, ATA_C_SETFEATURES, 0, |
| ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY); | ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY); |