From: Jon Hunter <jonathanh@nvidia.com>
To: Thierry Reding <thierry.reding@kernel.org>,
JC Kuo <jckuo@nvidia.com>, Vinod Koul <vkoul@kernel.org>,
Neil Armstrong <neil.armstrong@linaro.org>,
Manivannan Sadhasivam <mani@kernel.org>
Cc: <linux-tegra@vger.kernel.org>, <linux-phy@lists.infradead.org>,
Jon Hunter <jonathanh@nvidia.com>,
Wayne Chang <waynec@nvidia.com>
Subject: [PATCH v2 2/2] phy: tegra: xusb-tegra186: Extend Tegra264 fuse calibration
Date: Wed, 2 Dec 2026 14:52:18 +0000 [thread overview]
Message-ID: <20261202-tegra-phy-tegra264-v2-2-2ef15ed73f2c@nvidia.com> (raw)
In-Reply-To: <20261202-tegra-phy-tegra264-v2-0-2ef15ed73f2c@nvidia.com>
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
next prev parent reply other threads:[~2026-12-02 14:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Jon Hunter [this message]
2026-12-03 14:48 ` [PATCH v2 2/2] phy: tegra: xusb-tegra186: Extend Tegra264 fuse calibration Thierry Reding
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=20261202-tegra-phy-tegra264-v2-2-2ef15ed73f2c@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=jckuo@nvidia.com \
--cc=linux-phy@lists.infradead.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mani@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=thierry.reding@kernel.org \
--cc=vkoul@kernel.org \
--cc=waynec@nvidia.com \
/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