Merge "[Bugfix][T106BUG-567]add gpio suspend/resume power management"
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 5a5eb0a..db91206 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
@@ -23,8 +23,19 @@
 		bias-pull-up;
 //		input-schmitt-disable;
 	};
+//xf.li@20240327 modify for T106BUG-567 start
+	rmii_active: rmii_active {
+		pins ="RMII_TXEN", "RMII_RXEN", "RMII_RXD0", "RMII_RXD1", "RMII_TXD0", "RMII_TXD1";
+		function = "RMII";
+		bias-disabled;
+	};
 
-
+	rmii_sleep: rmii_sleep {
+		pins = "RMII_TXEN", "RMII_RXEN", "RMII_RXD0", "RMII_RXD1", "RMII_TXD0", "RMII_TXD1";
+    		function = "BGPIO";
+		bias-pull-down;
+		input-enable;
+	};
 
 i2c0_active: i2c0_active {
     pins = "I2C0_SCL", "I2C0_SDA";
@@ -36,8 +47,8 @@
 i2c0_sleep: i2c0_sleep {
     pins = "I2C0_SCL", "I2C0_SDA";
     function = "BGPIO";
-
-    bias-disabled;
+    input-enable;
+    bias-pull-down;
 };
 
 i2c1_active: i2c1_active {
@@ -50,10 +61,10 @@
 i2c1_sleep: i2c1_sleep {
     pins = "I2C1_SCL", "I2C1_SDA";
     function = "BGPIO";
-
-    bias-disabled;
+    input-enable;
+    bias-pull-down;
 };
-	
+//xf.li@20240327 modify for T106BUG-567 end
 	sd1_gpio: sd1_gpio {
 		pins = "SD1_CMD", "SD1_D0";
 		function = "BGPIO";
@@ -166,9 +177,12 @@
 		pins = "UART0_RXD", "UART0_TXD";
 		function = "UART0";
 	};
+//xf.li@20240327 modify for T106BUG-567 start
 	uart0_sleep: uart0_sleep {
 		pins = "UART0_RXD", "UART0_TXD";
 		function = "BGPIO";
+		input-enable;
+		bias-pull-down;
 	};
 	uart1_active: uart1_active {
 		pins = "UART1_RXD", "UART1_TXD";
@@ -185,13 +199,15 @@
 	uart2_sleep: uart2_sleep {
 		pins = "EXT_INT10", "EXT_INT11";
 		function = "BGPIO";
+		input-enable;
+		bias-pull-down;
 	};
-	
+//xf.li@20240327 modify for T106BUG-567 end
 	codec_reset_pins:codec_reset_pins {
 		pins = "EXT_INT10", "EXT_INT11";
 		function = "BGPIO";
 	};
-
+//xf.li@20240327 modify for T106BUG-567 start
 	ssp0_active:ssp0_active {
 		pins = "SSP0_CLK","SSP0_RXD","SSP0_TXD";
 		function = "SSP0";
@@ -200,9 +216,16 @@
 		pins = "SSP0_CLK","SSP0_RXD","SSP0_TXD";
 		function = "BGPIO";
 	};
-	ssp0_cs_gpio:ssp0_cs_gpio {
+	ssp0_cs_gpio_active:ssp0_cs_gpio_active {
 		pins = "SSP0_CS";
 		function = "BGPIO";
+		bias-pull-up;
+	};
+	ssp0_cs_gpio_sleep:ssp0_cs_gpio_sleep {
+		pins = "SSP0_CS";
+		function = "BGPIO";
+		bias-pull-down;
+		input-enable;
 	};
 	ssp0_cs_func:ssp0_cs_func {
 		pins = "SSP0_CS";
@@ -217,15 +240,22 @@
 		pins = "CAM_SPI_CLK","CAM_SPI_D0","CAM_SPI_D1";
 		function = "BGPIO";
 	};
-	ssp1_cs_gpio:ssp1_cs_gpio {
+	ssp1_cs_gpio_active:ssp1_cs_gpio_active {
 		pins = "CAM_SPI_CS";
 		function = "BGPIO";
+		bias-pull-up;
+	};
+	ssp1_cs_gpio_sleep:ssp1_cs_gpio_sleep {
+		pins = "CAM_SPI_CS";
+		function = "BGPIO";
+		bias-pull-down;
+		input-enable;
 	};
 	ssp1_cs_func:ssp1_cs_func {
 		pins = "CAM_SPI_CS";
 		function = "CAM_SPI";
 	};
-
+//xf.li@20240327 modify for T106BUG-567 end
 	spidev0_ex_gpio_pins:gpio129 {
 		pins = "GPIO129";
 		function = "BGPIO";	
@@ -251,17 +281,19 @@
 		input-schmitt-disable;
 	};
 	
-
+//xf.li@20240327 modify for T106BUG-567 start
 	i2s0_sleep: i2s0_sleep {
 		pins = "I2S0_WS","I2S0_CLK","I2S0_DIN","I2S0_DOUT";
 		function = "BGPIO";
-		bias-disable;
+		input-enable;
+		bias-pull-down;
 	};		
 
 	i2s1_sleep: i2s1_sleep {
 		pins = "I2S1_WS","I2S1_CLK","I2S1_DIN","I2S1_DOUT";
 		function = "BGPIO";
-		bias-disable;
+		input-enable;
+		bias-pull-down;
 	};		
 	tdm_pins: tdm_pins {
 		pins = "I2S0_WS","I2S0_CLK","I2S0_DIN","I2S0_DOUT";
@@ -274,9 +306,10 @@
 	tdm_sleep: tdm_sleep {
 		pins = "I2S0_WS","I2S0_CLK","I2S0_DIN","I2S0_DOUT";
 		function = "BGPIO";
-		bias-disable;
+		input-enable;
+		bias-pull-down;
 	};
-	
+//xf.li@20240327 modify for T106BUG-567 end
 	clk0_func_pins: clk0_func_pins 
 	{		
 		pins = "CLK_OUT0";		
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 ef16a4e..4aa7dd9 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
@@ -164,9 +164,10 @@
 &gmac {
     port-nums = <1>;
     rmii-ports = <1>;
-    pinctrl-names = "state0";
-	pinctrl-0 = <&rmii_clki_pins>;
-	
+//xf.li@20240327 modify for T106BUG-567 start
+    //pinctrl-names = "state0";
+	//pinctrl-0 = <&rmii_clki_pins>;
+//xf.li@20240327 modify for T106BUG-567 end
     gpios = <&bgpio 83 GPIO_ACTIVE_HIGH>,
             <&bgpio 63 GPIO_ACTIVE_HIGH>;
     status = "okay";
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi
index 6c69adc..c52f699 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/arch/arm/boot/dts/zx297520v3.dtsi
@@ -527,7 +527,11 @@
 			interrupts = <GIC_SPI GMAC_INT IRQ_TYPE_LEVEL_HIGH>;
 			phy-mode = "rmii";
 			port-mask = <0x00000000>;
-			
+//xf.li@20240327 modify for T106BUG-567 start
+			pinctrl-names = "default", "sleep";
+			pinctrl-0 = <&rmii_active>;
+			pinctrl-1 = <&rmii_sleep>;
+//xf.li@20240327 modify for T106BUG-567 end
 			status = "disabled";
 		};
 		
@@ -626,11 +630,12 @@
 			clock-frequency = <52000000>;
 			clocks = <&clkc SSP0_WCLK>, <&clkc SSP0_PCLK>;
 			clock-names = "work_clk", "apb_clk";
-			pinctrl-names = "default","sleep","cs_gpio","cs_func";
+			pinctrl-names = "default","sleep","cs_gpio_active","cs_func","cs_gpio_sleep";
 			pinctrl-0 = <&ssp0_active>; 
 			pinctrl-1 = <&ssp0_sleep>;
-			pinctrl-2 = <&ssp0_cs_gpio>;
+			pinctrl-2 = <&ssp0_cs_gpio_active>;
 			pinctrl-3 = <&ssp0_cs_func>;
+			pinctrl-4 = <&ssp0_cs_gpio_sleep>;
 			gpios = <&bgpio 25 GPIO_ACTIVE_HIGH>,
 					<&bgpio 26 GPIO_ACTIVE_HIGH>,/*clk*/
 					<&bgpio 28 GPIO_ACTIVE_HIGH>,/*tx*/
@@ -676,11 +681,12 @@
 			clock-frequency = <52000000>;
 			clocks = <&clkc SSP1_WCLK>, <&clkc SSP1_PCLK>;
 			clock-names = "work_clk", "apb_clk";
-			pinctrl-names = "default","sleep","cs_gpio","cs_func";
+			pinctrl-names = "default","sleep","cs_gpio_active","cs_func","cs_gpio_sleep";
 			pinctrl-0 = <&ssp1_active>; 
 			pinctrl-1 = <&ssp1_sleep>;
-			pinctrl-2 = <&ssp1_cs_gpio>;
+			pinctrl-2 = <&ssp1_cs_gpio_active>;
 			pinctrl-3 = <&ssp1_cs_func>;
+			pinctrl-4 = <&ssp1_cs_gpio_sleep>;
 			gpios = <&bgpio 87 GPIO_ACTIVE_LOW>,
 					<&bgpio 88 GPIO_ACTIVE_LOW>,/*clk*/
 					<&bgpio 90 GPIO_ACTIVE_LOW>,/*tx*/
@@ -850,8 +856,15 @@
 		};	
         zx29_es8311: zx29_es8311{
 			compatible = "zxic,zx29_es8311";
-			pinctrl-names = "top_i2s";
+//xf.li@20240327 modify for T106BUG-567 start
+			pinctrl-names = "top_i2s0","top_i2s1","top_tdm","topi2s0_sleep","topi2s1_sleep","toptdm_sleep";
 			pinctrl-0 = <&i2s0_pins>;
+			pinctrl-1 = <&i2s1_pins>;
+			pinctrl-2 = <&tdm_pins>;
+			pinctrl-3 = <&i2s0_sleep>;
+			pinctrl-4 = <&i2s1_sleep>;
+			pinctrl-5 = <&tdm_sleep>;
+//xf.li@20240327 modify for T106BUG-567 end
 			reg = <0x0 0x00140000 0x0 0x00001000>;
 			reg-names = "soc_sys";
 
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/i2c/busses/i2c-zx29.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/i2c/busses/i2c-zx29.c
index b8fce94..2d52e80 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/i2c/busses/i2c-zx29.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/i2c/busses/i2c-zx29.c
@@ -1897,21 +1897,37 @@
 }

 

 

-

+//xf.li@20240327 modify for T106BUG-567 start

 #ifdef CONFIG_PM

 static int zx29_i2c_suspend(struct platform_device *pdev, pm_message_t state)

 {

-//    pinctrl_pm_select_sleep_state(&pdev->dev);

+	printk("LYNQ: in zx29_i2c_suspend");

+	if(pdev == NULL)

+		return -1;

+	if(pdev && &pdev->dev)

+	{

+		printk("LYNQ: select sleep state");

+		pinctrl_pm_select_sleep_state(&pdev->dev);

+	}

+

     return 0;

 };

 

 static int zx29_i2c_resume(struct platform_device *pdev)

 {

-//    pinctrl_pm_select_default_state(&pdev->dev);

+	printk("LYNQ: in zx29_i2c_resume");

+	if(pdev == NULL)

+		return -1;

+	if(pdev && &pdev->dev)

+	{

+		printk("LYNQ: select default state");

+		pinctrl_pm_select_default_state(&pdev->dev);

+	}

+

     return 0;

 };

 #endif

-

+//xf.li@20240327 modify for T106BUG-567 end

 

 static const struct of_device_id zx29_i2c_match[] = {

     {.compatible = "zte,zx29_i2c"},

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 fd87356..2db6217 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
@@ -24,7 +24,7 @@
 #include <linux/pinctrl/consumer.h>

 #include <linux/gpio.h>

 #include <linux/of_gpio.h>

-#include <linux/device.h>
+#include <linux/device.h>

 #include "zx29_gmac.h"

 

 #define gmac_printk(_format, _args...)		do{printk(KERN_INFO"gmac," _format "\n",##_args);}while(0)

@@ -897,7 +897,7 @@
 	gmac = (unsigned *)ndev->base_addr;

 	

 	enum of_gpio_flags flags;

-    unsigned long flag;
+    unsigned long flag;

 	int gpio = 0;

 	int ret = 0;

 	

@@ -905,7 +905,7 @@
 	if (ndev && !priv->stopped) {

 		if (netif_running(ndev)) {

 			

-			spin_lock_irqsave(&priv->lock, flag);
+			spin_lock_irqsave(&priv->lock, flag);

             netif_stop_queue(ndev);

 			netif_carrier_off(ndev);

 			priv->stopped = 1;

@@ -918,12 +918,12 @@
 			gpio_direction_output(priv->gpio_power[0], 0);

 			

 			gmac_stop((void*)ndev->base_addr); 

-            spin_unlock_irqrestore(&priv->lock, flag);
+            spin_unlock_irqrestore(&priv->lock, flag);

 		

 //			netif_device_detach(ndev);

 		}

-        pm_relax(&pdev->dev);
-       // printk("[%s] sleep\n");
+        pm_relax(&pdev->dev);

+       // printk("[%s] sleep\n");

     }

 #endif

 	//printk("[%s] exit\n", __func__);

@@ -951,7 +951,7 @@
 	    pm_stay_awake(&pdev->dev);

 		if( netif_running(ndev)) {			

             printk("[%s] enter\n", __func__);

-			spin_lock_irqsave(&priv->lock, flag);
+			spin_lock_irqsave(&priv->lock, flag);

 			gpio_direction_output(priv->gpio_power[0], 1);

 

 			base = base_clk;

@@ -960,8 +960,8 @@
 			base = base_phy_release;

 			gmac_phy_release();

 

-		    mdelay(500); //icplus ping need
-
+		    mdelay(500); //icplus ping need

+

             priv->phydev->drv->config_init(priv->phydev);

 			gmac_hw_init(ndev);

 

@@ -972,7 +972,7 @@
             hrtimer_start(priv->timer, ktime_set(0, GTIMER_INTERVAL * 1000), HRTIMER_MODE_REL);

 #endif 

 			priv->stopped = 0;

-            spin_unlock_irqrestore(&priv->lock, flag);
+            spin_unlock_irqrestore(&priv->lock, flag);

             printk("[%s] enter\n", __func__);

 //			netif_device_attach(ndev);	  	

 		}

@@ -1153,6 +1153,9 @@
 #endif

     	}

     }

+//xf.li@20240327 modify for T106BUG-567 start

+    pinctrl_pm_select_sleep_state(&pdev->dev);

+//xf.li@20240327 modify for T106BUG-567 end

     return 0;

 }

 

@@ -1167,6 +1170,9 @@
 	gmac = (unsigned *)ndev->base_addr;

     unsigned long flag = 0;

 

+//xf.li@20240327 modify for T106BUG-567 start

+    pinctrl_pm_select_default_state(&pdev->dev);

+//xf.li@20240327 modify for T106BUG-567 end

     if(ndev) {

     	if(netif_running(ndev)) {

 //        	gmac_start((void*)ndev->base_addr);

@@ -1225,60 +1231,60 @@
 	.ndo_set_mac_address = zx29_gmac_set_mac_address,

 };

 

-
-
-ssize_t show_fun(struct device *dev, struct device_attribute *attr, char *buf)
-{
+

+

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

+{

 	struct platform_device *pdev	= to_platform_device(dev);

     struct net_device 	*ndev		= platform_get_drvdata(pdev);

-    int status = 0;
-    volatile unsigned *gmac = (unsigned *)ndev->base_addr;
-    struct zx29_gmac_dev *priv = (struct zx29_gmac_dev *)netdev_priv(ndev);
-    printk("MAC(1000) :0x%x\n", MAC(0x1000));
-    printk("MAC(1004) :0x%x\n", MAC(0x1004));
-    printk("MAC(1008) :0x%x\n", MAC(0x1008));
-    printk("MAC(100c) :0x%x\n", MAC(0x100c));
-    printk("MAC(1010) :0x%x\n", MAC(0x1010));
-    printk("MAC(1014) int status:0x%x\n", MAC(0x1014));
-    printk("MAC(1018) :0x%x\n", MAC(0x1018));
-    printk("MAC(101c) :0x%x\n", MAC(0x101c));
-    printk("MAC(0000) :0x%x\n", MAC(0x0000));
-    printk("MAC(0004) :0x%x\n", MAC(0x0004));
-    printk("MAC(0010) :0x%x\n", MAC(0x0010));
-
-    status = mdiobus_read(priv->phydev->mdio.bus, 21, 1);
-    printk("phy status:0x%x\n", status);
-    status = mdiobus_read(priv->phydev->mdio.bus, 0, 1);
-    printk("phy status port0:0x%x\n", status);
-    status = mdiobus_read(priv->phydev->mdio.bus, 1, 1);
-    printk("phy status port1:0x%x\n", status);
-    status = mdiobus_read(priv->phydev->mdio.bus, 2, 1);
-    printk("phy status port2:0x%x\n", status);
-    status = mdiobus_read(priv->phydev->mdio.bus, 3, 1);
-    printk("phy status port3:0x%x\n", status);
-    status = mdiobus_read(priv->phydev->mdio.bus, 4, 1);
-    printk("phy status port4:0x%x\n", status);
-
-    status = mdiobus_read(priv->phydev->mdio.bus, 21, 20);
-    status |= 0x4;
-    mdiobus_write(priv->phydev->mdio.bus, 21, 20, status);
-
-    status = mdiobus_read(priv->phydev->mdio.bus, 21, 21);
-    printk("phy status loop port:0x%x\n", status);
-
-
-    return 0;
-}
-
-ssize_t store_fun(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
-{
+    int status = 0;

+    volatile unsigned *gmac = (unsigned *)ndev->base_addr;

+    struct zx29_gmac_dev *priv = (struct zx29_gmac_dev *)netdev_priv(ndev);

+    printk("MAC(1000) :0x%x\n", MAC(0x1000));

+    printk("MAC(1004) :0x%x\n", MAC(0x1004));

+    printk("MAC(1008) :0x%x\n", MAC(0x1008));

+    printk("MAC(100c) :0x%x\n", MAC(0x100c));

+    printk("MAC(1010) :0x%x\n", MAC(0x1010));

+    printk("MAC(1014) int status:0x%x\n", MAC(0x1014));

+    printk("MAC(1018) :0x%x\n", MAC(0x1018));

+    printk("MAC(101c) :0x%x\n", MAC(0x101c));

+    printk("MAC(0000) :0x%x\n", MAC(0x0000));

+    printk("MAC(0004) :0x%x\n", MAC(0x0004));

+    printk("MAC(0010) :0x%x\n", MAC(0x0010));

+

+    status = mdiobus_read(priv->phydev->mdio.bus, 21, 1);

+    printk("phy status:0x%x\n", status);

+    status = mdiobus_read(priv->phydev->mdio.bus, 0, 1);

+    printk("phy status port0:0x%x\n", status);

+    status = mdiobus_read(priv->phydev->mdio.bus, 1, 1);

+    printk("phy status port1:0x%x\n", status);

+    status = mdiobus_read(priv->phydev->mdio.bus, 2, 1);

+    printk("phy status port2:0x%x\n", status);

+    status = mdiobus_read(priv->phydev->mdio.bus, 3, 1);

+    printk("phy status port3:0x%x\n", status);

+    status = mdiobus_read(priv->phydev->mdio.bus, 4, 1);

+    printk("phy status port4:0x%x\n", status);

+

+    status = mdiobus_read(priv->phydev->mdio.bus, 21, 20);

+    status |= 0x4;

+    mdiobus_write(priv->phydev->mdio.bus, 21, 20, status);

+

+    status = mdiobus_read(priv->phydev->mdio.bus, 21, 21);

+    printk("phy status loop port:0x%x\n", status);

+

+

+    return 0;

+}

+

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

+{

 	struct platform_device *pdev	= to_platform_device(dev);

     struct net_device 	*ndev		= platform_get_drvdata(pdev);

-    printk("[%s]", __func__);    
-    return 1;
-}
-
-
+    printk("[%s]", __func__);    

+    return 1;

+}

+

+

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

 {

 	struct platform_device *pdev	= to_platform_device(dev);

@@ -1695,7 +1701,7 @@
 

 /*zw.wang add for switching the primary/secondary mode of gmac on 20240118 end */

 

-static DEVICE_ATTR(gmac_test, 0664, show_fun, store_fun);
+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);

@@ -1723,7 +1729,7 @@
 	if (!ndev)

 		return -ENOMEM;

 

-    device_create_file(&pdev->dev, &dev_attr_gmac_test);
+    device_create_file(&pdev->dev, &dev_attr_gmac_test);

 	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);

@@ -1733,22 +1739,24 @@
 	prv = netdev_priv(ndev);

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

 	prv->stopped = 1;

-	
+	

     pctrl = devm_pinctrl_get(&pdev->dev);

 	if (IS_ERR(pctrl)) {

-		dev_warn(&pdev->dev, "Failed to get test pins");
+		dev_warn(&pdev->dev, "Failed to get test pins");

 		pctrl = NULL;

-		goto errirq;
+		goto errirq;

 	}

-	

-	state0 = pinctrl_lookup_state(pctrl, "state0");

+//xf.li@20240327 modify for T106BUG-567 start

+	//state0 = pinctrl_lookup_state(pctrl, "state0");

+	state0 = pinctrl_lookup_state(pctrl, "default");

+//xf.li@20240327 modify for T106BUG-567 end

 	if (IS_ERR(state0)) {

-		dev_err(&pdev->dev, "TEST: missing state0\n");
+		dev_err(&pdev->dev, "TEST: missing state0\n");

 		goto pinctrl_init_end;

 	}	

 

 	if (pinctrl_select_state(pctrl, state0) < 0) {

-		dev_err(&pdev->dev, "setting state0 failed\n");
+		dev_err(&pdev->dev, "setting state0 failed\n");

 		goto pinctrl_init_end;

 	}

     

@@ -1756,7 +1764,7 @@
 	ret = gpio_request(prv->gpio_power[0], "gmac_power"); /* gpio 83/124 */

 	gpio_direction_output(prv->gpio_power[0], 1);

 	mdelay(15);

-#ifdef CONFIG_MDIO_C45 //zw.wang Customer chooses phy c22/c45 issues on 20240301
+#ifdef CONFIG_MDIO_C45 //zw.wang Customer chooses phy c22/c45 issues on 20240301

 	prv->gpio_power[1] = of_get_gpio_flags(pdev->dev.of_node, 1, &flags);

 	ret = gpio_request(prv->gpio_power[1], "phy_rst"); /* gpio 63 */

 	gpio_direction_output(prv->gpio_power[1], 0);

@@ -1768,7 +1776,7 @@
 	SET_NETDEV_DEV(ndev, &pdev->dev); //if not, will panic

 	

 	base = devm_platform_ioremap_resource(pdev, 0);

-	gmac_power_flag = prv->gpio_power[0];//jb.qi add for gamc power down on 20231116
+	gmac_power_flag = prv->gpio_power[0];//jb.qi add for gamc power down on 20231116

 	ndev->base_addr = base;/*iomem->start;*/

 	if (!ndev->base_addr)

 		return -ENXIO;

@@ -1867,8 +1875,8 @@
 		printk("set gmac wakelock!\n");

 	} else {	

 		strcpy(board_name, "mdl");

-	    netif_device_detach(ndev);
-    }
+	    netif_device_detach(ndev);

+    }

     

 	platform_set_drvdata(pdev, ndev);

 

@@ -1963,7 +1971,7 @@
 		free_netdev(ndev);

 	    platform_set_drvdata(pdev, NULL);

 

-#ifdef CONFIG_MDIO_C45 //zw.wang Customer chooses phy c22/c45 issues on 20240301
+#ifdef CONFIG_MDIO_C45 //zw.wang Customer chooses phy c22/c45 issues on 20240301

 		gpio_free(priv->gpio_power[1]);

 #endif

 		gpio_direction_output(priv->gpio_power[0], 0);

diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/spi/spi-zx29.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/spi/spi-zx29.c
index 4000729..b18019f 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/spi/spi-zx29.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/spi/spi-zx29.c
@@ -288,12 +288,14 @@
 struct zx29_ssp_pins
 {
 	struct device	*dev;
-	
+	//xf.li@20240327 modify for T106BUG-567 start
 	struct pinctrl		*pctrl;
 	struct pinctrl_state	*pfunc;
 	struct pinctrl_state	*pgpio;
-	struct pinctrl_state	*pcs_gpio;
+	struct pinctrl_state	*pcs_gpio_active;
 	struct pinctrl_state	*pcs_func;
+	struct pinctrl_state	*pcs_gpio_sleep;
+	//xf.li@20240327 modify for T106BUG-567 end
 	int	gpio_cs;
 	int	gpio_clk;	
 	int	gpio_tx;	
@@ -1992,7 +1994,7 @@
 };
 
 /*
-*    spi ʹÓÃGPIOģʽ¶ÁÈ¡LCD µÄID Begin
+*    spi ʹ\D3\C3GPIOģʽ\B6\C1ȡLCD \B5\C4ID Begin
 */
 static void spi_set_gpio_function(int dev_id)
 {
@@ -2592,18 +2594,23 @@
 	}
 	ssp_pins[pdev->id].pctrl=pctrl;
 
-	ssp_pins[pdev->id].pcs_gpio =  pinctrl_lookup_state(pctrl, "cs_gpio");
-	if (IS_ERR(ssp_pins[pdev->id].pcs_gpio)) {
-			dev_err(&pdev->dev, "missing cs_gpio \n");
+	ssp_pins[pdev->id].pcs_gpio_active =  pinctrl_lookup_state(pctrl, "cs_gpio_active");
+	if (IS_ERR(ssp_pins[pdev->id].pcs_gpio_active)) {
+			dev_err(&pdev->dev, "missing cs_gpio_active \n");
 	}	
-
+//xf.li@20240327 modify for T106BUG-567 start
+	ssp_pins[pdev->id].pcs_gpio_sleep =  pinctrl_lookup_state(pctrl, "cs_gpio_sleep");
+	if (IS_ERR(ssp_pins[pdev->id].pcs_gpio_sleep)) {
+			dev_err(&pdev->dev, "missing cs_gpio_sleep \n");
+	}
+//xf.li@20240327 modify for T106BUG-567 end
 	ssp_pins[pdev->id].pcs_func = pinctrl_lookup_state(ssp_pins[pdev->id].pctrl, "cs_func");
 	if (IS_ERR(ssp_pins[pdev->id].pcs_func)) {
 			dev_err(&pdev->dev, "missing cs_func \n");
 	}
 	
 	if(zx29spi->master->slave == false) {	
-		if (pinctrl_select_state(ssp_pins[pdev->id].pctrl, ssp_pins[pdev->id].pcs_gpio) < 0) {
+		if (pinctrl_select_state(ssp_pins[pdev->id].pctrl, ssp_pins[pdev->id].pcs_gpio_active) < 0) {
 			printk("spi%d setting cs_gpio pin ctrl failed\n",pdev->id);
 		}		
 	}else {	
@@ -3222,14 +3229,23 @@
 		return -1;
 	if(pdev && &pdev->dev)
 		pinctrl_pm_select_sleep_state(&pdev->dev);
-
+//xf.li@20240327 modify for T106BUG-567 start
 	zx29spi = (struct zx29_spi *)platform_get_drvdata(pdev);
 	if(zx29spi && (zx29spi->master->slave == true)) {
-		if (pinctrl_select_state(ssp_pins[pdev->id].pctrl, ssp_pins[pdev->id].pcs_gpio) < 0) {
+		if (pinctrl_select_state(ssp_pins[pdev->id].pctrl, ssp_pins[pdev->id].pcs_gpio_sleep) < 0) {
 			printk("spi%d setting cs_gpio pin ctrl failed\n",pdev->id);
 			return -1;
 		}
 	}
+
+	if(zx29spi && (zx29spi->master->slave == false)) {
+		if (pinctrl_select_state(ssp_pins[pdev->id].pctrl, ssp_pins[pdev->id].pcs_gpio_sleep) < 0) {
+			printk("spi%d setting cs_gpio_sleep pin ctrl failed\n",pdev->id);
+			return -1;
+		}
+		printk("spi%d setting cs_gpio_sleep pin ctrl\n",pdev->id);
+	}
+//xf.li@20240327 modify for T106BUG-567 end
 	return 0;
 }
 
@@ -3241,7 +3257,7 @@
 		return -1;
 	if(pdev && &pdev->dev)
 		pinctrl_pm_select_default_state(&pdev->dev);
-
+//xf.li@20240327 modify for T106BUG-567 start
 	zx29spi = (struct zx29_spi *)platform_get_drvdata(pdev);
 	if(zx29spi && (zx29spi->master->slave == true)) {
 		if (pinctrl_select_state(ssp_pins[pdev->id].pctrl, ssp_pins[pdev->id].pcs_func) < 0) {
@@ -3249,6 +3265,15 @@
 			return -1;
 		}
 	}
+	if(zx29spi && (zx29spi->master->slave == false)) {
+		if (pinctrl_select_state(ssp_pins[pdev->id].pctrl, ssp_pins[pdev->id].pcs_gpio_active) < 0) {
+			printk("spi%d setting cs_gpio_active pin ctrl failed\n",pdev->id);
+			return -1;
+		}
+		printk("spi%d setting cs_gpio_active pin ctrl\n",pdev->id);
+		gpio_direction_output(ssp_pins[pdev->id].gpio_cs,SPI_GPIO_HIGH);
+	}
+//xf.li@20240327 modify for T106BUG-567 end
 	return 0;
 }
 #endif
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tty/serial/zx29_uart.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tty/serial/zx29_uart.c
index 608ff72..bfa5cc4 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tty/serial/zx29_uart.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/tty/serial/zx29_uart.c
@@ -3773,9 +3773,11 @@
 		enable_irq(zup->rxd_irq);
 		zup->rxd_int_depth = 1;
 	}
-#if 0
+//xf.li@20240327 modify for T106BUG-567 start
+#if 1
 	pinctrl_pm_select_sleep_state(dev);
 #endif
+//xf.li@20240327 modify for T106BUG-567 end
 	return 0;
 }
 
@@ -3799,9 +3801,11 @@
 	//	zup->rxd_int_depth--;
 	//}
 	//return uart_resume_port(&amba_reg, &uap->port);
-#if 0
+//xf.li@20240327 modify for T106BUG-567 start
+#if 1
 		pinctrl_pm_select_default_state(dev);
 #endif
+//xf.li@20240327 modify for T106BUG-567 end
 	return 0;
 }
 #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 050a0f8..6af8b65 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
@@ -77,6 +77,10 @@
 	int gpio_pdn;
 	void __iomem *sys_base_va;
 
+	struct pinctrl *p;
+	struct pinctrl_state *s;
+	struct pinctrl_state *s_sleep;
+
 };
 
 
@@ -703,15 +707,19 @@
 static void zx29_i2s_top_pin_cfg(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
-	struct pinctrl *p,*p2;
-	struct pinctrl_state *s,*s2;
+	struct pinctrl *p;
+	struct pinctrl_state *s;
+	struct pinctrl_state *s_sleep;
 	int ret = 0;
-	printk("%s start n",__func__);
+	printk("%s start \n",__func__);
 
 	struct resource *res;
 	void __iomem	*reg_base;
 	unsigned int val;
+	
+	struct zx29_board_data *info = s_board;
 
+	pr_info("%s: board name(%s)!\n", __func__,info->name); 
 
 
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "soc_sys");
@@ -732,7 +740,7 @@
 	#endif
 	 
 //#if 1 //CONFIG_USE_PIN_I2S0
-#ifdef 	CONFIG_USE_TOP_I2S0
+#if defined(CONFIG_USE_TOP_I2S0)
 
 	dev_info(dev, "%s: arm i2s1 to top i2s0!!\n", __func__); 
 	//9300
@@ -742,7 +750,7 @@
 	val &= ~(0x7<<0);
 	val |= 0x1<<0; //	inter arm_i2s1--top i2s1
 	zx_write_reg(reg_base+ZX29_I2S_TOP_LOOP_REG, val);
-#else //(CONFIG_USE_PIN_I2S1)
+#elif defined(CONFIG_USE_TOP_I2S1)//defined(CONFIG_USE_PIN_I2S1)
     //8501evb    	
 
 	dev_info(dev, "%s: arm i2s1 to top i2s1!\n", __func__); 
@@ -762,13 +770,89 @@
 	}
 	
 	dev_info(dev, "%s: get pinctrl ,p=0x%llx,dev=0x%llx!!\n", __func__,p,dev); 
+#if defined(CONFIG_USE_TOP_I2S0)
+	dev_info(dev, "%s: top_i2s0 pinctrl sel!!\n", __func__); 
 
-	s = pinctrl_lookup_state(p, "top_i2s");
+	s = pinctrl_lookup_state(p, "top_i2s0");
 	if (IS_ERR(s)) {
 		devm_pinctrl_put(p);
 		dev_err(dev, " get state failure!!\n");
 		return;
 	}
+
+	dev_info(dev, "%s: get  top_i2s sleep pinctrl sel!!\n", __func__); 
+
+	s_sleep = pinctrl_lookup_state(p, "topi2s0_sleep");
+	if (IS_ERR(s_sleep)) {
+		devm_pinctrl_put(p);
+		dev_err(dev, " get state failure!!\n");
+		return;
+	}
+
+	
+	
+#elif defined(CONFIG_USE_TOP_I2S1)
+	dev_info(dev, "%s: top_i2s1 pinctrl sel!!\n", __func__); 
+
+	s = pinctrl_lookup_state(p, "top_i2s1");
+	if (IS_ERR(s)) {
+		devm_pinctrl_put(p);
+		dev_err(dev, " get state failure!!\n");
+		return;
+	}
+	dev_info(dev, "%s: get  top_i2s sleep pinctrl sel!!\n", __func__); 
+
+	s_sleep = pinctrl_lookup_state(p, "topi2s1_sleep");
+	if (IS_ERR(s_sleep)) {
+		devm_pinctrl_put(p);
+		dev_err(dev, " get state failure!!\n");
+		return;
+	}	
+
+#elif defined(CONFIG_USE_TOP_TDM)
+	dev_info(dev, "%s: top_tdm pinctrl sel!!\n", __func__); 
+	s = pinctrl_lookup_state(p, "top_tdm");
+	if (IS_ERR(s)) {
+		devm_pinctrl_put(p);
+		dev_err(dev, " get state failure!!\n");
+		return;
+	}
+	dev_info(dev, "%s: get  top_i2s sleep pinctrl sel!!\n", __func__); 
+
+	s_sleep = pinctrl_lookup_state(p, "toptdm_sleep");
+	if (IS_ERR(s_sleep)) {
+		devm_pinctrl_put(p);
+		dev_err(dev, " get state failure!!\n");
+		return;
+	}
+
+#else
+	dev_info(dev, "%s: default top_i2s pinctrl sel!!\n", __func__); 
+
+	s = pinctrl_lookup_state(p, "top_i2s0");
+	if (IS_ERR(s)) {
+		devm_pinctrl_put(p);
+		dev_err(dev, " get state failure!!\n");
+		return;
+	}
+
+	dev_info(dev, "%s: get  top_i2s sleep pinctrl sel!!\n", __func__); 
+
+	s_sleep = pinctrl_lookup_state(p, "topi2s0_sleep");
+	if (IS_ERR(s_sleep)) {
+		devm_pinctrl_put(p);
+		dev_err(dev, " get state failure!!\n");
+		return;
+	}
+
+#endif
+	if(info != NULL){
+
+		info->p = p;
+		info->s = s;
+		info->s_sleep = s_sleep;
+	}
+
 	ret = pinctrl_select_state(p, s);
 	if (ret < 0) {
 		devm_pinctrl_put(p);
@@ -851,6 +935,104 @@
 	return ret;
 }
 
+#ifdef CONFIG_PM
+static int zx29_audio_suspend(struct platform_device * pdev, pm_message_t state)
+{
+	pr_info("%s: start!\n",__func__);
+
+    //pinctrl_pm_select_sleep_state(&pdev->dev);
+	return 0;
+}
+
+static int zx29_audio_resume(struct platform_device *pdev)
+{
+	pr_info("%s: start!\n",__func__);
+
+    //pinctrl_pm_select_default_state(&pdev->dev);
+
+	return 0;
+}
+
+int zx29_snd_soc_suspend(struct device *dev)
+{
+
+	int ret = 0;
+	struct zx29_board_data *info = s_board;
+
+	pr_info("%s: start![8311]\n",__func__);
+
+    //pinctrl_pm_select_sleep_state(dev);
+    if((info->p != NULL)&&(info->s_sleep != NULL)){
+		ret = pinctrl_select_state(info->p, info->s_sleep);
+		if (ret < 0) {
+			//devm_pinctrl_put(info->p);
+			dev_err(dev, " select state failure!!\n");
+			//return;
+		}
+		dev_info(dev, "%s: set pinctrl sleep end!\n", __func__);	
+    }
+	return snd_soc_suspend(dev);
+
+}
+int zx29_snd_soc_resume(struct device *dev)
+{
+	int ret = 0;
+	struct zx29_board_data *info = s_board;
+
+	pr_info("%s: start!\n",__func__);
+
+    //pinctrl_pm_select_default_state(dev);
+    if((info->p != NULL)&&(info->s != NULL)){
+		ret = pinctrl_select_state(info->p, info->s);
+		if (ret < 0) {
+			//devm_pinctrl_put(info->p);
+			dev_err(dev, " select state failure!!\n");
+			//return;
+		}
+		dev_info(dev, "%s: set pinctrl active end!\n", __func__);	
+    }
+
+
+	return snd_soc_resume(dev);
+
+}
+
+#else
+static int zx29_audio_suspend(struct platform_device * pdev, pm_message_t state)
+{
+
+	return 0;
+}
+
+static int zx29_audio_resume(struct platform_device *pdev)
+{
+
+
+	return 0;
+}
+
+int zx29_snd_soc_suspend(struct device *dev)
+{
+
+
+	return snd_soc_suspend(dev);
+
+}
+int zx29_snd_soc_resume(struct device *dev)
+{
+
+
+	return snd_soc_resume(dev);
+
+}
+
+
+#endif
+
+struct dev_pm_ops zx29_snd_soc_pm_ops = {
+	.suspend = zx29_snd_soc_suspend,
+	.resume = zx29_snd_soc_resume,
+};
 static struct platform_driver zx29_platform_driver = {
 	.driver		= {
 #if defined(CONFIG_SND_SOC_ZX29_ES8311)
@@ -862,7 +1044,7 @@
 		.name	= "zx29_es8311",
 #endif
 		.of_match_table = of_match_ptr(zx29_codec_of_match),
-		.pm	= &snd_soc_pm_ops,
+		.pm	= &zx29_snd_soc_pm_ops,
 	},
 	.probe		= zx29_audio_probe,
 };