[Feature][T106]fix uart sprintf lock too long

Change-Id: I17bdf29b5ac848e4b3425c1121ee37a16c728140
diff --git a/ap/os/linux/linux-3.4.x/drivers/tty/serial/zx29_uart.c b/ap/os/linux/linux-3.4.x/drivers/tty/serial/zx29_uart.c
index 2dfa903..d3502e3 100755
--- a/ap/os/linux/linux-3.4.x/drivers/tty/serial/zx29_uart.c
+++ b/ap/os/linux/linux-3.4.x/drivers/tty/serial/zx29_uart.c
@@ -210,9 +210,9 @@
 
 #define	zx29_MAXPORTS	ARRAY_SIZE(zx29_uart_ports)
 
-#ifdef _USE_CAP_SYS
+#ifdef _USE_VEHICLE_DC
 static void zx29_uart_console_putc(struct uart_port *port, const char c);
-static void zx29_uart_console_putc_printf(struct uart_port *port, int c);
+static void zx29_uart_console_putc_share(struct uart_port *port, const char c);
 #endif
 
 void uart_mod_timer(struct zx29_uart_port *zup, unsigned long *flags)
@@ -317,7 +317,7 @@
 }
 DEVICE_ATTR(statics, S_IRUGO | S_IWUSR, statics_show, NULL);
 
-#ifdef _USE_CAP_SYS
+#ifdef _USE_VEHICLE_DC
 #define ICP_CORE_ID_PS 2
 #define ICP_CORE_ID_CAP CAP_ID
 #define ICP_CHANNEL_CONSOLE_UART channel_7
@@ -330,8 +330,9 @@
 #define DISABLE_CURRENT_CONSOLE_UART 0
 #define ENABLE_TOGGLE 1
 #define DISABLE_TOGGLE 0
-unsigned char g_core_id_occupy_uart = 0;
+unsigned char g_core_id_occupy_uart = SYMB_CAP_CORE_ID;
 unsigned char g_ps_uart_toggle = 0;
+unsigned char g_up_init_done = 0;
 static irqreturn_t zx29_uart_interrupt(int irq, void *dev_id);
 static void restart_current_cons_uart(void)
 {
@@ -407,6 +408,7 @@
 				const char *buf, size_t count)
 {
     uint32_t  flag = 0;
+	g_up_init_done = 1;
 	flag = simple_strtoul(buf, NULL, 16);
 	if(flag == ENABLE_TOGGLE){
 		g_ps_uart_toggle = 1;
@@ -627,7 +629,7 @@
 
 
 #ifdef _USE_VEHICLE_DC
-	if((port->line == DEBUG_CONSOLE))
+	if((port->line == DEBUG_CONSOLE) && (g_up_init_done == 0))
 	{
 		if(g_core_id_occupy_uart == SYMB_CAP_CORE_ID){
 		#if 1
@@ -644,7 +646,7 @@
 		count = uart_circ_chars_pending(xmit);
 		while(count-- > 0) 
 		{
-			zx29_uart_console_putc_printf(&zup->port, xmit->buf[xmit->tail]);
+			zx29_uart_console_putc_share(&zup->port, xmit->buf[xmit->tail]);
 			xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
 			zup->port.icount.tx++;
 			if (uart_circ_empty(xmit)){
@@ -664,6 +666,33 @@
 else
 #endif
 {
+#ifdef _USE_VEHICLE_DC
+
+    if((port->line == DEBUG_CONSOLE) && (g_up_init_done == 1)){
+
+       if(g_core_id_occupy_uart == SYMB_CAP_CORE_ID){
+
+           count = uart_circ_chars_pending(xmit);
+
+           while(count-- > 0) 
+
+           {
+
+              xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
+
+              if (uart_circ_empty(xmit))
+
+                  break;
+
+           }
+
+       return;
+
+    }
+
+    }
+
+#endif
 	if(!(UART_GET_RIS(port)&UART_TXIS) && (UART_GET_FR(port) & UART_FR_TXFE))
 	{
 		if(!(UART_GET_RIS(port)&UART_TXIS))	
@@ -3052,7 +3081,6 @@
 
 #ifdef CONFIG_SERIAL_ZX29_UART_CONSOLE
 
-#ifndef _USE_CAP_SYS
 /****************************************************************************/
 static void zx29_uart_console_putc(struct uart_port *port, const char c)
 {
@@ -3061,28 +3089,7 @@
 	UART_PUT_CHAR(port, c);
 }
 
-#else
-static void zx29_uart_console_putc(struct uart_port *port, const char c)
-{
-	if(g_core_id_occupy_uart == SYMB_CAP_CORE_ID)
-		return;
-	soft_spin_lock(UART_SFLOCK);
-	while (UART_GET_FR(port) & UART_FR_TXFF)
-		barrier();
-	UART_PUT_CHAR(port, c);
-	soft_spin_unlock(UART_SFLOCK);
-}
-static void zx29_uart_console_putc_printf(struct uart_port *port, int c)
-{
-	int ret;
-	ret = soft_spin_lock_printf(UART_SFLOCK);
-	while (UART_GET_FR(port) & UART_FR_TXFF)
-		barrier();
-	UART_PUT_CHAR(port, c);
-	if(!ret)
-		soft_spin_unlock(UART_SFLOCK);
-}
-#endif
+#ifndef _USE_VEHICLE_DC
 
 /****************************************************************************/
 static void zx29_uart_console_write(struct console *co, const char *s, unsigned int count)
@@ -3101,7 +3108,63 @@
 	
 	//raw_spin_unlock(&port->lock);
 }
+#else
 
+static void zx29_uart_console_putc_share(struct uart_port *port, const char c)
+
+{
+
+    if(g_core_id_occupy_uart == SYMB_CAP_CORE_ID)
+
+       return;
+
+    int ret = soft_spin_lock_printf(UART_SFLOCK);
+
+    if(ret)
+
+       return;
+
+    while (UART_GET_FR(port) & UART_FR_TXFF)
+       barrier();
+    UART_PUT_CHAR(port, c);
+    soft_spin_unlock(UART_SFLOCK);
+
+}
+static void zx29_uart_console_write(struct console *co, const char *s, unsigned int count)
+
+{
+
+    struct uart_port *port = &zx29_uart_ports[co->index].port;
+
+#if 0
+
+    if(!g_console_open_flag)
+
+       return;
+
+#endif
+
+    //raw_spin_lock(&port->lock);
+
+    for (; (count); count--, s++) {
+
+       zx29_uart_console_putc_share(port, *s);
+
+       if (*s == '\n')
+
+           zx29_uart_console_putc_share(port, '\r');
+
+    }
+
+   
+
+    //raw_spin_unlock(&port->lock);
+
+}
+
+ 
+
+#endif
 /***************************************************************************
  * If the port was already initialised (eg, by a boot loader),
  * try to determine the current setup.
@@ -3264,7 +3327,8 @@
 	if(pdev->id == DEBUG_CONSOLE){
 		g_console_open_flag = pdata->uart_input_enable ? pdata->uart_input_enable : 0;
 		error = device_create_file(&pdev->dev, &dev_attr_console_input);
-#ifdef _USE_CAP_SYS
+#ifdef _USE_VEHICLE_DC
+       		g_up_init_done = 0;
 		error = device_create_file(&pdev->dev, &dev_attr_console_uart_toggle);
 		error = device_create_file(&pdev->dev, &dev_attr_coreid_occupy_uart);
 		int ret;