--- a/modules/lms2012/d_uart/Linuxmod_AM1808/d_uart.c
+++ b/modules/lms2012/d_uart/Linuxmod_AM1808/d_uart.c
@@ -541,6 +541,7 @@
 #include  <asm/io.h>
 #include  <linux/module.h>
 #include  <linux/miscdevice.h>
+#include  <linux/delay.h>
 #include  <asm/uaccess.h>
 #include <asm/cacheflush.h>
 
@@ -1155,15 +1156,18 @@
   return (Length);
 }
 
-
+static int Uart1FifoCnt;
 static UBYTE Uart1Write(UBYTE Byte)
 {
   UBYTE   Result = 0;
 
   if (Uart1Base[UART_LSR] & 0x20)
+      Uart1FifoCnt = 16;
+  if (Uart1FifoCnt > 0)
   {
     Uart1Base[UART_THR]   =  Byte;
     Result                =  1;
+    Uart1FifoCnt--;
   }
 
   return (Result);
@@ -1188,6 +1192,7 @@
 #else
   Uart1Base[UART_IER]   =  0x00;
 #endif
+  Uart1FifoCnt = 0;
 }
 
 
@@ -1437,19 +1442,23 @@
   return (Length);
 }
 
-
+static int Uart2FifoCnt;
 static UBYTE Uart2Write(UBYTE Byte)
 {
   UBYTE   Result = 0;
 
   if (Uart2Base[UART_LSR] & 0x20)
+      Uart2FifoCnt = 16;
+  if (Uart2FifoCnt > 0)
   {
     Uart2Base[UART_THR]   =  Byte;
     Result                =  1;
+    Uart2FifoCnt--;
   }
 
   return (Result);
 }
+
 
 
 static void Uart2Setup(ULONG BitRate)
@@ -1466,6 +1475,7 @@
   Uart2Base[UART_MCR]   =  0x00;
 
   Uart2Base[UART_IER]   =  0x01;
+  Uart2FifoCnt = 0;
 }
 
 
@@ -1843,6 +1853,8 @@
   UART_IDLE,
   UART_INIT,
   UART_RESTART,
+  UART_INIT_RAW,
+  UART_RAW,
   UART_ENABLE,
   UART_FLUSH,
   UART_SYNC,
@@ -1868,6 +1880,8 @@
   "IDLE\n",
   "INIT",
   "UART_RESTART",
+  "INIT RAW",
+  "RAW",
   "ENABLE",
   "FLUSH",
   "SYNC",
@@ -1880,6 +1894,7 @@
   "ACK_INFO",
   "CMD_ERROR",
   "INFO_ERROR",
+  "TERMINAL_INIT"
   "TERMINAL",
   "DATA_ERROR",
   "ERROR",
@@ -3470,6 +3485,38 @@
           }
           break;
 
+          case UART_INIT_RAW:
+          {
+            UartPortDisable(Port);
+            UartPort[Port]                  =  UartPortDefault;
+            UartPortEnable(Port);
+            UartPort[Port].BitRate      =  115200;
+            UartPortSetup(Port,UartPort[Port].BitRate);
+            for (Tmp = 0;Tmp < MAX_DEVICE_MODES;Tmp++)
+            {
+              TypeData[Port][Tmp]           =  TypeDefaultUart[0];
+              Changed[Port][Tmp]            =  0;
+            }
+    #ifndef DISABLE_FAST_DATALOG_BUFFER
+            (*pUart).Actual[Port]           =  0;
+            (*pUart).LogIn[Port]            =  0;
+    #endif
+            UartPortFlush(Port);
+            TypeData[Port][0]           =  TypeDefaultUart[1];
+            UartPort[Port].State        =  UART_RAW;
+            Changed[Port][0]            =  1;
+            UartPort[Port].Mode         =  UART_MODE_RAW;
+            (*pUart).Status[Port]       =  (UART_DATA_READY);
+            UartPort[Port].Initialised  =  1;
+          }
+          break;
+
+          case UART_RAW:
+          {
+
+          }
+          break;
+
           case UART_TERMINAL :
           {
           }
@@ -3617,11 +3664,13 @@
       {
         if (DevCon.Connection[Port] == CONN_INPUT_UART)
         {
-            (*pUart).Actual[0]++;
           if (UartConfigured[Port] == 0)
           {
             UartConfigured[Port]        =  1;
-            UartPort[Port].State        =  UART_INIT;
+            if (DevCon.Mode[Port] == UART_MODE_RAW)
+              UartPort[Port].State = UART_INIT_RAW;
+            else
+              UartPort[Port].State        =  UART_INIT;
           }
           else
           {
@@ -3636,6 +3685,8 @@
                 UartPort[Port].Mode         =  DevCon.Mode[Port];
                 UartPort[Port].ChangeMode   =  1;
                 (*pUart).Status[Port]      &= ~UART_DATA_READY;
+                if (DevCon.Mode[Port] == UART_MODE_RAW)
+                  UartPort[Port].State = UART_INIT_RAW;
               }
             }
           }
@@ -3704,6 +3755,46 @@
     }
     break;
 
+    case UART_SET_CONFIG:
+    {
+      UARTCONFIG *pConfig = (UARTCONFIG *)Pointer;
+      UartPort[pConfig->Port].BitRate = pConfig->BitRate;
+      UartPortSetup(pConfig->Port, pConfig->BitRate);
+    }
+    break;
+
+    case UART_RAW_READ:
+    {
+        UBYTE *pData = (UBYTE *)Pointer;
+        int max = pData[1];
+        int len = 0;
+        Port = pData[0];
+        while (len < max)
+        {
+          if (UartPortReceive(Port, pData + len + 2) == 0)
+              break;
+          len++;
+        }
+        Result = len;
+    }
+    break;
+
+    case UART_RAW_WRITE:
+    {
+        UBYTE *pData = (UBYTE *)Pointer;
+        int max = pData[1];
+        int len = 0;
+        Port = pData[0];
+        while (len < max)
+        {
+            if (UartPortSend(Port, pData[len+2]) == 0)
+              break;//usleep_range(100, 500);
+            else
+              len++;
+        }
+        Result = len;
+    }
+    break;
   }
   // Ensure shared memory is updated correctly on Arm systems
   //flush_dcache_page(virt_to_page((*pUart).Actual));
@@ -3824,7 +3915,6 @@
 
 
    ret = remap_pfn_range(vma,vma->vm_start,offset >> PAGE_SHIFT,vma->vm_end-vma->vm_start, vma->vm_page_prot);
-printk("remap returns %d\n", ret);
    if (ret != 0)
    {
      ret  =  -EAGAIN;
@@ -3875,7 +3965,6 @@
           //if ((kmalloc_ptr = kmalloc((NPAGES + 2) * PAGE_SIZE, GFP_DMA)) != NULL)
     if (kmalloc_ptr != NULL)
     {
-        printk("memory ok");
       pTmp = (UWORD*)((((unsigned long)kmalloc_ptr) + PAGE_SIZE - 1) & PAGE_MASK);
       for (i = 0; i < NPAGES * PAGE_SIZE; i += PAGE_SIZE)
       {
@@ -3942,7 +4031,7 @@
   }
   {
     UARTCTL c;
-  printk("mem address %x\n", kmalloc_ptr);
+  printk("mem address %x\n", (unsigned int)kmalloc_ptr);
   printk("mem size %d\n", SHM_LENGTH);
   printk("status offset %d\n", ((char *)&((*pUart).Status[0]) - (char *)pUart));
   printk("input offset %d\n", ((char *)&((*pUart).Raw[0]) - (char *)pUart));
@@ -3953,6 +4042,9 @@
   printk("UART_READ_MODE_INFO %x\n", UART_READ_MODE_INFO);
   printk("UART_NACK_MODE_INFO %x\n", UART_NACK_MODE_INFO);
   printk("UART_CLEAR_CHANGED %x\n", UART_CLEAR_CHANGED);
+  printk("UART_SET_CONFIG %x\n", UART_SET_CONFIG);
+  printk("UART_RAW_READ %x\n", UART_RAW_READ);
+  printk("UART_RAW_WRITE %x\n", UART_RAW_WRITE);
   printk("uartctl sz %d\n", sizeof(c));
   printk("port offset %d\n", (((char *)&c.Port) - (char *)&c));
   printk("New uart driver\n");