• Home
  • Raw
  • Download

Lines Matching +full:dwc +full:- +full:ahci

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Synopsys DesignWare Cores (DWC) SATA host driver
47 #define DRV_NAME "sata-dwc"
66 /* DWC SATA Registers */
101 /* DWC SATA Register Operations */
136 struct ata_probe_ent *pe; /* ptr to probe-ent */
166 * Commonly used DWC SATA driver macros
168 #define HSDEV_FROM_HOST(host) ((struct sata_dwc_device *)(host)->private_data)
169 #define HSDEV_FROM_AP(ap) ((struct sata_dwc_device *)(ap)->host->private_data)
170 #define HSDEVP_FROM_AP(ap) ((struct sata_dwc_device_port *)(ap)->private_data)
171 #define HSDEV_FROM_QC(qc) ((struct sata_dwc_device *)(qc)->ap->host->private_data)
172 #define HSDEV_FROM_HSDEVP(p) ((struct sata_dwc_device *)(p)->hsdev)
197 #include <linux/platform_data/dma-dw.h>
211 if (dws->dma_dev != chan->device->dev) in sata_dwc_dma_filter()
214 chan->private = dws; in sata_dwc_dma_filter()
220 struct sata_dwc_device *hsdev = hsdevp->hsdev; in sata_dwc_dma_get_channel_old()
224 dws->dma_dev = hsdev->dev; in sata_dwc_dma_get_channel_old()
230 hsdevp->chan = dma_request_channel(mask, sata_dwc_dma_filter, hsdevp); in sata_dwc_dma_get_channel_old()
231 if (!hsdevp->chan) { in sata_dwc_dma_get_channel_old()
232 dev_err(hsdev->dev, "%s: dma channel unavailable\n", in sata_dwc_dma_get_channel_old()
234 return -EAGAIN; in sata_dwc_dma_get_channel_old()
243 struct device_node *np = pdev->dev.of_node; in sata_dwc_dma_init_old()
246 hsdev->dma = devm_kzalloc(&pdev->dev, sizeof(*hsdev->dma), GFP_KERNEL); in sata_dwc_dma_init_old()
247 if (!hsdev->dma) in sata_dwc_dma_init_old()
248 return -ENOMEM; in sata_dwc_dma_init_old()
250 hsdev->dma->dev = &pdev->dev; in sata_dwc_dma_init_old()
251 hsdev->dma->id = pdev->id; in sata_dwc_dma_init_old()
254 hsdev->dma->irq = irq_of_parse_and_map(np, 1); in sata_dwc_dma_init_old()
255 if (hsdev->dma->irq == NO_IRQ) { in sata_dwc_dma_init_old()
256 dev_err(&pdev->dev, "no SATA DMA irq\n"); in sata_dwc_dma_init_old()
257 return -ENODEV; in sata_dwc_dma_init_old()
262 hsdev->dma->regs = devm_ioremap_resource(&pdev->dev, res); in sata_dwc_dma_init_old()
263 if (IS_ERR(hsdev->dma->regs)) in sata_dwc_dma_init_old()
264 return PTR_ERR(hsdev->dma->regs); in sata_dwc_dma_init_old()
267 return dw_dma_probe(hsdev->dma); in sata_dwc_dma_init_old()
272 if (!hsdev->dma) in sata_dwc_dma_exit_old()
275 dw_dma_remove(hsdev->dma); in sata_dwc_dma_exit_old()
320 dev_vdbg(ap->dev, in sata_dwc_tf_dump()
322 tf->command, get_prot_descript(tf->protocol), tf->flags, in sata_dwc_tf_dump()
323 tf->device); in sata_dwc_tf_dump()
324 dev_vdbg(ap->dev, in sata_dwc_tf_dump()
326 tf->feature, tf->nsect, tf->lbal, tf->lbam, tf->lbah); in sata_dwc_tf_dump()
327 dev_vdbg(ap->dev, in sata_dwc_tf_dump()
329 tf->hob_feature, tf->hob_nsect, tf->hob_lbal, tf->hob_lbam, in sata_dwc_tf_dump()
330 tf->hob_lbah); in sata_dwc_tf_dump()
337 struct ata_host *host = (struct ata_host *)hsdev->host; in dma_dwc_xfer_done()
343 spin_lock_irqsave(&host->lock, flags); in dma_dwc_xfer_done()
344 ap = host->ports[port]; in dma_dwc_xfer_done()
346 tag = ap->link.active_tag; in dma_dwc_xfer_done()
353 hsdevp->dma_interrupt_count++; in dma_dwc_xfer_done()
356 if (hsdevp->dma_pending[tag] == SATA_DWC_DMA_PENDING_NONE) { in dma_dwc_xfer_done()
357 dev_err(ap->dev, "DMA not pending tag=0x%02x pending=%d\n", in dma_dwc_xfer_done()
358 tag, hsdevp->dma_pending[tag]); in dma_dwc_xfer_done()
361 if ((hsdevp->dma_interrupt_count % 2) == 0) in dma_dwc_xfer_done()
364 spin_unlock_irqrestore(&host->lock, flags); in dma_dwc_xfer_done()
369 struct ata_port *ap = qc->ap; in dma_dwc_xfer_setup()
375 if (qc->dma_dir == DMA_DEV_TO_MEM) { in dma_dwc_xfer_setup()
376 sconf.src_addr = hsdev->dmadr; in dma_dwc_xfer_setup()
379 sconf.dst_addr = hsdev->dmadr; in dma_dwc_xfer_setup()
383 sconf.direction = qc->dma_dir; in dma_dwc_xfer_setup()
389 dmaengine_slave_config(hsdevp->chan, &sconf); in dma_dwc_xfer_setup()
392 desc = dmaengine_prep_slave_sg(hsdevp->chan, qc->sg, qc->n_elem, in dma_dwc_xfer_setup()
393 qc->dma_dir, in dma_dwc_xfer_setup()
399 desc->callback = dma_dwc_xfer_done; in dma_dwc_xfer_setup()
400 desc->callback_param = hsdev; in dma_dwc_xfer_setup()
402 dev_dbg(hsdev->dev, "%s sg: 0x%p, count: %d addr: %pa\n", __func__, in dma_dwc_xfer_setup()
403 qc->sg, qc->n_elem, &hsdev->dmadr); in dma_dwc_xfer_setup()
411 dev_err(link->ap->dev, "%s: Incorrect SCR offset 0x%02x\n", in sata_dwc_scr_read()
413 return -EINVAL; in sata_dwc_scr_read()
416 *val = sata_dwc_readl(link->ap->ioaddr.scr_addr + (scr * 4)); in sata_dwc_scr_read()
417 dev_dbg(link->ap->dev, "%s: id=%d reg=%d val=0x%08x\n", __func__, in sata_dwc_scr_read()
418 link->ap->print_id, scr, *val); in sata_dwc_scr_read()
425 dev_dbg(link->ap->dev, "%s: id=%d reg=%d val=0x%08x\n", __func__, in sata_dwc_scr_write()
426 link->ap->print_id, scr, val); in sata_dwc_scr_write()
428 dev_err(link->ap->dev, "%s: Incorrect SCR offset 0x%02x\n", in sata_dwc_scr_write()
430 return -EINVAL; in sata_dwc_scr_write()
432 sata_dwc_writel(link->ap->ioaddr.scr_addr + (scr * 4), val); in sata_dwc_scr_write()
440 sata_dwc_scr_read(&ap->link, SCR_ERROR, &val); in clear_serror()
441 sata_dwc_scr_write(&ap->link, SCR_ERROR, val); in clear_serror()
446 sata_dwc_writel(&hsdev->sata_dwc_regs->intpr, in clear_interrupt_bit()
447 sata_dwc_readl(&hsdev->sata_dwc_regs->intpr)); in clear_interrupt_bit()
455 /* See ahci.c */
460 struct ata_eh_info *ehi = &ap->link.eh_info; in sata_dwc_error_intr()
468 sata_dwc_scr_read(&ap->link, SCR_ERROR, &serror); in sata_dwc_error_intr()
469 status = ap->ops->sff_check_status(ap); in sata_dwc_error_intr()
471 tag = ap->link.active_tag; in sata_dwc_error_intr()
473 dev_err(ap->dev, in sata_dwc_error_intr()
475 __func__, serror, intpr, status, hsdevp->dma_interrupt_count, in sata_dwc_error_intr()
476 hsdevp->dma_pending[tag], hsdevp->cmd_issued[tag]); in sata_dwc_error_intr()
488 ehi->serror |= serror; in sata_dwc_error_intr()
489 ehi->action |= action; in sata_dwc_error_intr()
493 qc->err_mask |= err_mask; in sata_dwc_error_intr()
495 ehi->err_mask |= err_mask; in sata_dwc_error_intr()
503 * Return value : irqreturn_t - status of IRQ
518 hsdev->sactive_issued = 0; in sata_dwc_isr()
520 spin_lock_irqsave(&host->lock, flags); in sata_dwc_isr()
523 intpr = sata_dwc_readl(&hsdev->sata_dwc_regs->intpr); in sata_dwc_isr()
525 ap = host->ports[port]; in sata_dwc_isr()
528 dev_dbg(ap->dev, "%s intpr=0x%08x active_tag=%d\n", __func__, intpr, in sata_dwc_isr()
529 ap->link.active_tag); in sata_dwc_isr()
542 tag = (u8)(sata_dwc_readl(&hsdev->sata_dwc_regs->fptagr)); in sata_dwc_isr()
543 dev_dbg(ap->dev, "%s: NEWFP tag=%d\n", __func__, tag); in sata_dwc_isr()
544 if (hsdevp->cmd_issued[tag] != SATA_DWC_CMD_ISSUED_PEND) in sata_dwc_isr()
545 dev_warn(ap->dev, "CMD tag=%d not pending?\n", tag); in sata_dwc_isr()
547 hsdev->sactive_issued |= qcmd_tag_to_mask(tag); in sata_dwc_isr()
555 qc->ap->link.active_tag = tag; in sata_dwc_isr()
561 sata_dwc_scr_read(&ap->link, SCR_ACTIVE, &sactive); in sata_dwc_isr()
562 tag_mask = (hsdev->sactive_issued | sactive) ^ sactive; in sata_dwc_isr()
565 if (hsdev->sactive_issued == 0 && tag_mask == 0) { in sata_dwc_isr()
566 if (ap->link.active_tag == ATA_TAG_POISON) in sata_dwc_isr()
569 tag = ap->link.active_tag; in sata_dwc_isr()
573 if (unlikely(!qc || (qc->tf.flags & ATA_TFLAG_POLLING))) { in sata_dwc_isr()
574 dev_err(ap->dev, in sata_dwc_isr()
577 ap->ops->sff_check_status(ap); in sata_dwc_isr()
581 status = ap->ops->sff_check_status(ap); in sata_dwc_isr()
583 qc->ap->link.active_tag = tag; in sata_dwc_isr()
584 hsdevp->cmd_issued[tag] = SATA_DWC_CMD_ISSUED_NOT; in sata_dwc_isr()
587 dev_dbg(ap->dev, "interrupt ATA_ERR (0x%x)\n", status); in sata_dwc_isr()
593 dev_dbg(ap->dev, "%s non-NCQ cmd interrupt, protocol: %s\n", in sata_dwc_isr()
594 __func__, get_prot_descript(qc->tf.protocol)); in sata_dwc_isr()
596 if (ata_is_dma(qc->tf.protocol)) { in sata_dwc_isr()
603 hsdevp->dma_interrupt_count++; in sata_dwc_isr()
604 if (hsdevp->dma_pending[tag] == \ in sata_dwc_isr()
606 dev_err(ap->dev, in sata_dwc_isr()
609 hsdevp->dma_pending[tag]); in sata_dwc_isr()
612 if ((hsdevp->dma_interrupt_count % 2) == 0) in sata_dwc_isr()
614 } else if (ata_is_pio(qc->tf.protocol)) { in sata_dwc_isr()
635 sata_dwc_scr_read(&ap->link, SCR_ACTIVE, &sactive); in sata_dwc_isr()
636 tag_mask = (hsdev->sactive_issued | sactive) ^ sactive; in sata_dwc_isr()
638 if (sactive != 0 || hsdev->sactive_issued > 1 || tag_mask > 1) { in sata_dwc_isr()
639 dev_dbg(ap->dev, in sata_dwc_isr()
641 __func__, sactive, hsdev->sactive_issued, tag_mask); in sata_dwc_isr()
644 if ((tag_mask | hsdev->sactive_issued) != hsdev->sactive_issued) { in sata_dwc_isr()
645 dev_warn(ap->dev, in sata_dwc_isr()
647 sactive, hsdev->sactive_issued, tag_mask); in sata_dwc_isr()
651 status = ap->ops->sff_check_status(ap); in sata_dwc_isr()
652 dev_dbg(ap->dev, "%s ATA status register=0x%x\n", __func__, status); in sata_dwc_isr()
667 qc->ap->link.active_tag = tag; in sata_dwc_isr()
668 hsdevp->cmd_issued[tag] = SATA_DWC_CMD_ISSUED_NOT; in sata_dwc_isr()
672 dev_dbg(ap->dev, "%s ATA_ERR (0x%x)\n", __func__, in sata_dwc_isr()
680 dev_dbg(ap->dev, "%s NCQ command, protocol: %s\n", __func__, in sata_dwc_isr()
681 get_prot_descript(qc->tf.protocol)); in sata_dwc_isr()
682 if (ata_is_dma(qc->tf.protocol)) { in sata_dwc_isr()
683 hsdevp->dma_interrupt_count++; in sata_dwc_isr()
684 if (hsdevp->dma_pending[tag] == \ in sata_dwc_isr()
686 dev_warn(ap->dev, "%s: DMA not pending?\n", in sata_dwc_isr()
688 if ((hsdevp->dma_interrupt_count % 2) == 0) in sata_dwc_isr()
697 ap->stats.idle_irq++; in sata_dwc_isr()
698 dev_warn(ap->dev, "STILL BUSY IRQ ata%d: irq trap\n", in sata_dwc_isr()
699 ap->print_id); in sata_dwc_isr()
706 * we were processing --we read status as part of processing a completed in sata_dwc_isr()
709 sata_dwc_scr_read(&ap->link, SCR_ACTIVE, &sactive2); in sata_dwc_isr()
711 dev_dbg(ap->dev, in sata_dwc_isr()
712 "More completed - sactive=0x%x sactive2=0x%x\n", in sata_dwc_isr()
718 spin_unlock_irqrestore(&host->lock, flags); in sata_dwc_isr()
725 u32 dmacr = sata_dwc_readl(&hsdev->sata_dwc_regs->dmacr); in sata_dwc_clear_dmacr()
727 if (hsdevp->dma_pending[tag] == SATA_DWC_DMA_PENDING_RX) { in sata_dwc_clear_dmacr()
729 sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr, dmacr); in sata_dwc_clear_dmacr()
730 } else if (hsdevp->dma_pending[tag] == SATA_DWC_DMA_PENDING_TX) { in sata_dwc_clear_dmacr()
732 sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr, dmacr); in sata_dwc_clear_dmacr()
738 dev_err(hsdev->dev, in sata_dwc_clear_dmacr()
740 __func__, tag, hsdevp->dma_pending[tag], dmacr); in sata_dwc_clear_dmacr()
741 sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr, in sata_dwc_clear_dmacr()
753 tag = ap->link.active_tag; in sata_dwc_dma_xfer_complete()
756 dev_err(ap->dev, "failed to get qc"); in sata_dwc_dma_xfer_complete()
762 dev_info(ap->dev, in sata_dwc_dma_xfer_complete()
764 __func__, qc->hw_tag, qc->tf.command, in sata_dwc_dma_xfer_complete()
765 get_dma_dir_descript(qc->dma_dir), in sata_dwc_dma_xfer_complete()
766 get_prot_descript(qc->tf.protocol), in sata_dwc_dma_xfer_complete()
767 sata_dwc_readl(&hsdev->sata_dwc_regs->dmacr)); in sata_dwc_dma_xfer_complete()
771 if (ata_is_dma(qc->tf.protocol)) { in sata_dwc_dma_xfer_complete()
772 if (hsdevp->dma_pending[tag] == SATA_DWC_DMA_PENDING_NONE) { in sata_dwc_dma_xfer_complete()
773 dev_err(ap->dev, in sata_dwc_dma_xfer_complete()
776 sata_dwc_readl(&hsdev->sata_dwc_regs->dmacr)); in sata_dwc_dma_xfer_complete()
779 hsdevp->dma_pending[tag] = SATA_DWC_DMA_PENDING_NONE; in sata_dwc_dma_xfer_complete()
781 ap->link.active_tag = ATA_TAG_POISON; in sata_dwc_dma_xfer_complete()
792 u8 tag = qc->hw_tag; in sata_dwc_qc_complete()
795 hsdev->sactive_queued = 0; in sata_dwc_qc_complete()
796 dev_dbg(ap->dev, "%s checkstatus? %x\n", __func__, check_status); in sata_dwc_qc_complete()
798 if (hsdevp->dma_pending[tag] == SATA_DWC_DMA_PENDING_TX) in sata_dwc_qc_complete()
799 dev_err(ap->dev, "TX DMA PENDING\n"); in sata_dwc_qc_complete()
800 else if (hsdevp->dma_pending[tag] == SATA_DWC_DMA_PENDING_RX) in sata_dwc_qc_complete()
801 dev_err(ap->dev, "RX DMA PENDING\n"); in sata_dwc_qc_complete()
802 dev_dbg(ap->dev, in sata_dwc_qc_complete()
804 qc->tf.command, status, ap->print_id, qc->tf.protocol); in sata_dwc_qc_complete()
808 hsdev->sactive_queued = hsdev->sactive_queued & mask; in sata_dwc_qc_complete()
809 hsdev->sactive_issued = hsdev->sactive_issued & mask; in sata_dwc_qc_complete()
817 sata_dwc_writel(&hsdev->sata_dwc_regs->intmr, in sata_dwc_enable_interrupts()
826 sata_dwc_writel(&hsdev->sata_dwc_regs->errmr, SATA_DWC_SERROR_ERR_BITS); in sata_dwc_enable_interrupts()
828 dev_dbg(hsdev->dev, "%s: INTMR = 0x%08x, ERRMR = 0x%08x\n", in sata_dwc_enable_interrupts()
829 __func__, sata_dwc_readl(&hsdev->sata_dwc_regs->intmr), in sata_dwc_enable_interrupts()
830 sata_dwc_readl(&hsdev->sata_dwc_regs->errmr)); in sata_dwc_enable_interrupts()
835 port->cmd_addr = base + 0x00; in sata_dwc_setup_port()
836 port->data_addr = base + 0x00; in sata_dwc_setup_port()
838 port->error_addr = base + 0x04; in sata_dwc_setup_port()
839 port->feature_addr = base + 0x04; in sata_dwc_setup_port()
841 port->nsect_addr = base + 0x08; in sata_dwc_setup_port()
843 port->lbal_addr = base + 0x0c; in sata_dwc_setup_port()
844 port->lbam_addr = base + 0x10; in sata_dwc_setup_port()
845 port->lbah_addr = base + 0x14; in sata_dwc_setup_port()
847 port->device_addr = base + 0x18; in sata_dwc_setup_port()
848 port->command_addr = base + 0x1c; in sata_dwc_setup_port()
849 port->status_addr = base + 0x1c; in sata_dwc_setup_port()
851 port->altstatus_addr = base + 0x20; in sata_dwc_setup_port()
852 port->ctl_addr = base + 0x20; in sata_dwc_setup_port()
857 struct sata_dwc_device *hsdev = hsdevp->hsdev; in sata_dwc_dma_get_channel()
858 struct device *dev = hsdev->dev; in sata_dwc_dma_get_channel()
861 if (!of_find_property(dev->of_node, "dmas", NULL)) in sata_dwc_dma_get_channel()
865 hsdevp->chan = dma_request_chan(dev, "sata-dma"); in sata_dwc_dma_get_channel()
866 if (IS_ERR(hsdevp->chan)) { in sata_dwc_dma_get_channel()
868 PTR_ERR(hsdevp->chan)); in sata_dwc_dma_get_channel()
869 return PTR_ERR(hsdevp->chan); in sata_dwc_dma_get_channel()
891 dev_dbg(ap->dev, "%s: port_no=%d\n", __func__, ap->port_no); in sata_dwc_port_start()
893 hsdev->host = ap->host; in sata_dwc_port_start()
894 pdev = ap->host->dev; in sata_dwc_port_start()
896 dev_err(ap->dev, "%s: no ap->host->dev\n", __func__); in sata_dwc_port_start()
897 err = -ENODEV; in sata_dwc_port_start()
904 err = -ENOMEM; in sata_dwc_port_start()
907 hsdevp->hsdev = hsdev; in sata_dwc_port_start()
913 err = phy_power_on(hsdev->phy); in sata_dwc_port_start()
918 hsdevp->cmd_issued[i] = SATA_DWC_CMD_ISSUED_NOT; in sata_dwc_port_start()
920 ap->bmdma_prd = NULL; /* set these so libata doesn't use them */ in sata_dwc_port_start()
921 ap->bmdma_prd_dma = 0; in sata_dwc_port_start()
923 if (ap->port_no == 0) { in sata_dwc_port_start()
924 dev_dbg(ap->dev, "%s: clearing TXCHEN, RXCHEN in DMAC\n", in sata_dwc_port_start()
926 sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr, in sata_dwc_port_start()
929 dev_dbg(ap->dev, "%s: setting burst size in DBTSR\n", in sata_dwc_port_start()
931 sata_dwc_writel(&hsdev->sata_dwc_regs->dbtsr, in sata_dwc_port_start()
938 ap->private_data = hsdevp; in sata_dwc_port_start()
939 dev_dbg(ap->dev, "%s: done\n", __func__); in sata_dwc_port_start()
945 dev_dbg(ap->dev, "%s: fail. ap->id = %d\n", __func__, ap->print_id); in sata_dwc_port_start()
954 dev_dbg(ap->dev, "%s: ap->id = %d\n", __func__, ap->print_id); in sata_dwc_port_stop()
956 dmaengine_terminate_sync(hsdevp->chan); in sata_dwc_port_stop()
957 dma_release_channel(hsdevp->chan); in sata_dwc_port_stop()
958 phy_power_off(hsdev->phy); in sata_dwc_port_stop()
961 ap->private_data = NULL; in sata_dwc_port_stop()
977 dev_dbg(ap->dev, "%s cmd(0x%02x): %s tag=%d\n", __func__, tf->command, in sata_dwc_exec_command_by_tag()
978 ata_get_cmd_descript(tf->command), tag); in sata_dwc_exec_command_by_tag()
980 hsdevp->cmd_issued[tag] = cmd_issued; in sata_dwc_exec_command_by_tag()
994 sata_dwc_exec_command_by_tag(qc->ap, &qc->tf, tag, in sata_dwc_bmdma_setup_by_tag()
1000 u8 tag = qc->hw_tag; in sata_dwc_bmdma_setup()
1002 if (ata_is_ncq(qc->tf.protocol)) { in sata_dwc_bmdma_setup()
1003 dev_dbg(qc->ap->dev, "%s: ap->link.sactive=0x%08x tag=%d\n", in sata_dwc_bmdma_setup()
1004 __func__, qc->ap->link.sactive, tag); in sata_dwc_bmdma_setup()
1016 struct ata_port *ap = qc->ap; in sata_dwc_bmdma_start_by_tag()
1018 struct dma_async_tx_descriptor *desc = hsdevp->desc[tag]; in sata_dwc_bmdma_start_by_tag()
1019 int dir = qc->dma_dir; in sata_dwc_bmdma_start_by_tag()
1021 if (hsdevp->cmd_issued[tag] != SATA_DWC_CMD_ISSUED_NOT) { in sata_dwc_bmdma_start_by_tag()
1024 hsdevp->dma_pending[tag] = SATA_DWC_DMA_PENDING_TX; in sata_dwc_bmdma_start_by_tag()
1026 hsdevp->dma_pending[tag] = SATA_DWC_DMA_PENDING_RX; in sata_dwc_bmdma_start_by_tag()
1028 dev_err(ap->dev, in sata_dwc_bmdma_start_by_tag()
1030 __func__, hsdevp->cmd_issued[tag], tag); in sata_dwc_bmdma_start_by_tag()
1034 dev_dbg(ap->dev, in sata_dwc_bmdma_start_by_tag()
1036 __func__, qc, tag, qc->tf.command, in sata_dwc_bmdma_start_by_tag()
1037 get_dma_dir_descript(qc->dma_dir), start_dma); in sata_dwc_bmdma_start_by_tag()
1038 sata_dwc_tf_dump(ap, &qc->tf); in sata_dwc_bmdma_start_by_tag()
1041 sata_dwc_scr_read(&ap->link, SCR_ERROR, &reg); in sata_dwc_bmdma_start_by_tag()
1043 dev_err(ap->dev, "%s: ****** SError=0x%08x ******\n", in sata_dwc_bmdma_start_by_tag()
1048 sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr, in sata_dwc_bmdma_start_by_tag()
1051 sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr, in sata_dwc_bmdma_start_by_tag()
1056 dma_async_issue_pending(hsdevp->chan); in sata_dwc_bmdma_start_by_tag()
1062 u8 tag = qc->hw_tag; in sata_dwc_bmdma_start()
1064 if (ata_is_ncq(qc->tf.protocol)) { in sata_dwc_bmdma_start()
1065 dev_dbg(qc->ap->dev, "%s: ap->link.sactive=0x%08x tag=%d\n", in sata_dwc_bmdma_start()
1066 __func__, qc->ap->link.sactive, tag); in sata_dwc_bmdma_start()
1070 dev_dbg(qc->ap->dev, "%s\n", __func__); in sata_dwc_bmdma_start()
1077 u8 tag = qc->hw_tag; in sata_dwc_qc_issue()
1078 struct ata_port *ap = qc->ap; in sata_dwc_qc_issue()
1082 if (qc->hw_tag > 0 || ap->link.sactive > 1) in sata_dwc_qc_issue()
1083 dev_info(ap->dev, in sata_dwc_qc_issue()
1085 __func__, ap->print_id, qc->tf.command, in sata_dwc_qc_issue()
1086 ata_get_cmd_descript(qc->tf.command), in sata_dwc_qc_issue()
1087 qc->hw_tag, get_prot_descript(qc->tf.protocol), in sata_dwc_qc_issue()
1088 ap->link.active_tag, ap->link.sactive); in sata_dwc_qc_issue()
1091 if (!ata_is_ncq(qc->tf.protocol)) in sata_dwc_qc_issue()
1094 if (ata_is_dma(qc->tf.protocol)) { in sata_dwc_qc_issue()
1095 hsdevp->desc[tag] = dma_dwc_xfer_setup(qc); in sata_dwc_qc_issue()
1096 if (!hsdevp->desc[tag]) in sata_dwc_qc_issue()
1099 hsdevp->desc[tag] = NULL; in sata_dwc_qc_issue()
1102 if (ata_is_ncq(qc->tf.protocol)) { in sata_dwc_qc_issue()
1103 sata_dwc_scr_read(&ap->link, SCR_ACTIVE, &sactive); in sata_dwc_qc_issue()
1105 sata_dwc_scr_write(&ap->link, SCR_ACTIVE, sactive); in sata_dwc_qc_issue()
1107 dev_dbg(qc->ap->dev, in sata_dwc_qc_issue()
1108 "%s: tag=%d ap->link.sactive = 0x%08x sactive=0x%08x\n", in sata_dwc_qc_issue()
1109 __func__, tag, qc->ap->link.sactive, sactive); in sata_dwc_qc_issue()
1111 ap->ops->sff_tf_load(ap, &qc->tf); in sata_dwc_qc_issue()
1112 sata_dwc_exec_command_by_tag(ap, &qc->tf, tag, in sata_dwc_qc_issue()
1128 struct sata_dwc_device *hsdev = HSDEV_FROM_AP(link->ap); in sata_dwc_hardreset()
1136 sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr, in sata_dwc_hardreset()
1140 sata_dwc_writel(&hsdev->sata_dwc_regs->dbtsr, in sata_dwc_hardreset()
1149 /* SATA DWC is master only */ in sata_dwc_dev_select()
1153 * scsi mid-layer and libata interface structures
1158 * test-only: Currently this driver doesn't handle NCQ
1167 * that a DMA burst will cross that boundary -- this results in an
1213 struct device_node *np = ofdev->dev.of_node; in sata_dwc_probe()
1216 /* Allocate DWC SATA device */ in sata_dwc_probe()
1217 host = ata_host_alloc_pinfo(&ofdev->dev, ppi, SATA_DWC_MAX_PORTS); in sata_dwc_probe()
1218 hsdev = devm_kzalloc(&ofdev->dev, sizeof(*hsdev), GFP_KERNEL); in sata_dwc_probe()
1220 return -ENOMEM; in sata_dwc_probe()
1222 host->private_data = hsdev; in sata_dwc_probe()
1226 base = devm_ioremap_resource(&ofdev->dev, res); in sata_dwc_probe()
1229 dev_dbg(&ofdev->dev, "ioremap done for SATA register address\n"); in sata_dwc_probe()
1231 /* Synopsys DWC SATA specific Registers */ in sata_dwc_probe()
1232 hsdev->sata_dwc_regs = base + SATA_DWC_REG_OFFSET; in sata_dwc_probe()
1233 hsdev->dmadr = res->start + SATA_DWC_REG_OFFSET + offsetof(struct sata_dwc_regs, dmadr); in sata_dwc_probe()
1236 host->ports[0]->ioaddr.cmd_addr = base; in sata_dwc_probe()
1237 host->ports[0]->ioaddr.scr_addr = base + SATA_DWC_SCR_OFFSET; in sata_dwc_probe()
1238 sata_dwc_setup_port(&host->ports[0]->ioaddr, base); in sata_dwc_probe()
1241 idr = sata_dwc_readl(&hsdev->sata_dwc_regs->idr); in sata_dwc_probe()
1242 versionr = sata_dwc_readl(&hsdev->sata_dwc_regs->versionr); in sata_dwc_probe()
1243 dev_notice(&ofdev->dev, "id %d, controller version %c.%c%c\n", in sata_dwc_probe()
1247 hsdev->dev = &ofdev->dev; in sata_dwc_probe()
1255 dev_err(&ofdev->dev, "no SATA DMA irq\n"); in sata_dwc_probe()
1256 return -ENODEV; in sata_dwc_probe()
1267 hsdev->phy = devm_phy_optional_get(hsdev->dev, "sata-phy"); in sata_dwc_probe()
1268 if (IS_ERR(hsdev->phy)) in sata_dwc_probe()
1269 return PTR_ERR(hsdev->phy); in sata_dwc_probe()
1271 err = phy_init(hsdev->phy); in sata_dwc_probe()
1282 dev_err(&ofdev->dev, "failed to activate host"); in sata_dwc_probe()
1287 phy_exit(hsdev->phy); in sata_dwc_probe()
1293 struct device *dev = &ofdev->dev; in sata_dwc_remove()
1295 struct sata_dwc_device *hsdev = host->private_data; in sata_dwc_remove()
1299 phy_exit(hsdev->phy); in sata_dwc_remove()
1306 dev_dbg(&ofdev->dev, "done\n"); in sata_dwc_remove()
1311 { .compatible = "amcc,sata-460ex", },