]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ide: add ->cable_detect method to ide_hwif_t
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Sat, 2 Feb 2008 18:56:31 +0000 (19:56 +0100)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Sat, 2 Feb 2008 18:56:31 +0000 (19:56 +0100)
* Add ->cable_detect method to ide_hwif_t.

* Call the new method in ide_init_port() if:
  - the host supports UDMA modes > UDMA2 ('hwif->ultra_mask & 78')
  - DMA initialization was successful (if hwif->dma_base is not set
    ide_init_port() sets hwif->ultra_mask to zero)
  - "idex=ata66" is not used ('hwif->cbl != ATA_CBL_PATA40_SHORT')

* Convert PCI host drivers to use ->cable_detect method.

While at it:

* Factor out cable detection to separate functions (if not already done).

* hpt366.c/it8213.c/slc90e66.c:
  - don't check cable type if "idex=ata66" is used

* pdc202xx_new.c:
  - add __devinit tag to pdcnew_cable_detect()

* pdc202xx_old.c:
  - rename pdc202xx_old_cable_detect() to pdc2026x_old_cable_detect()
  - add __devinit tag to pdc2026x_old_cable_detect()

Reviewed-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
22 files changed:
drivers/ide/ide-probe.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
include/linux/ide.h

index 4c3d2cf3be5b583ec72ffaa4c07bba4ec73ffdbe..c25df65b51f83c2cac21b51cedbd43eedeaa9fa2 100644 (file)
@@ -1343,6 +1343,11 @@ static void ide_init_port(ide_hwif_t *hwif, unsigned int port,
        /* call chipset specific routine for each enabled port */
        if (d->init_hwif)
                d->init_hwif(hwif);
+
+       if (hwif->cable_detect && (hwif->ultra_mask & 0x78)) {
+               if (hwif->cbl != ATA_CBL_PATA40_SHORT)
+                       hwif->cbl = hwif->cable_detect(hwif);
+       }
 }
 
 int ide_device_add_all(u8 *idx, const struct ide_port_info *d)
index 824df78c70125966631c65dc450efb3dd67ee947..ca302fcba3ab5c2bc1e96262626cf128cf71058a 100644 (file)
@@ -166,6 +166,16 @@ static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const ch
        return dev->irq;
 }
 
+static u8 __devinit atp86x_cable_detect(ide_hwif_t *hwif)
+{
+       struct pci_dev *dev = to_pci_dev(hwif->dev);
+       u8 ata66 = 0, mask = hwif->channel ? 0x02 : 0x01;
+
+       pci_read_config_byte(dev, 0x49, &ata66);
+
+       return (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
+}
+
 static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif)
 {
        struct pci_dev *dev = to_pci_dev(hwif->dev);
@@ -174,21 +184,10 @@ static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif)
 
        if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF)
                hwif->set_dma_mode = &aec6210_set_mode;
-       else
+       else {
                hwif->set_dma_mode = &aec6260_set_mode;
 
-       if (hwif->dma_base == 0)
-               return;
-
-       if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF)
-               return;
-
-       if (hwif->cbl != ATA_CBL_PATA40_SHORT) {
-               u8 ata66 = 0, mask = hwif->channel ? 0x02 : 0x01;
-
-               pci_read_config_byte(dev, 0x49, &ata66);
-
-               hwif->cbl = (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
+               hwif->cable_detect = atp86x_cable_detect;
        }
 }
 
index 130cc6e784e552e7db3f842095e2ca9b8d83a6bd..91db990ab756fcd1a8a1fc5fa39c8970c39c6543 100644 (file)
@@ -666,13 +666,12 @@ static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif)
        hwif->set_dma_mode = &ali_set_dma_mode;
        hwif->udma_filter = &ali_udma_filter;
 
+       hwif->cable_detect = ata66_ali15x3;
+
        if (hwif->dma_base == 0)
                return;
 
        hwif->dma_setup = &ali15x3_dma_setup;
-
-       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
-               hwif->cbl = ata66_ali15x3(hwif);
 }
 
 /**
index 8c52bc9eaa5910575d70c123e86ffd3edd1ecc55..d6d58d217142ab5feca8d83c01e105cbcaa7a8c3 100644 (file)
@@ -199,6 +199,14 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev,
        return dev->irq;
 }
 
+static u8 __devinit amd_cable_detect(ide_hwif_t *hwif)
+{
+       if ((amd_80w >> hwif->channel) & 1)
+               return ATA_CBL_PATA80;
+       else
+               return ATA_CBL_PATA40;
+}
+
 static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif)
 {
        struct pci_dev *dev = to_pci_dev(hwif->dev);
@@ -209,15 +217,7 @@ static void __devinit init_hwif_amd74xx(ide_hwif_t *hwif)
        hwif->set_pio_mode = &amd_set_pio_mode;
        hwif->set_dma_mode = &amd_set_drive;
 
-       if (!hwif->dma_base)
-               return;
-
-       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->cable_detect = amd_cable_detect;
 }
 
 #define IDE_HFLAGS_AMD \
index 648fdf30cdf41374409f577dd428328da024a43b..b84185b4b68fbf4ccc3673bc04620a80c8f15152 100644 (file)
@@ -147,11 +147,7 @@ static void __devinit init_hwif_atiixp(ide_hwif_t *hwif)
        hwif->set_pio_mode = &atiixp_set_pio_mode;
        hwif->set_dma_mode = &atiixp_set_dma_mode;
 
-       if (!hwif->dma_base)
-               return;
-
-       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
-               hwif->cbl = atiixp_cable_detect(hwif);
+       hwif->cable_detect = atiixp_cable_detect;
 }
 
 static const struct ide_port_info atiixp_pci_info[] __devinitdata = {
index 04aa9e59670ea5413f184637bdcd490cad9527b2..181506340d9868adbebf97d6910e765a56c3df35 100644 (file)
@@ -393,6 +393,8 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif)
        hwif->set_pio_mode = &cmd64x_set_pio_mode;
        hwif->set_dma_mode = &cmd64x_set_dma_mode;
 
+       hwif->cable_detect = ata66_cmd64x;
+
        if (!hwif->dma_base)
                return;
 
@@ -411,9 +413,6 @@ static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif)
        if (dev->device == PCI_DEVICE_ID_CMD_646 && dev->revision < 5)
                hwif->ultra_mask = 0x00;
 
-       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
-               hwif->cbl = ata66_cmd64x(hwif);
-
        switch (dev->device) {
        case PCI_DEVICE_ID_CMD_648:
        case PCI_DEVICE_ID_CMD_649:
index 50046436a565ae960869b1c604a833297448ad76..d7b5ea992e94a25ee10b46eac7bb4237a9848764 100644 (file)
@@ -179,11 +179,7 @@ static void __devinit init_hwif_cs5535(ide_hwif_t *hwif)
        hwif->set_pio_mode = &cs5535_set_pio_mode;
        hwif->set_dma_mode = &cs5535_set_dma_mode;
 
-       if (hwif->dma_base == 0)
-               return;
-
-       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
-               hwif->cbl = cs5535_cable_detect(hwif);
+       hwif->cable_detect = cs5535_cable_detect;
 }
 
 static const struct ide_port_info cs5535_chipset __devinitdata = {
index 5623cad569da3f3b6e0c813e41f3b666d84a1b94..7a8c8c7a8b9608e640f0d174389d16d3bebc6cf4 100644 (file)
@@ -1279,12 +1279,55 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha
        return dev->irq;
 }
 
+static u8 __devinit hpt3xx_cable_detect(ide_hwif_t *hwif)
+{
+       struct pci_dev  *dev    = to_pci_dev(hwif->dev);
+       struct hpt_info *info   = pci_get_drvdata(dev);
+       u8 chip_type            = info->chip_type;
+       u8 scr1 = 0, ata66      = hwif->channel ? 0x01 : 0x02;
+
+       /*
+        * The HPT37x uses the CBLID pins as outputs for MA15/MA16
+        * address lines to access an external EEPROM.  To read valid
+        * cable detect state the pins must be enabled as inputs.
+        */
+       if (chip_type == HPT374 && (PCI_FUNC(dev->devfn) & 1)) {
+               /*
+                * HPT374 PCI function 1
+                * - set bit 15 of reg 0x52 to enable TCBLID as input
+                * - set bit 15 of reg 0x56 to enable FCBLID as input
+                */
+               u8  mcr_addr = hwif->select_data + 2;
+               u16 mcr;
+
+               pci_read_config_word(dev, mcr_addr, &mcr);
+               pci_write_config_word(dev, mcr_addr, (mcr | 0x8000));
+               /* now read cable id register */
+               pci_read_config_byte(dev, 0x5a, &scr1);
+               pci_write_config_word(dev, mcr_addr, mcr);
+       } else if (chip_type >= HPT370) {
+               /*
+                * HPT370/372 and 374 pcifn 0
+                * - clear bit 0 of reg 0x5b to enable P/SCBLID as inputs
+                */
+               u8 scr2 = 0;
+
+               pci_read_config_byte(dev, 0x5b, &scr2);
+               pci_write_config_byte(dev, 0x5b, (scr2 & ~1));
+               /* now read cable id register */
+               pci_read_config_byte(dev, 0x5a, &scr1);
+               pci_write_config_byte(dev, 0x5b,  scr2);
+       } else
+               pci_read_config_byte(dev, 0x5a, &scr1);
+
+       return (scr1 & ata66) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
+}
+
 static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
 {
        struct pci_dev *dev     = to_pci_dev(hwif->dev);
        struct hpt_info *info   = pci_get_drvdata(dev);
        int serialize           = HPT_SERIALIZE_IO;
-       u8  scr1 = 0, ata66     = hwif->channel ? 0x01 : 0x02;
        u8  chip_type           = info->chip_type;
        u8  new_mcr, old_mcr    = 0;
 
@@ -1301,6 +1344,8 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
        hwif->udma_filter       = &hpt3xx_udma_filter;
        hwif->mdma_filter       = &hpt3xx_mdma_filter;
 
+       hwif->cable_detect      = hpt3xx_cable_detect;
+
        /*
         * HPT3xxN chips have some complications:
         *
@@ -1346,43 +1391,6 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
        if (hwif->dma_base == 0)
                return;
 
-       /*
-        * The HPT37x uses the CBLID pins as outputs for MA15/MA16
-        * address lines to access an external EEPROM.  To read valid
-        * cable detect state the pins must be enabled as inputs.
-        */
-       if (chip_type == HPT374 && (PCI_FUNC(dev->devfn) & 1)) {
-               /*
-                * HPT374 PCI function 1
-                * - set bit 15 of reg 0x52 to enable TCBLID as input
-                * - set bit 15 of reg 0x56 to enable FCBLID as input
-                */
-               u8  mcr_addr = hwif->select_data + 2;
-               u16 mcr;
-
-               pci_read_config_word (dev, mcr_addr, &mcr);
-               pci_write_config_word(dev, mcr_addr, (mcr | 0x8000));
-               /* now read cable id register */
-               pci_read_config_byte (dev, 0x5a, &scr1);
-               pci_write_config_word(dev, mcr_addr, mcr);
-       } else if (chip_type >= HPT370) {
-               /*
-                * HPT370/372 and 374 pcifn 0
-                * - clear bit 0 of reg 0x5b to enable P/SCBLID as inputs
-                */
-               u8 scr2 = 0;
-
-               pci_read_config_byte (dev, 0x5b, &scr2);
-               pci_write_config_byte(dev, 0x5b, (scr2 & ~1));
-               /* now read cable id register */
-               pci_read_config_byte (dev, 0x5a, &scr1);
-               pci_write_config_byte(dev, 0x5b,  scr2);
-       } else
-               pci_read_config_byte (dev, 0x5a, &scr1);
-
-       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
-               hwif->cbl = (scr1 & ata66) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
-
        if (chip_type >= HPT374) {
                hwif->ide_dma_test_irq  = &hpt374_ide_dma_test_irq;
                hwif->ide_dma_end       = &hpt374_ide_dma_end;
index df74e588a530daea46e44b1a5fa30ea621fe88a3..c781ea6502d698c03ebcd6f71696107a63c24ff0 100644 (file)
@@ -143,6 +143,16 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed)
        }
 }
 
+static u8 __devinit it8213_cable_detect(ide_hwif_t *hwif)
+{
+       struct pci_dev *dev = to_pci_dev(hwif->dev);
+       u8 reg42h = 0;
+
+       pci_read_config_byte(dev, 0x42, &reg42h);
+
+       return (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
+}
+
 /**
  *     init_hwif_it8213        -       set up hwif structs
  *     @hwif: interface to set up
@@ -152,19 +162,10 @@ static void it8213_set_dma_mode(ide_drive_t *drive, const u8 speed)
 
 static void __devinit init_hwif_it8213(ide_hwif_t *hwif)
 {
-       struct pci_dev *dev = to_pci_dev(hwif->dev);
-       u8 reg42h = 0;
-
        hwif->set_dma_mode = &it8213_set_dma_mode;
        hwif->set_pio_mode = &it8213_set_pio_mode;
 
-       if (!hwif->dma_base)
-               return;
-
-       pci_read_config_byte(dev, 0x42, &reg42h);
-
-       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
-               hwif->cbl = (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
+       hwif->cable_detect = it8213_cable_detect;
 }
 
 
index 938d35f35c81a97ed2db333b0faa5d54a8763928..79232c6c1f01955a02a3c5e9d72359962caadde7 100644 (file)
@@ -579,14 +579,13 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
        } else
                hwif->host_flags |= IDE_HFLAG_NO_SET_MODE;
 
+       hwif->cable_detect = ata66_it821x;
+
        if (hwif->dma_base == 0)
                return;
 
        hwif->ultra_mask = ATA_UDMA6;
        hwif->mwdma_mask = ATA_MWDMA2;
-
-       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
-               hwif->cbl = ata66_it821x(hwif);
 }
 
 static void __devinit it8212_disable_raid(struct pci_dev *dev)
index 8b40f6479c55c9a694a6066766f8a0ab1c9d299f..ff53c2df7a1387df7cb17cabd872fee617093d95 100644 (file)
@@ -111,11 +111,7 @@ static void __devinit init_hwif_jmicron(ide_hwif_t *hwif)
        hwif->set_pio_mode = &jmicron_set_pio_mode;
        hwif->set_dma_mode = &jmicron_set_dma_mode;
 
-       if (hwif->dma_base == 0)
-               return;
-
-       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
-               hwif->cbl = ata66_jmicron(hwif);
+       hwif->cable_detect = ata66_jmicron;
 }
 
 static const struct ide_port_info jmicron_chipset __devinitdata = {
index bb29db03540edbec0dedb62333f6f06dabee947d..b552960dc1c1add5b22dac2af03733f76f3116db 100644 (file)
@@ -197,7 +197,7 @@ static void pdcnew_set_pio_mode(ide_drive_t *drive, const u8 pio)
        }
 }
 
-static u8 pdcnew_cable_detect(ide_hwif_t *hwif)
+static u8 __devinit pdcnew_cable_detect(ide_hwif_t *hwif)
 {
        if (get_indexed_reg(hwif, 0x0b) & 0x04)
                return ATA_CBL_PATA40;
@@ -456,11 +456,7 @@ static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif)
        hwif->quirkproc = &pdcnew_quirkproc;
        hwif->resetproc = &pdcnew_reset;
 
-       if (hwif->dma_base == 0)
-               return;
-
-       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
-               hwif->cbl = pdcnew_cable_detect(hwif);
+       hwif->cable_detect = pdcnew_cable_detect;
 }
 
 static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev)
index 31a1308414a0f87a57a004831ca1e4fc8ac160ae..41853a1bc913f19aaff5beae08f01dc63a70b9a4 100644 (file)
@@ -140,7 +140,7 @@ static void pdc202xx_set_pio_mode(ide_drive_t *drive, const u8 pio)
        pdc202xx_set_mode(drive, XFER_PIO_0 + pio);
 }
 
-static u8 pdc202xx_old_cable_detect (ide_hwif_t *hwif)
+static u8 __devinit pdc2026x_old_cable_detect(ide_hwif_t *hwif)
 {
        struct pci_dev *dev = to_pci_dev(hwif->dev);
        u16 CIS = 0, mask = (hwif->channel) ? (1<<11) : (1<<10);
@@ -311,9 +311,12 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif)
 
        hwif->quirkproc = &pdc202xx_quirkproc;
 
-       if (dev->device != PCI_DEVICE_ID_PROMISE_20246)
+       if (dev->device != PCI_DEVICE_ID_PROMISE_20246) {
                hwif->resetproc = &pdc202xx_reset;
 
+               hwif->cable_detect = pdc2026x_old_cable_detect;
+       }
+
        if (hwif->dma_base == 0)
                return;
 
@@ -321,9 +324,6 @@ static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif)
        hwif->dma_timeout = &pdc202xx_dma_timeout;
 
        if (dev->device != PCI_DEVICE_ID_PROMISE_20246) {
-               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 c1a6b68337d52816bb3f22f13aebb3025a549d48..039f442c9ea72e82adaaed708f5a784f1d6f0fd8 100644 (file)
@@ -290,14 +290,11 @@ static void __devinit init_hwif_piix(ide_hwif_t *hwif)
        hwif->set_pio_mode = &piix_set_pio_mode;
        hwif->set_dma_mode = &piix_set_dma_mode;
 
+       hwif->cable_detect = piix_cable_detect;
+
        if (!hwif->dma_base)
                return;
 
-       if (hwif->ultra_mask & 0x78) {
-               if (hwif->cbl != ATA_CBL_PATA40_SHORT)
-                       hwif->cbl = piix_cable_detect(hwif);
-       }
-
        if (no_piix_dma)
                hwif->ultra_mask = hwif->mwdma_mask = hwif->swdma_mask = 0;
 }
index dcd44d7c0846046b3ce3efebda19a9140b707200..085c1b58a99c138e8cf9cda087295a7199e3b78f 100644 (file)
@@ -683,8 +683,7 @@ static void __devinit init_hwif_scc(ide_hwif_t *hwif)
        else
                hwif->ultra_mask = ATA_UDMA5; /* 100MHz */
 
-       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
-               hwif->cbl = scc_cable_detect(hwif);
+       hwif->cable_detect = scc_cable_detect;
 }
 
 #define DECLARE_SCC_DEV(name_str)                      \
index f495253b7d417d0666fa77a3330407436306ad2d..d9687a431c5a7834ae207b95540204aafd054b36 100644 (file)
@@ -346,13 +346,8 @@ static void __devinit init_hwif_svwks (ide_hwif_t *hwif)
        hwif->set_dma_mode = &svwks_set_dma_mode;
        hwif->udma_filter = &svwks_udma_filter;
 
-       if (!hwif->dma_base)
-               return;
-
-       if (dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) {
-               if (hwif->cbl != ATA_CBL_PATA40_SHORT)
-                       hwif->cbl = ata66_svwks(hwif);
-       }
+       if (dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE)
+               hwif->cable_detect = ata66_svwks;
 }
 
 #define IDE_HFLAGS_SVWKS \
index 4877bc8cd599cd27feea2c0108fe5f781e99d685..accac8342e17d4355d32b4135fbb5a6ad09599d3 100644 (file)
@@ -827,15 +827,14 @@ static void __devinit init_hwif_siimage(ide_hwif_t *hwif)
        } else
                hwif->udma_filter = &sil_pata_udma_filter;
 
+       hwif->cable_detect = ata66_siimage;
+
        if (hwif->dma_base == 0)
                return;
 
        if (sata)
                hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA;
 
-       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;
        } else {
index 2a461de22aa005099fa7e27bb53e5de3afebeb0b..cb5c6fc6f3f95ad3d28c7e097dd4fa34ff3926d6 100644 (file)
@@ -565,13 +565,12 @@ static void __devinit init_hwif_sis5513 (ide_hwif_t *hwif)
        if (chipset_family >= ATA_133)
                hwif->udma_filter = sis5513_ata133_udma_filter;
 
+       hwif->cable_detect = ata66_sis5513;
+
        if (hwif->dma_base == 0)
                return;
 
        hwif->ultra_mask = udma_rates[chipset_family];
-
-       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
-               hwif->cbl = ata66_sis5513(hwif);
 }
 
 static const struct ide_port_info sis5513_chipset __devinitdata = {
index a6cf810c469984bf906d5bd7101c8b01b6ddbb28..427f95b25fde9824f1ef19b4f5c022bf8afbc671 100644 (file)
@@ -118,23 +118,23 @@ static void slc90e66_set_dma_mode(ide_drive_t *drive, const u8 speed)
        }
 }
 
-static void __devinit init_hwif_slc90e66 (ide_hwif_t *hwif)
+static u8 __devinit slc90e66_cable_detect(ide_hwif_t *hwif)
 {
        struct pci_dev *dev = to_pci_dev(hwif->dev);
-       u8 reg47 = 0;
-       u8 mask = hwif->channel ? 0x01 : 0x02;  /* bit0:Primary */
-
-       hwif->set_pio_mode = &slc90e66_set_pio_mode;
-       hwif->set_dma_mode = &slc90e66_set_dma_mode;
+       u8 reg47 = 0, mask = hwif->channel ? 0x01 : 0x02;
 
        pci_read_config_byte(dev, 0x47, &reg47);
 
-       if (hwif->dma_base == 0)
-               return;
+       /* bit[0(1)]: 0:80, 1:40 */
+       return (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
+}
+
+static void __devinit init_hwif_slc90e66(ide_hwif_t *hwif)
+{
+       hwif->set_pio_mode = &slc90e66_set_pio_mode;
+       hwif->set_dma_mode = &slc90e66_set_dma_mode;
 
-       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
-               /* bit[0(1)]: 0:80, 1:40 */
-               hwif->cbl = (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
+       hwif->cable_detect = slc90e66_cable_detect;
 }
 
 static const struct ide_port_info slc90e66_chipset __devinitdata = {
index 9fbbb4f2dd5475561c41405a8b869064babe13a7..2ef2ed2f2b32a9e0ba45d263963edf97efeccda5 100644 (file)
@@ -160,6 +160,19 @@ static int tc86c001_busproc(ide_drive_t *drive, int state)
        return 0;
 }
 
+static u8 __devinit tc86c001_cable_detect(ide_hwif_t *hwif)
+{
+       struct pci_dev *dev = to_pci_dev(hwif->dev);
+       unsigned long sc_base = pci_resource_start(dev, 5);
+       u16 scr1 = inw(sc_base + 0x00);
+
+       /*
+        * System Control  1 Register bit 13 (PDIAGN):
+        * 0=80-pin cable, 1=40-pin cable
+        */
+       return (scr1 & 0x2000) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
+}
+
 static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif)
 {
        struct pci_dev *dev     = to_pci_dev(hwif->dev);
@@ -183,6 +196,8 @@ static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif)
 
        hwif->busproc   = &tc86c001_busproc;
 
+       hwif->cable_detect = tc86c001_cable_detect;
+
        if (!hwif->dma_base)
                return;
 
@@ -196,15 +211,6 @@ static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif)
        hwif->rqsize     = 0xffff;
 
        hwif->dma_start         = &tc86c001_dma_start;
-
-       if (hwif->cbl != ATA_CBL_PATA40_SHORT) {
-               /*
-                * System Control  1 Register bit 13 (PDIAGN):
-                * 0=80-pin cable, 1=40-pin cable
-                */
-               scr1 = inw(sc_base + 0x00);
-               hwif->cbl = (scr1 & 0x2000) ? ATA_CBL_PATA40 : ATA_CBL_PATA80;
-       }
 }
 
 static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev,
index 24cb9047fb419a8ad3e6c6bcc1ea903b79b64245..c58a279d6b2f8114cdfc6e8e7256969238568ab4 100644 (file)
@@ -424,11 +424,7 @@ static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif)
        hwif->set_pio_mode = &via_set_pio_mode;
        hwif->set_dma_mode = &via_set_drive;
 
-       if (!hwif->dma_base)
-               return;
-
-       if (hwif->cbl != ATA_CBL_PATA40_SHORT)
-               hwif->cbl = via82cxxx_cable_detect(hwif);
+       hwif->cable_detect = via82cxxx_cable_detect;
 }
 
 static const struct ide_port_info via82cxxx_chipset __devinitdata = {
index 508f7e435cc477287ddc46265d02eba6ea66962a..29e35980d7e3282d189658f23fe4a3a2a245697b 100644 (file)
@@ -535,6 +535,8 @@ typedef struct hwif_s {
        u8 (*mdma_filter)(ide_drive_t *);
        u8 (*udma_filter)(ide_drive_t *);
 
+       u8 (*cable_detect)(struct hwif_s *);
+
        void (*ata_input_data)(ide_drive_t *, void *, u32);
        void (*ata_output_data)(ide_drive_t *, void *, u32);