aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-core.c
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2007-03-08 18:22:59 -0500
committerJeff Garzik <jeff@garzik.org>2007-04-28 14:15:58 -0400
commit432729f0b0c299ae9731aaa31beaa0dd3a9751eb (patch)
tree39a9cc9762136e2f049b6081637b6daf5fa1e882 /drivers/ata/libata-core.c
parent04351821b43e6c0c91ad50d7e4be54a935f749e1 (diff)
libata-core: Fix the iordy methods
This alone isn't sufficient to save the universe from prehistoric disks and controllers but it is a first important step. Split off a separate function to provide a mode filter when controller iordy is not available. Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/libata-core.c')
-rw-r--r--drivers/ata/libata-core.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 14b469f7b23e..d01bb5d50fcc 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1379,30 +1379,44 @@ unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd)
1379 * Check if the current speed of the device requires IORDY. Used 1379 * Check if the current speed of the device requires IORDY. Used
1380 * by various controllers for chip configuration. 1380 * by various controllers for chip configuration.
1381 */ 1381 */
1382 1382
1383unsigned int ata_pio_need_iordy(const struct ata_device *adev) 1383unsigned int ata_pio_need_iordy(const struct ata_device *adev)
1384{ 1384{
1385 int pio; 1385 /* Controller doesn't support IORDY. Probably a pointless check
1386 int speed = adev->pio_mode - XFER_PIO_0; 1386 as the caller should know this */
1387 1387 if (adev->ap->flags & ATA_FLAG_NO_IORDY)
1388 if (speed < 2)
1389 return 0; 1388 return 0;
1390 if (speed > 2) 1389 /* PIO3 and higher it is mandatory */
1390 if (adev->pio_mode > XFER_PIO_2)
1391 return 1; 1391 return 1;
1392 /* We turn it on when possible */
1393 if (ata_id_has_iordy(adev->id))
1394 return 1;
1395 return 0;
1396}
1392 1397
1398/**
1399 * ata_pio_mask_no_iordy - Return the non IORDY mask
1400 * @adev: ATA device
1401 *
1402 * Compute the highest mode possible if we are not using iordy. Return
1403 * -1 if no iordy mode is available.
1404 */
1405
1406static u32 ata_pio_mask_no_iordy(const struct ata_device *adev)
1407{
1393 /* If we have no drive specific rule, then PIO 2 is non IORDY */ 1408 /* If we have no drive specific rule, then PIO 2 is non IORDY */
1394
1395 if (adev->id[ATA_ID_FIELD_VALID] & 2) { /* EIDE */ 1409 if (adev->id[ATA_ID_FIELD_VALID] & 2) { /* EIDE */
1396 pio = adev->id[ATA_ID_EIDE_PIO]; 1410 u16 pio = adev->id[ATA_ID_EIDE_PIO];
1397 /* Is the speed faster than the drive allows non IORDY ? */ 1411 /* Is the speed faster than the drive allows non IORDY ? */
1398 if (pio) { 1412 if (pio) {
1399 /* This is cycle times not frequency - watch the logic! */ 1413 /* This is cycle times not frequency - watch the logic! */
1400 if (pio > 240) /* PIO2 is 240nS per cycle */ 1414 if (pio > 240) /* PIO2 is 240nS per cycle */
1401 return 1; 1415 return 3 << ATA_SHIFT_PIO;
1402 return 0; 1416 return 7 << ATA_SHIFT_PIO;
1403 } 1417 }
1404 } 1418 }
1405 return 0; 1419 return 3 << ATA_SHIFT_PIO;
1406} 1420}
1407 1421
1408/** 1422/**