Skip to content

Commit cc255eb

Browse files
Xiaowei BaoLorenzo Pieralisi
authored andcommitted
PCI: layerscape: Modify the way of getting capability with different PEX
The different PCIe controller in one board may be have different capability of MSI or MSIX, so change the way of getting the MSI capability, make it more flexible. Link: https://lore.kernel.org/r/20200918080024.13639-8-Zhiqiang.Hou@nxp.com Signed-off-by: Xiaowei Bao <xiaowei.bao@nxp.com> Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Reviewed-by: Rob Herring <robh@kernel.org>
1 parent 20e458f commit cc255eb

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

‎drivers/pci/controller/dwc/pci-layerscape-ep.c‎

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
struct ls_pcie_ep {
2424
struct dw_pcie *pci;
25+
struct pci_epc_features *ls_epc;
2526
};
2627

2728
#define to_ls_pcie_ep(x) dev_get_drvdata((x)->dev)
@@ -40,26 +41,31 @@ static const struct of_device_id ls_pcie_ep_of_match[] = {
4041
{ },
4142
};
4243

43-
static const struct pci_epc_features ls_pcie_epc_features = {
44-
.linkup_notifier = false,
45-
.msi_capable = true,
46-
.msix_capable = false,
47-
.bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4),
48-
};
49-
5044
static const struct pci_epc_features*
5145
ls_pcie_ep_get_features(struct dw_pcie_ep *ep)
5246
{
53-
return &ls_pcie_epc_features;
47+
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
48+
struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci);
49+
50+
return pcie->ls_epc;
5451
}
5552

5653
static void ls_pcie_ep_init(struct dw_pcie_ep *ep)
5754
{
5855
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
56+
struct ls_pcie_ep *pcie = to_ls_pcie_ep(pci);
57+
struct dw_pcie_ep_func *ep_func;
5958
enum pci_barno bar;
6059

60+
ep_func = dw_pcie_ep_get_func_from_ep(ep, 0);
61+
if (!ep_func)
62+
return;
63+
6164
for (bar = 0; bar < PCI_STD_NUM_BARS; bar++)
6265
dw_pcie_ep_reset_bar(pci, bar);
66+
67+
pcie->ls_epc->msi_capable = ep_func->msi_cap ? true : false;
68+
pcie->ls_epc->msix_capable = ep_func->msix_cap ? true : false;
6369
}
6470

6571
static int ls_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no,
@@ -119,6 +125,7 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev)
119125
struct device *dev = &pdev->dev;
120126
struct dw_pcie *pci;
121127
struct ls_pcie_ep *pcie;
128+
struct pci_epc_features *ls_epc;
122129
struct resource *dbi_base;
123130
int ret;
124131

@@ -130,6 +137,10 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev)
130137
if (!pci)
131138
return -ENOMEM;
132139

140+
ls_epc = devm_kzalloc(dev, sizeof(*ls_epc), GFP_KERNEL);
141+
if (!ls_epc)
142+
return -ENOMEM;
143+
133144
dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
134145
pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base);
135146
if (IS_ERR(pci->dbi_base))
@@ -140,6 +151,10 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev)
140151
pci->ops = &ls_pcie_ep_ops;
141152
pcie->pci = pci;
142153

154+
ls_epc->bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4),
155+
156+
pcie->ls_epc = ls_epc;
157+
143158
platform_set_drvdata(pdev, pcie);
144159

145160
ret = ls_add_pcie_ep(pcie, pdev);

0 commit comments

Comments
 (0)