aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/sata_promise.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/sata_promise.c')
-rw-r--r--drivers/ata/sata_promise.c98
1 files changed, 42 insertions, 56 deletions
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index 7914def54fa3..a07d319f6e8c 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -450,19 +450,19 @@ 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)
457 */ 457 */
458 switch (qc->tf.protocol) { 458 switch (qc->tf.protocol) {
459 case ATA_PROT_ATAPI_DMA: 459 case ATAPI_PROT_DMA:
460 if (!(qc->tf.flags & ATA_TFLAG_WRITE)) 460 if (!(qc->tf.flags & ATA_TFLAG_WRITE))
461 buf32[0] = cpu_to_le32(PDC_PKT_READ); 461 buf32[0] = cpu_to_le32(PDC_PKT_READ);
462 else 462 else
463 buf32[0] = 0; 463 buf32[0] = 0;
464 break; 464 break;
465 case ATA_PROT_ATAPI_NODATA: 465 case ATAPI_PROT_NODATA:
466 buf32[0] = cpu_to_le32(PDC_PKT_NODATA); 466 buf32[0] = cpu_to_le32(PDC_PKT_NODATA);
467 break; 467 break;
468 default: 468 default:
@@ -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 != ATAPI_PROT_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;
@@ -541,17 +533,15 @@ static void pdc_fill_sg(struct ata_queued_cmd *qc)
541{ 533{
542 struct ata_port *ap = qc->ap; 534 struct ata_port *ap = qc->ap;
543 struct scatterlist *sg; 535 struct scatterlist *sg;
544 unsigned int idx;
545 const u32 SG_COUNT_ASIC_BUG = 41*4; 536 const u32 SG_COUNT_ASIC_BUG = 41*4;
537 unsigned int si, idx;
538 u32 len;
546 539
547 if (!(qc->flags & ATA_QCFLAG_DMAMAP)) 540 if (!(qc->flags & ATA_QCFLAG_DMAMAP))
548 return; 541 return;
549 542
550 WARN_ON(qc->__sg == NULL);
551 WARN_ON(qc->n_elem == 0 && qc->pad_len == 0);
552
553 idx = 0; 543 idx = 0;
554 ata_for_each_sg(sg, qc) { 544 for_each_sg(qc->sg, sg, qc->n_elem, si) {
555 u32 addr, offset; 545 u32 addr, offset;
556 u32 sg_len, len; 546 u32 sg_len, len;
557 547
@@ -578,29 +568,27 @@ static void pdc_fill_sg(struct ata_queued_cmd *qc)
578 } 568 }
579 } 569 }
580 570
581 if (idx) { 571 len = le32_to_cpu(ap->prd[idx - 1].flags_len);
582 u32 len = le32_to_cpu(ap->prd[idx - 1].flags_len);
583 572
584 if (len > SG_COUNT_ASIC_BUG) { 573 if (len > SG_COUNT_ASIC_BUG) {
585 u32 addr; 574 u32 addr;
586 575
587 VPRINTK("Splitting last PRD.\n"); 576 VPRINTK("Splitting last PRD.\n");
588 577
589 addr = le32_to_cpu(ap->prd[idx - 1].addr); 578 addr = le32_to_cpu(ap->prd[idx - 1].addr);
590 ap->prd[idx - 1].flags_len = cpu_to_le32(len - SG_COUNT_ASIC_BUG); 579 ap->prd[idx - 1].flags_len = cpu_to_le32(len - SG_COUNT_ASIC_BUG);
591 VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", idx - 1, addr, SG_COUNT_ASIC_BUG); 580 VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", idx - 1, addr, SG_COUNT_ASIC_BUG);
592 581
593 addr = addr + len - SG_COUNT_ASIC_BUG; 582 addr = addr + len - SG_COUNT_ASIC_BUG;
594 len = SG_COUNT_ASIC_BUG; 583 len = SG_COUNT_ASIC_BUG;
595 ap->prd[idx].addr = cpu_to_le32(addr); 584 ap->prd[idx].addr = cpu_to_le32(addr);
596 ap->prd[idx].flags_len = cpu_to_le32(len); 585 ap->prd[idx].flags_len = cpu_to_le32(len);
597 VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", idx, addr, len); 586 VPRINTK("PRD[%u] = (0x%X, 0x%X)\n", idx, addr, len);
598 587
599 idx++; 588 idx++;
600 }
601
602 ap->prd[idx - 1].flags_len |= cpu_to_le32(ATA_PRD_EOT);
603 } 589 }
590
591 ap->prd[idx - 1].flags_len |= cpu_to_le32(ATA_PRD_EOT);
604} 592}
605 593
606static void pdc_qc_prep(struct ata_queued_cmd *qc) 594static void pdc_qc_prep(struct ata_queued_cmd *qc)
@@ -627,14 +615,14 @@ static void pdc_qc_prep(struct ata_queued_cmd *qc)
627 pdc_pkt_footer(&qc->tf, pp->pkt, i); 615 pdc_pkt_footer(&qc->tf, pp->pkt, i);
628 break; 616 break;
629 617
630 case ATA_PROT_ATAPI: 618 case ATAPI_PROT_PIO:
631 pdc_fill_sg(qc); 619 pdc_fill_sg(qc);
632 break; 620 break;
633 621
634 case ATA_PROT_ATAPI_DMA: 622 case ATAPI_PROT_DMA:
635 pdc_fill_sg(qc); 623 pdc_fill_sg(qc);
636 /*FALLTHROUGH*/ 624 /*FALLTHROUGH*/
637 case ATA_PROT_ATAPI_NODATA: 625 case ATAPI_PROT_NODATA:
638 pdc_atapi_pkt(qc); 626 pdc_atapi_pkt(qc);
639 break; 627 break;
640 628
@@ -754,8 +742,8 @@ static inline unsigned int pdc_host_intr(struct ata_port *ap,
754 switch (qc->tf.protocol) { 742 switch (qc->tf.protocol) {
755 case ATA_PROT_DMA: 743 case ATA_PROT_DMA:
756 case ATA_PROT_NODATA: 744 case ATA_PROT_NODATA:
757 case ATA_PROT_ATAPI_DMA: 745 case ATAPI_PROT_DMA:
758 case ATA_PROT_ATAPI_NODATA: 746 case ATAPI_PROT_NODATA:
759 qc->err_mask |= ac_err_mask(ata_wait_idle(ap)); 747 qc->err_mask |= ac_err_mask(ata_wait_idle(ap));
760 ata_qc_complete(qc); 748 ata_qc_complete(qc);
761 handled = 1; 749 handled = 1;
@@ -900,7 +888,7 @@ static inline void pdc_packet_start(struct ata_queued_cmd *qc)
900static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc) 888static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc)
901{ 889{
902 switch (qc->tf.protocol) { 890 switch (qc->tf.protocol) {
903 case ATA_PROT_ATAPI_NODATA: 891 case ATAPI_PROT_NODATA:
904 if (qc->dev->flags & ATA_DFLAG_CDB_INTR) 892 if (qc->dev->flags & ATA_DFLAG_CDB_INTR)
905 break; 893 break;
906 /*FALLTHROUGH*/ 894 /*FALLTHROUGH*/
@@ -908,7 +896,7 @@ static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc)
908 if (qc->tf.flags & ATA_TFLAG_POLLING) 896 if (qc->tf.flags & ATA_TFLAG_POLLING)
909 break; 897 break;
910 /*FALLTHROUGH*/ 898 /*FALLTHROUGH*/
911 case ATA_PROT_ATAPI_DMA: 899 case ATAPI_PROT_DMA:
912 case ATA_PROT_DMA: 900 case ATA_PROT_DMA:
913 pdc_packet_start(qc); 901 pdc_packet_start(qc);
914 return 0; 902 return 0;
@@ -922,16 +910,14 @@ static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc)
922 910
923static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf) 911static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf)
924{ 912{
925 WARN_ON(tf->protocol == ATA_PROT_DMA || 913 WARN_ON(tf->protocol == ATA_PROT_DMA || tf->protocol == ATAPI_PROT_DMA);
926 tf->protocol == ATA_PROT_ATAPI_DMA);
927 ata_tf_load(ap, tf); 914 ata_tf_load(ap, tf);
928} 915}
929 916
930static void pdc_exec_command_mmio(struct ata_port *ap, 917static void pdc_exec_command_mmio(struct ata_port *ap,
931 const struct ata_taskfile *tf) 918 const struct ata_taskfile *tf)
932{ 919{
933 WARN_ON(tf->protocol == ATA_PROT_DMA || 920 WARN_ON(tf->protocol == ATA_PROT_DMA || tf->protocol == ATAPI_PROT_DMA);
934 tf->protocol == ATA_PROT_ATAPI_DMA);
935 ata_exec_command(ap, tf); 921 ata_exec_command(ap, tf);
936} 922}
937 923