fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / serial / serial_lh7a40x.c
index 04186ea..eb18d42 100644 (file)
@@ -27,7 +27,6 @@
  *
  */
 
-#include <linux/config.h>
 
 #if defined(CONFIG_SERIAL_LH7A40X_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
 #define SUPPORT_SYSRQ
@@ -136,23 +135,19 @@ static void lh7a40xuart_enable_ms (struct uart_port* port)
        BIT_SET (port, UART_R_INTEN, ModemInt);
 }
 
-static void
-#ifdef SUPPORT_SYSRQ
-lh7a40xuart_rx_chars (struct uart_port* port, struct pt_regs* regs)
-#else
-lh7a40xuart_rx_chars (struct uart_port* port)
-#endif
+static void lh7a40xuart_rx_chars (struct uart_port* port)
 {
        struct tty_struct* tty = port->info->tty;
        int cbRxMax = 256;      /* (Gross) limit on receive */
-       unsigned int data, flag;/* Received data and status */
+       unsigned int data;      /* Received data and status */
+       unsigned int flag;
 
        while (!(UR (port, UART_R_STATUS) & nRxRdy) && --cbRxMax) {
                data = UR (port, UART_R_DATA);
                flag = TTY_NORMAL;
                ++port->icount.rx;
 
-               if (unlikely(data & RxError)) { /* Quick check, short-circuit */
+               if (unlikely(data & RxError)) {
                        if (data & RxBreak) {
                                data &= ~(RxFramingError | RxParityError);
                                ++port->icount.brk;
@@ -177,7 +172,7 @@ lh7a40xuart_rx_chars (struct uart_port* port)
                                flag = TTY_FRAME;
                }
 
-               if (uart_handle_sysrq_char (port, (unsigned char) data, regs))
+               if (uart_handle_sysrq_char (port, (unsigned char) data))
                        continue;
 
                uart_insert_char(port, data, RxOverrunError, data, flag);
@@ -248,8 +243,7 @@ static void lh7a40xuart_modem_status (struct uart_port* port)
        wake_up_interruptible (&port->info->delta_msr_wait);
 }
 
-static irqreturn_t lh7a40xuart_int (int irq, void* dev_id,
-                                   struct pt_regs* regs)
+static irqreturn_t lh7a40xuart_int (int irq, void* dev_id)
 {
        struct uart_port* port = dev_id;
        unsigned int cLoopLimit = ISR_LOOP_LIMIT;
@@ -258,11 +252,7 @@ static irqreturn_t lh7a40xuart_int (int irq, void* dev_id,
 
        do {
                if (isr & (RxInt | RxTimeoutInt))
-#ifdef SUPPORT_SYSRQ
-                       lh7a40xuart_rx_chars(port, regs);
-#else
                        lh7a40xuart_rx_chars(port);
-#endif
                if (isr & ModemInt)
                        lh7a40xuart_modem_status (port);
                if (isr & TxInt)
@@ -303,7 +293,7 @@ static void lh7a40xuart_set_mctrl (struct uart_port* port, unsigned int mctrl)
        /* Note, kernel appears to be setting DTR and RTS on console. */
 
        /* *** FIXME: this deserves more work.  There's some work in
-               tracing all of the IO pins. */
+              tracing all of the IO pins. */
 #if 0
        if( port->mapbase == UART1_PHYS) {
                gpioRegs_t *gpio = (gpioRegs_t *)IO_ADDRESS(GPIO_PHYS);
@@ -358,8 +348,8 @@ static void lh7a40xuart_shutdown (struct uart_port* port)
 }
 
 static void lh7a40xuart_set_termios (struct uart_port* port,
-                                    struct termios* termios,
-                                    struct termios* old)
+                                    struct ktermios* termios,
+                                    struct ktermios* old)
 {
        unsigned int con;
        unsigned int inten;
@@ -543,6 +533,12 @@ static struct uart_port_lh7a40x lh7a40x_ports[DEV_NR] = {
 #else
 # define LH7A40X_CONSOLE &lh7a40x_console
 
+static void lh7a40xuart_console_putchar(struct uart_port *port, int ch)
+{
+       while (UR(port, UART_R_STATUS) & nTxRdy)
+               ;
+       UR(port, UART_R_DATA) = ch;
+}
 
 static void lh7a40xuart_console_write (struct console* co,
                                       const char* s,
@@ -556,16 +552,7 @@ static void lh7a40xuart_console_write (struct console* co,
        UR (port, UART_R_INTEN) = 0;            /* Disable all interrupts */
        BIT_SET (port, UART_R_CON, UARTEN | SIRDIS); /* Enable UART */
 
-       for (; count-- > 0; ++s) {
-               while (UR (port, UART_R_STATUS) & nTxRdy)
-                       ;
-               UR (port, UART_R_DATA) = *s;
-               if (*s == '\n') {
-                       while ((UR (port, UART_R_STATUS) & TxBusy))
-                               ;
-                       UR (port, UART_R_DATA) = '\r';
-               }
-       }
+       uart_console_write(port, s, count, lh7a40xuart_console_putchar);
 
                                /* Wait until all characters are sent */
        while (UR (port, UART_R_STATUS) & TxBusy)
@@ -665,9 +652,13 @@ static int __init lh7a40xuart_init(void)
        if (ret == 0) {
                int i;
 
-               for (i = 0; i < DEV_NR; i++)
+               for (i = 0; i < DEV_NR; i++) {
+                       /* UART3, when used, requires GPIO pin reallocation */
+                       if (lh7a40x_ports[i].port.mapbase == UART3_PHYS)
+                               GPIO_PINMUX |= 1<<3;
                        uart_add_one_port (&lh7a40x_reg,
                                           &lh7a40x_ports[i].port);
+               }
        }
        return ret;
 }