]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ide: add short cables support
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Mon, 9 Jul 2007 21:17:58 +0000 (23:17 +0200)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Mon, 9 Jul 2007 21:17:58 +0000 (23:17 +0200)
This patch allows users to override both host and device side cable detection
with "ideX=ata66" kernel parameter.  Thanks to this it should be now possible
to use UDMA > 2 modes on systems (laptops mainly) which use short 40-pin cable
instead of 80-pin one.

Next patches add automatic detection of some systems using short cables.

Changes:

* Rename hwif->udma_four to hwif->cbl and make it u8.

* Convert all existing users accordingly (use ATA_CBL_* defines while at it).

* Add ATA_CBL_PATA40_SHORT support to ide-iops.c:eighty_ninty_three().

* Use ATA_CBL_PATA40_SHORT for "ideX=ata66" kernel parameter.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Reviewed-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
25 files changed:
drivers/ide/cris/ide-cris.c
drivers/ide/ide-iops.c
drivers/ide/ide.c
drivers/ide/pci/aec62xx.c
drivers/ide/pci/alim15x3.c
drivers/ide/pci/amd74xx.c
drivers/ide/pci/atiixp.c
drivers/ide/pci/cmd64x.c
drivers/ide/pci/cs5535.c
drivers/ide/pci/hpt366.c
drivers/ide/pci/it8213.c
drivers/ide/pci/it821x.c
drivers/ide/pci/jmicron.c
drivers/ide/pci/pdc202xx_new.c
drivers/ide/pci/pdc202xx_old.c
drivers/ide/pci/piix.c
drivers/ide/pci/scc_pata.c
drivers/ide/pci/serverworks.c
drivers/ide/pci/siimage.c
drivers/ide/pci/sis5513.c
drivers/ide/pci/slc90e66.c
drivers/ide/pci/tc86c001.c
drivers/ide/pci/via82cxxx.c
drivers/ide/ppc/pmac.c
include/linux/ide.h

index ca0341c05e556bf8828cc32349c7cfc07da29ebd..886091bc7db01e1028804b136a635f53f7c6cc3f 100644 (file)
@@ -819,7 +819,7 @@ init_e100_ide (void)
                hwif->dma_host_off = &cris_dma_off;
                hwif->dma_host_on = &cris_dma_on;
                hwif->dma_off_quietly = &cris_dma_off;
-               hwif->udma_four = 0;
+               hwif->cbl = ATA_CBL_PATA40;
                hwif->ultra_mask = cris_ultra_mask;
                hwif->mwdma_mask = 0x07; /* Multiword DMA 0-2 */
                hwif->autodma = 1;
index f0be5f665a0e0ae21af516609c0a82c556b4e0cd..92578b6832e9fbb2e31dd0287f1664ae979ab082 100644 (file)
@@ -574,7 +574,10 @@ u8 eighty_ninty_three (ide_drive_t *drive)
        ide_hwif_t *hwif = drive->hwif;
        struct hd_driveid *id = drive->id;
 
-       if (hwif->udma_four == 0)
+       if (hwif->cbl == ATA_CBL_PATA40_SHORT)
+               return 1;
+
+       if (hwif->cbl != ATA_CBL_PATA80)
                goto no_80w;
 
        /* Check for SATA but only if we are ATA5 or higher */
@@ -600,7 +603,8 @@ no_80w:
 
        printk(KERN_WARNING "%s: %s side 80-wire cable detection failed, "
                            "limiting max speed to UDMA33\n",
-                           drive->name, hwif->udma_four ? "drive" : "host");
+                           drive->name,
+                           hwif->cbl == ATA_CBL_PATA80 ? "drive" : "host");
 
        drive->udma33_warned = 1;
 
index 5744146892530498690b6428956e649cf628732a..c948a5c17a5d8c1e1cb5afe9682afa1f51e95442 100644 (file)
@@ -460,6 +460,8 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
        hwif->mwdma_mask                = tmp_hwif->mwdma_mask;
        hwif->swdma_mask                = tmp_hwif->swdma_mask;
 
+       hwif->cbl                       = tmp_hwif->cbl;
+
        hwif->chipset                   = tmp_hwif->chipset;
        hwif->hold                      = tmp_hwif->hold;
 
@@ -533,7 +535,6 @@ static void ide_hwif_restore(ide_hwif_t *hwif, ide_hwif_t *tmp_hwif)
        hwif->extra_base                = tmp_hwif->extra_base;
        hwif->extra_ports               = tmp_hwif->extra_ports;
        hwif->autodma                   = tmp_hwif->autodma;
-       hwif->udma_four                 = tmp_hwif->udma_four;
 
        hwif->hwif_data                 = tmp_hwif->hwif_data;
 }
@@ -1548,7 +1549,11 @@ static int __init ide_setup(char *s)
                                goto bad_option;
                        case -7: /* ata66 */
 #ifdef CONFIG_BLK_DEV_IDEPCI
-                               hwif->udma_four = 1;
+                               /*
+                                * Use ATA_CBL_PATA40_SHORT so drive side
+                                * cable detection is also overriden.
+                                */
+                               hwif->cbl = ATA_CBL_PATA40_SHORT;
                                goto obsolete_option;
 #else
                                goto bad_hwif;
index 794ac40ec90f11c059c9a6fb5dfe6bffddebc591..e5d09367627ee19e99217af29dd2bae68fc50286 100644 (file)
@@ -234,11 +234,12 @@ static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif)
                pci_read_config_byte (dev, 0x54, &reg54);
                pci_write_config_byte(dev, 0x54, (reg54 & ~mask));
                spin_unlock_irqrestore(&ide_lock, flags);
-       } else if (!hwif->udma_four) {
+       } else if (hwif->cbl != ATA_CBL_PATA40_SHORT) {
                u8 ata66 = 0, mask = hwif->channel ? 0x02 : 0x01;
 
                pci_read_config_byte(hwif->pci_dev, 0x49, &ata66);
-               hwif->udma_four = (ata66 & mask) ? 0 : 1;
+
+               hwif->cbl = (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
        }
 
        if (!noautodma)
index 27525ec2e19a68a566a2c53bfba05d4c4263117d..d52c54bb6a78b360c1cd5816e46e99146b63576a 100644 (file)
@@ -594,7 +594,7 @@ out:
  *     FIXME: frobs bits that are not defined on newer ALi devicea
  */
 
-static unsigned int __devinit ata66_ali15x3 (ide_hwif_t *hwif)
+static u8 __devinit ata66_ali15x3(ide_hwif_t *hwif)
 {
        struct pci_dev *dev     = hwif->pci_dev;
        unsigned int ata66      = 0;
@@ -657,7 +657,7 @@ static unsigned int __devinit ata66_ali15x3 (ide_hwif_t *hwif)
 
        local_irq_restore(flags);
 
-       return(ata66);
+       return ata66 ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
 }
 
 /**
@@ -708,8 +708,9 @@ static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif)
                hwif->dma_setup = &ali15x3_dma_setup;
                if (!noautodma)
                        hwif->autodma = 1;
-               if (!(hwif->udma_four))
-                       hwif->udma_four = ata66_ali15x3(hwif);
+
+               if (hwif->cbl != ATA_CBL_PATA40_SHORT)
+                       hwif->cbl = ata66_ali15x3(hwif);
        }
        hwif->drives[0].autodma = hwif->autodma;
        hwif->drives[1].autodma = hwif->autodma;
index a7443f15b27aa7828da9d940bb097adc11bb88c1..84ed30cdb324de5d4928700807f8db1198140228 100644 (file)
@@ -431,8 +431,13 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif)
        if ((amd_config->flags & AMD_BAD_SWDMA) == 0)
                hwif->swdma_mask = 0x07;
 
-       if (!hwif->udma_four)
-               hwif->udma_four = (amd_80w >> hwif->channel) & 1;
+       if (hwif->cbl != ATA_CBL_PATA40_SHORT) {
+               if ((amd_80w >> hwif->channel) & 1)
+                       hwif->cbl = ATA_CBL_PATA80;
+               else
+                       hwif->cbl = ATA_CBL_PATA40;
+       }
+
         hwif->ide_dma_check = &amd74xx_ide_dma_check;
         if (!noautodma)
                 hwif->autodma = 1;
index 8ab33faf6f76776d860d1b2db3ce72834937f369..2761510309b381a17de6dd8078262d104191de33 100644 (file)
@@ -264,10 +264,11 @@ static void __devinit init_hwif_atiixp(ide_hwif_t *hwif)
        hwif->swdma_mask = 0x04;
 
        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;
+               hwif->cbl = ATA_CBL_PATA80;
        else
-               hwif->udma_four = 0;
+               hwif->cbl = ATA_CBL_PATA40;
 
        hwif->dma_host_on = &atiixp_dma_host_on;
        hwif->dma_host_off = &atiixp_dma_host_off;
index b0aa7d03b8a576333a6675c3cd7c19b4e7addb4b..8631b6c8aa15bbae16f1f1b6ad817eb76d353840 100644 (file)
@@ -517,7 +517,7 @@ static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev, const cha
        return 0;
 }
 
-static unsigned int __devinit ata66_cmd64x(ide_hwif_t *hwif)
+static u8 __devinit ata66_cmd64x(ide_hwif_t *hwif)
 {
        struct pci_dev  *dev    = hwif->pci_dev;
        u8 bmidecsr = 0, mask   = hwif->channel ? 0x02 : 0x01;
@@ -526,9 +526,9 @@ static unsigned int __devinit ata66_cmd64x(ide_hwif_t *hwif)
        case PCI_DEVICE_ID_CMD_648:
        case PCI_DEVICE_ID_CMD_649:
                pci_read_config_byte(dev, BMIDECSR, &bmidecsr);
-               return (bmidecsr & mask) ? 1 : 0;
+               return (bmidecsr & mask) ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
        default:
-               return 0;
+               return ATA_CBL_PATA40;
        }
 }
 
@@ -568,8 +568,8 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif)
 
        hwif->ide_dma_check = &cmd64x_config_drive_for_dma;
 
-       if (!hwif->udma_four)
-               hwif->udma_four = ata66_cmd64x(hwif);
+       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
+               hwif->cbl = ata66_cmd64x(hwif);
 
        switch (dev->device) {
        case PCI_DEVICE_ID_CMD_648:
index 41925c47ef05968d484107b34b7c22b1e53373c4..10f61f38243cbc6242ee1b33c2634b1cdca6a8e1 100644 (file)
@@ -187,7 +187,8 @@ static u8 __devinit cs5535_cable_detect(struct pci_dev *dev)
 
        /* if a 80 wire cable was detected */
        pci_read_config_byte(dev, CS5535_CABLE_DETECT, &bit);
-       return (bit & 1);
+
+       return (bit & 1) ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
 }
 
 /****
@@ -212,8 +213,7 @@ static void __devinit init_hwif_cs5535(ide_hwif_t *hwif)
        hwif->ultra_mask = 0x1F;
        hwif->mwdma_mask = 0x07;
 
-
-       hwif->udma_four = cs5535_cable_detect(hwif->pci_dev);
+       hwif->cbl = cs5535_cable_detect(hwif->pci_dev);
 
        if (!noautodma)
                hwif->autodma = 1;
index ce363c923613f12c0adb40b62c5bb3df837e43e9..4b6bae8eee82822b875bd40f4ccba0cb72894c9b 100644 (file)
@@ -1330,8 +1330,8 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
        } else
                pci_read_config_byte (dev, 0x5a, &scr1);
 
-       if (!hwif->udma_four)
-               hwif->udma_four = (scr1 & ata66) ? 0 : 1;
+       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
+               hwif->cbl = (scr1 & ata66) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
 
        hwif->ide_dma_check             = &hpt366_config_drive_xfer_rate;
 
index c04a02687b95ec91c3687761c6f3e4e318b380c5..ff48c23e571ea03ad6506437b3ece40f3afedd47 100644 (file)
@@ -231,7 +231,7 @@ static int it8213_config_drive_for_dma (ide_drive_t *drive)
 
 static void __devinit init_hwif_it8213(ide_hwif_t *hwif)
 {
-       u8 reg42h = 0, ata66 = 0;
+       u8 reg42h = 0;
 
        hwif->speedproc = &it8213_tune_chipset;
        hwif->tuneproc  = &it8213_tuneproc;
@@ -250,11 +250,11 @@ static void __devinit init_hwif_it8213(ide_hwif_t *hwif)
        hwif->swdma_mask = 0x04;
 
        pci_read_config_byte(hwif->pci_dev, 0x42, &reg42h);
-       ata66 = (reg42h & 0x02) ? 0 : 1;
 
        hwif->ide_dma_check = &it8213_config_drive_for_dma;
-       if (!(hwif->udma_four))
-               hwif->udma_four = ata66;
+
+       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
+               hwif->cbl = (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
 
        /*
         *      The BIOS often doesn't set up DMA on this controller
index 3aeb7f1b79168f9790f3faafda531c653b7195c4..8197b653ba1ed8cbb67e450ed6d5af628a21dd40 100644 (file)
@@ -491,10 +491,10 @@ static int it821x_config_drive_for_dma (ide_drive_t *drive)
  *     the needed logic onboard.
  */
 
-static unsigned int __devinit ata66_it821x(ide_hwif_t *hwif)
+static u8 __devinit ata66_it821x(ide_hwif_t *hwif)
 {
        /* The reference driver also only does disk side */
-       return 1;
+       return ATA_CBL_PATA80;
 }
 
 /**
@@ -662,8 +662,9 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
        hwif->mwdma_mask = 0x07;
 
        hwif->ide_dma_check = &it821x_config_drive_for_dma;
-       if (!(hwif->udma_four))
-               hwif->udma_four = ata66_it821x(hwif);
+
+       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
+               hwif->cbl = ata66_it821x(hwif);
 
        /*
         *      The BIOS often doesn't set up DMA on this controller
index 76ed251472298682a516c0b6699dc0c07a7618d4..a6008f63e71ef677721411e7d2f36cb1696e9141 100644 (file)
@@ -25,10 +25,10 @@ typedef enum {
  *     ata66_jmicron           -       Cable check
  *     @hwif: IDE port
  *
- *     Return 1 if the cable is 80pin
+ *     Returns the cable type.
  */
 
-static int __devinit ata66_jmicron(ide_hwif_t *hwif)
+static u8 __devinit ata66_jmicron(ide_hwif_t *hwif)
 {
        struct pci_dev *pdev = hwif->pci_dev;
 
@@ -70,16 +70,17 @@ static int __devinit ata66_jmicron(ide_hwif_t *hwif)
        {
        case PORT_PATA0:
                if (control & (1 << 3)) /* 40/80 pin primary */
-                       return 0;
-               return 1;
+                       return ATA_CBL_PATA40;
+               return ATA_CBL_PATA80;
        case PORT_PATA1:
                if (control5 & (1 << 19))       /* 40/80 pin secondary */
-                       return 0;
-               return 1;
+                       return ATA_CBL_PATA40;
+               return ATA_CBL_PATA80;
        case PORT_SATA:
                break;
        }
-       return 1; /* Avoid bogus "control reaches end of non-void function" */
+       /* Avoid bogus "control reaches end of non-void function" */
+       return ATA_CBL_PATA80;
 }
 
 static void jmicron_tuneproc (ide_drive_t *drive, byte mode_wanted)
@@ -159,8 +160,9 @@ static void __devinit init_hwif_jmicron(ide_hwif_t *hwif)
        hwif->mwdma_mask = 0x07;
 
        hwif->ide_dma_check = &jmicron_config_drive_for_dma;
-       if (!(hwif->udma_four))
-               hwif->udma_four = ata66_jmicron(hwif);
+
+       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
+               hwif->cbl = ata66_jmicron(hwif);
 
        hwif->autodma = 1;
        hwif->drives[0].autodma = hwif->autodma;
index 0765dce6948eb1f91cc39ce878bac44750776a11..ee5020df005d7515eaf7822c18515a34fb119fff 100644 (file)
@@ -225,7 +225,10 @@ static void pdcnew_tune_drive(ide_drive_t *drive, u8 pio)
 
 static u8 pdcnew_cable_detect(ide_hwif_t *hwif)
 {
-       return get_indexed_reg(hwif, 0x0b) & 0x04;
+       if (get_indexed_reg(hwif, 0x0b) & 0x04)
+               return ATA_CBL_PATA40;
+       else
+               return ATA_CBL_PATA80;
 }
 
 static int pdcnew_config_drive_xfer_rate(ide_drive_t *drive)
@@ -509,8 +512,8 @@ static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif)
 
        hwif->ide_dma_check = &pdcnew_config_drive_xfer_rate;
 
-       if (!hwif->udma_four)
-               hwif->udma_four = pdcnew_cable_detect(hwif) ? 0 : 1;
+       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
+               hwif->cbl = pdcnew_cable_detect(hwif);
 
        if (!noautodma)
                hwif->autodma = 1;
index ae628b86e18aee382343609ce2f35836ce92b2f2..41ac4a94959fb2c6fd1e4032cf599fe9370d84b4 100644 (file)
@@ -152,8 +152,10 @@ static void pdc202xx_tune_drive(ide_drive_t *drive, u8 pio)
 static u8 pdc202xx_old_cable_detect (ide_hwif_t *hwif)
 {
        u16 CIS = 0, mask = (hwif->channel) ? (1<<11) : (1<<10);
+
        pci_read_config_word(hwif->pci_dev, 0x50, &CIS);
-       return (CIS & mask) ? 1 : 0;
+
+       return (CIS & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
 }
 
 /*
@@ -357,8 +359,9 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif)
        hwif->dma_timeout = &pdc202xx_dma_timeout;
 
        if (hwif->pci_dev->device != PCI_DEVICE_ID_PROMISE_20246) {
-               if (!(hwif->udma_four))
-                       hwif->udma_four = (pdc202xx_old_cable_detect(hwif)) ? 0 : 1;
+               if (hwif->cbl != ATA_CBL_PATA40_SHORT)
+                       hwif->cbl = pdc202xx_old_cable_detect(hwif);
+
                hwif->dma_start = &pdc202xx_old_ide_dma_start;
                hwif->ide_dma_end = &pdc202xx_old_ide_dma_end;
        } 
index 8b219dd630241f4285512e61a9b417872c5147e8..1547c37f3332753d67ba7a0289824bae63523751 100644 (file)
@@ -394,14 +394,14 @@ static void piix_dma_clear_irq(ide_drive_t *drive)
        hwif->OUTB(dma_stat, hwif->dma_status);
 }
 
-static int __devinit piix_cable_detect(ide_hwif_t *hwif)
+static u8 __devinit piix_cable_detect(ide_hwif_t *hwif)
 {
        struct pci_dev *dev = hwif->pci_dev;
        u8 reg54h = 0, mask = hwif->channel ? 0xc0 : 0x30;
 
        pci_read_config_byte(dev, 0x54, &reg54h);
 
-       return (reg54h & mask) ? 1 : 0;
+       return (reg54h & mask) ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
 }
 
 /**
@@ -444,8 +444,8 @@ static void __devinit init_hwif_piix(ide_hwif_t *hwif)
        hwif->swdma_mask = 0x04;
 
        if (hwif->ultra_mask & 0x78) {
-               if (!hwif->udma_four)
-                       hwif->udma_four = piix_cable_detect(hwif);
+               if (hwif->cbl != ATA_CBL_PATA40_SHORT)
+                       hwif->cbl = piix_cable_detect(hwif);
        }
 
        if (no_piix_dma)
index 55bc0a32e34f9d1b8781bef98a34461cce96ade8..7b87488e3daa831fee54fba1e4dc9f8d59c43b94 100644 (file)
@@ -716,7 +716,7 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif)
        hwif->atapi_dma = 1;
 
        /* we support 80c cable only. */
-       hwif->udma_four = 1;
+       hwif->cbl = ATA_CBL_PATA80;
 
        hwif->autodma = 0;
        if (!noautodma)
index 09a7aedf63ac04ee2dfae15b310afac732f2783b..1371b5bf6bf04b5537a7449fdcab0a0731465529 100644 (file)
@@ -329,9 +329,9 @@ static unsigned int __devinit init_chipset_svwks (struct pci_dev *dev, const cha
        return dev->irq;
 }
 
-static unsigned int __devinit ata66_svwks_svwks (ide_hwif_t *hwif)
+static u8 __devinit ata66_svwks_svwks(ide_hwif_t *hwif)
 {
-       return 1;
+       return ATA_CBL_PATA80;
 }
 
 /* On Dell PowerEdge servers with a CSB5/CSB6, the top two bits
@@ -341,7 +341,7 @@ static unsigned int __devinit ata66_svwks_svwks (ide_hwif_t *hwif)
  * Bit 14 clear = primary IDE channel does not have 80-pin cable.
  * Bit 14 set   = primary IDE channel has 80-pin cable.
  */
-static unsigned int __devinit ata66_svwks_dell (ide_hwif_t *hwif)
+static u8 __devinit ata66_svwks_dell(ide_hwif_t *hwif)
 {
        struct pci_dev *dev = hwif->pci_dev;
        if (dev->subsystem_vendor == PCI_VENDOR_ID_DELL &&
@@ -349,8 +349,8 @@ static unsigned int __devinit ata66_svwks_dell (ide_hwif_t *hwif)
            (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE ||
             dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE))
                return ((1 << (hwif->channel + 14)) &
-                       dev->subsystem_device) ? 1 : 0;
-       return 0;
+                       dev->subsystem_device) ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
+       return ATA_CBL_PATA40;
 }
 
 /* Sun Cobalt Alpine hardware avoids the 80-pin cable
@@ -359,18 +359,18 @@ static unsigned int __devinit ata66_svwks_dell (ide_hwif_t *hwif)
  *
  * WARNING: this only works on Alpine hardware!
  */
-static unsigned int __devinit ata66_svwks_cobalt (ide_hwif_t *hwif)
+static u8 __devinit ata66_svwks_cobalt(ide_hwif_t *hwif)
 {
        struct pci_dev *dev = hwif->pci_dev;
        if (dev->subsystem_vendor == PCI_VENDOR_ID_SUN &&
            dev->vendor == PCI_VENDOR_ID_SERVERWORKS &&
            dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5IDE)
                return ((1 << (hwif->channel + 14)) &
-                       dev->subsystem_device) ? 1 : 0;
-       return 0;
+                       dev->subsystem_device) ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
+       return ATA_CBL_PATA40;
 }
 
-static unsigned int __devinit ata66_svwks (ide_hwif_t *hwif)
+static u8 __devinit ata66_svwks(ide_hwif_t *hwif)
 {
        struct pci_dev *dev = hwif->pci_dev;
 
@@ -389,9 +389,9 @@ static unsigned int __devinit ata66_svwks (ide_hwif_t *hwif)
        /* Per Specified Design by OEM, and ASIC Architect */
        if ((dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE) ||
            (dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB6IDE2))
-               return 1;
+               return ATA_CBL_PATA80;
 
-       return 0;
+       return ATA_CBL_PATA40;
 }
 
 static void __devinit init_hwif_svwks (ide_hwif_t *hwif)
@@ -422,8 +422,8 @@ static void __devinit init_hwif_svwks (ide_hwif_t *hwif)
 
        hwif->ide_dma_check = &svwks_config_drive_xfer_rate;
        if (hwif->pci_dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) {
-               if (!hwif->udma_four)
-                       hwif->udma_four = ata66_svwks(hwif);
+               if (hwif->cbl != ATA_CBL_PATA40_SHORT)
+                       hwif->cbl = ata66_svwks(hwif);
        }
        if (!noautodma)
                hwif->autodma = 1;
index 1a4444e7226aa840093e39779bc192eaed8d728f..1c3e354878934dd923116fe7a6723524057c8026 100644 (file)
@@ -933,16 +933,17 @@ static void __devinit init_iops_siimage(ide_hwif_t *hwif)
  *     interface.
  */
 
-static unsigned int __devinit ata66_siimage(ide_hwif_t *hwif)
+static u8 __devinit ata66_siimage(ide_hwif_t *hwif)
 {
        unsigned long addr = siimage_selreg(hwif, 0);
-       if (pci_get_drvdata(hwif->pci_dev) == NULL) {
-               u8 ata66 = 0;
+       u8 ata66 = 0;
+
+       if (pci_get_drvdata(hwif->pci_dev) == NULL)
                pci_read_config_byte(hwif->pci_dev, addr, &ata66);
-               return (ata66 & 0x01) ? 1 : 0;
-       }
+       else
+               ata66 = hwif->INB(addr);
 
-       return (hwif->INB(addr) & 0x01) ? 1 : 0;
+       return (ata66 & 0x01) ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
 }
 
 /**
@@ -988,8 +989,9 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
                hwif->atapi_dma = 1;
 
        hwif->ide_dma_check = &siimage_config_drive_for_dma;
-       if (!(hwif->udma_four))
-               hwif->udma_four = ata66_siimage(hwif);
+
+       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
+               hwif->cbl = ata66_siimage(hwif);
 
        if (hwif->mmio) {
                hwif->ide_dma_test_irq = &siimage_mmio_ide_dma_test_irq;
index ec0adad9ef6132928094a5774c06daedd52525d7..4457c9d379f6feb6d8dd16dc698785fc0174bcc6 100644 (file)
@@ -796,7 +796,7 @@ static unsigned int __devinit init_chipset_sis5513 (struct pci_dev *dev, const c
        return 0;
 }
 
-static unsigned int __devinit ata66_sis5513 (ide_hwif_t *hwif)
+static u8 __devinit ata66_sis5513(ide_hwif_t *hwif)
 {
        u8 ata66 = 0;
 
@@ -811,7 +811,8 @@ static unsigned int __devinit ata66_sis5513 (ide_hwif_t *hwif)
                pci_read_config_byte(hwif->pci_dev, 0x48, &reg48h);
                ata66 = (reg48h & mask) ? 0 : 1;
        }
-        return ata66;
+
+       return ata66 ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
 }
 
 static void __devinit init_hwif_sis5513 (ide_hwif_t *hwif)
@@ -841,8 +842,8 @@ static void __devinit init_hwif_sis5513 (ide_hwif_t *hwif)
        if (!chipset_family)
                return;
 
-       if (!(hwif->udma_four))
-               hwif->udma_four = ata66_sis5513(hwif);
+       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
+               hwif->cbl = ata66_sis5513(hwif);
 
        if (chipset_family > ATA_16) {
                hwif->ide_dma_check = &sis5513_config_xfer_rate;
index c40f291f91e04c62cce013882abcc67ef53ad05d..575dbbd8b482edb345960fc5e56ecbf87ed39693 100644 (file)
@@ -199,10 +199,9 @@ static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif)
        hwif->mwdma_mask = 0x06;
        hwif->swdma_mask = 0x04;
 
-       if (!hwif->udma_four) {
+       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
                /* bit[0(1)]: 0:80, 1:40 */
-               hwif->udma_four = (reg47 & mask) ? 0 : 1;
-       }
+               hwif->cbl = (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
 
        hwif->ide_dma_check = &slc90e66_config_drive_xfer_rate;
 
index cee619bb2eaf8a7713ccc7582acb48b22f4c10e8..8de1f8e224946b589fb173df6d572499598eecb2 100644 (file)
@@ -220,13 +220,13 @@ static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif)
        hwif->ide_dma_check     = &tc86c001_config_drive_xfer_rate;
        hwif->dma_start         = &tc86c001_dma_start;
 
-       if (!hwif->udma_four) {
+       if (hwif->cbl != ATA_CBL_PATA40_SHORT) {
                /*
                 * System Control  1 Register bit 13 (PDIAGN):
                 * 0=80-pin cable, 1=40-pin cable
                 */
                scr1 = hwif->INW(sc_base + 0x00);
-               hwif->udma_four = (scr1 & 0x2000) ? 0 : 1;
+               hwif->cbl = (scr1 & 0x2000) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
        }
 
        if (!noautodma)
index 49bd1c645fb29dc4105ede35c15538f2ebd2c107..ae88e9f6592182bc55bbca2de86bb70ec4e69414 100644 (file)
@@ -448,8 +448,13 @@ static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif)
        hwif->mwdma_mask = 0x07;
        hwif->swdma_mask = 0x07;
 
-       if (!hwif->udma_four)
-               hwif->udma_four = (vdev->via_80w >> hwif->channel) & 1;
+       if (hwif->cbl != ATA_CBL_PATA40_SHORT) {
+               if ((vdev->via_80w >> hwif->channel) & 1)
+                       hwif->cbl = ATA_CBL_PATA80;
+               else
+                       hwif->cbl = ATA_CBL_PATA40;
+       }
+
        hwif->ide_dma_check = &via82cxxx_ide_dma_check;
        if (!noautodma)
                hwif->autodma = 1;
index 5e307740945798b2eeed854c42974fbdeb8d0fcc..e46f47206542bfec313086e5feab745b62131562 100644 (file)
@@ -942,8 +942,8 @@ pmac_ide_tune_chipset (ide_drive_t *drive, byte speed)
                                return 1;
                case XFER_UDMA_4:
                case XFER_UDMA_3:
-                       if (HWIF(drive)->udma_four == 0)
-                               return 1;               
+                       if (drive->hwif->cbl != ATA_CBL_PATA80)
+                               return 1;
                case XFER_UDMA_2:
                case XFER_UDMA_1:
                case XFER_UDMA_0:
@@ -1244,7 +1244,7 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
        hwif->chipset = ide_pmac;
        hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET] || pmif->mediabay;
        hwif->hold = pmif->mediabay;
-       hwif->udma_four = pmif->cable_80;
+       hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40;
        hwif->drives[0].unmask = 1;
        hwif->drives[1].unmask = 1;
        hwif->tuneproc = pmac_ide_tuneproc;
index b6546f442fa4424545c43ca56efb0699413cecf1..19ab25804056b7b467197d89f1d6b8a02a757912 100644 (file)
@@ -686,6 +686,8 @@ typedef struct hwif_s {
        u8 mwdma_mask;
        u8 swdma_mask;
 
+       u8 cbl;         /* cable type */
+
        hwif_chipset_t chipset; /* sub-module for tuning.. */
 
        struct pci_dev  *pci_dev;       /* for pci chipsets */
@@ -792,7 +794,6 @@ typedef struct hwif_s {
        unsigned        sharing_irq: 1; /* 1 = sharing irq with another hwif */
        unsigned        reset      : 1; /* reset after probe */
        unsigned        autodma    : 1; /* auto-attempt using DMA at boot */
-       unsigned        udma_four  : 1; /* 1=ATA-66 capable, 0=default */
        unsigned        no_lba48   : 1; /* 1 = cannot do LBA48 */
        unsigned        no_lba48_dma : 1; /* 1 = cannot do LBA48 DMA */
        unsigned        auto_poll  : 1; /* supports nop auto-poll */