Skip to content

Commit 047e8b6

Browse files
Richard ZhuMani-Sadhasivam
authored andcommitted
PCI: imx6: Add PLL lock check for i.MX95 SoC
PLL lock is required to ensure that the PLL clock is stable before enabling the controller in i.MX95 SoC. Signed-off-by: Richard Zhu <[email protected]> [mani: subject and description rewording] Signed-off-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Frank Li <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 744a1c2 commit 047e8b6

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

drivers/pci/controller/dwc/pci-imx6.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
#define IMX95_PCIE_PHY_GEN_CTRL 0x0
4646
#define IMX95_PCIE_REF_USE_PAD BIT(17)
4747

48+
#define IMX95_PCIE_PHY_MPLLA_CTRL 0x10
49+
#define IMX95_PCIE_PHY_MPLL_STATE BIT(30)
50+
4851
#define IMX95_PCIE_SS_RW_REG_0 0xf0
4952
#define IMX95_PCIE_REF_CLKEN BIT(23)
5053
#define IMX95_PCIE_PHY_CR_PARA_SEL BIT(9)
@@ -132,6 +135,7 @@ struct imx_pcie_drvdata {
132135
int (*init_phy)(struct imx_pcie *pcie);
133136
int (*enable_ref_clk)(struct imx_pcie *pcie, bool enable);
134137
int (*core_reset)(struct imx_pcie *pcie, bool assert);
138+
int (*wait_pll_lock)(struct imx_pcie *pcie);
135139
const struct dw_pcie_host_ops *ops;
136140
};
137141

@@ -479,6 +483,23 @@ static void imx7d_pcie_wait_for_phy_pll_lock(struct imx_pcie *imx_pcie)
479483
dev_err(dev, "PCIe PLL lock timeout\n");
480484
}
481485

486+
static int imx95_pcie_wait_for_phy_pll_lock(struct imx_pcie *imx_pcie)
487+
{
488+
u32 val;
489+
struct device *dev = imx_pcie->pci->dev;
490+
491+
if (regmap_read_poll_timeout(imx_pcie->iomuxc_gpr,
492+
IMX95_PCIE_PHY_MPLLA_CTRL, val,
493+
val & IMX95_PCIE_PHY_MPLL_STATE,
494+
PHY_PLL_LOCK_WAIT_USLEEP_MAX,
495+
PHY_PLL_LOCK_WAIT_TIMEOUT)) {
496+
dev_err(dev, "PCIe PLL lock timeout\n");
497+
return -ETIMEDOUT;
498+
}
499+
500+
return 0;
501+
}
502+
482503
static int imx_setup_phy_mpll(struct imx_pcie *imx_pcie)
483504
{
484505
unsigned long phy_rate = 0;
@@ -1225,6 +1246,12 @@ static int imx_pcie_host_init(struct dw_pcie_rp *pp)
12251246
goto err_phy_off;
12261247
}
12271248

1249+
if (imx_pcie->drvdata->wait_pll_lock) {
1250+
ret = imx_pcie->drvdata->wait_pll_lock(imx_pcie);
1251+
if (ret < 0)
1252+
goto err_phy_off;
1253+
}
1254+
12281255
imx_setup_phy_mpll(imx_pcie);
12291256

12301257
return 0;
@@ -1826,6 +1853,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
18261853
.mode_mask[0] = IMX95_PCIE_DEVICE_TYPE,
18271854
.core_reset = imx95_pcie_core_reset,
18281855
.init_phy = imx95_pcie_init_phy,
1856+
.wait_pll_lock = imx95_pcie_wait_for_phy_pll_lock,
18291857
},
18301858
[IMX8MQ_EP] = {
18311859
.variant = IMX8MQ_EP,
@@ -1880,6 +1908,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
18801908
.mode_mask[0] = IMX95_PCIE_DEVICE_TYPE,
18811909
.init_phy = imx95_pcie_init_phy,
18821910
.core_reset = imx95_pcie_core_reset,
1911+
.wait_pll_lock = imx95_pcie_wait_for_phy_pll_lock,
18831912
.epc_features = &imx95_pcie_epc_features,
18841913
.mode = DW_PCIE_EP_TYPE,
18851914
},

0 commit comments

Comments
 (0)