003-6.3-phy-freescale-imx8m-pcie-Add-i.MX8MP-PCIe-PHY-suppor.patch 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. From bf03b9281b119bcdc167b2dd6ac98294587eb5ff Mon Sep 17 00:00:00 2001
  2. From: Richard Zhu <[email protected]>
  3. Date: Thu, 13 Oct 2022 09:47:02 +0800
  4. Subject: [PATCH 3/3] phy: freescale: imx8m-pcie: Add i.MX8MP PCIe PHY support
  5. Add i.MX8MP PCIe PHY support.
  6. Signed-off-by: Richard Zhu <[email protected]>
  7. Signed-off-by: Lucas Stach <[email protected]>
  8. Tested-by: Marek Vasut <[email protected]>
  9. Tested-by: Richard Leitner <[email protected]>
  10. Tested-by: Alexander Stein <[email protected]>
  11. Reviewed-by: Lucas Stach <[email protected]>
  12. Reviewed-by: Ahmad Fatoum <[email protected]>
  13. ---
  14. drivers/phy/freescale/phy-fsl-imx8m-pcie.c | 25 ++++++++++++++++++++--
  15. 1 file changed, 23 insertions(+), 2 deletions(-)
  16. --- a/drivers/phy/freescale/phy-fsl-imx8m-pcie.c
  17. +++ b/drivers/phy/freescale/phy-fsl-imx8m-pcie.c
  18. @@ -48,6 +48,7 @@
  19. enum imx8_pcie_phy_type {
  20. IMX8MM,
  21. + IMX8MP,
  22. };
  23. struct imx8_pcie_phy_drvdata {
  24. @@ -60,6 +61,7 @@ struct imx8_pcie_phy {
  25. struct clk *clk;
  26. struct phy *phy;
  27. struct regmap *iomuxc_gpr;
  28. + struct reset_control *perst;
  29. struct reset_control *reset;
  30. u32 refclk_pad_mode;
  31. u32 tx_deemph_gen1;
  32. @@ -74,11 +76,11 @@ static int imx8_pcie_phy_power_on(struct
  33. u32 val, pad_mode;
  34. struct imx8_pcie_phy *imx8_phy = phy_get_drvdata(phy);
  35. - reset_control_assert(imx8_phy->reset);
  36. -
  37. pad_mode = imx8_phy->refclk_pad_mode;
  38. switch (imx8_phy->drvdata->variant) {
  39. case IMX8MM:
  40. + reset_control_assert(imx8_phy->reset);
  41. +
  42. /* Tune PHY de-emphasis setting to pass PCIe compliance. */
  43. if (imx8_phy->tx_deemph_gen1)
  44. writel(imx8_phy->tx_deemph_gen1,
  45. @@ -87,6 +89,8 @@ static int imx8_pcie_phy_power_on(struct
  46. writel(imx8_phy->tx_deemph_gen2,
  47. imx8_phy->base + PCIE_PHY_TRSV_REG6);
  48. break;
  49. + case IMX8MP: /* Do nothing. */
  50. + break;
  51. }
  52. if (pad_mode == IMX8_PCIE_REFCLK_PAD_INPUT ||
  53. @@ -141,6 +145,9 @@ static int imx8_pcie_phy_power_on(struct
  54. IMX8MM_GPR_PCIE_CMN_RST);
  55. switch (imx8_phy->drvdata->variant) {
  56. + case IMX8MP:
  57. + reset_control_deassert(imx8_phy->perst);
  58. + fallthrough;
  59. case IMX8MM:
  60. reset_control_deassert(imx8_phy->reset);
  61. usleep_range(200, 500);
  62. @@ -181,8 +188,14 @@ static const struct imx8_pcie_phy_drvdat
  63. .variant = IMX8MM,
  64. };
  65. +static const struct imx8_pcie_phy_drvdata imx8mp_drvdata = {
  66. + .gpr = "fsl,imx8mp-iomuxc-gpr",
  67. + .variant = IMX8MP,
  68. +};
  69. +
  70. static const struct of_device_id imx8_pcie_phy_of_match[] = {
  71. {.compatible = "fsl,imx8mm-pcie-phy", .data = &imx8mm_drvdata, },
  72. + {.compatible = "fsl,imx8mp-pcie-phy", .data = &imx8mp_drvdata, },
  73. { },
  74. };
  75. MODULE_DEVICE_TABLE(of, imx8_pcie_phy_of_match);
  76. @@ -238,6 +251,14 @@ static int imx8_pcie_phy_probe(struct pl
  77. return PTR_ERR(imx8_phy->reset);
  78. }
  79. + if (imx8_phy->drvdata->variant == IMX8MP) {
  80. + imx8_phy->perst =
  81. + devm_reset_control_get_exclusive(dev, "perst");
  82. + if (IS_ERR(imx8_phy->perst))
  83. + dev_err_probe(dev, PTR_ERR(imx8_phy->perst),
  84. + "Failed to get PCIE PHY PERST control\n");
  85. + }
  86. +
  87. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  88. imx8_phy->base = devm_ioremap_resource(dev, res);
  89. if (IS_ERR(imx8_phy->base))