[PATCH 1/2] scsi: ufs: core: Add a quirk for extended TX EQTR Adapt L0L1L2L3 length

From: Can Guo

Date: Fri May 01 2026 - 09:17:49 EST


Add a quirk to support TX Equalization Training (EQTR) using Adapt L0L1L2L3
length which is larger than what is allowed by M-PHY spec ver 6.0.

Signed-off-by: Can Guo <can.guo@xxxxxxxxxxxxxxxx>
---
drivers/ufs/core/ufs-txeq.c | 8 ++++++--
include/ufs/ufshcd.h | 7 +++++++
2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/ufs/core/ufs-txeq.c b/drivers/ufs/core/ufs-txeq.c
index b2dc89124353..fe647450a7a1 100644
--- a/drivers/ufs/core/ufs-txeq.c
+++ b/drivers/ufs/core/ufs-txeq.c
@@ -740,7 +740,9 @@ static int ufshcd_setup_tx_eqtr_adapt_length(struct ufs_hba *hba,
if (adapt_l0l1l2l3_cap_local > ADAPT_L0L1L2L3_LENGTH_MAX) {
dev_err(hba->dev, "local RX_HS_G%u_ADAPT_INITIAL_L0L1L2L3_CAP (0x%x) exceeds MAX\n",
gear, adapt_l0l1l2l3_cap_local);
- return -EINVAL;
+
+ if (!(hba->quirks & UFSHCD_QUIRK_EXTENDED_TX_EQTR_ADAPT_LENGTH_L0L1L2L3))
+ return -EINVAL;
}

ret = ufshcd_dme_get(hba, UIC_ARG_MIB(PA_PEERRXHSG6ADAPTINITIALL0L1L2L3),
@@ -751,7 +753,9 @@ static int ufshcd_setup_tx_eqtr_adapt_length(struct ufs_hba *hba,
if (adapt_l0l1l2l3_cap_peer > ADAPT_L0L1L2L3_LENGTH_MAX) {
dev_err(hba->dev, "peer RX_HS_G%u_ADAPT_INITIAL_L0L1L2L3_CAP (0x%x) exceeds MAX\n",
gear, adapt_l0l1l2l3_cap_peer);
- return -EINVAL;
+
+ if (!(hba->quirks & UFSHCD_QUIRK_EXTENDED_TX_EQTR_ADAPT_LENGTH_L0L1L2L3))
+ return -EINVAL;
}

t_adapt_l0l1l2l3_local = adapt_cap_to_t_adapt_l0l1l2l3(adapt_l0l1l2l3_cap_local);
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index cfbc75d8df83..7a7c07636cf7 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -804,6 +804,13 @@ enum ufshcd_quirks {
* delay after enabling VCC to ensure it's stable.
*/
UFSHCD_QUIRK_VCC_ON_DELAY = 1 << 27,
+
+ /*
+ * This quirk indicates that Host supports TX Equalization Training
+ * (EQTR) using Adapt L0L1L2L3 length which is larger than what is
+ * allowed by M-PHY spec ver 6.0.
+ */
+ UFSHCD_QUIRK_EXTENDED_TX_EQTR_ADAPT_LENGTH_L0L1L2L3 = 1 << 28,
};

enum ufshcd_caps {
--
2.34.1