Merge branch 'stable-3.2' into pandora-3.2
[pandora-kernel.git] / drivers / tty / serial / omap-serial.c
index 5e713d3..d3c8e82 100644 (file)
 #include <plat/dmtimer.h>
 #include <plat/omap-serial.h>
 
+/* SCR register bitmasks */
+#define OMAP_UART_SCR_RX_TRIG_GRANU1_MASK              (1 << 7)
+
+/* FCR register bitmasks */
+#define OMAP_UART_FCR_RX_FIFO_TRIG_SHIFT               6
+#define OMAP_UART_FCR_RX_FIFO_TRIG_MASK                        (0x3 << 6)
+
 static struct uart_omap_port *ui[OMAP_MAX_HSUART_PORTS];
 
 /* Forward declaration of functions */
@@ -148,11 +155,12 @@ static void serial_omap_stop_rx(struct uart_port *port)
        serial_out(up, UART_IER, up->ier);
 }
 
-static inline void receive_chars(struct uart_omap_port *up, int *status)
+static inline void receive_chars(struct uart_omap_port *up,
+               unsigned int *status)
 {
        struct tty_struct *tty = up->port.state->port.tty;
-       unsigned int flag;
-       unsigned char ch, lsr = *status;
+       unsigned int flag, lsr = *status;
+       unsigned char ch = 0;
        int max_count = 256;
 
        do {
@@ -262,6 +270,7 @@ static void serial_omap_start_tx(struct uart_port *port)
        int ret = 0;
 
        if (!up->use_dma) {
+               omap_uart_block_sleep_id(up->pdev->id);
                serial_omap_enable_ier_thri(up);
                return;
        }
@@ -723,6 +732,7 @@ serial_omap_set_termios(struct uart_port *port, struct ktermios *termios,
                up->ier |= UART_IER_MSI;
        serial_out(up, UART_IER, up->ier);
        serial_out(up, UART_LCR, cval);         /* reset DLAB */
+       up->scr = OMAP_UART_SCR_TX_EMPTY;
 
        /* FIFOs and DMA Settings */
 
@@ -744,15 +754,23 @@ serial_omap_set_termios(struct uart_port *port, struct ktermios *termios,
        up->mcr = serial_in(up, UART_MCR);
        serial_out(up, UART_MCR, up->mcr | UART_MCR_TCRTLR);
        /* FIFO ENABLE, DMA MODE */
-       serial_out(up, UART_FCR, up->fcr);
-       serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
+
+       up->scr |= OMAP_UART_SCR_RX_TRIG_GRANU1_MASK;
 
        if (up->use_dma) {
                serial_out(up, UART_TI752_TLR, 0);
-               serial_out(up, UART_OMAP_SCR,
-                       (UART_FCR_TRIGGER_4 | UART_FCR_TRIGGER_8));
+               up->scr |= UART_FCR_TRIGGER_4;
+       } else {
+               /* Set receive FIFO threshold to 1 byte */
+               up->fcr &= ~OMAP_UART_FCR_RX_FIFO_TRIG_MASK;
+               up->fcr |= (0x1 << OMAP_UART_FCR_RX_FIFO_TRIG_SHIFT);
        }
 
+       serial_out(up, UART_FCR, up->fcr);
+       serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
+
+       serial_out(up, UART_OMAP_SCR, up->scr);
+
        serial_out(up, UART_EFR, up->efr);
        serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A);
        serial_out(up, UART_MCR, up->mcr);