Lines Matching +full:tf +full:- +full:a
1 // SPDX-License-Identifier: GPL-2.0-only
3 * sata_inic162x.c - Driver for Initio 162x SATA controllers
25 * from the documentation and a 2.4 IDE driver posted on a Taiwan
30 * After a while, initio picked the driver up, renamed it to
41 * issues tho. Result Tf is not resported properly, NCQ isn't
46 * Anyways, so, here's finally a working driver for inic162x. Enjoy!
48 * initio: If you guys wanna improve the driver regarding result TF
83 /* registers for ATA TF operation */
255 .max_segment_size = 65536 - 512,
266 struct inic_host_priv *hpriv = ap->host->private_data; in inic_port_base()
268 return hpriv->mmio_base + ap->port_no * PORT_SIZE; in inic_port_base()
293 void __iomem *scr_addr = inic_port_base(link->ap) + PORT_SCR; in inic_scr_read()
296 return -EINVAL; in inic_scr_read()
308 void __iomem *scr_addr = inic_port_base(link->ap) + PORT_SCR; in inic_scr_write()
311 return -EINVAL; in inic_scr_write()
328 struct ata_eh_info *ehi = &ap->link.eh_info; in inic_host_err_intr()
329 struct inic_port_priv *pp = ap->private_data; in inic_host_err_intr()
330 struct inic_cpb *cpb = &pp->pkt->cpb; in inic_host_err_intr()
353 if (cpb->resp_flags & CPB_RESP_IGNORED) { in inic_host_err_intr()
355 ehi->err_mask |= AC_ERR_INVALID; in inic_host_err_intr()
359 if (cpb->resp_flags & CPB_RESP_ATA_ERR) in inic_host_err_intr()
360 ehi->err_mask |= AC_ERR_DEV; in inic_host_err_intr()
362 if (cpb->resp_flags & CPB_RESP_SPURIOUS) { in inic_host_err_intr()
363 __ata_ehi_push_desc(ehi, " spurious-intr"); in inic_host_err_intr()
364 ehi->err_mask |= AC_ERR_HSM; in inic_host_err_intr()
368 if (cpb->resp_flags & in inic_host_err_intr()
370 __ata_ehi_push_desc(ehi, " data-over/underflow"); in inic_host_err_intr()
371 ehi->err_mask |= AC_ERR_HSM; in inic_host_err_intr()
385 struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->link.active_tag); in inic_host_intr()
408 qc->err_mask |= AC_ERR_DEV; in inic_host_intr()
416 qc ? qc->tf.command : 0xff, irq_stat, idma_stat); in inic_host_intr()
422 struct inic_host_priv *hpriv = host->private_data; in inic_interrupt()
426 host_irq_stat = readw(hpriv->mmio_base + HOST_IRQ_STAT); in inic_interrupt()
431 spin_lock(&host->lock); in inic_interrupt()
435 inic_host_intr(host->ports[i]); in inic_interrupt()
439 spin_unlock(&host->lock); in inic_interrupt()
453 if (atapi_cmd_type(qc->cdb[0]) == READ) in inic_check_atapi_dma()
464 if (qc->tf.flags & ATA_TFLAG_WRITE) in inic_fill_sg()
467 if (ata_is_dma(qc->tf.protocol)) in inic_fill_sg()
470 for_each_sg(qc->sg, sg, qc->n_elem, si) { in inic_fill_sg()
471 prd->mad = cpu_to_le32(sg_dma_address(sg)); in inic_fill_sg()
472 prd->len = cpu_to_le16(sg_dma_len(sg)); in inic_fill_sg()
473 prd->flags = flags; in inic_fill_sg()
478 prd[-1].flags |= PRD_END; in inic_fill_sg()
483 struct inic_port_priv *pp = qc->ap->private_data; in inic_qc_prep()
484 struct inic_pkt *pkt = pp->pkt; in inic_qc_prep()
485 struct inic_cpb *cpb = &pkt->cpb; in inic_qc_prep()
486 struct inic_prd *prd = pkt->prd; in inic_qc_prep()
487 bool is_atapi = ata_is_atapi(qc->tf.protocol); in inic_qc_prep()
488 bool is_data = ata_is_data(qc->tf.protocol); in inic_qc_prep()
492 cdb_len = qc->dev->cdb_len; in inic_qc_prep()
497 cpb->ctl_flags = CPB_CTL_VALID | CPB_CTL_IEN; in inic_qc_prep()
499 cpb->ctl_flags |= CPB_CTL_DATA; in inic_qc_prep()
501 cpb->len = cpu_to_le32(qc->nbytes + cdb_len); in inic_qc_prep()
502 cpb->prd = cpu_to_le32(pp->pkt_dma + offsetof(struct inic_pkt, prd)); in inic_qc_prep()
504 cpb->device = qc->tf.device; in inic_qc_prep()
505 cpb->feature = qc->tf.feature; in inic_qc_prep()
506 cpb->nsect = qc->tf.nsect; in inic_qc_prep()
507 cpb->lbal = qc->tf.lbal; in inic_qc_prep()
508 cpb->lbam = qc->tf.lbam; in inic_qc_prep()
509 cpb->lbah = qc->tf.lbah; in inic_qc_prep()
511 if (qc->tf.flags & ATA_TFLAG_LBA48) { in inic_qc_prep()
512 cpb->hob_feature = qc->tf.hob_feature; in inic_qc_prep()
513 cpb->hob_nsect = qc->tf.hob_nsect; in inic_qc_prep()
514 cpb->hob_lbal = qc->tf.hob_lbal; in inic_qc_prep()
515 cpb->hob_lbam = qc->tf.hob_lbam; in inic_qc_prep()
516 cpb->hob_lbah = qc->tf.hob_lbah; in inic_qc_prep()
519 cpb->command = qc->tf.command; in inic_qc_prep()
520 /* don't load ctl - dunno why. it's like that in the initio driver */ in inic_qc_prep()
524 memcpy(pkt->cdb, qc->cdb, ATAPI_CDB_LEN); in inic_qc_prep()
525 prd->mad = cpu_to_le32(pp->pkt_dma + in inic_qc_prep()
527 prd->len = cpu_to_le16(cdb_len); in inic_qc_prep()
528 prd->flags = PRD_CDB | PRD_WRITE; in inic_qc_prep()
530 prd->flags |= PRD_END; in inic_qc_prep()
538 pp->cpb_tbl[0] = pp->pkt_dma; in inic_qc_prep()
545 struct ata_port *ap = qc->ap; in inic_qc_issue()
556 static void inic_tf_read(struct ata_port *ap, struct ata_taskfile *tf) in inic_tf_read() argument
560 tf->error = readb(port_base + PORT_TF_FEATURE); in inic_tf_read()
561 tf->nsect = readb(port_base + PORT_TF_NSECT); in inic_tf_read()
562 tf->lbal = readb(port_base + PORT_TF_LBAL); in inic_tf_read()
563 tf->lbam = readb(port_base + PORT_TF_LBAM); in inic_tf_read()
564 tf->lbah = readb(port_base + PORT_TF_LBAH); in inic_tf_read()
565 tf->device = readb(port_base + PORT_TF_DEVICE); in inic_tf_read()
566 tf->status = readb(port_base + PORT_TF_COMMAND); in inic_tf_read()
571 struct ata_taskfile *rtf = &qc->result_tf; in inic_qc_fill_rtf()
572 struct ata_taskfile tf; in inic_qc_fill_rtf() local
574 /* FIXME: Except for status and error, result TF access in inic_qc_fill_rtf()
581 inic_tf_read(qc->ap, &tf); in inic_qc_fill_rtf()
583 if (tf.status & ATA_ERR) { in inic_qc_fill_rtf()
584 rtf->status = tf.status; in inic_qc_fill_rtf()
585 rtf->error = tf.error; in inic_qc_fill_rtf()
607 void __iomem *port_base = inic_port_base(link->ap); in inic_check_ready()
619 struct ata_port *ap = link->ap; in inic_hardreset()
622 const unsigned int *timing = sata_ehc_deb_timing(&link->eh_context); in inic_hardreset()
643 struct ata_taskfile tf; in inic_hardreset() local
647 /* link occupied, -ENODEV too is an error */ in inic_hardreset()
655 inic_tf_read(ap, &tf); in inic_hardreset()
656 *class = ata_port_classify(ap, &tf); in inic_hardreset()
673 if (qc->flags & ATA_QCFLAG_EH) in inic_post_internal_cmd()
674 inic_reset_port(inic_port_base(qc->ap)); in inic_post_internal_cmd()
680 struct inic_port_priv *pp = ap->private_data; in init_port()
683 memset(pp->pkt, 0, sizeof(struct inic_pkt)); in init_port()
684 memset(pp->cpb_tbl, 0, IDMA_CPB_TBL_SIZE); in init_port()
687 writel(pp->cpb_tbl_dma, port_base + PORT_CPB_CPBLAR); in init_port()
698 struct device *dev = ap->host->dev; in inic_port_start()
704 return -ENOMEM; in inic_port_start()
705 ap->private_data = pp; in inic_port_start()
708 pp->pkt = dmam_alloc_coherent(dev, sizeof(struct inic_pkt), in inic_port_start()
709 &pp->pkt_dma, GFP_KERNEL); in inic_port_start()
710 if (!pp->pkt) in inic_port_start()
711 return -ENOMEM; in inic_port_start()
713 pp->cpb_tbl = dmam_alloc_coherent(dev, IDMA_CPB_TBL_SIZE, in inic_port_start()
714 &pp->cpb_tbl_dma, GFP_KERNEL); in inic_port_start()
715 if (!pp->cpb_tbl) in inic_port_start()
716 return -ENOMEM; in inic_port_start()
773 return -EIO; in init_controller()
796 struct inic_host_priv *hpriv = host->private_data; in inic_pci_device_resume()
803 if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { in inic_pci_device_resume()
804 rc = init_controller(hpriv->mmio_base, hpriv->cached_hctl); in inic_pci_device_resume()
824 ata_print_version_once(&pdev->dev, DRV_VERSION); in inic_init_one()
826 …dev_alert(&pdev->dev, "inic162x support is broken with common data corruption issues and will be d… in inic_init_one()
829 host = ata_host_alloc_pinfo(&pdev->dev, ppi, NR_PORTS); in inic_init_one()
830 hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); in inic_init_one()
832 return -ENOMEM; in inic_init_one()
834 host->private_data = hpriv; in inic_init_one()
851 host->iomap = iomap = pcim_iomap_table(pdev); in inic_init_one()
852 hpriv->mmio_base = iomap[mmio_bar]; in inic_init_one()
853 hpriv->cached_hctl = readw(hpriv->mmio_base + HOST_CTL); in inic_init_one()
856 struct ata_port *ap = host->ports[i]; in inic_init_one()
858 ata_port_pbar_desc(ap, mmio_bar, -1, "mmio"); in inic_init_one()
863 rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in inic_init_one()
865 dev_err(&pdev->dev, "32-bit DMA enable failed\n"); in inic_init_one()
869 rc = init_controller(hpriv->mmio_base, hpriv->cached_hctl); in inic_init_one()
871 dev_err(&pdev->dev, "failed to initialize controller\n"); in inic_init_one()
876 return ata_host_activate(host, pdev->irq, inic_interrupt, IRQF_SHARED, in inic_init_one()
899 MODULE_DESCRIPTION("low-level driver for Initio 162x SATA");