aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/sata_promise.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-12-03 23:33:30 -0500
committerJeff Garzik <jeff@garzik.org>2008-01-23 05:24:12 -0500
commit46a671430dfa4ca59c7a69f01326e99edddb21bd (patch)
tree17096533f8ceaa9200d109728708fbcd658b2b8e /drivers/ata/sata_promise.c
parentc88f90c3779cd5e710f2acdf59ad2bd0380de98d (diff)
sata_promise: make pdc_atapi_pkt() use values from qc->tf
Make pdc_atapi_pkt() use values from qc->tf instead of creating its own. This is to ease future ATAPI handling changes. Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: Mikael Pettersson <mikpe@it.uu.se> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/sata_promise.c')
-rw-r--r--drivers/ata/sata_promise.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index 7914def54fa3..9638faaa8111 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -450,7 +450,7 @@ static void pdc_atapi_pkt(struct ata_queued_cmd *qc)
450 struct pdc_port_priv *pp = ap->private_data; 450 struct pdc_port_priv *pp = ap->private_data;
451 u8 *buf = pp->pkt; 451 u8 *buf = pp->pkt;
452 u32 *buf32 = (u32 *) buf; 452 u32 *buf32 = (u32 *) buf;
453 unsigned int dev_sel, feature, nbytes; 453 unsigned int dev_sel, feature;
454 454
455 /* set control bits (byte 0), zero delay seq id (byte 3), 455 /* set control bits (byte 0), zero delay seq id (byte 3),
456 * and seq id (byte 2) 456 * and seq id (byte 2)
@@ -473,45 +473,37 @@ static void pdc_atapi_pkt(struct ata_queued_cmd *qc)
473 buf32[2] = 0; /* no next-packet */ 473 buf32[2] = 0; /* no next-packet */
474 474
475 /* select drive */ 475 /* select drive */
476 if (sata_scr_valid(&ap->link)) { 476 if (sata_scr_valid(&ap->link))
477 dev_sel = PDC_DEVICE_SATA; 477 dev_sel = PDC_DEVICE_SATA;
478 } else { 478 else
479 dev_sel = ATA_DEVICE_OBS; 479 dev_sel = qc->tf.device;
480 if (qc->dev->devno != 0) 480
481 dev_sel |= ATA_DEV1;
482 }
483 buf[12] = (1 << 5) | ATA_REG_DEVICE; 481 buf[12] = (1 << 5) | ATA_REG_DEVICE;
484 buf[13] = dev_sel; 482 buf[13] = dev_sel;
485 buf[14] = (1 << 5) | ATA_REG_DEVICE | PDC_PKT_CLEAR_BSY; 483 buf[14] = (1 << 5) | ATA_REG_DEVICE | PDC_PKT_CLEAR_BSY;
486 buf[15] = dev_sel; /* once more, waiting for BSY to clear */ 484 buf[15] = dev_sel; /* once more, waiting for BSY to clear */
487 485
488 buf[16] = (1 << 5) | ATA_REG_NSECT; 486 buf[16] = (1 << 5) | ATA_REG_NSECT;
489 buf[17] = 0x00; 487 buf[17] = qc->tf.nsect;
490 buf[18] = (1 << 5) | ATA_REG_LBAL; 488 buf[18] = (1 << 5) | ATA_REG_LBAL;
491 buf[19] = 0x00; 489 buf[19] = qc->tf.lbal;
492 490
493 /* set feature and byte counter registers */ 491 /* set feature and byte counter registers */
494 if (qc->tf.protocol != ATA_PROT_ATAPI_DMA) { 492 if (qc->tf.protocol != ATA_PROT_ATAPI_DMA)
495 feature = PDC_FEATURE_ATAPI_PIO; 493 feature = PDC_FEATURE_ATAPI_PIO;
496 /* set byte counter register to real transfer byte count */ 494 else
497 nbytes = qc->nbytes;
498 if (nbytes > 0xffff)
499 nbytes = 0xffff;
500 } else {
501 feature = PDC_FEATURE_ATAPI_DMA; 495 feature = PDC_FEATURE_ATAPI_DMA;
502 /* set byte counter register to 0 */ 496
503 nbytes = 0;
504 }
505 buf[20] = (1 << 5) | ATA_REG_FEATURE; 497 buf[20] = (1 << 5) | ATA_REG_FEATURE;
506 buf[21] = feature; 498 buf[21] = feature;
507 buf[22] = (1 << 5) | ATA_REG_BYTEL; 499 buf[22] = (1 << 5) | ATA_REG_BYTEL;
508 buf[23] = nbytes & 0xFF; 500 buf[23] = qc->tf.lbam;
509 buf[24] = (1 << 5) | ATA_REG_BYTEH; 501 buf[24] = (1 << 5) | ATA_REG_BYTEH;
510 buf[25] = (nbytes >> 8) & 0xFF; 502 buf[25] = qc->tf.lbah;
511 503
512 /* send ATAPI packet command 0xA0 */ 504 /* send ATAPI packet command 0xA0 */
513 buf[26] = (1 << 5) | ATA_REG_CMD; 505 buf[26] = (1 << 5) | ATA_REG_CMD;
514 buf[27] = ATA_CMD_PACKET; 506 buf[27] = qc->tf.command;
515 507
516 /* select drive and check DRQ */ 508 /* select drive and check DRQ */
517 buf[28] = (1 << 5) | ATA_REG_DEVICE | PDC_PKT_WAIT_DRDY; 509 buf[28] = (1 << 5) | ATA_REG_DEVICE | PDC_PKT_WAIT_DRDY;