aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2007-11-05 17:53:38 -0500
committerJeff Garzik <jeff@garzik.org>2007-11-05 18:08:46 -0500
commit73946f9fc5be1433f1e182d11303188390ff242f (patch)
tree123206e2090057dc1725c57624da016c1f2f6b81 /drivers/ata
parent7f2803d0266844adacacbc3dea7822d5347ccb50 (diff)
pata_hpt37x: Fix outstanding bug reports on the HPT374 and 37x cable detect
- Read frequency correctly - Correct cable detect handling - Fix wrong filter test Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/pata_hpt37x.c49
1 files changed, 36 insertions, 13 deletions
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c
index e61cb1fd57b2..3816b8605e0d 100644
--- a/drivers/ata/pata_hpt37x.c
+++ b/drivers/ata/pata_hpt37x.c
@@ -295,7 +295,7 @@ static unsigned long hpt370_filter(struct ata_device *adev, unsigned long mask)
295 295
296static unsigned long hpt370a_filter(struct ata_device *adev, unsigned long mask) 296static unsigned long hpt370a_filter(struct ata_device *adev, unsigned long mask)
297{ 297{
298 if (adev->class != ATA_DEV_ATA) { 298 if (adev->class == ATA_DEV_ATA) {
299 if (hpt_dma_blacklisted(adev, "UDMA100", bad_ata100_5)) 299 if (hpt_dma_blacklisted(adev, "UDMA100", bad_ata100_5))
300 mask &= ~ (0x1F << ATA_SHIFT_UDMA); 300 mask &= ~ (0x1F << ATA_SHIFT_UDMA);
301 } 301 }
@@ -359,28 +359,25 @@ static int hpt374_pre_reset(struct ata_link *link, unsigned long deadline)
359 { 0x50, 1, 0x04, 0x04 }, 359 { 0x50, 1, 0x04, 0x04 },
360 { 0x54, 1, 0x04, 0x04 } 360 { 0x54, 1, 0x04, 0x04 }
361 }; 361 };
362 u16 mcr3, mcr6; 362 u16 mcr3;
363 u8 ata66; 363 u8 ata66;
364 struct ata_port *ap = link->ap; 364 struct ata_port *ap = link->ap;
365 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 365 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
366 unsigned int mcrbase = 0x50 + 4 * ap->port_no;
366 367
367 if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no])) 368 if (!pci_test_config_bits(pdev, &hpt37x_enable_bits[ap->port_no]))
368 return -ENOENT; 369 return -ENOENT;
369 370
370 /* Do the extra channel work */ 371 /* Do the extra channel work */
371 pci_read_config_word(pdev, 0x52, &mcr3); 372 pci_read_config_word(pdev, mcrbase + 2, &mcr3);
372 pci_read_config_word(pdev, 0x56, &mcr6);
373 /* Set bit 15 of 0x52 to enable TCBLID as input 373 /* Set bit 15 of 0x52 to enable TCBLID as input
374 Set bit 15 of 0x56 to enable FCBLID as input
375 */ 374 */
376 pci_write_config_word(pdev, 0x52, mcr3 | 0x8000); 375 pci_write_config_word(pdev, mcrbase + 2, mcr3 | 0x8000);
377 pci_write_config_word(pdev, 0x56, mcr6 | 0x8000);
378 pci_read_config_byte(pdev, 0x5A, &ata66); 376 pci_read_config_byte(pdev, 0x5A, &ata66);
379 /* Reset TCBLID/FCBLID to output */ 377 /* Reset TCBLID/FCBLID to output */
380 pci_write_config_word(pdev, 0x52, mcr3); 378 pci_write_config_word(pdev, 0x52, mcr3);
381 pci_write_config_word(pdev, 0x56, mcr6);
382 379
383 if (ata66 & (1 << ap->port_no)) 380 if (ata66 & (2 >> ap->port_no))
384 ap->cbl = ATA_CBL_PATA40; 381 ap->cbl = ATA_CBL_PATA40;
385 else 382 else
386 ap->cbl = ATA_CBL_PATA80; 383 ap->cbl = ATA_CBL_PATA80;
@@ -844,6 +841,25 @@ static int hpt37x_calibrate_dpll(struct pci_dev *dev)
844 /* Never went stable */ 841 /* Never went stable */
845 return 0; 842 return 0;
846} 843}
844
845static u32 hpt374_read_freq(struct pci_dev *pdev)
846{
847 u32 freq;
848 unsigned long io_base = pci_resource_start(pdev, 4);
849 if (PCI_FUNC(pdev->devfn) & 1) {
850 struct pci_dev *pdev_0 = pci_get_slot(pdev->bus, pdev->devfn - 1);
851 /* Someone hot plugged the controller on us ? */
852 if (pdev_0 == NULL)
853 return 0;
854 io_base = pci_resource_start(pdev_0, 4);
855 freq = inl(io_base + 0x90);
856 pci_dev_put(pdev_0);
857 }
858 else
859 freq = inl(io_base + 0x90);
860 return freq;
861}
862
847/** 863/**
848 * hpt37x_init_one - Initialise an HPT37X/302 864 * hpt37x_init_one - Initialise an HPT37X/302
849 * @dev: PCI device 865 * @dev: PCI device
@@ -902,7 +918,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
902 .flags = ATA_FLAG_SLAVE_POSS, 918 .flags = ATA_FLAG_SLAVE_POSS,
903 .pio_mask = 0x1f, 919 .pio_mask = 0x1f,
904 .mwdma_mask = 0x07, 920 .mwdma_mask = 0x07,
905 .udma_mask = 0x0f, 921 .udma_mask = ATA_UDMA5,
906 .port_ops = &hpt370_port_ops 922 .port_ops = &hpt370_port_ops
907 }; 923 };
908 /* HPT370A - UDMA100 */ 924 /* HPT370A - UDMA100 */
@@ -911,7 +927,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
911 .flags = ATA_FLAG_SLAVE_POSS, 927 .flags = ATA_FLAG_SLAVE_POSS,
912 .pio_mask = 0x1f, 928 .pio_mask = 0x1f,
913 .mwdma_mask = 0x07, 929 .mwdma_mask = 0x07,
914 .udma_mask = 0x0f, 930 .udma_mask = ATA_UDMA5,
915 .port_ops = &hpt370a_port_ops 931 .port_ops = &hpt370a_port_ops
916 }; 932 };
917 /* HPT371, 372 and friends - UDMA133 */ 933 /* HPT371, 372 and friends - UDMA133 */
@@ -1047,9 +1063,16 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1047 outb(0x0e, iobase + 0x9c); 1063 outb(0x0e, iobase + 0x9c);
1048 1064
1049 /* Some devices do not let this value be accessed via PCI space 1065 /* Some devices do not let this value be accessed via PCI space
1050 according to the old driver */ 1066 according to the old driver. In addition we must use the value
1067 from FN 0 on the HPT374 */
1068
1069 if (chip_table == &hpt374) {
1070 freq = hpt374_read_freq(dev);
1071 if (freq == 0)
1072 return -ENODEV;
1073 } else
1074 freq = inl(iobase + 0x90);
1051 1075
1052 freq = inl(iobase + 0x90);
1053 if ((freq >> 12) != 0xABCDE) { 1076 if ((freq >> 12) != 0xABCDE) {
1054 int i; 1077 int i;
1055 u8 sr; 1078 u8 sr;