[Bugfix][T106-bug-657][factory]FIX Unable to find GNSS version number after GPIO testing in ES-MODE

Only Configure:No
Affected branch:master
Affected module:FACTORY
Is it affected on: only zxic
Self-test: Yes
Doc Update:No

Change-Id: I1fa51fedeca0101d219f603a7c2906ea492debce
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp
index c82b119..5add3a1 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp
@@ -821,6 +821,42 @@
     close(raw_socket);

     return;

 }

+

+void lynq_uart2_funswitch(char *input)

+{

+    FILE *fp;

+    char lynq_switch_dev[126] = {0};

+    char lynq_switch_buf[256] = {0};

+    int lynq_switch_num = atoi(input + strlen("uart2funswitch") + 1);

+    char flag[64] = {0};

+

+    sprintf(lynq_switch_dev,"echo %d > /sys/devices/platform/soc/140d000.uart/uart_io_select",lynq_switch_num);

+    system(lynq_switch_dev);

+

+    memset(lynq_switch_dev, 0, sizeof(lynq_switch_dev));

+    sprintf(lynq_switch_dev,"cat /sys/kernel/debug/pinctrl/13c000.pin-controller/pins | grep 122");

+    fp=popen(lynq_switch_dev, "r");

+    fgets(lynq_switch_buf,sizeof(lynq_switch_buf),fp);

+    if (lynq_switch_num == 0 && strstr(lynq_switch_buf, "BGPIO") == NULL)

+    {

+        ALOGE("switch failed\r\n");

+        lynq_response_error(100);

+    }

+    else if(lynq_switch_num == 1 && strstr(lynq_switch_buf, "UART2") == NULL)

+    {

+        ALOGE("switch failed\r\n");

+        lynq_response_error(100);

+    }

+    else if(lynq_switch_num !=0 && lynq_switch_num !=1)

+    {

+        ALOGE("error input\r\n");

+        lynq_response_error(99);

+    }

+    else

+        lynq_response_ok();

+    pclose(fp);

+}

+

 #endif

 

 void lynq_handle_sdio(char *input)

@@ -831,6 +867,7 @@
 {

     lynq_response_error(100);

 }

+

 static Command commands[] = 

 {

     {"adc",lynq_handle_adc},

@@ -840,6 +877,7 @@
     {"rmii",lynq_handle_rgmii},

     {"sdio",lynq_handle_sdio},

     {"pcm",lynq_handle_pcm},

+    {"uart2funswitch",lynq_uart2_funswitch},

     {NULL, NULL}

 };

 

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 b29437a..7029976 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
@@ -591,6 +591,48 @@
 		);
 }
 DEVICE_ATTR(statics, S_IRUGO, statics_show, NULL);
+
+static unsigned int uart_io_seletc = 0;
+ 
+ 
+static ssize_t uart_io_select_show(struct device *_dev,
+struct device_attribute *attr, char *buf)
+{
+struct platform_device *pdev = container_of(_dev, struct platform_device, dev);
+//struct zx29_uart_platdata *pdata = pdev->dev.platform_data;
+ 
+return sprintf(buf, "%d\n",uart_io_seletc );
+ 
+}
+ 
+static ssize_t uart_io_select_store(struct device *_dev,
+struct device_attribute *attr,
+const char *buf, size_t count)
+{
+    uint32_t  flag = 0;
+struct platform_device *pdev = container_of(_dev, struct platform_device, dev);
+flag = simple_strtoul(buf, NULL, 16);
+ 
+if(flag == 1){
+	printk("uart io is 1\n");
+pinctrl_pm_select_default_state(_dev);
+}else if(flag == 0){
+pinctrl_pm_select_sleep_state(_dev);
+}
+else{
+printk("uart io select flag invaild\n");
+}
+ 
+uart_io_seletc = flag;
+ 
+ 
+   
+return count;
+}
+ 
+DEVICE_ATTR(uart_io_select, S_IRUGO | S_IWUSR, uart_io_select_show,
+    uart_io_select_store);
+
 #define VEHICLE_USE_ONE_UART_LOG 1
 #if VEHICLE_USE_ONE_UART_LOG
 #define ICP_CORE_ID_PS CORE_PS0
@@ -4412,6 +4454,9 @@
 		error = device_create_file(&pdev->dev, &dev_attr_app_ctrl);
 		
 	}
+	if(pdev->id == 2){
+		error = device_create_file(&pdev->dev, &dev_attr_uart_io_select); 
+		}
 		error = device_create_file(&pdev->dev, &dev_attr_statics);
 	device_init_wakeup(&pdev->dev, true);
 /*