// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright 2020 NXP
 * Layerscape PCIe EP driver
 */

#include <common.h>
#include <asm/arch/fsl_serdes.h>
#include <dm.h>
#include <dm/devres.h>
#include <errno.h>
#include <pci_ep.h>
#include <asm/io.h>
#include <linux/sizes.h>
#include <linux/log2.h>
#include "pcie_layerscape.h"

DECLARE_GLOBAL_DATA_PTR;

static void ls_pcie_ep_enable_cfg(struct ls_pcie_ep *pcie_ep)
{
	struct ls_pcie *pcie = pcie_ep->pcie;
	u32 config;

	config = ctrl_readl(pcie,  PCIE_PF_CONFIG);
	config |= PCIE_CONFIG_READY;
	ctrl_writel(pcie, config, PCIE_PF_CONFIG);
}

static int ls_ep_set_bar(struct udevice *dev, uint fn, struct pci_bar *ep_bar)
{
	struct ls_pcie_ep *pcie_ep = dev_get_priv(dev);
	struct ls_pcie *pcie = pcie_ep->pcie;
	dma_addr_t bar_phys = ep_bar->phys_addr;
	enum pci_barno bar = ep_bar->barno;
	u32 reg = PCI_BASE_ADDRESS_0 + (4 * bar);
	int flags = ep_bar->flags;
	int type, idx;
	u64 size;

	idx  = bar;
	/* BAR size is 2^(aperture + 11) */
	size = max_t(size_t, ep_bar->size, FSL_PCIE_EP_MIN_APERTURE);

	if (!(flags & PCI_BASE_ADDRESS_SPACE))
		type = PCIE_ATU_TYPE_MEM;
	else
		type = PCIE_ATU_TYPE_IO;

	ls_pcie_atu_inbound_set(pcie, fn, 0, type, idx, bar, bar_phys);

	dbi_writel(pcie, lower_32_bits(size - 1), reg + PCIE_NO_SRIOV_BAR_BASE);
	dbi_writel(pcie, flags, reg);

	if (flags & PCI_BASE_ADDRESS_MEM_TYPE_64) {
		dbi_writel(pcie, upper_32_bits(size - 1),
			   reg + 4 + PCIE_NO_SRIOV_BAR_BASE);
		dbi_writel(pcie, 0, reg + 4);
	}

	return 0;
}

static struct pci_ep_ops ls_pcie_ep_ops = {
	.set_bar = ls_ep_set_bar,
};

static void ls_pcie_ep_setup_atu(struct ls_pcie_ep *pcie_ep, u32 pf)
{
	struct ls_pcie *pcie = pcie_ep->pcie;
	u32 vf_flag = 0;
	u64 phys = 0;

	phys = CONFIG_SYS_PCI_EP_MEMORY_BASE + pf * SZ_64M;

	phys = ALIGN(phys, PCIE_BAR0_SIZE);
	/* ATU 0 : INBOUND : map BAR0 */
	ls_pcie_atu_inbound_set(pcie, pf, vf_flag, PCIE_ATU_TYPE_MEM,
				0 + pf * BAR_NUM, 0, phys);
	/* ATU 1 : INBOUND : map BAR1 */
	phys = ALIGN(phys + PCIE_BAR0_SIZE, PCIE_BAR1_SIZE);
	ls_pcie_atu_inbound_set(pcie, pf, vf_flag, PCIE_ATU_TYPE_MEM,
				1 + pf * BAR_NUM, 1, phys);
	/* ATU 2 : INBOUND : map BAR2 */
	phys = ALIGN(phys + PCIE_BAR1_SIZE, PCIE_BAR2_SIZE);
	ls_pcie_atu_inbound_set(pcie, pf, vf_flag, PCIE_ATU_TYPE_MEM,
				2 + pf * BAR_NUM, 2, phys);
	/* ATU 3 : INBOUND : map BAR2 */
	phys = ALIGN(phys + PCIE_BAR2_SIZE, PCIE_BAR4_SIZE);
	ls_pcie_atu_inbound_set(pcie, pf, vf_flag, PCIE_ATU_TYPE_MEM,
				3 + pf * BAR_NUM, 4, phys);

	if (pcie_ep->sriov_flag) {
		vf_flag = 1;
		/* ATU 4 : INBOUND : map BAR0 */
		phys = ALIGN(phys + PCIE_BAR4_SIZE, PCIE_BAR0_SIZE);
		ls_pcie_atu_inbound_set(pcie, pf, vf_flag, PCIE_ATU_TYPE_MEM,
					4 + pf * BAR_NUM, 0, phys);
		/* ATU 5 : INBOUND : map BAR1 */
		phys = ALIGN(phys + PCIE_BAR0_SIZE * PCIE_VF_NUM,
			     PCIE_BAR1_SIZE);
		ls_pcie_atu_inbound_set(pcie, pf, vf_flag, PCIE_ATU_TYPE_MEM,
					5 + pf * BAR_NUM, 1, phys);
		/* ATU 6 : INBOUND : map BAR2 */
		phys = ALIGN(phys + PCIE_BAR1_SIZE * PCIE_VF_NUM,
			     PCIE_BAR2_SIZE);
		ls_pcie_atu_inbound_set(pcie, pf, vf_flag, PCIE_ATU_TYPE_MEM,
					6 + pf * BAR_NUM, 2, phys);
		/* ATU 7 : INBOUND : map BAR4 */
		phys = ALIGN(phys + PCIE_BAR2_SIZE * PCIE_VF_NUM,
			     PCIE_BAR4_SIZE);
		ls_pcie_atu_inbound_set(pcie, pf, vf_flag, PCIE_ATU_TYPE_MEM,
					7 + pf * BAR_NUM, 4, phys);
	}

	/* ATU: OUTBOUND : map MEM */
	ls_pcie_atu_outbound_set(pcie, pf, PCIE_ATU_TYPE_MEM,
				 (u64)pcie_ep->addr_res.start +
				 pf * CONFIG_SYS_PCI_MEMORY_SIZE,
				 0, CONFIG_SYS_PCI_MEMORY_SIZE);
}

/* BAR0 and BAR1 are 32bit BAR2 and BAR4 are 64bit */
static void ls_pcie_ep_setup_bar(void *bar_base, int bar, u32 size)
{
	u32 mask;

	/* The least inbound window is 4KiB */
	if (size < SZ_4K)
		mask = 0;
	else
		mask = size - 1;

	switch (bar) {
	case 0:
		writel(mask, bar_base + PCI_BASE_ADDRESS_0);
		break;
	case 1:
		writel(mask, bar_base + PCI_BASE_ADDRESS_1);
		break;
	case 2:
		writel(mask, bar_base + PCI_BASE_ADDRESS_2);
		writel(0, bar_base + PCI_BASE_ADDRESS_3);
		break;
	case 4:
		writel(mask, bar_base + PCI_BASE_ADDRESS_4);
		writel(0, bar_base + PCI_BASE_ADDRESS_5);
		break;
	default:
		break;
	}
}

static void ls_pcie_ep_setup_bars(void *bar_base)
{
	/* BAR0 - 32bit - MEM */
	ls_pcie_ep_setup_bar(bar_base, 0, PCIE_BAR0_SIZE);
	/* BAR1 - 32bit - MEM*/
	ls_pcie_ep_setup_bar(bar_base, 1, PCIE_BAR1_SIZE);
	/* BAR2 - 64bit - MEM */
	ls_pcie_ep_setup_bar(bar_base, 2, PCIE_BAR2_SIZE);
	/* BAR4 - 64bit - MEM */
	ls_pcie_ep_setup_bar(bar_base, 4, PCIE_BAR4_SIZE);
}

static void ls_pcie_ep_setup_vf_bars(void *bar_base)
{
	/* VF BAR0 MASK register at offset 0x19c*/
	bar_base += PCIE_SRIOV_VFBAR0 - PCI_BASE_ADDRESS_0;

	/* VF-BAR0 - 32bit - MEM */
	ls_pcie_ep_setup_bar(bar_base, 0, PCIE_BAR0_SIZE);
	/* VF-BAR1 - 32bit - MEM*/
	ls_pcie_ep_setup_bar(bar_base, 1, PCIE_BAR1_SIZE);
	/* VF-BAR2 - 64bit - MEM */
	ls_pcie_ep_setup_bar(bar_base, 2, PCIE_BAR2_SIZE);
	/* VF-BAR4 - 64bit - MEM */
	ls_pcie_ep_setup_bar(bar_base, 4, PCIE_BAR4_SIZE);
}

static void ls_pcie_setup_ep(struct ls_pcie_ep *pcie_ep)
{
	u32 sriov;
	u32 pf, vf;
	void *bar_base = NULL;
	struct ls_pcie *pcie = pcie_ep->pcie;

	sriov = readl(pcie->dbi + PCIE_SRIOV);
	if (PCI_EXT_CAP_ID(sriov) == PCI_EXT_CAP_ID_SRIOV) {
		pcie_ep->sriov_flag = 1;
		for (pf = 0; pf < PCIE_PF_NUM; pf++) {
			/*
			 * The VF_BARn_REG register's Prefetchable and Type bit
			 * fields are overwritten by a write to VF's BAR Mask
			 * register. Before writing to the VF_BARn_MASK_REG
			 * register, write 0b to the PCIE_MISC_CONTROL_1_OFF
			 * register.
			 */
			writel(0, pcie->dbi + PCIE_MISC_CONTROL_1_OFF);

			bar_base = pcie->dbi +
				   PCIE_MASK_OFFSET(pcie_ep->cfg2_flag, pf,
						    pcie_ep->pf1_offset);

			if (pcie_ep->cfg2_flag) {
				ctrl_writel(pcie,
					    PCIE_LCTRL0_VAL(pf, 0),
					    PCIE_PF_VF_CTRL);
				ls_pcie_ep_setup_bars(bar_base);

				for (vf = 1; vf <= PCIE_VF_NUM; vf++) {
					ctrl_writel(pcie,
						    PCIE_LCTRL0_VAL(pf, vf),
						    PCIE_PF_VF_CTRL);
					ls_pcie_ep_setup_vf_bars(bar_base);
				}
			} else {
				ls_pcie_ep_setup_bars(bar_base);
				ls_pcie_ep_setup_vf_bars(bar_base);
			}

			ls_pcie_ep_setup_atu(pcie_ep, pf);
		}

		if (pcie_ep->cfg2_flag)  /* Disable CFG2 */
			ctrl_writel(pcie, 0, PCIE_PF_VF_CTRL);
	} else {
		ls_pcie_ep_setup_bars(pcie->dbi + PCIE_NO_SRIOV_BAR_BASE);
		ls_pcie_ep_setup_atu(pcie_ep, 0);
	}

	ls_pcie_dump_atu(pcie, PCIE_ATU_REGION_NUM_SRIOV,
			 PCIE_ATU_REGION_INBOUND);

	ls_pcie_ep_enable_cfg(pcie_ep);
}

static int ls_pcie_ep_probe(struct udevice *dev)
{
	struct ls_pcie_ep *pcie_ep = dev_get_priv(dev);
	struct ls_pcie *pcie;
	u16 link_sta;
	int ret;
	u32 svr;

	pcie = devm_kmalloc(dev, sizeof(*pcie), GFP_KERNEL);
	if (!pcie)
		return -ENOMEM;

	pcie_ep->pcie = pcie;

	pcie->dbi = (void __iomem *)devfdt_get_addr_index(dev, 0);
	if (!pcie->dbi)
		return -ENOMEM;

	pcie->ctrl = (void __iomem *)devfdt_get_addr_index(dev, 1);
	if (!pcie->ctrl)
		return -ENOMEM;

	ret = fdt_get_named_resource(gd->fdt_blob, dev_of_offset(dev),
				     "reg", "reg-names",
				     "addr_space", &pcie_ep->addr_res);
	if (ret) {
		printf("%s: resource \"addr_space\" not found\n", dev->name);
		return ret;
	}

	pcie->idx = ((unsigned long)pcie->dbi - PCIE_SYS_BASE_ADDR) /
		    PCIE_CCSR_SIZE;

	pcie->big_endian = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
					   "big-endian");

	svr = SVR_SOC_VER(get_svr());

	if (svr == SVR_LX2160A || svr == SVR_LX2162A ||
	    svr == SVR_LX2120A || svr == SVR_LX2080A ||
	    svr == SVR_LX2122A || svr == SVR_LX2082A)
		pcie_ep->pf1_offset = LX2160_PCIE_PF1_OFFSET;
	else
		pcie_ep->pf1_offset = LS_PCIE_PF1_OFFSET;

	if (svr == SVR_LS2080A || svr == SVR_LS2085A)
		pcie_ep->cfg2_flag = 1;
	else
		pcie_ep->cfg2_flag = 0;

	pcie->mode = readb(pcie->dbi + PCI_HEADER_TYPE) & 0x7f;
	if (pcie->mode != PCI_HEADER_TYPE_NORMAL)
		return 0;

	pcie_ep->max_functions = fdtdec_get_int(gd->fdt_blob,
						dev_of_offset(dev),
						"max-functions", 1);
	pcie_ep->num_ib_wins = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
					      "num-ib-windows", 8);
	pcie_ep->num_ob_wins = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
					      "num-ob-windows", 8);

	printf("PCIe%u: %s %s", PCIE_SRDS_PRTCL(pcie->idx), dev->name,
	       "Endpoint");
	ls_pcie_setup_ep(pcie_ep);

	if (!ls_pcie_link_up(pcie)) {
		/* Let the user know there's no PCIe link */
		printf(": no link\n");
		return 0;
	}

	/* Print the negotiated PCIe link width */
	link_sta = readw(pcie->dbi + PCIE_LINK_STA);
	printf(": x%d gen%d\n", (link_sta & PCIE_LINK_WIDTH_MASK) >> 4,
	       link_sta & PCIE_LINK_SPEED_MASK);

	return 0;
}

static int ls_pcie_ep_remove(struct udevice *dev)
{
	return 0;
}

const struct udevice_id ls_pcie_ep_ids[] = {
	{ .compatible = "fsl,ls-pcie-ep" },
	{ }
};

U_BOOT_DRIVER(pci_layerscape_ep) = {
	.name = "pci_layerscape_ep",
	.id	= UCLASS_PCI_EP,
	.of_match = ls_pcie_ep_ids,
	.ops = &ls_pcie_ep_ops,
	.probe = ls_pcie_ep_probe,
	.remove = ls_pcie_ep_remove,
	.priv_auto	= sizeof(struct ls_pcie_ep),
};
