@@ -838,6 +838,51 @@ static void ufs_mtk_mcq_set_irq_affinity(struct ufs_hba *hba, unsigned int cpu)
838
838
dev_info (hba -> dev , "set irq %d affinity to CPU: %d\n" , irq , _cpu );
839
839
}
840
840
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
+
841
886
static void ufs_mtk_get_controller_version (struct ufs_hba * hba )
842
887
{
843
888
struct ufs_mtk_host * host = ufshcd_get_variant (hba );
@@ -1112,7 +1157,7 @@ static int ufs_mtk_init(struct ufs_hba *hba)
1112
1157
1113
1158
ufs_mtk_setup_clocks (hba , true, POST_CHANGE );
1114
1159
1115
- host -> ip_ver = ufshcd_readl (hba , REG_UFS_MTK_IP_VER );
1160
+ ufs_mtk_get_hw_ip_version (hba );
1116
1161
1117
1162
goto out ;
1118
1163
0 commit comments