From: Xu Yang <xu.yang_2@nxp.com>
To: vkoul@kernel.org, kishon@kernel.org, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, shawnguo@kernel.org,
s.hauer@pengutronix.de, kernel@pengutronix.de,
festevam@gmail.com
Cc: jun.li@nxp.com, alexander.stein@ew.tq-group.com,
linux-phy@lists.infradead.org, devicetree@vger.kernel.org,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] phy: fsl-imx8mq-usb: improve some tuning parameters and support i.MX95 tuning
Date: Wed, 23 Apr 2025 17:46:07 +0800 [thread overview]
Message-ID: <20250423094607.1029429-2-xu.yang_2@nxp.com> (raw)
In-Reply-To: <20250423094607.1029429-1-xu.yang_2@nxp.com>
Since device tree support negative number, this will improve some
parameter parsing functions to handle negative number. Because i.MX8MP
and i.MX95 USB3 PHY have different tuning parameter for same tuning
field, this will add i.MX95 tuning functions too.
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
drivers/phy/freescale/phy-fsl-imx8mq-usb.c | 94 ++++++++++++++++------
1 file changed, 68 insertions(+), 26 deletions(-)
diff --git a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
index a974ef94de9a..59b9b4704b03 100644
--- a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
+++ b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
@@ -113,11 +113,11 @@ struct imx8mq_usb_phy {
struct tca_blk *tca;
u32 pcs_tx_swing_full;
u32 pcs_tx_deemph_3p5db;
- u32 tx_vref_tune;
- u32 tx_rise_tune;
+ s32 tx_vref_tune;
+ s32 tx_rise_tune;
u32 tx_preemp_amp_tune;
u32 tx_vboost_level;
- u32 comp_dis_tune;
+ s32 comp_dis_tune;
};
@@ -286,24 +286,45 @@ static void imx95_usb_phy_put_tca(struct imx8mq_usb_phy *imx_phy)
tca_blk_put_typec_switch(tca->sw);
}
-static u32 phy_tx_vref_tune_from_property(u32 percent)
+static u32 phy_tx_vref_tune_from_property(s32 percent)
{
- percent = clamp(percent, 94U, 124U);
+ percent = clamp(percent, -6, 24);
- return DIV_ROUND_CLOSEST(percent - 94U, 2);
+ return DIV_ROUND_CLOSEST(percent + 6, 2);
}
-static u32 phy_tx_rise_tune_from_property(u32 percent)
+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) {
- case 0 ... 98:
+ case -3:
return 3;
- case 99:
+ case -1:
return 2;
- case 100 ... 101:
- return 1;
+ case 3:
+ return 0;
default:
+ return 1;
+ }
+}
+
+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;
}
}
@@ -317,12 +338,12 @@ static u32 phy_tx_preemp_amp_tune_from_property(u32 microamp)
static u32 phy_tx_vboost_level_from_property(u32 microvolt)
{
switch (microvolt) {
- case 0 ... 960:
- return 0;
- case 961 ... 1160:
- return 2;
- default:
+ case 1156:
+ return 5;
+ case 844:
return 3;
+ default:
+ return 4;
}
}
@@ -331,27 +352,35 @@ static u32 phy_pcs_tx_deemph_3p5db_from_property(u32 decibel)
return min(decibel, 36U);
}
-static u32 phy_comp_dis_tune_from_property(u32 percent)
+static u32 phy_comp_dis_tune_from_property(s32 percent)
{
switch (percent) {
- case 0 ... 92:
+ case -9:
return 0;
- case 93 ... 95:
+ case -6:
return 1;
- case 96 ... 97:
+ case -3:
return 2;
- case 98 ... 102:
- return 3;
- case 103 ... 105:
+ case 4:
return 4;
- case 106 ... 109:
+ case 7:
return 5;
- case 110 ... 113:
+ case 11:
return 6;
- default:
+ case 15:
return 7;
+ default:
+ return 3;
}
}
+
+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);
@@ -362,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);
@@ -373,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);
@@ -394,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
next prev parent reply other threads:[~2025-04-23 9:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-23 9:46 [PATCH 1/2] dt-bindings: phy: imx8mq-usb: improve some tuning properties Xu Yang
2025-04-23 9:46 ` Xu Yang [this message]
2025-04-28 7:59 ` Krzysztof Kozlowski
2025-04-28 8:20 ` Xu Yang
2025-04-29 7:33 ` Krzysztof Kozlowski
2025-04-29 9:27 ` Xu Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250423094607.1029429-2-xu.yang_2@nxp.com \
--to=xu.yang_2@nxp.com \
--cc=alexander.stein@ew.tq-group.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=jun.li@nxp.com \
--cc=kernel@pengutronix.de \
--cc=kishon@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-phy@lists.infradead.org \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox