linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] scsi: ufs-mediatek: Fix HCI version in some platforms
@ 2021-05-31  6:26 Stanley Chu
  2021-06-02  5:45 ` Martin K. Petersen
  0 siblings, 1 reply; 2+ messages in thread
From: Stanley Chu @ 2021-05-31  6:26 UTC (permalink / raw)
  To: linux-scsi, martin.petersen, avri.altman, alim.akhtar, jejb
  Cc: peter.wang, chun-hung.wu, alice.chao, jonathan.hsu, powen.kao,
	cc.chou, chaotian.jing, jiajie.hao, Stanley Chu

Some MediaTek SoC platforms with UFSHCI version below 3.0 have
incorrect UFSHCI versions showed in register map.

Fix the version by referring to UniPro version which is
always correct.

Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
 drivers/scsi/ufs/ufs-mediatek.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
index 9912e208c2a1..a0abf9cb2398 100644
--- a/drivers/scsi/ufs/ufs-mediatek.c
+++ b/drivers/scsi/ufs/ufs-mediatek.c
@@ -603,11 +603,23 @@ static void ufs_mtk_get_controller_version(struct ufs_hba *hba)
 
 	ret = ufshcd_dme_get(hba, UIC_ARG_MIB(PA_LOCALVERINFO), &ver);
 	if (!ret) {
-		if (ver >= UFS_UNIPRO_VER_1_8)
+		if (ver >= UFS_UNIPRO_VER_1_8) {
 			host->hw_ver.major = 3;
+			/*
+			 * Fix HCI version for some platforms with
+			 * incorrect version
+			 */
+			if (hba->ufs_version < ufshci_version(3, 0))
+				hba->ufs_version = ufshci_version(3, 0);
+		}
 	}
 }
 
+static u32 ufs_mtk_get_ufs_hci_version(struct ufs_hba *hba)
+{
+	return hba->ufs_version;
+}
+
 /**
  * ufs_mtk_init - find other essential mmio bases
  * @hba: host controller instance
@@ -1042,6 +1054,7 @@ static void ufs_mtk_event_notify(struct ufs_hba *hba,
 static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = {
 	.name                = "mediatek.ufshci",
 	.init                = ufs_mtk_init,
+	.get_ufs_hci_version = ufs_mtk_get_ufs_hci_version,
 	.setup_clocks        = ufs_mtk_setup_clocks,
 	.hce_enable_notify   = ufs_mtk_hce_enable_notify,
 	.link_startup_notify = ufs_mtk_link_startup_notify,
-- 
2.18.0


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

* Re: [PATCH v2] scsi: ufs-mediatek: Fix HCI version in some platforms
  2021-05-31  6:26 [PATCH v2] scsi: ufs-mediatek: Fix HCI version in some platforms Stanley Chu
@ 2021-06-02  5:45 ` Martin K. Petersen
  0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2021-06-02  5:45 UTC (permalink / raw)
  To: jejb, alim.akhtar, linux-scsi, avri.altman, Stanley Chu
  Cc: Martin K . Petersen, peter.wang, alice.chao, chun-hung.wu,
	cc.chou, jiajie.hao, chaotian.jing, powen.kao, jonathan.hsu

On Mon, 31 May 2021 14:26:42 +0800, Stanley Chu wrote:

> Some MediaTek SoC platforms with UFSHCI version below 3.0 have
> incorrect UFSHCI versions showed in register map.
> 
> Fix the version by referring to UniPro version which is
> always correct.

Applied to 5.13/scsi-fixes, thanks!

[1/1] scsi: ufs-mediatek: Fix HCI version in some platforms
      https://git.kernel.org/mkp/scsi/c/2c89e41326b1

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2021-06-02  5:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-31  6:26 [PATCH v2] scsi: ufs-mediatek: Fix HCI version in some platforms Stanley Chu
2021-06-02  5:45 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).