Linux-PHY Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Update USB PHY fuse calibration for Tegra264
@ 2026-12-02 14:52 Jon Hunter
  2026-12-02 14:52 ` [PATCH v2 1/2] soc/tegra: fuse: Add USB fuse calibration registers " Jon Hunter
  2026-12-02 14:52 ` [PATCH v2 2/2] phy: tegra: xusb-tegra186: Extend Tegra264 fuse calibration Jon Hunter
  0 siblings, 2 replies; 5+ messages in thread
From: Jon Hunter @ 2026-12-02 14:52 UTC (permalink / raw)
  To: Thierry Reding, JC Kuo, Vinod Koul, Neil Armstrong,
	Manivannan Sadhasivam
  Cc: linux-tegra, linux-phy, Jon Hunter, Wayne Chang

This series adds additional fuse calibration for the USB PHY on
Tegra264. The first patch simply adds the definitions for the
additional fuse registers and the second patch updates the Tegra USB PHY
driver to use these registers. Given that the first patch is trivial and
there are multiple subsystems touched by this series, it is probably
simpler to merge both via the PHY subsystem with Thierry's ACK.

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
Changes in v2:
- Used 'has_rec_sq_offsets' instead of checking both
  'priv->calib.rec_os && priv->calib.sq_os' as per feedback from Mani.
- Updated change to use FIELD_ macros for handling register fields as
  per feedback from Mani.
- Link to v1: https://patch.msgid.link/20261116-tegra-phy-tegra264-v1-0-a82b8e10a553@nvidia.com

---
Wayne Chang (2):
      soc/tegra: fuse: Add USB fuse calibration registers for Tegra264
      phy: tegra: xusb-tegra186: Extend Tegra264 fuse calibration

 drivers/phy/tegra/xusb-tegra186.c | 57 +++++++++++++++++++++++++++++++++++++++
 drivers/phy/tegra/xusb.h          |  1 +
 include/soc/tegra/fuse.h          |  2 ++
 3 files changed, 60 insertions(+)
---
base-commit: d138596e9f822033490b2e577ec2ea64f2aa246c
change-id: 20261116-tegra-phy-tegra264-2bedb8d1e48f

Best regards,
--  
Jon Hunter <jonathanh@nvidia.com>


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] soc/tegra: fuse: Add USB fuse calibration registers for Tegra264
  2026-12-02 14:52 [PATCH v2 0/2] Update USB PHY fuse calibration for Tegra264 Jon Hunter
@ 2026-12-02 14:52 ` Jon Hunter
  2026-12-03 14:37   ` Thierry Reding
  2026-12-02 14:52 ` [PATCH v2 2/2] phy: tegra: xusb-tegra186: Extend Tegra264 fuse calibration Jon Hunter
  1 sibling, 1 reply; 5+ messages in thread
From: Jon Hunter @ 2026-12-02 14:52 UTC (permalink / raw)
  To: Thierry Reding, JC Kuo, Vinod Koul, Neil Armstrong,
	Manivannan Sadhasivam
  Cc: linux-tegra, linux-phy, Jon Hunter, Wayne Chang

From: Wayne Chang <waynec@nvidia.com>

Add definitions for the FUSE_USB_CALIB_EXT2 and FUSE_USB_CALIB_EXT3
registers which are used for USB calibration on the Tegra264 device.

Signed-off-by: Wayne Chang <waynec@nvidia.com>
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
 include/soc/tegra/fuse.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/soc/tegra/fuse.h b/include/soc/tegra/fuse.h
index 14822f981fec..5063707839dd 100644
--- a/include/soc/tegra/fuse.h
+++ b/include/soc/tegra/fuse.h
@@ -23,6 +23,8 @@
 #define TEGRA_FUSE_SKU_CALIB_0	0xf0
 #define TEGRA30_FUSE_SATA_CALIB	0x124
 #define TEGRA_FUSE_USB_CALIB_EXT_0 0x250
+#define TEGRA_FUSE_USB_CALIB_EXT2_0 0x2ec
+#define TEGRA_FUSE_USB_CALIB_EXT3_0 0x3bc
 
 #ifndef __ASSEMBLER__
 

-- 
2.43.0


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] phy: tegra: xusb-tegra186: Extend Tegra264 fuse calibration
  2026-12-02 14:52 [PATCH v2 0/2] Update USB PHY fuse calibration for Tegra264 Jon Hunter
  2026-12-02 14:52 ` [PATCH v2 1/2] soc/tegra: fuse: Add USB fuse calibration registers " Jon Hunter
@ 2026-12-02 14:52 ` Jon Hunter
  2026-12-03 14:48   ` Thierry Reding
  1 sibling, 1 reply; 5+ messages in thread
From: Jon Hunter @ 2026-12-02 14:52 UTC (permalink / raw)
  To: Thierry Reding, JC Kuo, Vinod Koul, Neil Armstrong,
	Manivannan Sadhasivam
  Cc: linux-tegra, linux-phy, Jon Hunter, Wayne Chang

From: Wayne Chang <waynec@nvidia.com>

Add support for receiver offset and squelch offset calibration on
Tegra264 to compensate for manufacturing variation in the USB2
receivers. The receiver offset calibrates the receiver differential
offset between D+ and D-, while squelch offset calibrates the squelch
detector differential offset used to distinguish valid high-speed
signaling from low-amplitude noise or idle. Each USB2 port has a 4-bit
REC_OS (receiver offset) value and an 8-bit SQ_OS (squelch offset) value
stored in fuses.

Add a SoC data variable 'has_rec_sq_offsets' to indicate if the USB PHY
supports the REC_OS and SQ_OS register fields. If the USB PHY supports
these fields, then read REC_OS for ports 0-2 from FUSE_USB_CALIB_EXT_0
and for port 3 from FUSE_USB_CALIB_EXT3_0 and read SQ_OS for all four
ports from FUSE_USB_CALIB_EXT2_0. Apply these values to the corresponding
fields in each port's USB2 pad-control register when powering on the PHY.

Signed-off-by: Wayne Chang <waynec@nvidia.com>
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
 drivers/phy/tegra/xusb-tegra186.c | 57 +++++++++++++++++++++++++++++++++++++++
 drivers/phy/tegra/xusb.h          |  1 +
 2 files changed, 58 insertions(+)

diff --git a/drivers/phy/tegra/xusb-tegra186.c b/drivers/phy/tegra/xusb-tegra186.c
index 82f5c6c8f6a8..9b1df22451e6 100644
--- a/drivers/phy/tegra/xusb-tegra186.c
+++ b/drivers/phy/tegra/xusb-tegra186.c
@@ -3,6 +3,8 @@
  * Copyright (c) 2016-2022, NVIDIA CORPORATION.  All rights reserved.
  */
 
+#include <linux/bitfield.h>
+#include <linux/bits.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/module.h>
@@ -27,6 +29,9 @@
 
 #define RPD_CTRL_SHIFT			0
 #define RPD_CTRL_MASK			0x1f
+#define REC_OS_PAD_MASK			GENMASK(20, 17)
+#define REC_OS_PAD3_MASK			GENMASK(3, 0)
+#define SQ_OS_PAD_MASK			GENMASK(7, 0)
 
 /* XUSB PADCTL registers */
 #define XUSB_PADCTL_USB2_PAD_MUX	0x4
@@ -81,6 +86,10 @@
 #define  TERM_RANGE_ADJ(x)			(((x) & 0xf) << 3)
 #define  RPD_CTRL(x)				(((x) & 0x1f) << 26)
 
+#define XUSB_PADCTL_USB2_OTG_PADX_CTL3(x)	(0x94 + (x) * 0x40)
+#define  REC_OS					GENMASK(12, 9)
+#define  SQ_OS					GENMASK(21, 14)
+
 #define XUSB_PADCTL_USB2_BIAS_PAD_CTL0		0x284
 #define  BIAS_PAD_PD				BIT(11)
 #define  HS_SQUELCH_LEVEL(x)			(((x) & 0x7) << 0)
@@ -255,6 +264,8 @@ struct tegra_xusb_fuse_calibration {
 	u32 hs_squelch;
 	u32 *hs_term_range_adj;
 	u32 rpd_ctrl;
+	u32 *sq_os;
+	u32 *rec_os;
 };
 
 struct tegra186_xusb_padctl_context {
@@ -935,6 +946,14 @@ static int tegra186_utmi_phy_power_on(struct phy *phy)
 	value |= RPD_CTRL(priv->calib.rpd_ctrl);
 	padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
 
+	if (padctl->soc->has_rec_sq_offsets) {
+		value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL3(index));
+		value &= ~(REC_OS | SQ_OS);
+		value |= FIELD_PREP(REC_OS, priv->calib.rec_os[index]);
+		value |= FIELD_PREP(SQ_OS, priv->calib.sq_os[index]);
+		padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL3(index));
+	}
+
 	tegra186_utmi_pad_power_on(phy);
 
 	return 0;
@@ -1520,6 +1539,43 @@ tegra186_xusb_read_fuse_calibration(struct tegra186_xusb_padctl *padctl)
 
 	padctl->calib.hs_term_range_adj = hs_term_range_adj;
 
+	if (soc->has_rec_sq_offsets) {
+		u32 *sq_os, *rec_os;
+
+		sq_os = devm_kzalloc_objs(dev, u32, count);
+		if (!sq_os)
+			return -ENOMEM;
+
+		rec_os = devm_kzalloc_objs(dev, u32, count);
+		if (!rec_os)
+			return -ENOMEM;
+
+		for (i = 0; i < 3; i++)
+			rec_os[i] = FIELD_GET(REC_OS_PAD_MASK, value >> (i * 4));
+
+		err = tegra_fuse_readl(TEGRA_FUSE_USB_CALIB_EXT3_0, &value);
+		if (err)
+			return dev_err_probe(dev, err,
+					     "failed to read EXT3 calibration fuse\n");
+
+		dev_dbg(dev, "FUSE_USB_CALIB_EXT3_0 %#x\n", value);
+
+		rec_os[3] = FIELD_GET(REC_OS_PAD3_MASK, value);
+
+		err = tegra_fuse_readl(TEGRA_FUSE_USB_CALIB_EXT2_0, &value);
+		if (err)
+			return dev_err_probe(dev, err,
+					     "failed to read EXT2 calibration fuse\n");
+
+		dev_dbg(dev, "FUSE_USB_CALIB_EXT2_0 %#x\n", value);
+
+		for (i = 0; i < count; i++)
+			sq_os[i] = FIELD_GET(SQ_OS_PAD_MASK, value >> (i * 8));
+
+		padctl->calib.rec_os = rec_os;
+		padctl->calib.sq_os = sq_os;
+	}
+
 	return 0;
 }
 
@@ -1794,6 +1850,7 @@ const struct tegra_xusb_padctl_soc tegra264_xusb_padctl_soc = {
 	.trk_hw_mode = true,
 	.supports_lp_cfg_en = true,
 	.has_per_pad_term = true,
+	.has_rec_sq_offsets = true,
 };
 EXPORT_SYMBOL_GPL(tegra264_xusb_padctl_soc);
 
diff --git a/drivers/phy/tegra/xusb.h b/drivers/phy/tegra/xusb.h
index 086bb2d09bda..61df37d79ca3 100644
--- a/drivers/phy/tegra/xusb.h
+++ b/drivers/phy/tegra/xusb.h
@@ -436,6 +436,7 @@ struct tegra_xusb_padctl_soc {
 	bool trk_update_on_idle;
 	bool supports_lp_cfg_en;
 	bool has_per_pad_term;
+	bool has_rec_sq_offsets;
 };
 
 struct tegra_xusb_padctl {

-- 
2.43.0


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] soc/tegra: fuse: Add USB fuse calibration registers for Tegra264
  2026-12-02 14:52 ` [PATCH v2 1/2] soc/tegra: fuse: Add USB fuse calibration registers " Jon Hunter
@ 2026-12-03 14:37   ` Thierry Reding
  0 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2026-12-03 14:37 UTC (permalink / raw)
  To: Jon Hunter
  Cc: JC Kuo, Vinod Koul, Neil Armstrong, Manivannan Sadhasivam,
	linux-tegra, linux-phy, Wayne Chang


[-- Attachment #1.1: Type: text/plain, Size: 483 bytes --]

On Wed, Dec 02, 2026 at 02:52:17PM +0000, Jon Hunter wrote:
> From: Wayne Chang <waynec@nvidia.com>
> 
> Add definitions for the FUSE_USB_CALIB_EXT2 and FUSE_USB_CALIB_EXT3
> registers which are used for USB calibration on the Tegra264 device.
> 
> Signed-off-by: Wayne Chang <waynec@nvidia.com>
> Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
> ---
>  include/soc/tegra/fuse.h | 2 ++
>  1 file changed, 2 insertions(+)

Acked-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 112 bytes --]

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] phy: tegra: xusb-tegra186: Extend Tegra264 fuse calibration
  2026-12-02 14:52 ` [PATCH v2 2/2] phy: tegra: xusb-tegra186: Extend Tegra264 fuse calibration Jon Hunter
@ 2026-12-03 14:48   ` Thierry Reding
  0 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2026-12-03 14:48 UTC (permalink / raw)
  To: Jon Hunter
  Cc: JC Kuo, Vinod Koul, Neil Armstrong, Manivannan Sadhasivam,
	linux-tegra, linux-phy, Wayne Chang


[-- Attachment #1.1: Type: text/plain, Size: 1409 bytes --]

On Wed, Dec 02, 2026 at 02:52:18PM +0000, Jon Hunter wrote:
> From: Wayne Chang <waynec@nvidia.com>
> 
> Add support for receiver offset and squelch offset calibration on
> Tegra264 to compensate for manufacturing variation in the USB2
> receivers. The receiver offset calibrates the receiver differential
> offset between D+ and D-, while squelch offset calibrates the squelch
> detector differential offset used to distinguish valid high-speed
> signaling from low-amplitude noise or idle. Each USB2 port has a 4-bit
> REC_OS (receiver offset) value and an 8-bit SQ_OS (squelch offset) value
> stored in fuses.
> 
> Add a SoC data variable 'has_rec_sq_offsets' to indicate if the USB PHY
> supports the REC_OS and SQ_OS register fields. If the USB PHY supports
> these fields, then read REC_OS for ports 0-2 from FUSE_USB_CALIB_EXT_0
> and for port 3 from FUSE_USB_CALIB_EXT3_0 and read SQ_OS for all four
> ports from FUSE_USB_CALIB_EXT2_0. Apply these values to the corresponding
> fields in each port's USB2 pad-control register when powering on the PHY.
> 
> Signed-off-by: Wayne Chang <waynec@nvidia.com>
> Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
> ---
>  drivers/phy/tegra/xusb-tegra186.c | 57 +++++++++++++++++++++++++++++++++++++++
>  drivers/phy/tegra/xusb.h          |  1 +
>  2 files changed, 58 insertions(+)

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 112 bytes --]

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-12-03 14:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 14:52 [PATCH v2 0/2] Update USB PHY fuse calibration for Tegra264 Jon Hunter
2026-12-02 14:52 ` [PATCH v2 1/2] soc/tegra: fuse: Add USB fuse calibration registers " Jon Hunter
2026-12-03 14:37   ` Thierry Reding
2026-12-02 14:52 ` [PATCH v2 2/2] phy: tegra: xusb-tegra186: Extend Tegra264 fuse calibration Jon Hunter
2026-12-03 14:48   ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox