[PATCH v2 3/3] phy: fsl-imx8mq-usb: add i.MX95 tuning support

Xu Yang
2025-04-29T03:34:29Z

The i.MX8MP and i.MX95 USB3 PHY have different tuning parameter for same
tuning field, this will add i.MX95 tuning support.

Signed-off-by: Xu Yang <xu.yang_2@nxp.com>

---
Changes in v2:
- new patch
---
drivers/phy/freescale/phy-fsl-imx8mq-usb.c | 41 ++++++++++++++++++++++
1 file changed, 41 insertions(+)

diff --git a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
index 6c564b608539..59b9b4704b03 100644
--- a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
+++ b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
@@ -293,6 +293,13 @@ static u32 phy_tx_vref_tune_from_property(s32 percent)
return DIV_ROUND_CLOSEST(percent + 6, 2);
}

+static u32 imx95_phy_tx_vref_tune_from_property(s32 percent)
+{
+ percent = clamp(percent, -1000, 875);
+
+ return DIV_ROUND_CLOSEST(percent + 1000, 125);
+}
+
static u32 phy_tx_rise_tune_from_property(s32 percent)
{
switch (percent) {
@@ -307,6 +314,20 @@ static u32 phy_tx_rise_tune_from_property(s32 percent)
}
}

+static u32 imx95_phy_tx_rise_tune_from_property(s32 percent)
+{
+ switch (percent) {
+ case -10:
+ return 3;
+ case 15:
+ return 1;
+ case 20:
+ return 0;
+ default:
+ return 2;
+ }
+}
+
static u32 phy_tx_preemp_amp_tune_from_property(u32 microamp)
{
microamp = min(microamp, 1800U);
@@ -353,6 +374,13 @@ static u32 phy_comp_dis_tune_from_property(s32 percent)
}
}

+static u32 imx95_phy_comp_dis_tune_from_property(s32 percent)
+{
+ percent = clamp(percent, -60, 45);
+
+ return DIV_ROUND_CLOSEST(percent + 60, 15);
+}
+
static u32 phy_pcs_tx_swing_full_from_property(u32 percent)
{
percent = min(percent, 100U);
@@ -363,10 +391,17 @@ static u32 phy_pcs_tx_swing_full_from_property(u32 percent)
static void imx8m_get_phy_tuning_data(struct imx8mq_usb_phy *imx_phy)
{
struct device *dev = imx_phy->phy->dev.parent;
+ bool is_imx95 = false;
+
+ if (device_is_compatible(dev, "fsl,imx95-usb-phy"))
+ is_imx95 = true;

if (device_property_read_u32(dev, "fsl,phy-tx-vref-tune-percent",
&imx_phy->tx_vref_tune))
imx_phy->tx_vref_tune = PHY_TUNE_DEFAULT;
+ else if (is_imx95)
+ imx_phy->tx_vref_tune =
+ imx95_phy_tx_vref_tune_from_property(imx_phy->tx_vref_tune);
else
imx_phy->tx_vref_tune =
phy_tx_vref_tune_from_property(imx_phy->tx_vref_tune);
@@ -374,6 +409,9 @@ static void imx8m_get_phy_tuning_data(struct imx8mq_usb_phy *imx_phy)
if (device_property_read_u32(dev, "fsl,phy-tx-rise-tune-percent",
&imx_phy->tx_rise_tune))
imx_phy->tx_rise_tune = PHY_TUNE_DEFAULT;
+ else if (is_imx95)
+ imx_phy->tx_rise_tune =
+ imx95_phy_tx_rise_tune_from_property(imx_phy->tx_rise_tune);
else
imx_phy->tx_rise_tune =
phy_tx_rise_tune_from_property(imx_phy->tx_rise_tune);
@@ -395,6 +433,9 @@ static void imx8m_get_phy_tuning_data(struct imx8mq_usb_phy *imx_phy)
if (device_property_read_u32(dev, "fsl,phy-comp-dis-tune-percent",
&imx_phy->comp_dis_tune))
imx_phy->comp_dis_tune = PHY_TUNE_DEFAULT;
+ else if (is_imx95)
+ imx_phy->comp_dis_tune =
+ imx95_phy_comp_dis_tune_from_property(imx_phy->comp_dis_tune);
else
imx_phy->comp_dis_tune =
phy_comp_dis_tune_from_property(imx_phy->comp_dis_tune);
--
2.34.1