Skip to content

Commit aa5a239

Browse files
committed
Merge branch 'pci/controller/layerscape'
- Add support for link-down notification so the endpoint driver can process LINK_DOWN events (Frank Li) - Save Link Capabilities during probe so they can be restored when handling a link-up event, since the controller loses the Link Width and Link Speed values during reset (Xiaowei Bao) * pci/controller/layerscape: PCI: layerscape: Add workaround for lost link capabilities during reset PCI: layerscape: Add support for link-down notification
2 parents d4218e2 + 17cf866 commit aa5a239

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct ls_pcie_ep {
4545
struct pci_epc_features *ls_epc;
4646
const struct ls_pcie_ep_drvdata *drvdata;
4747
int irq;
48+
u32 lnkcap;
4849
bool big_endian;
4950
};
5051

@@ -73,6 +74,7 @@ static irqreturn_t ls_pcie_ep_event_handler(int irq, void *dev_id)
7374
struct ls_pcie_ep *pcie = dev_id;
7475
struct dw_pcie *pci = pcie->pci;
7576
u32 val, cfg;
77+
u8 offset;
7678

7779
val = ls_lut_readl(pcie, PEX_PF0_PME_MES_DR);
7880
ls_lut_writel(pcie, PEX_PF0_PME_MES_DR, val);
@@ -81,6 +83,19 @@ static irqreturn_t ls_pcie_ep_event_handler(int irq, void *dev_id)
8183
return IRQ_NONE;
8284

8385
if (val & PEX_PF0_PME_MES_DR_LUD) {
86+
87+
offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
88+
89+
/*
90+
* The values of the Maximum Link Width and Supported Link
91+
* Speed from the Link Capabilities Register will be lost
92+
* during link down or hot reset. Restore initial value
93+
* that configured by the Reset Configuration Word (RCW).
94+
*/
95+
dw_pcie_dbi_ro_wr_en(pci);
96+
dw_pcie_writel_dbi(pci, offset + PCI_EXP_LNKCAP, pcie->lnkcap);
97+
dw_pcie_dbi_ro_wr_dis(pci);
98+
8499
cfg = ls_lut_readl(pcie, PEX_PF0_CONFIG);
85100
cfg |= PEX_PF0_CFG_READY;
86101
ls_lut_writel(pcie, PEX_PF0_CONFIG, cfg);
@@ -89,6 +104,7 @@ static irqreturn_t ls_pcie_ep_event_handler(int irq, void *dev_id)
89104
dev_dbg(pci->dev, "Link up\n");
90105
} else if (val & PEX_PF0_PME_MES_DR_LDD) {
91106
dev_dbg(pci->dev, "Link down\n");
107+
pci_epc_linkdown(pci->ep.epc);
92108
} else if (val & PEX_PF0_PME_MES_DR_HRD) {
93109
dev_dbg(pci->dev, "Hot reset\n");
94110
}
@@ -215,6 +231,7 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev)
215231
struct ls_pcie_ep *pcie;
216232
struct pci_epc_features *ls_epc;
217233
struct resource *dbi_base;
234+
u8 offset;
218235
int ret;
219236

220237
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
@@ -251,6 +268,9 @@ static int __init ls_pcie_ep_probe(struct platform_device *pdev)
251268

252269
platform_set_drvdata(pdev, pcie);
253270

271+
offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
272+
pcie->lnkcap = dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCAP);
273+
254274
ret = dw_pcie_ep_init(&pci->ep);
255275
if (ret)
256276
return ret;

0 commit comments

Comments
 (0)