/* fd_mcs.c -- Future Domain MCS 600/700 (or IBM OEM) driver
*
* FutureDomain MCS-600/700 v0.2 03/11/1998 by ZP Gu (zpg@castle.net)
*
* This driver is cloned from fdomain.* to specifically support
* the Future Domain MCS 600/700 MCA SCSI adapters. Some PS/2s
* also equipped with IBM Fast SCSI Adapter/A which is an OEM
* of MCS 700.
*
* This driver also supports Reply SB16/SCSI card (the SCSI part).
*
* What makes this driver different is that this driver is MCA only
* and it supports multiple adapters in the same system, IRQ
* sharing, some driver statistics, and maps highest SCSI id to sda.
* All cards are auto-detected.
*
* Assumptions: TMC-1800/18C50/18C30, BIOS >= 3.4
*
* LILO command-line options:
* fd_mcs=<FIFO_COUNT>[,<FIFO_SIZE>]
*
* ********************************************************
* Please see Copyrights/Comments in fdomain.* for credits.
* Following is from fdomain.c for acknowledgement:
*
* Created: Sun May 3 18:53:19 1992 by faith@cs.unc.edu
* Revised: Wed Oct 2 11:10:55 1996 by r.faith@ieee.org
* Author: Rickard E. Faith, faith@cs.unc.edu
* Copyright 1992, 1993, 1994, 1995, 1996 Rickard E. Faith
*
* $Id: fdomain.c,v 5.45 1996/10/02 15:13:06 root Exp $
* 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, 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.
**************************************************************************
NOTES ON USER DEFINABLE OPTIONS:
DEBUG: This turns on the printing of various debug information.
ENABLE_PARITY: This turns on SCSI parity checking. With the current
driver, all attached devices must support SCSI parity. If none of your
devices support parity, then you can probably get the driver to work by
turning this option off. I have no way of testing this, however, and it
would appear that no one ever uses this option.
FIFO_COUNT: The host adapter has an 8K cache (host adapters based on the
18C30 chip have a 2k cache). When this many 512 byte blocks are filled by
the SCSI device, an interrupt will be raised. Therefore, this could be as
low as 0, or as high as 16. Note, however, that values which are too high
or too low seem to prevent any interrupts from occurring, and thereby lock
up the machine. I have found that 2 is a good number, but throughput may
be increased by changing this value to values which are close to 2.
Please let me know if you try any different values.
[*****Now a runtime option*****]
RESELECTION: This is no longer an option, since I gave up trying to
implement it in version 4.x of this driver. It did not improve
performance at all and made the driver unstable (because I never found one
of the two race conditions which were introduced by the multiple
outstanding command code). The instability seems a very high price to pay
just so that you don't have to wait for the tape to rewind. If you want
this feature implemented, send me patches. I'll be happy to send a copy
of my (broken) driver to anyone who would like to see a copy.
**************************************************************************/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/blkdev.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/ioport.h>
#include <linux/proc_fs.h>
#include <linux/delay.h>
#include <linux/mca.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
#include <scsi/scsicam.h>
#include <linux/mca-legacy.h>
#include <asm/io.h>
#include <asm/system.h>
#include "scsi.h"
#include <scsi/scsi_host.h>
#define DRIVER_VERSION "v0.2 by ZP Gu<zpg@castle.net>"
/* START OF USER DEFINABLE OPTIONS */
#define DEBUG 0 /* Enable debugging output */
#define ENABLE_PARITY 1 /* Enable SCSI Parity */
/* END OF USER DEFINABLE OPTIONS */
#if DEBUG
#define EVERY_ACCESS 0 /* Write a line on every scsi access */
#define ERRORS_ONLY 1 /* Only write a line if there is an error */
#define DEBUG_MESSAGES 1 /* Debug MESSAGE IN phase */
#define DEBUG_ABORT 1 /* Debug abort() routine */
#define DEBUG_RESET 1 /* Debug reset() routine */
#define DEBUG_RACE 1 /* Debug interrupt-driven race condition */
#else
#define EVERY_ACCESS 0 /* LEAVE THESE ALONE--CHANGE THE ONES ABOVE */
#define ERRORS_ONLY 0
#define DEBUG_MESSAGES 0
#define DEBUG_ABORT 0
#define DEBUG_RESET 0
#define DEBUG_RACE 0
#endif
/* Errors are reported on the line, so we don't need to report them again */
#if EVERY_ACCESS
#undef ERRORS_ONLY
#define ERRORS_ONLY 0
#endif
#if ENABLE_PARITY
#define PARITY_MASK 0x08
#else
#define PARITY_MASK 0x00
#endif
enum chip_type {
unknown = 0x00,
tmc1800 = 0x01,
tmc18c50 = 0x02,
tmc18c30 =