atiixp.c: add cable detection support for ATI IDE
authorConke Hu <conke.hu@amd.com>
Sat, 27 Jan 2007 12:46:40 +0000 (13:46 +0100)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Sat, 27 Jan 2007 12:46:40 +0000 (13:46 +0100)
IDE HDD does not work if it uses a 40-pin PATA cable on ATI chipset.
This patch fixes the bug.

Signed-off-by: Conke Hu <conke.hu@amd.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
drivers/ide/pci/atiixp.c

index 5b7e000..7e1d070 100644 (file)
@@ -291,8 +291,12 @@ fast_ata_pio:
 
 static void __devinit init_hwif_atiixp(ide_hwif_t *hwif)
 {
+       u8 udma_mode = 0;
+       u8 ch = hwif->channel;
+       struct pci_dev *pdev = hwif->pci_dev;
+
        if (!hwif->irq)
-               hwif->irq = hwif->channel ? 15 : 14;
+               hwif->irq = ch ? 15 : 14;
 
        hwif->autodma = 0;
        hwif->tuneproc = &atiixp_tuneproc;
@@ -308,8 +312,12 @@ static void __devinit init_hwif_atiixp(ide_hwif_t *hwif)
        hwif->mwdma_mask = 0x06;
        hwif->swdma_mask = 0x04;
 
-       /* FIXME: proper cable detection needed */
-       hwif->udma_four = 1;
+       pci_read_config_byte(pdev, ATIIXP_IDE_UDMA_MODE + ch, &udma_mode);
+       if ((udma_mode & 0x07) >= 0x04 || (udma_mode & 0x70) >= 0x40)
+               hwif->udma_four = 1;
+       else
+               hwif->udma_four = 0;
+
        hwif->ide_dma_host_on = &atiixp_ide_dma_host_on;
        hwif->ide_dma_host_off = &atiixp_ide_dma_host_off;
        hwif->ide_dma_check = &atiixp_dma_check;