@@ -21,6 +21,7 @@
/**
* struct cdns_pcie_ep - private data for this PCIe endpoint controller driver
* @pcie: Cadence PCIe controller
+ * @dev: pointer to PCIe EP device
* @max_regions: maximum number of regions supported by hardware
* @ob_region_map: bitmask of mapped outbound regions
* @ob_addr: base addresses in the AXI bus where the outbound regions start
@@ -37,6 +38,7 @@
*/
struct cdns_pcie_ep {
struct cdns_pcie pcie;
+ struct device *dev;
u32 max_regions;
unsigned long ob_region_map;
phys_addr_t *ob_addr;
@@ -386,6 +388,7 @@ static int cdns_pcie_ep_start(struct pci_epc *epc)
struct cdns_pcie_ep *ep = epc_get_drvdata(epc);
struct cdns_pcie *pcie = &ep->pcie;
struct pci_epf *epf;
+ int ret = 0;
u32 cfg;
/*
@@ -397,7 +400,11 @@ static int cdns_pcie_ep_start(struct pci_epc *epc)
cfg |= BIT(epf->func_no);
cdns_pcie_writel(pcie, CDNS_PCIE_LM_EP_FUNC_CFG, cfg);
- return 0;
+ ret = cdns_pcie_start_link(pcie, true);
+ if (ret)
+ dev_err(ep->dev, "Failed to start link\n");
+
+ return ret;
}
static const struct pci_epc_features cdns_pcie_epc_features = {
@@ -460,6 +467,8 @@ static int cdns_pcie_ep_probe(struct platform_device *pdev)
if (!ep)
return -ENOMEM;
+ ep->dev = dev;
+
pcie = &ep->pcie;
pcie->is_rc = false;
pcie->plat_data = pdev->dev.platform_data;
@@ -365,6 +365,14 @@ static int cdns_pcie_host_probe(struct platform_device *pdev)
goto err_get_sync;
}
+ ret = cdns_pcie_start_link(pcie, true);
+ if (ret) {
+ dev_err(dev, "Failed to start link\n");
+ goto err_start_link;
+ }
+
+ cdns_pcie_wait_for_link(dev, pcie);
+
ret = cdns_pcie_host_init(dev, &resources, rc);
if (ret)
goto err_init;
@@ -386,6 +394,9 @@ static int cdns_pcie_host_probe(struct platform_device *pdev)
pci_free_resource_list(&resources);
err_init:
+ cdns_pcie_start_link(pcie, false);
+
+ err_start_link:
pm_runtime_put_sync(dev);
err_get_sync:
Use cdns_pcie_start_link() to start link training and cdns_pcie_wait_for_link() in order to wait to establish the link. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> --- drivers/pci/controller/pcie-cadence-ep.c | 11 ++++++++++- drivers/pci/controller/pcie-cadence-host.c | 11 +++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) -- 2.17.1