Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bfa14b42 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz
Browse files

ide: add ->cable_detect method to ide_hwif_t



* 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: default avatarSergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent c413b9b9
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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)
+12 −13
Original line number Diff line number Diff line
@@ -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;
	}
}

+2 −3
Original line number Diff line number Diff line
@@ -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);
}

/**
+9 −9
Original line number Diff line number Diff line
@@ -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 \
+1 −5
Original line number Diff line number Diff line
@@ -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 = {
Loading