linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / serial / dz.c
index 293d172..ba5541d 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * dz.c: Serial port driver for DECStations equiped 
+ * dz.c: Serial port driver for DECStations equiped
  *       with the DZ chipset.
  *
- * Copyright (C) 1998 Olivier A. D. Lebaillif 
- *             
+ * Copyright (C) 1998 Olivier A. D. Lebaillif
+ *
  * Email: olivier.lebaillif@ifrsys.com
  *
  * [31-AUG-98] triemer
  * removed base_addr code - moving address assignment to setup.c
  * Changed name of dz_init to rs_init to be consistent with tc code
  * [13-NOV-98] triemer fixed code to receive characters
- *    after patches by harald to irq code.  
+ *    after patches by harald to irq code.
  * [09-JAN-99] triemer minor fix for schedule - due to removal of timeout
  *            field from "current" - somewhere between 2.1.121 and 2.1.131
  Qua Jun 27 15:02:26 BRT 2001
  * [27-JUN-2001] Arnaldo Carvalho de Melo <acme@conectiva.com.br> - cleanups
- *  
- * Parts (C) 1999 David Airlie, airlied@linux.ie 
- * [07-SEP-99] Bugfixes 
+ *
+ * Parts (C) 1999 David Airlie, airlied@linux.ie
+ * [07-SEP-99] Bugfixes
  *
  * [06-Jan-2002] Russell King <rmk@arm.linux.org.uk>
  * Converted to new serial core
 
 #include <linux/config.h>
 #include <linux/module.h>
-#include <linux/tty.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/console.h>
-#include <linux/serial.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
 #include <linux/serial_core.h>
+#include <linux/serial.h>
 
 #include <asm/bootinfo.h>
 #include <asm/dec/interrupts.h>
@@ -63,7 +64,7 @@ static struct dz_port dz_ports[DZ_NB_PORT];
 
 #ifdef DEBUG_DZ
 /*
- * debugging code to send out chars via prom 
+ * debugging code to send out chars via prom
  */
 static void debug_console(const char *s, int count)
 {
@@ -81,7 +82,7 @@ static void debug_console(const char *s, int count)
  * ------------------------------------------------------------
  * dz_in () and dz_out ()
  *
- * These routines are used to access the registers of the DZ 
+ * These routines are used to access the registers of the DZ
  * chip, hiding relocation differences between implementation.
  * ------------------------------------------------------------
  */
@@ -105,13 +106,13 @@ static inline void dz_out(struct dz_port *dport, unsigned offset,
  * ------------------------------------------------------------
  * rs_stop () and rs_start ()
  *
- * These routines are called before setting or resetting 
- * tty->stopped. They enable or disable transmitter interrupts, 
+ * These routines are called before setting or resetting
+ * tty->stopped. They enable or disable transmitter interrupts,
  * as necessary.
  * ------------------------------------------------------------
  */
 
-static void dz_stop_tx(struct uart_port *uport, unsigned int tty_stop)
+static void dz_stop_tx(struct uart_port *uport)
 {
        struct dz_port *dport = (struct dz_port *)uport;
        unsigned short tmp, mask = 1 << dport->port.line;
@@ -124,7 +125,7 @@ static void dz_stop_tx(struct uart_port *uport, unsigned int tty_stop)
        spin_unlock_irqrestore(&dport->port.lock, flags);
 }
 
-static void dz_start_tx(struct uart_port *uport, unsigned int tty_start)
+static void dz_start_tx(struct uart_port *uport)
 {
        struct dz_port *dport = (struct dz_port *)uport;
        unsigned short tmp, mask = 1 << dport->port.line;
@@ -155,17 +156,17 @@ static void dz_enable_ms(struct uart_port *port)
 
 /*
  * ------------------------------------------------------------
- * Here starts the interrupt handling routines.  All of the 
- * following subroutines are declared as inline and are folded 
- * into dz_interrupt.  They were separated out for readability's 
- * sake. 
+ * Here starts the interrupt handling routines.  All of the
+ * following subroutines are declared as inline and are folded
+ * into dz_interrupt.  They were separated out for readability's
+ * sake.
  *
  * Note: rs_interrupt() is a "fast" interrupt, which means that it
  * runs with interrupts turned off.  People who may want to modify
  * rs_interrupt() should try to keep the interrupt handler as fast as
  * possible.  After you are done making modifications, it is not a bad
  * idea to do:
- * 
+ *
  *     make drivers/serial/dz.s
  *
  * and look at the resulting assemble code in dz.s.
@@ -186,7 +187,7 @@ static inline void dz_receive_chars(struct dz_port *dport)
        struct uart_icount *icount;
        int ignore = 0;
        unsigned short status, tmp;
-       unsigned char ch;
+       unsigned char ch, flag;
 
        /* this code is going to be a problem...
           the call to tty_flip_buffer is going to need
@@ -201,6 +202,7 @@ static inline void dz_receive_chars(struct dz_port *dport)
 
 
                ch = UCHAR(status);     /* grab the char */
+               flag = TTY_NORMAL;
 
 #if 0
                if (info->is_console) {
@@ -214,11 +216,7 @@ static inline void dz_receive_chars(struct dz_port *dport)
 
                if (!tty)
                        break;
-               if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-                       break;
 
-               *tty->flip.char_buf_ptr = ch;
-               *tty->flip.flag_buf_ptr = 0;
                icount->rx++;
 
                /* keep track of the statistics */
@@ -243,12 +241,12 @@ static inline void dz_receive_chars(struct dz_port *dport)
                        tmp = status & dport->port.read_status_mask;
 
                        if (tmp & DZ_PERR) {
-                               *tty->flip.flag_buf_ptr = TTY_PARITY;
+                               flag = TTY_PARITY;
 #ifdef DEBUG_DZ
                                debug_console("PERR\n", 5);
 #endif
                        } else if (tmp & DZ_FERR) {
-                               *tty->flip.flag_buf_ptr = TTY_FRAME;
+                               flag = TTY_FRAME;
 #ifdef DEBUG_DZ
                                debug_console("FERR\n", 5);
 #endif
@@ -257,18 +255,14 @@ static inline void dz_receive_chars(struct dz_port *dport)
 #ifdef DEBUG_DZ
                                debug_console("OERR\n", 5);
 #endif
-                               if (tty->flip.count < TTY_FLIPBUF_SIZE) {
-                                       tty->flip.count++;
-                                       tty->flip.flag_buf_ptr++;
-                                       tty->flip.char_buf_ptr++;
-                                       *tty->flip.flag_buf_ptr = TTY_OVERRUN;
-                               }
+                               tty_insert_flip_char(tty, ch, flag);
+                               ch = 0;
+                               flag = TTY_OVERRUN;
                        }
                }
-               tty->flip.flag_buf_ptr++;
-               tty->flip.char_buf_ptr++;
-               tty->flip.count++;
+               tty_insert_flip_char(tty, ch, flag);
              ignore_char:
+                       ;
        } while (status & DZ_DVAL);
 
        if (tty)
@@ -295,7 +289,7 @@ static inline void dz_transmit_chars(struct dz_port *dport)
        }
        /* if nothing to do or stopped or hardware stopped */
        if (uart_circ_empty(xmit) || uart_tx_stopped(&dport->port)) {
-               dz_stop_tx(&dport->port, 0);
+               dz_stop_tx(&dport->port);
                return;
        }
 
@@ -313,7 +307,7 @@ static inline void dz_transmit_chars(struct dz_port *dport)
 
        /* Are we done */
        if (uart_circ_empty(xmit))
-               dz_stop_tx(&dport->port, 0);
+               dz_stop_tx(&dport->port);
 }
 
 /*
@@ -408,7 +402,7 @@ static void dz_set_mctrl(struct uart_port *uport, unsigned int mctrl)
  * startup ()
  *
  * various initialization tasks
- * ------------------------------------------------------------------- 
+ * -------------------------------------------------------------------
  */
 static int dz_startup(struct uart_port *uport)
 {
@@ -435,17 +429,17 @@ static int dz_startup(struct uart_port *uport)
        return 0;
 }
 
-/* 
+/*
  * -------------------------------------------------------------------
  * shutdown ()
  *
  * This routine will shutdown a serial port; interrupts are disabled, and
  * DTR is dropped if the hangup on close termio flag is on.
- * ------------------------------------------------------------------- 
+ * -------------------------------------------------------------------
  */
 static void dz_shutdown(struct uart_port *uport)
 {
-       dz_stop_tx(uport, 0);
+       dz_stop_tx(uport);
 }
 
 /*
@@ -456,7 +450,7 @@ static void dz_shutdown(struct uart_port *uport)
  *          release the bus after transmitting. This must be done when
  *          the transmit shift register is empty, not be done when the
  *          transmit holding register is empty.  This functionality
- *          allows an RS485 driver to be written in user space. 
+ *          allows an RS485 driver to be written in user space.
  */
 static unsigned int dz_tx_empty(struct uart_port *uport)
 {
@@ -650,14 +644,14 @@ static void __init dz_init_ports(void)
 
        if (mips_machtype == MACH_DS23100 ||
            mips_machtype == MACH_DS5100)
-               base = (unsigned long) KN01_DZ11_BASE;
+               base = CKSEG1ADDR(KN01_SLOT_BASE + KN01_DZ11);
        else
-               base = (unsigned long) KN02_DZ11_BASE;
+               base = CKSEG1ADDR(KN02_SLOT_BASE + KN02_DZ11);
 
        for (i = 0, dport = dz_ports; i < DZ_NB_PORT; i++, dport++) {
                spin_lock_init(&dport->port.lock);
                dport->port.membase     = (char *) base;
-               dport->port.iotype      = SERIAL_IO_PORT;
+               dport->port.iotype      = UPIO_PORT;
                dport->port.irq         = dec_interrupt[DEC_IRQ_DZ11];
                dport->port.line        = i;
                dport->port.fifosize    = 1;
@@ -700,13 +694,13 @@ static void dz_console_put_char(struct dz_port *dport, unsigned char ch)
 
        spin_unlock_irqrestore(&dport->port.lock, flags);
 }
-/* 
+/*
  * -------------------------------------------------------------------
  * dz_console_print ()
  *
  * dz_console_print is registered for printk.
  * The console must be locked when we get here.
- * ------------------------------------------------------------------- 
+ * -------------------------------------------------------------------
  */
 static void dz_console_print(struct console *cons,
                             const char *str,