From 9e589647fb0418f47d0e02934c06d324d50701c6 Mon Sep 17 00:00:00 2001 From: Liu Gang Date: Wed, 10 Aug 2016 15:07:08 +0800 Subject: pci-ep/ls1046a: Correct LUT offset for different LS platform There are different LUT offsets for different LS platforms. Adding a private struct for each LS platform in the of_device_id struct to bring in the specific LUT offset for the LS platform. Signed-off-by: Liu Gang Signed-off-by: Hou Zhiqiang diff --git a/drivers/pci/host/pci-layerscape-ep.c b/drivers/pci/host/pci-layerscape-ep.c index 4ee6884..7b99982 100644 --- a/drivers/pci/host/pci-layerscape-ep.c +++ b/drivers/pci/host/pci-layerscape-ep.c @@ -177,7 +177,7 @@ static int ls_pcie_ep_init(struct ls_pcie *pcie) vf = PCIE_VF_NUM; } else { pcie->sriov = 0; - pf = 0; + pf = 1; vf = 0; } @@ -189,12 +189,45 @@ static int ls_pcie_ep_init(struct ls_pcie *pcie) return 0; } +static struct ls_pcie_ep_drvdata ls1043_drvdata = { + .lut_offset = 0x10000, + .ltssm_shift = 24, + .lut_dbg = 0x7fc, +}; + +static struct ls_pcie_ep_drvdata ls1046_drvdata = { + .lut_offset = 0x80000, + .ltssm_shift = 24, + .lut_dbg = 0x407fc, +}; + +static struct ls_pcie_ep_drvdata ls2080_drvdata = { + .lut_offset = 0x80000, + .ltssm_shift = 0, + .lut_dbg = 0x7fc, +}; + +static const struct of_device_id ls_pcie_ep_of_match[] = { + { .compatible = "fsl,ls1021a-pcie", }, + { .compatible = "fsl,ls1043a-pcie", .data = &ls1043_drvdata }, + { .compatible = "fsl,ls1046a-pcie", .data = &ls1046_drvdata }, + { .compatible = "fsl,ls2080a-pcie", .data = &ls2080_drvdata }, + { .compatible = "fsl,ls2085a-pcie", .data = &ls2080_drvdata }, + { }, +}; +MODULE_DEVICE_TABLE(of, ls_pcie_ep_of_match); + static int ls_pcie_ep_probe(struct platform_device *pdev) { struct ls_pcie *pcie; struct resource *dbi_base, *cfg_res; + const struct of_device_id *match; int ret; + match = of_match_device(ls_pcie_ep_of_match, &pdev->dev); + if (!match) + return -ENODEV; + pcie = devm_kzalloc(&pdev->dev, sizeof(*pcie), GFP_KERNEL); if (!pcie) return -ENOMEM; @@ -209,7 +242,8 @@ static int ls_pcie_ep_probe(struct platform_device *pdev) return PTR_ERR(pcie->dbi); } - pcie->lut = pcie->dbi + PCIE_LUT_BASE; + pcie->drvdata = match->data; + pcie->lut = pcie->dbi + pcie->drvdata->lut_offset; if (ls_pcie_is_bridge(pcie)) return -ENODEV; @@ -258,13 +292,6 @@ static int ls_pcie_ep_remove(struct platform_device *pdev) return 0; } -static const struct of_device_id ls_pcie_ep_of_match[] = { - { .compatible = "fsl,ls2085a-pcie" }, - { .compatible = "fsl,ls2080a-pcie" }, - { }, -}; -MODULE_DEVICE_TABLE(of, ls_pcie_ep_of_match); - static struct platform_driver ls_pcie_ep_driver = { .driver = { .name = "ls-pcie-ep", diff --git a/drivers/pci/host/pci-layerscape-ep.h b/drivers/pci/host/pci-layerscape-ep.h index 89dd109..19e7e36 100644 --- a/drivers/pci/host/pci-layerscape-ep.h +++ b/drivers/pci/host/pci-layerscape-ep.h @@ -66,10 +66,17 @@ #define PCIE_PF_NUM 2 #define PCIE_VF_NUM 64 +struct ls_pcie_ep_drvdata { + u32 lut_offset; + u32 ltssm_shift; + u32 lut_dbg; +}; + struct ls_pcie { struct list_head ep_list; struct device *dev; struct dentry *dir; + const struct ls_pcie_ep_drvdata *drvdata; void __iomem *dbi; void __iomem *lut; phys_addr_t out_base; -- cgit v0.10.2