Skip to content

Commit 1372509

Browse files
Richard Zhubjorn-helgaas
authored andcommitted
PCI: imx6: Add Refclk for i.MX95 PCIe
Add "ref" clock to enable Refclk. To avoid breaking DT backwards compatibility, the i.MX95 "ref" clock is optional. Use devm_clk_get_optional() to fetch i.MX95 PCIe optional clocks in driver. If using external clock, "ref" clock should point to external reference. If using internal clock, CREF_EN in LAST_TO_REG controls reference output, implemented in drivers/clk/imx/clk-imx95-blk-ctl.c. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Richard Zhu <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Frank Li <[email protected]>
1 parent d462740 commit 1372509

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ struct imx_pcie_drvdata {
104104
const char *gpr;
105105
const char * const *clk_names;
106106
const u32 clks_cnt;
107+
const u32 clks_optional_cnt;
107108
const u32 ltssm_off;
108109
const u32 ltssm_mask;
109110
const u32 mode_off[IMX_PCIE_MAX_INSTANCES];
@@ -1322,9 +1323,8 @@ static int imx_pcie_probe(struct platform_device *pdev)
13221323
struct device_node *np;
13231324
struct resource *dbi_base;
13241325
struct device_node *node = dev->of_node;
1325-
int ret;
1326+
int i, ret, req_cnt;
13261327
u16 val;
1327-
int i;
13281328

13291329
imx_pcie = devm_kzalloc(dev, sizeof(*imx_pcie), GFP_KERNEL);
13301330
if (!imx_pcie)
@@ -1374,9 +1374,13 @@ static int imx_pcie_probe(struct platform_device *pdev)
13741374
imx_pcie->clks[i].id = imx_pcie->drvdata->clk_names[i];
13751375

13761376
/* Fetch clocks */
1377-
ret = devm_clk_bulk_get(dev, imx_pcie->drvdata->clks_cnt, imx_pcie->clks);
1377+
req_cnt = imx_pcie->drvdata->clks_cnt - imx_pcie->drvdata->clks_optional_cnt;
1378+
ret = devm_clk_bulk_get(dev, req_cnt, imx_pcie->clks);
13781379
if (ret)
13791380
return ret;
1381+
imx_pcie->clks[req_cnt].clk = devm_clk_get_optional(dev, "ref");
1382+
if (IS_ERR(imx_pcie->clks[req_cnt].clk))
1383+
return PTR_ERR(imx_pcie->clks[req_cnt].clk);
13801384

13811385
if (imx_check_flag(imx_pcie, IMX_PCIE_FLAG_HAS_PHYDRV)) {
13821386
imx_pcie->phy = devm_phy_get(dev, "pcie-phy");
@@ -1524,6 +1528,7 @@ static const char * const imx8mm_clks[] = {"pcie_bus", "pcie", "pcie_aux"};
15241528
static const char * const imx8mq_clks[] = {"pcie_bus", "pcie", "pcie_phy", "pcie_aux"};
15251529
static const char * const imx6sx_clks[] = {"pcie_bus", "pcie", "pcie_phy", "pcie_inbound_axi"};
15261530
static const char * const imx8q_clks[] = {"mstr", "slv", "dbi"};
1531+
static const char * const imx95_clks[] = {"pcie_bus", "pcie", "pcie_phy", "pcie_aux", "ref"};
15271532

15281533
static const struct imx_pcie_drvdata drvdata[] = {
15291534
[IMX6Q] = {
@@ -1639,8 +1644,9 @@ static const struct imx_pcie_drvdata drvdata[] = {
16391644
[IMX95] = {
16401645
.variant = IMX95,
16411646
.flags = IMX_PCIE_FLAG_HAS_SERDES,
1642-
.clk_names = imx8mq_clks,
1643-
.clks_cnt = ARRAY_SIZE(imx8mq_clks),
1647+
.clk_names = imx95_clks,
1648+
.clks_cnt = ARRAY_SIZE(imx95_clks),
1649+
.clks_optional_cnt = 1,
16441650
.ltssm_off = IMX95_PE0_GEN_CTRL_3,
16451651
.ltssm_mask = IMX95_PCIE_LTSSM_EN,
16461652
.mode_off[0] = IMX95_PE0_GEN_CTRL_1,

0 commit comments

Comments
 (0)