All of lore.kernel.org
 help / color / mirror / Atom feed
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 v2 2/3] phy: fsl-imx8mq-usb: improve some tuning parameters
Date: Tue, 29 Apr 2025 11:30:08 +0800	[thread overview]
Message-ID: <20250429033009.2388291-2-xu.yang_2@nxp.com> (raw)
In-Reply-To: <20250429033009.2388291-1-xu.yang_2@nxp.com>

Since device tree support negative number, this will improve some
parameter parsing functions to handle negative number which is
corresponding to the original value of register description.

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

---
Changes in v2:
 - split out imx95 part to another patch
---
 drivers/phy/freescale/phy-fsl-imx8mq-usb.c | 55 +++++++++++-----------
 1 file changed, 28 insertions(+), 27 deletions(-)

diff --git a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
index a974ef94de9a..6c564b608539 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,24 @@ 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 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;
-	default:
+	case 3:
 		return 0;
+	default:
+		return 1;
 	}
 }
 
@@ -317,12 +317,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 +331,28 @@ 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 phy_pcs_tx_swing_full_from_property(u32 percent)
 {
 	percent = min(percent, 100U);
-- 
2.34.1


WARNING: multiple messages have this Message-ID (diff)
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 v2 2/3] phy: fsl-imx8mq-usb: improve some tuning parameters
Date: Tue, 29 Apr 2025 11:30:08 +0800	[thread overview]
Message-ID: <20250429033009.2388291-2-xu.yang_2@nxp.com> (raw)
In-Reply-To: <20250429033009.2388291-1-xu.yang_2@nxp.com>

Since device tree support negative number, this will improve some
parameter parsing functions to handle negative number which is
corresponding to the original value of register description.

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

---
Changes in v2:
 - split out imx95 part to another patch
---
 drivers/phy/freescale/phy-fsl-imx8mq-usb.c | 55 +++++++++++-----------
 1 file changed, 28 insertions(+), 27 deletions(-)

diff --git a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
index a974ef94de9a..6c564b608539 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,24 @@ 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 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;
-	default:
+	case 3:
 		return 0;
+	default:
+		return 1;
 	}
 }
 
@@ -317,12 +317,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 +331,28 @@ 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 phy_pcs_tx_swing_full_from_property(u32 percent)
 {
 	percent = min(percent, 100U);
-- 
2.34.1


-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2025-04-29  3:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-29  3:30 [PATCH v2 1/3] dt-bindings: phy: imx8mq-usb: improve some tuning properties Xu Yang
2025-04-29  3:30 ` Xu Yang
2025-04-29  3:30 ` Xu Yang [this message]
2025-04-29  3:30   ` [PATCH v2 2/3] phy: fsl-imx8mq-usb: improve some tuning parameters Xu Yang
2025-04-29  3:30 ` [PATCH v2 3/3] phy: fsl-imx8mq-usb: add i.MX95 tuning support Xu Yang
2025-04-29  3:30   ` Xu Yang
2025-04-29  5:55 ` [PATCH v2 1/3] dt-bindings: phy: imx8mq-usb: improve some tuning properties Frank Li
2025-04-29  5:55   ` Frank Li
2025-04-29  6:26   ` Xu Yang
2025-04-29  6:26     ` Xu Yang
2025-04-29 12:10     ` Frank Li
2025-04-29 12:10       ` Frank Li
2025-04-29  9:30 ` Xu Yang
2025-04-29  9:30   ` Xu Yang
2025-04-29 13:10 ` Krzysztof Kozlowski
2025-04-29 13:10   ` Krzysztof Kozlowski
2025-04-29 15:10 ` Conor Dooley
2025-04-29 15:10   ` Conor Dooley
2025-04-30  5:57   ` Xu Yang
2025-04-30  5:57     ` 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=20250429033009.2388291-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.