[PATCH] libata: add a function to decide if we need iordy
This ought to be simple but for PIO2 we have to poke around the drive data to get it 100% correct. Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
This commit is contained in:
@ -1168,6 +1168,39 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
|
|||||||
return AC_ERR_OTHER;
|
return AC_ERR_OTHER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ata_pio_need_iordy - check if iordy needed
|
||||||
|
* @adev: ATA device
|
||||||
|
*
|
||||||
|
* Check if the current speed of the device requires IORDY. Used
|
||||||
|
* by various controllers for chip configuration.
|
||||||
|
*/
|
||||||
|
|
||||||
|
unsigned int ata_pio_need_iordy(const struct ata_device *adev)
|
||||||
|
{
|
||||||
|
int pio;
|
||||||
|
int speed = adev->pio_mode - XFER_PIO_0;
|
||||||
|
|
||||||
|
if (speed < 2)
|
||||||
|
return 0;
|
||||||
|
if (speed > 2)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* If we have no drive specific rule, then PIO 2 is non IORDY */
|
||||||
|
|
||||||
|
if (adev->id[ATA_ID_FIELD_VALID] & 2) { /* EIDE */
|
||||||
|
pio = adev->id[ATA_ID_EIDE_PIO];
|
||||||
|
/* Is the speed faster than the drive allows non IORDY ? */
|
||||||
|
if (pio) {
|
||||||
|
/* This is cycle times not frequency - watch the logic! */
|
||||||
|
if (pio > 240) /* PIO2 is 240nS per cycle */
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ata_dev_identify - obtain IDENTIFY x DEVICE page
|
* ata_dev_identify - obtain IDENTIFY x DEVICE page
|
||||||
* @ap: port on which device we wish to probe resides
|
* @ap: port on which device we wish to probe resides
|
||||||
@ -5126,6 +5159,7 @@ EXPORT_SYMBOL_GPL(ata_dev_id_string);
|
|||||||
EXPORT_SYMBOL_GPL(ata_dev_config);
|
EXPORT_SYMBOL_GPL(ata_dev_config);
|
||||||
EXPORT_SYMBOL_GPL(ata_scsi_simulate);
|
EXPORT_SYMBOL_GPL(ata_scsi_simulate);
|
||||||
|
|
||||||
|
EXPORT_SYMBOL_GPL(ata_pio_need_iordy);
|
||||||
EXPORT_SYMBOL_GPL(ata_timing_compute);
|
EXPORT_SYMBOL_GPL(ata_timing_compute);
|
||||||
EXPORT_SYMBOL_GPL(ata_timing_merge);
|
EXPORT_SYMBOL_GPL(ata_timing_merge);
|
||||||
|
|
||||||
|
@ -499,6 +499,8 @@ extern int ata_scsi_slave_config(struct scsi_device *sdev);
|
|||||||
/*
|
/*
|
||||||
* Timing helpers
|
* Timing helpers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
extern unsigned int ata_pio_need_iordy(const struct ata_device *);
|
||||||
extern int ata_timing_compute(struct ata_device *, unsigned short,
|
extern int ata_timing_compute(struct ata_device *, unsigned short,
|
||||||
struct ata_timing *, int, int);
|
struct ata_timing *, int, int);
|
||||||
extern void ata_timing_merge(const struct ata_timing *,
|
extern void ata_timing_merge(const struct ata_timing *,
|
||||||
|
Reference in New Issue
Block a user