diff options
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/ide-probe.c | 5 | ||||
-rw-r--r-- | drivers/ide/pci/aec62xx.c | 25 | ||||
-rw-r--r-- | drivers/ide/pci/alim15x3.c | 5 | ||||
-rw-r--r-- | drivers/ide/pci/amd74xx.c | 18 | ||||
-rw-r--r-- | drivers/ide/pci/atiixp.c | 6 | ||||
-rw-r--r-- | drivers/ide/pci/cmd64x.c | 5 | ||||
-rw-r--r-- | drivers/ide/pci/cs5535.c | 6 | ||||
-rw-r--r-- | drivers/ide/pci/hpt366.c | 84 | ||||
-rw-r--r-- | drivers/ide/pci/it8213.c | 21 | ||||
-rw-r--r-- | drivers/ide/pci/it821x.c | 5 | ||||
-rw-r--r-- | drivers/ide/pci/jmicron.c | 6 | ||||
-rw-r--r-- | drivers/ide/pci/pdc202xx_new.c | 8 | ||||
-rw-r--r-- | drivers/ide/pci/pdc202xx_old.c | 10 | ||||
-rw-r--r-- | drivers/ide/pci/piix.c | 7 | ||||
-rw-r--r-- | drivers/ide/pci/scc_pata.c | 3 | ||||
-rw-r--r-- | drivers/ide/pci/serverworks.c | 9 | ||||
-rw-r--r-- | drivers/ide/pci/siimage.c | 5 | ||||
-rw-r--r-- | drivers/ide/pci/sis5513.c | 5 | ||||
-rw-r--r-- | drivers/ide/pci/slc90e66.c | 22 | ||||
-rw-r--r-- | drivers/ide/pci/tc86c001.c | 24 | ||||
-rw-r--r-- | drivers/ide/pci/via82cxxx.c | 6 |
21 files changed, 135 insertions, 150 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 4c3d2cf3be5..c25df65b51f 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c @@ -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) diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c index 824df78c701..ca302fcba3a 100644 --- a/drivers/ide/pci/aec62xx.c +++ b/drivers/ide/pci/aec62xx.c @@ -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; } } diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c index 130cc6e784e..91db990ab75 100644 --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c @@ -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); } /** diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c index 8c52bc9eaa5..d6d58d21714 100644 --- a/drivers/ide/pci/amd74xx.c +++ b/drivers/ide/pci/amd74xx.c @@ -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 \ diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c index 648fdf30cdf..b84185b4b68 100644 --- a/drivers/ide/pci/atiixp.c +++ b/drivers/ide/pci/atiixp.c @@ -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 = { diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c index 04aa9e59670..181506340d9 100644 --- a/drivers/ide/pci/cmd64x.c +++ b/drivers/ide/pci/cmd64x.c @@ -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: diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c index 50046436a56..d7b5ea992e9 100644 --- a/drivers/ide/pci/cs5535.c +++ b/drivers/ide/pci/cs5535.c @@ -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 = { diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index 5623cad569d..7a8c8c7a8b9 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c @@ -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; diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c index df74e588a53..c781ea6502d 100644 --- a/drivers/ide/pci/it8213.c +++ b/drivers/ide/pci/it8213.c @@ -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, ®42h); + + 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, ®42h); - - if (hwif->cbl != ATA_CBL_PATA40_SHORT) - hwif->cbl = (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; + hwif->cable_detect = it8213_cable_detect; } diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c index 938d35f35c8..79232c6c1f0 100644 --- a/drivers/ide/pci/it821x.c +++ b/drivers/ide/pci/it821x.c @@ -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) diff --git a/drivers/ide/pci/jmicron.c b/drivers/ide/pci/jmicron.c index 8b40f6479c5..ff53c2df7a1 100644 --- a/drivers/ide/pci/jmicron.c +++ b/drivers/ide/pci/jmicron.c @@ -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 = { diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c index bb29db03540..b552960dc1c 100644 --- a/drivers/ide/pci/pdc202xx_new.c +++ b/drivers/ide/pci/pdc202xx_new.c @@ -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) diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c index 31a1308414a..41853a1bc91 100644 --- a/drivers/ide/pci/pdc202xx_old.c +++ b/drivers/ide/pci/pdc202xx_old.c @@ -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; } diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c index c1a6b68337d..039f442c9ea 100644 --- a/drivers/ide/pci/piix.c +++ b/drivers/ide/pci/piix.c @@ -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; } diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c index dcd44d7c084..085c1b58a99 100644 --- a/drivers/ide/pci/scc_pata.c +++ b/drivers/ide/pci/scc_pata.c @@ -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) \ diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c index f495253b7d4..d9687a431c5 100644 --- a/drivers/ide/pci/serverworks.c +++ b/drivers/ide/pci/serverworks.c @@ -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 \ diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c index 4877bc8cd59..accac8342e1 100644 --- a/drivers/ide/pci/siimage.c +++ b/drivers/ide/pci/siimage.c @@ -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 { diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c index 2a461de22aa..cb5c6fc6f3f 100644 --- a/drivers/ide/pci/sis5513.c +++ b/drivers/ide/pci/sis5513.c @@ -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 = { diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c index a6cf810c469..427f95b25fd 100644 --- a/drivers/ide/pci/slc90e66.c +++ b/drivers/ide/pci/slc90e66.c @@ -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, ®47); - 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 = { diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/pci/tc86c001.c index 9fbbb4f2dd5..2ef2ed2f2b3 100644 --- a/drivers/ide/pci/tc86c001.c +++ b/drivers/ide/pci/tc86c001.c @@ -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, diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c index 24cb9047fb4..c58a279d6b2 100644 --- a/drivers/ide/pci/via82cxxx.c +++ b/drivers/ide/pci/via82cxxx.c @@ -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 = { |