Lines Matching +full:fis +full:- +full:based
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * sata_sil24.c - Driver for Silicon Image 3124/3132 SATA-2 controllers
7 * Based on preview driver from Silicon Image.
17 #include <linux/dma-mapping.h>
33 u8 fis[6 * 4]; member
57 SIL24_MAX_SGT = (PAGE_SIZE - SIL24_PRB_SZ)
113 PORT_CTRL_STAT = 0x1000, /* write: ctrl-set, read: stat */
114 PORT_CTRL_CLR = 0x1004, /* write: ctrl-clear */
116 PORT_IRQ_ENABLE_SET = 0x1010, /* write: enable-set */
117 PORT_IRQ_ENABLE_CLR = 0x1014, /* write: enable-clear */
135 PORT_EXEC_DIAG = 0x1e00, /* 32bit exec diag * 16 (64 bytes, 0-10 used on 3124) */
136 PORT_PSD_DIAG = 0x1e40, /* 32bit psd diag * 16 (64 bytes, 0-8 used on 3124) */
149 PORT_CS_32BIT_ACTV = (1 << 10), /* 32-bit activation */
161 PORT_IRQ_UNK_FIS = (1 << 6), /* unknown FIS received */
177 /* ENABLE_SET/CLR specific, intr steering - 2 bit field */
182 PORT_CERR_DEV = 1, /* Error bit in D2H Register FIS */
183 PORT_CERR_SDB = 2, /* Error bit in SDB FIS */
184 PORT_CERR_DATA = 3, /* Error in data FIS not detected by dev */
185 PORT_CERR_SEND = 4, /* Initial cmd FIS transmission failure */
191 PORT_CERR_SGT_BOUNDARY = 16, /* PLD ecode 00 - SGT not on qword boundary */
192 PORT_CERR_SGT_TGTABRT = 17, /* PLD ecode 01 - target abort */
193 PORT_CERR_SGT_MSTABRT = 18, /* PLD ecode 10 - master abort */
194 PORT_CERR_SGT_PCIPERR = 19, /* PLD ecode 11 - PCI parity err while fetching SGT */
195 PORT_CERR_CMD_BOUNDARY = 24, /* ctrl[15:13] 001 - PRB not on qword boundary */
196 PORT_CERR_CMD_TGTABRT = 25, /* ctrl[15:13] 010 - target abort */
197 PORT_CERR_CMD_MSTABRT = 26, /* ctrl[15:13] 100 - master abort */
198 PORT_CERR_CMD_PCIPERR = 27, /* ctrl[15:13] 110 - PCI parity err while fetching PRB */
199 PORT_CERR_XFR_UNDEF = 32, /* PSD ecode 00 - undefined */
200 PORT_CERR_XFR_TGTABRT = 33, /* PSD ecode 01 - target abort */
201 PORT_CERR_XFR_MSTABRT = 34, /* PSD ecode 10 - master abort */
202 PORT_CERR_XFR_PCIPERR = 35, /* PSD ecode 11 - PCI prity err during transfer */
203 PORT_CERR_SENDSERVICE = 36, /* FIS received while sending service */
240 SIL24_FLAG_PCIX_IRQ_WOC = (1 << 24), /* IRQ loss errata on PCI-X */
268 "device error via D2H FIS" },
270 "device error via SDB FIS" },
272 "error in data FIS" },
274 "failed to transmit command FIS" },
310 "FIS received while sending service FIS" },
314 * ap->private_data
420 * Use bits 30-31 of port_flags to encode available port numbers.
423 #define SIL24_NPORTS2FLAG(nports) ((((unsigned)(nports) - 1) & 0x3) << 30)
463 return ap->port_no * PORT_REGS_SIZE; in sil24_port_offset()
468 return ap->host->iomap[SIL24_PORT_BAR] + sil24_port_offset(ap); in sil24_port_base()
473 void __iomem *port = sil24_port_base(dev->link->ap); in sil24_dev_config()
475 if (dev->cdb_len == 16) in sil24_dev_config()
485 u8 fis[6 * 4]; in sil24_read_tf() local
488 memcpy_fromio(fis, prb->fis, sizeof(fis)); in sil24_read_tf()
489 ata_tf_from_fis(fis, tf); in sil24_read_tf()
501 void __iomem *scr_addr = sil24_port_base(link->ap) + PORT_SCONTROL; in sil24_scr_read()
507 return -EINVAL; in sil24_scr_read()
512 void __iomem *scr_addr = sil24_port_base(link->ap) + PORT_SCONTROL; in sil24_scr_write()
518 return -EINVAL; in sil24_scr_write()
526 if (ap->flags & SIL24_FLAG_PCIX_IRQ_WOC) in sil24_config_port()
574 struct sil24_port_priv *pp = ap->private_data; in sil24_init_port()
588 pp->do_port_rst = 1; in sil24_init_port()
589 ap->link.eh_context.i.action |= ATA_EH_RESET; in sil24_init_port()
590 return -EIO; in sil24_init_port()
602 struct sil24_port_priv *pp = ap->private_data; in sil24_exec_polled_cmd()
603 struct sil24_prb *prb = &pp->cmd_block[0].ata.prb; in sil24_exec_polled_cmd()
604 dma_addr_t paddr = pp->cmd_block_dma; in sil24_exec_polled_cmd()
608 prb->ctrl = cpu_to_le16(ctrl); in sil24_exec_polled_cmd()
609 ata_tf_to_fis(tf, pmp, is_cmd, prb->fis); in sil24_exec_polled_cmd()
637 rc = -EIO; in sil24_exec_polled_cmd()
639 rc = -EBUSY; in sil24_exec_polled_cmd()
651 struct ata_port *ap = link->ap; in sil24_softreset()
666 timeout_msec = jiffies_to_msecs(deadline - jiffies); in sil24_softreset()
668 ata_tf_init(link->device, &tf); /* doesn't really matter */ in sil24_softreset()
671 if (rc == -EBUSY) { in sil24_softreset()
686 return -EIO; in sil24_softreset()
692 struct ata_port *ap = link->ap; in sil24_hardreset()
694 struct sil24_port_priv *pp = ap->private_data; in sil24_hardreset()
704 if (pp->do_port_rst) { in sil24_hardreset()
716 sil24_config_pmp(ap, ap->nr_pmp_links); in sil24_hardreset()
718 pp->do_port_rst = 0; in sil24_hardreset()
750 /* Sil24 doesn't store signature FIS after hardreset, so we in sil24_hardreset()
753 * for BSY clearance here. Tell libata to perform follow-up in sil24_hardreset()
756 return -EAGAIN; in sil24_hardreset()
760 pp->do_port_rst = 1; in sil24_hardreset()
765 return -EIO; in sil24_hardreset()
775 for_each_sg(qc->sg, sg, qc->n_elem, si) { in sil24_fill_sg()
776 sge->addr = cpu_to_le64(sg_dma_address(sg)); in sil24_fill_sg()
777 sge->cnt = cpu_to_le32(sg_dma_len(sg)); in sil24_fill_sg()
778 sge->flags = 0; in sil24_fill_sg()
784 last_sge->flags = cpu_to_le32(SGE_TRM); in sil24_fill_sg()
789 struct ata_link *link = qc->dev->link; in sil24_qc_defer()
790 struct ata_port *ap = link->ap; in sil24_qc_defer()
791 u8 prot = qc->tf.protocol; in sil24_qc_defer()
807 * - ATAPI commands which check the sense data in sil24_qc_defer()
808 * - Passthrough ATA commands which always have ATA_QCFLAG_RESULT_TF in sil24_qc_defer()
813 (qc->flags & ATA_QCFLAG_RESULT_TF)); in sil24_qc_defer()
815 if (unlikely(ap->excl_link)) { in sil24_qc_defer()
816 if (link == ap->excl_link) { in sil24_qc_defer()
817 if (ap->nr_active_links) in sil24_qc_defer()
819 qc->flags |= ATA_QCFLAG_CLEAR_EXCL; in sil24_qc_defer()
823 ap->excl_link = link; in sil24_qc_defer()
824 if (ap->nr_active_links) in sil24_qc_defer()
826 qc->flags |= ATA_QCFLAG_CLEAR_EXCL; in sil24_qc_defer()
834 struct ata_port *ap = qc->ap; in sil24_qc_prep()
835 struct sil24_port_priv *pp = ap->private_data; in sil24_qc_prep()
841 cb = &pp->cmd_block[sil24_tag(qc->hw_tag)]; in sil24_qc_prep()
843 if (!ata_is_atapi(qc->tf.protocol)) { in sil24_qc_prep()
844 prb = &cb->ata.prb; in sil24_qc_prep()
845 sge = cb->ata.sge; in sil24_qc_prep()
846 if (ata_is_data(qc->tf.protocol)) { in sil24_qc_prep()
849 if (ata_is_ncq(qc->tf.protocol)) in sil24_qc_prep()
851 if (qc->tf.flags & ATA_TFLAG_WRITE) in sil24_qc_prep()
855 prb->prot = cpu_to_le16(prot); in sil24_qc_prep()
858 prb = &cb->atapi.prb; in sil24_qc_prep()
859 sge = cb->atapi.sge; in sil24_qc_prep()
860 memset(cb->atapi.cdb, 0, sizeof(cb->atapi.cdb)); in sil24_qc_prep()
861 memcpy(cb->atapi.cdb, qc->cdb, qc->dev->cdb_len); in sil24_qc_prep()
863 if (ata_is_data(qc->tf.protocol)) { in sil24_qc_prep()
864 if (qc->tf.flags & ATA_TFLAG_WRITE) in sil24_qc_prep()
871 prb->ctrl = cpu_to_le16(ctrl); in sil24_qc_prep()
872 ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, prb->fis); in sil24_qc_prep()
874 if (qc->flags & ATA_QCFLAG_DMAMAP) in sil24_qc_prep()
882 struct ata_port *ap = qc->ap; in sil24_qc_issue()
883 struct sil24_port_priv *pp = ap->private_data; in sil24_qc_issue()
885 unsigned int tag = sil24_tag(qc->hw_tag); in sil24_qc_issue()
889 paddr = pp->cmd_block_dma + tag * sizeof(*pp->cmd_block); in sil24_qc_issue()
905 sil24_read_tf(qc->ap, qc->hw_tag, &qc->result_tf); in sil24_qc_fill_rtf()
910 u32 *gscr = ap->link.device->gscr; in sil24_pmp_attach()
918 "disabling NCQ support due to sil24-mv4140 quirk\n"); in sil24_pmp_attach()
919 ap->flags &= ~ATA_FLAG_NCQ; in sil24_pmp_attach()
928 ap->flags |= ATA_FLAG_NCQ; in sil24_pmp_detach()
936 rc = sil24_init_port(link->ap); in sil24_pmp_hardreset()
949 /* Port-wide IRQ mask in HOST_CTRL doesn't really work, clear in sil24_freeze()
971 struct sil24_port_priv *pp = ap->private_data; in sil24_error_intr()
983 link = &ap->link; in sil24_error_intr()
984 ehi = &link->eh_info; in sil24_error_intr()
1003 ehi->err_mask |= AC_ERR_HSM; in sil24_error_intr()
1004 ehi->action |= ATA_EH_RESET; in sil24_error_intr()
1005 ata_ehi_push_desc(ehi, "unknown FIS"); in sil24_error_intr()
1023 if (ap->nr_active_links >= 3) { in sil24_error_intr()
1024 ehi->err_mask |= AC_ERR_OTHER; in sil24_error_intr()
1025 ehi->action |= ATA_EH_RESET; in sil24_error_intr()
1027 pp->do_port_rst = 1; in sil24_error_intr()
1036 if (pmp < ap->nr_pmp_links) { in sil24_error_intr()
1037 link = &ap->pmp_link[pmp]; in sil24_error_intr()
1038 ehi = &link->eh_info; in sil24_error_intr()
1039 qc = ata_qc_from_tag(ap, link->active_tag); in sil24_error_intr()
1050 qc = ata_qc_from_tag(ap, link->active_tag); in sil24_error_intr()
1057 if (ci && ci->desc) { in sil24_error_intr()
1058 err_mask |= ci->err_mask; in sil24_error_intr()
1059 action |= ci->action; in sil24_error_intr()
1062 ata_ehi_push_desc(ehi, "%s", ci->desc); in sil24_error_intr()
1073 qc->err_mask |= err_mask; in sil24_error_intr()
1075 ehi->err_mask |= err_mask; in sil24_error_intr()
1077 ehi->action |= action; in sil24_error_intr()
1089 ata_link_abort(qc->dev->link); in sil24_error_intr()
1108 if (ap->flags & SIL24_FLAG_PCIX_IRQ_WOC) in sil24_host_intr()
1123 struct ata_eh_info *ehi = &ap->link.eh_info; in sil24_host_intr()
1124 ehi->err_mask |= AC_ERR_HSM; in sil24_host_intr()
1125 ehi->action |= ATA_EH_RESET; in sil24_host_intr()
1131 if (!(ap->flags & SIL24_FLAG_PCIX_IRQ_WOC) && ata_ratelimit()) in sil24_host_intr()
1134 slot_stat, ap->link.active_tag, ap->link.sactive); in sil24_host_intr()
1140 void __iomem *host_base = host->iomap[SIL24_HOST_BAR]; in sil24_interrupt()
1148 dev_err(host->dev, "IRQ status == 0xffffffff, " in sil24_interrupt()
1156 spin_lock(&host->lock); in sil24_interrupt()
1158 for (i = 0; i < host->n_ports; i++) in sil24_interrupt()
1160 sil24_host_intr(host->ports[i]); in sil24_interrupt()
1164 spin_unlock(&host->lock); in sil24_interrupt()
1171 struct sil24_port_priv *pp = ap->private_data; in sil24_error_handler()
1178 pp->do_port_rst = 0; in sil24_error_handler()
1183 struct ata_port *ap = qc->ap; in sil24_post_internal_cmd()
1186 if ((qc->flags & ATA_QCFLAG_EH) && sil24_init_port(ap)) in sil24_post_internal_cmd()
1192 struct device *dev = ap->host->dev; in sil24_port_start()
1200 return -ENOMEM; in sil24_port_start()
1204 return -ENOMEM; in sil24_port_start()
1206 pp->cmd_block = cb; in sil24_port_start()
1207 pp->cmd_block_dma = cb_dma; in sil24_port_start()
1209 ap->private_data = pp; in sil24_port_start()
1211 ata_port_pbar_desc(ap, SIL24_HOST_BAR, -1, "host"); in sil24_port_start()
1219 void __iomem *host_base = host->iomap[SIL24_HOST_BAR]; in sil24_init_controller()
1230 for (i = 0; i < host->n_ports; i++) { in sil24_init_controller()
1231 struct ata_port *ap = host->ports[i]; in sil24_init_controller()
1246 dev_err(host->dev, in sil24_init_controller()
1261 struct ata_port_info pi = sil24_port_info[ent->driver_data]; in sil24_init_one()
1272 ata_print_version_once(&pdev->dev, DRV_VERSION); in sil24_init_one()
1286 /* apply workaround for completion IRQ loss on PCI-X errata */ in sil24_init_one()
1290 dev_info(&pdev->dev, in sil24_init_one()
1291 "Applying completion IRQ loss on PCI-X errata fix\n"); in sil24_init_one()
1297 host = ata_host_alloc_pinfo(&pdev->dev, ppi, in sil24_init_one()
1298 SIL24_FLAG2NPORTS(ppi[0]->flags)); in sil24_init_one()
1300 return -ENOMEM; in sil24_init_one()
1301 host->iomap = iomap; in sil24_init_one()
1304 rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in sil24_init_one()
1306 dev_err(&pdev->dev, "DMA enable failed\n"); in sil24_init_one()
1311 * write throughput for pci-e variants. in sil24_init_one()
1318 dev_info(&pdev->dev, "Using MSI\n"); in sil24_init_one()
1323 return ata_host_activate(host, pdev->irq, sil24_interrupt, IRQF_SHARED, in sil24_init_one()
1331 void __iomem *host_base = host->iomap[SIL24_HOST_BAR]; in sil24_pci_device_resume()
1338 if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) in sil24_pci_device_resume()
1352 sil24_config_pmp(ap, ap->nr_pmp_links); in sil24_port_resume()
1360 MODULE_DESCRIPTION("Silicon Image 3124/3132 SATA low-level driver");