aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/pata_hpt3x2n.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/pata_hpt3x2n.c')
-rw-r--r--drivers/ata/pata_hpt3x2n.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/drivers/ata/pata_hpt3x2n.c b/drivers/ata/pata_hpt3x2n.c
index 3d59fe0a408d..9a09a1b11ca5 100644
--- a/drivers/ata/pata_hpt3x2n.c
+++ b/drivers/ata/pata_hpt3x2n.c
@@ -25,7 +25,7 @@
25#include <linux/libata.h> 25#include <linux/libata.h>
26 26
27#define DRV_NAME "pata_hpt3x2n" 27#define DRV_NAME "pata_hpt3x2n"
28#define DRV_VERSION "0.3.4" 28#define DRV_VERSION "0.3.7"
29 29
30enum { 30enum {
31 HPT_PCI_FAST = (1 << 31), 31 HPT_PCI_FAST = (1 << 31),
@@ -80,14 +80,13 @@ static struct hpt_clock hpt3x2n_clocks[] = {
80 80
81 { XFER_MW_DMA_2, 0x2c829c62 }, 81 { XFER_MW_DMA_2, 0x2c829c62 },
82 { XFER_MW_DMA_1, 0x2c829c66 }, 82 { XFER_MW_DMA_1, 0x2c829c66 },
83 { XFER_MW_DMA_0, 0x2c829d2c }, 83 { XFER_MW_DMA_0, 0x2c829d2e },
84 84
85 { XFER_PIO_4, 0x0c829c62 }, 85 { XFER_PIO_4, 0x0c829c62 },
86 { XFER_PIO_3, 0x0c829c84 }, 86 { XFER_PIO_3, 0x0c829c84 },
87 { XFER_PIO_2, 0x0c829ca6 }, 87 { XFER_PIO_2, 0x0c829ca6 },
88 { XFER_PIO_1, 0x0d029d26 }, 88 { XFER_PIO_1, 0x0d029d26 },
89 { XFER_PIO_0, 0x0d029d5e }, 89 { XFER_PIO_0, 0x0d029d5e },
90 { 0, 0x0d029d5e }
91}; 90};
92 91
93/** 92/**
@@ -128,12 +127,15 @@ static int hpt3x2n_cable_detect(struct ata_port *ap)
128 127
129 pci_read_config_byte(pdev, 0x5B, &scr2); 128 pci_read_config_byte(pdev, 0x5B, &scr2);
130 pci_write_config_byte(pdev, 0x5B, scr2 & ~0x01); 129 pci_write_config_byte(pdev, 0x5B, scr2 & ~0x01);
130
131 udelay(10); /* debounce */
132
131 /* Cable register now active */ 133 /* Cable register now active */
132 pci_read_config_byte(pdev, 0x5A, &ata66); 134 pci_read_config_byte(pdev, 0x5A, &ata66);
133 /* Restore state */ 135 /* Restore state */
134 pci_write_config_byte(pdev, 0x5B, scr2); 136 pci_write_config_byte(pdev, 0x5B, scr2);
135 137
136 if (ata66 & (1 << ap->port_no)) 138 if (ata66 & (2 >> ap->port_no))
137 return ATA_CBL_PATA40; 139 return ATA_CBL_PATA40;
138 else 140 else
139 return ATA_CBL_PATA80; 141 return ATA_CBL_PATA80;
@@ -185,9 +187,8 @@ static void hpt3x2n_set_piomode(struct ata_port *ap, struct ata_device *adev)
185 187
186 pci_read_config_dword(pdev, addr1, &reg); 188 pci_read_config_dword(pdev, addr1, &reg);
187 mode = hpt3x2n_find_mode(ap, adev->pio_mode); 189 mode = hpt3x2n_find_mode(ap, adev->pio_mode);
188 mode &= ~0x8000000; /* No FIFO in PIO */ 190 mode &= 0xCFC3FFFF; /* Leave DMA bits alone */
189 mode &= ~0x30070000; /* Leave config bits alone */ 191 reg &= ~0xCFC3FFFF; /* Strip timing bits */
190 reg &= 0x30070000; /* Strip timing bits */
191 pci_write_config_dword(pdev, addr1, reg | mode); 192 pci_write_config_dword(pdev, addr1, reg | mode);
192} 193}
193 194
@@ -204,8 +205,7 @@ static void hpt3x2n_set_dmamode(struct ata_port *ap, struct ata_device *adev)
204{ 205{
205 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 206 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
206 u32 addr1, addr2; 207 u32 addr1, addr2;
207 u32 reg; 208 u32 reg, mode, mask;
208 u32 mode;
209 u8 fast; 209 u8 fast;
210 210
211 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no); 211 addr1 = 0x40 + 4 * (adev->devno + 2 * ap->port_no);
@@ -216,11 +216,12 @@ static void hpt3x2n_set_dmamode(struct ata_port *ap, struct ata_device *adev)
216 fast &= ~0x07; 216 fast &= ~0x07;
217 pci_write_config_byte(pdev, addr2, fast); 217 pci_write_config_byte(pdev, addr2, fast);
218 218
219 mask = adev->dma_mode < XFER_UDMA_0 ? 0x31C001FF : 0x303C0000;
220
219 pci_read_config_dword(pdev, addr1, &reg); 221 pci_read_config_dword(pdev, addr1, &reg);
220 mode = hpt3x2n_find_mode(ap, adev->dma_mode); 222 mode = hpt3x2n_find_mode(ap, adev->dma_mode);
221 mode |= 0x8000000; /* FIFO in MWDMA or UDMA */ 223 mode &= mask;
222 mode &= ~0xC0000000; /* Leave config bits alone */ 224 reg &= ~mask;
223 reg &= 0xC0000000; /* Strip timing bits */
224 pci_write_config_dword(pdev, addr1, reg | mode); 225 pci_write_config_dword(pdev, addr1, reg | mode);
225} 226}
226 227
@@ -447,10 +448,8 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
447 .port_ops = &hpt3x2n_port_ops 448 .port_ops = &hpt3x2n_port_ops
448 }; 449 };
449 const struct ata_port_info *ppi[] = { &info, NULL }; 450 const struct ata_port_info *ppi[] = { &info, NULL };
450 451 u8 rev = dev->revision;
451 u8 irqmask; 452 u8 irqmask;
452 u32 class_rev;
453
454 unsigned int pci_mhz; 453 unsigned int pci_mhz;
455 unsigned int f_low, f_high; 454 unsigned int f_low, f_high;
456 int adjust; 455 int adjust;
@@ -462,26 +461,23 @@ static int hpt3x2n_init_one(struct pci_dev *dev, const struct pci_device_id *id)
462 if (rc) 461 if (rc)
463 return rc; 462 return rc;
464 463
465 pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
466 class_rev &= 0xFF;
467
468 switch(dev->device) { 464 switch(dev->device) {
469 case PCI_DEVICE_ID_TTI_HPT366: 465 case PCI_DEVICE_ID_TTI_HPT366:
470 if (class_rev < 6) 466 if (rev < 6)
471 return -ENODEV; 467 return -ENODEV;
472 break; 468 break;
473 case PCI_DEVICE_ID_TTI_HPT371: 469 case PCI_DEVICE_ID_TTI_HPT371:
474 if (class_rev < 2) 470 if (rev < 2)
475 return -ENODEV; 471 return -ENODEV;
476 /* 371N if rev > 1 */ 472 /* 371N if rev > 1 */
477 break; 473 break;
478 case PCI_DEVICE_ID_TTI_HPT372: 474 case PCI_DEVICE_ID_TTI_HPT372:
479 /* 372N if rev >= 2*/ 475 /* 372N if rev >= 2*/
480 if (class_rev < 2) 476 if (rev < 2)
481 return -ENODEV; 477 return -ENODEV;
482 break; 478 break;
483 case PCI_DEVICE_ID_TTI_HPT302: 479 case PCI_DEVICE_ID_TTI_HPT302:
484 if (class_rev < 2) 480 if (rev < 2)
485 return -ENODEV; 481 return -ENODEV;
486 break; 482 break;
487 case PCI_DEVICE_ID_TTI_HPT372N: 483 case PCI_DEVICE_ID_TTI_HPT372N: