scsi: ufs: ufs-mediatek: Fix HCI version in some platforms

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.

Link: https://lore.kernel.org/r/20210531062642.12642-1-stanley.chu@mediatek.com
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by Stanley Chu and committed by Martin K. Petersen 2c89e413 79c932cd

Changed files
+14 -1
drivers
scsi
+14 -1
drivers/scsi/ufs/ufs-mediatek.c
··· 603 603 604 604 ret = ufshcd_dme_get(hba, UIC_ARG_MIB(PA_LOCALVERINFO), &ver); 605 605 if (!ret) { 606 - if (ver >= UFS_UNIPRO_VER_1_8) 606 + if (ver >= UFS_UNIPRO_VER_1_8) { 607 607 host->hw_ver.major = 3; 608 + /* 609 + * Fix HCI version for some platforms with 610 + * incorrect version 611 + */ 612 + if (hba->ufs_version < ufshci_version(3, 0)) 613 + hba->ufs_version = ufshci_version(3, 0); 614 + } 608 615 } 616 + } 617 + 618 + static u32 ufs_mtk_get_ufs_hci_version(struct ufs_hba *hba) 619 + { 620 + return hba->ufs_version; 609 621 } 610 622 611 623 /** ··· 1060 1048 static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = { 1061 1049 .name = "mediatek.ufshci", 1062 1050 .init = ufs_mtk_init, 1051 + .get_ufs_hci_version = ufs_mtk_get_ufs_hci_version, 1063 1052 .setup_clocks = ufs_mtk_setup_clocks, 1064 1053 .hce_enable_notify = ufs_mtk_hce_enable_notify, 1065 1054 .link_startup_notify = ufs_mtk_link_startup_notify,