Merge "[Feature][ZXW-182] Sleep wake-up interface setting callback function"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-irq-demo/files/lynq-irq-demo.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-irq-demo/files/lynq-irq-demo.cpp
index 537273e..0f8ddef 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-irq-demo/files/lynq-irq-demo.cpp
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-irq-demo/files/lynq-irq-demo.cpp
@@ -5,10 +5,35 @@
 #include <include/lynq-irq.h>
 
 
+#define CMD_SET_WAKE    "set_wake"
+#define CMD_GET_WAKE    "get_wake\n"
+#define CMD_SET_TYPE    "set_type"
+#define CMD_GET_TYPE    "get_type\n"
+#define CMD_UNINSTALL   "uninstall\n"
+#define CMD_QUIT_TEST   "quit\n"
+
+int line;
+
+
+static void printUsage(void)
+{
+    printf("Usage:\n");
+    printf("-set_wake <en>\n");
+    printf("-set_type <en>\n");
+    printf("-get_type\n");
+    printf("-get_wake\n");
+    printf("-uninstall\n");
+    printf("-quit\n");
+    printf("Please input an cmd:");
+}
+
 
 static void irq_test_handler(void)
 {
-    printf("this is irq_test_handler\n");
+    int trig_type;
+    trig_type = lynq_irq_get_type(line);
+    printf("this is irq_test_handler\nthis irq is gpio %d,trig_type is %d\n", line_gpio[line], trig_type);
+    return NULL;
 }
 
 
@@ -18,60 +43,45 @@
     int irq;
     int trig_type;
     int en;
+    char cmd[16];
+    char *cmd2;
+    char *cmd1;
 
-    if(argc < 2)
+    if(argc != 3)
     {
-        printf("wrong input format, please -h \n");
+        printf("wrong input format, please inout lynq-irq-demo <irq_line> <trig_type/wake_state> \n");
         return -1;
     }
-
-    if(strcmp(argv[1],"-h") == 0)
-    {
-        printf("        -h                                        --help\n");
-        printf("        -t   [irq][trig_type]                    --lynq_irq_set_type\n");
-        printf("        -sw  [irq][en]                           --lynq_irq_set_wake\n");
-        printf("        -gw  [irq]                               --lynq_irq_get_wake\n");
-        return 0;
-    }
-
-    if(argv[2] == NULL)
-    {
-        printf("wrong input format, please -h \n");
-        return -1;
-    }
-
-    irq = atoi(argv[2]);
-    ret = lynq_irq_install(irq, irq_test_handler, 1);
+    irq = atoi(argv[1]);
+    trig_type = atoi(argv[2]);
+    ret = lynq_irq_install(irq, irq_test_handler, trig_type);
     if(ret != 0)
     {
         printf("lynq_irq_install fail\n");
+        return 0;
     }
     else
     {
         printf("lynq_irq_install success\n");
+        line = irq;
     }
 
-    if(strcmp(argv[1],"-t") == 0)
+    while(1)
     {
-        if(argv[3] != NULL)
+        printUsage();
+        memset(cmd,0,sizeof(cmd));
+        fgets(cmd, sizeof(cmd), stdin);
+        printf("cmd:%s\n",cmd);
+        cmd1 = strtok(cmd, " ");
+        cmd2 = strtok(NULL, " ");
+        if(strcmp(cmd1, CMD_SET_WAKE) == 0)
         {
-            trig_type = atoi(argv[3]);
-            ret = lynq_irq_set_type(irq, trig_type);
-            if(ret < 0)
+            if(cmd2 == NULL)
             {
-                printf("lynq_irq_set_type fail\n");
+                printf("wake_state is NULL\n");
+                break;
             }
-            else
-            {
-                printf("lynq_irq_set_type success\n");
-            }
-        }
-    }
-    else if (strcmp(argv[1],"-sw") == 0)
-    {
-        if(argv[3] != NULL)
-        {
-            en = atoi(argv[3]);
+            en = atoi(cmd2);
             ret = lynq_irq_set_wake(irq, en);
             if(ret < 0)
             {
@@ -84,30 +94,66 @@
                 printf("ret=%d\n", ret);
             }
         }
-    }
-    else if (strcmp(argv[1],"-gw") == 0)
-    {
-        ret = lynq_irq_get_wake(irq);
-        printf("lynq_irq_get_wake ret %d\n", ret);
-    }
-    else
-    {
-        printf("wrong input format, please -h \n");
-        return -1;
+        else if(strcmp(cmd1, CMD_GET_WAKE) == 0)
+        {
+            ret = lynq_irq_get_wake(irq);
+            printf("lynq_irq_get_wake ret %d\n", ret);
+        }
+        else if(strcmp(cmd1, CMD_SET_TYPE) == 0)
+        {
+            if(cmd2 == NULL)
+            {
+                printf("trig_type is NULL\n");
+                break;
+            }
+            trig_type = atoi(cmd2);
+            ret = lynq_irq_set_type(line, trig_type);
+            if(ret < 0)
+            {
+                printf("lynq_irq_set_type fail\n");
+            }
+            else
+            {
+                printf("lynq_irq_set_type success\n");
+            }
+        }
+        else if(strcmp(cmd1, CMD_GET_TYPE) == 0)
+        {
+            ret = lynq_irq_get_type(irq);
+            printf("lynq_irq_get_type ret %d\n", ret);
+        }
+        else if(strcmp(cmd1, CMD_UNINSTALL) == 0)
+        {
+            ret = lynq_irq_uninstall(irq);
+            if(ret != 0)
+            {
+                printf("lynq_irq_uninstall fail\n");
+            }
+            else
+            {
+                printf("lynq_irq_uninstall success\n");
+            }
+        }
+        else if(strcmp(cmd1, CMD_QUIT_TEST) == 0)
+        {
+            ret = lynq_irq_uninstall(irq);
+            if(ret != 0)
+            {
+                printf("lynq_irq_uninstall fail\n");
+            }
+            else
+            {
+                printf("lynq_irq_uninstall success\n");
+                break;
+            }
+        }
+        else
+        {
+            printf("wrong input format\n");
+        }
     }
 
-    ret = lynq_irq_uninstall(irq);
-    if(ret != 0)
-    {
-        printf("lynq_irq_uninstall fail\n");
-    }
-    else
-    {
-        printf("lynq_irq_uninstall success\n");
-    }
-        
     return 0;
-
 }
 
 
diff --git a/cap/zx297520v3/sources/meta-zxic/recipes-kernel/linux/files/zx297520v3/linux-5_10-vehicle_dc_ref-normal-defconfig b/cap/zx297520v3/sources/meta-zxic/recipes-kernel/linux/files/zx297520v3/linux-5_10-vehicle_dc_ref-normal-defconfig
index 6edd109..8bc48e6 100755
--- a/cap/zx297520v3/sources/meta-zxic/recipes-kernel/linux/files/zx297520v3/linux-5_10-vehicle_dc_ref-normal-defconfig
+++ b/cap/zx297520v3/sources/meta-zxic/recipes-kernel/linux/files/zx297520v3/linux-5_10-vehicle_dc_ref-normal-defconfig
@@ -1975,12 +1975,12 @@
 # CONFIG_SND_SOC_ZX29_TI3100 is not set
 #dongyu@modify for codec start
 # CONFIG_SND_SOC_ZX29_NAU8810 is not set
-CONFIG_SND_SOC_ZX29_TI3104=y
+# CONFIG_SND_SOC_ZX29_TI3104 is not set
 # CONFIG_SND_SOC_ZX29_ES8374 is not set
 # CONFIG_SND_SOC_ZX29_ES8312 is not set
 # CONFIG_SND_SOC_ZX29_AK4940 is not set
 # CONFIG_SND_SOC_ZX29_MAX9867 is not set
-# CONFIG_SND_SOC_ZX29_ES8311 is not set
+CONFIG_SND_SOC_ZX29_ES8311=y
 CONFIG_SND_SOC_ZX_VOICE=y
 CONFIG_SND_SOC_ZX297520V3=y
 CONFIG_SND_SOC_ZX_I2S=y
@@ -1988,9 +1988,9 @@
 # CONFIG_SND_SOC_ZX_TDM is not set
 # CONFIG_SND_SOC_TLV320AIC31XX is not set
 # CONFIG_SND_SOC_NAU8810 is not set
-CONFIG_SND_SOC_TLV320AIC3X=y
+# CONFIG_SND_SOC_TLV320AIC3X is not set
 # CONFIG_SND_SOC_MAX9867 is not set
-# CONFIG_SND_SOC_ES8311 is not set
+CONFIG_SND_SOC_ES8311=y
 #dongyu@modify for codec end
 CONFIG_SND_EXTRA_CTRL=y
 CONFIG_USE_TOP_I2S0=y
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-atcid/zxic_at_func_wrapper.cpp b/cap/zx297520v3/src/lynq/framework/lynq-atcid/zxic_at_func_wrapper.cpp
index 3037e62..99794fb 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-atcid/zxic_at_func_wrapper.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-atcid/zxic_at_func_wrapper.cpp
@@ -29,7 +29,7 @@
 template <int n>
 void zxic_at_callback(unsigned char * input, unsigned char * output)
 {
-    char org_cmd[64] = {0};
+    char *org_cmd = NULL;
     if (input == NULL || output == NULL)
     {
         ALOGE("zxic_at_callback invalid params %p-%p \n", input, output);
@@ -37,6 +37,12 @@
     }
     strcpy((char*)output, "\r\n");
     struct callback_entry *pEntry = g_all_reg_entry[n];
+	org_cmd = new char [strlen(input) + 32];
+	if (org_cmd == NULL)
+	{
+		strcat(output, "+CME ERROR: 100\r\n");
+	}
+	org_cmd[0] = '\0';
     strcat(org_cmd, pEntry->at_prefix);
     strcat(org_cmd, (char *)input);
     pEntry->plugin_entry->output_buffer = (char*)output;
@@ -44,6 +50,7 @@
     pEntry->plugin_entry->atsvc_incb(org_cmd, strlen(org_cmd));
     pEntry->plugin_entry->output_buffer = NULL;
     ALOGD("zxic_at_callback output -- %s \n", output);
+	delete [] org_cmd;
     //return 0;
 }
 
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-irq/include/lynq-irq.h b/cap/zx297520v3/src/lynq/lib/liblynq-irq/include/lynq-irq.h
index 298e75a..36fd9ed 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-irq/include/lynq-irq.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-irq/include/lynq-irq.h
@@ -6,6 +6,9 @@
 extern "C" {
 #endif
 
+
+int line_gpio[15]={-1,48,49,50,51,52,53,54,119,128,129,-1,131,-1,125};//this is the line match gpio
+
 typedef void (*irq_handler)(void);
 
 int lynq_irq_install(int line, irq_handler irq_handler, int trig_type);
@@ -14,6 +17,8 @@
 
 int lynq_irq_set_type(int line, int trig_type);
 
+int lynq_irq_get_type(int line);
+
 int lynq_irq_set_wake(int line, int en);
 
 int lynq_irq_get_wake(int line);
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-irq/lynq-irq.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-irq/lynq-irq.cpp
index 566961e..a48090e 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-irq/lynq-irq.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-irq/lynq-irq.cpp
@@ -12,7 +12,6 @@
 extern "C" {
 #endif
 
-#define USER_LOG_TAG "LYNQ_IRQ"
 
 /*****************************************
 * @brief:lynq_irq_install
@@ -27,8 +26,10 @@
 int lynq_irq_install(int line, irq_handler irq_test_handler, int trig_type)
 {
     int ret;
-    LYLOGSET(LOG_INFO);
-    LYLOGEINIT(USER_LOG_TAG);
+    if(trig_type < 0)
+    {
+        return -1;
+    }
     ret = sc_irq_install(line, irq_test_handler, trig_type);
     if (ret != 0)
     {
@@ -52,8 +53,6 @@
 int lynq_irq_uninstall(int line)
 {
     int ret;
-    LYLOGSET(LOG_INFO);
-    LYLOGEINIT(USER_LOG_TAG);
     ret = sc_irq_uninstall(line);
     if (ret != 0)
     {
@@ -77,8 +76,10 @@
 int lynq_irq_set_type(int line, int trig_type)
 {
     int ret;
-    LYLOGSET(LOG_INFO);
-    LYLOGEINIT(USER_LOG_TAG);
+    if(trig_type < 0)
+    {
+        return -1;
+    }
     ret = sc_irq_set_type(line, trig_type);
     if (ret < 0)
     {
@@ -89,6 +90,29 @@
 
 }
 
+/*****************************************
+* @brief:lynq_irq_get_type
+* @param count [IN]:1
+* @param sum [OUT]:NA
+* @return :success >= 0, failed other
+* @todo:NA
+* @see:NA
+* @warning:NA
+******************************************/
+int lynq_irq_get_type(int line)
+{
+    int ret;
+    int trig_type;
+    ret = sc_irq_get_type(line, &trig_type);
+    if (ret != 0)
+    {
+        LYINFLOG("get_type failed, ret:%d\n", ret);
+        return ret;
+    }
+    LYINFLOG("get_type readback(%d)\n", trig_type);
+    return trig_type;
+}
+
 
 /*****************************************
 * @brief:lynq_irq_set_wake
@@ -102,8 +126,6 @@
 int lynq_irq_set_wake(int line, int en)
 {
     int ret;
-    LYLOGSET(LOG_INFO);
-    LYLOGEINIT(USER_LOG_TAG);
     ret = sc_irq_set_wake(line, en);
     if (ret < 0)
     {
@@ -126,8 +148,6 @@
 {
     int ret;
     int en;
-    LYLOGSET(LOG_INFO);
-    LYLOGEINIT(USER_LOG_TAG);
     ret = sc_irq_get_wake(line, &en);
     if (ret != 0)
     {
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-pinctrl.dtsi b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-pinctrl.dtsi
index f9f558d..1a6ab53 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-pinctrl.dtsi
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-pinctrl.dtsi
@@ -288,97 +288,97 @@
 	sc_ext_int0: sc_ext_int0 {
 		pins = "EXT_INT0";
 		function = "EXT_INT0";
-		bias-disable;
+		//bias-disable; jb.qi changed for pullset fail on 20231107
 	};
 
 	sc_ext_int1: sc_ext_int1 {
 		pins = "EXT_INT1";
 		function = "EXT_INT1";
-		bias-disable;
+		//bias-disable; jb.qi changed for pullset fail on 20231107
 	};
 
 	sc_ext_int2: sc_ext_int2 {
 		pins = "EXT_INT2";
 		function = "EXT_INT2";
-		bias-disable;
+		//bias-disable; jb.qi changed for pullset fail on 20231107
 	};
 
 	sc_ext_int3: sc_ext_int3 {
 		pins = "EXT_INT3";
 		function = "EXT_INT3";
-		bias-disable;
+		//bias-disable; jb.qi changed for pullset fail on 20231107
 	};
 
 	sc_ext_int4: sc_ext_int4 {
 		pins = "EXT_INT4";
 		function = "EXT_INT4";
-		bias-disable;
+		//bias-disable; jb.qi changed for pullset fail on 20231107
 	};
 
 	sc_ext_int5: sc_ext_int5 {
 		pins = "EXT_INT5";
 		function = "EXT_INT5";
-		bias-disable;
+		//bias-disable; jb.qi changed for pullset fail on 20231107
 	};
 
 	sc_ext_int6: sc_ext_int6 {
 		pins = "EXT_INT6";
 		function = "EXT_INT6";
-		bias-disable;
+		//bias-disable; jb.qi changed for pullset fail on 20231107
 	};
 
 	sc_ext_int7: sc_ext_int7 {
 		pins = "EXT_INT7";
 		function = "EXT_INT7";
-		bias-disable;
+		//bias-disable; jb.qi changed for pullset fail on 20231107
 	};
 
 	sc_ext_int8: sc_ext_int8 {
 		pins = "EXT_INT8";
 		function = "EXT_INT8";
-		bias-disable;
+		//bias-disable; jb.qi changed for pullset fail on 20231107
 	};
 
 	sc_ext_int9: sc_ext_int9 {
 		pins = "EXT_INT9";
 		function = "EXT_INT9";
-		bias-disable;
+		//bias-disable; jb.qi changed for pullset fail on 20231107
 	};
 
 	sc_ext_int10: sc_ext_int10 {
 		pins = "GPIO129";   /*jb.qi add for EXT_INIT10 success*/
 		function = "EXT_INT10";
-		bias-disable;
+		//bias-disable; jb.qi changed for pullset fail on 20231107
 	};
 
 	sc_ext_int11: sc_ext_int11 {
 		pins = "EXT_INT11";
 		function = "EXT_INT11";
-		bias-disable;
+		//bias-disable; jb.qi changed for pullset fail on 20231107
 	};
 
 	sc_ext_int12: sc_ext_int12 {
 		pins = "GPIO131";  //"EXT_INT12";
 		function = "EXT_INT12";
-		bias-disable;
+		//bias-disable; jb.qi changed for pullset fail on 20231107
 	};
 
 	sc_ext_int13: sc_ext_int13 {
 		pins = "EXT_INT13";
 		function = "EXT_INT13";
-		bias-disable;
+		//bias-disable; jb.qi changed for pullset fail on 20231107
 	};
 
 	sc_ext_int14: sc_ext_int14 {
 		pins = "EXT_INT14";
 		function = "EXT_INT14";
-		bias-disable;
+		//bias-disable; jb.qi changed for pullset fail on 20231107
 	};
 
 	sc_ext_int15: sc_ext_int15 {
 		pins = "EXT_INT15";
 		function = "EXT_INT15";
-		bias-disable;
+		//bias-disable; jb.qi changed for pullset fail on 20231107
 	};
 
 };
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-vehicle_dc_ref.dts b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-vehicle_dc_ref.dts
index da48fcc..6f7cf69 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-vehicle_dc_ref.dts
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3-vehicle_dc_ref.dts
@@ -130,11 +130,11 @@
 //	status = "okay";
 };
 &codec_ti3104 {
-	status = "okay";
+//	status = "okay";
 };	
 &zx29_ti3104 {
 	pinctrl-0 = <&i2s0_pins>;
-	status = "okay";
+//	status = "okay";
 };
 &codec_nau8810 {
 //	status = "okay";
@@ -155,11 +155,11 @@
 //	status = "okay";
 };
 &codec_es8311 {
-//	status = "okay";
+	status = "okay";
 };	
 &zx29_es8311 {
 	pinctrl-0 = <&i2s0_pins>;
-//	status = "okay";
+	status = "okay";
 };
 &gmac {
     port-nums = <1>;
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/ethernet/zte/zx29_gmac.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/ethernet/zte/zx29_gmac.c
index 05a5b0b..7bc3ed0 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/ethernet/zte/zx29_gmac.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/ethernet/zte/zx29_gmac.c
@@ -1357,11 +1357,45 @@
     return 0;

 }

 

+/*jb.qi add for gamc power down on 20231116 start*/

+

+extern int gmac_power = 1;

+int gmac_power_flag = 0;

+

+ssize_t gmac_power_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)

+{

+    int val = 0;

+    int ret;

+    ret = sscanf(buf, "%d", &val);

+    if(ret < 1)

+    {

+        printk(KERN_INFO "gmac: failed ti read user buf, ret=%d, input %d\n", ret,val);

+        return count;

+    }

+    gmac_power = val;

+    gpio_direction_output(gmac_power_flag, val);

+    return count;

+}

+

+ssize_t gmac_power_show(struct device *dev, struct device_attribute *attr, char *buf)

+{

+    if(gmac_power)

+        memcpy(buf, "on",3);

+    else

+        memcpy(buf, "off", 4);

+

+    printk("gmac_power %s\n", buf);

+    return 0;

+

+}

+/*jb.qi add for gamc power down on 20231116 end */

+

 static DEVICE_ATTR(gmac_test, 0664, show_fun, store_fun);
 static DEVICE_ATTR(mdio_test, 0664, mdio_show, mdio_store);

 static DEVICE_ATTR(free_mdio, 0664, free_mdio_show, free_mdio_store);

 static DEVICE_ATTR(debug_on, 0664, debug_on_show, debug_on_store);

-
+static DEVICE_ATTR(gmac_power, 0664, gmac_power_show, gmac_power_store);//jb.qi add for gamc power down on 20231116

+

 static int zx29_gmac_probe(struct platform_device *pdev)

 {

     struct zx29_gmac_dev *prv = NULL;

@@ -1387,6 +1421,7 @@
 	device_create_file(&pdev->dev, &dev_attr_mdio_test);

 	device_create_file(&pdev->dev, &dev_attr_free_mdio);

 	device_create_file(&pdev->dev, &dev_attr_debug_on);

+    device_create_file(&pdev->dev, &dev_attr_gmac_power);//jb.qi add for gamc power down on 20231116

 

 	prv = netdev_priv(ndev);

 	memset(prv, 0, sizeof(*prv));

@@ -1422,7 +1457,7 @@
 	gpio_direction_output(prv->gpio_power[1], 1);

 	mdelay(15);

 #endif    

-
+    gmac_power_flag = prv->gpio_power[0];

 	SET_NETDEV_DEV(ndev, &pdev->dev); //if not, will panic

 	

 	base = devm_platform_ioremap_resource(pdev, 0);

@@ -1630,7 +1665,8 @@
 		device_remove_file(&pdev->dev, &dev_attr_gmac_test);

 	    device_remove_file(&pdev->dev, &dev_attr_mdio_test);

 	    device_remove_file(&pdev->dev, &dev_attr_free_mdio);

-	    device_remove_file(&pdev->dev, &dev_attr_debug_on);		

+	    device_remove_file(&pdev->dev, &dev_attr_debug_on);

+        device_remove_file(&pdev->dev, &dev_attr_gmac_power);//jb.qi add for gamc power down on 20231116

 	}

 	return 0;

 }