Merge "[Feature][T106]version update to T106-V2.01.01.02P56U03.AP.13.04_CAP.13.04"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp
index d91390c..23bb8e4 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp
@@ -30,11 +30,16 @@
 #define FOTA_REBOOT_FLAG "/mnt/userdata/.fota_reboot_flag"

 #define FOTA_FLAG_FILE "/mnt/userdata/.back_up_flag"

 #define FOTA_SYNC_FLAG    1

+#define FOTA_CURRENT_SYS  "/mnt/userdata/.fota_current_sys"

+

 

 extern int lynq_sync_system();

 extern int lynq_fota_get_addr_value(char *tmp_value);

 extern int lynq_fota_set_addr_value(char        *value,int size);

 extern int lynq_fota_nrestart(void);

+extern int lynq_get_current_system();

+

+

 #define REBOOT_DONE  1

 

 void set_upgrade_reboot_flag(void)

@@ -53,6 +58,134 @@
     system("sync");

     return ;

 }

+

+int check_need_sync()

+{

+    int current_sys = 0;

+    int record_sys = 0;

+    int ret = 0;

+    char tmp_sys[8] = {0};

+    FILE *fp = NULL;

+

+    //not fota 

+    if(access(FOTA_FLAG_FILE, F_OK) == -1)

+    {

+        printf("Fota flag file no exist\n");

+

+        //file no exist,get current sys write to file

+        if(access(FOTA_CURRENT_SYS,F_OK) == -1)

+        {

+            printf("Record current sys file no exist\n");

+            

+            fp = fopen(FOTA_CURRENT_SYS,"w");

+            if(fp == NULL)

+             {

+                printf("creat  record current file failed\n");

+                return -1;

+            }

+            current_sys = lynq_get_current_system();

+            if(current_sys < 0)

+            {

+                printf("Get current system failed %d\n",current_sys);

+                fclose(fp);

+                return -1;

+            }

+            else

+            {

+                

+                printf("Get current system success  %d\n",current_sys);

+                fprintf(fp, "%d", current_sys);

+                system("sync");

+                fclose(fp);

+                return 0;

+            }

+        }

+        else

+        {

+            current_sys = lynq_get_current_system();

+            if(current_sys < 0)

+            {

+                printf("Get current system failed %d\n",current_sys);

+                return -1;

+            }

+

+            printf("Get current system success  %d\n",current_sys);

+            

+            fp = fopen(FOTA_CURRENT_SYS,"r");

+            if(fp == NULL)

+            {

+                printf("read file failed \n");

+                return -1;

+            }

+        

+            if(fgets(tmp_sys, sizeof(tmp_sys), fp) != NULL)

+            {

+                record_sys = atoi(tmp_sys);

+            }

+            else

+            {

+                printf("tmp_sys is NULL");

+                fclose(fp);

+                return -1;

+            }

+            

+            if( record_sys == current_sys)

+            {

+                printf("System not need sync \n");

+                fclose(fp);

+                return 0;

+            }

+            else 

+            {

+                fp = fopen(FOTA_CURRENT_SYS,"w");

+                if(fp == NULL)

+                {

+                    printf("creat file failed  \n");

+                    return -1;

+                }

+                

+                printf("System need sync \n");

+                fprintf(fp,"%d",current_sys);

+                system("sync");

+                fclose(fp);

+                ret = lynq_sync_system();

+                if(ret < 0 )

+                {

+                    printf("A/B sync system failed \n");

+                    return -1;

+                }

+                printf("A/B sync system success \n");

+                return 0;

+            }

+        }

+            

+        

+    }

+    else

+    {

+        fp = fopen(FOTA_CURRENT_SYS,"w");

+        if(fp == NULL)

+        {

+            printf("Creat file failed \n");

+            return -1;

+        }

+        printf("fota flag file exist,record current sys \n");

+        current_sys = lynq_get_current_system();

+        if(current_sys < 0)

+        {

+            printf("Get current system failed %d\n",current_sys);

+            return -1;

+        }

+        

+        fprintf(fp,"%d",current_sys);

+        system("sync");

+        fclose(fp);

+        return 0;

+    }

+           

+

+}

+

 int main()

 {

     int ret = 0 ;

@@ -60,6 +193,8 @@
     char tmp_addr[128] = {0};

     FILE *fp = NULL;

 

+    check_need_sync();

+

     fp = fopen(FOTA_FLAG_FILE,"r");

     if(fp == NULL)

     {

@@ -67,7 +202,7 @@
         return -1;

 

     }

-   

+

     fread(&sync_flag,sizeof(int),1,fp);

     fclose(fp);

     

diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.cpp b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.cpp
index b05400c..c00501e 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/data/data.cpp
@@ -1705,7 +1705,7 @@
                     return;
                 }
                 RLOGD("lynq_apn_cid_table[j].cid %d and p_cur[i].cid %d", lynq_apn_cid_table[j].cid, p_cur[i].cid);
-                if(lynq_apn_cid_table[j].cid == p_cur[i].cid)
+                if(lynq_apn_cid_table[j].cid == p_cur[i].cid && lynq_apn_cid_table[j].dialing != 1)
                 {
                     RLOGD("need update");
                     lynq_apn_cid_table[j].dialing = 0;
@@ -1717,7 +1717,7 @@
                     break;
                 }
             }
-            if(i == num)
+            if(i == num && lynq_apn_cid_table[j].dialing != 1)
             {
                 RLOGD("clean start\n");
                 bzero(lynq_apn_cid_table[j].apn,LYNQ_APN_LEN_MAX);
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/lynq_timer.cpp b/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/lynq_timer.cpp
index b9fba74..4893dcb 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/lynq_timer.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/lynq_timer.cpp
@@ -333,22 +333,26 @@
     pclose(fp_1);

     while(1)

     {

+        ALOGD("start check");

         i = 0;

+        sleep(300);

+

         system("date >>/var/log/check_file/cpu_moniter.txt");

         ret = system("top -b |head -n 25 >>/var/log/check_file/cpu_moniter.txt");

         ALOGD("cpu ret %d", ret);

+        usleep(600000);

         system("date >>/var/log/check_file/inter_moniter.txt");

         ret = system("cat /proc/interrupts |grep -v \":          0          0\" >>/var/log/check_file/inter_moniter.txt");

         ALOGD("interrupts ret %d", ret);

-

+        usleep(600000);

         system("date >>/var/log/check_file/pid_moniter.txt");

         ret = system("ps -e \"%p %a\" | grep -v \"\\[\" >>/var/log/check_file/pid_moniter.txt");

         ALOGD("pid ret %d", ret);

-

+        usleep(600000);

         system("date >>/var/log/check_file/meminfo_moniter.txt");

         ret = system("cat /proc/meminfo >>/var/log/check_file/meminfo_moniter.txt");

         ALOGD("meminfo ret %d", ret);

-

+        usleep(600000);

         system("date >>/var/log/check_file/buddyinfo_moniter.txt");

         ret = system("cat /proc/buddyinfo >>/var/log/check_file/buddyinfo_moniter.txt");

         ALOGD("buddyinfo ret %d", ret);

@@ -357,10 +361,11 @@
         ret = system("ps -auxw|grep -v \"0.0  0.0\"|grep -v \"0.1  0.0\"|grep -v \"0.0  0.1\" >>/var/log/check_file/ps_auxw_moniter.txt");

         ALOGD("ps_auxw ret %d", ret);

 #endif

+        usleep(600000);

         system("date >>/var/log/check_file/cur_freq_moniter.txt");

         ret = system("cat /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq >>/var/log/check_file/cur_freq_moniter.txt");

         ALOGD("cur_freq ret %d", ret);

-

+        usleep(600000);

         system("date >>/var/log/check_file/available_frequencies_moniter.txt");

         ret = system("cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies >>/var/log/check_file/available_frequencies_moniter.txt");

         ALOGD("available_frequencies ret %d", ret);

@@ -370,13 +375,14 @@
         while(fgets(pid[i], 8, fp) != NULL)

         {

             ALOGD("pid[%d]:%s", i, pid[i]);

-             delete_enter(pid[i]);

-             i++;

+            delete_enter(pid[i]);

+            i++;

         }

         pclose(fp);

 

         for(j=1;j<i;j++)

         {

+            usleep(300000);

             sprintf(buf, "ls /proc/%s/fd | wc -l", pid[j]);

             fp = popen(buf, "r");

             fgets(ffd[j], 4, fp);

@@ -418,7 +424,6 @@
         num++;

         sprintf(timebuf, "echo \"%d\" >/var/log/check_time", num);

         ret = system(timebuf);

-        sleep(300);

     }

     return NULL;

 

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
index f3ebce3..010ed7c 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
@@ -1054,22 +1054,22 @@
     switch (auth_proto)
     {
     case QSER_APN_AUTH_PROTO_DEFAULT:
-        strcpy(out_proto,"NULL;authType=0");
+        strcpy(out_proto,"0");
         break;
     case QSER_APN_AUTH_PROTO_NONE:
-        strcpy(out_proto,"NULL;authType=1");
+        strcpy(out_proto,"0");
         break;
     case QSER_APN_AUTH_PROTO_PAP:
-        strcpy(out_proto,"NULL;authType=2");
+        strcpy(out_proto,"1");
         break;
     case QSER_APN_AUTH_PROTO_CHAP:
-        strcpy(out_proto,"NULL;authtype=3");
+        strcpy(out_proto,"2");
         break;
     case QSER_APN_AUTH_PROTO_PAP_CHAP:
-        strcpy(out_proto,"NULL;authtype=4");
+        strcpy(out_proto,"3");
         break;
     default:
-        strcpy(out_proto,"NULL;authType=NULL");
+        strcpy(out_proto,"NULL");
         break;
     }
     return ;
@@ -1332,6 +1332,7 @@
     else
     {
         char pdptype[16];
+        char auth_proto[16];
         qser_apn_info_s apn_info;
         LYINFLOG("datacall->profile_idx is %d\n", data_call->profile_idx);
         ret = qser_apn_get((unsigned char)data_call->profile_idx,&apn_info);
@@ -1342,7 +1343,8 @@
             return ret;
         }
         judge_pdp_type(apn_info.pdp_type,pdptype);
-        ret = lynq_setup_data_call_sp(&handle,apn_info.apn_name,apn_info.apn_type,apn_info.username,apn_info.password,NULL,pdptype,pdptype);
+        judge_authtype(apn_info.auth_proto,auth_proto);
+        ret = lynq_setup_data_call_sp(&handle,apn_info.apn_name,apn_info.apn_type,apn_info.username,apn_info.password,auth_proto,pdptype,pdptype);
     }
     if (ret != 0)
     {
@@ -1388,6 +1390,7 @@
     else
     {
         char pdptype[16];
+        char auth_proto[16];
         qser_apn_info_s apn_info;
         LYINFLOG("datacall->profile_idx is %d\n", data_call->profile_idx);
         ret = qser_apn_get((unsigned char)data_call->profile_idx,&apn_info);
@@ -1398,7 +1401,8 @@
             return ret;
         }
         judge_pdp_type(apn_info.pdp_type,pdptype);
-        ret = lynq_setup_data_call_sp_t106_async(&handle,apn_info.apn_name,apn_info.apn_type,apn_info.username,apn_info.password,NULL,pdptype,pdptype);
+        judge_authtype(apn_info.auth_proto,auth_proto);
+        ret = lynq_setup_data_call_sp_t106_async(&handle,apn_info.apn_name,apn_info.apn_type,apn_info.username,apn_info.password,auth_proto,pdptype,pdptype);
     }
     if (ret != 0)
     {
@@ -1506,6 +1510,33 @@
     }
     return ret;
 }
+int check_pdp_type(qser_apn_pdp_type_e pdp_type)
+{
+    switch (pdp_type)
+    {
+        case QSER_APN_PDP_TYPE_IPV4:
+        case QSER_APN_PDP_TYPE_PPP:
+        case QSER_APN_PDP_TYPE_IPV6:
+        case QSER_APN_PDP_TYPE_IPV4V6:
+            return 0;
+        default:
+            return -1;
+    }
+}
+int check_auth_proto(qser_apn_auth_proto_e auth_proto)
+{
+    switch (auth_proto)
+    {
+        case QSER_APN_AUTH_PROTO_DEFAULT:
+        case QSER_APN_AUTH_PROTO_NONE:
+        case QSER_APN_AUTH_PROTO_PAP:
+        case QSER_APN_AUTH_PROTO_CHAP:
+        case QSER_APN_AUTH_PROTO_PAP_CHAP:
+            return 0;
+        default:
+            return -1;
+    }
+}
 int qser_apn_set(qser_apn_info_s *apn)
 {
     int ret = 0;
@@ -1529,6 +1560,38 @@
         LYERRLOG("It has setup datacall");
         return RESULT_ERROR;
     }
+
+    if(strlen(apn->apn_name) > QSER_APN_NAME_SIZE)
+    {
+        LYERRLOG("apn_name out of range\n");
+        return RESULT_ERROR;
+    }
+    if(strlen(apn->username) > QSER_APN_USERNAME_SIZE)
+    {
+        LYERRLOG("username out of range\n");
+        return RESULT_ERROR;
+    }
+    if(strlen(apn->password) > QSER_APN_PASSWORD_SIZE)
+    {
+        LYERRLOG("password out of range\n");
+        return RESULT_ERROR;
+    }
+    if(strlen(apn->apn_type) > QSER_APN_NAME_SIZE)
+    {
+        LYERRLOG("apn_type out of range\n");
+        return RESULT_ERROR;
+    }
+    if(check_pdp_type(apn->pdp_type) != 0)
+    {
+        LYERRLOG("pdp_type out of range\n");
+        return RESULT_ERROR;
+    }
+    if(check_auth_proto(apn->auth_proto) != 0)
+    {
+        LYERRLOG("auth_proto out of range\n");
+        return RESULT_ERROR;
+    }
+
     ret = apn_db_modify(apn);
     if (ret < 0)
     {
@@ -1590,6 +1653,37 @@
         LYERRLOG("apn add incoming paramters error");
         return RESULT_ERROR;
     }
+    
+    if(strlen(apn->apn_name) > QSER_APN_NAME_SIZE)
+    {
+        LYERRLOG("apn_name out of range\n");
+        return RESULT_ERROR;
+    }
+    if(strlen(apn->username) > QSER_APN_USERNAME_SIZE)
+    {
+        LYERRLOG("username out of range\n");
+        return RESULT_ERROR;
+    }
+    if(strlen(apn->password) > QSER_APN_PASSWORD_SIZE)
+    {
+        LYERRLOG("password out of range\n");
+        return RESULT_ERROR;
+    }
+    if(strlen(apn->apn_type) > QSER_APN_NAME_SIZE)
+    {
+        LYERRLOG("apn_type out of range\n");
+        return RESULT_ERROR;
+    }
+    if(check_pdp_type(apn->pdp_type) != 0)
+    {
+        LYERRLOG("pdp_type out of range\n");
+        return RESULT_ERROR;
+    }
+    if(check_auth_proto(apn->auth_proto) != 0)
+    {
+        LYERRLOG("auth_proto out of range\n");
+        return RESULT_ERROR;
+    }
 
     *profile_idx = 0;
     *profile_idx = (unsigned char)find_unuse_apn_index(APN_DB_PATH);
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/es8311.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/es8311.c
index 899ab9c..0e9dab6 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/es8311.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/es8311.c
@@ -766,39 +766,39 @@
 		/* set iface */

 		snd_soc_component_write(component, ES8311_SDPOUT_REG0A, iface);

 	}

-

-	

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x98);

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x1b);

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG04, 0x1b);

-	/*

-	if(rate == 8000){

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0xbb);

-		  pr_info("%s rate:%d\n",__FUNCTION__,rate);

-

-		}

-	if(rate == 16000){

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0x55);

-			  pr_info("%s rate:%d\n",__FUNCTION__,rate);

-

-		}

-	*/	

-	if(rate == 44100){

-

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x90);

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x1d);

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG04, 0x1d);

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0x00);

-			  pr_info("%s rate:%d\n",__FUNCTION__,rate);

-

-		}

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG06, 0x18);

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG07, 0x06);

-

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG08, 0x58);

-

-

-

+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */
+#ifdef CONFIG_USE_TOP_TDM
+#else
+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x98);
+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x1b);
+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG04, 0x1b);
+	/*
+	if(rate == 8000){
+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0xbb);
+		  pr_info("%s rate:%d\n",__FUNCTION__,rate);
+
+		}
+	if(rate == 16000){
+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0x55);
+			  pr_info("%s rate:%d\n",__FUNCTION__,rate);
+
+		}
+	*/
+	if(rate == 44100){
+
+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x90);
+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x1d);
+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG04, 0x1d);
+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0x00);
+			  pr_info("%s rate:%d\n",__FUNCTION__,rate);
+
+		}
+#endif
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */
+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG06, 0x18);
+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG07, 0x06);
+
+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG08, 0x58);
 

 

 	return 0;

@@ -914,7 +914,12 @@
 			snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x10);

 			snd_soc_component_write(component, ES8311_RESET_REG00, 0x00);

 			snd_soc_component_write(component, ES8311_RESET_REG00, 0x1F);

+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */
+#ifdef CONFIG_USE_TOP_TDM
+			snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0xB0);

+#else
 			snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0x30);

+#endif
 			snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0x00);

 			snd_soc_component_write(component, ES8311_GP_REG45, 0x00);

 		}

@@ -933,7 +938,12 @@
 			snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x10);

 			snd_soc_component_write(component, ES8311_RESET_REG00, 0x00);

 			snd_soc_component_write(component, ES8311_RESET_REG00, 0x1F);

+#ifdef CONFIG_USE_TOP_TDM
+			snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0xB0);

+#else
 			snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0x30);

+#endif
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */
 			snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0x00);

 			snd_soc_component_write(component, ES8311_GP_REG45, 0x00);

 			snd_soc_component_write(component, ES8311_SYSTEM_REG0D, 0xFC);

@@ -1023,6 +1033,7 @@
 static int es8311_suspend(struct snd_soc_component *component)

 {

 	printk("Enter into %s()\n", __func__);

+
 	//snd_soc_component_write(component, ES8311_DAC_REG32, 0x00);

 	//snd_soc_component_write(component, ES8311_ADC_REG17, 0x00);

 	snd_soc_component_write(component, ES8311_SYSTEM_REG0E, 0xFF);

@@ -1039,6 +1050,7 @@
 	snd_soc_component_write(component, ES8311_GP_REG45, 0x00);

 	snd_soc_component_write(component, ES8311_SYSTEM_REG0D, 0xFC);

 	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x00);

+
 	return 0;

 }

 

@@ -1055,7 +1067,7 @@
 	struct es8311_private *es8311 = es8311_data;

 

 	printk("Enter into %s()\n", __func__);

-

+
 	snd_soc_component_set_drvdata(component, es8311);

 	if (component == NULL) {

 		dev_err(component->dev, "Codec device not registered\n");

@@ -1065,7 +1077,13 @@
 	es8311->component = component;

 

 	es8311->mastermode = 0;

-	es8311->mclk_src = ES8311_MCLK_SOURCE;

+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */
+#ifdef CONFIG_USE_TOP_TDM
+	es8311->mclk_src = ES8311_BCLK_PIN;
+#else
+	es8311->mclk_src = ES8311_MCLK_SOURCE;
+#endif
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */
 	/* Enable the following code if there is no mclk.

 	 * a clock named "mclk" need to be defined in the dts (see sample dts)

 	 *

@@ -1090,8 +1108,13 @@
 			return ret;

 		}

 	}

+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */
 	snd_soc_component_write(component, ES8311_GP_REG45, 0x00);

+#ifdef CONFIG_USE_TOP_TDM
+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0xB0);

+#else
 	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0x30);

+#endif
 	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x00);

 	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x10);

 	//snd_soc_component_write(component, ES8311_ADC_REG16, 0x24);

@@ -1155,10 +1178,20 @@
 	snd_soc_component_write(component, ES8311_DAC_REG37, 0x48);

 	snd_soc_component_write(component, ES8311_ADC_REG17, 0xBF);

 	snd_soc_component_write(component, ES8311_DAC_REG32, 0xBF);

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x98);

+#ifdef CONFIG_USE_TOP_TDM
+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x1A);

 	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x1b);

 	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG04, 0x1b);

-	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0xbb);

+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0x00);

+	snd_soc_component_write(component, ES8311_SDPIN_REG09,0x0F);
+	snd_soc_component_write(component, ES8311_SDPOUT_REG0A,0x0F);
+#else
+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x98);
+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x1b);
+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG04, 0x1b);
+	snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0xbb);
+#endif
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */
 	msleep(100);

 	es8311_set_bias_level(component, SND_SOC_BIAS_STANDBY);

 

@@ -1183,9 +1216,6 @@
 	int ret;

 	struct es8311_private *info = dev_get_drvdata(dev);

 	struct device_node *np = dev->of_node;

-

-	unsigned tmp;

-	printk("Enter into %s()\n", __func__);

 
 	//yu.dong@20240416[T106BUG-551][codec] codec 8311 sleep power consumption does not go down
 
@@ -1287,8 +1317,13 @@
 {
     pr_info("%s:begin!\n", __func__);
 
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */
     snd_soc_component_write(component, ES8311_GP_REG45, 0x00);
+#ifdef CONFIG_USE_TOP_TDM
+    snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0xB0);

+#else
     snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0x30);
+#endif
     snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x00);
     snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x10);
     //snd_soc_component_write(component, ES8311_ADC_REG16, 0x24);
@@ -1342,7 +1377,6 @@
     } else {
         snd_soc_component_update_bits(component, ES8311_SYSTEM_REG14, 0x40, 0x00);
     }
-
     snd_soc_component_write(component, ES8311_SYSTEM_REG12, 0x00);
     snd_soc_component_write(component, ES8311_SYSTEM_REG13, 0x10);
     snd_soc_component_write(component, ES8311_SYSTEM_REG0E, 0x02);
@@ -1353,14 +1387,22 @@
     snd_soc_component_write(component, ES8311_DAC_REG37, 0x48);
     snd_soc_component_write(component, ES8311_ADC_REG17, 0xBF);
     snd_soc_component_write(component, ES8311_DAC_REG32, 0xBF);
+#ifdef CONFIG_USE_TOP_TDM
+    snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x1A);
+    snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x1b);
+    snd_soc_component_write(component, ES8311_CLK_MANAGER_REG04, 0x1b);
+    snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0x00);
+    snd_soc_component_write(component, ES8311_SDPIN_REG09,0x0F);
+    snd_soc_component_write(component, ES8311_SDPOUT_REG0A,0x0F);
+#else
     snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x98);
     snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x1b);
     snd_soc_component_write(component, ES8311_CLK_MANAGER_REG04, 0x1b);
     snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0xbb);
-
+#endif
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */
     msleep(100);
     es8311_set_bias_level(component, SND_SOC_BIAS_STANDBY);
-
     pr_info("%s:end!\n", __func__);
 }
 
@@ -1382,15 +1424,17 @@
 			pr_err( "failed to enable clkout");

 		}

 	}

-	

+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */
+#ifdef CONFIG_USE_TOP_TDM
+#else
 	ret = zx29_i2s_config_default_pin();
 	if(ret < 0) {
 		pr_err("%s select state failure %d !! \n", __func__, ret);
 	}
+#endif
 	es8311_reinit(component, info);
-
-	pr_info("%s:clk en end!\n",__func__);

-

+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */	
+	pr_info("%s:clk en end!\n",__func__);
 	return ret;

 

 

@@ -1412,20 +1456,19 @@
 

 	}

 	pr_info("%s:clk dis end!\n",__func__);

-
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */
+#ifdef CONFIG_USE_TOP_TDM
+#else
 	ret = zx29_i2s_config_sleep_pin();
         if(ret < 0) {
                 pr_err("%s select state failure %d !! \n", __func__, ret);
         }
+#endif
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */
+	return ret;
+}
 
-	return ret;

-

-

-	

-

-}		

 //yu.dong@20240416[ZXW-268]Added codec re-initialization for power down and I2S default configuration adjustment end
-

 static const struct snd_soc_component_driver soc_component_dev_es8311 = {

 	.probe = es8311_probe,

 	.remove = es8311_remove,

@@ -1687,8 +1730,7 @@
 	struct es8311_private *es8311;

 	int ret = -1;

 	unsigned int val;

-	printk("Enter into %s\n", __func__);

-

+
 	pr_info("Enter into %s\n", __func__);

 	es8311 = devm_kzalloc(&i2c_client->dev,

 			sizeof(*es8311), GFP_KERNEL);

@@ -1734,9 +1776,11 @@
 	es8311->pctrl = NULL;

 	es8311->state0 = NULL;

 	es8311->clk = NULL;	

-	

-	clkout_init_pinctrl(&i2c_client->dev);

-

+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */
+#ifndef CONFIG_USE_TOP_TDM
+        clkout_init_pinctrl(&i2c_client->dev);

+#endif
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */
 	ret =  snd_soc_register_component(&i2c_client->dev,

 			&soc_component_dev_es8311,

 			&es8311_dai,

diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/es8311.h b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/es8311.h
index 5acb206..ba0c537 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/es8311.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/codecs/es8311.h
@@ -70,14 +70,26 @@
 	VMIDLEVEL2,

 	VMIDLEVEL3,

 };

-/* The VMIDLEVEL is different for 1.8V AVDD */

-#define ES8311_3V3 0

-#define ES8311_1V8 1

-//#define ES8311_AVDD ES8311_3V3

-#define ES8311_AVDD ES8311_1V8

 

-#define ES8311_MCLK_PIN	0

-#define ES8311_BCLK_PIN 1

-#define ES8311_MCLK_SOURCE	ES8311_MCLK_PIN

+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */

+#ifdef CONFIG_USE_TOP_TDM

+    /* The VMIDLEVEL is different for 1.8V AVDD */

+    #define ES8311_3V3 0

+    #define ES8311_1V8 1

+    #define ES8311_AVDD ES8311_3V3

+

+    #define ES8311_MCLK_PIN 0

+    #define ES8311_BCLK_PIN 1

+    #define ES8311_MCLK_SOURCE ES8311_BCLK_PIN

+#else

+    #define ES8311_3V3 0

+    #define ES8311_1V8 1

+    #define ES8311_AVDD ES8311_1V8

+

+    #define ES8311_MCLK_PIN 0

+    #define ES8311_BCLK_PIN 1

+    #define ES8311_MCLK_SOURCE ES8311_MCLK_PIN

+#endif

+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */

 

 #endif

diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/sanechips/zx29_es83xx.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/sanechips/zx29_es83xx.c
index 4e56af4..3c755a6 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/sanechips/zx29_es83xx.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/sound/soc/sanechips/zx29_es83xx.c
@@ -174,6 +174,216 @@
  
 	 return 0;
  }
+
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */
+ static int zx29_hw_params_tdm(struct snd_pcm_substream *substream,
+                                         struct snd_pcm_hw_params *params)
+ {
+ print_audio("Alsa:  Entered func %s\n", __func__);
+     struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+     struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
+     struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
+     int ret;
+     int rfs = 0, frq_out = 0;
+     switch (params_rate(params)) {
+     case 8000:
+     case 16000:
+     case 11025:
+     case 22050:
+     case 24000:
+     case 32000:
+     case 44100:
+     case 48000:
+         rfs = 32;
+         break;
+     default:
+         {
+         ret =-EINVAL;
+         print_audio("Alsa: rate=%d not support,ret=%d!\n", params_rate(params),ret);
+             return ret;
+         }
+     }
+
+     //frq_out = params_rate(params) * rfs * 2;
+
+     /* Set the Codec DAI configuration */
+     ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A
+                             | SND_SOC_DAIFMT_NB_NF
+                             | SND_SOC_DAIFMT_CBS_CFS);
+     if (ret < 0){
+
+         print_audio("Alsa: codec dai snd_soc_dai_set_fmt fail,ret=%d!\n",ret);
+         return ret;
+     }
+     /* Set the AP DAI configuration */
+     ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_DSP_A
+                             | SND_SOC_DAIFMT_NB_NF
+                             | SND_SOC_DAIFMT_CBS_CFS);
+     if (ret < 0){
+
+         print_audio("Alsa: ap dai snd_soc_dai_set_fmt fail,ret=%d!\n",ret);
+         return ret;
+     }
+     ret = snd_soc_dai_set_sysclk(codec_dai, ES8311_MCLK_PIN,params_rate(params)*256, SND_SOC_CLOCK_IN);
+     if (ret < 0){
+         print_audio("Alsa: codec dai snd_soc_dai_set_sysclk fail,ret=%d!\n",ret);
+         return ret;
+     }
+
+     /* Set the AP DAI clk */
+     //ret = snd_soc_dai_set_sysclk(cpu_dai, ZX29_I2S_WCLK_SEL,ZX29_I2S_WCLK_FREQ_26M, SND_SOC_CLOCK_IN);
+     ret = snd_soc_dai_set_sysclk(cpu_dai, ZX29_I2S_WCLK_SEL,ZX29_I2S_WCLK_FREQ_104M, SND_SOC_CLOCK_IN);
+     //ret = snd_soc_dai_set_sysclk(cpu_dai, ZX29_I2S_WCLK_SEL,ZX29_I2S_WCLK_FREQ_122M88, SND_SOC_CLOCK_IN);
+
+     if (ret < 0){
+         print_audio("Alsa: cpu dai snd_soc_dai_set_sysclk fail,ret=%d!\n",ret);
+         return ret;
+     }
+ print_audio("Alsa:  Entered func %s end\n", __func__);
+
+     return 0;
+ }
+
+ static int zx29_hw_params_lp_tdm(struct snd_pcm_substream *substream,
+                                     struct snd_pcm_hw_params *params)
+ {
+     print_audio("Alsa: Entered func %s\n", __func__);
+     struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+     struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
+     struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
+     int ret;
+     int rfs = 0, frq_out = 0;
+     switch (params_rate(params)) {
+     case 8000:
+     case 16000:
+     case 11025:
+     case 22050:
+     case 24000:
+     case 32000:
+     case 44100:
+     case 48000:
+         rfs = 32;
+         break;
+     default:
+     {
+         ret =-EINVAL;
+         print_audio("Alsa: rate=%d not support,ret=%d!\n", params_rate(params),ret);
+         return ret;
+     }
+     }
+
+     //frq_out = params_rate(params) * rfs * 2;
+
+     /* Set the Codec DAI configuration */
+     /*
+
+     ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S
+                             | SND_SOC_DAIFMT_NB_NF
+                             | SND_SOC_DAIFMT_CBS_CFS);
+     if (ret < 0){
+
+         print_audio("Alsa: codec dai snd_soc_dai_set_fmt fail,ret=%d!\n",ret);
+         return ret;
+     }
+     */
+
+     /* Set the AP DAI configuration */
+     ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_DSP_A
+                             | SND_SOC_DAIFMT_NB_NF
+                             | SND_SOC_DAIFMT_CBS_CFS);
+     if (ret < 0){
+
+         print_audio("Alsa: ap dai snd_soc_dai_set_fmt fail,ret=%d!\n",ret);
+         return ret;
+     }
+     /* Set the Codec DAI clk */
+     /*ret =snd_soc_dai_set_pll(codec_dai, 0, RT5670_PLL1_S_BCLK1,
+                                 fs*datawidth*2, 256*fs);
+     if (ret < 0){
+
+         print_audio("Alsa: codec dai clk snd_soc_dai_set_pll fail,ret=%d!\n",ret);
+         return ret;
+ }
+     */
+     /*
+     ret = snd_soc_dai_set_sysclk(codec_dai, ES8312_CLKID_MCLK,ZXIC_MCLK, SND_SOC_CLOCK_IN);
+     if (ret < 0){
+         print_audio("Alsa: codec dai snd_soc_dai_set_sysclk fail,ret=%d!\n",ret);
+         return ret;
+     }
+     */
+     /* Set the AP DAI clk */
+     //ret = snd_soc_dai_set_sysclk(cpu_dai, ZX29_I2S_WCLK_SEL,ZX29_I2S_WCLK_FREQ_26M, SND_SOC_CLOCK_IN);
+     ret = snd_soc_dai_set_sysclk(cpu_dai, ZX29_I2S_WCLK_SEL,ZX29_I2S_WCLK_FREQ_104M, SND_SOC_CLOCK_IN);
+
+     //ret = snd_soc_dai_set_sysclk(cpu_dai, ZX29_I2S_WCLK_SEL,ZX29_I2S_WCLK_FREQ_122M88, SND_SOC_CLOCK_IN);
+     if (ret < 0){
+         print_audio("Alsa: cpu dai snd_soc_dai_set_sysclk fail,ret=%d!\n",ret);
+         return ret;
+     }
+     print_audio("Alsa: Entered func %s end\n", __func__);
+
+     return 0;
+ }
+
+
+ static int zx29_hw_params_voice_tdm(struct snd_pcm_substream *substream,
+                                         struct snd_pcm_hw_params *params)
+ {
+     print_audio("Alsa: Entered func %s\n", __func__);
+     struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+     struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0);
+     struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
+     int ret;
+     int rfs = 0, frq_out = 0;
+     switch (params_rate(params)) {
+     case 8000:
+     case 16000:
+     case 11025:
+     case 22050:
+     case 24000:
+     case 32000:
+     case 44100:
+     case 48000:
+         rfs = 32;
+         break;
+     default:
+         {
+             ret =-EINVAL;
+             print_audio("Alsa: rate=%d not support,ret=%d!\n", params_rate(params),ret);
+             return ret;
+         }
+     }
+
+     frq_out = params_rate(params) * rfs * 2;
+
+     /* Set the Codec DAI configuration */
+     ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A
+                             | SND_SOC_DAIFMT_NB_NF
+                             | SND_SOC_DAIFMT_CBS_CFS);
+     if (ret < 0){
+
+         print_audio("Alsa: codec dai snd_soc_dai_set_fmt fail,ret=%d!\n",ret);
+         return ret;
+     }
+
+
+     //ret = snd_soc_dai_set_sysclk(codec_dai, NAU8810_SCLK_PLL,ZXIC_MCLK, SND_SOC_CLOCK_IN);
+
+     ret = snd_soc_dai_set_sysclk(codec_dai, ES8311_MCLK_PIN,params_rate(params)*256, SND_SOC_CLOCK_IN);
+     if (ret < 0){
+         print_audio("Alsa: codec dai snd_soc_dai_set_sysclk fail,ret=%d!\n",ret);
+         return ret;
+     }
+
+
+
+     print_audio("Alsa: Entered func %s end\n", __func__);
+
+     return 0;
+ }
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */
+
  static int zx29_hw_params(struct snd_pcm_substream *substream,
 										struct snd_pcm_hw_params *params)
  {
@@ -451,16 +661,25 @@
  
 	 return 0;
  }
- 
+
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */
  static struct snd_soc_ops zx29_ops = {
 	 //.startup = zx29_startup,
 	 .shutdown = zx29_shutdown,
+#ifdef CONFIG_USE_TOP_TDM
+	 .hw_params = zx29_hw_params_tdm,
+#else
 	 .hw_params = zx29_hw_params,
+#endif
  };
   static struct snd_soc_ops zx29_ops_lp = {
 	 //.startup = zx29_startup,
 	 .shutdown = zx29_shutdown,
+#ifdef CONFIG_USE_TOP_TDM
+	 .hw_params = zx29_hw_params_lp_tdm,
+#else
 	 .hw_params = zx29_hw_params_lp,
+#endif
  };
  static struct snd_soc_ops zx29_ops1 = {
 	 //.startup = zx29_startup,
@@ -477,10 +696,14 @@
  static struct snd_soc_ops voice_ops = {
 	 .startup = zx29startup,
 	 .shutdown = zx29_shutdown2,
+#ifdef CONFIG_USE_TOP_TDM
+	 .hw_params = zx29_hw_params_voice_tdm,
+#else
 	 .hw_params = zx29_hw_params_voice,
+#endif
 	 //.prepare = zx29_prepare2,
  };
-
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */
  
  enum {
 	 MERR_DPCM_AUDIO = 0,
@@ -530,6 +753,7 @@
 	
 	AUDIO_DL_MAX,
 };
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */
 SND_SOC_DAILINK_DEF(dummy, \
 	DAILINK_COMP_ARRAY(COMP_DUMMY()));
 
@@ -538,6 +762,8 @@
 SND_SOC_DAILINK_DEF(cpu_i2s0, \
 	DAILINK_COMP_ARRAY(COMP_CPU("1405000.i2s")));
 
+SND_SOC_DAILINK_DEF(cpu_tdm, \
+	DAILINK_COMP_ARRAY(COMP_CPU("1412000.tdm")));
 
 SND_SOC_DAILINK_DEF(voice_cpu, \
 	DAILINK_COMP_ARRAY(COMP_CPU("soc:voice_audio")));
@@ -576,6 +802,10 @@
 //	DAILINK_COMP_ARRAY(COMP_PLATFORM("zx29-pcm-audio")));
 SND_SOC_DAILINK_DEF(media_platform, \
 	DAILINK_COMP_ARRAY(COMP_PLATFORM("1405000.i2s")));
+
+SND_SOC_DAILINK_DEF(media_platform_tdm, \
+	DAILINK_COMP_ARRAY(COMP_PLATFORM("1412000.tdm")));
+
 //SND_SOC_DAILINK_DEF(voice_cpu, \
 //	DAILINK_COMP_ARRAY(COMP_CPU("E1D02000.i2s")));
 
@@ -595,8 +825,11 @@
 	//.dpcm_playback = 1,
 	.ops = &zx29_ops_lp,
 	.init = zx29_init_paiftx,
+#ifdef CONFIG_USE_TOP_TDM
+	SND_SOC_DAILINK_REG(cpu_tdm, dummy_codec, media_platform_tdm),
+#else
 	SND_SOC_DAILINK_REG(cpu_i2s0, dummy_codec, media_platform),
-	
+#endif	
 },
 {
 	.name = "media",//codec name
@@ -607,11 +840,14 @@
 	.ops = &zx29_ops,
 
  	.init = zx29_init_paiftx,
-	
 
+#ifdef CONFIG_USE_TOP_TDM
+	SND_SOC_DAILINK_REG(cpu_tdm, codec, media_platform_tdm),
+#else
 	SND_SOC_DAILINK_REG(cpu_i2s0, codec, media_platform),
-
+#endif
 },
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */
 {
 	.name = "voice",//codec name
 	.stream_name = "voice",
@@ -678,17 +914,21 @@
 
 
 
-
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */
 static struct snd_soc_card zx29_soc_card = {
 	.name = "zx29-sound-card",
 	.owner = THIS_MODULE,
 	.dai_link = zx29_dai_link,
 	.num_links = ARRAY_SIZE(zx29_dai_link),
-#ifdef USE_ALSA_VOICE_FUNC
-	 .controls = vp_snd_controls,
-	 .num_controls = ARRAY_SIZE(vp_snd_controls),
-#endif	
+#ifdef CONFIG_USE_TOP_TDM
+#else
+    #ifdef USE_ALSA_VOICE_FUNC
+        .controls = vp_snd_controls,
+        .num_controls = ARRAY_SIZE(vp_snd_controls),
+    #endif
+#endif
 };
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */
 
 static const struct of_device_id zx29_codec_of_match[] = {
 #if defined(CONFIG_SND_SOC_ZX29_ES8311)
@@ -737,30 +977,58 @@
 	#else
 	reg_base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
 	#endif
-	 
-//#if 1 //CONFIG_USE_PIN_I2S0
-#if defined(CONFIG_USE_TOP_I2S0)
 
-	dev_info(dev, "%s: arm i2s1 to top i2s0!!\n", __func__); 
-	//9300
-		 
-	//top i2s1 cfg
-	val = zx_read_reg(reg_base+ZX29_I2S_TOP_LOOP_REG);
-	val &= ~(0x7<<0);
-	val |= 0x1<<0; //	inter arm_i2s1--top i2s1
-	zx_write_reg(reg_base+ZX29_I2S_TOP_LOOP_REG, val);
-#elif defined(CONFIG_USE_TOP_I2S1)//defined(CONFIG_USE_PIN_I2S1)
-    //8501evb    	
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */
+#ifdef CONFIG_USE_TOP_TDM
+    //#if 1 //CONFIG_USE_PIN_I2S0
+    #if defined(CONFIG_USE_TOP_I2S0)
 
-	dev_info(dev, "%s: arm i2s1 to top i2s1!\n", __func__); 
-			 
-	//top i2s2 cfg
-	val = zx_read_reg(reg_base+ZX29_I2S_TOP_LOOP_REG);
-	//val &= 0xfffffff8;
-	val &= ~(0x7<<16);	
-	val |= 0x1<<16;//	inter arm_i2s1--top i2s2
-	zx_write_reg(reg_base+ZX29_I2S_TOP_LOOP_REG, val);
+        dev_info(dev, "%s: arm i2s1 to top i2s0!!\n", __func__); 
+        //9300
+         
+        //top i2s1 cfg
+        val = zx_read_reg(reg_base+ZX29_I2S_TOP_LOOP_REG);
+        val &= ~(0x7<<0);
+        val |= 0x1<<0; //  inter arm_i2s1--top i2s1
+        zx_write_reg(reg_base+ZX29_I2S_TOP_LOOP_REG, val);
+
+    #elif defined(CONFIG_USE_PIN_I2S1)
+
+        dev_info(dev, "%s: arm i2s1 to top i2s1!\n", __func__); 
+                 
+        //top i2s2 cfg
+        val = zx_read_reg(reg_base+ZX29_I2S_TOP_LOOP_REG);
+        val &= ~(0x7<<16);    
+        val |= 0x1<<16;//    inter arm_i2s1--top i2s2
+        zx_write_reg(reg_base+ZX29_I2S_TOP_LOOP_REG, val);
+    #endif
+
+#else
+
+    //#if 1 //CONFIG_USE_PIN_I2S0
+    #if defined(CONFIG_USE_TOP_I2S0)
+
+        dev_info(dev, "%s: arm i2s1 to top i2s0!!\n", __func__);
+        //9300
+
+        //top i2s1 cfg
+        val = zx_read_reg(reg_base+ZX29_I2S_TOP_LOOP_REG);
+        val &= ~(0x7<<0);
+        val |= 0x1<<0; //  inter arm_i2s1--top i2s1
+        zx_write_reg(reg_base+ZX29_I2S_TOP_LOOP_REG, val);
+
+    #elif defined(CONFIG_USE_TOP_I2S1)
+
+        dev_info(dev, "%s: arm i2s1 to top i2s1!\n", __func__);
+
+        //top i2s2 cfg
+        val = zx_read_reg(reg_base+ZX29_I2S_TOP_LOOP_REG);
+        val &= ~(0x7<<16);
+        val |= 0x1<<16;//    inter arm_i2s1--top i2s2
+        zx_write_reg(reg_base+ZX29_I2S_TOP_LOOP_REG, val);
+    #endif
 #endif
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */
 
 	p = devm_pinctrl_get(dev);
 	if (IS_ERR(p)) {
@@ -851,8 +1119,14 @@
 		info->s = s;
 		info->s_sleep = s_sleep;
 	}
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */
+#ifdef CONFIG_USE_TOP_TDM
+	ret = pinctrl_select_state(p, s);
+#else
 //yu.dong@20240416[ZXW-268]Added codec re-initialization for power down and I2S default configuration adjustment start
 	ret = pinctrl_select_state(p, s_sleep);
+#endif
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */
 	if (ret < 0) {
 		devm_pinctrl_put(p);
 		dev_err(dev, " select state failure!!\n");
@@ -914,7 +1188,9 @@
 	board = devm_kzalloc(&pdev->dev, sizeof(*board), GFP_KERNEL);
 	if (!board)
 		return -ENOMEM;
-
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */
+#ifdef CONFIG_USE_TOP_TDM
+#else
 	if (np) {
 		zx29_dai_link[0].cpus->dai_name = NULL;
 		zx29_dai_link[0].cpus->of_node = of_parse_phandle(np,
@@ -930,8 +1206,8 @@
 
 		
 	}
-
-
+#endif
+/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */
 
 	id = of_match_device(of_match_ptr(zx29_codec_of_match), &pdev->dev);
 	if (id)