#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/blkdev.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/dma-mapping.h>
#include <linux/device.h>
#include <linux/dmi.h>
#include <linux/gfp.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_cmnd.h>
#include <linux/libata.h>
#include <linux/ahci-remap.h>
#include <linux/io-64-nonatomic-lo-hi.h>
#include "ahci.h"
#define DRV_NAME …
#define DRV_VERSION …
enum { … };
enum board_ids { … };
static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
static void ahci_remove_one(struct pci_dev *dev);
static void ahci_shutdown_one(struct pci_dev *dev);
static void ahci_intel_pcs_quirk(struct pci_dev *pdev, struct ahci_host_priv *hpriv);
static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
unsigned long deadline);
static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class,
unsigned long deadline);
static void ahci_mcp89_apple_enable(struct pci_dev *pdev);
static bool is_mcp89_apple(struct pci_dev *pdev);
static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
unsigned long deadline);
#ifdef CONFIG_PM
static int ahci_pci_device_runtime_suspend(struct device *dev);
static int ahci_pci_device_runtime_resume(struct device *dev);
#ifdef CONFIG_PM_SLEEP
static int ahci_pci_device_suspend(struct device *dev);
static int ahci_pci_device_resume(struct device *dev);
#endif
#endif
static const struct scsi_host_template ahci_sht = …;
static struct ata_port_operations ahci_vt8251_ops = …;
static struct ata_port_operations ahci_p5wdh_ops = …;
static struct ata_port_operations ahci_avn_ops = …;
static const struct ata_port_info ahci_port_info[] = …;
static const struct pci_device_id ahci_pci_tbl[] = …;
static const struct dev_pm_ops ahci_pci_pm_ops = …;
static struct pci_driver ahci_pci_driver = …;
#if IS_ENABLED(CONFIG_PATA_MARVELL)
static int marvell_enable;
#else
static int marvell_enable = 1;
#endif
module_param(marvell_enable, int, 0644);
MODULE_PARM_DESC(…) …;
static int mobile_lpm_policy = …;
module_param(mobile_lpm_policy, int, 0644);
MODULE_PARM_DESC(…) …;
static char *ahci_mask_port_map;
module_param_named(mask_port_map, ahci_mask_port_map, charp, 0444);
MODULE_PARM_DESC(…) …;
static void ahci_apply_port_map_mask(struct device *dev,
struct ahci_host_priv *hpriv, char *mask_s)
{ … }
static void ahci_get_port_map_mask(struct device *dev,
struct ahci_host_priv *hpriv)
{ … }
static void ahci_pci_save_initial_config(struct pci_dev *pdev,
struct ahci_host_priv *hpriv)
{ … }
static int ahci_pci_reset_controller(struct ata_host *host)
{ … }
static void ahci_pci_init_controller(struct ata_host *host)
{ … }
static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
unsigned long deadline)
{ … }
static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
unsigned long deadline)
{ … }
static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class,
unsigned long deadline)
{ … }
#ifdef CONFIG_PM
static void ahci_pci_disable_interrupts(struct ata_host *host)
{ … }
static int ahci_pci_device_runtime_suspend(struct device *dev)
{ … }
static int ahci_pci_device_runtime_resume(struct device *dev)
{ … }
#ifdef CONFIG_PM_SLEEP
static int ahci_pci_device_suspend(struct device *dev)
{ … }
static int ahci_pci_device_resume(struct device *dev)
{ … }
#endif
#endif
static int ahci_configure_dma_masks(struct pci_dev *pdev,
struct ahci_host_priv *hpriv)
{ … }
static void ahci_pci_print_info(struct ata_host *host)
{ … }
static void ahci_p5wdh_workaround(struct ata_host *host)
{ … }
static void ahci_mcp89_apple_enable(struct pci_dev *pdev)
{ … }
static bool is_mcp89_apple(struct pci_dev *pdev)
{ … }
static bool ahci_sb600_enable_64bit(struct pci_dev *pdev)
{ … }
static bool ahci_broken_system_poweroff(struct pci_dev *pdev)
{ … }
static bool ahci_broken_suspend(struct pci_dev *pdev)
{ … }
static bool ahci_broken_lpm(struct pci_dev *pdev)
{ … }
static bool ahci_broken_online(struct pci_dev *pdev)
{ … }
#ifdef CONFIG_ATA_ACPI
static void ahci_gtf_filter_workaround(struct ata_host *host)
{ … }
#else
static inline void ahci_gtf_filter_workaround(struct ata_host *host)
{}
#endif
static void acer_sa5_271_workaround(struct ahci_host_priv *hpriv,
struct pci_dev *pdev)
{ … }
#ifdef CONFIG_ARM64
static irqreturn_t ahci_thunderx_irq_handler(int irq, void *dev_instance)
{
struct ata_host *host = dev_instance;
struct ahci_host_priv *hpriv;
unsigned int rc = 0;
void __iomem *mmio;
u32 irq_stat, irq_masked;
unsigned int handled = 1;
hpriv = host->private_data;
mmio = hpriv->mmio;
irq_stat = readl(mmio + HOST_IRQ_STAT);
if (!irq_stat)
return IRQ_NONE;
do {
irq_masked = irq_stat & hpriv->port_map;
spin_lock(&host->lock);
rc = ahci_handle_port_intr(host, irq_masked);
if (!rc)
handled = 0;
writel(irq_stat, mmio + HOST_IRQ_STAT);
irq_stat = readl(mmio + HOST_IRQ_STAT);
spin_unlock(&host->lock);
} while (irq_stat);
return IRQ_RETVAL(handled);
}
#endif
static void ahci_remap_check(struct pci_dev *pdev, int bar,
struct ahci_host_priv *hpriv)
{ … }
static int ahci_get_irq_vector(struct ata_host *host, int port)
{ … }
static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports,
struct ahci_host_priv *hpriv)
{ … }
static void ahci_mark_external_port(struct ata_port *ap)
{ … }
static void ahci_update_initial_lpm_policy(struct ata_port *ap)
{ … }
static void ahci_intel_pcs_quirk(struct pci_dev *pdev, struct ahci_host_priv *hpriv)
{ … }
static ssize_t remapped_nvme_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR_RO(remapped_nvme);
static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{ … }
static void ahci_shutdown_one(struct pci_dev *pdev)
{ … }
static void ahci_remove_one(struct pci_dev *pdev)
{ … }
module_pci_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
MODULE_DEVICE_TABLE(pci, ahci_pci_tbl);
MODULE_VERSION(…);