diff options
author | Jaroslav Kysela <perex@suse.cz> | 2006-03-22 05:02:08 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-03-22 05:02:08 -0500 |
commit | 5501972e0b5857bc8354770d900ceb9b40c7f6b7 (patch) | |
tree | ff239422827c4cd54d2998f8851304255de31b38 /drivers/scsi/sata_mv.c | |
parent | 9d2f928ddf64ca0361562e30faf584cd33055c60 (diff) | |
parent | e952f31bce6e9f64db01f607abc46529ba57ac9e (diff) |
Merge with rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Diffstat (limited to 'drivers/scsi/sata_mv.c')
-rw-r--r-- | drivers/scsi/sata_mv.c | 281 |
1 files changed, 227 insertions, 54 deletions
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c index 2770005324b4..e561281967dd 100644 --- a/drivers/scsi/sata_mv.c +++ b/drivers/scsi/sata_mv.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <asm/io.h> | 37 | #include <asm/io.h> |
38 | 38 | ||
39 | #define DRV_NAME "sata_mv" | 39 | #define DRV_NAME "sata_mv" |
40 | #define DRV_VERSION "0.5" | 40 | #define DRV_VERSION "0.6" |
41 | 41 | ||
42 | enum { | 42 | enum { |
43 | /* BAR's are enumerated in terms of pci_resource_start() terms */ | 43 | /* BAR's are enumerated in terms of pci_resource_start() terms */ |
@@ -228,7 +228,9 @@ enum { | |||
228 | MV_HP_ERRATA_50XXB2 = (1 << 2), | 228 | MV_HP_ERRATA_50XXB2 = (1 << 2), |
229 | MV_HP_ERRATA_60X1B2 = (1 << 3), | 229 | MV_HP_ERRATA_60X1B2 = (1 << 3), |
230 | MV_HP_ERRATA_60X1C0 = (1 << 4), | 230 | MV_HP_ERRATA_60X1C0 = (1 << 4), |
231 | MV_HP_50XX = (1 << 5), | 231 | MV_HP_ERRATA_XX42A0 = (1 << 5), |
232 | MV_HP_50XX = (1 << 6), | ||
233 | MV_HP_GEN_IIE = (1 << 7), | ||
232 | 234 | ||
233 | /* Port private flags (pp_flags) */ | 235 | /* Port private flags (pp_flags) */ |
234 | MV_PP_FLAG_EDMA_EN = (1 << 0), | 236 | MV_PP_FLAG_EDMA_EN = (1 << 0), |
@@ -237,6 +239,9 @@ enum { | |||
237 | 239 | ||
238 | #define IS_50XX(hpriv) ((hpriv)->hp_flags & MV_HP_50XX) | 240 | #define IS_50XX(hpriv) ((hpriv)->hp_flags & MV_HP_50XX) |
239 | #define IS_60XX(hpriv) (((hpriv)->hp_flags & MV_HP_50XX) == 0) | 241 | #define IS_60XX(hpriv) (((hpriv)->hp_flags & MV_HP_50XX) == 0) |
242 | #define IS_GEN_I(hpriv) IS_50XX(hpriv) | ||
243 | #define IS_GEN_II(hpriv) IS_60XX(hpriv) | ||
244 | #define IS_GEN_IIE(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_IIE) | ||
240 | 245 | ||
241 | enum { | 246 | enum { |
242 | /* Our DMA boundary is determined by an ePRD being unable to handle | 247 | /* Our DMA boundary is determined by an ePRD being unable to handle |
@@ -255,6 +260,8 @@ enum chip_type { | |||
255 | chip_5080, | 260 | chip_5080, |
256 | chip_604x, | 261 | chip_604x, |
257 | chip_608x, | 262 | chip_608x, |
263 | chip_6042, | ||
264 | chip_7042, | ||
258 | }; | 265 | }; |
259 | 266 | ||
260 | /* Command ReQuest Block: 32B */ | 267 | /* Command ReQuest Block: 32B */ |
@@ -265,6 +272,14 @@ struct mv_crqb { | |||
265 | u16 ata_cmd[11]; | 272 | u16 ata_cmd[11]; |
266 | }; | 273 | }; |
267 | 274 | ||
275 | struct mv_crqb_iie { | ||
276 | u32 addr; | ||
277 | u32 addr_hi; | ||
278 | u32 flags; | ||
279 | u32 len; | ||
280 | u32 ata_cmd[4]; | ||
281 | }; | ||
282 | |||
268 | /* Command ResPonse Block: 8B */ | 283 | /* Command ResPonse Block: 8B */ |
269 | struct mv_crpb { | 284 | struct mv_crpb { |
270 | u16 id; | 285 | u16 id; |
@@ -328,7 +343,8 @@ static void mv_host_stop(struct ata_host_set *host_set); | |||
328 | static int mv_port_start(struct ata_port *ap); | 343 | static int mv_port_start(struct ata_port *ap); |
329 | static void mv_port_stop(struct ata_port *ap); | 344 | static void mv_port_stop(struct ata_port *ap); |
330 | static void mv_qc_prep(struct ata_queued_cmd *qc); | 345 | static void mv_qc_prep(struct ata_queued_cmd *qc); |
331 | static int mv_qc_issue(struct ata_queued_cmd *qc); | 346 | static void mv_qc_prep_iie(struct ata_queued_cmd *qc); |
347 | static unsigned int mv_qc_issue(struct ata_queued_cmd *qc); | ||
332 | static irqreturn_t mv_interrupt(int irq, void *dev_instance, | 348 | static irqreturn_t mv_interrupt(int irq, void *dev_instance, |
333 | struct pt_regs *regs); | 349 | struct pt_regs *regs); |
334 | static void mv_eng_timeout(struct ata_port *ap); | 350 | static void mv_eng_timeout(struct ata_port *ap); |
@@ -362,11 +378,11 @@ static struct scsi_host_template mv_sht = { | |||
362 | .name = DRV_NAME, | 378 | .name = DRV_NAME, |
363 | .ioctl = ata_scsi_ioctl, | 379 | .ioctl = ata_scsi_ioctl, |
364 | .queuecommand = ata_scsi_queuecmd, | 380 | .queuecommand = ata_scsi_queuecmd, |
381 | .eh_timed_out = ata_scsi_timed_out, | ||
365 | .eh_strategy_handler = ata_scsi_error, | 382 | .eh_strategy_handler = ata_scsi_error, |
366 | .can_queue = MV_USE_Q_DEPTH, | 383 | .can_queue = MV_USE_Q_DEPTH, |
367 | .this_id = ATA_SHT_THIS_ID, | 384 | .this_id = ATA_SHT_THIS_ID, |
368 | .sg_tablesize = MV_MAX_SG_CT / 2, | 385 | .sg_tablesize = MV_MAX_SG_CT / 2, |
369 | .max_sectors = ATA_MAX_SECTORS, | ||
370 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, | 386 | .cmd_per_lun = ATA_SHT_CMD_PER_LUN, |
371 | .emulated = ATA_SHT_EMULATED, | 387 | .emulated = ATA_SHT_EMULATED, |
372 | .use_clustering = ATA_SHT_USE_CLUSTERING, | 388 | .use_clustering = ATA_SHT_USE_CLUSTERING, |
@@ -430,6 +446,33 @@ static const struct ata_port_operations mv6_ops = { | |||
430 | .host_stop = mv_host_stop, | 446 | .host_stop = mv_host_stop, |
431 | }; | 447 | }; |
432 | 448 | ||
449 | static const struct ata_port_operations mv_iie_ops = { | ||
450 | .port_disable = ata_port_disable, | ||
451 | |||
452 | .tf_load = ata_tf_load, | ||
453 | .tf_read = ata_tf_read, | ||
454 | .check_status = ata_check_status, | ||
455 | .exec_command = ata_exec_command, | ||
456 | .dev_select = ata_std_dev_select, | ||
457 | |||
458 | .phy_reset = mv_phy_reset, | ||
459 | |||
460 | .qc_prep = mv_qc_prep_iie, | ||
461 | .qc_issue = mv_qc_issue, | ||
462 | |||
463 | .eng_timeout = mv_eng_timeout, | ||
464 | |||
465 | .irq_handler = mv_interrupt, | ||
466 | .irq_clear = mv_irq_clear, | ||
467 | |||
468 | .scr_read = mv_scr_read, | ||
469 | .scr_write = mv_scr_write, | ||
470 | |||
471 | .port_start = mv_port_start, | ||
472 | .port_stop = mv_port_stop, | ||
473 | .host_stop = mv_host_stop, | ||
474 | }; | ||
475 | |||
433 | static const struct ata_port_info mv_port_info[] = { | 476 | static const struct ata_port_info mv_port_info[] = { |
434 | { /* chip_504x */ | 477 | { /* chip_504x */ |
435 | .sht = &mv_sht, | 478 | .sht = &mv_sht, |
@@ -467,6 +510,21 @@ static const struct ata_port_info mv_port_info[] = { | |||
467 | .udma_mask = 0x7f, /* udma0-6 */ | 510 | .udma_mask = 0x7f, /* udma0-6 */ |
468 | .port_ops = &mv6_ops, | 511 | .port_ops = &mv6_ops, |
469 | }, | 512 | }, |
513 | { /* chip_6042 */ | ||
514 | .sht = &mv_sht, | ||
515 | .host_flags = (MV_COMMON_FLAGS | MV_6XXX_FLAGS), | ||
516 | .pio_mask = 0x1f, /* pio0-4 */ | ||
517 | .udma_mask = 0x7f, /* udma0-6 */ | ||
518 | .port_ops = &mv_iie_ops, | ||
519 | }, | ||
520 | { /* chip_7042 */ | ||
521 | .sht = &mv_sht, | ||
522 | .host_flags = (MV_COMMON_FLAGS | MV_6XXX_FLAGS | | ||
523 | MV_FLAG_DUAL_HC), | ||
524 | .pio_mask = 0x1f, /* pio0-4 */ | ||
525 | .udma_mask = 0x7f, /* udma0-6 */ | ||
526 | .port_ops = &mv_iie_ops, | ||
527 | }, | ||
470 | }; | 528 | }; |
471 | 529 | ||
472 | static const struct pci_device_id mv_pci_tbl[] = { | 530 | static const struct pci_device_id mv_pci_tbl[] = { |
@@ -477,6 +535,7 @@ static const struct pci_device_id mv_pci_tbl[] = { | |||
477 | 535 | ||
478 | {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6040), 0, 0, chip_604x}, | 536 | {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6040), 0, 0, chip_604x}, |
479 | {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6041), 0, 0, chip_604x}, | 537 | {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6041), 0, 0, chip_604x}, |
538 | {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6042), 0, 0, chip_6042}, | ||
480 | {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6080), 0, 0, chip_608x}, | 539 | {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6080), 0, 0, chip_608x}, |
481 | {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6081), 0, 0, chip_608x}, | 540 | {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6081), 0, 0, chip_608x}, |
482 | 541 | ||
@@ -572,8 +631,8 @@ static void mv_irq_clear(struct ata_port *ap) | |||
572 | * @base: port base address | 631 | * @base: port base address |
573 | * @pp: port private data | 632 | * @pp: port private data |
574 | * | 633 | * |
575 | * Verify the local cache of the eDMA state is accurate with an | 634 | * Verify the local cache of the eDMA state is accurate with a |
576 | * assert. | 635 | * WARN_ON. |
577 | * | 636 | * |
578 | * LOCKING: | 637 | * LOCKING: |
579 | * Inherited from caller. | 638 | * Inherited from caller. |
@@ -584,15 +643,15 @@ static void mv_start_dma(void __iomem *base, struct mv_port_priv *pp) | |||
584 | writelfl(EDMA_EN, base + EDMA_CMD_OFS); | 643 | writelfl(EDMA_EN, base + EDMA_CMD_OFS); |
585 | pp->pp_flags |= MV_PP_FLAG_EDMA_EN; | 644 | pp->pp_flags |= MV_PP_FLAG_EDMA_EN; |
586 | } | 645 | } |
587 | assert(EDMA_EN & readl(base + EDMA_CMD_OFS)); | 646 | WARN_ON(!(EDMA_EN & readl(base + EDMA_CMD_OFS))); |
588 | } | 647 | } |
589 | 648 | ||
590 | /** | 649 | /** |
591 | * mv_stop_dma - Disable eDMA engine | 650 | * mv_stop_dma - Disable eDMA engine |
592 | * @ap: ATA channel to manipulate | 651 | * @ap: ATA channel to manipulate |
593 | * | 652 | * |
594 | * Verify the local cache of the eDMA state is accurate with an | 653 | * Verify the local cache of the eDMA state is accurate with a |
595 | * assert. | 654 | * WARN_ON. |
596 | * | 655 | * |
597 | * LOCKING: | 656 | * LOCKING: |
598 | * Inherited from caller. | 657 | * Inherited from caller. |
@@ -610,7 +669,7 @@ static void mv_stop_dma(struct ata_port *ap) | |||
610 | writelfl(EDMA_DS, port_mmio + EDMA_CMD_OFS); | 669 | writelfl(EDMA_DS, port_mmio + EDMA_CMD_OFS); |
611 | pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN; | 670 | pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN; |
612 | } else { | 671 | } else { |
613 | assert(!(EDMA_EN & readl(port_mmio + EDMA_CMD_OFS))); | 672 | WARN_ON(EDMA_EN & readl(port_mmio + EDMA_CMD_OFS)); |
614 | } | 673 | } |
615 | 674 | ||
616 | /* now properly wait for the eDMA to stop */ | 675 | /* now properly wait for the eDMA to stop */ |
@@ -773,6 +832,33 @@ static inline void mv_priv_free(struct mv_port_priv *pp, struct device *dev) | |||
773 | dma_free_coherent(dev, MV_PORT_PRIV_DMA_SZ, pp->crpb, pp->crpb_dma); | 832 | dma_free_coherent(dev, MV_PORT_PRIV_DMA_SZ, pp->crpb, pp->crpb_dma); |
774 | } | 833 | } |
775 | 834 | ||
835 | static void mv_edma_cfg(struct mv_host_priv *hpriv, void __iomem *port_mmio) | ||
836 | { | ||
837 | u32 cfg = readl(port_mmio + EDMA_CFG_OFS); | ||
838 | |||
839 | /* set up non-NCQ EDMA configuration */ | ||
840 | cfg &= ~0x1f; /* clear queue depth */ | ||
841 | cfg &= ~EDMA_CFG_NCQ; /* clear NCQ mode */ | ||
842 | cfg &= ~(1 << 9); /* disable equeue */ | ||
843 | |||
844 | if (IS_GEN_I(hpriv)) | ||
845 | cfg |= (1 << 8); /* enab config burst size mask */ | ||
846 | |||
847 | else if (IS_GEN_II(hpriv)) | ||
848 | cfg |= EDMA_CFG_RD_BRST_EXT | EDMA_CFG_WR_BUFF_LEN; | ||
849 | |||
850 | else if (IS_GEN_IIE(hpriv)) { | ||
851 | cfg |= (1 << 23); /* dis RX PM port mask */ | ||
852 | cfg &= ~(1 << 16); /* dis FIS-based switching (for now) */ | ||
853 | cfg &= ~(1 << 19); /* dis 128-entry queue (for now?) */ | ||
854 | cfg |= (1 << 18); /* enab early completion */ | ||
855 | cfg |= (1 << 17); /* enab host q cache */ | ||
856 | cfg |= (1 << 22); /* enab cutthrough */ | ||
857 | } | ||
858 | |||
859 | writelfl(cfg, port_mmio + EDMA_CFG_OFS); | ||
860 | } | ||
861 | |||
776 | /** | 862 | /** |
777 | * mv_port_start - Port specific init/start routine. | 863 | * mv_port_start - Port specific init/start routine. |
778 | * @ap: ATA channel to manipulate | 864 | * @ap: ATA channel to manipulate |
@@ -786,6 +872,7 @@ static inline void mv_priv_free(struct mv_port_priv *pp, struct device *dev) | |||
786 | static int mv_port_start(struct ata_port *ap) | 872 | static int mv_port_start(struct ata_port *ap) |
787 | { | 873 | { |
788 | struct device *dev = ap->host_set->dev; | 874 | struct device *dev = ap->host_set->dev; |
875 | struct mv_host_priv *hpriv = ap->host_set->private_data; | ||
789 | struct mv_port_priv *pp; | 876 | struct mv_port_priv *pp; |
790 | void __iomem *port_mmio = mv_ap_base(ap); | 877 | void __iomem *port_mmio = mv_ap_base(ap); |
791 | void *mem; | 878 | void *mem; |
@@ -829,17 +916,26 @@ static int mv_port_start(struct ata_port *ap) | |||
829 | pp->sg_tbl = mem; | 916 | pp->sg_tbl = mem; |
830 | pp->sg_tbl_dma = mem_dma; | 917 | pp->sg_tbl_dma = mem_dma; |
831 | 918 | ||
832 | writelfl(EDMA_CFG_Q_DEPTH | EDMA_CFG_RD_BRST_EXT | | 919 | mv_edma_cfg(hpriv, port_mmio); |
833 | EDMA_CFG_WR_BUFF_LEN, port_mmio + EDMA_CFG_OFS); | ||
834 | 920 | ||
835 | writel((pp->crqb_dma >> 16) >> 16, port_mmio + EDMA_REQ_Q_BASE_HI_OFS); | 921 | writel((pp->crqb_dma >> 16) >> 16, port_mmio + EDMA_REQ_Q_BASE_HI_OFS); |
836 | writelfl(pp->crqb_dma & EDMA_REQ_Q_BASE_LO_MASK, | 922 | writelfl(pp->crqb_dma & EDMA_REQ_Q_BASE_LO_MASK, |
837 | port_mmio + EDMA_REQ_Q_IN_PTR_OFS); | 923 | port_mmio + EDMA_REQ_Q_IN_PTR_OFS); |
838 | 924 | ||
839 | writelfl(0, port_mmio + EDMA_REQ_Q_OUT_PTR_OFS); | 925 | if (hpriv->hp_flags & MV_HP_ERRATA_XX42A0) |
840 | writelfl(0, port_mmio + EDMA_RSP_Q_IN_PTR_OFS); | 926 | writelfl(pp->crqb_dma & 0xffffffff, |
927 | port_mmio + EDMA_REQ_Q_OUT_PTR_OFS); | ||
928 | else | ||
929 | writelfl(0, port_mmio + EDMA_REQ_Q_OUT_PTR_OFS); | ||
841 | 930 | ||
842 | writel((pp->crpb_dma >> 16) >> 16, port_mmio + EDMA_RSP_Q_BASE_HI_OFS); | 931 | writel((pp->crpb_dma >> 16) >> 16, port_mmio + EDMA_RSP_Q_BASE_HI_OFS); |
932 | |||
933 | if (hpriv->hp_flags & MV_HP_ERRATA_XX42A0) | ||
934 | writelfl(pp->crpb_dma & 0xffffffff, | ||
935 | port_mmio + EDMA_RSP_Q_IN_PTR_OFS); | ||
936 | else | ||
937 | writelfl(0, port_mmio + EDMA_RSP_Q_IN_PTR_OFS); | ||
938 | |||
843 | writelfl(pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK, | 939 | writelfl(pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK, |
844 | port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); | 940 | port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); |
845 | 941 | ||
@@ -960,21 +1056,19 @@ static void mv_qc_prep(struct ata_queued_cmd *qc) | |||
960 | struct ata_taskfile *tf; | 1056 | struct ata_taskfile *tf; |
961 | u16 flags = 0; | 1057 | u16 flags = 0; |
962 | 1058 | ||
963 | if (ATA_PROT_DMA != qc->tf.protocol) { | 1059 | if (ATA_PROT_DMA != qc->tf.protocol) |
964 | return; | 1060 | return; |
965 | } | ||
966 | 1061 | ||
967 | /* the req producer index should be the same as we remember it */ | 1062 | /* the req producer index should be the same as we remember it */ |
968 | assert(((readl(mv_ap_base(qc->ap) + EDMA_REQ_Q_IN_PTR_OFS) >> | 1063 | WARN_ON(((readl(mv_ap_base(qc->ap) + EDMA_REQ_Q_IN_PTR_OFS) >> |
969 | EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) == | 1064 | EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) != |
970 | pp->req_producer); | 1065 | pp->req_producer); |
971 | 1066 | ||
972 | /* Fill in command request block | 1067 | /* Fill in command request block |
973 | */ | 1068 | */ |
974 | if (!(qc->tf.flags & ATA_TFLAG_WRITE)) { | 1069 | if (!(qc->tf.flags & ATA_TFLAG_WRITE)) |
975 | flags |= CRQB_FLAG_READ; | 1070 | flags |= CRQB_FLAG_READ; |
976 | } | 1071 | WARN_ON(MV_MAX_Q_DEPTH <= qc->tag); |
977 | assert(MV_MAX_Q_DEPTH > qc->tag); | ||
978 | flags |= qc->tag << CRQB_TAG_SHIFT; | 1072 | flags |= qc->tag << CRQB_TAG_SHIFT; |
979 | 1073 | ||
980 | pp->crqb[pp->req_producer].sg_addr = | 1074 | pp->crqb[pp->req_producer].sg_addr = |
@@ -1029,9 +1123,76 @@ static void mv_qc_prep(struct ata_queued_cmd *qc) | |||
1029 | mv_crqb_pack_cmd(cw++, tf->device, ATA_REG_DEVICE, 0); | 1123 | mv_crqb_pack_cmd(cw++, tf->device, ATA_REG_DEVICE, 0); |
1030 | mv_crqb_pack_cmd(cw++, tf->command, ATA_REG_CMD, 1); /* last */ | 1124 | mv_crqb_pack_cmd(cw++, tf->command, ATA_REG_CMD, 1); /* last */ |
1031 | 1125 | ||
1032 | if (!(qc->flags & ATA_QCFLAG_DMAMAP)) { | 1126 | if (!(qc->flags & ATA_QCFLAG_DMAMAP)) |
1127 | return; | ||
1128 | mv_fill_sg(qc); | ||
1129 | } | ||
1130 | |||
1131 | /** | ||
1132 | * mv_qc_prep_iie - Host specific command preparation. | ||
1133 | * @qc: queued command to prepare | ||
1134 | * | ||
1135 | * This routine simply redirects to the general purpose routine | ||
1136 | * if command is not DMA. Else, it handles prep of the CRQB | ||
1137 | * (command request block), does some sanity checking, and calls | ||
1138 | * the SG load routine. | ||
1139 | * | ||
1140 | * LOCKING: | ||
1141 | * Inherited from caller. | ||
1142 | */ | ||
1143 | static void mv_qc_prep_iie(struct ata_queued_cmd *qc) | ||
1144 | { | ||
1145 | struct ata_port *ap = qc->ap; | ||
1146 | struct mv_port_priv *pp = ap->private_data; | ||
1147 | struct mv_crqb_iie *crqb; | ||
1148 | struct ata_taskfile *tf; | ||
1149 | u32 flags = 0; | ||
1150 | |||
1151 | if (ATA_PROT_DMA != qc->tf.protocol) | ||
1152 | return; | ||
1153 | |||
1154 | /* the req producer index should be the same as we remember it */ | ||
1155 | WARN_ON(((readl(mv_ap_base(qc->ap) + EDMA_REQ_Q_IN_PTR_OFS) >> | ||
1156 | EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) != | ||
1157 | pp->req_producer); | ||
1158 | |||
1159 | /* Fill in Gen IIE command request block | ||
1160 | */ | ||
1161 | if (!(qc->tf.flags & ATA_TFLAG_WRITE)) | ||
1162 | flags |= CRQB_FLAG_READ; | ||
1163 | |||
1164 | WARN_ON(MV_MAX_Q_DEPTH <= qc->tag); | ||
1165 | flags |= qc->tag << CRQB_TAG_SHIFT; | ||
1166 | |||
1167 | crqb = (struct mv_crqb_iie *) &pp->crqb[pp->req_producer]; | ||
1168 | crqb->addr = cpu_to_le32(pp->sg_tbl_dma & 0xffffffff); | ||
1169 | crqb->addr_hi = cpu_to_le32((pp->sg_tbl_dma >> 16) >> 16); | ||
1170 | crqb->flags = cpu_to_le32(flags); | ||
1171 | |||
1172 | tf = &qc->tf; | ||
1173 | crqb->ata_cmd[0] = cpu_to_le32( | ||
1174 | (tf->command << 16) | | ||
1175 | (tf->feature << 24) | ||
1176 | ); | ||
1177 | crqb->ata_cmd[1] = cpu_to_le32( | ||
1178 | (tf->lbal << 0) | | ||
1179 | (tf->lbam << 8) | | ||
1180 | (tf->lbah << 16) | | ||
1181 | (tf->device << 24) | ||
1182 | ); | ||
1183 | crqb->ata_cmd[2] = cpu_to_le32( | ||
1184 | (tf->hob_lbal << 0) | | ||
1185 | (tf->hob_lbam << 8) | | ||
1186 | (tf->hob_lbah << 16) | | ||
1187 | (tf->hob_feature << 24) | ||
1188 | ); | ||
1189 | crqb->ata_cmd[3] = cpu_to_le32( | ||
1190 | (tf->nsect << 0) | | ||
1191 | (tf->hob_nsect << 8) | ||
1192 | ); | ||
1193 | |||
1194 | if (!(qc->flags & ATA_QCFLAG_DMAMAP)) | ||
1033 | return; | 1195 | return; |
1034 | } | ||
1035 | mv_fill_sg(qc); | 1196 | mv_fill_sg(qc); |
1036 | } | 1197 | } |
1037 | 1198 | ||
@@ -1047,7 +1208,7 @@ static void mv_qc_prep(struct ata_queued_cmd *qc) | |||
1047 | * LOCKING: | 1208 | * LOCKING: |
1048 | * Inherited from caller. | 1209 | * Inherited from caller. |
1049 | */ | 1210 | */ |
1050 | static int mv_qc_issue(struct ata_queued_cmd *qc) | 1211 | static unsigned int mv_qc_issue(struct ata_queued_cmd *qc) |
1051 | { | 1212 | { |
1052 | void __iomem *port_mmio = mv_ap_base(qc->ap); | 1213 | void __iomem *port_mmio = mv_ap_base(qc->ap); |
1053 | struct mv_port_priv *pp = qc->ap->private_data; | 1214 | struct mv_port_priv *pp = qc->ap->private_data; |
@@ -1065,12 +1226,12 @@ static int mv_qc_issue(struct ata_queued_cmd *qc) | |||
1065 | in_ptr = readl(port_mmio + EDMA_REQ_Q_IN_PTR_OFS); | 1226 | in_ptr = readl(port_mmio + EDMA_REQ_Q_IN_PTR_OFS); |
1066 | 1227 | ||
1067 | /* the req producer index should be the same as we remember it */ | 1228 | /* the req producer index should be the same as we remember it */ |
1068 | assert(((in_ptr >> EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) == | 1229 | WARN_ON(((in_ptr >> EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) != |
1069 | pp->req_producer); | 1230 | pp->req_producer); |
1070 | /* until we do queuing, the queue should be empty at this point */ | 1231 | /* until we do queuing, the queue should be empty at this point */ |
1071 | assert(((in_ptr >> EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) == | 1232 | WARN_ON(((in_ptr >> EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) != |
1072 | ((readl(port_mmio + EDMA_REQ_Q_OUT_PTR_OFS) >> | 1233 | ((readl(port_mmio + EDMA_REQ_Q_OUT_PTR_OFS) >> |
1073 | EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK)); | 1234 | EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK)); |
1074 | 1235 | ||
1075 | mv_inc_q_index(&pp->req_producer); /* now incr producer index */ | 1236 | mv_inc_q_index(&pp->req_producer); /* now incr producer index */ |
1076 | 1237 | ||
@@ -1090,7 +1251,7 @@ static int mv_qc_issue(struct ata_queued_cmd *qc) | |||
1090 | * | 1251 | * |
1091 | * This routine is for use when the port is in DMA mode, when it | 1252 | * This routine is for use when the port is in DMA mode, when it |
1092 | * will be using the CRPB (command response block) method of | 1253 | * will be using the CRPB (command response block) method of |
1093 | * returning command completion information. We assert indices | 1254 | * returning command completion information. We check indices |
1094 | * are good, grab status, and bump the response consumer index to | 1255 | * are good, grab status, and bump the response consumer index to |
1095 | * prove that we're up to date. | 1256 | * prove that we're up to date. |
1096 | * | 1257 | * |
@@ -1106,16 +1267,16 @@ static u8 mv_get_crpb_status(struct ata_port *ap) | |||
1106 | out_ptr = readl(port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); | 1267 | out_ptr = readl(port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); |
1107 | 1268 | ||
1108 | /* the response consumer index should be the same as we remember it */ | 1269 | /* the response consumer index should be the same as we remember it */ |
1109 | assert(((out_ptr >> EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) == | 1270 | WARN_ON(((out_ptr >> EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) != |
1110 | pp->rsp_consumer); | 1271 | pp->rsp_consumer); |
1111 | 1272 | ||
1112 | /* increment our consumer index... */ | 1273 | /* increment our consumer index... */ |
1113 | pp->rsp_consumer = mv_inc_q_index(&pp->rsp_consumer); | 1274 | pp->rsp_consumer = mv_inc_q_index(&pp->rsp_consumer); |
1114 | 1275 | ||
1115 | /* and, until we do NCQ, there should only be 1 CRPB waiting */ | 1276 | /* and, until we do NCQ, there should only be 1 CRPB waiting */ |
1116 | assert(((readl(port_mmio + EDMA_RSP_Q_IN_PTR_OFS) >> | 1277 | WARN_ON(((readl(port_mmio + EDMA_RSP_Q_IN_PTR_OFS) >> |
1117 | EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) == | 1278 | EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) != |
1118 | pp->rsp_consumer); | 1279 | pp->rsp_consumer); |
1119 | 1280 | ||
1120 | /* write out our inc'd consumer index so EDMA knows we're caught up */ | 1281 | /* write out our inc'd consumer index so EDMA knows we're caught up */ |
1121 | out_ptr &= EDMA_RSP_Q_BASE_LO_MASK; | 1282 | out_ptr &= EDMA_RSP_Q_BASE_LO_MASK; |
@@ -1192,7 +1353,6 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, | |||
1192 | u32 hc_irq_cause; | 1353 | u32 hc_irq_cause; |
1193 | int shift, port, port0, hard_port, handled; | 1354 | int shift, port, port0, hard_port, handled; |
1194 | unsigned int err_mask; | 1355 | unsigned int err_mask; |
1195 | u8 ata_status = 0; | ||
1196 | 1356 | ||
1197 | if (hc == 0) { | 1357 | if (hc == 0) { |
1198 | port0 = 0; | 1358 | port0 = 0; |
@@ -1210,6 +1370,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, | |||
1210 | hc,relevant,hc_irq_cause); | 1370 | hc,relevant,hc_irq_cause); |
1211 | 1371 | ||
1212 | for (port = port0; port < port0 + MV_PORTS_PER_HC; port++) { | 1372 | for (port = port0; port < port0 + MV_PORTS_PER_HC; port++) { |
1373 | u8 ata_status = 0; | ||
1213 | ap = host_set->ports[port]; | 1374 | ap = host_set->ports[port]; |
1214 | hard_port = port & MV_PORT_MASK; /* range 0-3 */ | 1375 | hard_port = port & MV_PORT_MASK; /* range 0-3 */ |
1215 | handled = 0; /* ensure ata_status is set if handled++ */ | 1376 | handled = 0; /* ensure ata_status is set if handled++ */ |
@@ -1681,6 +1842,12 @@ static void mv6_phy_errata(struct mv_host_priv *hpriv, void __iomem *mmio, | |||
1681 | m2 |= hpriv->signal[port].pre; | 1842 | m2 |= hpriv->signal[port].pre; |
1682 | m2 &= ~(1 << 16); | 1843 | m2 &= ~(1 << 16); |
1683 | 1844 | ||
1845 | /* according to mvSata 3.6.1, some IIE values are fixed */ | ||
1846 | if (IS_GEN_IIE(hpriv)) { | ||
1847 | m2 &= ~0xC30FF01F; | ||
1848 | m2 |= 0x0000900F; | ||
1849 | } | ||
1850 | |||
1684 | writel(m2, port_mmio + PHY_MODE2); | 1851 | writel(m2, port_mmio + PHY_MODE2); |
1685 | } | 1852 | } |
1686 | 1853 | ||
@@ -1846,7 +2013,6 @@ static void mv_phy_reset(struct ata_port *ap) | |||
1846 | static void mv_eng_timeout(struct ata_port *ap) | 2013 | static void mv_eng_timeout(struct ata_port *ap) |
1847 | { | 2014 | { |
1848 | struct ata_queued_cmd *qc; | 2015 | struct ata_queued_cmd *qc; |
1849 | unsigned long flags; | ||
1850 | 2016 | ||
1851 | printk(KERN_ERR "ata%u: Entering mv_eng_timeout\n",ap->id); | 2017 | printk(KERN_ERR "ata%u: Entering mv_eng_timeout\n",ap->id); |
1852 | DPRINTK("All regs @ start of eng_timeout\n"); | 2018 | DPRINTK("All regs @ start of eng_timeout\n"); |
@@ -1861,22 +2027,8 @@ static void mv_eng_timeout(struct ata_port *ap) | |||
1861 | mv_err_intr(ap); | 2027 | mv_err_intr(ap); |
1862 | mv_stop_and_reset(ap); | 2028 | mv_stop_and_reset(ap); |
1863 | 2029 | ||
1864 | if (!qc) { | 2030 | qc->err_mask |= AC_ERR_TIMEOUT; |
1865 | printk(KERN_ERR "ata%u: BUG: timeout without command\n", | 2031 | ata_eh_qc_complete(qc); |
1866 | ap->id); | ||
1867 | } else { | ||
1868 | /* hack alert! We cannot use the supplied completion | ||
1869 | * function from inside the ->eh_strategy_handler() thread. | ||
1870 | * libata is the only user of ->eh_strategy_handler() in | ||
1871 | * any kernel, so the default scsi_done() assumes it is | ||
1872 | * not being called from the SCSI EH. | ||
1873 | */ | ||
1874 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
1875 | qc->scsidone = scsi_finish_command; | ||
1876 | qc->err_mask |= AC_ERR_OTHER; | ||
1877 | ata_qc_complete(qc); | ||
1878 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
1879 | } | ||
1880 | } | 2032 | } |
1881 | 2033 | ||
1882 | /** | 2034 | /** |
@@ -1995,6 +2147,27 @@ static int mv_chip_id(struct pci_dev *pdev, struct mv_host_priv *hpriv, | |||
1995 | } | 2147 | } |
1996 | break; | 2148 | break; |
1997 | 2149 | ||
2150 | case chip_7042: | ||
2151 | case chip_6042: | ||
2152 | hpriv->ops = &mv6xxx_ops; | ||
2153 | |||
2154 | hp_flags |= MV_HP_GEN_IIE; | ||
2155 | |||
2156 | switch (rev_id) { | ||
2157 | case 0x0: | ||
2158 | hp_flags |= MV_HP_ERRATA_XX42A0; | ||
2159 | break; | ||
2160 | case 0x1: | ||
2161 | hp_flags |= MV_HP_ERRATA_60X1C0; | ||
2162 | break; | ||
2163 | default: | ||
2164 | dev_printk(KERN_WARNING, &pdev->dev, | ||
2165 | "Applying 60X1C0 workarounds to unknown rev\n"); | ||
2166 | hp_flags |= MV_HP_ERRATA_60X1C0; | ||
2167 | break; | ||
2168 | } | ||
2169 | break; | ||
2170 | |||
1998 | default: | 2171 | default: |
1999 | printk(KERN_ERR DRV_NAME ": BUG: invalid board index %u\n", board_idx); | 2172 | printk(KERN_ERR DRV_NAME ": BUG: invalid board index %u\n", board_idx); |
2000 | return 1; | 2173 | return 1; |