Lines Matching full:ap

294 static void nv_nf2_freeze(struct ata_port *ap);
295 static void nv_nf2_thaw(struct ata_port *ap);
296 static void nv_ck804_freeze(struct ata_port *ap);
297 static void nv_ck804_thaw(struct ata_port *ap);
303 static void nv_adma_irq_clear(struct ata_port *ap);
304 static int nv_adma_port_start(struct ata_port *ap);
305 static void nv_adma_port_stop(struct ata_port *ap);
307 static int nv_adma_port_suspend(struct ata_port *ap, pm_message_t mesg);
308 static int nv_adma_port_resume(struct ata_port *ap);
310 static void nv_adma_freeze(struct ata_port *ap);
311 static void nv_adma_thaw(struct ata_port *ap);
312 static void nv_adma_error_handler(struct ata_port *ap);
315 static void nv_adma_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
317 static void nv_mcp55_thaw(struct ata_port *ap);
318 static void nv_mcp55_freeze(struct ata_port *ap);
319 static void nv_swncq_error_handler(struct ata_port *ap);
321 static int nv_swncq_port_start(struct ata_port *ap);
325 static void nv_swncq_irq_clear(struct ata_port *ap, u16 fis);
328 static int nv_swncq_port_suspend(struct ata_port *ap, pm_message_t mesg);
329 static int nv_swncq_port_resume(struct ata_port *ap);
589 static void nv_adma_register_mode(struct ata_port *ap) in nv_adma_register_mode() argument
591 struct nv_adma_port_priv *pp = ap->private_data; in nv_adma_register_mode()
606 ata_port_warn(ap, "timeout waiting for ADMA IDLE, stat=0x%hx\n", in nv_adma_register_mode()
620 ata_port_warn(ap, in nv_adma_register_mode()
627 static void nv_adma_mode(struct ata_port *ap) in nv_adma_mode() argument
629 struct nv_adma_port_priv *pp = ap->private_data; in nv_adma_mode()
650 ata_port_warn(ap, in nv_adma_mode()
659 struct ata_port *ap = ata_shost_to_port(sdev->host); in nv_adma_slave_config() local
660 struct nv_adma_port_priv *pp = ap->private_data; in nv_adma_slave_config()
662 struct pci_dev *pdev = to_pci_dev(ap->host->dev); in nv_adma_slave_config()
675 spin_lock_irqsave(ap->lock, flags); in nv_adma_slave_config()
677 if (ap->link.device[sdev->id].class == ATA_DEV_ATAPI) { in nv_adma_slave_config()
693 nv_adma_register_mode(ap); in nv_adma_slave_config()
702 if (ap->port_no == 1) in nv_adma_slave_config()
720 port0 = ap->host->ports[0]->private_data; in nv_adma_slave_config()
721 port1 = ap->host->ports[1]->private_data; in nv_adma_slave_config()
738 ata_port_info(ap, in nv_adma_slave_config()
740 (unsigned long long)*ap->host->dev->dma_mask, in nv_adma_slave_config()
743 spin_unlock_irqrestore(ap->lock, flags); in nv_adma_slave_config()
750 struct nv_adma_port_priv *pp = qc->ap->private_data; in nv_adma_check_atapi_dma()
754 static void nv_adma_tf_read(struct ata_port *ap, struct ata_taskfile *tf) in nv_adma_tf_read() argument
763 nv_adma_register_mode(ap); in nv_adma_tf_read()
765 ata_sff_tf_read(ap, tf); in nv_adma_tf_read()
800 static int nv_adma_check_cpb(struct ata_port *ap, int cpb_num, int force_err) in nv_adma_check_cpb() argument
802 struct nv_adma_port_priv *pp = ap->private_data; in nv_adma_check_cpb()
811 struct ata_eh_info *ehi = &ap->link.eh_info; in nv_adma_check_cpb()
834 ata_port_freeze(ap); in nv_adma_check_cpb()
836 ata_port_abort(ap); in nv_adma_check_cpb()
845 static int nv_host_intr(struct ata_port *ap, u8 irq_stat) in nv_host_intr() argument
847 struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->link.active_tag); in nv_host_intr()
851 ata_port_freeze(ap); in nv_host_intr()
861 ata_sff_check_status(ap); in nv_host_intr()
866 return ata_bmdma_port_intr(ap, qc); in nv_host_intr()
878 struct ata_port *ap = host->ports[i]; in nv_adma_interrupt() local
879 struct nv_adma_port_priv *pp = ap->private_data; in nv_adma_interrupt()
891 handled += nv_host_intr(ap, irq_stat); in nv_adma_interrupt()
899 if (ata_tag_valid(ap->link.active_tag)) in nv_adma_interrupt()
905 handled += nv_host_intr(ap, irq_stat); in nv_adma_interrupt()
914 if (!NV_ADMA_CHECK_INTR(gen_ctl, ap->port_no) && !notifier && in nv_adma_interrupt()
938 struct ata_eh_info *ehi = &ap->link.eh_info; in nv_adma_interrupt()
956 ata_port_freeze(ap); in nv_adma_interrupt()
969 if (ata_tag_valid(ap->link.active_tag)) in nv_adma_interrupt()
971 ap->link.active_tag; in nv_adma_interrupt()
973 check_commands = ap->link.sactive; in nv_adma_interrupt()
979 rc = nv_adma_check_cpb(ap, pos, in nv_adma_interrupt()
987 ata_qc_complete_multiple(ap, ata_qc_get_active(ap) ^ done_mask); in nv_adma_interrupt()
1005 static void nv_adma_freeze(struct ata_port *ap) in nv_adma_freeze() argument
1007 struct nv_adma_port_priv *pp = ap->private_data; in nv_adma_freeze()
1011 nv_ck804_freeze(ap); in nv_adma_freeze()
1017 writeb(NV_INT_ALL << (ap->port_no * NV_INT_PORT_SHIFT), in nv_adma_freeze()
1018 ap->host->iomap[NV_MMIO_BAR] + NV_INT_STATUS_CK804); in nv_adma_freeze()
1027 static void nv_adma_thaw(struct ata_port *ap) in nv_adma_thaw() argument
1029 struct nv_adma_port_priv *pp = ap->private_data; in nv_adma_thaw()
1033 nv_ck804_thaw(ap); in nv_adma_thaw()
1045 static void nv_adma_irq_clear(struct ata_port *ap) in nv_adma_irq_clear() argument
1047 struct nv_adma_port_priv *pp = ap->private_data; in nv_adma_irq_clear()
1052 ata_bmdma_irq_clear(ap); in nv_adma_irq_clear()
1057 writeb(NV_INT_ALL << (ap->port_no * NV_INT_PORT_SHIFT), in nv_adma_irq_clear()
1058 ap->host->iomap[NV_MMIO_BAR] + NV_INT_STATUS_CK804); in nv_adma_irq_clear()
1065 if (ap->port_no == 0) { in nv_adma_irq_clear()
1072 pp = ap->host->ports[0]->private_data; in nv_adma_irq_clear()
1074 pp = ap->host->ports[1]->private_data; in nv_adma_irq_clear()
1080 struct nv_adma_port_priv *pp = qc->ap->private_data; in nv_adma_post_internal_cmd()
1086 static int nv_adma_port_start(struct ata_port *ap) in nv_adma_port_start() argument
1088 struct device *dev = ap->host->dev; in nv_adma_port_start()
1108 rc = ata_bmdma_port_start(ap); in nv_adma_port_start()
1116 mmio = ap->host->iomap[NV_MMIO_BAR] + NV_ADMA_PORT + in nv_adma_port_start()
1117 ap->port_no * NV_ADMA_PORT_SIZE; in nv_adma_port_start()
1119 pp->gen_block = ap->host->iomap[NV_MMIO_BAR] + NV_ADMA_GEN; in nv_adma_port_start()
1121 NV_ADMA_NOTIFIER_CLEAR + (4 * ap->port_no); in nv_adma_port_start()
1156 ap->private_data = pp; in nv_adma_port_start()
1182 static void nv_adma_port_stop(struct ata_port *ap) in nv_adma_port_stop() argument
1184 struct nv_adma_port_priv *pp = ap->private_data; in nv_adma_port_stop()
1192 static int nv_adma_port_suspend(struct ata_port *ap, pm_message_t mesg) in nv_adma_port_suspend() argument
1194 struct nv_adma_port_priv *pp = ap->private_data; in nv_adma_port_suspend()
1198 nv_adma_register_mode(ap); in nv_adma_port_suspend()
1209 static int nv_adma_port_resume(struct ata_port *ap) in nv_adma_port_resume() argument
1211 struct nv_adma_port_priv *pp = ap->private_data; in nv_adma_port_resume()
1244 static void nv_adma_setup_port(struct ata_port *ap) in nv_adma_setup_port() argument
1246 void __iomem *mmio = ap->host->iomap[NV_MMIO_BAR]; in nv_adma_setup_port()
1247 struct ata_ioports *ioport = &ap->ioaddr; in nv_adma_setup_port()
1251 mmio += NV_ADMA_PORT + ap->port_no * NV_ADMA_PORT_SIZE; in nv_adma_setup_port()
1312 struct nv_adma_port_priv *pp = qc->ap->private_data; in nv_adma_fill_sg()
1332 struct nv_adma_port_priv *pp = qc->ap->private_data; in nv_adma_use_reg_mode()
1349 struct nv_adma_port_priv *pp = qc->ap->private_data; in nv_adma_qc_prep()
1357 nv_adma_register_mode(qc->ap); in nv_adma_qc_prep()
1397 struct nv_adma_port_priv *pp = qc->ap->private_data; in nv_adma_qc_issue()
1417 nv_adma_register_mode(qc->ap); in nv_adma_qc_issue()
1420 nv_adma_mode(qc->ap); in nv_adma_qc_issue()
1450 struct ata_port *ap = host->ports[i]; in nv_generic_interrupt() local
1453 qc = ata_qc_from_tag(ap, ap->link.active_tag); in nv_generic_interrupt()
1455 handled += ata_bmdma_port_intr(ap, qc); in nv_generic_interrupt()
1461 ap->ops->sff_check_status(ap); in nv_generic_interrupt()
1515 *val = ioread32(link->ap->ioaddr.scr_addr + (sc_reg * 4)); in nv_scr_read()
1524 iowrite32(val, link->ap->ioaddr.scr_addr + (sc_reg * 4)); in nv_scr_write()
1536 if (!(link->ap->pflags & ATA_PFLAG_LOADING) && in nv_hardreset()
1560 static void nv_nf2_freeze(struct ata_port *ap) in nv_nf2_freeze() argument
1562 void __iomem *scr_addr = ap->host->ports[0]->ioaddr.scr_addr; in nv_nf2_freeze()
1563 int shift = ap->port_no * NV_INT_PORT_SHIFT; in nv_nf2_freeze()
1571 static void nv_nf2_thaw(struct ata_port *ap) in nv_nf2_thaw() argument
1573 void __iomem *scr_addr = ap->host->ports[0]->ioaddr.scr_addr; in nv_nf2_thaw()
1574 int shift = ap->port_no * NV_INT_PORT_SHIFT; in nv_nf2_thaw()
1584 static void nv_ck804_freeze(struct ata_port *ap) in nv_ck804_freeze() argument
1586 void __iomem *mmio_base = ap->host->iomap[NV_MMIO_BAR]; in nv_ck804_freeze()
1587 int shift = ap->port_no * NV_INT_PORT_SHIFT; in nv_ck804_freeze()
1595 static void nv_ck804_thaw(struct ata_port *ap) in nv_ck804_thaw() argument
1597 void __iomem *mmio_base = ap->host->iomap[NV_MMIO_BAR]; in nv_ck804_thaw()
1598 int shift = ap->port_no * NV_INT_PORT_SHIFT; in nv_ck804_thaw()
1608 static void nv_mcp55_freeze(struct ata_port *ap) in nv_mcp55_freeze() argument
1610 void __iomem *mmio_base = ap->host->iomap[NV_MMIO_BAR]; in nv_mcp55_freeze()
1611 int shift = ap->port_no * NV_INT_PORT_SHIFT_MCP55; in nv_mcp55_freeze()
1621 static void nv_mcp55_thaw(struct ata_port *ap) in nv_mcp55_thaw() argument
1623 void __iomem *mmio_base = ap->host->iomap[NV_MMIO_BAR]; in nv_mcp55_thaw()
1624 int shift = ap->port_no * NV_INT_PORT_SHIFT_MCP55; in nv_mcp55_thaw()
1634 static void nv_adma_error_handler(struct ata_port *ap) in nv_adma_error_handler() argument
1636 struct nv_adma_port_priv *pp = ap->private_data; in nv_adma_error_handler()
1642 if (ata_tag_valid(ap->link.active_tag) || ap->link.sactive) { in nv_adma_error_handler()
1650 ata_port_err(ap, in nv_adma_error_handler()
1659 if ((ata_tag_valid(ap->link.active_tag) && i == ap->link.active_tag) || in nv_adma_error_handler()
1660 ap->link.sactive & (1 << i)) in nv_adma_error_handler()
1661 ata_port_err(ap, in nv_adma_error_handler()
1668 nv_adma_register_mode(ap); in nv_adma_error_handler()
1687 ata_bmdma_error_handler(ap); in nv_adma_error_handler()
1690 static void nv_swncq_qc_to_dq(struct ata_port *ap, struct ata_queued_cmd *qc) in nv_swncq_qc_to_dq() argument
1692 struct nv_swncq_port_priv *pp = ap->private_data; in nv_swncq_qc_to_dq()
1701 static struct ata_queued_cmd *nv_swncq_qc_from_dq(struct ata_port *ap) in nv_swncq_qc_from_dq() argument
1703 struct nv_swncq_port_priv *pp = ap->private_data; in nv_swncq_qc_from_dq()
1715 return ata_qc_from_tag(ap, tag); in nv_swncq_qc_from_dq()
1718 static void nv_swncq_fis_reinit(struct ata_port *ap) in nv_swncq_fis_reinit() argument
1720 struct nv_swncq_port_priv *pp = ap->private_data; in nv_swncq_fis_reinit()
1728 static void nv_swncq_pp_reinit(struct ata_port *ap) in nv_swncq_pp_reinit() argument
1730 struct nv_swncq_port_priv *pp = ap->private_data; in nv_swncq_pp_reinit()
1738 nv_swncq_fis_reinit(ap); in nv_swncq_pp_reinit()
1741 static void nv_swncq_irq_clear(struct ata_port *ap, u16 fis) in nv_swncq_irq_clear() argument
1743 struct nv_swncq_port_priv *pp = ap->private_data; in nv_swncq_irq_clear()
1748 static void __ata_bmdma_stop(struct ata_port *ap) in __ata_bmdma_stop() argument
1752 qc.ap = ap; in __ata_bmdma_stop()
1756 static void nv_swncq_ncq_stop(struct ata_port *ap) in nv_swncq_ncq_stop() argument
1758 struct nv_swncq_port_priv *pp = ap->private_data; in nv_swncq_ncq_stop()
1763 ata_port_err(ap, "EH in SWNCQ mode,QC:qc_active 0x%llX sactive 0x%X\n", in nv_swncq_ncq_stop()
1764 ap->qc_active, ap->link.sactive); in nv_swncq_ncq_stop()
1765 ata_port_err(ap, in nv_swncq_ncq_stop()
1771 ata_port_err(ap, "ATA_REG 0x%X ERR_REG 0x%X\n", in nv_swncq_ncq_stop()
1772 ap->ops->sff_check_status(ap), in nv_swncq_ncq_stop()
1773 ioread8(ap->ioaddr.error_addr)); in nv_swncq_ncq_stop()
1778 ata_port_err(ap, "tag : dhfis dmafis sdbfis sactive\n"); in nv_swncq_ncq_stop()
1788 ata_port_err(ap, in nv_swncq_ncq_stop()
1797 nv_swncq_pp_reinit(ap); in nv_swncq_ncq_stop()
1798 ap->ops->sff_irq_clear(ap); in nv_swncq_ncq_stop()
1799 __ata_bmdma_stop(ap); in nv_swncq_ncq_stop()
1800 nv_swncq_irq_clear(ap, 0xffff); in nv_swncq_ncq_stop()
1803 static void nv_swncq_error_handler(struct ata_port *ap) in nv_swncq_error_handler() argument
1805 struct ata_eh_context *ehc = &ap->link.eh_context; in nv_swncq_error_handler()
1807 if (ap->link.sactive) { in nv_swncq_error_handler()
1808 nv_swncq_ncq_stop(ap); in nv_swncq_error_handler()
1812 ata_bmdma_error_handler(ap); in nv_swncq_error_handler()
1816 static int nv_swncq_port_suspend(struct ata_port *ap, pm_message_t mesg) in nv_swncq_port_suspend() argument
1818 void __iomem *mmio = ap->host->iomap[NV_MMIO_BAR]; in nv_swncq_port_suspend()
1835 static int nv_swncq_port_resume(struct ata_port *ap) in nv_swncq_port_resume() argument
1837 void __iomem *mmio = ap->host->iomap[NV_MMIO_BAR]; in nv_swncq_port_resume()
1882 struct ata_port *ap = ata_shost_to_port(sdev->host); in nv_swncq_slave_config() local
1883 struct pci_dev *pdev = to_pci_dev(ap->host->dev); in nv_swncq_slave_config()
1895 dev = &ap->link.device[sdev->id]; in nv_swncq_slave_config()
1896 if (!(ap->flags & ATA_FLAG_NCQ) || dev->class == ATA_DEV_ATAPI) in nv_swncq_slave_config()
1926 static int nv_swncq_port_start(struct ata_port *ap) in nv_swncq_port_start() argument
1928 struct device *dev = ap->host->dev; in nv_swncq_port_start()
1929 void __iomem *mmio = ap->host->iomap[NV_MMIO_BAR]; in nv_swncq_port_start()
1934 rc = ata_bmdma_port_start(ap); in nv_swncq_port_start()
1947 ap->private_data = pp; in nv_swncq_port_start()
1948 pp->sactive_block = ap->ioaddr.scr_addr + 4 * SCR_ACTIVE; in nv_swncq_port_start()
1949 pp->irq_block = mmio + NV_INT_STATUS_MCP55 + ap->port_no * 2; in nv_swncq_port_start()
1950 pp->tag_block = mmio + NV_NCQ_REG_MCP55 + ap->port_no * 2; in nv_swncq_port_start()
1972 struct ata_port *ap = qc->ap; in nv_swncq_fill_sg() local
1974 struct nv_swncq_port_priv *pp = ap->private_data; in nv_swncq_fill_sg()
2006 static unsigned int nv_swncq_issue_atacmd(struct ata_port *ap, in nv_swncq_issue_atacmd() argument
2009 struct nv_swncq_port_priv *pp = ap->private_data; in nv_swncq_issue_atacmd()
2022 ap->ops->sff_tf_load(ap, &qc->tf); /* load tf registers */ in nv_swncq_issue_atacmd()
2023 ap->ops->sff_exec_command(ap, &qc->tf); in nv_swncq_issue_atacmd()
2032 struct ata_port *ap = qc->ap; in nv_swncq_qc_issue() local
2033 struct nv_swncq_port_priv *pp = ap->private_data; in nv_swncq_qc_issue()
2041 nv_swncq_issue_atacmd(ap, qc); in nv_swncq_qc_issue()
2043 nv_swncq_qc_to_dq(ap, qc); /* add qc to defer queue */ in nv_swncq_qc_issue()
2048 static void nv_swncq_hotplug(struct ata_port *ap, u32 fis) in nv_swncq_hotplug() argument
2051 struct ata_eh_info *ehi = &ap->link.eh_info; in nv_swncq_hotplug()
2056 sata_scr_read(&ap->link, SCR_ERROR, &serror); in nv_swncq_hotplug()
2057 sata_scr_write(&ap->link, SCR_ERROR, serror); in nv_swncq_hotplug()
2070 ata_port_freeze(ap); in nv_swncq_hotplug()
2073 static int nv_swncq_sdbfis(struct ata_port *ap) in nv_swncq_sdbfis() argument
2076 struct nv_swncq_port_priv *pp = ap->private_data; in nv_swncq_sdbfis()
2077 struct ata_eh_info *ehi = &ap->link.eh_info; in nv_swncq_sdbfis()
2083 host_stat = ap->ops->bmdma_status(ap); in nv_swncq_sdbfis()
2093 ap->ops->sff_irq_clear(ap); in nv_swncq_sdbfis()
2094 __ata_bmdma_stop(ap); in nv_swncq_sdbfis()
2103 ata_qc_complete_multiple(ap, ata_qc_get_active(ap) ^ done_mask); in nv_swncq_sdbfis()
2105 if (!ap->qc_active) { in nv_swncq_sdbfis()
2107 nv_swncq_pp_reinit(ap); in nv_swncq_sdbfis()
2124 ap->print_id, ap->qc_active, pp->qc_active, in nv_swncq_sdbfis()
2128 nv_swncq_fis_reinit(ap); in nv_swncq_sdbfis()
2131 qc = ata_qc_from_tag(ap, pp->last_issue_tag); in nv_swncq_sdbfis()
2132 nv_swncq_issue_atacmd(ap, qc); in nv_swncq_sdbfis()
2138 qc = nv_swncq_qc_from_dq(ap); in nv_swncq_sdbfis()
2140 nv_swncq_issue_atacmd(ap, qc); in nv_swncq_sdbfis()
2146 static inline u32 nv_swncq_tag(struct ata_port *ap) in nv_swncq_tag() argument
2148 struct nv_swncq_port_priv *pp = ap->private_data; in nv_swncq_tag()
2155 static void nv_swncq_dmafis(struct ata_port *ap) in nv_swncq_dmafis() argument
2161 struct nv_swncq_port_priv *pp = ap->private_data; in nv_swncq_dmafis()
2163 __ata_bmdma_stop(ap); in nv_swncq_dmafis()
2164 tag = nv_swncq_tag(ap); in nv_swncq_dmafis()
2167 qc = ata_qc_from_tag(ap, tag); in nv_swncq_dmafis()
2176 ap->ioaddr.bmdma_addr + ATA_DMA_TABLE_OFS); in nv_swncq_dmafis()
2179 dmactl = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_CMD); in nv_swncq_dmafis()
2184 iowrite8(dmactl | ATA_DMA_START, ap->ioaddr.bmdma_addr + ATA_DMA_CMD); in nv_swncq_dmafis()
2187 static void nv_swncq_host_interrupt(struct ata_port *ap, u16 fis) in nv_swncq_host_interrupt() argument
2189 struct nv_swncq_port_priv *pp = ap->private_data; in nv_swncq_host_interrupt()
2191 struct ata_eh_info *ehi = &ap->link.eh_info; in nv_swncq_host_interrupt()
2195 ata_stat = ap->ops->sff_check_status(ap); in nv_swncq_host_interrupt()
2196 nv_swncq_irq_clear(ap, fis); in nv_swncq_host_interrupt()
2200 if (ap->pflags & ATA_PFLAG_FROZEN) in nv_swncq_host_interrupt()
2204 nv_swncq_hotplug(ap, fis); in nv_swncq_host_interrupt()
2211 if (ap->ops->scr_read(&ap->link, SCR_ERROR, &serror)) in nv_swncq_host_interrupt()
2213 ap->ops->scr_write(&ap->link, SCR_ERROR, serror); in nv_swncq_host_interrupt()
2221 ata_port_freeze(ap); in nv_swncq_host_interrupt()
2236 ap->print_id, pp->qc_active, pp->dhfis_bits, in nv_swncq_host_interrupt()
2238 if (nv_swncq_sdbfis(ap) < 0) in nv_swncq_host_interrupt()
2257 ata_stat = ap->ops->sff_check_status(ap); in nv_swncq_host_interrupt()
2263 qc = nv_swncq_qc_from_dq(ap); in nv_swncq_host_interrupt()
2264 nv_swncq_issue_atacmd(ap, qc); in nv_swncq_host_interrupt()
2273 pp->dmafis_bits |= (0x1 << nv_swncq_tag(ap)); in nv_swncq_host_interrupt()
2275 nv_swncq_dmafis(ap); in nv_swncq_host_interrupt()
2282 ata_port_freeze(ap); in nv_swncq_host_interrupt()
2299 struct ata_port *ap = host->ports[i]; in nv_swncq_interrupt() local
2301 if (ap->link.sactive) { in nv_swncq_interrupt()
2302 nv_swncq_host_interrupt(ap, (u16)irq_stat); in nv_swncq_interrupt()
2306 nv_swncq_irq_clear(ap, 0xfff0); in nv_swncq_interrupt()
2308 handled += nv_host_intr(ap, (u8)irq_stat); in nv_swncq_interrupt()