Skip to content

Commit a152a90

Browse files
Richard ZhuMani-Sadhasivam
authored andcommitted
PCI: imx6: Clear CLKREQ# override if 'supports-clkreq' DT property is available
CLKREQ# is an optional reference clock request signal defined by the PCIe CEM and M.2 specifications to request REFCLK and exit the L1 Substates. The imx6 controller driver so far forced the CLKREQ# signal to low by enabling the CLKREQ# override logic as the slots do not expose this signal. Now, there are board designs coming up exposing this signal to the endpoint devices. This is identified using the 'supports-clkreq' DT property in the controller node. So when the DT node has this property, clear the CLKREQ# override after link up in host_post_init() callback to allow the endpoint to drive the CLKREQ# signal. Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com> [mani: squashed the imx8mm_pcie_clkreq_override helper patch & reworded description] Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
1 parent 27a064a commit a152a90

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ struct imx_pcie_drvdata {
138138
int (*enable_ref_clk)(struct imx_pcie *pcie, bool enable);
139139
int (*core_reset)(struct imx_pcie *pcie, bool assert);
140140
int (*wait_pll_lock)(struct imx_pcie *pcie);
141+
void (*clr_clkreq_override)(struct imx_pcie *pcie);
141142
const struct dw_pcie_host_ops *ops;
142143
};
143144

@@ -151,6 +152,7 @@ struct imx_pcie {
151152
struct gpio_desc *reset_gpiod;
152153
struct clk_bulk_data *clks;
153154
int num_clks;
155+
bool supports_clkreq;
154156
bool enable_ext_refclk;
155157
struct regmap *iomuxc_gpr;
156158
u16 msi_ctrl;
@@ -689,7 +691,7 @@ static int imx6q_pcie_enable_ref_clk(struct imx_pcie *imx_pcie, bool enable)
689691
return 0;
690692
}
691693

692-
static int imx8mm_pcie_enable_ref_clk(struct imx_pcie *imx_pcie, bool enable)
694+
static void imx8mm_pcie_clkreq_override(struct imx_pcie *imx_pcie, bool enable)
693695
{
694696
int offset = imx_pcie_grp_offset(imx_pcie);
695697

@@ -699,6 +701,11 @@ static int imx8mm_pcie_enable_ref_clk(struct imx_pcie *imx_pcie, bool enable)
699701
regmap_update_bits(imx_pcie->iomuxc_gpr, offset,
700702
IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE_EN,
701703
enable ? IMX8MQ_GPR_PCIE_CLK_REQ_OVERRIDE_EN : 0);
704+
}
705+
706+
static int imx8mm_pcie_enable_ref_clk(struct imx_pcie *imx_pcie, bool enable)
707+
{
708+
imx8mm_pcie_clkreq_override(imx_pcie, enable);
702709
return 0;
703710
}
704711

@@ -726,6 +733,16 @@ static int imx95_pcie_enable_ref_clk(struct imx_pcie *imx_pcie, bool enable)
726733
return 0;
727734
}
728735

736+
static void imx8mm_pcie_clr_clkreq_override(struct imx_pcie *imx_pcie)
737+
{
738+
imx8mm_pcie_clkreq_override(imx_pcie, false);
739+
}
740+
741+
static void imx95_pcie_clr_clkreq_override(struct imx_pcie *imx_pcie)
742+
{
743+
imx95_pcie_clkreq_override(imx_pcie, false);
744+
}
745+
729746
static int imx_pcie_clk_enable(struct imx_pcie *imx_pcie)
730747
{
731748
struct dw_pcie *pci = imx_pcie->pci;
@@ -1342,6 +1359,12 @@ static void imx_pcie_host_post_init(struct dw_pcie_rp *pp)
13421359
dw_pcie_writel_dbi(pci, GEN3_RELATED_OFF, val);
13431360
dw_pcie_dbi_ro_wr_dis(pci);
13441361
}
1362+
1363+
/* Clear CLKREQ# override if supports_clkreq is true and link is up */
1364+
if (dw_pcie_link_up(pci) && imx_pcie->supports_clkreq) {
1365+
if (imx_pcie->drvdata->clr_clkreq_override)
1366+
imx_pcie->drvdata->clr_clkreq_override(imx_pcie);
1367+
}
13451368
}
13461369

13471370
/*
@@ -1763,6 +1786,7 @@ static int imx_pcie_probe(struct platform_device *pdev)
17631786
/* Limit link speed */
17641787
pci->max_link_speed = 1;
17651788
of_property_read_u32(node, "fsl,max-link-speed", &pci->max_link_speed);
1789+
imx_pcie->supports_clkreq = of_property_read_bool(node, "supports-clkreq");
17661790

17671791
ret = devm_regulator_get_enable_optional(&pdev->dev, "vpcie3v3aux");
17681792
if (ret < 0 && ret != -ENODEV)
@@ -1896,6 +1920,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
18961920
.mode_mask[1] = IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE,
18971921
.init_phy = imx8mq_pcie_init_phy,
18981922
.enable_ref_clk = imx8mm_pcie_enable_ref_clk,
1923+
.clr_clkreq_override = imx8mm_pcie_clr_clkreq_override,
18991924
},
19001925
[IMX8MM] = {
19011926
.variant = IMX8MM,
@@ -1906,6 +1931,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
19061931
.mode_off[0] = IOMUXC_GPR12,
19071932
.mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE,
19081933
.enable_ref_clk = imx8mm_pcie_enable_ref_clk,
1934+
.clr_clkreq_override = imx8mm_pcie_clr_clkreq_override,
19091935
},
19101936
[IMX8MP] = {
19111937
.variant = IMX8MP,
@@ -1916,6 +1942,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
19161942
.mode_off[0] = IOMUXC_GPR12,
19171943
.mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE,
19181944
.enable_ref_clk = imx8mm_pcie_enable_ref_clk,
1945+
.clr_clkreq_override = imx8mm_pcie_clr_clkreq_override,
19191946
},
19201947
[IMX8Q] = {
19211948
.variant = IMX8Q,
@@ -1937,6 +1964,7 @@ static const struct imx_pcie_drvdata drvdata[] = {
19371964
.init_phy = imx95_pcie_init_phy,
19381965
.wait_pll_lock = imx95_pcie_wait_for_phy_pll_lock,
19391966
.enable_ref_clk = imx95_pcie_enable_ref_clk,
1967+
.clr_clkreq_override = imx95_pcie_clr_clkreq_override,
19401968
},
19411969
[IMX8MQ_EP] = {
19421970
.variant = IMX8MQ_EP,

0 commit comments

Comments
 (0)