/*
 * Cavium ThunderX memory controller kernel module
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright Cavium, Inc. (C) 2015-2017. All rights reserved.
 *
 */

#include <linux/module.h>
#include <linux/pci.h>
#include <linux/edac.h>
#include <linux/interrupt.h>
#include <linux/string.h>
#include <linux/stop_machine.h>
#include <linux/delay.h>
#include <linux/sizes.h>
#include <linux/atomic.h>
#include <linux/bitfield.h>
#include <linux/circ_buf.h>

#include <asm/page.h>

#include "edac_module.h"

#define phys_to_pfn(phys)	(PFN_DOWN(phys))

#define THUNDERX_NODE		GENMASK(45, 44)

enum {
	ERR_CORRECTED	= 1,
	ERR_UNCORRECTED	= 2,
	ERR_UNKNOWN	= 3,
};

#define MAX_SYNDROME_REGS 4

struct error_syndrome {
	u64 reg[MAX_SYNDROME_REGS];
};

struct error_descr {
	int	type;
	u64	mask;
	char	*descr;
};

static void decode_register(char *str, size_t size,
			   const struct error_descr *descr,
			   const uint64_t reg)
{
	int ret = 0;

	while (descr->type && descr->mask && descr->descr) {
		if (reg & descr->mask) {
			ret = snprintf(str, size, "\n\t%s, %s",
				       descr->type == ERR_CORRECTED ?
					 "Corrected" : "Uncorrected",
				       descr->descr);
			str += ret;
			size -= ret;
		}
		descr++;
	}
}

static unsigned long get_bits(unsigned long data, int pos, int width)
{
	return (data >> pos) & ((1 << width) - 1);
}

#define L2C_CTL			0x87E080800000
#define L2C_CTL_DISIDXALIAS	BIT(0)

#define PCI_DEVICE_ID_THUNDER_LMC 0xa022

#define LMC_FADR		0x20
#define LMC_FADR_FDIMM(x)	((x >> 37) & 0x1)
#define LMC_FADR_FBUNK(x)	((x >> 36) & 0x1)
#define LMC_FADR_FBANK(x)	((x >> 32) & 0xf)
#define LMC_FADR_FROW(x)	((x >> 14) & 0xffff)
#define LMC_FADR_FCOL(x)	((x >> 0) & 0x1fff)

#define LMC_NXM_FADR		0x28
#define LMC_ECC_SYND		0x38

#define LMC_ECC_PARITY_TEST	0x108

#define LMC_INT_W1S		0x150

#define LMC_INT_ENA_W1C		0x158
#define LMC_INT_ENA_W1S		0x160

#define LMC_CONFIG		0x188

#define LMC_CONFIG_BG2		BIT(62)
#define LMC_CONFIG_RANK_ENA	BIT(42)
#define LMC_CONFIG_PBANK_LSB(x)	(((x) >> 5) & 0xF)
#define LMC_CONFIG_ROW_LSB(x)	(((x) >> 2) & 0x7)

#define LMC_CONTROL		0x190
#define LMC_CONTROL_XOR_BANK	BIT(16)

#define LMC_INT			0x1F0

#define LMC_INT_DDR_ERR		BIT(11)
#define LMC_INT_DED_ERR		(0xFUL << 5)
#define LMC_INT_SEC_ERR         (0xFUL << 1)
#define LMC_INT_NXM_WR_MASK	BIT(0)

#define LMC_DDR_PLL_CTL		0x258
#define LMC_DDR_PLL_CTL_DDR4	BIT(29)

#define LMC_FADR_SCRAMBLED	0x330

#define LMC_INT_UE              (LMC_INT_DDR_ERR | LMC_INT_DED_ERR | \
				 LMC_INT_NXM_WR_MASK)

#define LMC_INT_CE		(LMC_INT_SEC_ERR)

static const struct error_descr lmc_errors[] = {
	{
		.type  = ERR_CORRECTED,
		.mask  = LMC_INT_SEC_ERR,
		.descr = "Single-bit ECC error",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = LMC_INT_DDR_ERR,
		.descr = "DDR chip error",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = LMC_INT_DED_ERR,
		.descr = "Double-bit ECC error",
	},
	{
		.type = ERR_UNCORRECTED,
		.mask = LMC_INT_NXM_WR_MASK,
		.descr = "Non-existent memory write",
	},
	{0, 0, NULL},
};

#define LMC_INT_EN_DDR_ERROR_ALERT_ENA	BIT(5)
#define LMC_INT_EN_DLCRAM_DED_ERR	BIT(4)
#define LMC_INT_EN_DLCRAM_SEC_ERR	BIT(3)
#define LMC_INT_INTR_DED_ENA		BIT(2)
#define LMC_INT_INTR_SEC_ENA		BIT(1)
#define LMC_INT_INTR_NXM_WR_ENA		BIT(0)

#define LMC_INT_ENA_ALL			GENMASK(5, 0)

#define LMC_DDR_PLL_CTL		0x258
#define LMC_DDR_PLL_CTL_DDR4	BIT(29)

#define LMC_CONTROL		0x190
#define LMC_CONTROL_RDIMM	BIT(0)

#define LMC_SCRAM_FADR		0x330

#define LMC_CHAR_MASK0		0x228
#define LMC_CHAR_MASK2		0x238

#define RING_ENTRIES	8

struct debugfs_entry {
	const char *name;
	umode_t mode;
	const struct file_operations fops;
};

struct lmc_err_ctx {
	u64 reg_int;
	u64 reg_fadr;
	u64 reg_nxm_fadr;
	u64 reg_scram_fadr;
	u64 reg_ecc_synd;
};

struct thunderx_lmc {
	void __iomem *regs;
	struct pci_dev *pdev;
	struct msix_entry msix_ent;

	atomic_t ecc_int;

	u64 mask0;
	u64 mask2;
	u64 parity_test;
	u64 node;

	int xbits;
	int bank_width;
	int pbank_lsb;
	int dimm_lsb;
	int rank_lsb;
	int bank_lsb;
	int row_lsb;
	int col_hi_lsb;

	int xor_bank;
	int l2c_alias;

	struct page *mem;

	struct lmc_err_ctx err_ctx[RING_ENTRIES];
	unsigned long ring_head;
	unsigned long ring_tail;
};

#define ring_pos(pos, size) ((pos) & (size - 1))

#define DEBUGFS_STRUCT(_name, _mode, _write, _read)			    \
static struct debugfs_entry debugfs_##_name = {				    \
	.name = __stringify(_name),					    \
	.mode = VERIFY_OCTAL_PERMISSIONS(_mode),			    \
	.fops = {							    \
		.open = simple_open,					    \
		.write = _write,					    \
		.read  = _read,						    \
		.llseek = generic_file_llseek,				    \
	},								    \
}

#define DEBUGFS_FIELD_ATTR(_type, _field)				    \
static ssize_t thunderx_##_type##_##_field##_read(struct file *file,	    \
					    char __user *data,		    \
					    size_t count, loff_t *ppos)	    \
{									    \
	struct thunderx_##_type *pdata = file->private_data;		    \
	char buf[20];							    \
									    \
	snprintf(buf, count, "0x%016llx", pdata->_field);		    \
	return simple_read_from_buffer(data, count, ppos,		    \
				       buf, sizeof(buf));		    \
}									    \
									    \
static ssize_t thunderx_##_type##_##_field##_write(struct file *file,	    \
					     const char __user *data,	    \
					     size_t count, loff_t *ppos)    \
{									    \
	struct thunderx_##_type *pdata = file->private_data;		    \
	int res;							    \
									    \
	res = kstrtoull_from_user(data, count, 0, &pdata->_field);	    \
									    \
	return res ? res : count;					    \
}									    \
									    \
DEBUGFS_STRUCT(_field, 0600,						    \
		   thunderx_##_type##_##_field##_write,			    \
		   thunderx_##_type##_##_field##_read)			    \

#define DEBUGFS_REG_ATTR(_type, _name, _reg)				    \
static ssize_t thunderx_##_type##_##_name##_read(struct file *file,	    \
					   char __user *data,		    \
					   size_t count, loff_t *ppos)      \
{									    \
	struct thunderx_##_type *pdata = file->private_data;		    \
	char buf[20];							    \
									    \
	sprintf(buf, "0x%016llx", readq(pdata->regs + _reg));		    \
	return simple_read_from_buffer(data, count, ppos,		    \
				       buf, sizeof(buf));		    \
}									    \
									    \
static ssize_t thunderx_##_type##_##_name##_write(struct file *file,	    \
					    const char __user *data,	    \
					    size_t count, loff_t *ppos)     \
{									    \
	struct thunderx_##_type *pdata = file->private_data;		    \
	u64 val;							    \
	int res;							    \
									    \
	res = kstrtoull_from_user(data, count, 0, &val);		    \
									    \
	if (!res) {							    \
		writeq(val, pdata->regs + _reg);			    \
		res = count;						    \
	}								    \
									    \
	return res;							    \
}									    \
									    \
DEBUGFS_STRUCT(_name, 0600,						    \
	       thunderx_##_type##_##_name##_write,			    \
	       thunderx_##_type##_##_name##_read)

#define LMC_DEBUGFS_ENT(_field)	DEBUGFS_FIELD_ATTR(lmc, _field)

/*
 * To get an ECC error injected, the following steps are needed:
 * - Setup the ECC injection by writing the appropriate parameters:
 *	echo <bit mask value> > /sys/kernel/debug/<device number>/ecc_mask0
 *	echo <bit mask value> > /sys/kernel/debug/<device number>/ecc_mask2
 *	echo 0x802 > /sys/kernel/debug/<device number>/ecc_parity_test
 * - Do the actual injection:
 *	echo 1 > /sys/kernel/debug/<device number>/inject_ecc
 */
static ssize_t thunderx_lmc_inject_int_write(struct file *file,
					     const char __user *data,
					     size_t count, loff_t *ppos)
{
	struct thunderx_lmc *lmc = file->private_data;
	u64 val;
	int res;

	res = kstrtoull_from_user(data, count, 0, &val);

	if (!res) {
		/* Trigger the interrupt */
		writeq(val, lmc->regs + LMC_INT_W1S);
		res = count;
	}

	return res;
}

static ssize_t thunderx_lmc_int_read(struct file *file,
				     char __user *data,
				     size_t count, loff_t *ppos)
{
	struct thunderx_lmc *lmc = file->private_data;
	char buf[20];
	u64 lmc_int = readq(lmc->regs + LMC_INT);

	snprintf(buf, sizeof(buf), "0x%016llx", lmc_int);
	return simple_read_from_buffer(data, count, ppos, buf, sizeof(buf));
}

#define TEST_PATTERN 0xa5

static int inject_ecc_fn(void *arg)
{
	struct thunderx_lmc *lmc = arg;
	uintptr_t addr, phys;
	unsigned int cline_size = cache_line_size();
	const unsigned int lines = PAGE_SIZE / cline_size;
	unsigned int i, cl_idx;

	addr = (uintptr_t)page_address(lmc->mem);
	phys = (uintptr_t)page_to_phys(lmc->mem);

	cl_idx = (phys & 0x7f) >> 4;
	lmc->parity_test &= ~(7ULL << 8);
	lmc->parity_test |= (cl_idx << 8);

	writeq(lmc->mask0, lmc->regs + LMC_CHAR_MASK0);
	writeq(lmc->mask2, lmc->regs + LMC_CHAR_MASK2);
	writeq(lmc->parity_test, lmc->regs + LMC_ECC_PARITY_TEST);

	readq(lmc->regs + LMC_CHAR_MASK0);
	readq(lmc->regs + LMC_CHAR_MASK2);
	readq(lmc->regs + LMC_ECC_PARITY_TEST);

	for (i = 0; i < lines; i++) {
		memset((void *)addr, TEST_PATTERN, cline_size);
		barrier();

		/*
		 * Flush L1 cachelines to the PoC (L2).
		 * This will cause cacheline eviction to the L2.
		 */
		asm volatile("dc civac, %0\n"
			     "dsb sy\n"
			     : : "r"(addr + i * cline_size));
	}

	for (i = 0; i < lines; i++) {
		/*
		 * Flush L2 cachelines to the DRAM.
		 * This will cause cacheline eviction to the DRAM
		 * and ECC corruption according to the masks set.
		 */
		__asm__ volatile("sys #0,c11,C1,#2, %0\n"
				 : : "r"(phys + i * cline_size));
	}

	for (i = 0; i < lines; i++) {
		/*
		 * Invalidate L2 cachelines.
		 * The subsequent load will cause cacheline fetch
		 * from the DRAM and an error interrupt
		 */
		__asm__ volatile("sys #0,c11,C1,#1, %0"
				 : : "r"(phys + i * cline_size));
	}

	for (i = 0; i < lines; i++) {
		/*
		 * Invalidate L1 cachelines.
		 * The subsequent load will cause cacheline fetch
		 * from the L2 and/or DRAM
		 */
		asm volatile("dc ivac, %0\n"
			     "dsb sy\n"
			     : : "r"(addr + i * cline_size));
	}

	return 0;
}

static ssize_t thunderx_lmc_inject_ecc_write(struct file *file,
					     const char __user *data,
					     size_t count, loff_t *ppos)
{
	struct thunderx_lmc *lmc = file->private_data;
	unsigned int cline_size = cache_line_size();
	u8 *tmp;
	void __iomem *addr;
	unsigned int offs, timeout = 100000;

	atomic_set(&lmc->ecc_int, 0);

	lmc->mem = alloc_pages_node(lmc->node, GFP_KERNEL, 0);
	if (!lmc->mem)
		return -ENOMEM;

	tmp = kmalloc(cline_size, GFP_KERNEL);
	if (!tmp) {
		__free_pages(lmc->mem, 0);
		return -ENOMEM;
	}

	addr = page_address(lmc->mem);

	while (!atomic_read(&lmc->ecc_int) && timeout--) {
		stop_machine(inject_ecc_fn, lmc, NULL);

		for (offs = 0; offs < PAGE_SIZE; offs += cline_size) {
			/*
			 * Do a load from the previously rigged location
			 * This should generate an error interrupt.
			 */
			memcpy(tmp, addr + offs, cline_size);
			asm volatile("dsb ld\n");
		}
	}

	kfree(tmp);
	__free_pages(lmc->mem, 0);

	return count;
}

LMC_DEBUGFS_ENT(mask0);
LMC_DEBUGFS_ENT(mask2);
LMC_DEBUGFS_ENT(parity_test);

DEBUGFS_STRUCT(inject_int, 0200, thunderx_lmc_inject_int_write, NULL);
DEBUGFS_STRUCT(inject_ecc, 0200, thunderx_lmc_inject_ecc_write, NULL);
DEBUGFS_STRUCT(int_w1c, 0400, NULL, thunderx_lmc_int_read);

static struct debugfs_entry *lmc_dfs_ents[] = {
	&debugfs_mask0,
	&debugfs_mask2,
	&debugfs_parity_test,
	&debugfs_inject_ecc,
	&debugfs_inject_int,
	&debugfs_int_w1c,
};

static int thunderx_create_debugfs_nodes(struct dentry *parent,
					  struct debugfs_entry *attrs[],
					  void *data,
					  size_t num)
{
	int i;
	struct dentry *ent;

	if (!IS_ENABLED(CONFIG_EDAC_DEBUG))
		return 0;

	if (!parent)
		return -ENOENT;

	for (i = 0; i < num; i++) {
		ent = edac_debugfs_create_file(attrs[i]->name, attrs[i]->mode,
					       parent, data, &attrs[i]->fops);

		if (IS_ERR(ent))
			break;
	}

	return i;
}

static phys_addr_t thunderx_faddr_to_phys(u64 faddr, struct thunderx_lmc *lmc)
{
	phys_addr_t addr = 0;
	int bank, xbits;

	addr |= lmc->node << 40;
	addr |= LMC_FADR_FDIMM(faddr) << lmc->dimm_lsb;
	addr |= LMC_FADR_FBUNK(faddr) << lmc->rank_lsb;
	addr |= LMC_FADR_FROW(faddr) << lmc->row_lsb;
	addr |= (LMC_FADR_FCOL(faddr) >> 4) << lmc->col_hi_lsb;

	bank = LMC_FADR_FBANK(faddr) << lmc->bank_lsb;

	if (lmc->xor_bank)
		bank ^= get_bits(addr, 12 + lmc->xbits, lmc->bank_width);

	addr |= bank << lmc->bank_lsb;

	xbits = PCI_FUNC(lmc->pdev->devfn);

	if (lmc->l2c_alias)
		xbits ^= get_bits(addr, 20, lmc->xbits) ^
			 get_bits(addr, 12, lmc->xbits);

	addr |= xbits << 7;

	return addr;
}

static unsigned int thunderx_get_num_lmcs(unsigned int node)
{
	unsigned int number = 0;
	struct pci_dev *pdev = NULL;

	do {
		pdev = pci_get_device(PCI_VENDOR_ID_CAVIUM,
				      PCI_DEVICE_ID_THUNDER_LMC,
				      pdev);
		if (pdev) {
#ifdef CONFIG_NUMA
			if (pdev->dev.numa_node == node)
				number++;
#else
			number++;
#endif
		}
	} while (pdev);

	return number;
}

#define LMC_MESSAGE_SIZE	120
#define LMC_OTHER_SIZE		(50 * ARRAY_SIZE(lmc_errors))

static irqreturn_t thunderx_lmc_err_isr(int irq, void *dev_id)
{
	struct mem_ctl_info *mci = dev_id;
	struct thunderx_lmc *lmc = mci->pvt_info;

	unsigned long head = ring_pos(lmc->ring_head, ARRAY_SIZE(lmc->err_ctx));
	struct lmc_err_ctx *ctx = &lmc->err_ctx[head];

	writeq(0, lmc->regs + LMC_CHAR_MASK0);
	writeq(0, lmc->regs + LMC_CHAR_MASK2);
	writeq(0x2, lmc->regs + LMC_ECC_PARITY_TEST);

	ctx->reg_int = readq(lmc->regs + LMC_INT);
	ctx->reg_fadr = readq(lmc->regs + LMC_FADR);
	ctx->reg_nxm_fadr = readq(lmc->regs + LMC_NXM_FADR);
	ctx->reg_scram_fadr = readq(lmc->regs + LMC_SCRAM_FADR);
	ctx->reg_ecc_synd = readq(lmc->regs + LMC_ECC_SYND);

	lmc->ring_head++;

	atomic_set(&lmc->ecc_int, 1);

	/* Clear the interrupt */
	writeq(ctx->reg_int, lmc->regs + LMC_INT);

	return IRQ_WAKE_THREAD;
}

static irqreturn_t thunderx_lmc_threaded_isr(int irq, void *dev_id)
{
	struct mem_ctl_info *mci = dev_id;
	struct thunderx_lmc *lmc = mci->pvt_info;
	phys_addr_t phys_addr;

	unsigned long tail;
	struct lmc_err_ctx *ctx;

	irqreturn_t ret = IRQ_NONE;

	char *msg;
	char *other;

	msg = kmalloc(LMC_MESSAGE_SIZE, GFP_KERNEL);
	other =  kmalloc(LMC_OTHER_SIZE, GFP_KERNEL);

	if (!msg || !other)
		goto err_free;

	while (CIRC_CNT(lmc->ring_head, lmc->ring_tail,
		ARRAY_SIZE(lmc->err_ctx))) {
		tail = ring_pos(lmc->ring_tail, ARRAY_SIZE(lmc->err_ctx));

		ctx = &lmc->err_ctx[tail];

		dev_dbg(&lmc->pdev->dev, "LMC_INT: %016llx\n",
			ctx->reg_int);
		dev_dbg(&lmc->pdev->dev, "LMC_FADR: %016llx\n",
			ctx->reg_fadr);
		dev_dbg(&lmc->pdev->dev, "LMC_NXM_FADR: %016llx\n",
			ctx->reg_nxm_fadr);
		dev_dbg(&lmc->pdev->dev, "LMC_SCRAM_FADR: %016llx\n",
			ctx->reg_scram_fadr);
		dev_dbg(&lmc->pdev->dev, "LMC_ECC_SYND: %016llx\n",
			ctx->reg_ecc_synd);

		snprintf(msg, LMC_MESSAGE_SIZE,
			 "DIMM %lld rank %lld bank %lld row %lld col %lld",
			 LMC_FADR_FDIMM(ctx->reg_scram_fadr),
			 LMC_FADR_FBUNK(ctx->reg_scram_fadr),
			 LMC_FADR_FBANK(ctx->reg_scram_fadr),
			 LMC_FADR_FROW(ctx->reg_scram_fadr),
			 LMC_FADR_FCOL(ctx->reg_scram_fadr));

		decode_register(other, LMC_OTHER_SIZE, lmc_errors,
				ctx->reg_int);

		phys_addr = thunderx_faddr_to_phys(ctx->reg_fadr, lmc);

		if (ctx->reg_int & LMC_INT_UE)
			edac_mc_handle_error(HW_EVENT_ERR_UNCORRECTED, mci, 1,
					     phys_to_pfn(phys_addr),
					     offset_in_page(phys_addr),
					     0, -1, -1, -1, msg, other);
		else if (ctx->reg_int & LMC_INT_CE)
			edac_mc_handle_error(HW_EVENT_ERR_CORRECTED, mci, 1,
					     phys_to_pfn(phys_addr),
					     offset_in_page(phys_addr),
					     0, -1, -1, -1, msg, other);

		lmc->ring_tail++;
	}

	ret = IRQ_HANDLED;

err_free:
	kfree(msg);
	kfree(other);

	return ret;
}

static const struct pci_device_id thunderx_lmc_pci_tbl[] = {
	{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVICE_ID_THUNDER_LMC) },
	{ 0, },
};

static inline int pci_dev_to_mc_idx(struct pci_dev *pdev)
{
	int node = dev_to_node(&pdev->dev);
	int ret = PCI_FUNC(pdev->devfn);

	ret += max(node, 0) << 3;

	return ret;
}

static int thunderx_lmc_probe(struct pci_dev *pdev,
				const struct pci_device_id *id)
{
	struct thunderx_lmc *lmc;
	struct edac_mc_layer layer;
	struct mem_ctl_info *mci;
	u64 lmc_control, lmc_ddr_pll_ctl, lmc_config;
	int ret;
	u64 lmc_int;
	void *l2c_ioaddr;

	layer.type = EDAC_MC_LAYER_SLOT;
	layer.size = 2;
	layer.is_virt_csrow = false;

	ret = pcim_enable_device(pdev);
	if (ret) {
		dev_err(&pdev->dev, "Cannot enable PCI device: %d\n", ret);
		return ret;
	}

	ret = pcim_iomap_regions(pdev, BIT(0), "thunderx_lmc");
	if (ret) {
		dev_err(&pdev->dev, "Cannot map PCI resources: %d\n", ret);
		return ret;
	}

	mci = edac_mc_alloc(pci_dev_to_mc_idx(pdev), 1, &layer,
			    sizeof(struct thunderx_lmc));
	if (!mci)
		return -ENOMEM;

	mci->pdev = &pdev->dev;
	lmc = mci->pvt_info;

	pci_set_drvdata(pdev, mci);

	lmc->regs = pcim_iomap_table(pdev)[0];

	lmc_control = readq(lmc->regs + LMC_CONTROL);
	lmc_ddr_pll_ctl = readq(lmc->regs + LMC_DDR_PLL_CTL);
	lmc_config = readq(lmc->regs + LMC_CONFIG);

	if (lmc_control & LMC_CONTROL_RDIMM) {
		mci->mtype_cap = FIELD_GET(LMC_DDR_PLL_CTL_DDR4,
					   lmc_ddr_pll_ctl) ?
				MEM_RDDR4 : MEM_RDDR3;
	} else {
		mci->mtype_cap = FIELD_GET(LMC_DDR_PLL_CTL_DDR4,
					   lmc_ddr_pll_ctl) ?
				MEM_DDR4 : MEM_DDR3;
	}

	mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED;
	mci->edac_cap = EDAC_FLAG_SECDED;

	mci->mod_name = "thunderx-lmc";
	mci->ctl_name = "thunderx-lmc";
	mci->dev_name = dev_name(&pdev->dev);
	mci->scrub_mode = SCRUB_NONE;

	lmc->pdev = pdev;
	lmc->msix_ent.entry = 0;

	lmc->ring_head = 0;
	lmc->ring_tail = 0;

	ret = pci_enable_msix_exact(pdev, &lmc->msix_ent, 1);
	if (ret) {
		dev_err(&pdev->dev, "Cannot enable interrupt: %d\n", ret);
		goto err_free;
	}

	ret = devm_request_threaded_irq(&pdev->dev, lmc->msix_ent.vector,
					thunderx_lmc_err_isr,
					thunderx_lmc_threaded_isr, 0,
					"[EDAC] ThunderX LMC", mci);
	if (ret) {
		dev_err(&pdev->dev, "Cannot set ISR: %d\n", ret);
		goto err_free;
	}

	lmc->node = FIELD_GET(THUNDERX_NODE, pci_resource_start(pdev, 0));

	lmc->xbits = thunderx_get_num_lmcs(lmc->node) >> 1;
	lmc->bank_width = (FIELD_GET(LMC_DDR_PLL_CTL_DDR4, lmc_ddr_pll_ctl) &&
			   FIELD_GET(LMC_CONFIG_BG2, lmc_config)) ? 4 : 3;

	lmc->pbank_lsb = (lmc_config >> 5) & 0xf;
	lmc->dimm_lsb  = 28 + lmc->pbank_lsb + lmc->xbits;
	lmc->rank_lsb = lmc->dimm_lsb;
	lmc->rank_lsb -= FIELD_GET(LMC_CONFIG_RANK_ENA, lmc_config) ? 1 : 0;
	lmc->bank_lsb = 7 + lmc->xbits;
	lmc->row_lsb = 14 + LMC_CONFIG_ROW_LSB(lmc_config) + lmc->xbits;

	lmc->col_hi_lsb = lmc->bank_lsb + lmc->bank_width;

	lmc->xor_bank = lmc_control & LMC_CONTROL_XOR_BANK;

	l2c_ioaddr = ioremap(L2C_CTL | FIELD_PREP(THUNDERX_NODE, lmc->node), PAGE_SIZE);
	if (!l2c_ioaddr) {
		dev_err(&pdev->dev, "Cannot map L2C_CTL\n");
		ret = -ENOMEM;
		goto err_free;
	}

	lmc->l2c_alias = !(readq(l2c_ioaddr) & L2C_CTL_DISIDXALIAS);

	iounmap(l2c_ioaddr);

	ret = edac_mc_add_mc(mci);
	if (ret) {
		dev_err(&pdev->dev, "Cannot add the MC: %d\n", ret);
		goto err_free;
	}

	lmc_int = readq(lmc->regs + LMC_INT);
	writeq(lmc_int, lmc->regs + LMC_INT);

	writeq(LMC_INT_ENA_ALL, lmc->regs + LMC_INT_ENA_W1S);

	if (IS_ENABLED(CONFIG_EDAC_DEBUG)) {
		ret = thunderx_create_debugfs_nodes(mci->debugfs,
						    lmc_dfs_ents,
						    lmc,
						    ARRAY_SIZE(lmc_dfs_ents));

		if (ret != ARRAY_SIZE(lmc_dfs_ents)) {
			dev_warn(&pdev->dev, "Error creating debugfs entries: %d%s\n",
				 ret, ret >= 0 ? " created" : "");
		}
	}

	return 0;

err_free:
	pci_set_drvdata(pdev, NULL);
	edac_mc_free(mci);

	return ret;
}

static void thunderx_lmc_remove(struct pci_dev *pdev)
{
	struct mem_ctl_info *mci = pci_get_drvdata(pdev);
	struct thunderx_lmc *lmc = mci->pvt_info;

	writeq(LMC_INT_ENA_ALL, lmc->regs + LMC_INT_ENA_W1C);

	edac_mc_del_mc(&pdev->dev);
	edac_mc_free(mci);
}

MODULE_DEVICE_TABLE(pci, thunderx_lmc_pci_tbl);

static struct pci_driver thunderx_lmc_driver = {
	.name     = "thunderx_lmc_edac",
	.probe    = thunderx_lmc_probe,
	.remove   = thunderx_lmc_remove,
	.id_table = thunderx_lmc_pci_tbl,
};

/*---------------------- OCX driver ---------------------------------*/

#define PCI_DEVICE_ID_THUNDER_OCX 0xa013

#define OCX_LINK_INTS		3
#define OCX_INTS		(OCX_LINK_INTS + 1)
#define OCX_RX_LANES		24
#define OCX_RX_LANE_STATS	15

#define OCX_COM_INT		0x100
#define OCX_COM_INT_W1S		0x108
#define OCX_COM_INT_ENA_W1S	0x110
#define OCX_COM_INT_ENA_W1C	0x118

#define OCX_COM_IO_BADID		BIT(54)
#define OCX_COM_MEM_BADID		BIT(53)
#define OCX_COM_COPR_BADID		BIT(52)
#define OCX_COM_WIN_REQ_BADID		BIT(51)
#define OCX_COM_WIN_REQ_TOUT		BIT(50)
#define OCX_COM_RX_LANE			GENMASK(23, 0)

#define OCX_COM_INT_CE			(OCX_COM_IO_BADID      | \
					 OCX_COM_MEM_BADID     | \
					 OCX_COM_COPR_BADID    | \
					 OCX_COM_WIN_REQ_BADID | \
					 OCX_COM_WIN_REQ_TOUT)

static const struct error_descr ocx_com_errors[] = {
	{
		.type  = ERR_CORRECTED,
		.mask  = OCX_COM_IO_BADID,
		.descr = "Invalid IO transaction node ID",
	},
	{
		.type  = ERR_CORRECTED,
		.mask  = OCX_COM_MEM_BADID,
		.descr = "Invalid memory transaction node ID",
	},
	{
		.type  = ERR_CORRECTED,
		.mask  = OCX_COM_COPR_BADID,
		.descr = "Invalid coprocessor transaction node ID",
	},
	{
		.type  = ERR_CORRECTED,
		.mask  = OCX_COM_WIN_REQ_BADID,
		.descr = "Invalid SLI transaction node ID",
	},
	{
		.type  = ERR_CORRECTED,
		.mask  = OCX_COM_WIN_REQ_TOUT,
		.descr = "Window/core request timeout",
	},
	{0, 0, NULL},
};

#define OCX_COM_LINKX_INT(x)		(0x120 + (x) * 8)
#define OCX_COM_LINKX_INT_W1S(x)	(0x140 + (x) * 8)
#define OCX_COM_LINKX_INT_ENA_W1S(x)	(0x160 + (x) * 8)
#define OCX_COM_LINKX_INT_ENA_W1C(x)	(0x180 + (x) * 8)

#define OCX_COM_LINK_BAD_WORD			BIT(13)
#define OCX_COM_LINK_ALIGN_FAIL			BIT(12)
#define OCX_COM_LINK_ALIGN_DONE			BIT(11)
#define OCX_COM_LINK_UP				BIT(10)
#define OCX_COM_LINK_STOP			BIT(9)
#define OCX_COM_LINK_BLK_ERR			BIT(8)
#define OCX_COM_LINK_REINIT			BIT(7)
#define OCX_COM_LINK_LNK_DATA			BIT(6)
#define OCX_COM_LINK_RXFIFO_DBE			BIT(5)
#define OCX_COM_LINK_RXFIFO_SBE			BIT(4)
#define OCX_COM_LINK_TXFIFO_DBE			BIT(3)
#define OCX_COM_LINK_TXFIFO_SBE			BIT(2)
#define OCX_COM_LINK_REPLAY_DBE			BIT(1)
#define OCX_COM_LINK_REPLAY_SBE			BIT(0)

static const struct error_descr ocx_com_link_errors[] = {
	{
		.type  = ERR_CORRECTED,
		.mask  = OCX_COM_LINK_REPLAY_SBE,
		.descr = "Replay buffer single-bit error",
	},
	{
		.type  = ERR_CORRECTED,
		.mask  = OCX_COM_LINK_TXFIFO_SBE,
		.descr = "TX FIFO single-bit error",
	},
	{
		.type  = ERR_CORRECTED,
		.mask  = OCX_COM_LINK_RXFIFO_SBE,
		.descr = "RX FIFO single-bit error",
	},
	{
		.type  = ERR_CORRECTED,
		.mask  = OCX_COM_LINK_BLK_ERR,
		.descr = "Block code error",
	},
	{
		.type  = ERR_CORRECTED,
		.mask  = OCX_COM_LINK_ALIGN_FAIL,
		.descr = "Link alignment failure",
	},
	{
		.type  = ERR_CORRECTED,
		.mask  = OCX_COM_LINK_BAD_WORD,
		.descr = "Bad code word",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = OCX_COM_LINK_REPLAY_DBE,
		.descr = "Replay buffer double-bit error",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = OCX_COM_LINK_TXFIFO_DBE,
		.descr = "TX FIFO double-bit error",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = OCX_COM_LINK_RXFIFO_DBE,
		.descr = "RX FIFO double-bit error",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = OCX_COM_LINK_STOP,
		.descr = "Link stopped",
	},
	{0, 0, NULL},
};

#define OCX_COM_LINK_INT_UE       (OCX_COM_LINK_REPLAY_DBE | \
				   OCX_COM_LINK_TXFIFO_DBE | \
				   OCX_COM_LINK_RXFIFO_DBE | \
				   OCX_COM_LINK_STOP)

#define OCX_COM_LINK_INT_CE       (OCX_COM_LINK_REPLAY_SBE | \
				   OCX_COM_LINK_TXFIFO_SBE | \
				   OCX_COM_LINK_RXFIFO_SBE | \
				   OCX_COM_LINK_BLK_ERR    | \
				   OCX_COM_LINK_ALIGN_FAIL | \
				   OCX_COM_LINK_BAD_WORD)

#define OCX_LNE_INT(x)			(0x8018 + (x) * 0x100)
#define OCX_LNE_INT_EN(x)		(0x8020 + (x) * 0x100)
#define OCX_LNE_BAD_CNT(x)		(0x8028 + (x) * 0x100)
#define OCX_LNE_CFG(x)			(0x8000 + (x) * 0x100)
#define OCX_LNE_STAT(x, y)		(0x8040 + (x) * 0x100 + (y) * 8)

#define OCX_LNE_CFG_RX_BDRY_LOCK_DIS		BIT(8)
#define OCX_LNE_CFG_RX_STAT_WRAP_DIS		BIT(2)
#define OCX_LNE_CFG_RX_STAT_RDCLR		BIT(1)
#define OCX_LNE_CFG_RX_STAT_ENA			BIT(0)


#define OCX_LANE_BAD_64B67B			BIT(8)
#define OCX_LANE_DSKEW_FIFO_OVFL		BIT(5)
#define OCX_LANE_SCRM_SYNC_LOSS			BIT(4)
#define OCX_LANE_UKWN_CNTL_WORD			BIT(3)
#define OCX_LANE_CRC32_ERR			BIT(2)
#define OCX_LANE_BDRY_SYNC_LOSS			BIT(1)
#define OCX_LANE_SERDES_LOCK_LOSS		BIT(0)

#define OCX_COM_LANE_INT_UE       (0)
#define OCX_COM_LANE_INT_CE       (OCX_LANE_SERDES_LOCK_LOSS | \
				   OCX_LANE_BDRY_SYNC_LOSS   | \
				   OCX_LANE_CRC32_ERR        | \
				   OCX_LANE_UKWN_CNTL_WORD   | \
				   OCX_LANE_SCRM_SYNC_LOSS   | \
				   OCX_LANE_DSKEW_FIFO_OVFL  | \
				   OCX_LANE_BAD_64B67B)

static const struct error_descr ocx_lane_errors[] = {
	{
		.type  = ERR_CORRECTED,
		.mask  = OCX_LANE_SERDES_LOCK_LOSS,
		.descr = "RX SerDes lock lost",
	},
	{
		.type  = ERR_CORRECTED,
		.mask  = OCX_LANE_BDRY_SYNC_LOSS,
		.descr = "RX word boundary lost",
	},
	{
		.type  = ERR_CORRECTED,
		.mask  = OCX_LANE_CRC32_ERR,
		.descr = "CRC32 error",
	},
	{
		.type  = ERR_CORRECTED,
		.mask  = OCX_LANE_UKWN_CNTL_WORD,
		.descr = "Unknown control word",
	},
	{
		.type  = ERR_CORRECTED,
		.mask  = OCX_LANE_SCRM_SYNC_LOSS,
		.descr = "Scrambler synchronization lost",
	},
	{
		.type  = ERR_CORRECTED,
		.mask  = OCX_LANE_DSKEW_FIFO_OVFL,
		.descr = "RX deskew FIFO overflow",
	},
	{
		.type  = ERR_CORRECTED,
		.mask  = OCX_LANE_BAD_64B67B,
		.descr = "Bad 64B/67B codeword",
	},
	{0, 0, NULL},
};

#define OCX_LNE_INT_ENA_ALL		(GENMASK(9, 8) | GENMASK(6, 0))
#define OCX_COM_INT_ENA_ALL		(GENMASK(54, 50) | GENMASK(23, 0))
#define OCX_COM_LINKX_INT_ENA_ALL	(GENMASK(13, 12) | \
					 GENMASK(9, 7) | GENMASK(5, 0))

#define OCX_TLKX_ECC_CTL(x)		(0x10018 + (x) * 0x2000)
#define OCX_RLKX_ECC_CTL(x)		(0x18018 + (x) * 0x2000)

struct ocx_com_err_ctx {
	u64 reg_com_int;
	u64 reg_lane_int[OCX_RX_LANES];
	u64 reg_lane_stat11[OCX_RX_LANES];
};

struct ocx_link_err_ctx {
	u64 reg_com_link_int;
	int link;
};

struct thunderx_ocx {
	void __iomem *regs;
	int com_link;
	struct pci_dev *pdev;
	struct edac_device_ctl_info *edac_dev;

	struct dentry *debugfs;
	struct msix_entry msix_ent[OCX_INTS];

	struct ocx_com_err_ctx com_err_ctx[RING_ENTRIES];
	struct ocx_link_err_ctx link_err_ctx[RING_ENTRIES];

	unsigned long com_ring_head;
	unsigned long com_ring_tail;

	unsigned long link_ring_head;
	unsigned long link_ring_tail;
};

#define OCX_MESSAGE_SIZE	SZ_1K
#define OCX_OTHER_SIZE		(50 * ARRAY_SIZE(ocx_com_link_errors))

/* This handler is threaded */
static irqreturn_t thunderx_ocx_com_isr(int irq, void *irq_id)
{
	struct msix_entry *msix = irq_id;
	struct thunderx_ocx *ocx = container_of(msix, struct thunderx_ocx,
						msix_ent[msix->entry]);

	int lane;
	unsigned long head = ring_pos(ocx->com_ring_head,
				      ARRAY_SIZE(ocx->com_err_ctx));
	struct ocx_com_err_ctx *ctx = &ocx->com_err_ctx[head];

	ctx->reg_com_int = readq(ocx->regs + OCX_COM_INT);

	for (lane = 0; lane < OCX_RX_LANES; lane++) {
		ctx->reg_lane_int[lane] =
			readq(ocx->regs + OCX_LNE_INT(lane));
		ctx->reg_lane_stat11[lane] =
			readq(ocx->regs + OCX_LNE_STAT(lane, 11));

		writeq(ctx->reg_lane_int[lane], ocx->regs + OCX_LNE_INT(lane));
	}

	writeq(ctx->reg_com_int, ocx->regs + OCX_COM_INT);

	ocx->com_ring_head++;

	return IRQ_WAKE_THREAD;
}

static irqreturn_t thunderx_ocx_com_threaded_isr(int irq, void *irq_id)
{
	struct msix_entry *msix = irq_id;
	struct thunderx_ocx *ocx = container_of(msix, struct thunderx_ocx,
						msix_ent[msix->entry]);

	irqreturn_t ret = IRQ_NONE;

	unsigned long tail;
	struct ocx_com_err_ctx *ctx;
	int lane;
	char *msg;
	char *other;

	msg = kmalloc(OCX_MESSAGE_SIZE, GFP_KERNEL);
	other = kmalloc(OCX_OTHER_SIZE, GFP_KERNEL);

	if (!msg || !other)
		goto err_free;

	while (CIRC_CNT(ocx->com_ring_head, ocx->com_ring_tail,
			ARRAY_SIZE(ocx->com_err_ctx))) {
		tail = ring_pos(ocx->com_ring_tail,
				ARRAY_SIZE(ocx->com_err_ctx));
		ctx = &ocx->com_err_ctx[tail];

		snprintf(msg, OCX_MESSAGE_SIZE, "%s: OCX_COM_INT: %016llx",
			ocx->edac_dev->ctl_name, ctx->reg_com_int);

		decode_register(other, OCX_OTHER_SIZE,
				ocx_com_errors, ctx->reg_com_int);

		strlcat(msg, other, OCX_MESSAGE_SIZE);

		for (lane = 0; lane < OCX_RX_LANES; lane++)
			if (ctx->reg_com_int & BIT(lane)) {
				snprintf(other, OCX_OTHER_SIZE,
					 "\n\tOCX_LNE_INT[%02d]: %016llx OCX_LNE_STAT11[%02d]: %016llx",
					 lane, ctx->reg_lane_int[lane],
					 lane, ctx->reg_lane_stat11[lane]);

				strlcat(msg, other, OCX_MESSAGE_SIZE);

				decode_register(other, OCX_OTHER_SIZE,
						ocx_lane_errors,
						ctx->reg_lane_int[lane]);
				strlcat(msg, other, OCX_MESSAGE_SIZE);
			}

		if (ctx->reg_com_int & OCX_COM_INT_CE)
			edac_device_handle_ce(ocx->edac_dev, 0, 0, msg);

		ocx->com_ring_tail++;
	}

	ret = IRQ_HANDLED;

err_free:
	kfree(other);
	kfree(msg);

	return ret;
}

static irqreturn_t thunderx_ocx_lnk_isr(int irq, void *irq_id)
{
	struct msix_entry *msix = irq_id;
	struct thunderx_ocx *ocx = container_of(msix, struct thunderx_ocx,
						msix_ent[msix->entry]);
	unsigned long head = ring_pos(ocx->link_ring_head,
				      ARRAY_SIZE(ocx->link_err_ctx));
	struct ocx_link_err_ctx *ctx = &ocx->link_err_ctx[head];

	ctx->link = msix->entry;
	ctx->reg_com_link_int = readq(ocx->regs + OCX_COM_LINKX_INT(ctx->link));

	writeq(ctx->reg_com_link_int, ocx->regs + OCX_COM_LINKX_INT(ctx->link));

	ocx->link_ring_head++;

	return IRQ_WAKE_THREAD;
}

static irqreturn_t thunderx_ocx_lnk_threaded_isr(int irq, void *irq_id)
{
	struct msix_entry *msix = irq_id;
	struct thunderx_ocx *ocx = container_of(msix, struct thunderx_ocx,
						msix_ent[msix->entry]);
	irqreturn_t ret = IRQ_NONE;
	unsigned long tail;
	struct ocx_link_err_ctx *ctx;

	char *msg;
	char *other;

	msg = kmalloc(OCX_MESSAGE_SIZE, GFP_KERNEL);
	other = kmalloc(OCX_OTHER_SIZE, GFP_KERNEL);

	if (!msg || !other)
		goto err_free;

	while (CIRC_CNT(ocx->link_ring_head, ocx->link_ring_tail,
			ARRAY_SIZE(ocx->link_err_ctx))) {
		tail = ring_pos(ocx->link_ring_head,
				ARRAY_SIZE(ocx->link_err_ctx));

		ctx = &ocx->link_err_ctx[tail];

		snprintf(msg, OCX_MESSAGE_SIZE,
			 "%s: OCX_COM_LINK_INT[%d]: %016llx",
			 ocx->edac_dev->ctl_name,
			 ctx->link, ctx->reg_com_link_int);

		decode_register(other, OCX_OTHER_SIZE,
				ocx_com_link_errors, ctx->reg_com_link_int);

		strlcat(msg, other, OCX_MESSAGE_SIZE);

		if (ctx->reg_com_link_int & OCX_COM_LINK_INT_UE)
			edac_device_handle_ue(ocx->edac_dev, 0, 0, msg);
		else if (ctx->reg_com_link_int & OCX_COM_LINK_INT_CE)
			edac_device_handle_ce(ocx->edac_dev, 0, 0, msg);

		ocx->link_ring_tail++;
	}

	ret = IRQ_HANDLED;
err_free:
	kfree(other);
	kfree(msg);

	return ret;
}

#define OCX_DEBUGFS_ATTR(_name, _reg)	DEBUGFS_REG_ATTR(ocx, _name, _reg)

OCX_DEBUGFS_ATTR(tlk0_ecc_ctl, OCX_TLKX_ECC_CTL(0));
OCX_DEBUGFS_ATTR(tlk1_ecc_ctl, OCX_TLKX_ECC_CTL(1));
OCX_DEBUGFS_ATTR(tlk2_ecc_ctl, OCX_TLKX_ECC_CTL(2));

OCX_DEBUGFS_ATTR(rlk0_ecc_ctl, OCX_RLKX_ECC_CTL(0));
OCX_DEBUGFS_ATTR(rlk1_ecc_ctl, OCX_RLKX_ECC_CTL(1));
OCX_DEBUGFS_ATTR(rlk2_ecc_ctl, OCX_RLKX_ECC_CTL(2));

OCX_DEBUGFS_ATTR(com_link0_int, OCX_COM_LINKX_INT_W1S(0));
OCX_DEBUGFS_ATTR(com_link1_int, OCX_COM_LINKX_INT_W1S(1));
OCX_DEBUGFS_ATTR(com_link2_int, OCX_COM_LINKX_INT_W1S(2));

OCX_DEBUGFS_ATTR(lne00_badcnt, OCX_LNE_BAD_CNT(0));
OCX_DEBUGFS_ATTR(lne01_badcnt, OCX_LNE_BAD_CNT(1));
OCX_DEBUGFS_ATTR(lne02_badcnt, OCX_LNE_BAD_CNT(2));
OCX_DEBUGFS_ATTR(lne03_badcnt, OCX_LNE_BAD_CNT(3));
OCX_DEBUGFS_ATTR(lne04_badcnt, OCX_LNE_BAD_CNT(4));
OCX_DEBUGFS_ATTR(lne05_badcnt, OCX_LNE_BAD_CNT(5));
OCX_DEBUGFS_ATTR(lne06_badcnt, OCX_LNE_BAD_CNT(6));
OCX_DEBUGFS_ATTR(lne07_badcnt, OCX_LNE_BAD_CNT(7));

OCX_DEBUGFS_ATTR(lne08_badcnt, OCX_LNE_BAD_CNT(8));
OCX_DEBUGFS_ATTR(lne09_badcnt, OCX_LNE_BAD_CNT(9));
OCX_DEBUGFS_ATTR(lne10_badcnt, OCX_LNE_BAD_CNT(10));
OCX_DEBUGFS_ATTR(lne11_badcnt, OCX_LNE_BAD_CNT(11));
OCX_DEBUGFS_ATTR(lne12_badcnt, OCX_LNE_BAD_CNT(12));
OCX_DEBUGFS_ATTR(lne13_badcnt, OCX_LNE_BAD_CNT(13));
OCX_DEBUGFS_ATTR(lne14_badcnt, OCX_LNE_BAD_CNT(14));
OCX_DEBUGFS_ATTR(lne15_badcnt, OCX_LNE_BAD_CNT(15));

OCX_DEBUGFS_ATTR(lne16_badcnt, OCX_LNE_BAD_CNT(16));
OCX_DEBUGFS_ATTR(lne17_badcnt, OCX_LNE_BAD_CNT(17));
OCX_DEBUGFS_ATTR(lne18_badcnt, OCX_LNE_BAD_CNT(18));
OCX_DEBUGFS_ATTR(lne19_badcnt, OCX_LNE_BAD_CNT(19));
OCX_DEBUGFS_ATTR(lne20_badcnt, OCX_LNE_BAD_CNT(20));
OCX_DEBUGFS_ATTR(lne21_badcnt, OCX_LNE_BAD_CNT(21));
OCX_DEBUGFS_ATTR(lne22_badcnt, OCX_LNE_BAD_CNT(22));
OCX_DEBUGFS_ATTR(lne23_badcnt, OCX_LNE_BAD_CNT(23));

OCX_DEBUGFS_ATTR(com_int, OCX_COM_INT_W1S);

static struct debugfs_entry *ocx_dfs_ents[] = {
	&debugfs_tlk0_ecc_ctl,
	&debugfs_tlk1_ecc_ctl,
	&debugfs_tlk2_ecc_ctl,

	&debugfs_rlk0_ecc_ctl,
	&debugfs_rlk1_ecc_ctl,
	&debugfs_rlk2_ecc_ctl,

	&debugfs_com_link0_int,
	&debugfs_com_link1_int,
	&debugfs_com_link2_int,

	&debugfs_lne00_badcnt,
	&debugfs_lne01_badcnt,
	&debugfs_lne02_badcnt,
	&debugfs_lne03_badcnt,
	&debugfs_lne04_badcnt,
	&debugfs_lne05_badcnt,
	&debugfs_lne06_badcnt,
	&debugfs_lne07_badcnt,
	&debugfs_lne08_badcnt,
	&debugfs_lne09_badcnt,
	&debugfs_lne10_badcnt,
	&debugfs_lne11_badcnt,
	&debugfs_lne12_badcnt,
	&debugfs_lne13_badcnt,
	&debugfs_lne14_badcnt,
	&debugfs_lne15_badcnt,
	&debugfs_lne16_badcnt,
	&debugfs_lne17_badcnt,
	&debugfs_lne18_badcnt,
	&debugfs_lne19_badcnt,
	&debugfs_lne20_badcnt,
	&debugfs_lne21_badcnt,
	&debugfs_lne22_badcnt,
	&debugfs_lne23_badcnt,

	&debugfs_com_int,
};

static const struct pci_device_id thunderx_ocx_pci_tbl[] = {
	{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVICE_ID_THUNDER_OCX) },
	{ 0, },
};

static void thunderx_ocx_clearstats(struct thunderx_ocx *ocx)
{
	int lane, stat, cfg;

	for (lane = 0; lane < OCX_RX_LANES; lane++) {
		cfg = readq(ocx->regs + OCX_LNE_CFG(lane));
		cfg |= OCX_LNE_CFG_RX_STAT_RDCLR;
		cfg &= ~OCX_LNE_CFG_RX_STAT_ENA;
		writeq(cfg, ocx->regs + OCX_LNE_CFG(lane));

		for (stat = 0; stat < OCX_RX_LANE_STATS; stat++)
			readq(ocx->regs + OCX_LNE_STAT(lane, stat));
	}
}

static int thunderx_ocx_probe(struct pci_dev *pdev,
			      const struct pci_device_id *id)
{
	struct thunderx_ocx *ocx;
	struct edac_device_ctl_info *edac_dev;
	char name[32];
	int idx;
	int i;
	int ret;
	u64 reg;

	ret = pcim_enable_device(pdev);
	if (ret) {
		dev_err(&pdev->dev, "Cannot enable PCI device: %d\n", ret);
		return ret;
	}

	ret = pcim_iomap_regions(pdev, BIT(0), "thunderx_ocx");
	if (ret) {
		dev_err(&pdev->dev, "Cannot map PCI resources: %d\n", ret);
		return ret;
	}

	idx = edac_device_alloc_index();
	snprintf(name, sizeof(name), "OCX%d", idx);
	edac_dev = edac_device_alloc_ctl_info(sizeof(struct thunderx_ocx),
					      name, 1, "CCPI", 1, 0, idx);
	if (!edac_dev) {
		dev_err(&pdev->dev, "Cannot allocate EDAC device\n");
		return -ENOMEM;
	}
	ocx = edac_dev->pvt_info;
	ocx->edac_dev = edac_dev;
	ocx->com_ring_head = 0;
	ocx->com_ring_tail = 0;
	ocx->link_ring_head = 0;
	ocx->link_ring_tail = 0;

	ocx->regs = pcim_iomap_table(pdev)[0];
	if (!ocx->regs) {
		dev_err(&pdev->dev, "Cannot map PCI resources\n");
		ret = -ENODEV;
		goto err_free;
	}

	ocx->pdev = pdev;

	for (i = 0; i < OCX_INTS; i++) {
		ocx->msix_ent[i].entry = i;
		ocx->msix_ent[i].vector = 0;
	}

	ret = pci_enable_msix_exact(pdev, ocx->msix_ent, OCX_INTS);
	if (ret) {
		dev_err(&pdev->dev, "Cannot enable interrupt: %d\n", ret);
		goto err_free;
	}

	for (i = 0; i < OCX_INTS; i++) {
		ret = devm_request_threaded_irq(&pdev->dev,
						ocx->msix_ent[i].vector,
						(i == 3) ?
						 thunderx_ocx_com_isr :
						 thunderx_ocx_lnk_isr,
						(i == 3) ?
						 thunderx_ocx_com_threaded_isr :
						 thunderx_ocx_lnk_threaded_isr,
						0, "[EDAC] ThunderX OCX",
						&ocx->msix_ent[i]);
		if (ret)
			goto err_free;
	}

	edac_dev->dev = &pdev->dev;
	edac_dev->dev_name = dev_name(&pdev->dev);
	edac_dev->mod_name = "thunderx-ocx";
	edac_dev->ctl_name = "thunderx-ocx";

	ret = edac_device_add_device(edac_dev);
	if (ret) {
		dev_err(&pdev->dev, "Cannot add EDAC device: %d\n", ret);
		goto err_free;
	}

	if (IS_ENABLED(CONFIG_EDAC_DEBUG)) {
		ocx->debugfs = edac_debugfs_create_dir(pdev->dev.kobj.name);

		ret = thunderx_create_debugfs_nodes(ocx->debugfs,
						    ocx_dfs_ents,
						    ocx,
						    ARRAY_SIZE(ocx_dfs_ents));
		if (ret != ARRAY_SIZE(ocx_dfs_ents)) {
			dev_warn(&pdev->dev, "Error creating debugfs entries: %d%s\n",
				 ret, ret >= 0 ? " created" : "");
		}
	}

	pci_set_drvdata(pdev, edac_dev);

	thunderx_ocx_clearstats(ocx);

	for (i = 0; i < OCX_RX_LANES; i++) {
		writeq(OCX_LNE_INT_ENA_ALL,
		       ocx->regs + OCX_LNE_INT_EN(i));

		reg = readq(ocx->regs + OCX_LNE_INT(i));
		writeq(reg, ocx->regs + OCX_LNE_INT(i));

	}

	for (i = 0; i < OCX_LINK_INTS; i++) {
		reg = readq(ocx->regs + OCX_COM_LINKX_INT(i));
		writeq(reg, ocx->regs + OCX_COM_LINKX_INT(i));

		writeq(OCX_COM_LINKX_INT_ENA_ALL,
		       ocx->regs + OCX_COM_LINKX_INT_ENA_W1S(i));
	}

	reg = readq(ocx->regs + OCX_COM_INT);
	writeq(reg, ocx->regs + OCX_COM_INT);

	writeq(OCX_COM_INT_ENA_ALL, ocx->regs + OCX_COM_INT_ENA_W1S);

	return 0;
err_free:
	edac_device_free_ctl_info(edac_dev);

	return ret;
}

static void thunderx_ocx_remove(struct pci_dev *pdev)
{
	struct edac_device_ctl_info *edac_dev = pci_get_drvdata(pdev);
	struct thunderx_ocx *ocx = edac_dev->pvt_info;
	int i;

	writeq(OCX_COM_INT_ENA_ALL, ocx->regs + OCX_COM_INT_ENA_W1C);

	for (i = 0; i < OCX_INTS; i++) {
		writeq(OCX_COM_LINKX_INT_ENA_ALL,
		       ocx->regs + OCX_COM_LINKX_INT_ENA_W1C(i));
	}

	edac_debugfs_remove_recursive(ocx->debugfs);

	edac_device_del_device(&pdev->dev);
	edac_device_free_ctl_info(edac_dev);
}

MODULE_DEVICE_TABLE(pci, thunderx_ocx_pci_tbl);

static struct pci_driver thunderx_ocx_driver = {
	.name     = "thunderx_ocx_edac",
	.probe    = thunderx_ocx_probe,
	.remove   = thunderx_ocx_remove,
	.id_table = thunderx_ocx_pci_tbl,
};

/*---------------------- L2C driver ---------------------------------*/

#define PCI_DEVICE_ID_THUNDER_L2C_TAD 0xa02e
#define PCI_DEVICE_ID_THUNDER_L2C_CBC 0xa02f
#define PCI_DEVICE_ID_THUNDER_L2C_MCI 0xa030

#define L2C_TAD_INT_W1C		0x40000
#define L2C_TAD_INT_W1S		0x40008

#define L2C_TAD_INT_ENA_W1C	0x40020
#define L2C_TAD_INT_ENA_W1S	0x40028


#define L2C_TAD_INT_L2DDBE	 BIT(1)
#define L2C_TAD_INT_SBFSBE	 BIT(2)
#define L2C_TAD_INT_SBFDBE	 BIT(3)
#define L2C_TAD_INT_FBFSBE	 BIT(4)
#define L2C_TAD_INT_FBFDBE	 BIT(5)
#define L2C_TAD_INT_TAGDBE	 BIT(9)
#define L2C_TAD_INT_RDDISLMC	 BIT(15)
#define L2C_TAD_INT_WRDISLMC	 BIT(16)
#define L2C_TAD_INT_LFBTO	 BIT(17)
#define L2C_TAD_INT_GSYNCTO	 BIT(18)
#define L2C_TAD_INT_RTGSBE	 BIT(32)
#define L2C_TAD_INT_RTGDBE	 BIT(33)
#define L2C_TAD_INT_RDDISOCI	 BIT(34)
#define L2C_TAD_INT_WRDISOCI	 BIT(35)

#define L2C_TAD_INT_ECC		(L2C_TAD_INT_L2DDBE | \
				 L2C_TAD_INT_SBFSBE | L2C_TAD_INT_SBFDBE | \
				 L2C_TAD_INT_FBFSBE | L2C_TAD_INT_FBFDBE)

#define L2C_TAD_INT_CE          (L2C_TAD_INT_SBFSBE | \
				 L2C_TAD_INT_FBFSBE)

#define L2C_TAD_INT_UE          (L2C_TAD_INT_L2DDBE | \
				 L2C_TAD_INT_SBFDBE | \
				 L2C_TAD_INT_FBFDBE | \
				 L2C_TAD_INT_TAGDBE | \
				 L2C_TAD_INT_RTGDBE | \
				 L2C_TAD_INT_WRDISOCI | \
				 L2C_TAD_INT_RDDISOCI | \
				 L2C_TAD_INT_WRDISLMC | \
				 L2C_TAD_INT_RDDISLMC | \
				 L2C_TAD_INT_LFBTO    | \
				 L2C_TAD_INT_GSYNCTO)

static const struct error_descr l2_tad_errors[] = {
	{
		.type  = ERR_CORRECTED,
		.mask  = L2C_TAD_INT_SBFSBE,
		.descr = "SBF single-bit error",
	},
	{
		.type  = ERR_CORRECTED,
		.mask  = L2C_TAD_INT_FBFSBE,
		.descr = "FBF single-bit error",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = L2C_TAD_INT_L2DDBE,
		.descr = "L2D double-bit error",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = L2C_TAD_INT_SBFDBE,
		.descr = "SBF double-bit error",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = L2C_TAD_INT_FBFDBE,
		.descr = "FBF double-bit error",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = L2C_TAD_INT_TAGDBE,
		.descr = "TAG double-bit error",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = L2C_TAD_INT_RTGDBE,
		.descr = "RTG double-bit error",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = L2C_TAD_INT_WRDISOCI,
		.descr = "Write to a disabled CCPI",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = L2C_TAD_INT_RDDISOCI,
		.descr = "Read from a disabled CCPI",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = L2C_TAD_INT_WRDISLMC,
		.descr = "Write to a disabled LMC",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = L2C_TAD_INT_RDDISLMC,
		.descr = "Read from a disabled LMC",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = L2C_TAD_INT_LFBTO,
		.descr = "LFB entry timeout",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = L2C_TAD_INT_GSYNCTO,
		.descr = "Global sync CCPI timeout",
	},
	{0, 0, NULL},
};

#define L2C_TAD_INT_TAG		(L2C_TAD_INT_TAGDBE)

#define L2C_TAD_INT_RTG		(L2C_TAD_INT_RTGDBE)

#define L2C_TAD_INT_DISLMC	(L2C_TAD_INT_WRDISLMC | L2C_TAD_INT_RDDISLMC)

#define L2C_TAD_INT_DISOCI	(L2C_TAD_INT_WRDISOCI | L2C_TAD_INT_RDDISOCI)

#define L2C_TAD_INT_ENA_ALL	(L2C_TAD_INT_ECC | L2C_TAD_INT_TAG | \
				 L2C_TAD_INT_RTG | \
				 L2C_TAD_INT_DISLMC | L2C_TAD_INT_DISOCI | \
				 L2C_TAD_INT_LFBTO)

#define L2C_TAD_TIMETWO		0x50000
#define L2C_TAD_TIMEOUT		0x50100
#define L2C_TAD_ERR		0x60000
#define L2C_TAD_TQD_ERR		0x60100
#define L2C_TAD_TTG_ERR		0x60200


#define L2C_CBC_INT_W1C		0x60000

#define L2C_CBC_INT_RSDSBE	 BIT(0)
#define L2C_CBC_INT_RSDDBE	 BIT(1)

#define L2C_CBC_INT_RSD		 (L2C_CBC_INT_RSDSBE | L2C_CBC_INT_RSDDBE)

#define L2C_CBC_INT_MIBSBE	 BIT(4)
#define L2C_CBC_INT_MIBDBE	 BIT(5)

#define L2C_CBC_INT_MIB		 (L2C_CBC_INT_MIBSBE | L2C_CBC_INT_MIBDBE)

#define L2C_CBC_INT_IORDDISOCI	 BIT(6)
#define L2C_CBC_INT_IOWRDISOCI	 BIT(7)

#define L2C_CBC_INT_IODISOCI	 (L2C_CBC_INT_IORDDISOCI | \
				  L2C_CBC_INT_IOWRDISOCI)

#define L2C_CBC_INT_CE		 (L2C_CBC_INT_RSDSBE | L2C_CBC_INT_MIBSBE)
#define L2C_CBC_INT_UE		 (L2C_CBC_INT_RSDDBE | L2C_CBC_INT_MIBDBE)


static const struct error_descr l2_cbc_errors[] = {
	{
		.type  = ERR_CORRECTED,
		.mask  = L2C_CBC_INT_RSDSBE,
		.descr = "RSD single-bit error",
	},
	{
		.type  = ERR_CORRECTED,
		.mask  = L2C_CBC_INT_MIBSBE,
		.descr = "MIB single-bit error",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = L2C_CBC_INT_RSDDBE,
		.descr = "RSD double-bit error",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = L2C_CBC_INT_MIBDBE,
		.descr = "MIB double-bit error",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = L2C_CBC_INT_IORDDISOCI,
		.descr = "Read from a disabled CCPI",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = L2C_CBC_INT_IOWRDISOCI,
		.descr = "Write to a disabled CCPI",
	},
	{0, 0, NULL},
};

#define L2C_CBC_INT_W1S		0x60008
#define L2C_CBC_INT_ENA_W1C	0x60020

#define L2C_CBC_INT_ENA_ALL	 (L2C_CBC_INT_RSD | L2C_CBC_INT_MIB | \
				  L2C_CBC_INT_IODISOCI)

#define L2C_CBC_INT_ENA_W1S	0x60028

#define L2C_CBC_IODISOCIERR	0x80008
#define L2C_CBC_IOCERR		0x80010
#define L2C_CBC_RSDERR		0x80018
#define L2C_CBC_MIBERR		0x80020


#define L2C_MCI_INT_W1C		0x0

#define L2C_MCI_INT_VBFSBE	 BIT(0)
#define L2C_MCI_INT_VBFDBE	 BIT(1)

static const struct error_descr l2_mci_errors[] = {
	{
		.type  = ERR_CORRECTED,
		.mask  = L2C_MCI_INT_VBFSBE,
		.descr = "VBF single-bit error",
	},
	{
		.type  = ERR_UNCORRECTED,
		.mask  = L2C_MCI_INT_VBFDBE,
		.descr = "VBF double-bit error",
	},
	{0, 0, NULL},
};

#define L2C_MCI_INT_W1S		0x8
#define L2C_MCI_INT_ENA_W1C	0x20

#define L2C_MCI_INT_ENA_ALL	 (L2C_MCI_INT_VBFSBE | L2C_MCI_INT_VBFDBE)

#define L2C_MCI_INT_ENA_W1S	0x28

#define L2C_MCI_ERR		0x10000

#define L2C_MESSAGE_SIZE	SZ_1K
#define L2C_OTHER_SIZE		(50 * ARRAY_SIZE(l2_tad_errors))

struct l2c_err_ctx {
	char *reg_ext_name;
	u64  reg_int;
	u64  reg_ext;
};

struct thunderx_l2c {
	void __iomem *regs;
	struct pci_dev *pdev;
	struct edac_device_ctl_info *edac_dev;

	struct dentry *debugfs;

	int index;

	struct msix_entry msix_ent;

	struct l2c_err_ctx err_ctx[RING_ENTRIES];
	unsigned long ring_head;
	unsigned long ring_tail;
};

static irqreturn_t thunderx_l2c_tad_isr(int irq, void *irq_id)
{
	struct msix_entry *msix = irq_id;
	struct thunderx_l2c *tad = container_of(msix, struct thunderx_l2c,
						msix_ent);

	unsigned long head = ring_pos(tad->ring_head, ARRAY_SIZE(tad->err_ctx));
	struct l2c_err_ctx *ctx = &tad->err_ctx[head];

	ctx->reg_int = readq(tad->regs + L2C_TAD_INT_W1C);

	if (ctx->reg_int & L2C_TAD_INT_ECC) {
		ctx->reg_ext_name = "TQD_ERR";
		ctx->reg_ext = readq(tad->regs + L2C_TAD_TQD_ERR);
	} else if (ctx->reg_int & L2C_TAD_INT_TAG) {
		ctx->reg_ext_name = "TTG_ERR";
		ctx->reg_ext = readq(tad->regs + L2C_TAD_TTG_ERR);
	} else if (ctx->reg_int & L2C_TAD_INT_LFBTO) {
		ctx->reg_ext_name = "TIMEOUT";
		ctx->reg_ext = readq(tad->regs + L2C_TAD_TIMEOUT);
	} else if (ctx->reg_int & L2C_TAD_INT_DISOCI) {
		ctx->reg_ext_name = "ERR";
		ctx->reg_ext = readq(tad->regs + L2C_TAD_ERR);
	}

	writeq(ctx->reg_int, tad->regs + L2C_TAD_INT_W1C);

	tad->ring_head++;

	return IRQ_WAKE_THREAD;
}

static irqreturn_t thunderx_l2c_cbc_isr(int irq, void *irq_id)
{
	struct msix_entry *msix = irq_id;
	struct thunderx_l2c *cbc = container_of(msix, struct thunderx_l2c,
						msix_ent);

	unsigned long head = ring_pos(cbc->ring_head, ARRAY_SIZE(cbc->err_ctx));
	struct l2c_err_ctx *ctx = &cbc->err_ctx[head];

	ctx->reg_int = readq(cbc->regs + L2C_CBC_INT_W1C);

	if (ctx->reg_int & L2C_CBC_INT_RSD) {
		ctx->reg_ext_name = "RSDERR";
		ctx->reg_ext = readq(cbc->regs + L2C_CBC_RSDERR);
	} else if (ctx->reg_int & L2C_CBC_INT_MIB) {
		ctx->reg_ext_name = "MIBERR";
		ctx->reg_ext = readq(cbc->regs + L2C_CBC_MIBERR);
	} else if (ctx->reg_int & L2C_CBC_INT_IODISOCI) {
		ctx->reg_ext_name = "IODISOCIERR";
		ctx->reg_ext = readq(cbc->regs + L2C_CBC_IODISOCIERR);
	}

	writeq(ctx->reg_int, cbc->regs + L2C_CBC_INT_W1C);

	cbc->ring_head++;

	return IRQ_WAKE_THREAD;
}

static irqreturn_t thunderx_l2c_mci_isr(int irq, void *irq_id)
{
	struct msix_entry *msix = irq_id;
	struct thunderx_l2c *mci = container_of(msix, struct thunderx_l2c,
						msix_ent);

	unsigned long head = ring_pos(mci->ring_head, ARRAY_SIZE(mci->err_ctx));
	struct l2c_err_ctx *ctx = &mci->err_ctx[head];

	ctx->reg_int = readq(mci->regs + L2C_MCI_INT_W1C);
	ctx->reg_ext = readq(mci->regs + L2C_MCI_ERR);

	writeq(ctx->reg_int, mci->regs + L2C_MCI_INT_W1C);

	ctx->reg_ext_name = "ERR";

	mci->ring_head++;

	return IRQ_WAKE_THREAD;
}

static irqreturn_t thunderx_l2c_threaded_isr(int irq, void *irq_id)
{
	struct msix_entry *msix = irq_id;
	struct thunderx_l2c *l2c = container_of(msix, struct thunderx_l2c,
						msix_ent);

	unsigned long tail = ring_pos(l2c->ring_tail, ARRAY_SIZE(l2c->err_ctx));
	struct l2c_err_ctx *ctx = &l2c->err_ctx[tail];
	irqreturn_t ret = IRQ_NONE;

	u64 mask_ue, mask_ce;
	const struct error_descr *l2_errors;
	char *reg_int_name;

	char *msg;
	char *other;

	msg = kmalloc(OCX_MESSAGE_SIZE, GFP_KERNEL);
	other = kmalloc(OCX_OTHER_SIZE, GFP_KERNEL);

	if (!msg || !other)
		goto err_free;

	switch (l2c->pdev->device) {
	case PCI_DEVICE_ID_THUNDER_L2C_TAD:
		reg_int_name = "L2C_TAD_INT";
		mask_ue = L2C_TAD_INT_UE;
		mask_ce = L2C_TAD_INT_CE;
		l2_errors = l2_tad_errors;
		break;
	case PCI_DEVICE_ID_THUNDER_L2C_CBC:
		reg_int_name = "L2C_CBC_INT";
		mask_ue = L2C_CBC_INT_UE;
		mask_ce = L2C_CBC_INT_CE;
		l2_errors = l2_cbc_errors;
		break;
	case PCI_DEVICE_ID_THUNDER_L2C_MCI:
		reg_int_name = "L2C_MCI_INT";
		mask_ue = L2C_MCI_INT_VBFDBE;
		mask_ce = L2C_MCI_INT_VBFSBE;
		l2_errors = l2_mci_errors;
		break;
	default:
		dev_err(&l2c->pdev->dev, "Unsupported device: %04x\n",
			l2c->pdev->device);
		goto err_free;
	}

	while (CIRC_CNT(l2c->ring_head, l2c->ring_tail,
			ARRAY_SIZE(l2c->err_ctx))) {
		snprintf(msg, L2C_MESSAGE_SIZE,
			 "%s: %s: %016llx, %s: %016llx",
			 l2c->edac_dev->ctl_name, reg_int_name, ctx->reg_int,
			 ctx->reg_ext_name, ctx->reg_ext);

		decode_register(other, L2C_OTHER_SIZE, l2_errors, ctx->reg_int);

		strlcat(msg, other, L2C_MESSAGE_SIZE);

		if (ctx->reg_int & mask_ue)
			edac_device_handle_ue(l2c->edac_dev, 0, 0, msg);
		else if (ctx->reg_int & mask_ce)
			edac_device_handle_ce(l2c->edac_dev, 0, 0, msg);

		l2c->ring_tail++;
	}

	ret = IRQ_HANDLED;

err_free:
	kfree(other);
	kfree(msg);

	return ret;
}

#define L2C_DEBUGFS_ATTR(_name, _reg)	DEBUGFS_REG_ATTR(l2c, _name, _reg)

L2C_DEBUGFS_ATTR(tad_int, L2C_TAD_INT_W1S);

static struct debugfs_entry *l2c_tad_dfs_ents[] = {
	&debugfs_tad_int,
};

L2C_DEBUGFS_ATTR(cbc_int, L2C_CBC_INT_W1S);

static struct debugfs_entry *l2c_cbc_dfs_ents[] = {
	&debugfs_cbc_int,
};

L2C_DEBUGFS_ATTR(mci_int, L2C_MCI_INT_W1S);

static struct debugfs_entry *l2c_mci_dfs_ents[] = {
	&debugfs_mci_int,
};

static const struct pci_device_id thunderx_l2c_pci_tbl[] = {
	{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVICE_ID_THUNDER_L2C_TAD), },
	{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVICE_ID_THUNDER_L2C_CBC), },
	{ PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVICE_ID_THUNDER_L2C_MCI), },
	{ 0, },
};

static int thunderx_l2c_probe(struct pci_dev *pdev,
			      const struct pci_device_id *id)
{
	struct thunderx_l2c *l2c;
	struct edac_device_ctl_info *edac_dev;
	struct debugfs_entry **l2c_devattr;
	size_t dfs_entries;
	irqreturn_t (*thunderx_l2c_isr)(int, void *) = NULL;
	char name[32];
	const char *fmt;
	u64 reg_en_offs, reg_en_mask;
	int idx;
	int ret;

	ret = pcim_enable_device(pdev);
	if (ret) {
		dev_err(&pdev->dev, "Cannot enable PCI device: %d\n", ret);
		return ret;
	}

	ret = pcim_iomap_regions(pdev, BIT(0), "thunderx_l2c");
	if (ret) {
		dev_err(&pdev->dev, "Cannot map PCI resources: %d\n", ret);
		return ret;
	}

	switch (pdev->device) {
	case PCI_DEVICE_ID_THUNDER_L2C_TAD:
		thunderx_l2c_isr = thunderx_l2c_tad_isr;
		l2c_devattr = l2c_tad_dfs_ents;
		dfs_entries = ARRAY_SIZE(l2c_tad_dfs_ents);
		fmt = "L2C-TAD%d";
		reg_en_offs = L2C_TAD_INT_ENA_W1S;
		reg_en_mask = L2C_TAD_INT_ENA_ALL;
		break;
	case PCI_DEVICE_ID_THUNDER_L2C_CBC:
		thunderx_l2c_isr = thunderx_l2c_cbc_isr;
		l2c_devattr = l2c_cbc_dfs_ents;
		dfs_entries = ARRAY_SIZE(l2c_cbc_dfs_ents);
		fmt = "L2C-CBC%d";
		reg_en_offs = L2C_CBC_INT_ENA_W1S;
		reg_en_mask = L2C_CBC_INT_ENA_ALL;
		break;
	case PCI_DEVICE_ID_THUNDER_L2C_MCI:
		thunderx_l2c_isr = thunderx_l2c_mci_isr;
		l2c_devattr = l2c_mci_dfs_ents;
		dfs_entries = ARRAY_SIZE(l2c_mci_dfs_ents);
		fmt = "L2C-MCI%d";
		reg_en_offs = L2C_MCI_INT_ENA_W1S;
		reg_en_mask = L2C_MCI_INT_ENA_ALL;
		break;
	default:
		//Should never ever get here
		dev_err(&pdev->dev, "Unsupported PCI device: %04x\n",
			pdev->device);
		return -EINVAL;
	}

	idx = edac_device_alloc_index();
	snprintf(name, sizeof(name), fmt, idx);

	edac_dev = edac_device_alloc_ctl_info(sizeof(struct thunderx_l2c),
					      name, 1, "L2C", 1, 0, idx);
	if (!edac_dev) {
		dev_err(&pdev->dev, "Cannot allocate EDAC device\n");
		return -ENOMEM;
	}

	l2c = edac_dev->pvt_info;
	l2c->edac_dev = edac_dev;

	l2c->regs = pcim_iomap_table(pdev)[0];
	if (!l2c->regs) {
		dev_err(&pdev->dev, "Cannot map PCI resources\n");
		ret = -ENODEV;
		goto err_free;
	}

	l2c->pdev = pdev;

	l2c->ring_head = 0;
	l2c->ring_tail = 0;

	l2c->msix_ent.entry = 0;
	l2c->msix_ent.vector = 0;

	ret = pci_enable_msix_exact(pdev, &l2c->msix_ent, 1);
	if (ret) {
		dev_err(&pdev->dev, "Cannot enable interrupt: %d\n", ret);
		goto err_free;
	}

	ret = devm_request_threaded_irq(&pdev->dev, l2c->msix_ent.vector,
					thunderx_l2c_isr,
					thunderx_l2c_threaded_isr,
					0, "[EDAC] ThunderX L2C",
					&l2c->msix_ent);
	if (ret)
		goto err_free;

	edac_dev->dev = &pdev->dev;
	edac_dev->dev_name = dev_name(&pdev->dev);
	edac_dev->mod_name = "thunderx-l2c";
	edac_dev->ctl_name = "thunderx-l2c";

	ret = edac_device_add_device(edac_dev);
	if (ret) {
		dev_err(&pdev->dev, "Cannot add EDAC device: %d\n", ret);
		goto err_free;
	}

	if (IS_ENABLED(CONFIG_EDAC_DEBUG)) {
		l2c->debugfs = edac_debugfs_create_dir(pdev->dev.kobj.name);

		ret = thunderx_create_debugfs_nodes(l2c->debugfs, l2c_devattr,
					      l2c, dfs_entries);

		if (ret != dfs_entries) {
			dev_warn(&pdev->dev, "Error creating debugfs entries: %d%s\n",
				 ret, ret >= 0 ? " created" : "");
		}
	}

	pci_set_drvdata(pdev, edac_dev);

	writeq(reg_en_mask, l2c->regs + reg_en_offs);

	return 0;

err_free:
	edac_device_free_ctl_info(edac_dev);

	return ret;
}

static void thunderx_l2c_remove(struct pci_dev *pdev)
{
	struct edac_device_ctl_info *edac_dev = pci_get_drvdata(pdev);
	struct thunderx_l2c *l2c = edac_dev->pvt_info;

	switch (pdev->device) {
	case PCI_DEVICE_ID_THUNDER_L2C_TAD:
		writeq(L2C_TAD_INT_ENA_ALL, l2c->regs + L2C_TAD_INT_ENA_W1C);
		break;
	case PCI_DEVICE_ID_THUNDER_L2C_CBC:
		writeq(L2C_CBC_INT_ENA_ALL, l2c->regs + L2C_CBC_INT_ENA_W1C);
		break;
	case PCI_DEVICE_ID_THUNDER_L2C_MCI:
		writeq(L2C_MCI_INT_ENA_ALL, l2c->regs + L2C_MCI_INT_ENA_W1C);
		break;
	}

	edac_debugfs_remove_recursive(l2c->debugfs);

	edac_device_del_device(&pdev->dev);
	edac_device_free_ctl_info(edac_dev);
}

MODULE_DEVICE_TABLE(pci, thunderx_l2c_pci_tbl);

static struct pci_driver thunderx_l2c_driver = {
	.name     = "thunderx_l2c_edac",
	.probe    = thunderx_l2c_probe,
	.remove   = thunderx_l2c_remove,
	.id_table = thunderx_l2c_pci_tbl,
};

static int __init thunderx_edac_init(void)
{
	int rc = 0;

	if (ghes_get_devices())
		return -EBUSY;

	rc = pci_register_driver(&thunderx_lmc_driver);
	if (rc)
		return rc;

	rc = pci_register_driver(&thunderx_ocx_driver);
	if (rc)
		goto err_lmc;

	rc = pci_register_driver(&thunderx_l2c_driver);
	if (rc)
		goto err_ocx;

	return rc;
err_ocx:
	pci_unregister_driver(&thunderx_ocx_driver);
err_lmc:
	pci_unregister_driver(&thunderx_lmc_driver);

	return rc;
}

static void __exit thunderx_edac_exit(void)
{
	pci_unregister_driver(&thunderx_l2c_driver);
	pci_unregister_driver(&thunderx_ocx_driver);
	pci_unregister_driver(&thunderx_lmc_driver);

}

module_init(thunderx_edac_init);
module_exit(thunderx_edac_exit);

MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Cavium, Inc.");
MODULE_DESCRIPTION("EDAC Driver for Cavium ThunderX");
