Skip to content

Commit d8574ce

Browse files
Richard ZhuMani-Sadhasivam
authored andcommitted
PCI: imx6: Add external reference clock input mode support
i.MX95 PCIes have two reference clock inputs: one from internal PLL, the other from off chip crystal oscillator. The "extref" clock refers to a reference clock from an external crystal oscillator. Add external reference clock input mode support for i.MX95 PCIes. Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://patch.msgid.link/20251211064821.2707001-4-hongxing.zhu@nxp.com
1 parent 1352f58 commit d8574ce

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ struct imx_pcie {
149149
struct gpio_desc *reset_gpiod;
150150
struct clk_bulk_data *clks;
151151
int num_clks;
152+
bool enable_ext_refclk;
152153
struct regmap *iomuxc_gpr;
153154
u16 msi_ctrl;
154155
u32 controller_id;
@@ -241,6 +242,8 @@ static unsigned int imx_pcie_grp_offset(const struct imx_pcie *imx_pcie)
241242

242243
static int imx95_pcie_init_phy(struct imx_pcie *imx_pcie)
243244
{
245+
bool ext = imx_pcie->enable_ext_refclk;
246+
244247
/*
245248
* ERR051624: The Controller Without Vaux Cannot Exit L23 Ready
246249
* Through Beacon or PERST# De-assertion
@@ -259,13 +262,12 @@ static int imx95_pcie_init_phy(struct imx_pcie *imx_pcie)
259262
IMX95_PCIE_PHY_CR_PARA_SEL,
260263
IMX95_PCIE_PHY_CR_PARA_SEL);
261264

262-
regmap_update_bits(imx_pcie->iomuxc_gpr,
263-
IMX95_PCIE_PHY_GEN_CTRL,
264-
IMX95_PCIE_REF_USE_PAD, 0);
265-
regmap_update_bits(imx_pcie->iomuxc_gpr,
266-
IMX95_PCIE_SS_RW_REG_0,
265+
regmap_update_bits(imx_pcie->iomuxc_gpr, IMX95_PCIE_PHY_GEN_CTRL,
266+
ext ? IMX95_PCIE_REF_USE_PAD : 0,
267+
IMX95_PCIE_REF_USE_PAD);
268+
regmap_update_bits(imx_pcie->iomuxc_gpr, IMX95_PCIE_SS_RW_REG_0,
267269
IMX95_PCIE_REF_CLKEN,
268-
IMX95_PCIE_REF_CLKEN);
270+
ext ? 0 : IMX95_PCIE_REF_CLKEN);
269271

270272
return 0;
271273
}
@@ -1602,7 +1604,7 @@ static int imx_pcie_probe(struct platform_device *pdev)
16021604
struct imx_pcie *imx_pcie;
16031605
struct device_node *np;
16041606
struct device_node *node = dev->of_node;
1605-
int ret, domain;
1607+
int i, ret, domain;
16061608
u16 val;
16071609

16081610
imx_pcie = devm_kzalloc(dev, sizeof(*imx_pcie), GFP_KERNEL);
@@ -1653,6 +1655,9 @@ static int imx_pcie_probe(struct platform_device *pdev)
16531655
if (imx_pcie->num_clks < 0)
16541656
return dev_err_probe(dev, imx_pcie->num_clks,
16551657
"failed to get clocks\n");
1658+
for (i = 0; i < imx_pcie->num_clks; i++)
1659+
if (strncmp(imx_pcie->clks[i].id, "extref", 6) == 0)
1660+
imx_pcie->enable_ext_refclk = true;
16561661

16571662
if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_HAS_PHYDRV)) {
16581663
imx_pcie->phy = devm_phy_get(dev, "pcie-phy");

0 commit comments

Comments
 (0)