Skip to content

Commit 7996746

Browse files
Alice Chaomartinkpetersen
authored andcommitted
scsi: ufs: host: mediatek: Add more UFSCHI hardware versions
Introduce a function for version control to distinguish between new and old platforms. Update the handling of hardware IP versions, ensuring correct version comparisons by adjusting the version format for specific projects. Signed-off-by: Alice Chao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Peter Wang <[email protected]> Reviewed-by: Chun-Hung Wu <[email protected]> Signed-off-by: Peter Wang <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 66e26a4 commit 7996746

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

drivers/ufs/host/ufs-mediatek.c

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,51 @@ static void ufs_mtk_mcq_set_irq_affinity(struct ufs_hba *hba, unsigned int cpu)
838838
dev_info(hba->dev, "set irq %d affinity to CPU: %d\n", irq, _cpu);
839839
}
840840

841+
static bool ufs_mtk_is_legacy_chipset(struct ufs_hba *hba, u32 hw_ip_ver)
842+
{
843+
bool is_legacy = false;
844+
845+
switch (hw_ip_ver) {
846+
case IP_LEGACY_VER_MT6893:
847+
case IP_LEGACY_VER_MT6781:
848+
/* can add other legacy chipset ID here accordingly */
849+
is_legacy = true;
850+
break;
851+
default:
852+
break;
853+
}
854+
dev_info(hba->dev, "legacy IP version - 0x%x, is legacy : %d", hw_ip_ver, is_legacy);
855+
856+
return is_legacy;
857+
}
858+
859+
/*
860+
* HW version format has been changed from 01MMmmmm to 1MMMmmmm, since
861+
* project MT6878. In order to perform correct version comparison,
862+
* version number is changed by SW for the following projects.
863+
* IP_VER_MT6983 0x00360000 to 0x10360000
864+
* IP_VER_MT6897 0x01440000 to 0x10440000
865+
* IP_VER_MT6989 0x01450000 to 0x10450000
866+
* IP_VER_MT6991 0x01460000 to 0x10460000
867+
*/
868+
static void ufs_mtk_get_hw_ip_version(struct ufs_hba *hba)
869+
{
870+
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
871+
u32 hw_ip_ver;
872+
873+
hw_ip_ver = ufshcd_readl(hba, REG_UFS_MTK_IP_VER);
874+
875+
if (((hw_ip_ver & (0xFF << 24)) == (0x1 << 24)) ||
876+
((hw_ip_ver & (0xFF << 24)) == 0)) {
877+
hw_ip_ver &= ~(0xFF << 24);
878+
hw_ip_ver |= (0x1 << 28);
879+
}
880+
881+
host->ip_ver = hw_ip_ver;
882+
883+
host->legacy_ip_ver = ufs_mtk_is_legacy_chipset(hba, hw_ip_ver);
884+
}
885+
841886
static void ufs_mtk_get_controller_version(struct ufs_hba *hba)
842887
{
843888
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
@@ -1112,7 +1157,7 @@ static int ufs_mtk_init(struct ufs_hba *hba)
11121157

11131158
ufs_mtk_setup_clocks(hba, true, POST_CHANGE);
11141159

1115-
host->ip_ver = ufshcd_readl(hba, REG_UFS_MTK_IP_VER);
1160+
ufs_mtk_get_hw_ip_version(hba);
11161161

11171162
goto out;
11181163

drivers/ufs/host/ufs-mediatek.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ struct ufs_mtk_host {
181181
u16 ref_clk_ungating_wait_us;
182182
u16 ref_clk_gating_wait_us;
183183
u32 ip_ver;
184+
bool legacy_ip_ver;
184185

185186
bool mcq_set_intr;
186187
bool is_mcq_intr_enabled;
@@ -197,13 +198,24 @@ struct ufs_mtk_host {
197198
/* UFSHCI MTK ip version value */
198199
enum {
199200
/* UFSHCI 3.1 */
201+
IP_VER_MT6983 = 0x10360000,
200202
IP_VER_MT6878 = 0x10420200,
201203

202204
/* UFSHCI 4.0 */
203205
IP_VER_MT6897 = 0x10440000,
204206
IP_VER_MT6989 = 0x10450000,
207+
IP_VER_MT6899 = 0x10450100,
208+
IP_VER_MT6991_A0 = 0x10460000,
209+
IP_VER_MT6991_B0 = 0x10470000,
210+
IP_VER_MT6993 = 0x10480000,
205211

206212
IP_VER_NONE = 0xFFFFFFFF
207213
};
208214

215+
enum ip_ver_legacy {
216+
IP_LEGACY_VER_MT6781 = 0x10380000,
217+
IP_LEGACY_VER_MT6879 = 0x10360000,
218+
IP_LEGACY_VER_MT6893 = 0x20160706
219+
};
220+
209221
#endif /* !_UFS_MEDIATEK_H */

0 commit comments

Comments
 (0)