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

Commit a73984a0 authored by Jeff Garzik's avatar Jeff Garzik
Browse files

[libata] More PATA driver ->cable_detect support



Roll-up of ->cable_detect feature addition patches, authored and
signed-off-by Alan Cox.

Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent fecfda5d
Loading
Loading
Loading
Loading
+18 −8
Original line number Original line Diff line number Diff line
@@ -49,8 +49,6 @@ static int artop6210_pre_reset(struct ata_port *ap)


	if (!pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no]))
	if (!pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no]))
		return -ENOENT;
		return -ENOENT;

	ap->cbl = ATA_CBL_PATA40;
	return ata_std_prereset(ap);
	return ata_std_prereset(ap);
}
}


@@ -85,18 +83,28 @@ static int artop6260_pre_reset(struct ata_port *ap)
	};
	};


	struct pci_dev *pdev = to_pci_dev(ap->host->dev);
	struct pci_dev *pdev = to_pci_dev(ap->host->dev);
	u8 tmp;


	/* Odd numbered device ids are the units with enable bits (the -R cards) */
	/* Odd numbered device ids are the units with enable bits (the -R cards) */
	if (pdev->device % 1 && !pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no]))
	if (pdev->device % 1 && !pci_test_config_bits(pdev, &artop_enable_bits[ap->port_no]))
		return -ENOENT;
		return -ENOENT;
	return ata_std_prereset(ap);
}

/**
 *	artop6260_cable_detect	-	identify cable type
 *	@ap: Port
 *
 *	Identify the cable type for the ARTOp interface in question
 */
 
 
static int artop6260_cable_detect(struct ata_port *ap)
{
	struct pci_dev *pdev = to_pci_dev(ap->host->dev);
	u8 tmp;
	pci_read_config_byte(pdev, 0x49, &tmp);
	pci_read_config_byte(pdev, 0x49, &tmp);
	if (tmp & (1 << ap->port_no))
	if (tmp & (1 << ap->port_no))
		ap->cbl = ATA_CBL_PATA40;
		return ATA_CBL_PATA40;
	else
	return ATA_CBL_PATA80;
		ap->cbl = ATA_CBL_PATA80;
	return ata_std_prereset(ap);
}
}


/**
/**
@@ -225,7 +233,7 @@ static void artop6260_set_piomode(struct ata_port *ap, struct ata_device *adev)
/**
/**
 *	artop6210_set_dmamode - Initialize host controller PATA PIO timings
 *	artop6210_set_dmamode - Initialize host controller PATA PIO timings
 *	@ap: Port whose timings we are configuring
 *	@ap: Port whose timings we are configuring
 *	@adev: um
 *	@adev: Device whose timings we are configuring
 *
 *
 *	Set DMA mode for device, in host controller PCI config space.
 *	Set DMA mode for device, in host controller PCI config space.
 *
 *
@@ -333,6 +341,7 @@ static const struct ata_port_operations artop6210_ops = {
	.thaw			= ata_bmdma_thaw,
	.thaw			= ata_bmdma_thaw,
	.error_handler		= artop6210_error_handler,
	.error_handler		= artop6210_error_handler,
	.post_internal_cmd 	= ata_bmdma_post_internal_cmd,
	.post_internal_cmd 	= ata_bmdma_post_internal_cmd,
	.cable_detect		= ata_cable_40wire,


	.bmdma_setup		= ata_bmdma_setup,
	.bmdma_setup		= ata_bmdma_setup,
	.bmdma_start		= ata_bmdma_start,
	.bmdma_start		= ata_bmdma_start,
@@ -366,6 +375,7 @@ static const struct ata_port_operations artop6260_ops = {
	.thaw			= ata_bmdma_thaw,
	.thaw			= ata_bmdma_thaw,
	.error_handler		= artop6260_error_handler,
	.error_handler		= artop6260_error_handler,
	.post_internal_cmd 	= ata_bmdma_post_internal_cmd,
	.post_internal_cmd 	= ata_bmdma_post_internal_cmd,
	.cable_detect		= artop6260_cable_detect,


	.bmdma_setup		= ata_bmdma_setup,
	.bmdma_setup		= ata_bmdma_setup,
	.bmdma_start		= ata_bmdma_start,
	.bmdma_start		= ata_bmdma_start,
+9 −25
Original line number Original line Diff line number Diff line
@@ -75,13 +75,7 @@ enum {
	DTPR1		= 0x7C
	DTPR1		= 0x7C
};
};


static int cmd64x_pre_reset(struct ata_port *ap)
static int cmd648_cable_detect(struct ata_port *ap)
{
	ap->cbl = ATA_CBL_PATA40;
	return ata_std_prereset(ap);
}

static int cmd648_pre_reset(struct ata_port *ap)
{
{
	struct pci_dev *pdev = to_pci_dev(ap->host->dev);
	struct pci_dev *pdev = to_pci_dev(ap->host->dev);
	u8 r;
	u8 r;
@@ -89,21 +83,8 @@ static int cmd648_pre_reset(struct ata_port *ap)
	/* Check cable detect bits */
	/* Check cable detect bits */
	pci_read_config_byte(pdev, BMIDECSR, &r);
	pci_read_config_byte(pdev, BMIDECSR, &r);
	if (r & (1 << ap->port_no))
	if (r & (1 << ap->port_no))
		ap->cbl = ATA_CBL_PATA80;
		return ATA_CBL_PATA80;
	else
	return ATA_CBL_PATA40;
		ap->cbl = ATA_CBL_PATA40;

	return ata_std_prereset(ap);
}

static void cmd64x_error_handler(struct ata_port *ap)
{
	return ata_bmdma_drive_eh(ap, cmd64x_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
}

static void cmd648_error_handler(struct ata_port *ap)
{
	ata_bmdma_drive_eh(ap, cmd648_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
}
}


/**
/**
@@ -304,8 +285,9 @@ static struct ata_port_operations cmd64x_port_ops = {


	.freeze		= ata_bmdma_freeze,
	.freeze		= ata_bmdma_freeze,
	.thaw		= ata_bmdma_thaw,
	.thaw		= ata_bmdma_thaw,
	.error_handler	= cmd64x_error_handler,
	.error_handler	= ata_bmdma_error_handler,
	.post_internal_cmd = ata_bmdma_post_internal_cmd,
	.post_internal_cmd = ata_bmdma_post_internal_cmd,
	.cable_detect	= ata_cable_40wire,


	.bmdma_setup 	= ata_bmdma_setup,
	.bmdma_setup 	= ata_bmdma_setup,
	.bmdma_start 	= ata_bmdma_start,
	.bmdma_start 	= ata_bmdma_start,
@@ -338,8 +320,9 @@ static struct ata_port_operations cmd646r1_port_ops = {


	.freeze		= ata_bmdma_freeze,
	.freeze		= ata_bmdma_freeze,
	.thaw		= ata_bmdma_thaw,
	.thaw		= ata_bmdma_thaw,
	.error_handler	= cmd64x_error_handler,
	.error_handler	= ata_bmdma_error_handler,
	.post_internal_cmd = ata_bmdma_post_internal_cmd,
	.post_internal_cmd = ata_bmdma_post_internal_cmd,
	.cable_detect	= ata_cable_40wire,


	.bmdma_setup 	= ata_bmdma_setup,
	.bmdma_setup 	= ata_bmdma_setup,
	.bmdma_start 	= ata_bmdma_start,
	.bmdma_start 	= ata_bmdma_start,
@@ -372,8 +355,9 @@ static struct ata_port_operations cmd648_port_ops = {


	.freeze		= ata_bmdma_freeze,
	.freeze		= ata_bmdma_freeze,
	.thaw		= ata_bmdma_thaw,
	.thaw		= ata_bmdma_thaw,
	.error_handler	= cmd648_error_handler,
	.error_handler	= ata_bmdma_error_handler,
	.post_internal_cmd = ata_bmdma_post_internal_cmd,
	.post_internal_cmd = ata_bmdma_post_internal_cmd,
	.cable_detect	= cmd648_cable_detect,


	.bmdma_setup 	= ata_bmdma_setup,
	.bmdma_setup 	= ata_bmdma_setup,
	.bmdma_start 	= ata_bmdma_start,
	.bmdma_start 	= ata_bmdma_start,
+2 −13
Original line number Original line Diff line number Diff line
@@ -139,18 +139,6 @@ static void cs5520_set_piomode(struct ata_port *ap, struct ata_device *adev)
	cs5520_set_timings(ap, adev, adev->pio_mode);
	cs5520_set_timings(ap, adev, adev->pio_mode);
}
}



static int cs5520_pre_reset(struct ata_port *ap)
{
	ap->cbl = ATA_CBL_PATA40;
	return ata_std_prereset(ap);
}

static void cs5520_error_handler(struct ata_port *ap)
{
	return ata_bmdma_drive_eh(ap, cs5520_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
}

static struct scsi_host_template cs5520_sht = {
static struct scsi_host_template cs5520_sht = {
	.module			= THIS_MODULE,
	.module			= THIS_MODULE,
	.name			= DRV_NAME,
	.name			= DRV_NAME,
@@ -186,8 +174,9 @@ static struct ata_port_operations cs5520_port_ops = {


	.freeze			= ata_bmdma_freeze,
	.freeze			= ata_bmdma_freeze,
	.thaw			= ata_bmdma_thaw,
	.thaw			= ata_bmdma_thaw,
	.error_handler		= cs5520_error_handler,
	.error_handler		= ata_bmdma_error_handler,
	.post_internal_cmd	= ata_bmdma_post_internal_cmd,
	.post_internal_cmd	= ata_bmdma_post_internal_cmd,
	.cable_detect		= ata_cable_40wire,


	.bmdma_setup		= ata_bmdma_setup,
	.bmdma_setup		= ata_bmdma_setup,
	.bmdma_start		= ata_bmdma_start,
	.bmdma_start		= ata_bmdma_start,
+2 −13
Original line number Original line Diff line number Diff line
@@ -160,18 +160,6 @@ static unsigned int cs5530_qc_issue_prot(struct ata_queued_cmd *qc)
	return ata_qc_issue_prot(qc);
	return ata_qc_issue_prot(qc);
}
}


static int cs5530_pre_reset(struct ata_port *ap)
{
	ap->cbl = ATA_CBL_PATA40;
	return ata_std_prereset(ap);
}

static void cs5530_error_handler(struct ata_port *ap)
{
	return ata_bmdma_drive_eh(ap, cs5530_pre_reset, ata_std_softreset, NULL, ata_std_postreset);
}


static struct scsi_host_template cs5530_sht = {
static struct scsi_host_template cs5530_sht = {
	.module			= THIS_MODULE,
	.module			= THIS_MODULE,
	.name			= DRV_NAME,
	.name			= DRV_NAME,
@@ -213,8 +201,9 @@ static struct ata_port_operations cs5530_port_ops = {


	.freeze		= ata_bmdma_freeze,
	.freeze		= ata_bmdma_freeze,
	.thaw		= ata_bmdma_thaw,
	.thaw		= ata_bmdma_thaw,
	.error_handler	= cs5530_error_handler,
	.error_handler	= ata_bmdma_error_handler,
	.post_internal_cmd = ata_bmdma_post_internal_cmd,
	.post_internal_cmd = ata_bmdma_post_internal_cmd,
	.cable_detect	= ata_cable_40wire,


	.qc_prep 	= ata_qc_prep,
	.qc_prep 	= ata_qc_prep,
	.qc_issue	= cs5530_qc_issue_prot,
	.qc_issue	= cs5530_qc_issue_prot,
+2 −20
Original line number Original line Diff line number Diff line
@@ -25,25 +25,6 @@
#define DRV_NAME	"pata_hpt3x3"
#define DRV_NAME	"pata_hpt3x3"
#define DRV_VERSION	"0.4.2"
#define DRV_VERSION	"0.4.2"


static int hpt3x3_probe_init(struct ata_port *ap)
{
	ap->cbl = ATA_CBL_PATA40;
	return ata_std_prereset(ap);
}

/**
 *	hpt3x3_probe_reset	-	reset the hpt3x3 bus
 *	@ap: ATA port to reset
 *
 *	Perform the housekeeping when doing an ATA bus reeset. We just
 *	need to force the cable type.
 */

static void hpt3x3_error_handler(struct ata_port *ap)
{
	return ata_bmdma_drive_eh(ap, hpt3x3_probe_init, ata_std_softreset, NULL, ata_std_postreset);
}

/**
/**
 *	hpt3x3_set_piomode		-	PIO setup
 *	hpt3x3_set_piomode		-	PIO setup
 *	@ap: ATA interface
 *	@ap: ATA interface
@@ -139,8 +120,9 @@ static struct ata_port_operations hpt3x3_port_ops = {


	.freeze		= ata_bmdma_freeze,
	.freeze		= ata_bmdma_freeze,
	.thaw		= ata_bmdma_thaw,
	.thaw		= ata_bmdma_thaw,
	.error_handler	= hpt3x3_error_handler,
	.error_handler	= ata_bmdma_error_handler,
	.post_internal_cmd = ata_bmdma_post_internal_cmd,
	.post_internal_cmd = ata_bmdma_post_internal_cmd,
	.cable_detect	= ata_cable_40wire,


	.bmdma_setup 	= ata_bmdma_setup,
	.bmdma_setup 	= ata_bmdma_setup,
	.bmdma_start 	= ata_bmdma_start,
	.bmdma_start 	= ata_bmdma_start,
Loading