36 #include <linux/kernel.h>
37 #include <linux/module.h>
38 #include <linux/pci.h>
44 #include <linux/device.h>
52 #define DRV_NAME "acard-ahci"
53 #define DRV_VERSION "1.0"
59 #define ACARD_AHCI_RX_FIS_SZ 128
78 static int acard_ahci_port_start(
struct ata_port *ap);
83 static int acard_ahci_pci_device_resume(
struct pci_dev *pdev);
92 .qc_prep = acard_ahci_qc_prep,
93 .qc_fill_rtf = acard_ahci_qc_fill_rtf,
94 .port_start = acard_ahci_port_start,
97 #define AHCI_HFLAGS(flags) .private_data = (void *)(flags)
106 .port_ops = &acard_ops,
117 static struct pci_driver acard_ahci_pci_driver = {
119 .id_table = acard_ahci_pci_tbl,
120 .probe = acard_ahci_init_one,
121 .remove = ata_pci_remove_one,
123 .suspend = acard_ahci_pci_device_suspend,
124 .resume = acard_ahci_pci_device_resume,
139 "BIOS update required for suspend/resume\n");
154 return ata_pci_device_suspend(pdev, mesg);
157 static int acard_ahci_pci_device_resume(
struct pci_dev *pdev)
162 rc = ata_pci_device_do_resume(pdev);
174 ata_host_resume(host);
180 static int acard_ahci_configure_dma_masks(
struct pci_dev *pdev,
int using_dac)
186 rc = pci_set_consistent_dma_mask(pdev,
DMA_BIT_MASK(64));
188 rc = pci_set_consistent_dma_mask(pdev,
DMA_BIT_MASK(32));
191 "64-bit DMA enable failed\n");
198 dev_err(&pdev->
dev,
"32-bit DMA enable failed\n");
201 rc = pci_set_consistent_dma_mask(pdev,
DMA_BIT_MASK(32));
204 "32-bit consistent DMA enable failed\n");
211 static void acard_ahci_pci_print_info(
struct ata_host *host)
217 pci_read_config_word(pdev, 0x0a, &cc);
230 static unsigned int acard_ahci_fill_sg(
struct ata_queued_cmd *qc,
void *cmd_tbl)
234 unsigned int si, last_si = 0;
265 int is_atapi = ata_is_atapi(qc->
tf.protocol);
268 const u32 cmd_fis_len = 5;
285 n_elem = acard_ahci_fill_sg(qc, cmd_tbl);
292 opts = cmd_fis_len | (qc->
dev->link->pmp << 12);
325 static int acard_ahci_port_start(
struct ata_port *ap)
332 size_t dma_sz, rx_fis_sz;
340 void __iomem *port_mmio = ahci_port_base(ap);
345 dev_info(dev,
"port %d can do FBS, forcing FBSCP\n",
349 dev_warn(dev,
"port %d is not capable of FBS\n",
383 mem_dma += rx_fis_sz;
440 pci_enable_msi(pdev);
473 for (i = 0; i < host->
n_ports; i++) {
478 0x100 + ap->
port_no * 0x80,
"port");
490 rc = acard_ahci_configure_dma_masks(pdev, hpriv->
cap &
HOST_CAP_64);
499 acard_ahci_pci_print_info(host);