Skip to content

Commit 8026f2d

Browse files
nxpfranklikwilczynski
authored andcommitted
PCI: imx6: Call common PHY API to set mode, speed, and submode
Invoke the common PHY API to configure mode, speed, and submode. While these functions are optional in the PHY interface, they are necessary for certain PHY drivers. Lack of support for these functions in a PHY driver does not cause harm. Link: https://lore.kernel.org/linux-pci/[email protected] Signed-off-by: Frank Li <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]>
1 parent 4f1e478 commit 8026f2d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/types.h>
2929
#include <linux/interrupt.h>
3030
#include <linux/reset.h>
31+
#include <linux/phy/pcie.h>
3132
#include <linux/phy/phy.h>
3233
#include <linux/pm_domain.h>
3334
#include <linux/pm_runtime.h>
@@ -226,6 +227,10 @@ static void imx_pcie_configure_type(struct imx_pcie *imx_pcie)
226227

227228
id = imx_pcie->controller_id;
228229

230+
/* If mode_mask is 0, then generic PHY driver is used to set the mode */
231+
if (!drvdata->mode_mask[0])
232+
return;
233+
229234
/* If mode_mask[id] is zero, means each controller have its individual gpr */
230235
if (!drvdata->mode_mask[id])
231236
id = 0;
@@ -801,7 +806,11 @@ static void imx_pcie_ltssm_enable(struct device *dev)
801806
{
802807
struct imx_pcie *imx_pcie = dev_get_drvdata(dev);
803808
const struct imx_pcie_drvdata *drvdata = imx_pcie->drvdata;
809+
u8 offset = dw_pcie_find_capability(imx_pcie->pci, PCI_CAP_ID_EXP);
810+
u32 tmp;
804811

812+
tmp = dw_pcie_readl_dbi(imx_pcie->pci, offset + PCI_EXP_LNKCAP);
813+
phy_set_speed(imx_pcie->phy, FIELD_GET(PCI_EXP_LNKCAP_SLS, tmp));
805814
if (drvdata->ltssm_mask)
806815
regmap_update_bits(imx_pcie->iomuxc_gpr, drvdata->ltssm_off, drvdata->ltssm_mask,
807816
drvdata->ltssm_mask);
@@ -814,6 +823,7 @@ static void imx_pcie_ltssm_disable(struct device *dev)
814823
struct imx_pcie *imx_pcie = dev_get_drvdata(dev);
815824
const struct imx_pcie_drvdata *drvdata = imx_pcie->drvdata;
816825

826+
phy_set_speed(imx_pcie->phy, 0);
817827
if (drvdata->ltssm_mask)
818828
regmap_update_bits(imx_pcie->iomuxc_gpr, drvdata->ltssm_off,
819829
drvdata->ltssm_mask, 0);
@@ -949,6 +959,12 @@ static int imx_pcie_host_init(struct dw_pcie_rp *pp)
949959
goto err_clk_disable;
950960
}
951961

962+
ret = phy_set_mode_ext(imx_pcie->phy, PHY_MODE_PCIE, PHY_MODE_PCIE_RC);
963+
if (ret) {
964+
dev_err(dev, "unable to set PCIe PHY mode\n");
965+
goto err_phy_exit;
966+
}
967+
952968
ret = phy_power_on(imx_pcie->phy);
953969
if (ret) {
954970
dev_err(dev, "waiting for PHY ready timeout!\n");

0 commit comments

Comments
 (0)