Lines Matching +full:ahci +full:- +full:port
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * acard-ahci.c - ACard AHCI SATA support
7 * Please ALWAYS copy linux-ide@vger.kernel.org
13 * as Documentation/driver-api/libata.rst
15 * AHCI hardware documentation:
26 #include <linux/dma-mapping.h>
33 #include "ahci.h"
35 #define DRV_NAME "acard-ahci"
70 AHCI_SHT("acard-ahci"),
115 struct ahci_host_priv *hpriv = host->private_data; in acard_ahci_pci_device_suspend()
116 void __iomem *mmio = hpriv->mmio; in acard_ahci_pci_device_suspend()
120 hpriv->flags & AHCI_HFLAG_NO_SUSPEND) { in acard_ahci_pci_device_suspend()
121 dev_err(&pdev->dev, in acard_ahci_pci_device_suspend()
123 return -EIO; in acard_ahci_pci_device_suspend()
127 /* AHCI spec rev1.1 section 8.3.3: in acard_ahci_pci_device_suspend()
149 if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { in acard_ahci_pci_device_resume()
165 struct pci_dev *pdev = to_pci_dev(host->dev); in acard_ahci_pci_print_info()
193 for_each_sg(qc->sg, sg, qc->n_elem, si) { in acard_ahci_fill_sg()
199 * We must set an end-of-table (EOT) bit, in acard_ahci_fill_sg()
215 struct ata_port *ap = qc->ap; in acard_ahci_qc_prep()
216 struct ahci_port_priv *pp = ap->private_data; in acard_ahci_qc_prep()
217 int is_atapi = ata_is_atapi(qc->tf.protocol); in acard_ahci_qc_prep()
224 * a SATA Register - Host to Device command FIS. in acard_ahci_qc_prep()
226 cmd_tbl = pp->cmd_tbl + qc->hw_tag * AHCI_CMD_TBL_SZ; in acard_ahci_qc_prep()
228 ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, cmd_tbl); in acard_ahci_qc_prep()
231 memcpy(cmd_tbl + AHCI_CMD_TBL_CDB, qc->cdb, qc->dev->cdb_len); in acard_ahci_qc_prep()
234 if (qc->flags & ATA_QCFLAG_DMAMAP) in acard_ahci_qc_prep()
242 opts = cmd_fis_len | (qc->dev->link->pmp << 12); in acard_ahci_qc_prep()
243 if (qc->tf.flags & ATA_TFLAG_WRITE) in acard_ahci_qc_prep()
248 ahci_fill_cmd_slot(pp, qc->hw_tag, opts); in acard_ahci_qc_prep()
255 struct ahci_port_priv *pp = qc->ap->private_data; in acard_ahci_qc_fill_rtf()
256 u8 *rx_fis = pp->rx_fis; in acard_ahci_qc_fill_rtf()
258 if (pp->fbs_enabled) in acard_ahci_qc_fill_rtf()
259 rx_fis += qc->dev->link->pmp * ACARD_AHCI_RX_FIS_SZ; in acard_ahci_qc_fill_rtf()
262 * After a successful execution of an ATA PIO data-in command, in acard_ahci_qc_fill_rtf()
267 if (qc->tf.protocol == ATA_PROT_PIO && qc->dma_dir == DMA_FROM_DEVICE && in acard_ahci_qc_fill_rtf()
268 !(qc->flags & ATA_QCFLAG_FAILED)) { in acard_ahci_qc_fill_rtf()
269 ata_tf_from_fis(rx_fis + RX_FIS_PIO_SETUP, &qc->result_tf); in acard_ahci_qc_fill_rtf()
270 qc->result_tf.command = (rx_fis + RX_FIS_PIO_SETUP)[15]; in acard_ahci_qc_fill_rtf()
272 ata_tf_from_fis(rx_fis + RX_FIS_D2H_REG, &qc->result_tf); in acard_ahci_qc_fill_rtf()
279 struct ahci_host_priv *hpriv = ap->host->private_data; in acard_ahci_port_start()
280 struct device *dev = ap->host->dev; in acard_ahci_port_start()
288 return -ENOMEM; in acard_ahci_port_start()
291 if ((hpriv->cap & HOST_CAP_FBS) && sata_pmp_supported(ap)) { in acard_ahci_port_start()
295 pp->fbs_supported = true; in acard_ahci_port_start()
296 else if (hpriv->flags & AHCI_HFLAG_YES_FBS) { in acard_ahci_port_start()
297 dev_info(dev, "port %d can do FBS, forcing FBSCP\n", in acard_ahci_port_start()
298 ap->port_no); in acard_ahci_port_start()
299 pp->fbs_supported = true; in acard_ahci_port_start()
301 dev_warn(dev, "port %d is not capable of FBS\n", in acard_ahci_port_start()
302 ap->port_no); in acard_ahci_port_start()
305 if (pp->fbs_supported) { in acard_ahci_port_start()
315 return -ENOMEM; in acard_ahci_port_start()
318 * First item in chunk of DMA memory: 32-slot command table, in acard_ahci_port_start()
321 pp->cmd_slot = mem; in acard_ahci_port_start()
322 pp->cmd_slot_dma = mem_dma; in acard_ahci_port_start()
328 * Second item: Received-FIS area in acard_ahci_port_start()
330 pp->rx_fis = mem; in acard_ahci_port_start()
331 pp->rx_fis_dma = mem_dma; in acard_ahci_port_start()
338 * and its scatter-gather table in acard_ahci_port_start()
340 pp->cmd_tbl = mem; in acard_ahci_port_start()
341 pp->cmd_tbl_dma = mem_dma; in acard_ahci_port_start()
347 pp->intr_mask = DEF_PORT_IRQ; in acard_ahci_port_start()
349 ap->private_data = pp; in acard_ahci_port_start()
357 unsigned int board_id = ent->driver_data; in acard_ahci_init_one()
360 struct device *dev = &pdev->dev; in acard_ahci_init_one()
369 ata_print_version_once(&pdev->dev, DRV_VERSION); in acard_ahci_init_one()
376 /* AHCI controllers often implement SFF compatible interface. in acard_ahci_init_one()
380 if (rc == -EBUSY) in acard_ahci_init_one()
387 return -ENOMEM; in acard_ahci_init_one()
389 hpriv->irq = pdev->irq; in acard_ahci_init_one()
390 hpriv->flags |= (unsigned long)pi.private_data; in acard_ahci_init_one()
392 if (!(hpriv->flags & AHCI_HFLAG_NO_MSI)) in acard_ahci_init_one()
395 hpriv->mmio = pcim_iomap_table(pdev)[AHCI_PCI_BAR]; in acard_ahci_init_one()
398 ahci_save_initial_config(&pdev->dev, hpriv); in acard_ahci_init_one()
401 if (hpriv->cap & HOST_CAP_NCQ) in acard_ahci_init_one()
404 if (hpriv->cap & HOST_CAP_PMP) in acard_ahci_init_one()
410 * port, at other times, that of the last possible port, so in acard_ahci_init_one()
411 * determining the maximum port number requires looking at in acard_ahci_init_one()
414 n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map)); in acard_ahci_init_one()
416 host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports); in acard_ahci_init_one()
418 return -ENOMEM; in acard_ahci_init_one()
419 host->private_data = hpriv; in acard_ahci_init_one()
421 if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss) in acard_ahci_init_one()
422 host->flags |= ATA_HOST_PARALLEL_SCAN; in acard_ahci_init_one()
424 printk(KERN_INFO "ahci: SSS flag set, parallel bus scan disabled\n"); in acard_ahci_init_one()
426 for (i = 0; i < host->n_ports; i++) { in acard_ahci_init_one()
427 struct ata_port *ap = host->ports[i]; in acard_ahci_init_one()
429 ata_port_pbar_desc(ap, AHCI_PCI_BAR, -1, "abar"); in acard_ahci_init_one()
431 0x100 + ap->port_no * 0x80, "port"); in acard_ahci_init_one()
435 ap->pm_policy = NOT_AVAILABLE; in acard_ahci_init_one()
437 /* disabled/not-implemented port */ in acard_ahci_init_one()
438 if (!(hpriv->port_map & (1 << i))) in acard_ahci_init_one()
439 ap->ops = &ata_dummy_port_ops; in acard_ahci_init_one()
443 rc = dma_set_mask_and_coherent(&pdev->dev, in acard_ahci_init_one()
444 DMA_BIT_MASK((hpriv->cap & HOST_CAP_64) ? 64 : 32)); in acard_ahci_init_one()
446 dev_err(&pdev->dev, "DMA enable failed\n"); in acard_ahci_init_one()
464 MODULE_DESCRIPTION("ACard AHCI SATA low-level driver");