8250: use callbacks to access UART_DLL/UART_DLM
[pandora-kernel.git] / drivers / tty / serial / 8250.c
index eeadf1b..07cfec5 100644 (file)
@@ -316,6 +316,33 @@ static const struct serial8250_config uart_config[] = {
                .fcr            = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
                .flags          = UART_CAP_FIFO | UART_CAP_AFE | UART_CAP_EFR,
        },
+       [PORT_BRCM_TRUMANAGE] = {
+               .name           = "TruManage",
+               .fifo_size      = 1,
+               .tx_loadsz      = 1024,
+               .flags          = UART_CAP_HFIFO,
+       },
+       [PORT_ALTR_16550_F32] = {
+               .name           = "Altera 16550 FIFO32",
+               .fifo_size      = 32,
+               .tx_loadsz      = 32,
+               .fcr            = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
+               .flags          = UART_CAP_FIFO | UART_CAP_AFE,
+       },
+       [PORT_ALTR_16550_F64] = {
+               .name           = "Altera 16550 FIFO64",
+               .fifo_size      = 64,
+               .tx_loadsz      = 64,
+               .fcr            = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
+               .flags          = UART_CAP_FIFO | UART_CAP_AFE,
+       },
+       [PORT_ALTR_16550_F128] = {
+               .name           = "Altera 16550 FIFO128",
+               .fifo_size      = 128,
+               .tx_loadsz      = 128,
+               .fcr            = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
+               .flags          = UART_CAP_FIFO | UART_CAP_AFE,
+       },
 };
 
 #if defined(CONFIG_MIPS_ALCHEMY)
@@ -750,22 +777,16 @@ static int size_fifo(struct uart_8250_port *up)
  */
 static unsigned int autoconfig_read_divisor_id(struct uart_8250_port *p)
 {
-       unsigned char old_dll, old_dlm, old_lcr;
-       unsigned int id;
+       unsigned char old_lcr;
+       unsigned int id, old_dl;
 
        old_lcr = serial_inp(p, UART_LCR);
        serial_outp(p, UART_LCR, UART_LCR_CONF_MODE_A);
+       old_dl = serial_dl_read(p);
+       serial_dl_write(p, 0);
+       id = serial_dl_read(p);
+       serial_dl_write(p, old_dl);
 
-       old_dll = serial_inp(p, UART_DLL);
-       old_dlm = serial_inp(p, UART_DLM);
-
-       serial_outp(p, UART_DLL, 0);
-       serial_outp(p, UART_DLM, 0);
-
-       id = serial_inp(p, UART_DLL) | serial_inp(p, UART_DLM) << 8;
-
-       serial_outp(p, UART_DLL, old_dll);
-       serial_outp(p, UART_DLM, old_dlm);
        serial_outp(p, UART_LCR, old_lcr);
 
        return id;
@@ -1511,6 +1532,11 @@ static void transmit_chars(struct uart_8250_port *up)
                up->port.icount.tx++;
                if (uart_circ_empty(xmit))
                        break;
+               if (up->capabilities & UART_CAP_HFIFO) {
+                       if ((serial_in(up, UART_LSR) & BOTH_EMPTY) !=
+                           BOTH_EMPTY)
+                               break;
+               }
        } while (--count > 0);
 
        if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
@@ -2327,10 +2353,11 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
                quot++;
 
        if (up->capabilities & UART_CAP_FIFO && up->port.fifosize > 1) {
-               if (baud < 2400)
-                       fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1;
-               else
-                       fcr = uart_config[up->port.type].fcr;
+               fcr = uart_config[up->port.type].fcr;
+               if (baud < 2400) {
+                       fcr &= ~UART_FCR_TRIGGER_MASK;
+                       fcr |= UART_FCR_TRIGGER_1;
+               }
        }
 
        /*
@@ -2668,6 +2695,10 @@ static void serial8250_config_port(struct uart_port *port, int flags)
        if (up->port.type == PORT_16550A && up->port.iotype == UPIO_AU)
                up->bugs |= UART_BUG_NOMSR;
 
+       /* HW bugs may trigger IRQ while IIR == NO_INT */
+       if (up->port.type == PORT_TEGRA)
+               up->bugs |= UART_BUG_NOMSR;
+
        if (up->port.type != PORT_UNKNOWN && flags & UART_CONFIG_IRQ)
                autoconfig_irq(up);
 
@@ -2683,7 +2714,7 @@ serial8250_verify_port(struct uart_port *port, struct serial_struct *ser)
        if (ser->irq >= nr_irqs || ser->irq < 0 ||
            ser->baud_base < 9600 || ser->type < PORT_UNKNOWN ||
            ser->type >= ARRAY_SIZE(uart_config) || ser->type == PORT_CIRRUS ||
-           ser->type == PORT_STARTECH)
+           ser->type == PORT_STARTECH || uart_config[ser->type].name == NULL)
                return -EINVAL;
        return 0;
 }
@@ -2693,7 +2724,7 @@ serial8250_type(struct uart_port *port)
 {
        int type = port->type;
 
-       if (type >= ARRAY_SIZE(uart_config))
+       if (type >= ARRAY_SIZE(uart_config) || uart_config[type].name == NULL)
                type = 0;
        return uart_config[type].name;
 }