/*
 * linux/drivers/char/serial167.c
 *
 * Driver for MVME166/7 board serial ports, which are via a CD2401.
 * Based very much on cyclades.c.
 *
 * MVME166/7 work by Richard Hirst [richard@sleepie.demon.co.uk]
 *
 * ==============================================================
 *
 * static char rcsid[] =
 * "$Revision: 1.36.1.4 $$Date: 1995/03/29 06:14:14 $";
 *
 *  linux/kernel/cyclades.c
 *
 * Maintained by Marcio Saito (cyclades@netcom.com) and
 * Randolph Bentson (bentson@grieg.seaslug.org)
 *
 * Much of the design and some of the code came from serial.c
 * which was copyright (C) 1991, 1992  Linus Torvalds.  It was
 * extensively rewritten by Theodore Ts'o, 8/16/92 -- 9/14/92,
 * and then fixed as suggested by Michael K. Johnson 12/12/92.
 *
 * This version does not support shared irq's.
 *
 * $Log: cyclades.c,v $
 * Revision 1.36.1.4  1995/03/29  06:14:14  bentson
 * disambiguate between Cyclom-16Y and Cyclom-32Ye;
 *
 * Changes:
 *
 * 200 lines of changes record removed - RGH 11-10-95, starting work on
 * converting this to drive serial ports on mvme166 (cd2401).
 *
 * Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 2000/08/25
 * - get rid of verify_area
 * - use get_user to access memory from userspace in set_threshold,
 *   set_default_threshold and set_timeout
 * - don't use the panic function in serial167_init
 * - do resource release on failure on serial167_init
 * - include missing restore_flags in mvme167_serial_console_setup
 *
 * Kars de Jong <jongk@linux-m68k.org> - 2004/09/06
 * - replace bottom half handler with task queue handler
 */

#include <linux/errno.h>
#include <linux/signal.h>
#include <linux/sched.h>
#include <linux/timer.h>
#include <linux/tty.h>
#include <linux/interrupt.h>
#include <linux/serial.h>
#include <linux/serialP.h>
#include <linux/string.h>
#include <linux/fcntl.h>
#include <linux/ptrace.h>
#include <linux/serial167.h>
#include <linux/delay.h>
#include <linux/major.h>
#include <linux/mm.h>
#include <linux/console.h>
#include <linux/module.h>
#include <linux/bitops.h>

#include <asm/system.h>
#include <asm/io.h>
#include <asm/mvme16xhw.h>
#include <asm/bootinfo.h>
#include <asm/setup.h>

#include <linux/types.h>
#include <linux/kernel.h>

#include <asm/uaccess.h>
#include <linux/init.h>

#define SERIAL_PARANOIA_CHECK
#undef  SERIAL_DEBUG_OPEN
#undef  SERIAL_DEBUG_THROTTLE
#undef  SERIAL_DEBUG_OTHER
#undef  SERIAL_DEBUG_IO
#undef  SERIAL_DEBUG_COUNT
#undef  SERIAL_DEBUG_DTR
#undef  CYCLOM_16Y_HACK
#define  CYCLOM_ENABLE_MONITORING

#define WAKEUP_CHARS 256

#define STD_COM_FLAGS (0)

#define SERIAL_TYPE_NORMAL  1

static struct tty_driver *cy_serial_driver;
extern int serial_console;
static struct cyclades_port *serial_console_info = NULL;
static unsigned int serial_console_cflag = 0;
u_char initial_console_speed;

/* Base address of cd2401 chip on mvme166/7 */

#define BASE_ADDR (0xfff45000)
#define pcc2chip	((volatile u_char *)0xfff42000)
#define PccSCCMICR	0x1d
#define PccSCCTICR	0x1e
#define PccSCCRICR	0x1f
#define PccTPIACKR	0x25
#define PccRPIACKR	0x27
#define PccIMLR		0x3f

/* This is the per-port data structure */
struct cyclades_port cy_port[] = {
      /* CARD#  */
        {-1 },      /* ttyS0 */
        {-1 },      /* ttyS1 */
        {-1 },      /* ttyS2 */
        {-1 },      /* ttyS3 */
};
#define NR_PORTS        ARRAY_SIZE(cy_port)

/*
 * This is used to look up the divisor speeds and the timeouts
 * We're normally limited to 15 distinct baud rates.  The extra
 * are accessed via settings in info->flags.
 *         0,     1,     2,     3,     4,     5,     6,     7,     8,     9,
 *        10,    11,    12,    13,    14,    15,    16,    17,    18,    19,
 *                                                  HI            VHI
 */
static int baud_table[] = {
           0,    50,    75,   110,   134,   150,   200,   300,   600,  1200,
        1800,  2400,  4800,  9600, 19200, 38400, 57600, 76800,115200,150000,
        0};

#if 0
static char baud_co[] = {  /* 25 MHz clock option table */
        /* value =>    00    01   02    03    04 */
        /* divide by    8    32   128   512  2048 */
        0x00,  0x04,  0x04,  0x04,  0x04,  0x04,  0x03,  0x03,  0x03,  0x02,
        0x02,  0x02,  0x01,  0x01,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00};

static char baud_bpr[] = {  /* 25 MHz baud rate period table */
        0x00,  0xf5,  0xa3,  0x6f,  0x5c,  0x51,  0xf5,  0xa3,  0x51,  0xa3,
        0x6d,  0x51,  0xa3,  0x51,  0xa3,  0x51,  0x36,  0x29,  0x1b,  0x15};
#endif

/* I think 166 brd clocks 2401 at 20MHz.... */

/* These values are written directly to tcor, and >> 5 for writing to rcor */
static u_char baud_co[] = {  /* 20 MHz clock option table */
        0x00,  0x80,  0x80,  0x80,  0x80,  0x80,  0x80,  0x60,  0x60,  0x40,
        0x40,  0x40,  0x20,  0x20,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00};

/* These values written directly to tbpr/rbpr */
static u_char baud_bpr[] = {  /* 20 MHz baud rate period table */
        0x00,  0xc0,  0x80,  0x58,  0x6c,  0x40,  0xc0,  0x81,  0x40,  0x81,
        0x57,  0x40,  0x81,  0x40,  0x81,  0x40,  0x2b,  0x20,  0x15,  0x10};

static u_char baud_cor4[] = {  /* receive threshold */
        0x0a,  0x0a,  0x0a,  0x0a,  0x0a,  0x0a,  0x0a,  0x0a,  0x0a,  0x0a,
        0x0a,  0x0a,  0x0a,  0x09,  0x09,  0x08,  0x08,  0x08,  0x08,  0x07};



static void shutdown(struct cyclades_port *);
static int startup (struct cyclades_port *);
static void cy_throttle(struct tty_struct *);
static void cy_unthrottle(struct tty_struct *);
static void config_setup(struct cyclades_port *);
extern void console_print(const char *);
#ifdef CYCLOM_SHOW_STATUS
static void show_status(int);
#endif

#ifdef CONFIG_REMOTE_DEBUG
static void debug_setup(void);
void queueDebugChar (int c);
int getDebugChar(void);

#define DEBUG_PORT	1
#define DEBUG_LEN	256

typedef struct {
	int	in;
	int	out;
	unsigned char	buf[DEBUG_LEN];
} debugq;

debugq debugiq;
#endif

/*
 * I have my own version of udelay(), as it is needed when initialising
 * the chip, before the delay loop has been calibrated.  Should probably
 * reference one of the vmechip2 or pccchip2 counter for an accurate
 * delay, but this wild guess will do for now.
 */

void my_udelay (long us)
{
	u_char x;
	volatile u_char *p = &x;
	int i;

	while (us--)
		for (i = 100; i; i--)
			x |= *p;
}

static inline int
serial_paranoia_check(struct cyclades_port *info, char *name,
		      const char *routine)
{
#ifdef SERIAL_PARANOIA_CHECK
    static const char *badmagic =
	"Warning: bad magic number for serial struct (%s) in %s\n";
    static const char *badinfo =
	"Warning: null cyclades_port for (%s) in %s\n";
    static const char *badrange =
	"Warning: cyclades_port out of range for (%s) in %s\n";

    if (!info) {
	printk(badinfo, name, routine);
	return 1;
    }

    if( (long)info < (long)(&cy_port[0])
    || (long)(&cy_port[NR_PORTS]) < (long)info ){
	printk(badrange, name, routine);
	return 1;
    }

    if (info->magic != CYCLADES_MAGIC) {
	printk(badmagic, name, routine);
	return 1;
    }
#endif
	return 0;
} /* serial_paranoia_check */

#if 0
/* The following diagnostic routines allow the driver to spew
   information on the screen, even (especially!) during interrupts.
 */
void
SP(char *data){
  unsigned long flags;
    local_irq_save(flags);
        console_print(data);
    local_irq_restore(flags);
}
char scrn[2];
void
CP(char data){
  unsigned long flags;
    local_irq_save(flags);
        scrn[0] = data;
        console_print(scrn);
    local_irq_restore(flags);
}/* CP */

void CP1(int data) { (data<10)?  CP(data+'0'): CP(data+'A'-10); }/* CP1 */
void CP2(int data) { CP1((data>>4) & 0x0f); CP1( data & 0x0f); }/* CP2 */
void CP4(int data) { CP2((data>>8) & 0xff); CP2(data & 0xff); }/* CP4 */
void CP8(long data) { CP4((data>>16) & 0xffff); CP4(data & 0xffff); }/* CP8 */
#endif

/* This routine waits up to 1000 micro-seconds for the previous
   command to the Cirrus chip to complete and then issues the
   new command.  An error is returned if the previous command
   didn't finish within the time limit.
 */
u_short
write_cy_cmd(volatile u_char *base_addr, u_char cmd)
{
  unsigned long flags;
  volatile int  i;

    local_irq_save(flags);
	/* Check to see that the previous command has completed */
	for(i = 0 ; i < 100 ; i++){
	    if (base_addr[CyCCR] == 0){
		break;
	    }
	    my_udelay(10L);
	}
	/* if the CCR never cleared, the previous command
	    didn't finish within the "reasonable time" */
	if ( i == 10 ) {
	    local_irq_restore(flags);
	    return (-1);
	}

	/* Issue the new command */
	base_addr[CyCCR] = cmd;
    local_irq_restore(flags);
    return(0);
} /* write_cy_cmd */


/* cy_start and cy_stop provide software output flow control as a
   function of XON/XOFF, software CTS, and other such stuff. */

static void
cy_stop(struct tty_struct *tty)
{
  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
  volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
  int channel;
  unsigned long flags;

#ifdef SERIAL_DEBUG_OTHER
    printk("cy_stop %s\n", tty->name); /* */
#endif

    if (serial_paranoia_check(info, tty->name, "cy_stop"))
	return;
	
    channel = info->line;

    local_irq_save(flags);
        base_addr[CyCAR] = (u_char)(channel); /* index channel */
        base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
    local_irq_restore(flags);

    return;
} /* cy_stop */

static void
cy_start(struct tty_struct *tty)
{
  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
  volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
  int channel;
  unsigned long flags;

#ifdef SERIAL_DEBUG_OTHER
    printk("cy_start %s\n", tty->name); /* */
#endif

    if (serial_paranoia_check(info, tty->name, "cy_start"))
	return;
	
    channel = info->line;

    local_irq_save(flags);
        base_addr[CyCAR] = (u_char)(channel);
        base_addr[CyIER] |= CyTxMpty;
    local_irq_restore(flags);

    return;
} /* cy_start */


/*
 * This routine is used by the interrupt handler to schedule
 * processing in the software interrupt portion of the driver
 * (also known as the "bottom half").  This can be called any
 * number of times for any channel without harm.
 */
static inline void
cy_sched_event(struct cyclades_port *info, int event)
{
    info->event |= 1 << event; /* remember what kind of event and who */
    schedule_work(&info->tqueue);
} /* cy_sched_event */


/* The real interrupt service routines are called
   whenever the card wants its hand held--chars
   received, out buffer empty, modem change, etc.
 */
static irqreturn_t
cd2401_rxerr_interrupt(int irq, void *dev_id)
{
    struct tty_struct *tty;
    struct cyclades_port *info;
    volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
    unsigned char err, rfoc;
    int channel;
    char data;

    /* determine the channel and change to that context */
    channel = (u_short ) (base_addr[CyLICR] >> 2);
    info = &cy_port[channel];
    info->last_active = jiffies;

    if ((err = base_addr[CyRISR]) & CyTIMEOUT) {
	/* This is a receive timeout interrupt, ignore it */
	base_addr[CyREOIR] = CyNOTRANS;
	return IRQ_HANDLED;
    }

    /* Read a byte of data if there is any - assume the error
     * is associated with this character */

    if ((rfoc = base_addr[CyRFOC]) != 0)
	data = base_addr[CyRDR];
    else
	data = 0;

    /* if there is nowhere to put the data, discard it */
    if(info->tty == 0) {
	base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
	return IRQ_HANDLED;
    }
    else { /* there is an open port for this data */
	tty = info->tty;
	if(err & info->ignore_status_mask){
	    base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
	    return IRQ_HANDLED;
	}
	if (tty_buffer_request_room(tty, 1) != 0){
	    if (err & info->read_status_mask){
		if(err & CyBREAK){
		    tty_insert_flip_char(tty, data, TTY_BREAK);
		    if (info->flags & ASYNC_SAK){
			do_SAK(tty);
		    }
		}else if(err & CyFRAME){
		    tty_insert_flip_char(tty, data, TTY_FRAME);
		}else if(err & CyPARITY){
		    tty_insert_flip_char(tty, data, TTY_PARITY);
		}else if(err & CyOVERRUN){
		    tty_insert_flip_char(tty, 0, TTY_OVERRUN);
		    /*
		       If the flip buffer itself is
		       overflowing, we still loose
		       the next incoming character.
		     */
		    tty_insert_flip_char(tty, data, TTY_NORMAL);
		}
		/* These two conditions may imply */
		/* a normal read should be done. */
		/* else if(data & CyTIMEOUT) */
		/* else if(data & CySPECHAR) */
		}else{
		    tty_insert_flip_char(tty, 0, TTY_NORMAL);
		}
	    }else{
		    tty_insert_flip_char(tty, data, TTY_NORMAL);
	    }
	}else{
	    /* there was a software buffer overrun
	       and nothing could be done about it!!! */
	}
    }
    schedule_delayed_work(&tty->flip.work, 1);
    /* end of service */
    base_addr[CyREOIR] = rfoc ? 0 : CyNOTRANS;
    return IRQ_HANDLED;
} /* cy_rxerr_interrupt */

static irqreturn_t
cd2401_modem_interrupt(int irq, void *dev_id)
{
    struct cyclades_port *info;
    volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
    int channel;
    int mdm_change;
    int mdm_status;


    /* determine the channel and change to that context */
    channel = (u_short ) (base_addr[CyLICR] >> 2);
    info = &cy_port[channel];
    info->last_active = jiffies;

    mdm_change = base_addr[CyMISR];
    mdm_status = base_addr[CyMSVR1];

    if(info->tty == 0){ /* nowhere to put the data, ignore it */
	;
    }else{
	if((mdm_change & CyDCD)
	&& (info->flags & ASYNC_CHECK_CD)){
	    if(mdm_status & CyDCD){
/* CP('!'); */
		cy_sched_event(info, Cy_EVENT_OPEN_WAKEUP);
	    } else {
/* CP('@'); */
		cy_sched_event(info, Cy_EVENT_HANGUP);
	    }
	}
	if((mdm_change & CyCTS)
	&& (info->flags & ASYNC_CTS_FLOW)){
	    if(info->tty->stopped){
		if(mdm_status & CyCTS){
		    /* !!! cy_start isn't used because... */
		    info->tty->stopped = 0;
        	    base_addr[CyIER] |= CyTxMpty;
		    cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
		}
	    }else{
		if(!(mdm_status & CyCTS)){
		    /* !!! cy_stop isn't used because... */
		    info->tty->stopped = 1;
        	    base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
		}
	    }
	}
	if(mdm_status & CyDSR){
	}
    }
    base_addr[CyMEOIR] = 0;
    return IRQ_HANDLED;
} /* cy_modem_interrupt */

static irqreturn_t
cd2401_tx_interrupt(int irq, void *dev_id)
{
    struct cyclades_port *info;
    volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
    int channel;
    int char_count, saved_cnt;
    int outch;

    /* determine the channel and change to that context */
    channel = (u_short ) (base_addr[CyLICR] >> 2);

#ifdef CONFIG_REMOTE_DEBUG
    if (channel == DEBUG_PORT) {
	panic ("TxInt on debug port!!!");
    }
#endif

    info = &cy_port[channel];

    /* validate the port number (as configured and open) */
    if( (channel < 0) || (NR_PORTS <= channel) ){
	base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
	base_addr[CyTEOIR] = CyNOTRANS;
	return IRQ_HANDLED;
    }
    info->last_active = jiffies;
    if(info->tty == 0){
	base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
        if (info->xmit_cnt < WAKEUP_CHARS) {
	    cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
        }
	base_addr[CyTEOIR] = CyNOTRANS;
	return IRQ_HANDLED;
    }

    /* load the on-chip space available for outbound data */
    saved_cnt = char_count = base_addr[CyTFTC];

    if(info->x_char) { /* send special char */
	outch = info->x_char;
	base_addr[CyTDR] = outch;
	char_count--;
	info->x_char = 0;
    }

    if (info->x_break){
	/*  The Cirrus chip requires the "Embedded Transmit
	    Commands" of start break, delay, and end break
	    sequences to be sent.  The duration of the
	    break is given in TICs, which runs at HZ
	    (typically 100) and the PPR runs at 200 Hz,
	    so the delay is duration * 200/HZ, and thus a
	    break can run from 1/100 sec to about 5/4 sec.
	    Need to check these values - RGH 141095.
	 */
	base_addr[CyTDR] = 0; /* start break */
	base_addr[CyTDR] = 0x81;
	base_addr[CyTDR] = 0; /* delay a bit */
	base_addr[CyTDR] = 0x82;
	base_addr[CyTDR] = info->x_break*200/HZ;
	base_addr[CyTDR] = 0; /* terminate break */
	base_addr[CyTDR] = 0x83;
	char_count -= 7;
	info->x_break = 0;
    }

    while (char_count > 0){
	if (!info->xmit_cnt){
	    base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
	    break;
	}
	if (info->xmit_buf == 0){
	    base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
	    break;
	}
	if (info->tty->stopped || info->tty->hw_stopped){
	    base_addr[CyIER] &= ~(CyTxMpty|CyTxRdy);
	    break;
	}
	/* Because the Embedded Transmit Commands have been
	   enabled, we must check to see if the escape
	   character, NULL, is being sent.  If it is, we
	   must ensure that there is room for it to be
	   doubled in the output stream.  Therefore we
	   no longer advance the pointer when the character
	   is fetched, but rather wait until after the check
	   for a NULL output character. (This is necessary
	   because there may not be room for the two chars
	   needed to send a NULL.
	 */
	outch = info->xmit_buf[info->xmit_tail];
	if( outch ){
	    info->xmit_cnt--;
	    info->xmit_tail = (info->xmit_tail + 1)
				      & (PAGE_SIZE - 1);
	    base_addr[CyTDR] = outch;
	    char_count--;
	}else{
	    if(char_count > 1){
		info->xmit_cnt--;
		info->xmit_tail = (info->xmit_tail + 1)
					  & (PAGE_SIZE - 1);
		base_addr[CyTDR] = outch;
		base_addr[CyTDR] = 0;
		char_count--;
		char_count--;
	    }else{
		break;
	    }
	}
    }

    if (info->xmit_cnt < WAKEUP_CHARS) {
	cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
    }
    base_addr[CyTEOIR] = (char_count != saved_cnt) ? 0 : CyNOTRANS;
    return IRQ_HANDLED;
} /* cy_tx_interrupt */

static irqreturn_t
cd2401_rx_interrupt(int irq, void *dev_id)
{
    struct tty_struct *tty;
    struct cyclades_port *info;
    volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
    int channel;
    char data;
    int char_count;
    int save_cnt;

    /* determine the channel and change to that context */
    channel = (u_short ) (base_addr[CyLICR] >> 2);
    info = &cy_port[channel];
    info->last_active = jiffies;
    save_cnt = char_count = base_addr[CyRFOC];

#ifdef CONFIG_REMOTE_DEBUG
    if (channel == DEBUG_PORT) {
	while (char_count--) {
            data = base_addr[CyRDR];
	    queueDebugChar(data);
	}
    }
    else
#endif
    /* if there is nowhere to put the data, discard it */
    if(info->tty == 0){
	while(char_count--){
	    data = base_addr[CyRDR];
	}
    }else{ /* there is an open port for this data */
	tty = info->tty;
	/* load # characters available from the chip */

#ifdef CYCLOM_ENABLE_MONITORING
	++info->mon.int_count;
	info->mon.char_count += char_count;
	if (char_count > info->mon.char_max)
	    info->mon.char_max = char_count;
	info->mon.char_last = char_count;
#endif
	while(char_count--){
	    data = base_addr[CyRDR];
	    tty_insert_flip_char(tty, data, TTY_NORMAL);
#ifdef CYCLOM_16Y_HACK
	    udelay(10L);
#endif
        }
	schedule_delayed_work(&tty->flip.work, 1);
    }
    /* end of service */
    base_addr[CyREOIR] = save_cnt ? 0 : CyNOTRANS;
    return IRQ_HANDLED;
} /* cy_rx_interrupt */

/*
 * This routine is used to handle the "bottom half" processing for the
 * serial driver, known also the "software interrupt" processing.
 * This processing is done at the kernel interrupt level, after the
 * cy#/_interrupt() has returned, BUT WITH INTERRUPTS TURNED ON.  This
 * is where time-consuming activities which can not be done in the
 * interrupt driver proper are done; the interrupt driver schedules
 * them using cy_sched_event(), and they get done here.
 *
 * This is done through one level of indirection--the task queue.
 * When a hardware interrupt service routine wants service by the
 * driver's bottom half, it enqueues the appropriate tq_struct (one
 * per port) to the keventd work queue and sets a request flag
 * that the work queue be processed.
 *
 * Although this may seem unwieldy, it gives the system a way to
 * pass an argument (in this case the pointer to the cyclades_port
 * structure) to the bottom half of the driver.  Previous kernels
 * had to poll every port to see if that port needed servicing.
 */
static void
do_softint(void *private_)
{
  struct cyclades_port *info = (struct cyclades_port *) private_;
  struct tty_struct    *tty;

    tty = info->tty;
    if (!tty)
	return;

    if (test_and_clear_bit(Cy_EVENT_HANGUP, &info->event)) {
	tty_hangup(info->tty);
	wake_up_interruptible(&info->open_wait);
	info->flags &= ~ASYNC_NORMAL_ACTIVE;
    }
    if (test_and_clear_bit(Cy_EVENT_OPEN_WAKEUP, &info->event)) {
	wake_up_interruptible(&info->open_wait);
    }
    if (test_and_clear_bit(Cy_EVENT_WRITE_WAKEUP, &info->event)) {
    	tty_wakeup(tty);
    }
} /* do_softint */


/* This is called whenever a port becomes active;
   interrupts are enabled and DTR & RTS are turned on.
 */
static int
startup(struct cyclades_port * info)
{
  unsigned long flags;
  volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR;
  int channel;

    if (info->flags & ASYNC_INITIALIZED){
	return 0;
    }

    if (!info->type){
	if (info->tty){
	    set_bit(TTY_IO_ERROR, &info->tty->flags);
	}
	return 0;
    }
    if (!info->xmit_buf){
	info->xmit_buf = (unsigned char *) get_zeroed_page (GFP_KERNEL);
	if (!info->xmit_buf){
	    return -ENOMEM;
	}
    }

    config_setup(info);

    channel = info->line;

#ifdef SERIAL_DEBUG_OPEN
    printk("startup channel %d\n", channel);
#endif

    local_irq_save(flags);
	base_addr[CyCAR] = (u_char)channel;
	write_cy_cmd(base_addr,CyENB_RCVR|CyENB_XMTR);

	base_addr[CyCAR] = (u_char)channel; /* !!! Is this needed? */
	base_addr[CyMSVR1] = CyRTS;
/* CP('S');CP('1'); */
	base_addr[CyMSVR2] = CyDTR;

#ifdef SERIAL_DEBUG_DTR
        printk("cyc: %d: raising DTR\n", __LINE__);
        printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
#endif

	base_addr[CyIER] |= CyRxData;
	info->flags |= ASYNC_INITIALIZED;

	if (info->tty){
	    clear_bit(TTY_IO_ERROR, &info->tty->flags);
	}
	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;

    local_irq_restore(flags);

#ifdef SERIAL_DEBUG_OPEN
    printk(" done\n");
#endif
    return 0;
} /* startup */

void
start_xmit( struct cyclades_port *info )
{
  unsigned long flags;
  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
  int channel;

    channel = info->line;
    local_irq_save(flags);
	base_addr[CyCAR] = channel;
	base_addr[CyIER] |= CyTxMpty;
    local_irq_restore(flags);
} /* start_xmit */

/*
 * This routine shuts down a serial port; interrupts are disabled,
 * and DTR is dropped if the hangup on close termio flag is on.
 */
static void
shutdown(struct cyclades_port * info)
{
  unsigned long flags;
  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
  int channel;

    if (!(info->flags & ASYNC_INITIALIZED)){
/* CP('$'); */
	return;
    }

    channel = info->line;

#ifdef SERIAL_DEBUG_OPEN
    printk("shutdown channel %d\n", channel);
#endif

    /* !!! REALLY MUST WAIT FOR LAST CHARACTER TO BE
       SENT BEFORE DROPPING THE LINE !!!  (Perhaps
       set some flag that is read when XMTY happens.)
       Other choices are to delay some fixed interval
       or schedule some later processing.
     */
    local_irq_save(flags);
	if (info->xmit_buf){
	    free_page((unsigned long) info->xmit_buf);
	    info->xmit_buf = 0;
	}

	base_addr[CyCAR] = (u_char)channel;
	if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
	    base_addr[CyMSVR1] = 0;
/* CP('C');CP('1'); */
	    base_addr[CyMSVR2] = 0;
#ifdef SERIAL_DEBUG_DTR
            printk("cyc: %d: dropping DTR\n", __LINE__);
            printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
#endif
        }
	write_cy_cmd(base_addr,CyDIS_RCVR);
         /* it may be appropriate to clear _XMIT at
           some later date (after testing)!!! */

	if (info->tty){
	    set_bit(TTY_IO_ERROR, &info->tty->flags);
	}
	info->flags &= ~ASYNC_INITIALIZED;
    local_irq_restore(flags);

#ifdef SERIAL_DEBUG_OPEN
    printk(" done\n");
#endif
    return;
} /* shutdown */

/*
 * This routine finds or computes the various line characteristics.
 */
static void
config_setup(struct cyclades_port * info)
{
  unsigned long flags;
  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
  int channel;
  unsigned cflag;
  int   i;
  unsigned char ti, need_init_chan = 0;

    if (!info->tty || !info->tty->termios){
        return;
    }
    if (info->line == -1){
        return;
    }
    cflag = info->tty->termios->c_cflag;

    /* baud rate */
    i = cflag & CBAUD;
#ifdef CBAUDEX
/* Starting with kernel 1.1.65, there is direct support for
   higher baud rates.  The following code supports those
   changes.  The conditional aspect allows this driver to be
   used for earlier as well as later kernel versions.  (The
   mapping is slightly different from serial.c because there
   is still the possibility of supporting 75 kbit/sec with
   the Cyclades board.)
 */
    if (i & CBAUDEX) {
	if (i == B57600)
	    i = 16;
	else if(i == B115200) 
	    i = 18;
#ifdef B78600
	else if(i == B78600) 
	    i = 17;
#endif
	else
	    info->tty->termios->c_cflag &= ~CBAUDEX;
    }
#endif
    if (i == 15) {
	    if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
		    i += 1;
	    if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
		    i += 3;
    }
    /* Don't ever change the speed of the console port.  It will
     * run at the speed specified in bootinfo, or at 19.2K */
    /* Actually, it should run at whatever speed 166Bug was using */
    /* Note info->timeout isn't used at present */
    if (info != serial_console_info) {
	info->tbpr = baud_bpr[i]; /* Tx BPR */
	info->tco = baud_co[i]; /* Tx CO */
	info->rbpr = baud_bpr[i]; /* Rx BPR */
	info->rco = baud_co[i] >> 5; /* Rx CO */
	if (baud_table[i] == 134) {
            info->timeout = (info->xmit_fifo_size*HZ*30/269) + 2;
            /* get it right for 134.5 baud */
	} else if (baud_table[i]) {
            info->timeout = (info->xmit_fifo_size*HZ*15/baud_table[i]) + 2;
        /* this needs to be propagated into the card info */
	} else {
            info->timeout = 0;
	}
    }
    /* By tradition (is it a standard?) a baud rate of zero
       implies the line should be/has been closed.  A bit
       later in this routine such a test is performed. */

    /* byte size and parity */
    info->cor7 = 0;
    info->cor6 = 0;
    info->cor5 = 0;
    info->cor4 = (info->default_threshold
		  ? info->default_threshold
		  : baud_cor4[i]); /* receive threshold */
    /* Following two lines added 101295, RGH. */
    /* It is obviously wrong to access CyCORx, and not info->corx here,
     * try and remember to fix it later! */
    channel = info->line;
    base_addr[CyCAR] = (u_char)channel;
    if (C_CLOCAL(info->tty)) {
	if (base_addr[CyIER] & CyMdmCh)
	    base_addr[CyIER] &= ~CyMdmCh; /* without modem intr */
			       /* ignore 1->0 modem transitions */
	if (base_addr[CyCOR4] & (CyDSR|CyCTS|CyDCD))
	    base_addr[CyCOR4] &= ~(CyDSR|CyCTS|CyDCD);
			       /* ignore 0->1 modem transitions */
	if (base_addr[CyCOR5] & (CyDSR|CyCTS|CyDCD))
	    base_addr[CyCOR5] &= ~(CyDSR|CyCTS|CyDCD);
    } else {
	if ((base_addr[CyIER] & CyMdmCh) != CyMdmCh)
	    base_addr[CyIER] |= CyMdmCh; /* with modem intr */
			       /* act on 1->0 modem transitions */
	if ((base_addr[CyCOR4] & (CyDSR|CyCTS|CyDCD)) != (CyDSR|CyCTS|CyDCD))
	    base_addr[CyCOR4] |= CyDSR|CyCTS|CyDCD;
			       /* act on 0->1 modem transitions */
	if ((base_addr[CyCOR5] & (CyDSR|CyCTS|CyDCD)) != (CyDSR|CyCTS|CyDCD))
	    base_addr[CyCOR5] |= CyDSR|CyCTS|CyDCD;
    }
    info->cor3 = (cflag & CSTOPB) ? Cy_2_STOP : Cy_1_STOP;
    info->cor2 = CyETC;
    switch(cflag & CSIZE){
    case CS5:
        info->cor1 = Cy_5_BITS;
        break;
    case CS6:
        info->cor1 = Cy_6_BITS;
        break;
    case CS7:
        info->cor1 = Cy_7_BITS;
        break;
    case CS8:
        info->cor1 = Cy_8_BITS;
        break;
    }
    if (cflag & PARENB){
        if (cflag & PARODD){
            info->cor1 |= CyPARITY_O;
        }else{
            info->cor1 |= CyPARITY_E;
        }
    }else{
        info->cor1 |= CyPARITY_NONE;
    }
	
    /* CTS flow control flag */
#if 0
    /* Don't complcate matters for now! RGH 141095 */
    if (cflag & CRTSCTS){
	info->flags |= ASYNC_CTS_FLOW;
	info->cor2 |= CyCtsAE;
    }else{
	info->flags &= ~ASYNC_CTS_FLOW;
	info->cor2 &= ~CyCtsAE;
    }
#endif
    if (cflag & CLOCAL)
	info->flags &= ~ASYNC_CHECK_CD;
    else
	info->flags |= ASYNC_CHECK_CD;

     /***********************************************
	The hardware option, CyRtsAO, presents RTS when
	the chip has characters to send.  Since most modems
	use RTS as reverse (inbound) flow control, this
	option is not used.  If inbound flow control is
	necessary, DTR can be programmed to provide the
	appropriate signals for use with a non-standard
	cable.  Contact Marcio Saito for details.
     ***********************************************/

    channel = info->line;

    local_irq_save(flags);
	base_addr[CyCAR] = (u_char)channel;

	/* CyCMR set once only in mvme167_init_serial() */
	if (base_addr[CyLICR] != channel << 2)
	    base_addr[CyLICR] = channel << 2;
	if (base_addr[CyLIVR] != 0x5c)
	    base_addr[CyLIVR] = 0x5c;

       /* tx and rx baud rate */

	if (base_addr[CyCOR1] != info->cor1)
	    need_init_chan = 1;
	if (base_addr[CyTCOR] != info->tco)
	    base_addr[CyTCOR] = info->tco;
	if (base_addr[CyTBPR] != info->tbpr)
	    base_addr[CyTBPR] = info->tbpr;
	if (base_addr[CyRCOR] != info->rco)
	    base_addr[CyRCOR] = info->rco;
	if (base_addr[CyRBPR] != info->rbpr)
	    base_addr[CyRBPR] = info->rbpr;

	/* set line characteristics  according configuration */

	if (base_addr[CySCHR1] != START_CHAR(info->tty))
	    base_addr[CySCHR1] = START_CHAR(info->tty);
	if (base_addr[CySCHR2] != STOP_CHAR(info->tty))
	    base_addr[CySCHR2] = STOP_CHAR(info->tty);
	if (base_addr[CySCRL] != START_CHAR(info->tty))
	    base_addr[CySCRL] = START_CHAR(info->tty);
	if (base_addr[CySCRH] != START_CHAR(info->tty))
	    base_addr[CySCRH] = START_CHAR(info->tty);
	if (base_addr[CyCOR1] != info->cor1)
	    base_addr[CyCOR1] = info->cor1;
	if (base_addr[CyCOR2] != info->cor2)
	    base_addr[CyCOR2] = info->cor2;
	if (base_addr[CyCOR3] != info->cor3)
	    base_addr[CyCOR3] = info->cor3;
	if (base_addr[CyCOR4] != info->cor4)
	    base_addr[CyCOR4] = info->cor4;
	if (base_addr[CyCOR5] != info->cor5)
	    base_addr[CyCOR5] = info->cor5;
	if (base_addr[CyCOR6] != info->cor6)
	    base_addr[CyCOR6] = info->cor6;
	if (base_addr[CyCOR7] != info->cor7)
	    base_addr[CyCOR7] = info->cor7;

	if (need_init_chan)
	    write_cy_cmd(base_addr,CyINIT_CHAN);

	base_addr[CyCAR] = (u_char)channel; /* !!! Is this needed? */

	/* 2ms default rx timeout */
	ti = info->default_timeout ? info->default_timeout : 0x02;
	if (base_addr[CyRTPRL] != ti)
	    base_addr[CyRTPRL] = ti;
	if (base_addr[CyRTPRH] != 0)
	    base_addr[CyRTPRH] = 0;

	/* Set up RTS here also ????? RGH 141095 */
	if(i == 0){ /* baud rate is zero, turn off line */
	    if ((base_addr[CyMSVR2] & CyDTR) == CyDTR)
	        base_addr[CyMSVR2] = 0;
#ifdef SERIAL_DEBUG_DTR
            printk("cyc: %d: dropping DTR\n", __LINE__);
            printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
#endif
	}else{
	    if ((base_addr[CyMSVR2] & CyDTR) != CyDTR)
	        base_addr[CyMSVR2] = CyDTR;
#ifdef SERIAL_DEBUG_DTR
            printk("cyc: %d: raising DTR\n", __LINE__);
            printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
#endif
	}

	if (info->tty){
	    clear_bit(TTY_IO_ERROR, &info->tty->flags);
	}

    local_irq_restore(flags);

} /* config_setup */


static void
cy_put_char(struct tty_struct *tty, unsigned char ch)
{
  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
  unsigned long flags;

#ifdef SERIAL_DEBUG_IO
    printk("cy_put_char %s(0x%02x)\n", tty->name, ch);
#endif

    if (serial_paranoia_check(info, tty->name, "cy_put_char"))
	return;

    if (!info->xmit_buf)
	return;

    local_irq_save(flags);
	if (info->xmit_cnt >= PAGE_SIZE - 1) {
	    local_irq_restore(flags);
	    return;
	}

	info->xmit_buf[info->xmit_head++] = ch;
	info->xmit_head &= PAGE_SIZE - 1;
	info->xmit_cnt++;
    local_irq_restore(flags);
} /* cy_put_char */


static void
cy_flush_chars(struct tty_struct *tty)
{
  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
  unsigned long flags;
  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
  int channel;
				
#ifdef SERIAL_DEBUG_IO
    printk("cy_flush_chars %s\n", tty->name); /* */
#endif

    if (serial_paranoia_check(info, tty->name, "cy_flush_chars"))
	return;

    if (info->xmit_cnt <= 0 || tty->stopped
    || tty->hw_stopped || !info->xmit_buf)
	return;

    channel = info->line;

    local_irq_save(flags);
	base_addr[CyCAR] = channel;
	base_addr[CyIER] |= CyTxMpty;
    local_irq_restore(flags);
} /* cy_flush_chars */


/* This routine gets called when tty_write has put something into
    the write_queue.  If the port is not already transmitting stuff,
    start it off by enabling interrupts.  The interrupt service
    routine will then ensure that the characters are sent.  If the
    port is already active, there is no need to kick it.
 */
static int
cy_write(struct tty_struct * tty,
           const unsigned char *buf, int count)
{
  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
  unsigned long flags;
  int c, total = 0;

#ifdef SERIAL_DEBUG_IO
    printk("cy_write %s\n", tty->name); /* */
#endif

    if (serial_paranoia_check(info, tty->name, "cy_write")){
	return 0;
    }
	
    if (!info->xmit_buf){
        return 0;
    }

    while (1) {
	    local_irq_save(flags);
	    c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
				      SERIAL_XMIT_SIZE - info->xmit_head));
	    if (c <= 0) {
		    local_irq_restore(flags);
		    break;
	    }

	    memcpy(info->xmit_buf + info->xmit_head, buf, c);
	    info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
	    info->xmit_cnt += c;
	    local_irq_restore(flags);

	    buf += c;
	    count -= c;
	    total += c;
    }

    if (info->xmit_cnt
    && !tty->stopped
    && !tty->hw_stopped ) {
        start_xmit(info);
    }
    return total;
} /* cy_write */


static int
cy_write_room(struct tty_struct *tty)
{
  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
  int	ret;
				
#ifdef SERIAL_DEBUG_IO
    printk("cy_write_room %s\n", tty->name); /* */
#endif

    if (serial_paranoia_check(info, tty->name, "cy_write_room"))
	return 0;
    ret = PAGE_SIZE - info->xmit_cnt - 1;
    if (ret < 0)
	ret = 0;
    return ret;
} /* cy_write_room */


static int
cy_chars_in_buffer(struct tty_struct *tty)
{
  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
				
#ifdef SERIAL_DEBUG_IO
    printk("cy_chars_in_buffer %s %d\n", tty->name, info->xmit_cnt); /* */
#endif

    if (serial_paranoia_check(info, tty->name, "cy_chars_in_buffer"))
	return 0;

    return info->xmit_cnt;
} /* cy_chars_in_buffer */


static void
cy_flush_buffer(struct tty_struct *tty)
{
  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
  unsigned long flags;
				
#ifdef SERIAL_DEBUG_IO
    printk("cy_flush_buffer %s\n", tty->name); /* */
#endif

    if (serial_paranoia_check(info, tty->name, "cy_flush_buffer"))
	return;
    local_irq_save(flags);
	info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
    local_irq_restore(flags);
    tty_wakeup(tty);
} /* cy_flush_buffer */


/* This routine is called by the upper-layer tty layer to signal
   that incoming characters should be throttled or that the
   throttle should be released.
 */
static void
cy_throttle(struct tty_struct * tty)
{
  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
  unsigned long flags;
  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
  int channel;

#ifdef SERIAL_DEBUG_THROTTLE
  char buf[64];
	
    printk("throttle %s: %d....\n", tty_name(tty, buf),
	   tty->ldisc.chars_in_buffer(tty));
    printk("cy_throttle %s\n", tty->name);
#endif

    if (serial_paranoia_check(info, tty->name, "cy_nthrottle")){
	    return;
    }

    if (I_IXOFF(tty)) {
	info->x_char = STOP_CHAR(tty);
	    /* Should use the "Send Special Character" feature!!! */
    }

    channel = info->line;

    local_irq_save(flags);
	base_addr[CyCAR] = (u_char)channel;
	base_addr[CyMSVR1] = 0;
    local_irq_restore(flags);

    return;
} /* cy_throttle */


static void
cy_unthrottle(struct tty_struct * tty)
{
  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
  unsigned long flags;
  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
  int channel;

#ifdef SERIAL_DEBUG_THROTTLE
  char buf[64];
	
    printk("throttle %s: %d....\n", tty_name(tty, buf),
	   tty->ldisc.chars_in_buffer(tty));
    printk("cy_unthrottle %s\n", tty->name);
#endif

    if (serial_paranoia_check(info, tty->name, "cy_nthrottle")){
	    return;
    }

    if (I_IXOFF(tty)) {
	info->x_char = START_CHAR(tty);
	/* Should use the "Send Special Character" feature!!! */
    }

    channel = info->line;

    local_irq_save(flags);
	base_addr[CyCAR] = (u_char)channel;
	base_addr[CyMSVR1] = CyRTS;
    local_irq_restore(flags);

    return;
} /* cy_unthrottle */

static int
get_serial_info(struct cyclades_port * info,
                           struct serial_struct * retinfo)
{
  struct serial_struct tmp;

/* CP('g'); */
    if (!retinfo)
            return -EFAULT;
    memset(&tmp, 0, sizeof(tmp));
    tmp.type = info->type;
    tmp.line = info->line;
    tmp.port = info->line;
    tmp.irq = 0;
    tmp.flags = info->flags;
    tmp.baud_base = 0;          /*!!!*/
    tmp.close_delay = info->close_delay;
    tmp.custom_divisor = 0;     /*!!!*/
    tmp.hub6 = 0;               /*!!!*/
    return copy_to_user(retinfo,&tmp,sizeof(*retinfo)) ? -EFAULT : 0;
} /* get_serial_info */

static int
set_serial_info(struct cyclades_port * info,
                           struct serial_struct * new_info)
{
  struct serial_struct new_serial;
  struct cyclades_port old_info;

/* CP('s'); */
    if (!new_info)
	    return -EFAULT;
    if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
	    return -EFAULT;
    old_info = *info;

    if (!capable(CAP_SYS_ADMIN)) {
	    if ((new_serial.close_delay != info->close_delay) ||
		((new_serial.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK) !=
		 (info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK)))
		    return -EPERM;
	    info->flags = ((info->flags & ~ASYNC_USR_MASK) |
			   (new_serial.flags & ASYNC_USR_MASK));
	    goto check_and_exit;
    }


    /*
     * OK, past this point, all the error checking has been done.
     * At this point, we start making changes.....
     */

    info->flags = ((info->flags & ~ASYNC_FLAGS) |
		    (new_serial.flags & ASYNC_FLAGS));
    info->close_delay = new_serial.close_delay;


check_and_exit:
    if (info->flags & ASYNC_INITIALIZED){
	config_setup(info);
	return 0;
    }else{
        return startup(info);
    }
} /* set_serial_info */

static int
cy_tiocmget(struct tty_struct *tty, struct file *file)
{
  struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
  int channel;
  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
  unsigned long flags;
  unsigned char status;
  unsigned int result;

    channel = info->line;

    local_irq_save(flags);
        base_addr[CyCAR] = (u_char)channel;
        status = base_addr[CyMSVR1] | base_addr[CyMSVR2];
    local_irq_restore(flags);

    return    ((status  & CyRTS) ? TIOCM_RTS : 0)
            | ((status  & CyDTR) ? TIOCM_DTR : 0)
            | ((status  & CyDCD) ? TIOCM_CAR : 0)
            | ((status  & CyDSR) ? TIOCM_DSR : 0)
            | ((status  & CyCTS) ? TIOCM_CTS : 0);
} /* cy_tiocmget */

static int
cy_tiocmset(struct tty_struct *tty, struct file *file,
	    unsigned int set, unsigned int clear)
{
  struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
  int channel;
  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
  unsigned long flags;
  unsigned int arg;
	  
    channel = info->line;

	if (set & TIOCM_RTS){
	    local_irq_save(flags);
		base_addr[CyCAR] = (u_char)channel;
		base_addr[CyMSVR1] = CyRTS;
	    local_irq_restore(flags);
	}
	if (set & TIOCM_DTR){
	    local_irq_save(flags);
	    base_addr[CyCAR] = (u_char)channel;
/* CP('S');CP('2'); */
	    base_addr[CyMSVR2] = CyDTR;
#ifdef SERIAL_DEBUG_DTR
            printk("cyc: %d: raising DTR\n", __LINE__);
            printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
#endif
	    local_irq_restore(flags);
	}

	if (clear & TIOCM_RTS){
	    local_irq_save(flags);
		base_addr[CyCAR] = (u_char)channel;
		base_addr[CyMSVR1] = 0;
	    local_irq_restore(flags);
	}
	if (clear & TIOCM_DTR){
	    local_irq_save(flags);
	    base_addr[CyCAR] = (u_char)channel;
/* CP('C');CP('2'); */
	    base_addr[CyMSVR2] = 0;
#ifdef SERIAL_DEBUG_DTR
            printk("cyc: %d: dropping DTR\n", __LINE__);
            printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
#endif
	    local_irq_restore(flags);
	}

    return 0;
} /* set_modem_info */

static void
send_break( struct cyclades_port * info, int duration)
{ /* Let the transmit ISR take care of this (since it
     requires stuffing characters into the output stream).
   */
    info->x_break = duration;
    if (!info->xmit_cnt ) {
	start_xmit(info);
    }
} /* send_break */

static int
get_mon_info(struct cyclades_port * info, struct cyclades_monitor * mon)
{

   if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor)))
	   return -EFAULT;
   info->mon.int_count  = 0;
   info->mon.char_count = 0;
   info->mon.char_max   = 0;
   info->mon.char_last  = 0;
   return 0;
}

static int
set_threshold(struct cyclades_port * info, unsigned long *arg)
{
   volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
   unsigned long value;
   int channel;
   
   if (get_user(value, arg))
	   return -EFAULT;

   channel = info->line;
   info->cor4 &= ~CyREC_FIFO;
   info->cor4 |= value & CyREC_FIFO;
   base_addr[CyCOR4] = info->cor4;
   return 0;
}

static int
get_threshold(struct cyclades_port * info, unsigned long *value)
{
   volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
   int channel;
   unsigned long tmp;
   
   channel = info->line;

   tmp = base_addr[CyCOR4] & CyREC_FIFO;
   return put_user(tmp,value);
}

static int
set_default_threshold(struct cyclades_port * info, unsigned long *arg)
{
   unsigned long value;

   if (get_user(value, arg))
	return -EFAULT;

   info->default_threshold = value & 0x0f;
   return 0;
}

static int
get_default_threshold(struct cyclades_port * info, unsigned long *value)
{
   return put_user(info->default_threshold,value);
}

static int
set_timeout(struct cyclades_port * info, unsigned long *arg)
{
   volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
   int channel;
   unsigned long value;

   if (get_user(value, arg))
	   return -EFAULT;
   
   channel = info->line;

   base_addr[CyRTPRL] = value & 0xff;
   base_addr[CyRTPRH] = (value >> 8) & 0xff;
   return 0;
}

static int
get_timeout(struct cyclades_port * info, unsigned long *value)
{
   volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
   int channel;
   unsigned long tmp;
   
   channel = info->line;

   tmp = base_addr[CyRTPRL];
   return put_user(tmp,value);
}

static int
set_default_timeout(struct cyclades_port * info, unsigned long value)
{
   info->default_timeout = value & 0xff;
   return 0;
}

static int
get_default_timeout(struct cyclades_port * info, unsigned long *value)
{
   return put_user(info->default_timeout,value);
}

static int
cy_ioctl(struct tty_struct *tty, struct file * file,
            unsigned int cmd, unsigned long arg)
{
  unsigned long val;
  struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
  int ret_val = 0;

#ifdef SERIAL_DEBUG_OTHER
    printk("cy_ioctl %s, cmd = %x arg = %lx\n", tty->name, cmd, arg); /* */
#endif

    switch (cmd) {
        case CYGETMON:
            ret_val = get_mon_info(info, (struct cyclades_monitor *)arg);
	    break;
        case CYGETTHRESH:
	    ret_val = get_threshold(info, (unsigned long *)arg);
 	    break;
        case CYSETTHRESH:
            ret_val = set_threshold(info, (unsigned long *)arg);
	    break;
        case CYGETDEFTHRESH:
	    ret_val = get_default_threshold(info, (unsigned long *)arg);
 	    break;
        case CYSETDEFTHRESH:
            ret_val = set_default_threshold(info, (unsigned long *)arg);
	    break;
        case CYGETTIMEOUT:
	    ret_val = get_timeout(info, (unsigned long *)arg);
 	    break;
        case CYSETTIMEOUT:
            ret_val = set_timeout(info, (unsigned long *)arg);
	    break;
        case CYGETDEFTIMEOUT:
	    ret_val = get_default_timeout(info, (unsigned long *)arg);
 	    break;
        case CYSETDEFTIMEOUT:
            ret_val = set_default_timeout(info, (unsigned long)arg);
	    break;
        case TCSBRK:    /* SVID version: non-zero arg --> no break */
	    ret_val = tty_check_change(tty);
	    if (ret_val)
		    break;
            tty_wait_until_sent(tty,0);
            if (!arg)
                send_break(info, HZ/4); /* 1/4 second */
            break;
        case TCSBRKP:   /* support for POSIX tcsendbreak() */
	    ret_val = tty_check_change(tty);
	    if (ret_val)
		break;
            tty_wait_until_sent(tty,0);
            send_break(info, arg ? arg*(HZ/10) : HZ/4);
            break;

/* The following commands are incompletely implemented!!! */
        case TIOCGSOFTCAR:
            ret_val = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long *) arg);
            break;
        case TIOCSSOFTCAR:
            ret_val = get_user(val, (unsigned long *) arg);
	    if (ret_val)
		    break;
            tty->termios->c_cflag =
                    ((tty->termios->c_cflag & ~CLOCAL) | (val ? CLOCAL : 0));
            break;
        case TIOCGSERIAL:
            ret_val = get_serial_info(info, (struct serial_struct *) arg);
            break;
        case TIOCSSERIAL:
            ret_val = set_serial_info(info,
                                   (struct serial_struct *) arg);
            break;
        default:
	    ret_val = -ENOIOCTLCMD;
    }

#ifdef SERIAL_DEBUG_OTHER
    printk("cy_ioctl done\n");
#endif

    return ret_val;
} /* cy_ioctl */




static void
cy_set_termios(struct tty_struct *tty, struct termios * old_termios)
{
  struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;

#ifdef SERIAL_DEBUG_OTHER
    printk("cy_set_termios %s\n", tty->name);
#endif

    if (tty->termios->c_cflag == old_termios->c_cflag)
        return;
    config_setup(info);

    if ((old_termios->c_cflag & CRTSCTS) &&
        !(tty->termios->c_cflag & CRTSCTS)) {
            tty->stopped = 0;
            cy_start(tty);
    }
#ifdef tytso_patch_94Nov25_1726
    if (!(old_termios->c_cflag & CLOCAL) &&
        (tty->termios->c_cflag & CLOCAL))
            wake_up_interruptible(&info->open_wait);
#endif

    return;
} /* cy_set_termios */


static void
cy_close(struct tty_struct * tty, struct file * filp)
{
  struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;

/* CP('C'); */
#ifdef SERIAL_DEBUG_OTHER
    printk("cy_close %s\n", tty->name);
#endif

    if (!info
    || serial_paranoia_check(info, tty->name, "cy_close")){
        return;
    }
#ifdef SERIAL_DEBUG_OPEN
    printk("cy_close %s, count = %d\n", tty->name, info->count);
#endif

    if ((tty->count == 1) && (info->count != 1)) {
	/*
	 * Uh, oh.  tty->count is 1, which means that the tty
	 * structure will be freed.  Info->count should always
	 * be one in these conditions.  If it's greater than
	 * one, we've got real problems, since it means the
	 * serial port won't be shutdown.
	 */
	printk("cy_close: bad serial port count; tty->count is 1, "
	   "info->count is %d\n", info->count);
	info->count = 1;
    }
#ifdef SERIAL_DEBUG_COUNT
    printk("cyc: %d: decrementing count to %d\n", __LINE__, info->count - 1);
#endif
    if (--info->count < 0) {
	printk("cy_close: bad serial port count for ttys%d: %d\n",
	       info->line, info->count);
#ifdef SERIAL_DEBUG_COUNT
    printk("cyc: %d: setting count to 0\n", __LINE__);
#endif
	info->count = 0;
    }
    if (info->count)
	return;
    info->flags |= ASYNC_CLOSING;
    if (info->flags & ASYNC_INITIALIZED)
	tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */
    shutdown(info);
    if (tty->driver->flush_buffer)
	tty->driver->flush_buffer(tty);
    tty_ldisc_flush(tty);
    info->event = 0;
    info->tty = 0;
    if (info->blocked_open) {
	if (info->close_delay) {
	    msleep_interruptible(jiffies_to_msecs(info->close_delay));
	}
	wake_up_interruptible(&info->open_wait);
    }
    info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
    wake_up_interruptible(&info->close_wait);

#ifdef SERIAL_DEBUG_OTHER
    printk("cy_close done\n");
#endif

    return;
} /* cy_close */

/*
 * cy_hangup() --- called by tty_hangup() when a hangup is signaled.
 */
void
cy_hangup(struct tty_struct *tty)
{
  struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
	
#ifdef SERIAL_DEBUG_OTHER
    printk("cy_hangup %s\n", tty->name); /* */
#endif

    if (serial_paranoia_check(info, tty->name, "cy_hangup"))
	return;
    
    shutdown(info);
#if 0
    info->event = 0;
    info->count = 0;
#ifdef SERIAL_DEBUG_COUNT
    printk("cyc: %d: setting count to 0\n", __LINE__);
#endif
    info->tty = 0;
#endif
    info->flags &= ~ASYNC_NORMAL_ACTIVE;
    wake_up_interruptible(&info->open_wait);
} /* cy_hangup */



/*
 * ------------------------------------------------------------
 * cy_open() and friends
 * ------------------------------------------------------------
 */

static int
block_til_ready(struct tty_struct *tty, struct file * filp,
                           struct cyclades_port *info)
{
  DECLARE_WAITQUEUE(wait, current);
  unsigned long flags;
  int channel;
  int retval;
  volatile u_char *base_addr = (u_char *)BASE_ADDR;

    /*
     * If the device is in the middle of being closed, then block
     * until it's done, and then try again.
     */
    if (info->flags & ASYNC_CLOSING) {
	interruptible_sleep_on(&info->close_wait);
	if (info->flags & ASYNC_HUP_NOTIFY){
	    return -EAGAIN;
	}else{
	    return -ERESTARTSYS;
	}
    }

    /*
     * If non-blocking mode is set, then make the check up front
     * and then exit.
     */
    if (filp->f_flags & O_NONBLOCK) {
	info->flags |= ASYNC_NORMAL_ACTIVE;
	return 0;
    }

    /*
     * Block waiting for the carrier detect and the line to become
     * free (i.e., not in use by the callout).  While we are in
     * this loop, info->count is dropped by one, so that
     * cy_close() knows when to free things.  We restore it upon
     * exit, either normal or abnormal.
     */
    retval = 0;
    add_wait_queue(&info->open_wait, &wait);
#ifdef SERIAL_DEBUG_OPEN
    printk("block_til_ready before block: %s, count = %d\n",
	   tty->name, info->count);/**/
#endif
    info->count--;
#ifdef SERIAL_DEBUG_COUNT
    printk("cyc: %d: decrementing count to %d\n", __LINE__, info->count);
#endif
    info->blocked_open++;

    channel = info->line;

    while (1) {
	local_irq_save(flags);
	base_addr[CyCAR] = (u_char)channel;
	base_addr[CyMSVR1] = CyRTS;
/* CP('S');CP('4'); */
	base_addr[CyMSVR2] = CyDTR;
#ifdef SERIAL_DEBUG_DTR
	printk("cyc: %d: raising DTR\n", __LINE__);
	printk("     status: 0x%x, 0x%x\n", base_addr[CyMSVR1], base_addr[CyMSVR2]);
#endif
	local_irq_restore(flags);
	set_current_state(TASK_INTERRUPTIBLE);
	if (tty_hung_up_p(filp)
	|| !(info->flags & ASYNC_INITIALIZED) ){
	    if (info->flags & ASYNC_HUP_NOTIFY) {
		retval = -EAGAIN;
	    }else{
		retval = -ERESTARTSYS;
	    }
	    break;
	}
	local_irq_save(flags);
	    base_addr[CyCAR] = (u_char)channel;
/* CP('L');CP1(1 && C_CLOCAL(tty)); CP1(1 && (base_addr[CyMSVR1] & CyDCD) ); */
	    if (!(info->flags & ASYNC_CLOSING)
	    && (C_CLOCAL(tty)
	        || (base_addr[CyMSVR1] & CyDCD))) {
		    local_irq_restore(flags);
		    break;
	    }
	local_irq_restore(flags);
	if (signal_pending(current)) {
	    retval = -ERESTARTSYS;
	    break;
	}
#ifdef SERIAL_DEBUG_OPEN
	printk("block_til_ready blocking: %s, count = %d\n",
	       tty->name, info->count);/**/
#endif
	schedule();
    }
    current->state = TASK_RUNNING;
    remove_wait_queue(&info->open_wait, &wait);
    if (!tty_hung_up_p(filp)){
	info->count++;
#ifdef SERIAL_DEBUG_COUNT
    printk("cyc: %d: incrementing count to %d\n", __LINE__, info->count);
#endif
    }
    info->blocked_open--;
#ifdef SERIAL_DEBUG_OPEN
    printk("block_til_ready after blocking: %s, count = %d\n",
	   tty->name, info->count);/**/
#endif
    if (retval)
	    return retval;
    info->flags |= ASYNC_NORMAL_ACTIVE;
    return 0;
} /* block_til_ready */

/*
 * This routine is called whenever a serial port is opened.  It
 * performs the serial-specific initialization for the tty structure.
 */
int
cy_open(struct tty_struct *tty, struct file * filp)
{
  struct cyclades_port  *info;
  int retval, line;

/* CP('O'); */
    line = tty->index;
    if ((line < 0) || (NR_PORTS <= line)){
        return -ENODEV;
    }
    info = &cy_port[line];
    if (info->line < 0){
        return -ENODEV;
    }
#ifdef SERIAL_DEBUG_OTHER
    printk("cy_open %s\n", tty->name); /* */
#endif
    if (serial_paranoia_check(info, tty->name, "cy_open")){
        return -ENODEV;
    }
#ifdef SERIAL_DEBUG_OPEN
    printk("cy_open %s, count = %d\n", tty->name, info->count);/**/
#endif
    info->count++;
#ifdef SERIAL_DEBUG_COUNT
    printk("cyc: %d: incrementing count to %d\n", __LINE__, info->count);
#endif
    tty->driver_data = info;
    info->tty = tty;

    /*
     * Start up serial port
     */
    retval = startup(info);
    if (retval){
	return retval;
    }

    retval = block_til_ready(tty, filp, info);
    if (retval) {
#ifdef SERIAL_DEBUG_OPEN
	printk("cy_open returning after block_til_ready with %d\n",
	       retval);
#endif
	return retval;
    }

#ifdef SERIAL_DEBUG_OPEN
    printk("cy_open done\n");/**/
#endif
    return 0;
} /* cy_open */



/*
 * ---------------------------------------------------------------------
 * serial167_init() and friends
 *
 * serial167_init() is called at boot-time to initialize the serial driver.
 * ---------------------------------------------------------------------
 */

/*
 * This routine prints out the appropriate serial driver version
 * number, and identifies which options were configured into this
 * driver.
 */
static void
show_version(void)
{
    printk("MVME166/167 cd2401 driver\n");
} /* show_version */

/* initialize chips on card -- return number of valid
   chips (which is number of ports/4) */

/*
 * This initialises the hardware to a reasonable state.  It should
 * probe the chip first so as to copy 166-Bug setup as a default for
 * port 0.  It initialises CMR to CyASYNC; that is never done again, so
 * as to limit the number of CyINIT_CHAN commands in normal running.
 *
 * ... I wonder what I should do if this fails ...
 */

void
mvme167_serial_console_setup(int cflag)
{
	volatile unsigned char* base_addr = (u_char *)BASE_ADDR;
	int ch;
	u_char spd;
	u_char rcor, rbpr, badspeed = 0;
	unsigned long flags;

	local_irq_save(flags);

	/*
	 * First probe channel zero of the chip, to see what speed has
	 * been selected.
	 */

	base_addr[CyCAR] = 0;

	rcor = base_addr[CyRCOR] << 5;
	rbpr = base_addr[CyRBPR];

	for (spd = 0; spd < sizeof(baud_bpr); spd++)
		if (rbpr == baud_bpr[spd] && rcor == baud_co[spd])
			break;
	if (spd >= sizeof(baud_bpr)) {
		spd = 14;	/* 19200 */
		badspeed = 1;	/* Failed to identify speed */
	}
	initial_console_speed = spd;

	/* OK, we have chosen a speed, now reset and reinitialise */

        my_udelay(20000L);	/* Allow time for any active o/p to complete */
        if(base_addr[CyCCR] != 0x00){
            local_irq_restore(flags);
            /* printk(" chip is never idle (CCR != 0)\n"); */
            return;
        }

        base_addr[CyCCR] = CyCHIP_RESET;	/* Reset the chip */
        my_udelay(1000L);

        if(base_addr[CyGFRCR] == 0x00){
            local_irq_restore(flags);
            /* printk(" chip is not responding (GFRCR stayed 0)\n"); */
            return;
        }

	/*
	 * System clock is 20Mhz, divided by 2048, so divide by 10 for a 1.0ms
	 * tick
	 */

	base_addr[CyTPR] = 10;

	base_addr[CyPILR1] = 0x01;    /* Interrupt level for modem change */
	base_addr[CyPILR2] = 0x02;    /* Interrupt level for tx ints */
	base_addr[CyPILR3] = 0x03;    /* Interrupt level for rx ints */

	/*
	 * Attempt to set up all channels to something reasonable, and
	 * bang out a INIT_CHAN command.  We should then be able to limit
	 * the ammount of fiddling we have to do in normal running.
	 */

	for (ch = 3; ch >= 0 ; ch--) {
		base_addr[CyCAR] = (u_char)ch;
		base_addr[CyIER] = 0;
		base_addr[CyCMR] = CyASYNC;
		base_addr[CyLICR] = (u_char)ch << 2;
		base_addr[CyLIVR] = 0x5c;
		base_addr[CyTCOR] = baud_co[spd];
		base_addr[CyTBPR] = baud_bpr[spd];
		base_addr[CyRCOR] = baud_co[spd] >> 5;
		base_addr[CyRBPR] = baud_bpr[spd];
		base_addr[CySCHR1] = 'Q' & 0x1f;
		base_addr[CySCHR2] = 'X' & 0x1f;
		base_addr[CySCRL] = 0;
		base_addr[CySCRH] = 0;
		base_addr[CyCOR1] = Cy_8_BITS | CyPARITY_NONE;
		base_addr[CyCOR2] = 0;
		base_addr[CyCOR3] = Cy_1_STOP;
		base_addr[CyCOR4] = baud_cor4[spd];
		base_addr[CyCOR5] = 0;
		base_addr[CyCOR6] = 0;
		base_addr[CyCOR7] = 0;
		base_addr[CyRTPRL] = 2;
		base_addr[CyRTPRH] = 0;
	        base_addr[CyMSVR1] = 0;
	        base_addr[CyMSVR2] = 0;
		write_cy_cmd(base_addr,CyINIT_CHAN|CyDIS_RCVR|CyDIS_XMTR);
	}

	/*
	 * Now do specials for channel zero....
	 */

        base_addr[CyMSVR1] = CyRTS;
        base_addr[CyMSVR2] = CyDTR;
	base_addr[CyIER] = CyRxData;
	write_cy_cmd(base_addr,CyENB_RCVR|CyENB_XMTR);

	local_irq_restore(flags);

	my_udelay(20000L);	/* Let it all settle down */

        printk("CD2401 initialised,  chip is rev 0x%02x\n", base_addr[CyGFRCR]);
	if (badspeed)
        	printk("  WARNING:  Failed to identify line speed, rcor=%02x,rbpr=%02x\n",
					rcor >> 5, rbpr);
} /* serial_console_init */

static const struct tty_operations cy_ops = {
	.open = cy_open,
	.close = cy_close,
	.write = cy_write,
	.put_char = cy_put_char,
	.flush_chars = cy_flush_chars,
	.write_room = cy_write_room,
	.chars_in_buffer = cy_chars_in_buffer,
	.flush_buffer = cy_flush_buffer,
	.ioctl = cy_ioctl,
	.throttle = cy_throttle,
	.unthrottle = cy_unthrottle,
	.set_termios = cy_set_termios,
	.stop = cy_stop,
	.start = cy_start,
	.hangup = cy_hangup,
	.tiocmget = cy_tiocmget,
	.tiocmset = cy_tiocmset,
};
/* The serial driver boot-time initialization code!
    Hardware I/O ports are mapped to character special devices on a
    first found, first allocated manner.  That is, this code searches
    for Cyclom cards in the system.  As each is found, it is probed
    to discover how many chips (and thus how many ports) are present.
    These ports are mapped to the tty ports 64 and upward in monotonic
    fashion.  If an 8-port card is replaced with a 16-port card, the
    port mapping on a following card will shift.

    This approach is different from what is used in the other serial
    device driver because the Cyclom is more properly a multiplexer,
    not just an aggregation of serial ports on one card.

    If there are more cards with more ports than have been statically
    allocated above, a warning is printed and the extra ports are ignored.
 */
static int __init
serial167_init(void)
{
  struct cyclades_port *info;
  int ret = 0;
  int good_ports = 0;
  int port_num = 0;
  int index;
  int DefSpeed;
#ifdef notyet
  struct sigaction sa;
#endif

    if (!(mvme16x_config &MVME16x_CONFIG_GOT_CD2401))
	return 0;

    cy_serial_driver = alloc_tty_driver(NR_PORTS);
    if (!cy_serial_driver)
	return -ENOMEM;

#if 0
scrn[1] = '\0';
#endif

    show_version();

    /* Has "console=0,9600n8" been used in bootinfo to change speed? */
    if (serial_console_cflag)
	DefSpeed = serial_console_cflag & 0017;
    else {
	DefSpeed = initial_console_speed;
	serial_console_info = &cy_port[0];
	serial_console_cflag = DefSpeed | CS8;
#if 0
	serial_console = 64; /*callout_driver.minor_start*/
#endif
    }

    /* Initialize the tty_driver structure */
    
    cy_serial_driver->owner = THIS_MODULE;
    cy_serial_driver->name = "ttyS";
    cy_serial_driver->major = TTY_MAJOR;
    cy_serial_driver->minor_start = 64;
    cy_serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
    cy_serial_driver->subtype = SERIAL_TYPE_NORMAL;
    cy_serial_driver->init_termios = tty_std_termios;
    cy_serial_driver->init_termios.c_cflag =
	    B9600 | CS8 | CREAD | HUPCL | CLOCAL;
    cy_serial_driver->flags = TTY_DRIVER_REAL_RAW;
    tty_set_operations(cy_serial_driver, &cy_ops);

    ret = tty_register_driver(cy_serial_driver);
    if (ret) {
	    printk(KERN_ERR "Couldn't register MVME166/7 serial driver\n");
	    put_tty_driver(cy_serial_driver);
	    return ret;
    }

    port_num = 0;
    info = cy_port;
    for (index = 0; index < 1; index++) {

	good_ports = 4;

	if(port_num < NR_PORTS){
	    while( good_ports-- && port_num < NR_PORTS){
		/*** initialize port ***/
		info->magic = CYCLADES_MAGIC;
		info->type = PORT_CIRRUS;
		info->card = index;
		info->line = port_num;
		info->flags = STD_COM_FLAGS;
		info->tty = 0;
		info->xmit_fifo_size = 12;
		info->cor1 = CyPARITY_NONE|Cy_8_BITS;
		info->cor2 = CyETC;
		info->cor3 = Cy_1_STOP;
		info->cor4 = 0x08; /* _very_ small receive threshold */
		info->cor5 = 0;
		info->cor6 = 0;
		info->cor7 = 0;
		info->tbpr = baud_bpr[DefSpeed]; /* Tx BPR */
		info->tco = baud_co[DefSpeed]; /* Tx CO */
		info->rbpr = baud_bpr[DefSpeed]; /* Rx BPR */
		info->rco = baud_co[DefSpeed] >> 5; /* Rx CO */
		info->close_delay = 0;
		info->x_char = 0;
		info->event = 0;
		info->count = 0;
#ifdef SERIAL_DEBUG_COUNT
    printk("cyc: %d: setting count to 0\n", __LINE__);
#endif
		info->blocked_open = 0;
		info->default_threshold = 0;
		info->default_timeout = 0;
		INIT_WORK(&info->tqueue, do_softint, info);
		init_waitqueue_head(&info->open_wait);
		init_waitqueue_head(&info->close_wait);
		/* info->session */
		/* info->pgrp */
/*** !!!!!!!! this may expose new bugs !!!!!!!!! *********/
		info->read_status_mask = CyTIMEOUT| CySPECHAR| CyBREAK
                                       | CyPARITY| CyFRAME| CyOVERRUN;
		/* info->timeout */

		printk("ttyS%d ", info->line);
		port_num++;info++;
		if(!(port_num & 7)){
		    printk("\n               ");
		}
	    }
	}
	printk("\n");
    }
    while( port_num < NR_PORTS){
	info->line = -1;
	port_num++;info++;
    }
#ifdef CONFIG_REMOTE_DEBUG
    debug_setup();
#endif
    ret = request_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt, 0,
				"cd2401_errors", cd2401_rxerr_interrupt);
    if (ret) {
	    printk(KERN_ERR "Could't get cd2401_errors IRQ");
	    goto cleanup_serial_driver;
    }

    ret = request_irq(MVME167_IRQ_SER_MODEM, cd2401_modem_interrupt, 0,
				"cd2401_modem", cd2401_modem_interrupt);
    if (ret) {
	    printk(KERN_ERR "Could't get cd2401_modem IRQ");
	    goto cleanup_irq_cd2401_errors;
    }

    ret = request_irq(MVME167_IRQ_SER_TX, cd2401_tx_interrupt, 0,
				"cd2401_txints", cd2401_tx_interrupt);
    if (ret) {
	    printk(KERN_ERR "Could't get cd2401_txints IRQ");
	    goto cleanup_irq_cd2401_modem;
    }

    ret = request_irq(MVME167_IRQ_SER_RX, cd2401_rx_interrupt, 0,
				"cd2401_rxints", cd2401_rx_interrupt);
    if (ret) {
	    printk(KERN_ERR "Could't get cd2401_rxints IRQ");
	    goto cleanup_irq_cd2401_txints;
    }

    /* Now we have registered the interrupt handlers, allow the interrupts */

    pcc2chip[PccSCCMICR] = 0x15;		/* Serial ints are level 5 */
    pcc2chip[PccSCCTICR] = 0x15;
    pcc2chip[PccSCCRICR] = 0x15;

    pcc2chip[PccIMLR] = 3;			/* Allow PCC2 ints above 3!? */

    return 0;
cleanup_irq_cd2401_txints:
    free_irq(MVME167_IRQ_SER_TX, cd2401_tx_interrupt);
cleanup_irq_cd2401_modem:
    free_irq(MVME167_IRQ_SER_MODEM, cd2401_modem_interrupt);
cleanup_irq_cd2401_errors:
    free_irq(MVME167_IRQ_SER_ERR, cd2401_rxerr_interrupt);
cleanup_serial_driver:
    if (tty_unregister_driver(cy_serial_driver))
	    printk(KERN_ERR "Couldn't unregister MVME166/7 serial driver\n");
    put_tty_driver(cy_serial_driver);
    return ret;
} /* serial167_init */

module_init(serial167_init);


#ifdef CYCLOM_SHOW_STATUS
static void
show_status(int line_num)
{
  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
  int channel;
  struct cyclades_port * info;
  unsigned long flags;

    info = &cy_port[line_num];
    channel = info->line;
    printk("  channel %d\n", channel);/**/

    printk(" cy_port\n");
    printk("  card line flags = %d %d %x\n",
                 info->card, info->line, info->flags);
    printk("  *tty read_status_mask timeout xmit_fifo_size = %lx %x %x %x\n",
                 (long)info->tty, info->read_status_mask,
                 info->timeout, info->xmit_fifo_size);
    printk("  cor1,cor2,cor3,cor4,cor5,cor6,cor7 = %x %x %x %x %x %x %x\n",
             info->cor1, info->cor2, info->cor3, info->cor4, info->cor5,
			info->cor6, info->cor7);
    printk("  tbpr,tco,rbpr,rco = %d %d %d %d\n",
             info->tbpr, info->tco, info->rbpr, info->rco);
    printk("  close_delay event count = %d %d %d\n",
             info->close_delay, info->event, info->count);
    printk("  x_char blocked_open = %x %x\n",
             info->x_char, info->blocked_open);
    printk("  open_wait = %lx %lx %lx\n",
             (long)info->open_wait);


    local_irq_save(flags);

/* Global Registers */

	printk(" CyGFRCR %x\n", base_addr[CyGFRCR]);
	printk(" CyCAR %x\n", base_addr[CyCAR]);
	printk(" CyRISR %x\n", base_addr[CyRISR]);
	printk(" CyTISR %x\n", base_addr[CyTISR]);
	printk(" CyMISR %x\n", base_addr[CyMISR]);
	printk(" CyRIR %x\n", base_addr[CyRIR]);
	printk(" CyTIR %x\n", base_addr[CyTIR]);
	printk(" CyMIR %x\n", base_addr[CyMIR]);
	printk(" CyTPR %x\n", base_addr[CyTPR]);

	base_addr[CyCAR] = (u_char)channel;

/* Virtual Registers */

#if 0
	printk(" CyRIVR %x\n", base_addr[CyRIVR]);
	printk(" CyTIVR %x\n", base_addr[CyTIVR]);
	printk(" CyMIVR %x\n", base_addr[CyMIVR]);
	printk(" CyMISR %x\n", base_addr[CyMISR]);
#endif

/* Channel Registers */

	printk(" CyCCR %x\n", base_addr[CyCCR]);
	printk(" CyIER %x\n", base_addr[CyIER]);
	printk(" CyCOR1 %x\n", base_addr[CyCOR1]);
	printk(" CyCOR2 %x\n", base_addr[CyCOR2]);
	printk(" CyCOR3 %x\n", base_addr[CyCOR3]);
	printk(" CyCOR4 %x\n", base_addr[CyCOR4]);
	printk(" CyCOR5 %x\n", base_addr[CyCOR5]);
#if 0
	printk(" CyCCSR %x\n", base_addr[CyCCSR]);
	printk(" CyRDCR %x\n", base_addr[CyRDCR]);
#endif
	printk(" CySCHR1 %x\n", base_addr[CySCHR1]);
	printk(" CySCHR2 %x\n", base_addr[CySCHR2]);
#if 0
	printk(" CySCHR3 %x\n", base_addr[CySCHR3]);
	printk(" CySCHR4 %x\n", base_addr[CySCHR4]);
	printk(" CySCRL %x\n", base_addr[CySCRL]);
	printk(" CySCRH %x\n", base_addr[CySCRH]);
	printk(" CyLNC %x\n", base_addr[CyLNC]);
	printk(" CyMCOR1 %x\n", base_addr[CyMCOR1]);
	printk(" CyMCOR2 %x\n", base_addr[CyMCOR2]);
#endif
	printk(" CyRTPRL %x\n", base_addr[CyRTPRL]);
	printk(" CyRTPRH %x\n", base_addr[CyRTPRH]);
	printk(" CyMSVR1 %x\n", base_addr[CyMSVR1]);
	printk(" CyMSVR2 %x\n", base_addr[CyMSVR2]);
	printk(" CyRBPR %x\n", base_addr[CyRBPR]);
	printk(" CyRCOR %x\n", base_addr[CyRCOR]);
	printk(" CyTBPR %x\n", base_addr[CyTBPR]);
	printk(" CyTCOR %x\n", base_addr[CyTCOR]);

    local_irq_restore(flags);
} /* show_status */
#endif


#if 0
/* Dummy routine in mvme16x/config.c for now */

/* Serial console setup. Called from linux/init/main.c */

void console_setup(char *str, int *ints)
{
	char *s;
	int baud, bits, parity;
	int cflag = 0;

	/* Sanity check. */
	if (ints[0] > 3 || ints[1] > 3) return;

	/* Get baud, bits and parity */
	baud = 2400;
	bits = 8;
	parity = 'n';
	if (ints[2]) baud = ints[2];
	if ((s = strchr(str, ','))) {
		do {
			s++;
		} while(*s >= '0' && *s <= '9');
		if (*s) parity = *s++;
		if (*s) bits   = *s - '0';
	}

	/* Now construct a cflag setting. */
	switch(baud) {
		case 1200:
			cflag |= B1200;
			break;
		case 9600:
			cflag |= B9600;
			break;
		case 19200:
			cflag |= B19200;
			break;
		case 38400:
			cflag |= B38400;
			break;
		case 2400:
		default:
			cflag |= B2400;
			break;
	}
	switch(bits) {
		case 7:
			cflag |= CS7;
			break;
		default:
		case 8:
			cflag |= CS8;
			break;
	}
	switch(parity) {
		case 'o': case 'O':
			cflag |= PARODD;
			break;
		case 'e': case 'E':
			cflag |= PARENB;
			break;
	}

	serial_console_info = &cy_port[ints[1]];
	serial_console_cflag = cflag;
	serial_console = ints[1] + 64; /*callout_driver.minor_start*/
}
#endif

/*
 * The following is probably out of date for 2.1.x serial console stuff.
 *
 * The console is registered early on from arch/m68k/kernel/setup.c, and
 * it therefore relies on the chip being setup correctly by 166-Bug.  This
 * seems reasonable, as the serial port has been used to invoke the system
 * boot.  It also means that this function must not rely on any data
 * initialisation performed by serial167_init() etc.
 *
 * Of course, once the console has been registered, we had better ensure
 * that serial167_init() doesn't leave the chip non-functional.
 *
 * The console must be locked when we get here.
 */

void serial167_console_write(struct console *co, const char *str, unsigned count)
{
	volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
	unsigned long flags;
	volatile u_char sink;
	u_char ier;
	int port;
	u_char do_lf = 0;
	int i = 0;

	local_irq_save(flags);

	/* Ensure transmitter is enabled! */

	port = 0;
	base_addr[CyCAR] = (u_char)port;
	while (base_addr[CyCCR])
		;
	base_addr[CyCCR] = CyENB_XMTR;

	ier = base_addr[CyIER];
	base_addr[CyIER] = CyTxMpty;

	while (1) {
		if (pcc2chip[PccSCCTICR] & 0x20)
		{
			/* We have a Tx int. Acknowledge it */
			sink = pcc2chip[PccTPIACKR];
			if ((base_addr[CyLICR] >> 2) == port) {
				if (i == count) {
					/* Last char of string is now output */
					base_addr[CyTEOIR] = CyNOTRANS;
					break;
				}
				if (do_lf) {
					base_addr[CyTDR] = '\n';
					str++;
					i++;
					do_lf = 0;
				}
				else if (*str == '\n') {
					base_addr[CyTDR] = '\r';
					do_lf = 1;
				}
				else {
					base_addr[CyTDR] = *str++;
					i++;
				}
				base_addr[CyTEOIR] = 0;
			}
			else
				base_addr[CyTEOIR] = CyNOTRANS;
		}
	}

	base_addr[CyIER] = ier;

	local_irq_restore(flags);
}

static struct tty_driver *serial167_console_device(struct console *c, int *index)
{
	*index = c->index;
	return cy_serial_driver;
}


static int __init serial167_console_setup(struct console *co, char *options)
{
	return 0;
}


static struct console sercons = {
	.name		= "ttyS",
	.write		= serial167_console_write,
	.device		= serial167_console_device,
	.setup		= serial167_console_setup,
	.flags		= CON_PRINTBUFFER,
	.index		= -1,
};


static int __init serial167_console_init(void)
{
	if (vme_brdtype == VME_TYPE_MVME166 ||
			vme_brdtype == VME_TYPE_MVME167 ||
			vme_brdtype == VME_TYPE_MVME177) {
		mvme167_serial_console_setup(0);
		register_console(&sercons);
	}
	return 0;
}
console_initcall(serial167_console_init);

#ifdef CONFIG_REMOTE_DEBUG
void putDebugChar (int c)
{
	volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
	unsigned long flags;
	volatile u_char sink;
	u_char ier;
	int port;

	local_irq_save(flags);

	/* Ensure transmitter is enabled! */

	port = DEBUG_PORT;
	base_addr[CyCAR] = (u_char)port;
	while (base_addr[CyCCR])
		;
	base_addr[CyCCR] = CyENB_XMTR;

	ier = base_addr[CyIER];
	base_addr[CyIER] = CyTxMpty;

	while (1) {
		if (pcc2chip[PccSCCTICR] & 0x20)
		{
			/* We have a Tx int. Acknowledge it */
			sink = pcc2chip[PccTPIACKR];
			if ((base_addr[CyLICR] >> 2) == port) {
				base_addr[CyTDR] = c;
				base_addr[CyTEOIR] = 0;
				break;
			}
			else
				base_addr[CyTEOIR] = CyNOTRANS;
		}
	}

	base_addr[CyIER] = ier;

	local_irq_restore(flags);
}

int getDebugChar()
{
	volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
	unsigned long flags;
	volatile u_char sink;
	u_char ier;
	int port;
	int i, c;

	i = debugiq.out;
	if (i != debugiq.in) {
		c = debugiq.buf[i];
		if (++i == DEBUG_LEN)
			i = 0;
		debugiq.out = i;
		return c;
	}
	/* OK, nothing in queue, wait in poll loop */

	local_irq_save(flags);

	/* Ensure receiver is enabled! */

	port = DEBUG_PORT;
	base_addr[CyCAR] = (u_char)port;
#if 0
	while (base_addr[CyCCR])
		;
	base_addr[CyCCR] = CyENB_RCVR;
#endif
	ier = base_addr[CyIER];
	base_addr[CyIER] = CyRxData;

	while (1) {
		if (pcc2chip[PccSCCRICR] & 0x20)
		{
			/* We have a Rx int. Acknowledge it */
			sink = pcc2chip[PccRPIACKR];
			if ((base_addr[CyLICR] >> 2) == port) {
				int cnt = base_addr[CyRFOC];
				while (cnt-- > 0)
				{
					c = base_addr[CyRDR];
					if (c == 0)
						printk ("!! debug char is null (cnt=%d) !!", cnt);
					else
						queueDebugChar (c);
				}
				base_addr[CyREOIR] = 0;
				i = debugiq.out;
				if (i == debugiq.in)
					panic ("Debug input queue empty!");
				c = debugiq.buf[i];
				if (++i == DEBUG_LEN)
					i = 0;
				debugiq.out = i;
				break;
			}
			else
				base_addr[CyREOIR] = CyNOTRANS;
		}
	}

	base_addr[CyIER] = ier;

	local_irq_restore(flags);

	return (c);
}

void queueDebugChar (int c)
{
	int i;

	i = debugiq.in;
	debugiq.buf[i] = c;
	if (++i == DEBUG_LEN)
		i = 0;
	if (i != debugiq.out)
		debugiq.in = i;
}

static void
debug_setup()
{
  unsigned long flags;
  volatile unsigned char *base_addr = (u_char *)BASE_ADDR;
  int   i, cflag;

    cflag = B19200;

    local_irq_save(flags);

    for (i = 0; i < 4; i++)
    {
	base_addr[CyCAR] = i;
	base_addr[CyLICR] = i << 2;
    }

    debugiq.in = debugiq.out = 0;

    base_addr[CyCAR] = DEBUG_PORT;

    /* baud rate */
    i = cflag & CBAUD;

    base_addr[CyIER] = 0;

    base_addr[CyCMR] = CyASYNC;
    base_addr[CyLICR] = DEBUG_PORT << 2;
    base_addr[CyLIVR] = 0x5c;

    /* tx and rx baud rate */

    base_addr[CyTCOR] = baud_co[i];
    base_addr[CyTBPR] = baud_bpr[i];
    base_addr[CyRCOR] = baud_co[i] >> 5;
    base_addr[CyRBPR] = baud_bpr[i];

    /* set line characteristics  according configuration */

    base_addr[CySCHR1] = 0;
    base_addr[CySCHR2] = 0;
    base_addr[CySCRL] = 0;
    base_addr[CySCRH] = 0;
    base_addr[CyCOR1] = Cy_8_BITS | CyPARITY_NONE;
    base_addr[CyCOR2] = 0;
    base_addr[CyCOR3] = Cy_1_STOP;
    base_addr[CyCOR4] = baud_cor4[i];
    base_addr[CyCOR5] = 0;
    base_addr[CyCOR6] = 0;
    base_addr[CyCOR7] = 0;

    write_cy_cmd(base_addr,CyINIT_CHAN);
    write_cy_cmd(base_addr,CyENB_RCVR);

    base_addr[CyCAR] = DEBUG_PORT; /* !!! Is this needed? */

    base_addr[CyRTPRL] = 2;
    base_addr[CyRTPRH] = 0;

    base_addr[CyMSVR1] = CyRTS;
    base_addr[CyMSVR2] = CyDTR;

    base_addr[CyIER] = CyRxData;

    local_irq_restore(flags);

} /* debug_setup */

#endif

MODULE_LICENSE("GPL");
