
/* sx.c -- driver for the Specialix SX series cards. 
 *
 *  This driver will also support the older SI, and XIO cards.
 *
 *
 *   (C) 1998 - 2004  R.E.Wolff@BitWizard.nl
 *
 *  Simon Allen (simonallen@cix.compulink.co.uk) wrote a previous
 *  version of this driver. Some fragments may have been copied. (none
 *  yet :-)
 *
 * Specialix pays for the development and support of this driver.
 * Please DO contact support@specialix.co.uk if you require
 * support. But please read the documentation (sx.txt) first.
 *
 *
 *
 *      This program is free software; you can redistribute it and/or
 *      modify it under the terms of the GNU General Public License as
 *      published by the Free Software Foundation; either version 2 of
 *      the License, or (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be
 *      useful, but WITHOUT ANY WARRANTY; without even the implied
 *      warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 *      PURPOSE.  See the GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public
 *      License along with this program; if not, write to the Free
 *      Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
 *      USA.
 *
 * Revision history:
 * $Log: sx.c,v $
 * Revision 1.33  2000/03/09 10:00:00  pvdl,wolff
 * - Fixed module and port counting
 * - Fixed signal handling
 * - Fixed an Ooops
 * 
 * Revision 1.32  2000/03/07 09:00:00  wolff,pvdl
 * - Fixed some sx_dprintk typos
 * - added detection for an invalid board/module configuration
 *
 * Revision 1.31  2000/03/06 12:00:00  wolff,pvdl
 * - Added support for EISA
 *
 * Revision 1.30  2000/01/21 17:43:06  wolff
 * - Added support for SX+
 *
 * Revision 1.26  1999/08/05 15:22:14  wolff
 * - Port to 2.3.x
 * - Reformatted to Linus' liking.
 *
 * Revision 1.25  1999/07/30 14:24:08  wolff
 * Had accidentally left "gs_debug" set to "-1" instead of "off" (=0).
 *
 * Revision 1.24  1999/07/28 09:41:52  wolff
 * - I noticed the remark about use-count straying in sx.txt. I checked
 *   sx_open, and found a few places where that could happen. I hope it's
 *   fixed now.
 *
 * Revision 1.23  1999/07/28 08:56:06  wolff
 * - Fixed crash when sx_firmware run twice.
 * - Added sx_slowpoll as a module parameter (I guess nobody really wanted
 *   to change it from the default... )
 * - Fixed a stupid editing problem I introduced in 1.22.
 * - Fixed dropping characters on a termios change.
 *
 * Revision 1.22  1999/07/26 21:01:43  wolff
 * Russell Brown noticed that I had overlooked 4 out of six modem control
 * signals in sx_getsignals. Ooops.
 *
 * Revision 1.21  1999/07/23 09:11:33  wolff
 * I forgot to free dynamically allocated memory when the driver is unloaded.
 *
 * Revision 1.20  1999/07/20 06:25:26  wolff
 * The "closing wait" wasn't honoured. Thanks to James Griffiths for
 * reporting this.
 *
 * Revision 1.19  1999/07/11 08:59:59  wolff
 * Fixed an oops in close, when an open was pending. Changed the memtest
 * a bit. Should also test the board in word-mode, however my card fails the
 * memtest then. I still have to figure out what is wrong...
 *
 * Revision 1.18  1999/06/10 09:38:42  wolff
 * Changed the format of the firmware revision from %04x to %x.%02x .
 *
 * Revision 1.17  1999/06/04 09:44:35  wolff
 * fixed problem: reference to pci stuff when config_pci was off...
 * Thanks to Jorge Novo for noticing this.
 *
 * Revision 1.16  1999/06/02 08:30:15  wolff
 * added/removed the workaround for the DCD bug in the Firmware.
 * A bit more debugging code to locate that...
 *
 * Revision 1.15  1999/06/01 11:35:30  wolff
 * when DCD is left low (floating?), on TA's the firmware first tells us
 * that DCD is high, but after a short while suddenly comes to the
 * conclusion that it is low. All this would be fine, if it weren't that
 * Unix requires us to send a "hangup" signal in that case. This usually
 * all happens BEFORE the program has had a chance to ioctl the device
 * into clocal mode..
 *
 * Revision 1.14  1999/05/25 11:18:59  wolff
 * Added PCI-fix.
 * Added checks for return code of sx_sendcommand.
 * Don't issue "reconfig" if port isn't open yet. (bit us on TA modules...)
 *
 * Revision 1.13  1999/04/29 15:18:01  wolff
 * Fixed an "oops" that showed on SuSE 6.0 systems.
 * Activate DTR again after stty 0.
 *
 * Revision 1.12  1999/04/29 07:49:52  wolff
 * Improved "stty 0" handling a bit. (used to change baud to 9600 assuming
 *     the connection would be dropped anyway. That is not always the case,
 *     and confuses people).
 * Told the card to always monitor the modem signals.
 * Added support for dynamic  gs_debug adjustments.
 * Now tells the rest of the system the number of ports.
 *
 * Revision 1.11  1999/04/24 11:11:30  wolff
 * Fixed two stupid typos in the memory test.
 *
 * Revision 1.10  1999/04/24 10:53:39  wolff
 * Added some of Christian's suggestions.
 * Fixed an HW_COOK_IN bug (ISIG was not in I_OTHER. We used to trust the
 * card to send the signal to the process.....)
 *
 * Revision 1.9  1999/04/23 07:26:38  wolff
 * Included Christian Lademann's 2.0 compile-warning fixes and interrupt
 *    assignment redesign.
 * Cleanup of some other stuff.
 *
 * Revision 1.8  1999/04/16 13:05:30  wolff
 * fixed a DCD change unnoticed bug.
 *
 * Revision 1.7  1999/04/14 22:19:51  wolff
 * Fixed typo that showed up in 2.0.x builds (get_user instead of Get_user!)
 *
 * Revision 1.6  1999/04/13 18:40:20  wolff
 * changed misc-minor to 161, as assigned by HPA.
 *
 * Revision 1.5  1999/04/13 15:12:25  wolff
 * Fixed use-count leak when "hangup" occurred.
 * Added workaround for a stupid-PCIBIOS bug.
 *
 *
 * Revision 1.4  1999/04/01 22:47:40  wolff
 * Fixed < 1M linux-2.0 problem.
 * (vremap isn't compatible with ioremap in that case)
 *
 * Revision 1.3  1999/03/31 13:45:45  wolff
 * Firmware loading is now done through a separate IOCTL.
 *
 * Revision 1.2  1999/03/28 12:22:29  wolff
 * rcs cleanup
 *
 * Revision 1.1  1999/03/28 12:10:34  wolff
 * Readying for release on 2.0.x (sorry David, 1.01 becomes 1.1 for RCS). 
 *
 * Revision 0.12  1999/03/28 09:20:10  wolff
 * Fixed problem in 0.11, continueing cleanup.
 *
 * Revision 0.11  1999/03/28 08:46:44  wolff
 * cleanup. Not good.
 *
 * Revision 0.10  1999/03/28 08:09:43  wolff
 * Fixed loosing characters on close.
 *
 * Revision 0.9  1999/03/21 22:52:01  wolff
 * Ported back to 2.2.... (minor things)
 *
 * Revision 0.8  1999/03/21 22:40:33  wolff
 * Port to 2.0
 *
 * Revision 0.7  1999/03/21 19:06:34  wolff
 * Fixed hangup processing.
 *
 * Revision 0.6  1999/02/05 08:45:14  wolff
 * fixed real_raw problems. Inclusion into kernel imminent.
 *
 * Revision 0.5  1998/12/21 23:51:06  wolff
 * Snatched a nasty bug: sx_transmit_chars was getting re-entered, and it
 * shouldn't have. THATs why I want to have transmit interrupts even when
 * the buffer is empty.
 *
 * Revision 0.4  1998/12/17 09:34:46  wolff
 * PPP works. ioctl works. Basically works!
 *
 * Revision 0.3  1998/12/15 13:05:18  wolff
 * It works! Wow! Gotta start implementing IOCTL and stuff....
 *
 * Revision 0.2  1998/12/01 08:33:53  wolff
 * moved over to 2.1.130
 *
 * Revision 0.1  1998/11/03 21:23:51  wolff
 * Initial revision. Detects SX card.
 *
 * */


#define RCS_ID "$Id: sx.c,v 1.33 2000/03/08 10:01:02 wolff, pvdl Exp $"
#define RCS_REV "$Revision: 1.33 $"


#include <linux/module.h>
#include <linux/config.h> 
#include <linux/kdev_t.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/ioport.h>
#include <linux/interrupt.h>
#include <linux/errno.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/mm.h>
#include <linux/serial.h>
#include <linux/fcntl.h>
#include <linux/major.h>
#include <linux/delay.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/miscdevice.h>
#include <linux/bitops.h>

#include <asm/io.h>
#include <asm/uaccess.h>

/* The 3.0.0 version of sxboards/sxwindow.h  uses BYTE and WORD.... */
#define BYTE u8
#define WORD u16

/* .... but the 3.0.4 version uses _u8 and _u16. */
#define _u8 u8
#define _u16 u16

#include "sxboards.h"
#include "sxwindow.h"

#include <linux/generic_serial.h>
#include "sx.h"


/* I don't think that this driver can handle more than 256 ports on
   one machine. You'll have to increase the number of boards in sx.h
   if you want more than 4 boards.  */

#ifndef PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8
#define PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8 0x2000
#endif

#ifdef CONFIG_PCI
static struct pci_device_id sx_pci_tbl[] = {
	{ PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, PCI_ANY_ID, PCI_ANY_ID },
	{ 0 }
};
MODULE_DEVICE_TABLE(pci, sx_pci_tbl);
#endif /* CONFIG_PCI */

/* Configurable options: 
   (Don't be too sure that it'll work if you toggle them) */

/* Am I paranoid or not ? ;-) */
#undef SX_PARANOIA_CHECK


/* 20 -> 2000 per second. The card should rate-limit interrupts at 100
   Hz, but it is user configurable. I don't recommend going above 1000
   Hz. The interrupt ratelimit might trigger if the interrupt is
   shared with a very active other device. */
#define IRQ_RATE_LIMIT 20

/* Sharing interrupts is possible now. If the other device wants more
   than 2000 interrupts per second, we'd gracefully decline further
   interrupts. That's not what we want. On the other hand, if the
   other device interrupts 2000 times a second, don't use the SX
   interrupt. Use polling. */
#undef IRQ_RATE_LIMIT


#if 0
/* Not implemented */
/* 
 * The following defines are mostly for testing purposes. But if you need
 * some nice reporting in your syslog, you can define them also.
 */
#define SX_REPORT_FIFO
#define SX_REPORT_OVERRUN
#endif 


/* Function prototypes */
static void sx_disable_tx_interrupts (void * ptr); 
static void sx_enable_tx_interrupts (void * ptr); 
static void sx_disable_rx_interrupts (void * ptr); 
static void sx_enable_rx_interrupts (void * ptr); 
static int  sx_get_CD (void * ptr); 
static void sx_shutdown_port (void * ptr);
static int  sx_set_real_termios (void  *ptr);
static void sx_close (void  *ptr);
static int sx_chars_in_buffer (void * ptr);
static int sx_init_board (struct sx_board *board);
static int sx_init_portstructs (int nboards, int nports);
static int sx_fw_ioctl (struct inode *inode, struct file *filp,
                        unsigned int cmd, unsigned long arg);
static int sx_init_drivers(void);


static struct tty_driver *sx_driver;

static struct sx_board boards[SX_NBOARDS];
static struct sx_port *sx_ports;
static int sx_initialized;
static int sx_nports;
static int sx_debug;


/* You can have the driver poll your card. 
    - Set sx_poll to 1 to poll every timer tick (10ms on Intel). 
      This is used when the card cannot use an interrupt for some reason.

    - set sx_slowpoll to 100 to do an extra poll once a second (on Intel). If 
      the driver misses an interrupt (report this if it DOES happen to you!)
      everything will continue to work.... 
 */
static int sx_poll = 1;
static int sx_slowpoll;

/* The card limits the number of interrupts per second. 
   At 115k2 "100" should be sufficient. 
   If you're using higher baudrates, you can increase this...
 */

static int sx_maxints = 100;

/* These are the only open spaces in my computer. Yours may have more
   or less.... -- REW 
   duh: Card at 0xa0000 is possible on HP Netserver?? -- pvdl
*/
static int sx_probe_addrs[]= {0xc0000, 0xd0000, 0xe0000, 
                              0xc8000, 0xd8000, 0xe8000};
static int si_probe_addrs[]= {0xc0000, 0xd0000, 0xe0000, 
                              0xc8000, 0xd8000, 0xe8000, 0xa0000};
static int si1_probe_addrs[]= { 0xd0000};

#define NR_SX_ADDRS ARRAY_SIZE(sx_probe_addrs)
#define NR_SI_ADDRS ARRAY_SIZE(si_probe_addrs)
#define NR_SI1_ADDRS ARRAY_SIZE(si1_probe_addrs)


/* Set the mask to all-ones. This alas, only supports 32 interrupts. 
   Some architectures may need more. */
static int sx_irqmask = -1;

module_param_array(sx_probe_addrs, int, NULL, 0);
module_param_array(si_probe_addrs, int, NULL, 0);
module_param(sx_poll, int, 0);
module_param(sx_slowpoll, int, 0);
module_param(sx_maxints, int, 0);
module_param(sx_debug, int, 0);
module_param(sx_irqmask, int, 0);

MODULE_LICENSE("GPL");

static struct real_driver sx_real_driver = {
	sx_disable_tx_interrupts,
	sx_enable_tx_interrupts,
	sx_disable_rx_interrupts,
	sx_enable_rx_interrupts,
	sx_get_CD,
	sx_shutdown_port, 
	sx_set_real_termios, 
	sx_chars_in_buffer,
	sx_close,
};


/* 
   This driver can spew a whole lot of debugging output at you. If you
   need maximum performance, you should disable the DEBUG define. To
   aid in debugging in the field, I'm leaving the compile-time debug
   features enabled, and disable them "runtime". That allows me to
   instruct people with problems to enable debugging without requiring
   them to recompile... 
*/
#define DEBUG


#ifdef DEBUG
#define sx_dprintk(f, str...) if (sx_debug & f) printk (str)
#else
#define sx_dprintk(f, str...) /* nothing */
#endif



#define func_enter() sx_dprintk (SX_DEBUG_FLOW, "sx: enter %s\n",__FUNCTION__)
#define func_exit()  sx_dprintk (SX_DEBUG_FLOW, "sx: exit  %s\n", __FUNCTION__)

#define func_enter2() sx_dprintk (SX_DEBUG_FLOW, "sx: enter %s (port %d)\n", \
					__FUNCTION__, port->line)




/* 
 *  Firmware loader driver specific routines
 *
 */

static struct file_operations sx_fw_fops = {
	.owner		= THIS_MODULE,
	.ioctl		= sx_fw_ioctl,
};

static struct miscdevice sx_fw_device = {
	SXCTL_MISC_MINOR, "sxctl", &sx_fw_fops
};





#ifdef SX_PARANOIA_CHECK

/* This doesn't work. Who's paranoid around here? Not me! */

static inline int sx_paranoia_check(struct sx_port const * port,
				    char *name, const char *routine)
{

	static const char *badmagic =
	  KERN_ERR "sx: Warning: bad sx port magic number for device %s in %s\n";
	static const char *badinfo =
	  KERN_ERR "sx: Warning: null sx port for device %s in %s\n";
 
	if (!port) {
		printk(badinfo, name, routine);
		return 1;
	}
	if (port->magic != SX_MAGIC) {
		printk(badmagic, name, routine);
		return 1;
	}

	return 0;
}
#else
#define sx_paranoia_check(a,b,c) 0
#endif

/* The timeouts. First try 30 times as fast as possible. Then give
   the card some time to breathe between accesses. (Otherwise the
   processor on the card might not be able to access its OWN bus... */

#define TIMEOUT_1 30
#define TIMEOUT_2 1000000


#ifdef DEBUG
static void my_hd_io(void __iomem *p, int len)
{
	int i, j, ch;
	unsigned char __iomem *addr = p;

	for (i=0;i<len;i+=16) {
		printk ("%p ", addr+i);
		for (j=0;j<16;j++) {
			printk ("%02x %s", readb(addr+j+i), (j==7)?" ":"");
		}
		for (j=0;j<16;j++) {
			ch = readb(addr+j+i);
			printk ("%c", (ch < 0x20)?'.':((ch > 0x7f)?'.':ch));
		}
		printk ("\n");
	}
}
static void my_hd(void *p, int len)
{
	int i, j, ch;
	unsigned char *addr = p;

	for (i=0;i<len;i+=16) {
		printk ("%p ", addr+i);
		for (j=0;j<16;j++) {
			printk ("%02x %s", addr[j+i], (j==7)?" ":"");
		}
		for (j=0;j<16;j++) {
			ch = addr[j+i];
			printk ("%c", (ch < 0x20)?'.':((ch > 0x7f)?'.':ch));
		}
		printk ("\n");
	}
}
#endif



/* This needs redoing for Alpha -- REW -- Done. */

static inline void write_sx_byte (struct sx_board *board, int offset, u8 byte)
{
	writeb (byte, board->base+offset);
}

static inline u8 read_sx_byte (struct sx_board *board, int offset)
{
	return readb (board->base+offset);
}


static inline void write_sx_word (struct sx_board *board, int offset, u16 word)
{
	writew (word, board->base+offset);
}

static inline u16 read_sx_word (struct sx_board *board, int offset)
{
	return readw (board->base + offset);
}


static int sx_busy_wait_eq (struct sx_board *board, 
                     	    int offset, int mask, int correctval)
{
	int i;

	func_enter ();

	for (i=0; i < TIMEOUT_1 ;i++)
		if ((read_sx_byte (board, offset) & mask) == correctval) {
			func_exit ();
			return 1;
		}

	for (i=0; i < TIMEOUT_2 ;i++) {
		if ((read_sx_byte (board, offset) & mask) == correctval) {
			func_exit ();
			return 1;
		}
		udelay (1);
	}

	func_exit ();
	return 0;
}


static int sx_busy_wait_neq (struct sx_board *board, 
                      	     int offset, int mask, int badval)
{
	int i;

	func_enter ();

	for (i=0; i < TIMEOUT_1 ;i++)
		if ((read_sx_byte (board, offset) & mask) != badval) {
			func_exit ();
			return 1;
		}

	for (i=0; i < TIMEOUT_2 ;i++) {
		if ((read_sx_byte (board, offset) & mask) != badval) {
			func_exit ();
			return 1;
		}
		udelay (1);
	}

	func_exit ();
	return 0;
}



/* 5.6.4 of 6210028 r2.3 */
static int sx_reset (struct sx_board *board)
{
	func_enter ();

	if (IS_SX_BOARD (board)) {

		write_sx_byte (board, SX_CONFIG, 0);
		write_sx_byte (board, SX_RESET, 1); /* Value doesn't matter */

		if (!sx_busy_wait_eq (board, SX_RESET_STATUS, 1, 0)) {
			printk (KERN_INFO "sx: Card doesn't respond to reset....\n");
			return 0;
		}
	} else if (IS_EISA_BOARD(board)) {
		outb(board->irq<<4, board->eisa_base+0xc02);
	} else if (IS_SI1_BOARD(board)) {
	        write_sx_byte (board, SI1_ISA_RESET,   0); // value does not matter
	} else {
		/* Gory details of the SI/ISA board */
		write_sx_byte (board, SI2_ISA_RESET,    SI2_ISA_RESET_SET);
		write_sx_byte (board, SI2_ISA_IRQ11,    SI2_ISA_IRQ11_CLEAR);
		write_sx_byte (board, SI2_ISA_IRQ12,    SI2_ISA_IRQ12_CLEAR);
		write_sx_byte (board, SI2_ISA_IRQ15,    SI2_ISA_IRQ15_CLEAR);
		write_sx_byte (board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_CLEAR);
		write_sx_byte (board, SI2_ISA_IRQSET,   SI2_ISA_IRQSET_CLEAR);
	}

	func_exit ();
	return 1;
}


/* This doesn't work on machines where "NULL" isn't 0 */
/* If you have one of those, someone will need to write 
   the equivalent of this, which will amount to about 3 lines. I don't
   want to complicate this right now. -- REW
   (See, I do write comments every now and then :-) */
#define OFFSETOF(strct, elem) ((long)&(((struct strct *)NULL)->elem))


#define CHAN_OFFSET(port,elem) (port->ch_base + OFFSETOF (_SXCHANNEL, elem))
#define MODU_OFFSET(board,addr,elem)    (addr + OFFSETOF (_SXMODULE, elem))
#define  BRD_OFFSET(board,elem)                (OFFSETOF (_SXCARD, elem))


#define sx_write_channel_byte(port, elem, val) \
   write_sx_byte (port->board, CHAN_OFFSET (port, elem), val)

#define sx_read_channel_byte(port, elem) \
   read_sx_byte (port->board, CHAN_OFFSET (port, elem))

#define sx_write_channel_word(port, elem, val) \
   write_sx_word (port->board, CHAN_OFFSET (port, elem), val)

#define sx_read_channel_word(port, elem) \
   read_sx_word (port->board, CHAN_OFFSET (port, elem))


#define sx_write_module_byte(board, addr, elem, val) \
   write_sx_byte (board, MODU_OFFSET (board, addr, elem), val)

#define sx_read_module_byte(board, addr, elem) \
   read_sx_byte (board, MODU_OFFSET (board, addr, elem))

#define sx_write_module_word(board, addr, elem, val) \
   write_sx_word (board, MODU_OFFSET (board, addr, elem), val)

#define sx_read_module_word(board, addr, elem) \
   read_sx_word (board, MODU_OFFSET (board, addr, elem))


#define sx_write_board_byte(board, elem, val) \
   write_sx_byte (board, BRD_OFFSET (board, elem), val)

#define sx_read_board_byte(board, elem) \
   read_sx_byte (board, BRD_OFFSET (board, elem))

#define sx_write_board_word(board, elem, val) \
   write_sx_word (board, BRD_OFFSET (board, elem), val)

#define sx_read_board_word(board, elem) \
   read_sx_word (board, BRD_OFFSET (board, elem))


static int sx_start_board (struct sx_board *board)
{
	if (IS_SX_BOARD (board)) {
		write_sx_byte (board, SX_CONFIG, SX_CONF_BUSEN);
	} else if (IS_EISA_BOARD(board)) {
		write_sx_byte(board, SI2_EISA_OFF, SI2_EISA_VAL);
		outb((board->irq<<4)|4, board->eisa_base+0xc02);
	} else if (IS_SI1_BOARD(board)) {
		write_sx_byte (board, SI1_ISA_RESET_CLEAR, 0);
		write_sx_byte (board, SI1_ISA_INTCL, 0);
	} else {
		/* Don't bug me about the clear_set. 
		   I haven't the foggiest idea what it's about -- REW */
		write_sx_byte (board, SI2_ISA_RESET,    SI2_ISA_RESET_CLEAR);
		write_sx_byte (board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_SET);
	}
	return 1;
}

#define SX_IRQ_REG_VAL(board) \
        ((board->flags & SX_ISA_BOARD)?(board->irq << 4):0)

/* Note. The SX register is write-only. Therefore, we have to enable the
   bus too. This is a no-op, if you don't mess with this driver... */
static int sx_start_interrupts (struct sx_board *board)
{

	/* Don't call this with board->irq == 0 */

	if (IS_SX_BOARD(board)) {
		write_sx_byte (board, SX_CONFIG, SX_IRQ_REG_VAL (board) | 
		                                 SX_CONF_BUSEN | 
		                                 SX_CONF_HOSTIRQ);
	} else if (IS_EISA_BOARD(board)) {
		inb(board->eisa_base+0xc03);  
	} else if (IS_SI1_BOARD(board)) {
	       write_sx_byte (board, SI1_ISA_INTCL,0);
	       write_sx_byte (board, SI1_ISA_INTCL_CLEAR,0);
	} else {
		switch (board->irq) {
		case 11:write_sx_byte (board, SI2_ISA_IRQ11, SI2_ISA_IRQ11_SET);break;
		case 12:write_sx_byte (board, SI2_ISA_IRQ12, SI2_ISA_IRQ12_SET);break;
		case 15:write_sx_byte (board, SI2_ISA_IRQ15, SI2_ISA_IRQ15_SET);break;
		default:printk (KERN_INFO "sx: SI/XIO card doesn't support interrupt %d.\n", 
		                board->irq);
		return 0;
		}
		write_sx_byte (board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_SET);
	}

	return 1;
}


static int sx_send_command (struct sx_port *port, 
                     	    int command, int mask, int newstat)
{
	func_enter2 ();
	write_sx_byte (port->board, CHAN_OFFSET (port, hi_hstat), command);
	func_exit ();
	return sx_busy_wait_eq (port->board, CHAN_OFFSET (port, hi_hstat), mask, newstat);
}


static char *mod_type_s (int module_type)
{
	switch (module_type) {
	case TA4:       return "TA4";
	case TA8:       return "TA8";
	case TA4_ASIC:  return "TA4_ASIC";
	case TA8_ASIC:  return "TA8_ASIC";
	case MTA_CD1400:return "MTA_CD1400";
	case SXDC:      return "SXDC";
	default:return "Unknown/invalid";
	}
}


static char *pan_type_s (int pan_type)
{
	switch (pan_type) {
	case MOD_RS232DB25:     return "MOD_RS232DB25";
	case MOD_RS232RJ45:     return "MOD_RS232RJ45";
	case MOD_RS422DB25:     return "MOD_RS422DB25";
	case MOD_PARALLEL:      return "MOD_PARALLEL";
	case MOD_2_RS232DB25:   return "MOD_2_RS232DB25";
	case MOD_2_RS232RJ45:   return "MOD_2_RS232RJ45";
	case MOD_2_RS422DB25:   return "MOD_2_RS422DB25";
	case MOD_RS232DB25MALE: return "MOD_RS232DB25MALE";
	case MOD_2_PARALLEL:    return "MOD_2_PARALLEL";
	case MOD_BLANK:         return "empty";
	default:return "invalid";
	}
}


static int mod_compat_type (int module_type)
{
	return module_type >> 4;
}

static void sx_reconfigure_port(struct sx_port *port)
{
	if (sx_read_channel_byte (port, hi_hstat) == HS_IDLE_OPEN) {
		if (sx_send_command (port, HS_CONFIG, -1, HS_IDLE_OPEN) != 1) {
			printk (KERN_WARNING "sx: Sent reconfigure command, but card didn't react.\n");
		}
	} else {
		sx_dprintk (SX_DEBUG_TERMIOS, 
		            "sx: Not sending reconfigure: port isn't open (%02x).\n", 
		            sx_read_channel_byte (port, hi_hstat));
	}	
}

static void sx_setsignals (struct sx_port *port, int dtr, int rts)
{
	int t;
	func_enter2 ();

	t = sx_read_channel_byte (port, hi_op);
	if (dtr >= 0) t = dtr? (t | OP_DTR): (t & ~OP_DTR);
	if (rts >= 0) t = rts? (t | OP_RTS): (t & ~OP_RTS);
	sx_write_channel_byte (port, hi_op, t);
	sx_dprintk (SX_DEBUG_MODEMSIGNALS, "setsignals: %d/%d\n", dtr, rts);

	func_exit ();
}



static int sx_getsignals (struct sx_port *port)
{
	int i_stat,o_stat;

	o_stat = sx_read_channel_byte (port, hi_op);
	i_stat = sx_read_channel_byte (port, hi_ip);

	sx_dprintk (SX_DEBUG_MODEMSIGNALS, "getsignals: %d/%d  (%d/%d) %02x/%02x\n",
	            (o_stat & OP_DTR) != 0, (o_stat & OP_RTS) != 0,
	            port->c_dcd, sx_get_CD (port),
	            sx_read_channel_byte (port, hi_ip),
	            sx_read_channel_byte (port, hi_state));

	return (((o_stat & OP_DTR)?TIOCM_DTR:0) |
	        ((o_stat & OP_RTS)?TIOCM_RTS:0) |
	        ((i_stat & IP_CTS)?TIOCM_CTS:0) |
	        ((i_stat & IP_DCD)?TIOCM_CAR:0) |
	        ((i_stat & IP_DSR)?TIOCM_DSR:0) |
	        ((i_stat & IP_RI)?TIOCM_RNG:0)
	        );
}


static void sx_set_baud (struct sx_port *port)
{
	int t;

	if (port->board->ta_type == MOD_SXDC) {
		switch (port->gs.baud) {
		  /* Save some typing work... */
#define e(x) case x:t= BAUD_ ## x ; break
			e(50);e(75);e(110);e(150);e(200);e(300);e(600);
                        e(1200);e(1800);e(2000);e(2400);e(4800);e(7200);
                        e(9600);e(14400);e(19200);e(28800);e(38400);
                        e(56000);e(57600);e(64000);e(76800);e(115200);
			e(128000);e(150000);e(230400);e(256000);e(460800);
                        e(921600);
		case 134    :t = BAUD_134_5;   break;
		case 0      :t = -1;
								 break;
		default:
			/* Can I return "invalid"? */
			t = BAUD_9600;
			printk (KERN_INFO "sx: unsupported baud rate: %d.\n", port->gs.baud);
			break;
		}
#undef e
		if (t > 0) {
			/* The baud rate is not set to 0, so we're enabeling DTR... -- REW */
			sx_setsignals (port, 1, -1); 
			/* XXX This is not TA & MTA compatible */
			sx_write_channel_byte (port, hi_csr, 0xff);

			sx_write_channel_byte (port, hi_txbaud, t);
			sx_write_channel_byte (port, hi_rxbaud, t);
		} else {
			sx_setsignals (port, 0, -1);
		}
	} else {
		switch (port->gs.baud) {
#define e(x) case x:t= CSR_ ## x ; break
			e(75);e(150);e(300);e(600);e(1200);e(2400);e(4800);
                        e(1800);e(9600);
			e(19200);e(57600);e(38400);
			/* TA supports 110, but not 115200, MTA supports 115200, but not 110 */
		case 110: 
			if (port->board->ta_type == MOD_TA) {
				t = CSR_110;
				break;
			} else {
				t = CSR_9600;
				printk (KERN_INFO "sx: Unsupported baud rate: %d.\n", port->gs.baud);
				break;
			}
		case 115200: 
			if (port->board->ta_type == MOD_TA) {
				t = CSR_9600;
				printk (KERN_INFO "sx: Unsupported baud rate: %d.\n", port->gs.baud);
				break;
			} else {
				t = CSR_110;
				break;
			}
		case 0      :t = -1;
								 break;
		default:
			t = CSR_9600;
			printk (KERN_INFO "sx: Unsupported baud rate: %d.\n", port->gs.baud);
			break;
		}
#undef e
		if (t >= 0) {
			sx_setsignals (port, 1, -1);
			sx_write_channel_byte (port, hi_csr, t * 0x11);
		} else {
			sx_setsignals (port, 0, -1);
		}
	}
}


/* Simon Allen's version of this routine was 225 lines long. 85 is a lot
   better. -- REW */

static int sx_set_real_termios (void *ptr)
{
	struct sx_port *port = ptr;

	func_enter2();

	if (!port->gs.tty)
		return 0;

	/* What is this doing here? -- REW
	   Ha! figured it out. It is to allow you to get DTR active again
	   if you've dropped it with stty 0. Moved to set_baud, where it
	   belongs (next to the drop dtr if baud == 0) -- REW */
	/* sx_setsignals (port, 1, -1); */

	sx_set_baud (port);

#define CFLAG port->gs.tty->termios->c_cflag
	sx_write_channel_byte (port, hi_mr1,
	                       (C_PARENB (port->gs.tty)? MR1_WITH:MR1_NONE) |
	                       (C_PARODD (port->gs.tty)? MR1_ODD:MR1_EVEN) |
	                       (C_CRTSCTS(port->gs.tty)? MR1_RTS_RXFLOW:0) |
	                       (((CFLAG & CSIZE)==CS8) ? MR1_8_BITS:0) |
	                       (((CFLAG & CSIZE)==CS7) ? MR1_7_BITS:0) |
	                       (((CFLAG & CSIZE)==CS6) ? MR1_6_BITS:0) |
	                       (((CFLAG & CSIZE)==CS5) ? MR1_5_BITS:0) );

	sx_write_channel_byte (port, hi_mr2,
	                       (C_CRTSCTS(port->gs.tty)?MR2_CTS_TXFLOW:0) |
	                       (C_CSTOPB (port->gs.tty)?MR2_2_STOP:MR2_1_STOP));

	switch (CFLAG & CSIZE) {
	case CS8:sx_write_channel_byte (port, hi_mask, 0xff);break;
	case CS7:sx_write_channel_byte (port, hi_mask, 0x7f);break;
	case CS6:sx_write_channel_byte (port, hi_mask, 0x3f);break;
	case CS5:sx_write_channel_byte (port, hi_mask, 0x1f);break;
	default:
		printk (KERN_INFO "sx: Invalid wordsize: %u\n", CFLAG & CSIZE);
		break;
	}

	sx_write_channel_byte (port, hi_prtcl, 
	                       (I_IXON   (port->gs.tty)?SP_TXEN:0) |
	                       (I_IXOFF  (port->gs.tty)?SP_RXEN:0) |
	                       (I_IXANY  (port->gs.tty)?SP_TANY:0) |
	                       SP_DCEN);

	sx_write_channel_byte (port, hi_break, 
	                       (I_IGNBRK(port->gs.tty)?BR_IGN:0 |
	                        I_BRKINT(port->gs.tty)?BR_INT:0));

	sx_write_channel_byte (port, hi_txon,  START_CHAR (port->gs.tty));
	sx_write_channel_byte (port, hi_rxon,  START_CHAR (port->gs.tty));
	sx_write_channel_byte (port, hi_txoff, STOP_CHAR  (port->gs.tty));
	sx_write_channel_byte (port, hi_rxoff, STOP_CHAR  (port->gs.tty));

	sx_reconfigure_port(port);

	/* Tell line discipline whether we will do input cooking */
	if(I_OTHER(port->gs.tty)) {
		clear_bit(TTY_HW_COOK_IN, &port->gs.tty->flags);
	} else {
		set_bit(TTY_HW_COOK_IN, &port->gs.tty->flags);
	}
	sx_dprintk (SX_DEBUG_TERMIOS, "iflags: %x(%d) ",
	            port->gs.tty->termios->c_iflag, 
	            I_OTHER(port->gs.tty));


/* Tell line discipline whether we will do output cooking.
 * If OPOST is set and no other output flags are set then we can do output
 * processing.  Even if only *one* other flag in the O_OTHER group is set
 * we do cooking in software.
 */
	if(O_OPOST(port->gs.tty) && !O_OTHER(port->gs.tty)) {
		set_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags);
	} else {
		clear_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags);
	}
	sx_dprintk (SX_DEBUG_TERMIOS, "oflags: %x(%d)\n",
	            port->gs.tty->termios->c_oflag, 
	            O_OTHER(port->gs.tty));
	/* port->c_dcd = sx_get_CD (port); */
	func_exit ();
	return 0;
}



/* ********************************************************************** *
 *                   the interrupt related routines                       *
 * ********************************************************************** */

/* Note:
   Other drivers use the macro "MIN" to calculate how much to copy.
   This has the disadvantage that it will evaluate parts twice. That's
   expensive when it's IO (and the compiler cannot optimize those away!).
   Moreover, I'm not sure that you're race-free. 

   I assign a value, and then only allow the value to decrease. This
   is always safe. This makes the code a few lines longer, and you
   know I'm dead against that, but I think it is required in this
   case.  */


static void sx_transmit_chars (struct sx_port *port)
{
	int c;
	int tx_ip;
	int txroom;

	func_enter2 ();
	sx_dprintk (SX_DEBUG_TRANSMIT, "Port %p: transmit %d chars\n", 
	            port, port->gs.xmit_cnt);

	if (test_and_set_bit (SX_PORT_TRANSMIT_LOCK, &port->locks)) {
		return;
	}

	while (1) {
		c = port->gs.xmit_cnt;

		sx_dprintk (SX_DEBUG_TRANSMIT, "Copying %d ", c);
		tx_ip  = sx_read_channel_byte (port, hi_txipos);

		/* Took me 5 minutes to deduce this formula. 
		   Luckily it is literally in the manual in section 6.5.4.3.5 */
		txroom = (sx_read_channel_byte (port, hi_txopos) - tx_ip - 1) & 0xff;

		/* Don't copy more bytes than there is room for in the buffer */
		if (c > txroom)
			c = txroom;
		sx_dprintk (SX_DEBUG_TRANSMIT, " %d(%d) ", c, txroom );

		/* Don't copy past the end of the hardware transmit buffer */
		if (c > 0x100 - tx_ip) 
			c = 0x100 - tx_ip;

		sx_dprintk (SX_DEBUG_TRANSMIT, " %d(%d) ", c, 0x100-tx_ip );

		/* Don't copy pas the end of the source buffer */
		if (c > SERIAL_XMIT_SIZE - port->gs.xmit_tail) 
			c = SERIAL_XMIT_SIZE - port->gs.xmit_tail;

		sx_dprintk (SX_DEBUG_TRANSMIT, " %d(%ld) \n", 
		            c, SERIAL_XMIT_SIZE- port->gs.xmit_tail);

		/* If for one reason or another, we can't copy more data, we're done! */
		if (c == 0) break;


		memcpy_toio (port->board->base + CHAN_OFFSET(port,hi_txbuf) + tx_ip, 
		             port->gs.xmit_buf + port->gs.xmit_tail, c);

		/* Update the pointer in the card */
		sx_write_channel_byte (port, hi_txipos, (tx_ip+c) & 0xff);

		/* Update the kernel buffer end */
		port->gs.xmit_tail = (port->gs.xmit_tail + c) & (SERIAL_XMIT_SIZE-1);

		/* This one last. (this is essential)
		   It would allow others to start putting more data into the buffer! */
		port->gs.xmit_cnt -= c;
	}

	if (port->gs.xmit_cnt == 0) {
		sx_disable_tx_interrupts (port);
	}

	if ((port->gs.xmit_cnt <= port->gs.wakeup_chars) && port->gs.tty) {
		tty_wakeup(port->gs.tty);
		sx_dprintk (SX_DEBUG_TRANSMIT, "Waking up.... ldisc (%d)....\n",
		            port->gs.wakeup_chars); 
	}

	clear_bit (SX_PORT_TRANSMIT_LOCK, &port->locks);
	func_exit ();
}


/* Note the symmetry between receiving chars and transmitting them!
   Note: The kernel should have implemented both a receive buffer and
   a transmit buffer. */

/* Inlined: Called only once. Remove the inline when you add another call */
static inline void sx_receive_chars (struct sx_port *port)
{
	int c;
	int rx_op;
	struct tty_struct *tty;
	int copied=0;
	unsigned char *rp;

	func_enter2 ();
	tty = port->gs.tty;
	while (1) {
		rx_op = sx_read_channel_byte (port, hi_rxopos);
		c = (sx_read_channel_byte (port, hi_rxipos) - rx_op) & 0xff;

		sx_dprintk (SX_DEBUG_RECEIVE, "rxop=%d, c = %d.\n", rx_op, c); 

		/* Don't copy more bytes than there is room for in the buffer */

		c = tty_prepare_flip_string(tty, &rp, c);

		sx_dprintk (SX_DEBUG_RECEIVE, "c = %d.\n", c); 

		/* Don't copy past the end of the hardware receive buffer */
		if (rx_op + c > 0x100) c = 0x100 - rx_op;

		sx_dprintk (SX_DEBUG_RECEIVE, "c = %d.\n", c);

		/* If for one reason or another, we can't copy more data, we're done! */
		if (c == 0) break;

		sx_dprintk (SX_DEBUG_RECEIVE , "Copying over %d chars. First is %d at %lx\n", c, 
		            read_sx_byte (port->board, CHAN_OFFSET(port,hi_rxbuf) + rx_op),
		            CHAN_OFFSET(port, hi_rxbuf)); 
		memcpy_fromio (rp,
		               port->board->base + CHAN_OFFSET(port,hi_rxbuf) + rx_op, c);

		/* This one last. ( Not essential.)
		   It allows the card to start putting more data into the buffer! 
		   Update the pointer in the card */
		sx_write_channel_byte (port, hi_rxopos, (rx_op + c) & 0xff);

		copied += c;
	}
	if (copied) {
		struct timeval tv;

		do_gettimeofday (&tv);
		sx_dprintk (SX_DEBUG_RECEIVE, 
		            "pushing flipq port %d (%3d chars): %d.%06d  (%d/%d)\n", 
		            port->line, copied, 
		            (int) (tv.tv_sec % 60), (int)tv.tv_usec, tty->raw, tty->real_raw);

		/* Tell the rest of the system the news. Great news. New characters! */
		tty_flip_buffer_push (tty);
		/*    tty_schedule_flip (tty); */
	}

	func_exit ();
}

/* Inlined: it is called only once. Remove the inline if you add another 
   call */
static inline void sx_check_modem_signals (struct sx_port *port)
{
	int hi_state;
	int c_dcd;

	hi_state = sx_read_channel_byte (port, hi_state);
	sx_dprintk (SX_DEBUG_MODEMSIGNALS, "Checking modem signals (%d/%d)\n",
	            port->c_dcd, sx_get_CD (port));

	if (hi_state & ST_BREAK) {
		hi_state &= ~ST_BREAK;
		sx_dprintk (SX_DEBUG_MODEMSIGNALS, "got a break.\n");
		sx_write_channel_byte (port, hi_state, hi_state);
		gs_got_break (&port->gs);
	}
	if (hi_state & ST_DCD) {
		hi_state &= ~ST_DCD;
		sx_dprintk (SX_DEBUG_MODEMSIGNALS, "got a DCD change.\n");
		sx_write_channel_byte (port, hi_state, hi_state);
		c_dcd = sx_get_CD (port);
		sx_dprintk (SX_DEBUG_MODEMSIGNALS, "DCD is now %d\n", c_dcd);
		if (c_dcd != port->c_dcd) {
			port->c_dcd = c_dcd;
			if (sx_get_CD (port)) {
				/* DCD went UP */
				if ((sx_read_channel_byte(port, hi_hstat) != HS_IDLE_CLOSED) &&
						!(port->gs.tty->termios->c_cflag & CLOCAL) ) {
					/* Are we blocking in open?*/
					sx_dprintk (SX_DEBUG_MODEMSIGNALS, "DCD active, unblocking open\n");
					wake_up_interruptible(&port->gs.open_wait);
				} else {
					sx_dprintk (SX_DEBUG_MODEMSIGNALS, "DCD raised. Ignoring.\n");
				}
			} else {
				/* DCD went down! */
				if (!(port->gs.tty->termios->c_cflag & CLOCAL) ) {
					sx_dprintk (SX_DEBUG_MODEMSIGNALS, "DCD dropped. hanging up....\n");
					tty_hangup (port->gs.tty);
				} else {
					sx_dprintk (SX_DEBUG_MODEMSIGNALS, "DCD dropped. ignoring.\n");
				}
			}
		} else {
			sx_dprintk (SX_DEBUG_MODEMSIGNALS, "Hmmm. card told us DCD changed, but it didn't.\n");
		}
	}
}


/* This is what an interrupt routine should look like. 
 * Small, elegant, clear.
 */

static irqreturn_t sx_interrupt (int irq, void *ptr, struct pt_regs *regs)
{
	struct sx_board *board = ptr;
	struct sx_port *port;
	int i;

	func_enter ();
	sx_dprintk (SX_DEBUG_FLOW, "sx: enter sx_interrupt (%d/%d)\n", irq, board->irq); 

	/* AAargh! The order in which to do these things is essential and
	   not trivial. 

	   - Rate limit goes before "recursive". Otherwise a series of
	     recursive calls will hang the machine in the interrupt routine. 

	   - hardware twiddling goes before "recursive". Otherwise when we
	     poll the card, and a recursive interrupt happens, we won't
	     ack the card, so it might keep on interrupting us. (especially
	     level sensitive interrupt systems like PCI).

	   - Rate limit goes before hardware twiddling. Otherwise we won't
	     catch a card that has gone bonkers.

	   - The "initialized" test goes after the hardware twiddling. Otherwise
	     the card will stick us in the interrupt routine again.

	   - The initialized test goes before recursive. 
	*/



#ifdef IRQ_RATE_LIMIT
	/* Aaargh! I'm ashamed. This costs more lines-of-code than the
	   actual interrupt routine!. (Well, used to when I wrote that comment) */
	{
		static int lastjif;
		static int nintr=0;

		if (lastjif == jiffies) {
			if (++nintr > IRQ_RATE_LIMIT) {
				free_irq (board->irq, board);
				printk (KERN_ERR "sx: Too many interrupts. Turning off interrupt %d.\n", 
					      board->irq);
			}
		} else {
			lastjif = jiffies;
			nintr = 0;
		}
	}
#endif


	if (board->irq == irq) {
		/* Tell the card we've noticed the interrupt. */

		sx_write_board_word (board, cc_int_pending, 0);
		if (IS_SX_BOARD (board)) {
			write_sx_byte (board, SX_RESET_IRQ, 1);
		} else if (IS_EISA_BOARD(board)) {
			inb(board->eisa_base+0xc03);
			write_sx_word(board, 8, 0); 
		} else {
			write_sx_byte (board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_CLEAR);
			write_sx_byte (board, SI2_ISA_INTCLEAR, SI2_ISA_INTCLEAR_SET);
		}
	}

	if (!sx_initialized)
		return IRQ_HANDLED;
	if (!(board->flags & SX_BOARD_INITIALIZED))
		return IRQ_HANDLED;

	if (test_and_set_bit (SX_BOARD_INTR_LOCK, &board->locks)) {
		printk (KERN_ERR "Recursive interrupt! (%d)\n", board->irq);
		return IRQ_HANDLED;
	}

	 for (i=0;i<board->nports;i++) {
		port = &board->ports[i];
		if (port->gs.flags & GS_ACTIVE) {
			if (sx_read_channel_byte (port, hi_state)) {
				sx_dprintk (SX_DEBUG_INTERRUPTS, 
				            "Port %d: modem signal change?... \n", i);
				sx_check_modem_signals (port); 
			}
			if (port->gs.xmit_cnt) {
				sx_transmit_chars (port);
			}
			if (!(port->gs.flags & SX_RX_THROTTLE)) {
				sx_receive_chars (port);
			}
		}
	}

	clear_bit (SX_BOARD_INTR_LOCK, &board->locks);

	sx_dprintk (SX_DEBUG_FLOW, "sx: exit sx_interrupt (%d/%d)\n", irq, board->irq); 
        func_exit ();
	return IRQ_HANDLED;
}


static void sx_pollfunc (unsigned long data)
{
	struct sx_board *board = (struct sx_board *) data;

	func_enter ();

	sx_interrupt (0, board, NULL);

	init_timer(&board->timer);

	board->timer.expires = jiffies + sx_poll;
	add_timer (&board->timer);
	func_exit ();
}



/* ********************************************************************** *
 *                Here are the routines that actually                     *
 *              interface with the generic_serial driver                  *
 * ********************************************************************** */

/* Ehhm. I don't know how to fiddle with interrupts on the SX card. --REW */
/* Hmm. Ok I figured it out. You don't.  */

static void sx_disable_tx_interrupts (void * ptr) 
{
	struct sx_port *port = ptr; 
	func_enter2();

	port->gs.flags &= ~GS_TX_INTEN;

	func_exit();
}


static void sx_enable_tx_interrupts (void * ptr) 
{
	struct sx_port *port = ptr; 
	int data_in_buffer;
	func_enter2();

	/* First transmit the characters that we're supposed to */
	sx_transmit_chars (port);

	/* The sx card will never interrupt us if we don't fill the buffer
	   past 25%. So we keep considering interrupts off if that's the case. */
	data_in_buffer = (sx_read_channel_byte (port, hi_txipos) - 
	                  sx_read_channel_byte (port, hi_txopos)) & 0xff;

	/* XXX Must be "HIGH_WATER" for SI card according to doc. */
	if (data_in_buffer < LOW_WATER) 
		port->gs.flags &= ~GS_TX_INTEN;

	func_exit();
}


static void sx_disable_rx_interrupts (void * ptr) 
{
	/*  struct sx_port *port = ptr; */
	func_enter();

	func_exit();
}

static void sx_enable_rx_interrupts (void * ptr) 
{
	/*  struct sx_port *port = ptr; */
	func_enter();

	func_exit();
}


/* Jeez. Isn't this simple? */
static int sx_get_CD (void * ptr) 
{
	struct sx_port *port = ptr;
	func_enter2();

	func_exit();
	return ((sx_read_channel_byte (port, hi_ip) & IP_DCD) != 0);
}


/* Jeez. Isn't this simple? */
static int sx_chars_in_buffer (void * ptr) 
{
	struct sx_port *port = ptr;
	func_enter2();

	func_exit();
	return ((sx_read_channel_byte (port, hi_txipos) - 
	         sx_read_channel_byte (port, hi_txopos)) & 0xff);
}


static void sx_shutdown_port (void * ptr) 
{
	struct sx_port *port = ptr; 

	func_enter();

	port->gs.flags &= ~ GS_ACTIVE;
	if (port->gs.tty && (port->gs.tty->termios->c_cflag & HUPCL)) {
		sx_setsignals (port, 0, 0);
		sx_reconfigure_port(port);
	}

	func_exit();
}





/* ********************************************************************** *
 *                Here are the routines that actually                     *
 *               interface with the rest of the system                    *
 * ********************************************************************** */

static int sx_open  (struct tty_struct * tty, struct file * filp)
{
	struct sx_port *port;
	int retval, line;
	unsigned long flags;

	func_enter();

	if (!sx_initialized) {
		return -EIO;
	}

	line = tty->index;
	sx_dprintk (SX_DEBUG_OPEN, "%d: opening line %d. tty=%p ctty=%p, np=%d)\n", 
	            current->pid, line, tty, current->signal->tty, sx_nports);

	if ((line < 0) || (line >= SX_NPORTS) || (line >= sx_nports))
		return -ENODEV;

	port = & sx_ports[line];
	port->c_dcd = 0; /* Make sure that the first interrupt doesn't detect a
	                    1 -> 0 transition. */


	sx_dprintk (SX_DEBUG_OPEN, "port = %p c_dcd = %d\n", port, port->c_dcd);

	spin_lock_irqsave(&port->gs.driver_lock, flags);

	tty->driver_data = port;
	port->gs.tty = tty;
	port->gs.count++;
	spin_unlock_irqrestore(&port->gs.driver_lock, flags);

	sx_dprintk (SX_DEBUG_OPEN, "starting port\n");

	/*
	 * Start up serial port
	 */
	retval = gs_init_port(&port->gs);
	sx_dprintk (SX_DEBUG_OPEN, "done gs_init\n");
	if (retval) {
		port->gs.count--;
		return retval;
	}

	port->gs.flags |= GS_ACTIVE;
	if (port->gs.count <= 1)
		sx_setsignals (port, 1,1);

#if 0
	if (sx_debug & SX_DEBUG_OPEN)
		my_hd (port, sizeof (*port));
#else
	if (sx_debug & SX_DEBUG_OPEN)
		my_hd_io (port->board->base + port->ch_base, sizeof (*port));
#endif

	if (port->gs.count <= 1) {
		if (sx_send_command (port, HS_LOPEN, -1, HS_IDLE_OPEN) != 1) {
			printk (KERN_ERR "sx: Card didn't respond to LOPEN command.\n");
			spin_lock_irqsave(&port->gs.driver_lock, flags);
			port->gs.count--;
			spin_unlock_irqrestore(&port->gs.driver_lock, flags);
			return -EIO;
		}
	}

	retval = gs_block_til_ready(port, filp);
	sx_dprintk (SX_DEBUG_OPEN, "Block til ready returned %d. Count=%d\n", 
	            retval, port->gs.count);

	if (retval) {
		/* 
		 * Don't lower gs.count here because sx_close() will be called later
		 */ 

		return retval;
	}
	/* tty->low_latency = 1; */

	port->c_dcd = sx_get_CD (port);
	sx_dprintk (SX_DEBUG_OPEN, "at open: cd=%d\n", port->c_dcd);

	func_exit();
	return 0;

}


static void sx_close (void *ptr)
{
	struct sx_port *port = ptr; 
	/* Give the port 5 seconds to close down. */
	int to = 5 * HZ; 

	func_enter ();

	sx_setsignals (port, 0, 0);
	sx_reconfigure_port(port);	
	sx_send_command (port, HS_CLOSE, 0, 0);

	while (to-- && (sx_read_channel_byte (port, hi_hstat) != HS_IDLE_CLOSED))
		if (msleep_interruptible(10))
			break;
	if (sx_read_channel_byte (port, hi_hstat) != HS_IDLE_CLOSED) {
		if (sx_send_command (port, HS_FORCE_CLOSED, -1, HS_IDLE_CLOSED) != 1) {
			printk (KERN_ERR 
			        "sx: sent the force_close command, but card didn't react\n");
		} else
			sx_dprintk (SX_DEBUG_CLOSE, "sent the force_close command.\n");
	}

	sx_dprintk (SX_DEBUG_CLOSE, "waited %d jiffies for close. count=%d\n", 
	            5 * HZ - to - 1, port->gs.count);

	if(port->gs.count) {
		sx_dprintk(SX_DEBUG_CLOSE, "WARNING port count:%d\n", port->gs.count);
		//printk ("%s SETTING port count to zero: %p count: %d\n", __FUNCTION__, port, port->gs.count);
		//port->gs.count = 0;
	}

	func_exit ();
}



/* This is relatively thorough. But then again it is only 20 lines. */
#define MARCHUP    for (i=min;i<max;i++) 
#define MARCHDOWN  for (i=max-1;i>=min;i--)
#define W0         write_sx_byte (board, i, 0x55)
#define W1         write_sx_byte (board, i, 0xaa)
#define R0         if (read_sx_byte (board, i) != 0x55) return 1
#define R1         if (read_sx_byte (board, i) != 0xaa) return 1

/* This memtest takes a human-noticable time. You normally only do it
   once a boot, so I guess that it is worth it. */
static int do_memtest (struct sx_board *board, int min, int max)
{
	int i;

	/* This is a marchb. Theoretically, marchb catches much more than
	   simpler tests. In practise, the longer test just catches more
	   intermittent errors. -- REW
	   (For the theory behind memory testing see: 
	   Testing Semiconductor Memories by A.J. van de Goor.) */
	MARCHUP	 {W0;}
	MARCHUP   {R0;W1;R1;W0;R0;W1;}
	MARCHUP   {R1;W0;W1;}
	MARCHDOWN {R1;W0;W1;W0;}
	MARCHDOWN {R0;W1;W0;}

	return 0;
}


#undef MARCHUP
#undef MARCHDOWN
#undef W0
#undef W1
#undef R0
#undef R1

#define MARCHUP    for (i=min;i<max;i+=2) 
#define MARCHDOWN  for (i=max-1;i>=min;i-=2)
#define W0         write_sx_word (board, i, 0x55aa)
#define W1         write_sx_word (board, i, 0xaa55)
#define R0         if (read_sx_word (board, i) != 0x55aa) return 1
#define R1         if (read_sx_word (board, i) != 0xaa55) return 1

#if 0
/* This memtest takes a human-noticable time. You normally only do it
   once a boot, so I guess that it is worth it. */
static int do_memtest_w (struct sx_board *board, int min, int max)
{
	int i;

	MARCHUP   {W0;}
	MARCHUP   {R0;W1;R1;W0;R0;W1;}
	MARCHUP   {R1;W0;W1;}
	MARCHDOWN {R1;W0;W1;W0;}
	MARCHDOWN {R0;W1;W0;}

	return 0;
}
#endif


static int sx_fw_ioctl (struct inode *inode, struct file *filp,
                        unsigned int cmd, unsigned long arg)
{
	int rc = 0;
	int __user *descr = (int __user *)arg;
	int i;
	static struct sx_board *board = NULL;
	int nbytes, offset;
	unsigned long data;
	char *tmp;

	func_enter();

#if 0 
	/* Removed superuser check: Sysops can use the permissions on the device
	   file to restrict access. Recommendation: Root only. (root.root 600) */
	if (!capable(CAP_SYS_ADMIN)) {
		return -EPERM;
	}
#endif

	sx_dprintk (SX_DEBUG_FIRMWARE, "IOCTL %x: %lx\n", cmd, arg);

	if (!board) board = &boards[0];
	if (board->flags & SX_BOARD_PRESENT) {
		sx_dprintk (SX_DEBUG_FIRMWARE, "Board present! (%x)\n", 
		            board->flags);
	} else {
		sx_dprintk (SX_DEBUG_FIRMWARE, "Board not present! (%x) all:", 
		            board->flags);
		for (i=0;i< SX_NBOARDS;i++)
			sx_dprintk (SX_DEBUG_FIRMWARE, "<%x> ", boards[i].flags);
		sx_dprintk (SX_DEBUG_FIRMWARE, "\n");
		return -EIO;
	}

	switch (cmd) {
	case SXIO_SET_BOARD:
		sx_dprintk (SX_DEBUG_FIRMWARE, "set board to %ld\n", arg);
		if (arg >= SX_NBOARDS) return -EIO;
		sx_dprintk (SX_DEBUG_FIRMWARE, "not out of range\n");
		if (!(boards[arg].flags	& SX_BOARD_PRESENT)) return -EIO;
		sx_dprintk (SX_DEBUG_FIRMWARE, ".. and present!\n");
		board = &boards[arg];
		break;
	case SXIO_GET_TYPE:
		rc = -ENOENT; /* If we manage to miss one, return error. */
		if (IS_SX_BOARD (board)) rc = SX_TYPE_SX;
		if (IS_CF_BOARD (board)) rc = SX_TYPE_CF;
		if (IS_SI_BOARD (board)) rc = SX_TYPE_SI;
		if (IS_SI1_BOARD (board)) rc = SX_TYPE_SI;
		if (IS_EISA_BOARD (board)) rc = SX_TYPE_SI;
		sx_dprintk (SX_DEBUG_FIRMWARE, "returning type= %d\n", rc);
		break;
	case SXIO_DO_RAMTEST:
		if (sx_initialized) /* Already initialized: better not ramtest the board.  */
			return -EPERM;
		if (IS_SX_BOARD (board)) {
			rc          = do_memtest   (board, 0, 0x7000);
			if (!rc) rc = do_memtest   (board, 0, 0x7000);
			/*if (!rc) rc = do_memtest_w (board, 0, 0x7000);*/
		} else {
			rc             = do_memtest   (board, 0, 0x7ff8);
			/* if (!rc) rc = do_memtest_w (board, 0, 0x7ff8); */
		}
		sx_dprintk (SX_DEBUG_FIRMWARE, "returning memtest result= %d\n", rc);
		break;
	case SXIO_DOWNLOAD:
		if (sx_initialized) /* Already initialized */
			return -EEXIST;
		if (!sx_reset (board)) 
			return -EIO;
		sx_dprintk (SX_DEBUG_INIT, "reset the board...\n");

		tmp = kmalloc (SX_CHUNK_SIZE, GFP_USER);
		if (!tmp) return -ENOMEM;
		get_user (nbytes, descr++);
		get_user (offset, descr++); 
		get_user (data,	 descr++);
		while (nbytes && data) {
			for (i=0;i<nbytes;i += SX_CHUNK_SIZE) {
				if (copy_from_user(tmp, (char __user *)data+i, 
						   (i + SX_CHUNK_SIZE >
						    nbytes) ? nbytes - i :
						   	      SX_CHUNK_SIZE)) {
					kfree (tmp);
					return -EFAULT;
				}
				memcpy_toio(board->base2 + offset + i, tmp, 
				                (i+SX_CHUNK_SIZE>nbytes)?nbytes-i:SX_CHUNK_SIZE);
			}

			get_user (nbytes, descr++);
			get_user (offset, descr++); 
			get_user (data,   descr++);
		}
		kfree (tmp);
		sx_nports += sx_init_board (board);
		rc = sx_nports;
		break;
	case SXIO_INIT:
		if (sx_initialized) /* Already initialized */
			return -EEXIST;
		/* This is not allowed until all boards are initialized... */
		for (i=0;i<SX_NBOARDS;i++) {
			if ( (boards[i].flags & SX_BOARD_PRESENT) &&
			     !(boards[i].flags & SX_BOARD_INITIALIZED))
				return -EIO;
		}
		for (i=0;i<SX_NBOARDS;i++)
			if (!(boards[i].flags & SX_BOARD_PRESENT)) break;

		sx_dprintk (SX_DEBUG_FIRMWARE, "initing portstructs, %d boards, "
		            "%d channels, first board: %d ports\n", 
		            i, sx_nports, boards[0].nports);
		rc = sx_init_portstructs (i, sx_nports);
		sx_init_drivers ();
		if (rc >= 0) 
			sx_initialized++;
		break;
	case SXIO_SETDEBUG:
		sx_debug = arg;
		break;
	case SXIO_GETDEBUG:
		rc = sx_debug;
		break;
	case SXIO_GETGSDEBUG:
	case SXIO_SETGSDEBUG:
		rc = -EINVAL;
		break;
	case SXIO_GETNPORTS:
		rc = sx_nports;
		break;
	default:
		printk (KERN_WARNING "Unknown ioctl on firmware device (%x).\n", cmd);
		break;
	}
	func_exit ();
	return rc;
}


static void sx_break (struct tty_struct * tty, int flag)
{
	struct sx_port *port = tty->driver_data;
	int rv;

	func_enter ();

	if (flag) 
		rv = sx_send_command (port, HS_START, -1, HS_IDLE_BREAK);
	else 
		rv = sx_send_command (port, HS_STOP, -1, HS_IDLE_OPEN);
	if (rv != 1) printk (KERN_ERR "sx: couldn't send break (%x).\n",
			read_sx_byte (port->board, CHAN_OFFSET (port, hi_hstat)));

	func_exit ();
}


static int sx_tiocmget(struct tty_struct *tty, struct file *file)
{
	struct sx_port *port = tty->driver_data;
	return sx_getsignals(port);
}

static int sx_tiocmset(struct tty_struct *tty, struct file *file,
		       unsigned int set, unsigned int clear)
{
	struct sx_port *port = tty->driver_data;
	int rts = -1, dtr = -1;

	if (set & TIOCM_RTS)
		rts = 1;
	if (set & TIOCM_DTR)
		dtr = 1;
	if (clear & TIOCM_RTS)
		rts = 0;
	if (clear & TIOCM_DTR)
		dtr = 0;

	sx_setsignals(port, dtr, rts);
	sx_reconfigure_port(port);
	return 0;
}

static int sx_ioctl (struct tty_struct * tty, struct file * filp, 
                     unsigned int cmd, unsigned long arg)
{
	int rc;
	struct sx_port *port = tty->driver_data;
	void __user *argp = (void __user *)arg;
	int ival;

	/* func_enter2(); */

	rc = 0;
	switch (cmd) {
	case TIOCGSOFTCAR:
		rc = put_user(((tty->termios->c_cflag & CLOCAL) ? 1 : 0),
		              (unsigned __user *) argp);
		break;
	case TIOCSSOFTCAR:
		if ((rc = get_user(ival, (unsigned __user *) argp)) == 0) {
			tty->termios->c_cflag =
				(tty->termios->c_cflag & ~CLOCAL) |
				(ival ? CLOCAL : 0);
		}
		break;
	case TIOCGSERIAL:
		rc = gs_getserial(&port->gs, argp);
		break;
	case TIOCSSERIAL:
		rc = gs_setserial(&port->gs, argp);
		break;
	default:
		rc = -ENOIOCTLCMD;
		break;
	}

	/* func_exit(); */
	return rc;
}


/* The throttle/unthrottle scheme for the Specialix card is different
 * from other drivers and deserves some explanation. 
 * The Specialix hardware takes care of XON/XOFF
 * and CTS/RTS flow control itself.  This means that all we have to
 * do when signalled by the upper tty layer to throttle/unthrottle is
 * to make a note of it here.  When we come to read characters from the
 * rx buffers on the card (sx_receive_chars()) we look to see if the
 * upper layer can accept more (as noted here in sx_rx_throt[]). 
 * If it can't we simply don't remove chars from the cards buffer. 
 * When the tty layer can accept chars, we again note that here and when
 * sx_receive_chars() is called it will remove them from the cards buffer.
 * The card will notice that a ports buffer has drained below some low
 * water mark and will unflow control the line itself, using whatever
 * flow control scheme is in use for that port. -- Simon Allen
 */

static void sx_throttle (struct tty_struct * tty)
{
	struct sx_port *port = (struct sx_port *)tty->driver_data;

	func_enter2();
	/* If the port is using any type of input flow
	 * control then throttle the port.
	 */
	if((tty->termios->c_cflag & CRTSCTS) || (I_IXOFF(tty)) ) {
		port->gs.flags |= SX_RX_THROTTLE;
	}
	func_exit();
}


static void sx_unthrottle (struct tty_struct * tty)
{
	struct sx_port *port = (struct sx_port *)tty->driver_data;

	func_enter2();
	/* Always unthrottle even if flow control is not enabled on
	 * this port in case we disabled flow control while the port
	 * was throttled
	 */
	port->gs.flags &= ~SX_RX_THROTTLE;
	func_exit();
	return;
}


/* ********************************************************************** *
 *                    Here are the initialization routines.               *
 * ********************************************************************** */




static int sx_init_board (struct sx_board *board)
{
	int addr;
	int chans;
	int type;

	func_enter();

	/* This is preceded by downloading the download code. */

	board->flags |= SX_BOARD_INITIALIZED;

	if (read_sx_byte (board, 0))
		/* CF boards may need this. */
		write_sx_byte(board,0, 0);

	/* This resets the processor again, to make sure it didn't do any
	   foolish things while we were downloading the image */
	if (!sx_reset (board))
		return 0;

	sx_start_board (board);
	udelay (10);
	if (!sx_busy_wait_neq (board, 0, 0xff, 0)) {
		printk (KERN_ERR "sx: Ooops. Board won't initialize.\n");
		return 0;
	}

	/* Ok. So now the processor on the card is running. It gathered
	   some info for us... */
	sx_dprintk (SX_DEBUG_INIT, "The sxcard structure:\n");
	if (sx_debug & SX_DEBUG_INIT) my_hd_io (board->base, 0x10);
	sx_dprintk (SX_DEBUG_INIT, "the first sx_module structure:\n");
	if (sx_debug & SX_DEBUG_INIT) my_hd_io (board->base + 0x80, 0x30);

	sx_dprintk (SX_DEBUG_INIT, 
	            "init_status: %x, %dk memory, firmware V%x.%02x,\n", 
	            read_sx_byte (board, 0), read_sx_byte(board, 1), 
	            read_sx_byte (board, 5), read_sx_byte(board, 4));

	if (read_sx_byte (board, 0) == 0xff) {
		printk (KERN_INFO "sx: No modules found. Sorry.\n");
		board->nports = 0;
		return 0;
	}

	chans = 0;

	if (IS_SX_BOARD(board)) {
		sx_write_board_word (board, cc_int_count, sx_maxints);
	} else {
		if (sx_maxints)
			sx_write_board_word (board, cc_int_count, SI_PROCESSOR_CLOCK/8/sx_maxints);
	}

	/* grab the first module type... */
	/*  board->ta_type = mod_compat_type (read_sx_byte (board, 0x80 + 0x08)); */
	board->ta_type = mod_compat_type (sx_read_module_byte (board, 0x80, mc_chip));

	/* XXX byteorder */
	for (addr = 0x80;addr != 0;addr = read_sx_word (board, addr) & 0x7fff) {
		type = sx_read_module_byte (board, addr, mc_chip);
		sx_dprintk (SX_DEBUG_INIT, "Module at %x: %d channels\n", 
		            addr, read_sx_byte (board, addr + 2));

		chans += sx_read_module_byte (board, addr, mc_type);

		sx_dprintk (SX_DEBUG_INIT, "module is an %s, which has %s/%s panels\n", 
		            mod_type_s (type),
		            pan_type_s (sx_read_module_byte (board, addr, mc_mods) & 0xf),
		            pan_type_s (sx_read_module_byte (board, addr, mc_mods) >> 4));

		sx_dprintk (SX_DEBUG_INIT, "CD1400 versions: %x/%x, ASIC version: %x\n", 
		            sx_read_module_byte (board, addr, mc_rev1),
		            sx_read_module_byte (board, addr, mc_rev2),
		            sx_read_module_byte (board, addr, mc_mtaasic_rev));

		/* The following combinations are illegal: It should theoretically
		   work, but timing problems make the bus HANG. */

		if (mod_compat_type (type) != board->ta_type) {
			printk (KERN_ERR "sx: This is an invalid configuration.\n"
			        "Don't mix TA/MTA/SXDC on the same hostadapter.\n");
			chans=0;
			break;
		}
		if ((IS_EISA_BOARD(board) || 
		     IS_SI_BOARD(board)) && (mod_compat_type(type) == 4)) {
			printk (KERN_ERR "sx: This is an invalid configuration.\n"
			        "Don't use SXDCs on an SI/XIO adapter.\n");
			chans=0;
			break;
		}
#if 0 /* Problem fixed: firmware 3.05 */
		if (IS_SX_BOARD(board) && (type == TA8)) {
			/* There are some issues with the firmware and the DCD/RTS
			   lines. It might work if you tie them together or something.
			   It might also work if you get a newer sx_firmware.	Therefore
			   this is just a warning. */
			printk (KERN_WARNING "sx: The SX host doesn't work too well "
			        "with the TA8 adapters.\nSpecialix is working on it.\n");
		}
#endif
	}

	if (chans) {
		/* board->flags |= SX_BOARD_PRESENT; */
		if(board->irq > 0) {
			/* fixed irq, probably PCI */
			if(sx_irqmask & (1 << board->irq)) { /* may we use this irq? */
				if(request_irq(board->irq, sx_interrupt, SA_SHIRQ | SA_INTERRUPT, "sx", board)) {
					printk(KERN_ERR "sx: Cannot allocate irq %d.\n", board->irq);
					board->irq = 0;
				}
			} else
				board->irq = 0;
		} else if(board->irq < 0 && sx_irqmask) {
			/* auto-allocate irq */
			int irqnr;
			int irqmask = sx_irqmask & (IS_SX_BOARD(board) ? SX_ISA_IRQ_MASK : SI2_ISA_IRQ_MASK);
			for(irqnr = 15; irqnr > 0; irqnr--)
				if(irqmask & (1 << irqnr))
					if(! request_irq(irqnr, sx_interrupt, SA_SHIRQ | SA_INTERRUPT, "sx", board))
						break;
			if(! irqnr)
				printk(KERN_ERR "sx: Cannot allocate IRQ.\n");
			board->irq = irqnr;
		} else
			board->irq = 0;

		if (board->irq) {
			/* Found a valid interrupt, start up interrupts! */
			sx_dprintk (SX_DEBUG_INIT, "Using irq %d.\n", board->irq);
			sx_start_interrupts (board);
			board->poll = sx_slowpoll;
			board->flags |= SX_IRQ_ALLOCATED;
		} else {
			/* no irq: setup board for polled operation */
			board->poll = sx_poll;
			sx_dprintk (SX_DEBUG_INIT, "Using poll-interval %d.\n", board->poll);
		}

		/* The timer should be initialized anyway: That way we can safely
			 del_timer it when the module is unloaded. */
		init_timer (&board->timer);

		if (board->poll) {
			board->timer.data = (unsigned long) board;
			board->timer.function = sx_pollfunc;
			board->timer.expires = jiffies + board->poll;
			add_timer (&board->timer);
		}
	} else {
		board->irq = 0;
	}

	board->nports = chans;
	sx_dprintk (SX_DEBUG_INIT, "returning %d ports.", board->nports);

	func_exit();
	return chans;
}


static void printheader(void)
{
	static int header_printed;

	if (!header_printed) {
		printk (KERN_INFO "Specialix SX driver "
		        "(C) 1998/1999 R.E.Wolff@BitWizard.nl \n");
		printk (KERN_INFO "sx: version %s\n", RCS_ID);
		header_printed = 1;
	}
}


static int probe_sx (struct sx_board *board)
{
	struct vpd_prom vpdp;
	char *p;
	int i;

	func_enter();

	if (!IS_CF_BOARD (board)) {    
		sx_dprintk (SX_DEBUG_PROBE, "Going to verify vpd prom at %p.\n", 
		            board->base + SX_VPD_ROM);

		if (sx_debug & SX_DEBUG_PROBE)
			my_hd_io(board->base + SX_VPD_ROM, 0x40);

		p = (char *) &vpdp;
		for (i=0;i< sizeof (struct vpd_prom);i++)
			*p++ = read_sx_byte (board, SX_VPD_ROM + i*2);

		if (sx_debug & SX_DEBUG_PROBE)
			my_hd (&vpdp, 0x20);

		sx_dprintk (SX_DEBUG_PROBE, "checking identifier...\n");

		if (strncmp (vpdp.identifier, SX_VPD_IDENT_STRING, 16) != 0) {
			sx_dprintk (SX_DEBUG_PROBE, "Got non-SX identifier: '%s'\n", 
			            vpdp.identifier); 
			return 0;
		}
	}

	printheader ();

	if (!IS_CF_BOARD (board)) {
		printk (KERN_DEBUG "sx: Found an SX board at %lx\n", board->hw_base);
		printk (KERN_DEBUG "sx: hw_rev: %d, assembly level: %d, uniq ID:%08x, ", 
		        vpdp.hwrev, vpdp.hwass, vpdp.uniqid);
		printk (           "Manufactured: %d/%d\n", 
		        1970 + vpdp.myear, vpdp.mweek);


		if ((((vpdp.uniqid >> 24) & SX_UNIQUEID_MASK) != SX_PCI_UNIQUEID1) &&
		    (((vpdp.uniqid >> 24) & SX_UNIQUEID_MASK) != SX_ISA_UNIQUEID1)) {
			/* This might be a bit harsh. This was the primary reason the
			   SX/ISA card didn't work at first... */
			printk (KERN_ERR "sx: Hmm. Not an SX/PCI or SX/ISA card. Sorry: giving up.\n");
			return (0);
		}

		if (((vpdp.uniqid >> 24) & SX_UNIQUEID_MASK) == SX_ISA_UNIQUEID1) {
			if (((unsigned long)board->hw_base) & 0x8000) {
				printk (KERN_WARNING "sx: Warning: There may be hardware problems with the card at %lx.\n", board->hw_base);
				printk (KERN_WARNING "sx: Read sx.txt for more info.\n");
			}
		}
	}

	board->nports = -1;

	/* This resets the processor, and keeps it off the bus. */
	if (!sx_reset (board)) 
		return 0;
	sx_dprintk (SX_DEBUG_INIT, "reset the board...\n");

	board->flags |= SX_BOARD_PRESENT;

	func_exit();
	return 1;
}



/* Specialix probes for this card at 32k increments from 640k to 16M.
   I consider machines with less than 16M unlikely nowadays, so I'm
   not probing above 1Mb. Also, 0xa0000, 0xb0000, are taken by the VGA
   card. 0xe0000 and 0xf0000 are taken by the BIOS. That only leaves 
   0xc0000, 0xc8000, 0xd0000 and 0xd8000 . */

static int probe_si (struct sx_board *board)
{
	int i;

	func_enter();
	sx_dprintk (SX_DEBUG_PROBE, "Going to verify SI signature hw %lx at %p.\n", board->hw_base,
	            board->base + SI2_ISA_ID_BASE);

	if (sx_debug & SX_DEBUG_PROBE)
		my_hd_io(board->base + SI2_ISA_ID_BASE, 0x8);

	if (!IS_EISA_BOARD(board)) {
	  if( IS_SI1_BOARD(board) ) 
	    {
		for (i=0;i<8;i++) {
		  write_sx_byte (board, SI2_ISA_ID_BASE+7-i,i); 

		}
	    }
		for (i=0;i<8;i++) {
			if ((read_sx_byte (board, SI2_ISA_ID_BASE+7-i) & 7) != i) {
				func_exit ();
				return 0;
			}
		}
	}

	/* Now we're pretty much convinced that there is an SI board here, 
	   but to prevent trouble, we'd better double check that we don't
	   have an SI1 board when we're probing for an SI2 board.... */

	write_sx_byte (board, SI2_ISA_ID_BASE,0x10); 
	if ( IS_SI1_BOARD(board)) {
		/* This should be an SI1 board, which has this
		   location writable... */
		if (read_sx_byte (board, SI2_ISA_ID_BASE) != 0x10) {
			func_exit ();
			return 0; 
		}
	} else {
		/* This should be an SI2 board, which has the bottom
		   3 bits non-writable... */
		if (read_sx_byte (board, SI2_ISA_ID_BASE) == 0x10) {
			func_exit ();
			return 0; 
		}
	}

	/* Now we're pretty much convinced that there is an SI board here, 
	   but to prevent trouble, we'd better double check that we don't
	   have an SI1 board when we're probing for an SI2 board.... */

	write_sx_byte (board, SI2_ISA_ID_BASE,0x10); 
	if ( IS_SI1_BOARD(board)) {
		/* This should be an SI1 board, which has this
		   location writable... */
		if (read_sx_byte (board, SI2_ISA_ID_BASE) != 0x10) {
			func_exit();
			return 0; 
		}
	} else {
		/* This should be an SI2 board, which has the bottom
		   3 bits non-writable... */
		if (read_sx_byte (board, SI2_ISA_ID_BASE) == 0x10) {
			func_exit ();
			return 0; 
		}
	}

	printheader ();

	printk (KERN_DEBUG "sx: Found an SI board at %lx\n", board->hw_base);
	/* Compared to the SX boards, it is a complete guess as to what
		 this card is up to... */

	board->nports = -1;

	/* This resets the processor, and keeps it off the bus. */
	if (!sx_reset (board)) 
		return 0;
	sx_dprintk (SX_DEBUG_INIT, "reset the board...\n");

	board->flags |= SX_BOARD_PRESENT;

	func_exit();
	return 1;
}

static struct tty_operations sx_ops = {
	.break_ctl = sx_break,
	.open	= sx_open,
	.close = gs_close,
	.write = gs_write,
	.put_char = gs_put_char,
	.flush_chars = gs_flush_chars,
	.write_room = gs_write_room,
	.chars_in_buffer = gs_chars_in_buffer,
	.flush_buffer = gs_flush_buffer,
	.ioctl = sx_ioctl,
	.throttle = sx_throttle,
	.unthrottle = sx_unthrottle,
	.set_termios = gs_set_termios,
	.stop = gs_stop,
	.start = gs_start,
	.hangup = gs_hangup,
	.tiocmget = sx_tiocmget,
	.tiocmset = sx_tiocmset,
};

static int sx_init_drivers(void)
{
	int error;

	func_enter();

	sx_driver = alloc_tty_driver(sx_nports);
	if (!sx_driver)
		return 1;
	sx_driver->owner = THIS_MODULE;
	sx_driver->driver_name = "specialix_sx";
	sx_driver->name = "ttyX";
	sx_driver->major = SX_NORMAL_MAJOR;
	sx_driver->type = TTY_DRIVER_TYPE_SERIAL;
	sx_driver->subtype = SERIAL_TYPE_NORMAL;
	sx_driver->init_termios = tty_std_termios;
	sx_driver->init_termios.c_cflag =
	  B9600 | CS8 | CREAD | HUPCL | CLOCAL;
	sx_driver->flags = TTY_DRIVER_REAL_RAW;
	tty_set_operations(sx_driver, &sx_ops);

	if ((error = tty_register_driver(sx_driver))) {
		put_tty_driver(sx_driver);
		printk(KERN_ERR "sx: Couldn't register sx driver, error = %d\n",
		       error);
		return 1;
	}
	func_exit();
	return 0;
}


static void * ckmalloc (int size)
{
	void *p;

	p = kmalloc(size, GFP_KERNEL);
	if (p) 
		memset(p, 0, size);
	return p;
}


static int sx_init_portstructs (int nboards, int nports)
{
	struct sx_board *board;
	struct sx_port *port;
	int i, j;
	int addr, chans;
	int portno;

	func_enter();

	/* Many drivers statically allocate the maximum number of ports
	   There is no reason not to allocate them dynamically. Is there? -- REW */
	sx_ports          = ckmalloc(nports * sizeof (struct sx_port));
	if (!sx_ports)
		return -ENOMEM;

	port = sx_ports;
	for (i = 0; i < nboards; i++) {
		board = &boards[i];
		board->ports = port;
		for (j=0; j < boards[i].nports;j++) {
			sx_dprintk (SX_DEBUG_INIT, "initing port %d\n", j);
			port->gs.magic = SX_MAGIC;
			port->gs.close_delay = HZ/2;
			port->gs.closing_wait = 30 * HZ;
			port->board = board;
			port->gs.rd = &sx_real_driver;
#ifdef NEW_WRITE_LOCKING
			port->gs.port_write_sem = MUTEX;
#endif
			port->gs.driver_lock = SPIN_LOCK_UNLOCKED;
			/*
			 * Initializing wait queue
			 */
			init_waitqueue_head(&port->gs.open_wait);
			init_waitqueue_head(&port->gs.close_wait); 		
			
			port++;
		}
	}

	port = sx_ports;
	portno = 0;
	for (i = 0; i < nboards; i++) {
		board = &boards[i];
		board->port_base = portno;
		/* Possibly the configuration was rejected. */
		sx_dprintk (SX_DEBUG_PROBE, "Board has %d channels\n", board->nports);
		if (board->nports <= 0) continue;
		/* XXX byteorder ?? */
		for (addr = 0x80;addr != 0;addr = read_sx_word (board, addr) & 0x7fff) {
			chans = sx_read_module_byte (board, addr, mc_type); 
			sx_dprintk (SX_DEBUG_PROBE, "Module at %x: %d channels\n", addr, chans);
			sx_dprintk (SX_DEBUG_PROBE, "Port at");
			for (j=0;j<chans;j++) {
				/* The "sx-way" is the way it SHOULD be done. That way in the 
				   future, the firmware may for example pack the structures a bit
				   more efficient. Neil tells me it isn't going to happen anytime
				   soon though. */
				if (IS_SX_BOARD(board))
					port->ch_base = sx_read_module_word (board, addr+j*2, mc_chan_pointer);
				else
					port->ch_base = addr + 0x100 + 0x300*j;

				sx_dprintk (SX_DEBUG_PROBE, " %x", port->ch_base);
				port->line = portno++;
				port++;
			}
			sx_dprintk (SX_DEBUG_PROBE, "\n");
		}
		/* This has to be done earlier. */
		/* board->flags |= SX_BOARD_INITIALIZED; */
	}

	func_exit();
	return 0;
}

static void __exit sx_release_drivers(void)
{
	func_enter();
	tty_unregister_driver(sx_driver);
	put_tty_driver(sx_driver);
	func_exit();
}

#ifdef CONFIG_PCI
 /******************************************************** 
 * Setting bit 17 in the CNTRL register of the PLX 9050  * 
 * chip forces a retry on writes while a read is pending.*
 * This is to prevent the card locking up on Intel Xeon  *
 * multiprocessor systems with the NX chipset.    -- NV  *
 ********************************************************/

/* Newer cards are produced with this bit set from the configuration
   EEprom.  As the bit is read/write for the CPU, we can fix it here,
   if we detect that it isn't set correctly. -- REW */

static void fix_sx_pci (struct pci_dev *pdev, struct sx_board *board)
{
	unsigned int hwbase;
	void __iomem *rebase;
	unsigned int t;

#define CNTRL_REG_OFFSET        0x50
#define CNTRL_REG_GOODVALUE     0x18260000

	pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase);
	hwbase &= PCI_BASE_ADDRESS_MEM_MASK;
	rebase = ioremap(hwbase, 0x80);
	t = readl (rebase + CNTRL_REG_OFFSET);
	if (t != CNTRL_REG_GOODVALUE) {
		printk (KERN_DEBUG "sx: performing cntrl reg fix: %08x -> %08x\n", t, CNTRL_REG_GOODVALUE); 
		writel (CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET);
	}
	iounmap(rebase);
}
#endif


static int __init sx_init(void) 
{
	int i;
	int found = 0;
	int eisa_slot;
	struct sx_board *board;

#ifdef CONFIG_PCI
	struct pci_dev *pdev = NULL;
	unsigned int tint;
	unsigned short tshort;
#endif

	func_enter();
	sx_dprintk (SX_DEBUG_INIT, "Initing sx module... (sx_debug=%d)\n", sx_debug);
	if (abs ((long) (&sx_debug) - sx_debug) < 0x10000) {
		printk (KERN_WARNING "sx: sx_debug is an address, instead of a value. "
		        "Assuming -1.\n");
		printk ("(%p)\n", &sx_debug);
		sx_debug=-1;
	}

	if (misc_register(&sx_fw_device) < 0) {
		printk(KERN_ERR "SX: Unable to register firmware loader driver.\n");
		return -EIO;
	}

#ifdef CONFIG_PCI
	while ((pdev = pci_find_device (PCI_VENDOR_ID_SPECIALIX, 
					PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, 
					      pdev))) {
		if (pci_enable_device(pdev))
			continue;

		/* Specialix has a whole bunch of cards with
		   0x2000 as the device ID. They say its because
		   the standard requires it. Stupid standard. */
		/* It seems that reading a word doesn't work reliably on 2.0.
		   Also, reading a non-aligned dword doesn't work. So we read the
		   whole dword at 0x2c and extract the word at 0x2e (SUBSYSTEM_ID)
		   ourselves */
		/* I don't know why the define doesn't work, constant 0x2c does --REW */ 
		pci_read_config_dword (pdev, 0x2c, &tint);
		tshort = (tint >> 16) & 0xffff;
		sx_dprintk (SX_DEBUG_PROBE, "Got a specialix card: %x.\n", tint);
		/* sx_dprintk (SX_DEBUG_PROBE, "pdev = %d/%d	(%x)\n", pdev, tint); */ 
		if ((tshort != 0x0200) && (tshort != 0x0300)) {
			sx_dprintk (SX_DEBUG_PROBE, "But it's not an SX card (%d)...\n", 
				    tshort);
			continue;
		}
		board = &boards[found];

		board->flags &= ~SX_BOARD_TYPE;
		board->flags |= (tshort == 0x200)?SX_PCI_BOARD:
						  SX_CFPCI_BOARD;

		/* CF boards use base address 3.... */
		if (IS_CF_BOARD (board))
			board->hw_base = pci_resource_start (pdev, 3);
		else
			board->hw_base = pci_resource_start (pdev, 2);
		board->base2 = 
		board->base = ioremap(board->hw_base, WINDOW_LEN (board));
		if (!board->base) {
			printk(KERN_ERR "ioremap failed\n");
			/* XXX handle error */
		}

		/* Most of the stuff on the CF board is offset by
		   0x18000 ....  */
		if (IS_CF_BOARD (board)) board->base += 0x18000;

		board->irq = pdev->irq;

		sx_dprintk (SX_DEBUG_PROBE, "Got a specialix card: %x/%p(%d) %x.\n", 
			    tint, boards[found].base, board->irq, board->flags);

		if (probe_sx (board)) {
			found++;
			fix_sx_pci (pdev, board);
		} else 
			iounmap(board->base2);
	}
#endif

	for (i=0;i<NR_SX_ADDRS;i++) {
		board = &boards[found];
		board->hw_base = sx_probe_addrs[i];
		board->base2 =
		board->base = ioremap(board->hw_base, SX_WINDOW_LEN);
		board->flags &= ~SX_BOARD_TYPE;
		board->flags |=	SX_ISA_BOARD;
		board->irq = sx_irqmask?-1:0;

		if (probe_sx (board)) {
			found++;
		} else {
			iounmap(board->base);
		}
	}

	for (i=0;i<NR_SI_ADDRS;i++) {
		board = &boards[found];
		board->hw_base = si_probe_addrs[i];
		board->base2 =
		board->base = ioremap(board->hw_base, SI2_ISA_WINDOW_LEN);
		board->flags &= ~SX_BOARD_TYPE;
		board->flags |=  SI_ISA_BOARD;
		board->irq = sx_irqmask ?-1:0;

		if (probe_si (board)) {
			found++;
		} else {
			iounmap (board->base);
		}
	}
	for (i=0;i<NR_SI1_ADDRS;i++) {
		board = &boards[found];
		board->hw_base = si1_probe_addrs[i];
		board->base2 =
		board->base = ioremap(board->hw_base, SI1_ISA_WINDOW_LEN);
		board->flags &= ~SX_BOARD_TYPE;
		board->flags |=  SI1_ISA_BOARD;
		board->irq = sx_irqmask ?-1:0;

		if (probe_si (board)) {
			found++;
		} else {
			iounmap (board->base);
		}
	}

        sx_dprintk(SX_DEBUG_PROBE, "Probing for EISA cards\n");
        for(eisa_slot=0x1000; eisa_slot<0x10000; eisa_slot+=0x1000)
        {
                if((inb(eisa_slot+0xc80)==0x4d) &&
                   (inb(eisa_slot+0xc81)==0x98))
                {
			sx_dprintk(SX_DEBUG_PROBE, "%s : Signature found in EISA slot %d, Product %d Rev %d\n",
			                        "XIO", (eisa_slot>>12), inb(eisa_slot+0xc82), inb(eisa_slot+0xc83));

			board = &boards[found];
			board->eisa_base = eisa_slot;
			board->flags &= ~SX_BOARD_TYPE;
			board->flags |= SI_EISA_BOARD;

			board->hw_base = (((inb(0xc01+eisa_slot) << 8) + inb(0xc00+eisa_slot)) << 16);
			board->base2 =
			board->base = ioremap(board->hw_base, SI2_EISA_WINDOW_LEN);

			sx_dprintk(SX_DEBUG_PROBE, "IO hw_base address: %lx\n", board->hw_base);
			sx_dprintk(SX_DEBUG_PROBE, "base: %p\n", board->base);
			board->irq = inb(board->eisa_base+0xc02)>>4; 
			sx_dprintk(SX_DEBUG_PROBE, "IRQ: %d\n", board->irq);
			
			probe_si(board);

			found++;
		}
	}
	if (found) {
		printk (KERN_INFO "sx: total of %d boards detected.\n", found);
	} else {
		misc_deregister(&sx_fw_device);
	}

	func_exit();
	return found?0:-EIO;
}


static void __exit sx_exit (void)
{
	int i; 
	struct sx_board *board;

	func_enter();
	for (i = 0; i < SX_NBOARDS; i++) {
		board = &boards[i];
		if (board->flags & SX_BOARD_INITIALIZED) {
			sx_dprintk (SX_DEBUG_CLEANUP, "Cleaning up board at %p\n", board->base);
			/* The board should stop messing with us.
			   (actually I mean the interrupt) */
			sx_reset (board);
			if ((board->irq) && (board->flags & SX_IRQ_ALLOCATED))
				free_irq (board->irq, board);

			/* It is safe/allowed to del_timer a non-active timer */
			del_timer (& board->timer);
			iounmap(board->base);
		}
	}
	if (misc_deregister(&sx_fw_device) < 0) {
		printk (KERN_INFO "sx: couldn't deregister firmware loader devic\n");
	}
	sx_dprintk (SX_DEBUG_CLEANUP, "Cleaning up drivers (%d)\n", sx_initialized);
	if (sx_initialized)
		sx_release_drivers ();

	kfree (sx_ports);
	func_exit();
}

module_init(sx_init);
module_exit(sx_exit);


