aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2006-01-09 12:18:14 -0500
committerJeff Garzik <jgarzik@pobox.com>2006-01-17 08:25:39 -0500
commit1bc4ccfff8675adc3d96f91245eb7e2dc0043ca9 (patch)
tree03bd5a2d64c52dff3c68a66e37f43b4109854170
parentffa29456cd316a5394cdd489de5af3bf87d3c485 (diff)
[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>
-rw-r--r--drivers/scsi/libata-core.c34
-rw-r--r--include/linux/libata.h2
2 files changed, 36 insertions, 0 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index bc48d88fef5a..b42acbe0e9a5 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -1169,6 +1169,39 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
1169} 1169}
1170 1170
1171/** 1171/**
1172 * ata_pio_need_iordy - check if iordy needed
1173 * @adev: ATA device
1174 *
1175 * Check if the current speed of the device requires IORDY. Used
1176 * by various controllers for chip configuration.
1177 */
1178
1179unsigned int ata_pio_need_iordy(const struct ata_device *adev)
1180{
1181 int pio;
1182 int speed = adev->pio_mode - XFER_PIO_0;
1183
1184 if (speed < 2)
1185 return 0;
1186 if (speed > 2)
1187 return 1;
1188
1189 /* If we have no drive specific rule, then PIO 2 is non IORDY */
1190
1191 if (adev->id[ATA_ID_FIELD_VALID] & 2) { /* EIDE */
1192 pio = adev->id[ATA_ID_EIDE_PIO];
1193 /* Is the speed faster than the drive allows non IORDY ? */
1194 if (pio) {
1195 /* This is cycle times not frequency - watch the logic! */
1196 if (pio > 240) /* PIO2 is 240nS per cycle */
1197 return 1;
1198 return 0;
1199 }
1200 }
1201 return 0;
1202}
1203
1204/**
1172 * ata_dev_identify - obtain IDENTIFY x DEVICE page 1205 * ata_dev_identify - obtain IDENTIFY x DEVICE page
1173 * @ap: port on which device we wish to probe resides 1206 * @ap: port on which device we wish to probe resides
1174 * @device: device bus address, starting at zero 1207 * @device: device bus address, starting at zero
@@ -5126,6 +5159,7 @@ EXPORT_SYMBOL_GPL(ata_dev_id_string);
5126EXPORT_SYMBOL_GPL(ata_dev_config); 5159EXPORT_SYMBOL_GPL(ata_dev_config);
5127EXPORT_SYMBOL_GPL(ata_scsi_simulate); 5160EXPORT_SYMBOL_GPL(ata_scsi_simulate);
5128 5161
5162EXPORT_SYMBOL_GPL(ata_pio_need_iordy);
5129EXPORT_SYMBOL_GPL(ata_timing_compute); 5163EXPORT_SYMBOL_GPL(ata_timing_compute);
5130EXPORT_SYMBOL_GPL(ata_timing_merge); 5164EXPORT_SYMBOL_GPL(ata_timing_merge);
5131 5165
diff --git a/include/linux/libata.h b/include/linux/libata.h
index a43c95f8f968..af6624450f65 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -499,6 +499,8 @@ extern int ata_scsi_slave_config(struct scsi_device *sdev);
499/* 499/*
500 * Timing helpers 500 * Timing helpers
501 */ 501 */
502
503extern unsigned int ata_pio_need_iordy(const struct ata_device *);
502extern int ata_timing_compute(struct ata_device *, unsigned short, 504extern int ata_timing_compute(struct ata_device *, unsigned short,
503 struct ata_timing *, int, int); 505 struct ata_timing *, int, int);
504extern void ata_timing_merge(const struct ata_timing *, 506extern void ata_timing_merge(const struct ata_timing *,