Replace the two dw_pcie_find_capability(pci, PCI_CAP_ID_EXP) calls in
imx_pcie_ltssm_enable() and imx_pcie_start_link() with
dw_pcie_get_pcie_cap().

Both functions run with the controller powered and clocked: they are
reached either from the host .start_link callback or, in Endpoint mode,
after the PERST# deassert path has enabled the resources. The helper
therefore performs the DBI read at the same point as the replaced call
and caches the result for later invocations, which is useful for
suspend/resume where the link is started again.

Signed-off-by: Hans Zhang <[email protected]>
---
 drivers/pci/controller/dwc/pci-imx6.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/dwc/pci-imx6.c 
b/drivers/pci/controller/dwc/pci-imx6.c
index 39790e66b98d..7fe9c1fa2686 100644
--- a/drivers/pci/controller/dwc/pci-imx6.c
+++ b/drivers/pci/controller/dwc/pci-imx6.c
@@ -970,7 +970,7 @@ static void imx_pcie_ltssm_enable(struct device *dev)
 {
        struct imx_pcie *imx_pcie = dev_get_drvdata(dev);
        const struct imx_pcie_drvdata *drvdata = imx_pcie->drvdata;
-       u8 offset = dw_pcie_find_capability(imx_pcie->pci, PCI_CAP_ID_EXP);
+       u8 offset = dw_pcie_get_pcie_cap(imx_pcie->pci);
        u32 tmp;
 
        tmp = dw_pcie_readl_dbi(imx_pcie->pci, offset + PCI_EXP_LNKCAP);
@@ -999,7 +999,7 @@ static int imx_pcie_start_link(struct dw_pcie *pci)
 {
        struct imx_pcie *imx_pcie = to_imx_pcie(pci);
        struct device *dev = pci->dev;
-       u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
+       u8 offset = dw_pcie_get_pcie_cap(pci);
        u32 tmp;
        int ret;
 
-- 
2.43.0


Reply via email to