xref: /openbmc/linux/drivers/scsi/ncr53c8xx.h (revision b0dc1db15225d5801bf3105966c9ce12c5142013)
11da177e4SLinus Torvalds /******************************************************************************
21da177e4SLinus Torvalds **  Device driver for the PCI-SCSI NCR538XX controller family.
31da177e4SLinus Torvalds **
41da177e4SLinus Torvalds **  Copyright (C) 1994  Wolfgang Stanglmeier
519c65091SMatthew Wilcox **  Copyright (C) 1998-2001  Gerard Roudier <groudier@free.fr>
61da177e4SLinus Torvalds **
71da177e4SLinus Torvalds **  This program is free software; you can redistribute it and/or modify
81da177e4SLinus Torvalds **  it under the terms of the GNU General Public License as published by
91da177e4SLinus Torvalds **  the Free Software Foundation; either version 2 of the License, or
101da177e4SLinus Torvalds **  (at your option) any later version.
111da177e4SLinus Torvalds **
121da177e4SLinus Torvalds **  This program is distributed in the hope that it will be useful,
131da177e4SLinus Torvalds **  but WITHOUT ANY WARRANTY; without even the implied warranty of
141da177e4SLinus Torvalds **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
151da177e4SLinus Torvalds **  GNU General Public License for more details.
161da177e4SLinus Torvalds **
171da177e4SLinus Torvalds **  You should have received a copy of the GNU General Public License
181da177e4SLinus Torvalds **  along with this program; if not, write to the Free Software
191da177e4SLinus Torvalds **  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
201da177e4SLinus Torvalds **
211da177e4SLinus Torvalds **-----------------------------------------------------------------------------
221da177e4SLinus Torvalds **
231da177e4SLinus Torvalds **  This driver has been ported to Linux from the FreeBSD NCR53C8XX driver
241da177e4SLinus Torvalds **  and is currently maintained by
251da177e4SLinus Torvalds **
261da177e4SLinus Torvalds **          Gerard Roudier              <groudier@free.fr>
271da177e4SLinus Torvalds **
281da177e4SLinus Torvalds **  Being given that this driver originates from the FreeBSD version, and
291da177e4SLinus Torvalds **  in order to keep synergy on both, any suggested enhancements and corrections
301da177e4SLinus Torvalds **  received on Linux are automatically a potential candidate for the FreeBSD
311da177e4SLinus Torvalds **  version.
321da177e4SLinus Torvalds **
331da177e4SLinus Torvalds **  The original driver has been written for 386bsd and FreeBSD by
341da177e4SLinus Torvalds **          Wolfgang Stanglmeier        <wolf@cologne.de>
351da177e4SLinus Torvalds **          Stefan Esser                <se@mi.Uni-Koeln.de>
361da177e4SLinus Torvalds **
371da177e4SLinus Torvalds **  And has been ported to NetBSD by
381da177e4SLinus Torvalds **          Charles M. Hannum           <mycroft@gnu.ai.mit.edu>
391da177e4SLinus Torvalds **
4019c65091SMatthew Wilcox **  NVRAM detection and reading.
4119c65091SMatthew Wilcox **    Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
4219c65091SMatthew Wilcox **
4319c65091SMatthew Wilcox **  Added support for MIPS big endian systems.
4419c65091SMatthew Wilcox **    Carsten Langgaard, carstenl@mips.com
4519c65091SMatthew Wilcox **    Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
4619c65091SMatthew Wilcox **
4719c65091SMatthew Wilcox **  Added support for HP PARISC big endian systems.
4819c65091SMatthew Wilcox **    Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
4919c65091SMatthew Wilcox **
501da177e4SLinus Torvalds *******************************************************************************
511da177e4SLinus Torvalds */
521da177e4SLinus Torvalds 
531da177e4SLinus Torvalds #ifndef NCR53C8XX_H
541da177e4SLinus Torvalds #define NCR53C8XX_H
551da177e4SLinus Torvalds 
5619c65091SMatthew Wilcox #include <linux/config.h>
571da177e4SLinus Torvalds #include <scsi/scsi_host.h>
581da177e4SLinus Torvalds 
59*b0dc1db1SMatthew Wilcox #include <linux/config.h>
60*b0dc1db1SMatthew Wilcox 
6119c65091SMatthew Wilcox /*
62*b0dc1db1SMatthew Wilcox **	If you want a driver as small as possible, donnot define the
6319c65091SMatthew Wilcox **	following options.
6419c65091SMatthew Wilcox */
6519c65091SMatthew Wilcox #define SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
6619c65091SMatthew Wilcox #define SCSI_NCR_DEBUG_INFO_SUPPORT
6719c65091SMatthew Wilcox 
6819c65091SMatthew Wilcox /*
6919c65091SMatthew Wilcox **	To disable integrity checking, do not define the
7019c65091SMatthew Wilcox **	following option.
7119c65091SMatthew Wilcox */
7219c65091SMatthew Wilcox #ifdef	CONFIG_SCSI_NCR53C8XX_INTEGRITY_CHECK
7319c65091SMatthew Wilcox #	define SCSI_NCR_ENABLE_INTEGRITY_CHECK
7419c65091SMatthew Wilcox #endif
7519c65091SMatthew Wilcox 
7619c65091SMatthew Wilcox /* ---------------------------------------------------------------------
7719c65091SMatthew Wilcox ** Take into account kernel configured parameters.
7819c65091SMatthew Wilcox ** Most of these options can be overridden at startup by a command line.
7919c65091SMatthew Wilcox ** ---------------------------------------------------------------------
8019c65091SMatthew Wilcox */
8119c65091SMatthew Wilcox 
8219c65091SMatthew Wilcox /*
8319c65091SMatthew Wilcox  * For Ultra2 and Ultra3 SCSI support option, use special features.
8419c65091SMatthew Wilcox  *
8519c65091SMatthew Wilcox  * Value (default) means:
8619c65091SMatthew Wilcox  *	bit 0 : all features enabled, except:
8719c65091SMatthew Wilcox  *		bit 1 : PCI Write And Invalidate.
8819c65091SMatthew Wilcox  *		bit 2 : Data Phase Mismatch handling from SCRIPTS.
8919c65091SMatthew Wilcox  *
9019c65091SMatthew Wilcox  * Use boot options ncr53c8xx=specf:1 if you want all chip features to be
9119c65091SMatthew Wilcox  * enabled by the driver.
9219c65091SMatthew Wilcox  */
9319c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_SPECIAL_FEATURES		(3)
9419c65091SMatthew Wilcox 
9519c65091SMatthew Wilcox #define SCSI_NCR_MAX_SYNC			(80)
9619c65091SMatthew Wilcox 
9719c65091SMatthew Wilcox /*
9819c65091SMatthew Wilcox  * Allow tags from 2 to 256, default 8
9919c65091SMatthew Wilcox  */
10019c65091SMatthew Wilcox #ifdef	CONFIG_SCSI_NCR53C8XX_MAX_TAGS
10119c65091SMatthew Wilcox #if	CONFIG_SCSI_NCR53C8XX_MAX_TAGS < 2
10219c65091SMatthew Wilcox #define SCSI_NCR_MAX_TAGS	(2)
10319c65091SMatthew Wilcox #elif	CONFIG_SCSI_NCR53C8XX_MAX_TAGS > 256
10419c65091SMatthew Wilcox #define SCSI_NCR_MAX_TAGS	(256)
10519c65091SMatthew Wilcox #else
10619c65091SMatthew Wilcox #define	SCSI_NCR_MAX_TAGS	CONFIG_SCSI_NCR53C8XX_MAX_TAGS
10719c65091SMatthew Wilcox #endif
10819c65091SMatthew Wilcox #else
10919c65091SMatthew Wilcox #define SCSI_NCR_MAX_TAGS	(8)
11019c65091SMatthew Wilcox #endif
11119c65091SMatthew Wilcox 
11219c65091SMatthew Wilcox /*
11319c65091SMatthew Wilcox  * Allow tagged command queuing support if configured with default number
11419c65091SMatthew Wilcox  * of tags set to max (see above).
11519c65091SMatthew Wilcox  */
11619c65091SMatthew Wilcox #ifdef	CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS
11719c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_DEFAULT_TAGS	CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS
11819c65091SMatthew Wilcox #elif	defined CONFIG_SCSI_NCR53C8XX_TAGGED_QUEUE
11919c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_DEFAULT_TAGS	SCSI_NCR_MAX_TAGS
12019c65091SMatthew Wilcox #else
12119c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_DEFAULT_TAGS	(0)
12219c65091SMatthew Wilcox #endif
12319c65091SMatthew Wilcox 
12419c65091SMatthew Wilcox /*
12519c65091SMatthew Wilcox  * Immediate arbitration
12619c65091SMatthew Wilcox  */
12719c65091SMatthew Wilcox #if defined(CONFIG_SCSI_NCR53C8XX_IARB)
12819c65091SMatthew Wilcox #define SCSI_NCR_IARB_SUPPORT
12919c65091SMatthew Wilcox #endif
13019c65091SMatthew Wilcox 
13119c65091SMatthew Wilcox /*
13219c65091SMatthew Wilcox  * Sync transfer frequency at startup.
13319c65091SMatthew Wilcox  * Allow from 5Mhz to 80Mhz default 20 Mhz.
13419c65091SMatthew Wilcox  */
13519c65091SMatthew Wilcox #ifndef	CONFIG_SCSI_NCR53C8XX_SYNC
13619c65091SMatthew Wilcox #define	CONFIG_SCSI_NCR53C8XX_SYNC	(20)
13719c65091SMatthew Wilcox #elif	CONFIG_SCSI_NCR53C8XX_SYNC > SCSI_NCR_MAX_SYNC
13819c65091SMatthew Wilcox #undef	CONFIG_SCSI_NCR53C8XX_SYNC
13919c65091SMatthew Wilcox #define	CONFIG_SCSI_NCR53C8XX_SYNC	SCSI_NCR_MAX_SYNC
14019c65091SMatthew Wilcox #endif
14119c65091SMatthew Wilcox 
14219c65091SMatthew Wilcox #if	CONFIG_SCSI_NCR53C8XX_SYNC == 0
14319c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_DEFAULT_SYNC	(255)
14419c65091SMatthew Wilcox #elif	CONFIG_SCSI_NCR53C8XX_SYNC <= 5
14519c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_DEFAULT_SYNC	(50)
14619c65091SMatthew Wilcox #elif	CONFIG_SCSI_NCR53C8XX_SYNC <= 20
14719c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_DEFAULT_SYNC	(250/(CONFIG_SCSI_NCR53C8XX_SYNC))
14819c65091SMatthew Wilcox #elif	CONFIG_SCSI_NCR53C8XX_SYNC <= 33
14919c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_DEFAULT_SYNC	(11)
15019c65091SMatthew Wilcox #elif	CONFIG_SCSI_NCR53C8XX_SYNC <= 40
15119c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_DEFAULT_SYNC	(10)
15219c65091SMatthew Wilcox #else
15319c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_DEFAULT_SYNC 	(9)
15419c65091SMatthew Wilcox #endif
15519c65091SMatthew Wilcox 
15619c65091SMatthew Wilcox /*
15719c65091SMatthew Wilcox  * Disallow disconnections at boot-up
15819c65091SMatthew Wilcox  */
15919c65091SMatthew Wilcox #ifdef CONFIG_SCSI_NCR53C8XX_NO_DISCONNECT
16019c65091SMatthew Wilcox #define SCSI_NCR_SETUP_DISCONNECTION	(0)
16119c65091SMatthew Wilcox #else
16219c65091SMatthew Wilcox #define SCSI_NCR_SETUP_DISCONNECTION	(1)
16319c65091SMatthew Wilcox #endif
16419c65091SMatthew Wilcox 
16519c65091SMatthew Wilcox /*
16619c65091SMatthew Wilcox  * Force synchronous negotiation for all targets
16719c65091SMatthew Wilcox  */
16819c65091SMatthew Wilcox #ifdef CONFIG_SCSI_NCR53C8XX_FORCE_SYNC_NEGO
16919c65091SMatthew Wilcox #define SCSI_NCR_SETUP_FORCE_SYNC_NEGO	(1)
17019c65091SMatthew Wilcox #else
17119c65091SMatthew Wilcox #define SCSI_NCR_SETUP_FORCE_SYNC_NEGO	(0)
17219c65091SMatthew Wilcox #endif
17319c65091SMatthew Wilcox 
17419c65091SMatthew Wilcox /*
17519c65091SMatthew Wilcox  * Disable master parity checking (flawed hardwares need that)
17619c65091SMatthew Wilcox  */
17719c65091SMatthew Wilcox #ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_MPARITY_CHECK
17819c65091SMatthew Wilcox #define SCSI_NCR_SETUP_MASTER_PARITY	(0)
17919c65091SMatthew Wilcox #else
18019c65091SMatthew Wilcox #define SCSI_NCR_SETUP_MASTER_PARITY	(1)
18119c65091SMatthew Wilcox #endif
18219c65091SMatthew Wilcox 
18319c65091SMatthew Wilcox /*
18419c65091SMatthew Wilcox  * Disable scsi parity checking (flawed devices may need that)
18519c65091SMatthew Wilcox  */
18619c65091SMatthew Wilcox #ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_PARITY_CHECK
18719c65091SMatthew Wilcox #define SCSI_NCR_SETUP_SCSI_PARITY	(0)
18819c65091SMatthew Wilcox #else
18919c65091SMatthew Wilcox #define SCSI_NCR_SETUP_SCSI_PARITY	(1)
19019c65091SMatthew Wilcox #endif
19119c65091SMatthew Wilcox 
19219c65091SMatthew Wilcox /*
19319c65091SMatthew Wilcox  * Settle time after reset at boot-up
19419c65091SMatthew Wilcox  */
19519c65091SMatthew Wilcox #define SCSI_NCR_SETUP_SETTLE_TIME	(2)
19619c65091SMatthew Wilcox 
19719c65091SMatthew Wilcox /*
19819c65091SMatthew Wilcox **	Bridge quirks work-around option defaulted to 1.
19919c65091SMatthew Wilcox */
20019c65091SMatthew Wilcox #ifndef	SCSI_NCR_PCIQ_WORK_AROUND_OPT
20119c65091SMatthew Wilcox #define	SCSI_NCR_PCIQ_WORK_AROUND_OPT	1
20219c65091SMatthew Wilcox #endif
20319c65091SMatthew Wilcox 
20419c65091SMatthew Wilcox /*
20519c65091SMatthew Wilcox **	Work-around common bridge misbehaviour.
20619c65091SMatthew Wilcox **
20719c65091SMatthew Wilcox **	- Do not flush posted writes in the opposite
20819c65091SMatthew Wilcox **	  direction on read.
20919c65091SMatthew Wilcox **	- May reorder DMA writes to memory.
21019c65091SMatthew Wilcox **
21119c65091SMatthew Wilcox **	This option should not affect performances
21219c65091SMatthew Wilcox **	significantly, so it is the default.
21319c65091SMatthew Wilcox */
21419c65091SMatthew Wilcox #if	SCSI_NCR_PCIQ_WORK_AROUND_OPT == 1
21519c65091SMatthew Wilcox #define	SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM
21619c65091SMatthew Wilcox #define	SCSI_NCR_PCIQ_MAY_REORDER_WRITES
21719c65091SMatthew Wilcox #define	SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS
21819c65091SMatthew Wilcox 
21919c65091SMatthew Wilcox /*
22019c65091SMatthew Wilcox **	Same as option 1, but also deal with
22119c65091SMatthew Wilcox **	misconfigured interrupts.
22219c65091SMatthew Wilcox **
22319c65091SMatthew Wilcox **	- Edge triggerred instead of level sensitive.
22419c65091SMatthew Wilcox **	- No interrupt line connected.
22519c65091SMatthew Wilcox **	- IRQ number misconfigured.
22619c65091SMatthew Wilcox **
22719c65091SMatthew Wilcox **	If no interrupt is delivered, the driver will
22819c65091SMatthew Wilcox **	catch the interrupt conditions 10 times per
22919c65091SMatthew Wilcox **	second. No need to say that this option is
23019c65091SMatthew Wilcox **	not recommended.
23119c65091SMatthew Wilcox */
23219c65091SMatthew Wilcox #elif	SCSI_NCR_PCIQ_WORK_AROUND_OPT == 2
23319c65091SMatthew Wilcox #define	SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM
23419c65091SMatthew Wilcox #define	SCSI_NCR_PCIQ_MAY_REORDER_WRITES
23519c65091SMatthew Wilcox #define	SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS
23619c65091SMatthew Wilcox #define	SCSI_NCR_PCIQ_BROKEN_INTR
23719c65091SMatthew Wilcox 
23819c65091SMatthew Wilcox /*
23919c65091SMatthew Wilcox **	Some bridge designers decided to flush
24019c65091SMatthew Wilcox **	everything prior to deliver the interrupt.
24119c65091SMatthew Wilcox **	This option tries to deal with such a
24219c65091SMatthew Wilcox **	behaviour.
24319c65091SMatthew Wilcox */
24419c65091SMatthew Wilcox #elif	SCSI_NCR_PCIQ_WORK_AROUND_OPT == 3
24519c65091SMatthew Wilcox #define	SCSI_NCR_PCIQ_SYNC_ON_INTR
24619c65091SMatthew Wilcox #endif
24719c65091SMatthew Wilcox 
24819c65091SMatthew Wilcox /*
24919c65091SMatthew Wilcox **	Other parameters not configurable with "make config"
25019c65091SMatthew Wilcox **	Avoid to change these constants, unless you know what you are doing.
25119c65091SMatthew Wilcox */
25219c65091SMatthew Wilcox 
25319c65091SMatthew Wilcox #define SCSI_NCR_ALWAYS_SIMPLE_TAG
25419c65091SMatthew Wilcox #define SCSI_NCR_MAX_SCATTER	(127)
25519c65091SMatthew Wilcox #define SCSI_NCR_MAX_TARGET	(16)
25619c65091SMatthew Wilcox 
25719c65091SMatthew Wilcox /*
25819c65091SMatthew Wilcox **   Compute some desirable value for CAN_QUEUE
25919c65091SMatthew Wilcox **   and CMD_PER_LUN.
26019c65091SMatthew Wilcox **   The driver will use lower values if these
26119c65091SMatthew Wilcox **   ones appear to be too large.
26219c65091SMatthew Wilcox */
26319c65091SMatthew Wilcox #define SCSI_NCR_CAN_QUEUE	(8*SCSI_NCR_MAX_TAGS + 2*SCSI_NCR_MAX_TARGET)
26419c65091SMatthew Wilcox #define SCSI_NCR_CMD_PER_LUN	(SCSI_NCR_MAX_TAGS)
26519c65091SMatthew Wilcox 
26619c65091SMatthew Wilcox #define SCSI_NCR_SG_TABLESIZE	(SCSI_NCR_MAX_SCATTER)
26719c65091SMatthew Wilcox #define SCSI_NCR_TIMER_INTERVAL	(HZ)
26819c65091SMatthew Wilcox 
26919c65091SMatthew Wilcox #if 1 /* defined CONFIG_SCSI_MULTI_LUN */
27019c65091SMatthew Wilcox #define SCSI_NCR_MAX_LUN	(16)
27119c65091SMatthew Wilcox #else
27219c65091SMatthew Wilcox #define SCSI_NCR_MAX_LUN	(1)
27319c65091SMatthew Wilcox #endif
27419c65091SMatthew Wilcox 
27519c65091SMatthew Wilcox /*
27619c65091SMatthew Wilcox  *  IO functions definition for big/little endian CPU support.
27719c65091SMatthew Wilcox  *  For now, the NCR is only supported in little endian addressing mode,
27819c65091SMatthew Wilcox  */
27919c65091SMatthew Wilcox 
28019c65091SMatthew Wilcox #ifdef	__BIG_ENDIAN
28119c65091SMatthew Wilcox 
28219c65091SMatthew Wilcox #define	inw_l2b		inw
28319c65091SMatthew Wilcox #define	inl_l2b		inl
28419c65091SMatthew Wilcox #define	outw_b2l	outw
28519c65091SMatthew Wilcox #define	outl_b2l	outl
28619c65091SMatthew Wilcox 
28719c65091SMatthew Wilcox #define	readb_raw	readb
28819c65091SMatthew Wilcox #define	writeb_raw	writeb
28919c65091SMatthew Wilcox 
29019c65091SMatthew Wilcox #if defined(SCSI_NCR_BIG_ENDIAN)
29119c65091SMatthew Wilcox #define	readw_l2b	__raw_readw
29219c65091SMatthew Wilcox #define	readl_l2b	__raw_readl
29319c65091SMatthew Wilcox #define	writew_b2l	__raw_writew
29419c65091SMatthew Wilcox #define	writel_b2l	__raw_writel
29519c65091SMatthew Wilcox #define	readw_raw	__raw_readw
29619c65091SMatthew Wilcox #define	readl_raw	__raw_readl
29719c65091SMatthew Wilcox #define	writew_raw	__raw_writew
29819c65091SMatthew Wilcox #define	writel_raw	__raw_writel
29919c65091SMatthew Wilcox #else	/* Other big-endian */
30019c65091SMatthew Wilcox #define	readw_l2b	readw
30119c65091SMatthew Wilcox #define	readl_l2b	readl
30219c65091SMatthew Wilcox #define	writew_b2l	writew
30319c65091SMatthew Wilcox #define	writel_b2l	writel
30419c65091SMatthew Wilcox #define	readw_raw	readw
30519c65091SMatthew Wilcox #define	readl_raw	readl
30619c65091SMatthew Wilcox #define	writew_raw	writew
30719c65091SMatthew Wilcox #define	writel_raw	writel
30819c65091SMatthew Wilcox #endif
30919c65091SMatthew Wilcox 
31019c65091SMatthew Wilcox #else	/* little endian */
31119c65091SMatthew Wilcox 
31219c65091SMatthew Wilcox #define	inw_raw		inw
31319c65091SMatthew Wilcox #define	inl_raw		inl
31419c65091SMatthew Wilcox #define	outw_raw	outw
31519c65091SMatthew Wilcox #define	outl_raw	outl
31619c65091SMatthew Wilcox 
31719c65091SMatthew Wilcox #define	readb_raw	readb
31819c65091SMatthew Wilcox #define	readw_raw	readw
31919c65091SMatthew Wilcox #define	readl_raw	readl
32019c65091SMatthew Wilcox #define	writeb_raw	writeb
32119c65091SMatthew Wilcox #define	writew_raw	writew
32219c65091SMatthew Wilcox #define	writel_raw	writel
32319c65091SMatthew Wilcox 
32419c65091SMatthew Wilcox #endif
32519c65091SMatthew Wilcox 
32619c65091SMatthew Wilcox #if !defined(__hppa__) && !defined(__mips__)
32719c65091SMatthew Wilcox #ifdef	SCSI_NCR_BIG_ENDIAN
32819c65091SMatthew Wilcox #error	"The NCR in BIG ENDIAN addressing mode is not (yet) supported"
32919c65091SMatthew Wilcox #endif
33019c65091SMatthew Wilcox #endif
33119c65091SMatthew Wilcox 
33219c65091SMatthew Wilcox #define MEMORY_BARRIER()	mb()
33319c65091SMatthew Wilcox 
33419c65091SMatthew Wilcox 
33519c65091SMatthew Wilcox /*
33619c65091SMatthew Wilcox  *  If the NCR uses big endian addressing mode over the
33719c65091SMatthew Wilcox  *  PCI, actual io register addresses for byte and word
33819c65091SMatthew Wilcox  *  accesses must be changed according to lane routing.
33919c65091SMatthew Wilcox  *  Btw, ncr_offb() and ncr_offw() macros only apply to
34019c65091SMatthew Wilcox  *  constants and so donnot generate bloated code.
34119c65091SMatthew Wilcox  */
34219c65091SMatthew Wilcox 
34319c65091SMatthew Wilcox #if	defined(SCSI_NCR_BIG_ENDIAN)
34419c65091SMatthew Wilcox 
34519c65091SMatthew Wilcox #define ncr_offb(o)	(((o)&~3)+((~((o)&3))&3))
34619c65091SMatthew Wilcox #define ncr_offw(o)	(((o)&~3)+((~((o)&3))&2))
34719c65091SMatthew Wilcox 
34819c65091SMatthew Wilcox #else
34919c65091SMatthew Wilcox 
35019c65091SMatthew Wilcox #define ncr_offb(o)	(o)
35119c65091SMatthew Wilcox #define ncr_offw(o)	(o)
35219c65091SMatthew Wilcox 
35319c65091SMatthew Wilcox #endif
35419c65091SMatthew Wilcox 
35519c65091SMatthew Wilcox /*
35619c65091SMatthew Wilcox  *  If the CPU and the NCR use same endian-ness addressing,
35719c65091SMatthew Wilcox  *  no byte reordering is needed for script patching.
35819c65091SMatthew Wilcox  *  Macro cpu_to_scr() is to be used for script patching.
35919c65091SMatthew Wilcox  *  Macro scr_to_cpu() is to be used for getting a DWORD
36019c65091SMatthew Wilcox  *  from the script.
36119c65091SMatthew Wilcox  */
36219c65091SMatthew Wilcox 
36319c65091SMatthew Wilcox #if	defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)
36419c65091SMatthew Wilcox 
36519c65091SMatthew Wilcox #define cpu_to_scr(dw)	cpu_to_le32(dw)
36619c65091SMatthew Wilcox #define scr_to_cpu(dw)	le32_to_cpu(dw)
36719c65091SMatthew Wilcox 
36819c65091SMatthew Wilcox #elif	defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)
36919c65091SMatthew Wilcox 
37019c65091SMatthew Wilcox #define cpu_to_scr(dw)	cpu_to_be32(dw)
37119c65091SMatthew Wilcox #define scr_to_cpu(dw)	be32_to_cpu(dw)
37219c65091SMatthew Wilcox 
37319c65091SMatthew Wilcox #else
37419c65091SMatthew Wilcox 
37519c65091SMatthew Wilcox #define cpu_to_scr(dw)	(dw)
37619c65091SMatthew Wilcox #define scr_to_cpu(dw)	(dw)
37719c65091SMatthew Wilcox 
37819c65091SMatthew Wilcox #endif
37919c65091SMatthew Wilcox 
38019c65091SMatthew Wilcox /*
38119c65091SMatthew Wilcox  *  Access to the controller chip.
38219c65091SMatthew Wilcox  *
38319c65091SMatthew Wilcox  *  If the CPU and the NCR use same endian-ness addressing,
38419c65091SMatthew Wilcox  *  no byte reordering is needed for accessing chip io
38519c65091SMatthew Wilcox  *  registers. Functions suffixed by '_raw' are assumed
38619c65091SMatthew Wilcox  *  to access the chip over the PCI without doing byte
38719c65091SMatthew Wilcox  *  reordering. Functions suffixed by '_l2b' are
38819c65091SMatthew Wilcox  *  assumed to perform little-endian to big-endian byte
38919c65091SMatthew Wilcox  *  reordering, those suffixed by '_b2l' blah, blah,
39019c65091SMatthew Wilcox  *  blah, ...
39119c65091SMatthew Wilcox  */
39219c65091SMatthew Wilcox 
39319c65091SMatthew Wilcox /*
39419c65091SMatthew Wilcox  *  MEMORY mapped IO input / output
39519c65091SMatthew Wilcox  */
39619c65091SMatthew Wilcox 
39719c65091SMatthew Wilcox #define INB_OFF(o)		readb_raw((char __iomem *)np->reg + ncr_offb(o))
39819c65091SMatthew Wilcox #define OUTB_OFF(o, val)	writeb_raw((val), (char __iomem *)np->reg + ncr_offb(o))
39919c65091SMatthew Wilcox 
40019c65091SMatthew Wilcox #if	defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)
40119c65091SMatthew Wilcox 
40219c65091SMatthew Wilcox #define INW_OFF(o)		readw_l2b((char __iomem *)np->reg + ncr_offw(o))
40319c65091SMatthew Wilcox #define INL_OFF(o)		readl_l2b((char __iomem *)np->reg + (o))
40419c65091SMatthew Wilcox 
40519c65091SMatthew Wilcox #define OUTW_OFF(o, val)	writew_b2l((val), (char __iomem *)np->reg + ncr_offw(o))
40619c65091SMatthew Wilcox #define OUTL_OFF(o, val)	writel_b2l((val), (char __iomem *)np->reg + (o))
40719c65091SMatthew Wilcox 
40819c65091SMatthew Wilcox #elif	defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)
40919c65091SMatthew Wilcox 
41019c65091SMatthew Wilcox #define INW_OFF(o)		readw_b2l((char __iomem *)np->reg + ncr_offw(o))
41119c65091SMatthew Wilcox #define INL_OFF(o)		readl_b2l((char __iomem *)np->reg + (o))
41219c65091SMatthew Wilcox 
41319c65091SMatthew Wilcox #define OUTW_OFF(o, val)	writew_l2b((val), (char __iomem *)np->reg + ncr_offw(o))
41419c65091SMatthew Wilcox #define OUTL_OFF(o, val)	writel_l2b((val), (char __iomem *)np->reg + (o))
41519c65091SMatthew Wilcox 
41619c65091SMatthew Wilcox #else
41719c65091SMatthew Wilcox 
41819c65091SMatthew Wilcox #ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
41919c65091SMatthew Wilcox /* Only 8 or 32 bit transfers allowed */
42019c65091SMatthew Wilcox #define INW_OFF(o)		(readb((char __iomem *)np->reg + ncr_offw(o)) << 8 | readb((char __iomem *)np->reg + ncr_offw(o) + 1))
42119c65091SMatthew Wilcox #else
42219c65091SMatthew Wilcox #define INW_OFF(o)		readw_raw((char __iomem *)np->reg + ncr_offw(o))
42319c65091SMatthew Wilcox #endif
42419c65091SMatthew Wilcox #define INL_OFF(o)		readl_raw((char __iomem *)np->reg + (o))
42519c65091SMatthew Wilcox 
42619c65091SMatthew Wilcox #ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
42719c65091SMatthew Wilcox /* Only 8 or 32 bit transfers allowed */
42819c65091SMatthew Wilcox #define OUTW_OFF(o, val)	do { writeb((char)((val) >> 8), (char __iomem *)np->reg + ncr_offw(o)); writeb((char)(val), (char __iomem *)np->reg + ncr_offw(o) + 1); } while (0)
42919c65091SMatthew Wilcox #else
43019c65091SMatthew Wilcox #define OUTW_OFF(o, val)	writew_raw((val), (char __iomem *)np->reg + ncr_offw(o))
43119c65091SMatthew Wilcox #endif
43219c65091SMatthew Wilcox #define OUTL_OFF(o, val)	writel_raw((val), (char __iomem *)np->reg + (o))
43319c65091SMatthew Wilcox 
43419c65091SMatthew Wilcox #endif
43519c65091SMatthew Wilcox 
43619c65091SMatthew Wilcox #define INB(r)		INB_OFF (offsetof(struct ncr_reg,r))
43719c65091SMatthew Wilcox #define INW(r)		INW_OFF (offsetof(struct ncr_reg,r))
43819c65091SMatthew Wilcox #define INL(r)		INL_OFF (offsetof(struct ncr_reg,r))
43919c65091SMatthew Wilcox 
44019c65091SMatthew Wilcox #define OUTB(r, val)	OUTB_OFF (offsetof(struct ncr_reg,r), (val))
44119c65091SMatthew Wilcox #define OUTW(r, val)	OUTW_OFF (offsetof(struct ncr_reg,r), (val))
44219c65091SMatthew Wilcox #define OUTL(r, val)	OUTL_OFF (offsetof(struct ncr_reg,r), (val))
44319c65091SMatthew Wilcox 
44419c65091SMatthew Wilcox /*
44519c65091SMatthew Wilcox  *  Set bit field ON, OFF
44619c65091SMatthew Wilcox  */
44719c65091SMatthew Wilcox 
44819c65091SMatthew Wilcox #define OUTONB(r, m)	OUTB(r, INB(r) | (m))
44919c65091SMatthew Wilcox #define OUTOFFB(r, m)	OUTB(r, INB(r) & ~(m))
45019c65091SMatthew Wilcox #define OUTONW(r, m)	OUTW(r, INW(r) | (m))
45119c65091SMatthew Wilcox #define OUTOFFW(r, m)	OUTW(r, INW(r) & ~(m))
45219c65091SMatthew Wilcox #define OUTONL(r, m)	OUTL(r, INL(r) | (m))
45319c65091SMatthew Wilcox #define OUTOFFL(r, m)	OUTL(r, INL(r) & ~(m))
45419c65091SMatthew Wilcox 
45519c65091SMatthew Wilcox /*
45619c65091SMatthew Wilcox  *  We normally want the chip to have a consistent view
45719c65091SMatthew Wilcox  *  of driver internal data structures when we restart it.
45819c65091SMatthew Wilcox  *  Thus these macros.
45919c65091SMatthew Wilcox  */
46019c65091SMatthew Wilcox #define OUTL_DSP(v)				\
46119c65091SMatthew Wilcox 	do {					\
46219c65091SMatthew Wilcox 		MEMORY_BARRIER();		\
46319c65091SMatthew Wilcox 		OUTL (nc_dsp, (v));		\
46419c65091SMatthew Wilcox 	} while (0)
46519c65091SMatthew Wilcox 
46619c65091SMatthew Wilcox #define OUTONB_STD()				\
46719c65091SMatthew Wilcox 	do {					\
46819c65091SMatthew Wilcox 		MEMORY_BARRIER();		\
46919c65091SMatthew Wilcox 		OUTONB (nc_dcntl, (STD|NOCOM));	\
47019c65091SMatthew Wilcox 	} while (0)
47119c65091SMatthew Wilcox 
47219c65091SMatthew Wilcox 
47319c65091SMatthew Wilcox /*
47419c65091SMatthew Wilcox **   NCR53C8XX devices features table.
47519c65091SMatthew Wilcox */
47619c65091SMatthew Wilcox struct ncr_chip {
47719c65091SMatthew Wilcox 	unsigned short	revision_id;
47819c65091SMatthew Wilcox 	unsigned char	burst_max;	/* log-base-2 of max burst */
47919c65091SMatthew Wilcox 	unsigned char	offset_max;
48019c65091SMatthew Wilcox 	unsigned char	nr_divisor;
48119c65091SMatthew Wilcox 	unsigned int	features;
48219c65091SMatthew Wilcox #define FE_LED0		(1<<0)
48319c65091SMatthew Wilcox #define FE_WIDE		(1<<1)    /* Wide data transfers */
48419c65091SMatthew Wilcox #define FE_ULTRA	(1<<2)	  /* Ultra speed 20Mtrans/sec */
48519c65091SMatthew Wilcox #define FE_DBLR		(1<<4)	  /* Clock doubler present */
48619c65091SMatthew Wilcox #define FE_QUAD		(1<<5)	  /* Clock quadrupler present */
48719c65091SMatthew Wilcox #define FE_ERL		(1<<6)    /* Enable read line */
48819c65091SMatthew Wilcox #define FE_CLSE		(1<<7)    /* Cache line size enable */
48919c65091SMatthew Wilcox #define FE_WRIE		(1<<8)    /* Write & Invalidate enable */
49019c65091SMatthew Wilcox #define FE_ERMP		(1<<9)    /* Enable read multiple */
49119c65091SMatthew Wilcox #define FE_BOF		(1<<10)   /* Burst opcode fetch */
49219c65091SMatthew Wilcox #define FE_DFS		(1<<11)   /* DMA fifo size */
49319c65091SMatthew Wilcox #define FE_PFEN		(1<<12)   /* Prefetch enable */
49419c65091SMatthew Wilcox #define FE_LDSTR	(1<<13)   /* Load/Store supported */
49519c65091SMatthew Wilcox #define FE_RAM		(1<<14)   /* On chip RAM present */
49619c65091SMatthew Wilcox #define FE_VARCLK	(1<<15)   /* SCSI clock may vary */
49719c65091SMatthew Wilcox #define FE_RAM8K	(1<<16)   /* On chip RAM sized 8Kb */
49819c65091SMatthew Wilcox #define FE_64BIT	(1<<17)   /* Have a 64-bit PCI interface */
49919c65091SMatthew Wilcox #define FE_IO256	(1<<18)   /* Requires full 256 bytes in PCI space */
50019c65091SMatthew Wilcox #define FE_NOPM		(1<<19)   /* Scripts handles phase mismatch */
50119c65091SMatthew Wilcox #define FE_LEDC		(1<<20)   /* Hardware control of LED */
50219c65091SMatthew Wilcox #define FE_DIFF		(1<<21)   /* Support Differential SCSI */
50319c65091SMatthew Wilcox #define FE_66MHZ 	(1<<23)   /* 66MHz PCI Support */
50419c65091SMatthew Wilcox #define FE_DAC	 	(1<<24)   /* Support DAC cycles (64 bit addressing) */
50519c65091SMatthew Wilcox #define FE_ISTAT1 	(1<<25)   /* Have ISTAT1, MBOX0, MBOX1 registers */
50619c65091SMatthew Wilcox #define FE_DAC_IN_USE	(1<<26)	  /* Platform does DAC cycles */
50719c65091SMatthew Wilcox #define FE_EHP		(1<<27)   /* 720: Even host parity */
50819c65091SMatthew Wilcox #define FE_MUX		(1<<28)   /* 720: Multiplexed bus */
50919c65091SMatthew Wilcox #define FE_EA		(1<<29)   /* 720: Enable Ack */
51019c65091SMatthew Wilcox 
51119c65091SMatthew Wilcox #define FE_CACHE_SET	(FE_ERL|FE_CLSE|FE_WRIE|FE_ERMP)
51219c65091SMatthew Wilcox #define FE_SCSI_SET	(FE_WIDE|FE_ULTRA|FE_DBLR|FE_QUAD|F_CLK80)
51319c65091SMatthew Wilcox #define FE_SPECIAL_SET	(FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_RAM)
51419c65091SMatthew Wilcox };
51519c65091SMatthew Wilcox 
51619c65091SMatthew Wilcox 
51719c65091SMatthew Wilcox /*
51819c65091SMatthew Wilcox **	Driver setup structure.
51919c65091SMatthew Wilcox **
52019c65091SMatthew Wilcox **	This structure is initialized from linux config options.
52119c65091SMatthew Wilcox **	It can be overridden at boot-up by the boot command line.
52219c65091SMatthew Wilcox */
52319c65091SMatthew Wilcox #define SCSI_NCR_MAX_EXCLUDES 8
52419c65091SMatthew Wilcox struct ncr_driver_setup {
52519c65091SMatthew Wilcox 	u8	master_parity;
52619c65091SMatthew Wilcox 	u8	scsi_parity;
52719c65091SMatthew Wilcox 	u8	disconnection;
52819c65091SMatthew Wilcox 	u8	special_features;
52919c65091SMatthew Wilcox 	u8	force_sync_nego;
53019c65091SMatthew Wilcox 	u8	reverse_probe;
53119c65091SMatthew Wilcox 	u8	pci_fix_up;
53219c65091SMatthew Wilcox 	u8	use_nvram;
53319c65091SMatthew Wilcox 	u8	verbose;
53419c65091SMatthew Wilcox 	u8	default_tags;
53519c65091SMatthew Wilcox 	u16	default_sync;
53619c65091SMatthew Wilcox 	u16	debug;
53719c65091SMatthew Wilcox 	u8	burst_max;
53819c65091SMatthew Wilcox 	u8	led_pin;
53919c65091SMatthew Wilcox 	u8	max_wide;
54019c65091SMatthew Wilcox 	u8	settle_delay;
54119c65091SMatthew Wilcox 	u8	diff_support;
54219c65091SMatthew Wilcox 	u8	irqm;
54319c65091SMatthew Wilcox 	u8	bus_check;
54419c65091SMatthew Wilcox 	u8	optimize;
54519c65091SMatthew Wilcox 	u8	recovery;
54619c65091SMatthew Wilcox 	u8	host_id;
54719c65091SMatthew Wilcox 	u16	iarb;
54819c65091SMatthew Wilcox 	u32	excludes[SCSI_NCR_MAX_EXCLUDES];
54919c65091SMatthew Wilcox 	char	tag_ctrl[100];
55019c65091SMatthew Wilcox };
55119c65091SMatthew Wilcox 
55219c65091SMatthew Wilcox /*
55319c65091SMatthew Wilcox **	Initial setup.
55419c65091SMatthew Wilcox **	Can be overriden at startup by a command line.
55519c65091SMatthew Wilcox */
55619c65091SMatthew Wilcox #define SCSI_NCR_DRIVER_SETUP			\
55719c65091SMatthew Wilcox {						\
55819c65091SMatthew Wilcox 	SCSI_NCR_SETUP_MASTER_PARITY,		\
55919c65091SMatthew Wilcox 	SCSI_NCR_SETUP_SCSI_PARITY,		\
56019c65091SMatthew Wilcox 	SCSI_NCR_SETUP_DISCONNECTION,		\
56119c65091SMatthew Wilcox 	SCSI_NCR_SETUP_SPECIAL_FEATURES,	\
56219c65091SMatthew Wilcox 	SCSI_NCR_SETUP_FORCE_SYNC_NEGO,		\
56319c65091SMatthew Wilcox 	0,					\
56419c65091SMatthew Wilcox 	0,					\
56519c65091SMatthew Wilcox 	1,					\
56619c65091SMatthew Wilcox 	0,					\
56719c65091SMatthew Wilcox 	SCSI_NCR_SETUP_DEFAULT_TAGS,		\
56819c65091SMatthew Wilcox 	SCSI_NCR_SETUP_DEFAULT_SYNC,		\
56919c65091SMatthew Wilcox 	0x00,					\
57019c65091SMatthew Wilcox 	7,					\
57119c65091SMatthew Wilcox 	0,					\
57219c65091SMatthew Wilcox 	1,					\
57319c65091SMatthew Wilcox 	SCSI_NCR_SETUP_SETTLE_TIME,		\
57419c65091SMatthew Wilcox 	0,					\
57519c65091SMatthew Wilcox 	0,					\
57619c65091SMatthew Wilcox 	1,					\
57719c65091SMatthew Wilcox 	0,					\
57819c65091SMatthew Wilcox 	0,					\
57919c65091SMatthew Wilcox 	255,					\
58019c65091SMatthew Wilcox 	0x00					\
58119c65091SMatthew Wilcox }
58219c65091SMatthew Wilcox 
58319c65091SMatthew Wilcox /*
58419c65091SMatthew Wilcox **	Boot fail safe setup.
58519c65091SMatthew Wilcox **	Override initial setup from boot command line:
58619c65091SMatthew Wilcox **	ncr53c8xx=safe:y
58719c65091SMatthew Wilcox */
58819c65091SMatthew Wilcox #define SCSI_NCR_DRIVER_SAFE_SETUP		\
58919c65091SMatthew Wilcox {						\
59019c65091SMatthew Wilcox 	0,					\
59119c65091SMatthew Wilcox 	1,					\
59219c65091SMatthew Wilcox 	0,					\
59319c65091SMatthew Wilcox 	0,					\
59419c65091SMatthew Wilcox 	0,					\
59519c65091SMatthew Wilcox 	0,					\
59619c65091SMatthew Wilcox 	0,					\
59719c65091SMatthew Wilcox 	1,					\
59819c65091SMatthew Wilcox 	2,					\
59919c65091SMatthew Wilcox 	0,					\
60019c65091SMatthew Wilcox 	255,					\
60119c65091SMatthew Wilcox 	0x00,					\
60219c65091SMatthew Wilcox 	255,					\
60319c65091SMatthew Wilcox 	0,					\
60419c65091SMatthew Wilcox 	0,					\
60519c65091SMatthew Wilcox 	10,					\
60619c65091SMatthew Wilcox 	1,					\
60719c65091SMatthew Wilcox 	1,					\
60819c65091SMatthew Wilcox 	1,					\
60919c65091SMatthew Wilcox 	0,					\
61019c65091SMatthew Wilcox 	0,					\
61119c65091SMatthew Wilcox 	255					\
61219c65091SMatthew Wilcox }
61319c65091SMatthew Wilcox 
61419c65091SMatthew Wilcox /**************** ORIGINAL CONTENT of ncrreg.h from FreeBSD ******************/
61519c65091SMatthew Wilcox 
61619c65091SMatthew Wilcox /*-----------------------------------------------------------------
61719c65091SMatthew Wilcox **
61819c65091SMatthew Wilcox **	The ncr 53c810 register structure.
61919c65091SMatthew Wilcox **
62019c65091SMatthew Wilcox **-----------------------------------------------------------------
62119c65091SMatthew Wilcox */
62219c65091SMatthew Wilcox 
62319c65091SMatthew Wilcox struct ncr_reg {
62419c65091SMatthew Wilcox /*00*/  u8	nc_scntl0;    /* full arb., ena parity, par->ATN  */
62519c65091SMatthew Wilcox 
62619c65091SMatthew Wilcox /*01*/  u8	nc_scntl1;    /* no reset                         */
62719c65091SMatthew Wilcox         #define   ISCON   0x10  /* connected to scsi		    */
62819c65091SMatthew Wilcox         #define   CRST    0x08  /* force reset                      */
62919c65091SMatthew Wilcox         #define   IARB    0x02  /* immediate arbitration            */
63019c65091SMatthew Wilcox 
63119c65091SMatthew Wilcox /*02*/  u8	nc_scntl2;    /* no disconnect expected           */
63219c65091SMatthew Wilcox 	#define   SDU     0x80  /* cmd: disconnect will raise error */
63319c65091SMatthew Wilcox 	#define   CHM     0x40  /* sta: chained mode                */
63419c65091SMatthew Wilcox 	#define   WSS     0x08  /* sta: wide scsi send           [W]*/
63519c65091SMatthew Wilcox 	#define   WSR     0x01  /* sta: wide scsi received       [W]*/
63619c65091SMatthew Wilcox 
63719c65091SMatthew Wilcox /*03*/  u8	nc_scntl3;    /* cnf system clock dependent       */
63819c65091SMatthew Wilcox 	#define   EWS     0x08  /* cmd: enable wide scsi         [W]*/
63919c65091SMatthew Wilcox 	#define   ULTRA   0x80  /* cmd: ULTRA enable                */
64019c65091SMatthew Wilcox 				/* bits 0-2, 7 rsvd for C1010       */
64119c65091SMatthew Wilcox 
64219c65091SMatthew Wilcox /*04*/  u8	nc_scid;	/* cnf host adapter scsi address    */
64319c65091SMatthew Wilcox 	#define   RRE     0x40  /* r/w:e enable response to resel.  */
64419c65091SMatthew Wilcox 	#define   SRE     0x20  /* r/w:e enable response to select  */
64519c65091SMatthew Wilcox 
64619c65091SMatthew Wilcox /*05*/  u8	nc_sxfer;	/* ### Sync speed and count         */
64719c65091SMatthew Wilcox 				/* bits 6-7 rsvd for C1010          */
64819c65091SMatthew Wilcox 
64919c65091SMatthew Wilcox /*06*/  u8	nc_sdid;	/* ### Destination-ID               */
65019c65091SMatthew Wilcox 
65119c65091SMatthew Wilcox /*07*/  u8	nc_gpreg;	/* ??? IO-Pins                      */
65219c65091SMatthew Wilcox 
65319c65091SMatthew Wilcox /*08*/  u8	nc_sfbr;	/* ### First byte in phase          */
65419c65091SMatthew Wilcox 
65519c65091SMatthew Wilcox /*09*/  u8	nc_socl;
65619c65091SMatthew Wilcox 	#define   CREQ	  0x80	/* r/w: SCSI-REQ                    */
65719c65091SMatthew Wilcox 	#define   CACK	  0x40	/* r/w: SCSI-ACK                    */
65819c65091SMatthew Wilcox 	#define   CBSY	  0x20	/* r/w: SCSI-BSY                    */
65919c65091SMatthew Wilcox 	#define   CSEL	  0x10	/* r/w: SCSI-SEL                    */
66019c65091SMatthew Wilcox 	#define   CATN	  0x08	/* r/w: SCSI-ATN                    */
66119c65091SMatthew Wilcox 	#define   CMSG	  0x04	/* r/w: SCSI-MSG                    */
66219c65091SMatthew Wilcox 	#define   CC_D	  0x02	/* r/w: SCSI-C_D                    */
66319c65091SMatthew Wilcox 	#define   CI_O	  0x01	/* r/w: SCSI-I_O                    */
66419c65091SMatthew Wilcox 
66519c65091SMatthew Wilcox /*0a*/  u8	nc_ssid;
66619c65091SMatthew Wilcox 
66719c65091SMatthew Wilcox /*0b*/  u8	nc_sbcl;
66819c65091SMatthew Wilcox 
66919c65091SMatthew Wilcox /*0c*/  u8	nc_dstat;
67019c65091SMatthew Wilcox         #define   DFE     0x80  /* sta: dma fifo empty              */
67119c65091SMatthew Wilcox         #define   MDPE    0x40  /* int: master data parity error    */
67219c65091SMatthew Wilcox         #define   BF      0x20  /* int: script: bus fault           */
67319c65091SMatthew Wilcox         #define   ABRT    0x10  /* int: script: command aborted     */
67419c65091SMatthew Wilcox         #define   SSI     0x08  /* int: script: single step         */
67519c65091SMatthew Wilcox         #define   SIR     0x04  /* int: script: interrupt instruct. */
67619c65091SMatthew Wilcox         #define   IID     0x01  /* int: script: illegal instruct.   */
67719c65091SMatthew Wilcox 
67819c65091SMatthew Wilcox /*0d*/  u8	nc_sstat0;
67919c65091SMatthew Wilcox         #define   ILF     0x80  /* sta: data in SIDL register lsb   */
68019c65091SMatthew Wilcox         #define   ORF     0x40  /* sta: data in SODR register lsb   */
68119c65091SMatthew Wilcox         #define   OLF     0x20  /* sta: data in SODL register lsb   */
68219c65091SMatthew Wilcox         #define   AIP     0x10  /* sta: arbitration in progress     */
68319c65091SMatthew Wilcox         #define   LOA     0x08  /* sta: arbitration lost            */
68419c65091SMatthew Wilcox         #define   WOA     0x04  /* sta: arbitration won             */
68519c65091SMatthew Wilcox         #define   IRST    0x02  /* sta: scsi reset signal           */
68619c65091SMatthew Wilcox         #define   SDP     0x01  /* sta: scsi parity signal          */
68719c65091SMatthew Wilcox 
68819c65091SMatthew Wilcox /*0e*/  u8	nc_sstat1;
68919c65091SMatthew Wilcox 	#define   FF3210  0xf0	/* sta: bytes in the scsi fifo      */
69019c65091SMatthew Wilcox 
69119c65091SMatthew Wilcox /*0f*/  u8	nc_sstat2;
69219c65091SMatthew Wilcox         #define   ILF1    0x80  /* sta: data in SIDL register msb[W]*/
69319c65091SMatthew Wilcox         #define   ORF1    0x40  /* sta: data in SODR register msb[W]*/
69419c65091SMatthew Wilcox         #define   OLF1    0x20  /* sta: data in SODL register msb[W]*/
69519c65091SMatthew Wilcox         #define   DM      0x04  /* sta: DIFFSENS mismatch (895/6 only) */
69619c65091SMatthew Wilcox         #define   LDSC    0x02  /* sta: disconnect & reconnect      */
69719c65091SMatthew Wilcox 
69819c65091SMatthew Wilcox /*10*/  u8	nc_dsa;	/* --> Base page                    */
69919c65091SMatthew Wilcox /*11*/  u8	nc_dsa1;
70019c65091SMatthew Wilcox /*12*/  u8	nc_dsa2;
70119c65091SMatthew Wilcox /*13*/  u8	nc_dsa3;
70219c65091SMatthew Wilcox 
70319c65091SMatthew Wilcox /*14*/  u8	nc_istat;	/* --> Main Command and status      */
70419c65091SMatthew Wilcox         #define   CABRT   0x80  /* cmd: abort current operation     */
70519c65091SMatthew Wilcox         #define   SRST    0x40  /* mod: reset chip                  */
70619c65091SMatthew Wilcox         #define   SIGP    0x20  /* r/w: message from host to ncr    */
70719c65091SMatthew Wilcox         #define   SEM     0x10  /* r/w: message between host + ncr  */
70819c65091SMatthew Wilcox         #define   CON     0x08  /* sta: connected to scsi           */
70919c65091SMatthew Wilcox         #define   INTF    0x04  /* sta: int on the fly (reset by wr)*/
71019c65091SMatthew Wilcox         #define   SIP     0x02  /* sta: scsi-interrupt              */
71119c65091SMatthew Wilcox         #define   DIP     0x01  /* sta: host/script interrupt       */
71219c65091SMatthew Wilcox 
71319c65091SMatthew Wilcox /*15*/  u8	nc_istat1;	/* 896 and later cores only */
71419c65091SMatthew Wilcox         #define   FLSH    0x04  /* sta: chip is flushing            */
71519c65091SMatthew Wilcox         #define   SRUN    0x02  /* sta: scripts are running         */
71619c65091SMatthew Wilcox         #define   SIRQD   0x01  /* r/w: disable INT pin             */
71719c65091SMatthew Wilcox 
71819c65091SMatthew Wilcox /*16*/  u8	nc_mbox0;	/* 896 and later cores only */
71919c65091SMatthew Wilcox /*17*/  u8	nc_mbox1;	/* 896 and later cores only */
72019c65091SMatthew Wilcox 
72119c65091SMatthew Wilcox /*18*/	u8	nc_ctest0;
72219c65091SMatthew Wilcox 	#define   EHP     0x04	/* 720 even host parity             */
72319c65091SMatthew Wilcox /*19*/  u8	nc_ctest1;
72419c65091SMatthew Wilcox 
72519c65091SMatthew Wilcox /*1a*/  u8	nc_ctest2;
72619c65091SMatthew Wilcox 	#define   CSIGP   0x40
72719c65091SMatthew Wilcox 				/* bits 0-2,7 rsvd for C1010        */
72819c65091SMatthew Wilcox 
72919c65091SMatthew Wilcox /*1b*/  u8	nc_ctest3;
73019c65091SMatthew Wilcox 	#define   FLF     0x08  /* cmd: flush dma fifo              */
73119c65091SMatthew Wilcox 	#define   CLF	  0x04	/* cmd: clear dma fifo		    */
73219c65091SMatthew Wilcox 	#define   FM      0x02  /* mod: fetch pin mode              */
73319c65091SMatthew Wilcox 	#define   WRIE    0x01  /* mod: write and invalidate enable */
73419c65091SMatthew Wilcox 				/* bits 4-7 rsvd for C1010          */
73519c65091SMatthew Wilcox 
73619c65091SMatthew Wilcox /*1c*/  u32    nc_temp;	/* ### Temporary stack              */
73719c65091SMatthew Wilcox 
73819c65091SMatthew Wilcox /*20*/	u8	nc_dfifo;
73919c65091SMatthew Wilcox /*21*/  u8	nc_ctest4;
74019c65091SMatthew Wilcox 	#define   MUX     0x80  /* 720 host bus multiplex mode      */
74119c65091SMatthew Wilcox 	#define   BDIS    0x80  /* mod: burst disable               */
74219c65091SMatthew Wilcox 	#define   MPEE    0x08  /* mod: master parity error enable  */
74319c65091SMatthew Wilcox 
74419c65091SMatthew Wilcox /*22*/  u8	nc_ctest5;
74519c65091SMatthew Wilcox 	#define   DFS     0x20  /* mod: dma fifo size               */
74619c65091SMatthew Wilcox 				/* bits 0-1, 3-7 rsvd for C1010          */
74719c65091SMatthew Wilcox /*23*/  u8	nc_ctest6;
74819c65091SMatthew Wilcox 
74919c65091SMatthew Wilcox /*24*/  u32    nc_dbc;	/* ### Byte count and command       */
75019c65091SMatthew Wilcox /*28*/  u32    nc_dnad;	/* ### Next command register        */
75119c65091SMatthew Wilcox /*2c*/  u32    nc_dsp;	/* --> Script Pointer               */
75219c65091SMatthew Wilcox /*30*/  u32    nc_dsps;	/* --> Script pointer save/opcode#2 */
75319c65091SMatthew Wilcox 
75419c65091SMatthew Wilcox /*34*/  u8	nc_scratcha;  /* Temporary register a            */
75519c65091SMatthew Wilcox /*35*/  u8	nc_scratcha1;
75619c65091SMatthew Wilcox /*36*/  u8	nc_scratcha2;
75719c65091SMatthew Wilcox /*37*/  u8	nc_scratcha3;
75819c65091SMatthew Wilcox 
75919c65091SMatthew Wilcox /*38*/  u8	nc_dmode;
76019c65091SMatthew Wilcox 	#define   BL_2    0x80  /* mod: burst length shift value +2 */
76119c65091SMatthew Wilcox 	#define   BL_1    0x40  /* mod: burst length shift value +1 */
76219c65091SMatthew Wilcox 	#define   ERL     0x08  /* mod: enable read line            */
76319c65091SMatthew Wilcox 	#define   ERMP    0x04  /* mod: enable read multiple        */
76419c65091SMatthew Wilcox 	#define   BOF     0x02  /* mod: burst op code fetch         */
76519c65091SMatthew Wilcox 
76619c65091SMatthew Wilcox /*39*/  u8	nc_dien;
76719c65091SMatthew Wilcox /*3a*/  u8	nc_sbr;
76819c65091SMatthew Wilcox 
76919c65091SMatthew Wilcox /*3b*/  u8	nc_dcntl;	/* --> Script execution control     */
77019c65091SMatthew Wilcox 	#define   CLSE    0x80  /* mod: cache line size enable      */
77119c65091SMatthew Wilcox 	#define   PFF     0x40  /* cmd: pre-fetch flush             */
77219c65091SMatthew Wilcox 	#define   PFEN    0x20  /* mod: pre-fetch enable            */
77319c65091SMatthew Wilcox 	#define   EA      0x20  /* mod: 720 enable-ack              */
77419c65091SMatthew Wilcox 	#define   SSM     0x10  /* mod: single step mode            */
77519c65091SMatthew Wilcox 	#define   IRQM    0x08  /* mod: irq mode (1 = totem pole !) */
77619c65091SMatthew Wilcox 	#define   STD     0x04  /* cmd: start dma mode              */
77719c65091SMatthew Wilcox 	#define   IRQD    0x02  /* mod: irq disable                 */
77819c65091SMatthew Wilcox  	#define	  NOCOM   0x01	/* cmd: protect sfbr while reselect */
77919c65091SMatthew Wilcox 				/* bits 0-1 rsvd for C1010          */
78019c65091SMatthew Wilcox 
78119c65091SMatthew Wilcox /*3c*/  u32	nc_adder;
78219c65091SMatthew Wilcox 
78319c65091SMatthew Wilcox /*40*/  u16	nc_sien;	/* -->: interrupt enable            */
78419c65091SMatthew Wilcox /*42*/  u16	nc_sist;	/* <--: interrupt status            */
78519c65091SMatthew Wilcox         #define   SBMC    0x1000/* sta: SCSI Bus Mode Change (895/6 only) */
78619c65091SMatthew Wilcox         #define   STO     0x0400/* sta: timeout (select)            */
78719c65091SMatthew Wilcox         #define   GEN     0x0200/* sta: timeout (general)           */
78819c65091SMatthew Wilcox         #define   HTH     0x0100/* sta: timeout (handshake)         */
78919c65091SMatthew Wilcox         #define   MA      0x80  /* sta: phase mismatch              */
79019c65091SMatthew Wilcox         #define   CMP     0x40  /* sta: arbitration complete        */
79119c65091SMatthew Wilcox         #define   SEL     0x20  /* sta: selected by another device  */
79219c65091SMatthew Wilcox         #define   RSL     0x10  /* sta: reselected by another device*/
79319c65091SMatthew Wilcox         #define   SGE     0x08  /* sta: gross error (over/underflow)*/
79419c65091SMatthew Wilcox         #define   UDC     0x04  /* sta: unexpected disconnect       */
79519c65091SMatthew Wilcox         #define   RST     0x02  /* sta: scsi bus reset detected     */
79619c65091SMatthew Wilcox         #define   PAR     0x01  /* sta: scsi parity error           */
79719c65091SMatthew Wilcox 
79819c65091SMatthew Wilcox /*44*/  u8	nc_slpar;
79919c65091SMatthew Wilcox /*45*/  u8	nc_swide;
80019c65091SMatthew Wilcox /*46*/  u8	nc_macntl;
80119c65091SMatthew Wilcox /*47*/  u8	nc_gpcntl;
80219c65091SMatthew Wilcox /*48*/  u8	nc_stime0;    /* cmd: timeout for select&handshake*/
80319c65091SMatthew Wilcox /*49*/  u8	nc_stime1;    /* cmd: timeout user defined        */
80419c65091SMatthew Wilcox /*4a*/  u16   nc_respid;    /* sta: Reselect-IDs                */
80519c65091SMatthew Wilcox 
80619c65091SMatthew Wilcox /*4c*/  u8	nc_stest0;
80719c65091SMatthew Wilcox 
80819c65091SMatthew Wilcox /*4d*/  u8	nc_stest1;
80919c65091SMatthew Wilcox 	#define   SCLK    0x80	/* Use the PCI clock as SCSI clock	*/
81019c65091SMatthew Wilcox 	#define   DBLEN   0x08	/* clock doubler running		*/
81119c65091SMatthew Wilcox 	#define   DBLSEL  0x04	/* clock doubler selected		*/
81219c65091SMatthew Wilcox 
81319c65091SMatthew Wilcox 
81419c65091SMatthew Wilcox /*4e*/  u8	nc_stest2;
81519c65091SMatthew Wilcox 	#define   ROF     0x40	/* reset scsi offset (after gross error!) */
81619c65091SMatthew Wilcox 	#define   DIF     0x20  /* 720 SCSI differential mode             */
81719c65091SMatthew Wilcox 	#define   EXT     0x02  /* extended filtering                     */
81819c65091SMatthew Wilcox 
81919c65091SMatthew Wilcox /*4f*/  u8	nc_stest3;
82019c65091SMatthew Wilcox 	#define   TE     0x80	/* c: tolerAnt enable */
82119c65091SMatthew Wilcox 	#define   HSC    0x20	/* c: Halt SCSI Clock */
82219c65091SMatthew Wilcox 	#define   CSF    0x02	/* c: clear scsi fifo */
82319c65091SMatthew Wilcox 
82419c65091SMatthew Wilcox /*50*/  u16   nc_sidl;	/* Lowlevel: latched from scsi data */
82519c65091SMatthew Wilcox /*52*/  u8	nc_stest4;
82619c65091SMatthew Wilcox 	#define   SMODE  0xc0	/* SCSI bus mode      (895/6 only) */
82719c65091SMatthew Wilcox 	#define    SMODE_HVD 0x40	/* High Voltage Differential       */
82819c65091SMatthew Wilcox 	#define    SMODE_SE  0x80	/* Single Ended                    */
82919c65091SMatthew Wilcox 	#define    SMODE_LVD 0xc0	/* Low Voltage Differential        */
83019c65091SMatthew Wilcox 	#define   LCKFRQ 0x20	/* Frequency Lock (895/6 only)     */
83119c65091SMatthew Wilcox 				/* bits 0-5 rsvd for C1010          */
83219c65091SMatthew Wilcox 
83319c65091SMatthew Wilcox /*53*/  u8	nc_53_;
83419c65091SMatthew Wilcox /*54*/  u16	nc_sodl;	/* Lowlevel: data out to scsi data  */
83519c65091SMatthew Wilcox /*56*/	u8	nc_ccntl0;	/* Chip Control 0 (896)             */
83619c65091SMatthew Wilcox 	#define   ENPMJ  0x80	/* Enable Phase Mismatch Jump       */
83719c65091SMatthew Wilcox 	#define   PMJCTL 0x40	/* Phase Mismatch Jump Control      */
83819c65091SMatthew Wilcox 	#define   ENNDJ  0x20	/* Enable Non Data PM Jump          */
83919c65091SMatthew Wilcox 	#define   DISFC  0x10	/* Disable Auto FIFO Clear          */
84019c65091SMatthew Wilcox 	#define   DILS   0x02	/* Disable Internal Load/Store      */
84119c65091SMatthew Wilcox 	#define   DPR    0x01	/* Disable Pipe Req                 */
84219c65091SMatthew Wilcox 
84319c65091SMatthew Wilcox /*57*/	u8	nc_ccntl1;	/* Chip Control 1 (896)             */
84419c65091SMatthew Wilcox 	#define   ZMOD   0x80	/* High Impedance Mode              */
84519c65091SMatthew Wilcox 	#define	  DIC	 0x10	/* Disable Internal Cycles	    */
84619c65091SMatthew Wilcox 	#define   DDAC   0x08	/* Disable Dual Address Cycle       */
84719c65091SMatthew Wilcox 	#define   XTIMOD 0x04	/* 64-bit Table Ind. Indexing Mode  */
84819c65091SMatthew Wilcox 	#define   EXTIBMV 0x02	/* Enable 64-bit Table Ind. BMOV    */
84919c65091SMatthew Wilcox 	#define   EXDBMV 0x01	/* Enable 64-bit Direct BMOV        */
85019c65091SMatthew Wilcox 
85119c65091SMatthew Wilcox /*58*/  u16	nc_sbdl;	/* Lowlevel: data from scsi data    */
85219c65091SMatthew Wilcox /*5a*/  u16	nc_5a_;
85319c65091SMatthew Wilcox 
85419c65091SMatthew Wilcox /*5c*/  u8	nc_scr0;	/* Working register B               */
85519c65091SMatthew Wilcox /*5d*/  u8	nc_scr1;	/*                                  */
85619c65091SMatthew Wilcox /*5e*/  u8	nc_scr2;	/*                                  */
85719c65091SMatthew Wilcox /*5f*/  u8	nc_scr3;	/*                                  */
85819c65091SMatthew Wilcox 
85919c65091SMatthew Wilcox /*60*/  u8	nc_scrx[64];	/* Working register C-R             */
86019c65091SMatthew Wilcox /*a0*/	u32	nc_mmrs;	/* Memory Move Read Selector        */
86119c65091SMatthew Wilcox /*a4*/	u32	nc_mmws;	/* Memory Move Write Selector       */
86219c65091SMatthew Wilcox /*a8*/	u32	nc_sfs;		/* Script Fetch Selector            */
86319c65091SMatthew Wilcox /*ac*/	u32	nc_drs;		/* DSA Relative Selector            */
86419c65091SMatthew Wilcox /*b0*/	u32	nc_sbms;	/* Static Block Move Selector       */
86519c65091SMatthew Wilcox /*b4*/	u32	nc_dbms;	/* Dynamic Block Move Selector      */
86619c65091SMatthew Wilcox /*b8*/	u32	nc_dnad64;	/* DMA Next Address 64              */
86719c65091SMatthew Wilcox /*bc*/	u16	nc_scntl4;	/* C1010 only                       */
86819c65091SMatthew Wilcox 	#define   U3EN   0x80	/* Enable Ultra 3                   */
86919c65091SMatthew Wilcox 	#define   AIPEN	 0x40   /* Allow check upper byte lanes     */
87019c65091SMatthew Wilcox 	#define   XCLKH_DT 0x08 /* Extra clock of data hold on DT
87119c65091SMatthew Wilcox 					transfer edge	            */
87219c65091SMatthew Wilcox 	#define   XCLKH_ST 0x04 /* Extra clock of data hold on ST
87319c65091SMatthew Wilcox 					transfer edge	            */
87419c65091SMatthew Wilcox 
87519c65091SMatthew Wilcox /*be*/  u8	nc_aipcntl0;	/* Epat Control 1 C1010 only        */
87619c65091SMatthew Wilcox /*bf*/  u8	nc_aipcntl1;	/* AIP Control C1010_66 Only        */
87719c65091SMatthew Wilcox 
87819c65091SMatthew Wilcox /*c0*/	u32	nc_pmjad1;	/* Phase Mismatch Jump Address 1    */
87919c65091SMatthew Wilcox /*c4*/	u32	nc_pmjad2;	/* Phase Mismatch Jump Address 2    */
88019c65091SMatthew Wilcox /*c8*/	u8	nc_rbc;		/* Remaining Byte Count             */
88119c65091SMatthew Wilcox /*c9*/	u8	nc_rbc1;	/*                                  */
88219c65091SMatthew Wilcox /*ca*/	u8	nc_rbc2;	/*                                  */
88319c65091SMatthew Wilcox /*cb*/	u8	nc_rbc3;	/*                                  */
88419c65091SMatthew Wilcox 
88519c65091SMatthew Wilcox /*cc*/	u8	nc_ua;		/* Updated Address                  */
88619c65091SMatthew Wilcox /*cd*/	u8	nc_ua1;		/*                                  */
88719c65091SMatthew Wilcox /*ce*/	u8	nc_ua2;		/*                                  */
88819c65091SMatthew Wilcox /*cf*/	u8	nc_ua3;		/*                                  */
88919c65091SMatthew Wilcox /*d0*/	u32	nc_esa;		/* Entry Storage Address            */
89019c65091SMatthew Wilcox /*d4*/	u8	nc_ia;		/* Instruction Address              */
89119c65091SMatthew Wilcox /*d5*/	u8	nc_ia1;
89219c65091SMatthew Wilcox /*d6*/	u8	nc_ia2;
89319c65091SMatthew Wilcox /*d7*/	u8	nc_ia3;
89419c65091SMatthew Wilcox /*d8*/	u32	nc_sbc;		/* SCSI Byte Count (3 bytes only)   */
89519c65091SMatthew Wilcox /*dc*/	u32	nc_csbc;	/* Cumulative SCSI Byte Count       */
89619c65091SMatthew Wilcox 
89719c65091SMatthew Wilcox 				/* Following for C1010 only         */
89819c65091SMatthew Wilcox /*e0*/  u16	nc_crcpad;	/* CRC Value                        */
89919c65091SMatthew Wilcox /*e2*/  u8	nc_crccntl0;	/* CRC control register             */
90019c65091SMatthew Wilcox 	#define   SNDCRC  0x10	/* Send CRC Request                 */
90119c65091SMatthew Wilcox /*e3*/  u8	nc_crccntl1;	/* CRC control register             */
90219c65091SMatthew Wilcox /*e4*/  u32	nc_crcdata;	/* CRC data register                */
90319c65091SMatthew Wilcox /*e8*/  u32	nc_e8_;		/* rsvd 			    */
90419c65091SMatthew Wilcox /*ec*/  u32	nc_ec_;		/* rsvd 			    */
90519c65091SMatthew Wilcox /*f0*/  u16	nc_dfbc;	/* DMA FIFO byte count              */
90619c65091SMatthew Wilcox 
90719c65091SMatthew Wilcox };
90819c65091SMatthew Wilcox 
90919c65091SMatthew Wilcox /*-----------------------------------------------------------
91019c65091SMatthew Wilcox **
91119c65091SMatthew Wilcox **	Utility macros for the script.
91219c65091SMatthew Wilcox **
91319c65091SMatthew Wilcox **-----------------------------------------------------------
91419c65091SMatthew Wilcox */
91519c65091SMatthew Wilcox 
91619c65091SMatthew Wilcox #define REGJ(p,r) (offsetof(struct ncr_reg, p ## r))
91719c65091SMatthew Wilcox #define REG(r) REGJ (nc_, r)
91819c65091SMatthew Wilcox 
91919c65091SMatthew Wilcox typedef u32 ncrcmd;
92019c65091SMatthew Wilcox 
92119c65091SMatthew Wilcox /*-----------------------------------------------------------
92219c65091SMatthew Wilcox **
92319c65091SMatthew Wilcox **	SCSI phases
92419c65091SMatthew Wilcox **
92519c65091SMatthew Wilcox **	DT phases illegal for ncr driver.
92619c65091SMatthew Wilcox **
92719c65091SMatthew Wilcox **-----------------------------------------------------------
92819c65091SMatthew Wilcox */
92919c65091SMatthew Wilcox 
93019c65091SMatthew Wilcox #define	SCR_DATA_OUT	0x00000000
93119c65091SMatthew Wilcox #define	SCR_DATA_IN	0x01000000
93219c65091SMatthew Wilcox #define	SCR_COMMAND	0x02000000
93319c65091SMatthew Wilcox #define	SCR_STATUS	0x03000000
93419c65091SMatthew Wilcox #define SCR_DT_DATA_OUT	0x04000000
93519c65091SMatthew Wilcox #define SCR_DT_DATA_IN	0x05000000
93619c65091SMatthew Wilcox #define SCR_MSG_OUT	0x06000000
93719c65091SMatthew Wilcox #define SCR_MSG_IN      0x07000000
93819c65091SMatthew Wilcox 
93919c65091SMatthew Wilcox #define SCR_ILG_OUT	0x04000000
94019c65091SMatthew Wilcox #define SCR_ILG_IN	0x05000000
94119c65091SMatthew Wilcox 
94219c65091SMatthew Wilcox /*-----------------------------------------------------------
94319c65091SMatthew Wilcox **
94419c65091SMatthew Wilcox **	Data transfer via SCSI.
94519c65091SMatthew Wilcox **
94619c65091SMatthew Wilcox **-----------------------------------------------------------
94719c65091SMatthew Wilcox **
94819c65091SMatthew Wilcox **	MOVE_ABS (LEN)
94919c65091SMatthew Wilcox **	<<start address>>
95019c65091SMatthew Wilcox **
95119c65091SMatthew Wilcox **	MOVE_IND (LEN)
95219c65091SMatthew Wilcox **	<<dnad_offset>>
95319c65091SMatthew Wilcox **
95419c65091SMatthew Wilcox **	MOVE_TBL
95519c65091SMatthew Wilcox **	<<dnad_offset>>
95619c65091SMatthew Wilcox **
95719c65091SMatthew Wilcox **-----------------------------------------------------------
95819c65091SMatthew Wilcox */
95919c65091SMatthew Wilcox 
96019c65091SMatthew Wilcox #define OPC_MOVE          0x08000000
96119c65091SMatthew Wilcox 
96219c65091SMatthew Wilcox #define SCR_MOVE_ABS(l) ((0x00000000 | OPC_MOVE) | (l))
96319c65091SMatthew Wilcox #define SCR_MOVE_IND(l) ((0x20000000 | OPC_MOVE) | (l))
96419c65091SMatthew Wilcox #define SCR_MOVE_TBL     (0x10000000 | OPC_MOVE)
96519c65091SMatthew Wilcox 
96619c65091SMatthew Wilcox #define SCR_CHMOV_ABS(l) ((0x00000000) | (l))
96719c65091SMatthew Wilcox #define SCR_CHMOV_IND(l) ((0x20000000) | (l))
96819c65091SMatthew Wilcox #define SCR_CHMOV_TBL     (0x10000000)
96919c65091SMatthew Wilcox 
97019c65091SMatthew Wilcox struct scr_tblmove {
97119c65091SMatthew Wilcox         u32  size;
97219c65091SMatthew Wilcox         u32  addr;
97319c65091SMatthew Wilcox };
97419c65091SMatthew Wilcox 
97519c65091SMatthew Wilcox /*-----------------------------------------------------------
97619c65091SMatthew Wilcox **
97719c65091SMatthew Wilcox **	Selection
97819c65091SMatthew Wilcox **
97919c65091SMatthew Wilcox **-----------------------------------------------------------
98019c65091SMatthew Wilcox **
98119c65091SMatthew Wilcox **	SEL_ABS | SCR_ID (0..15)    [ | REL_JMP]
98219c65091SMatthew Wilcox **	<<alternate_address>>
98319c65091SMatthew Wilcox **
98419c65091SMatthew Wilcox **	SEL_TBL | << dnad_offset>>  [ | REL_JMP]
98519c65091SMatthew Wilcox **	<<alternate_address>>
98619c65091SMatthew Wilcox **
98719c65091SMatthew Wilcox **-----------------------------------------------------------
98819c65091SMatthew Wilcox */
98919c65091SMatthew Wilcox 
99019c65091SMatthew Wilcox #define	SCR_SEL_ABS	0x40000000
99119c65091SMatthew Wilcox #define	SCR_SEL_ABS_ATN	0x41000000
99219c65091SMatthew Wilcox #define	SCR_SEL_TBL	0x42000000
99319c65091SMatthew Wilcox #define	SCR_SEL_TBL_ATN	0x43000000
99419c65091SMatthew Wilcox 
99519c65091SMatthew Wilcox 
99619c65091SMatthew Wilcox #ifdef SCSI_NCR_BIG_ENDIAN
99719c65091SMatthew Wilcox struct scr_tblsel {
99819c65091SMatthew Wilcox         u8	sel_scntl3;
99919c65091SMatthew Wilcox         u8	sel_id;
100019c65091SMatthew Wilcox         u8	sel_sxfer;
100119c65091SMatthew Wilcox         u8	sel_scntl4;
100219c65091SMatthew Wilcox };
100319c65091SMatthew Wilcox #else
100419c65091SMatthew Wilcox struct scr_tblsel {
100519c65091SMatthew Wilcox         u8	sel_scntl4;
100619c65091SMatthew Wilcox         u8	sel_sxfer;
100719c65091SMatthew Wilcox         u8	sel_id;
100819c65091SMatthew Wilcox         u8	sel_scntl3;
100919c65091SMatthew Wilcox };
101019c65091SMatthew Wilcox #endif
101119c65091SMatthew Wilcox 
101219c65091SMatthew Wilcox #define SCR_JMP_REL     0x04000000
101319c65091SMatthew Wilcox #define SCR_ID(id)	(((u32)(id)) << 16)
101419c65091SMatthew Wilcox 
101519c65091SMatthew Wilcox /*-----------------------------------------------------------
101619c65091SMatthew Wilcox **
101719c65091SMatthew Wilcox **	Waiting for Disconnect or Reselect
101819c65091SMatthew Wilcox **
101919c65091SMatthew Wilcox **-----------------------------------------------------------
102019c65091SMatthew Wilcox **
102119c65091SMatthew Wilcox **	WAIT_DISC
102219c65091SMatthew Wilcox **	dummy: <<alternate_address>>
102319c65091SMatthew Wilcox **
102419c65091SMatthew Wilcox **	WAIT_RESEL
102519c65091SMatthew Wilcox **	<<alternate_address>>
102619c65091SMatthew Wilcox **
102719c65091SMatthew Wilcox **-----------------------------------------------------------
102819c65091SMatthew Wilcox */
102919c65091SMatthew Wilcox 
103019c65091SMatthew Wilcox #define	SCR_WAIT_DISC	0x48000000
103119c65091SMatthew Wilcox #define SCR_WAIT_RESEL  0x50000000
103219c65091SMatthew Wilcox 
103319c65091SMatthew Wilcox /*-----------------------------------------------------------
103419c65091SMatthew Wilcox **
103519c65091SMatthew Wilcox **	Bit Set / Reset
103619c65091SMatthew Wilcox **
103719c65091SMatthew Wilcox **-----------------------------------------------------------
103819c65091SMatthew Wilcox **
103919c65091SMatthew Wilcox **	SET (flags {|.. })
104019c65091SMatthew Wilcox **
104119c65091SMatthew Wilcox **	CLR (flags {|.. })
104219c65091SMatthew Wilcox **
104319c65091SMatthew Wilcox **-----------------------------------------------------------
104419c65091SMatthew Wilcox */
104519c65091SMatthew Wilcox 
104619c65091SMatthew Wilcox #define SCR_SET(f)     (0x58000000 | (f))
104719c65091SMatthew Wilcox #define SCR_CLR(f)     (0x60000000 | (f))
104819c65091SMatthew Wilcox 
104919c65091SMatthew Wilcox #define	SCR_CARRY	0x00000400
105019c65091SMatthew Wilcox #define	SCR_TRG		0x00000200
105119c65091SMatthew Wilcox #define	SCR_ACK		0x00000040
105219c65091SMatthew Wilcox #define	SCR_ATN		0x00000008
105319c65091SMatthew Wilcox 
105419c65091SMatthew Wilcox 
105519c65091SMatthew Wilcox 
105619c65091SMatthew Wilcox 
105719c65091SMatthew Wilcox /*-----------------------------------------------------------
105819c65091SMatthew Wilcox **
105919c65091SMatthew Wilcox **	Memory to memory move
106019c65091SMatthew Wilcox **
106119c65091SMatthew Wilcox **-----------------------------------------------------------
106219c65091SMatthew Wilcox **
106319c65091SMatthew Wilcox **	COPY (bytecount)
106419c65091SMatthew Wilcox **	<< source_address >>
106519c65091SMatthew Wilcox **	<< destination_address >>
106619c65091SMatthew Wilcox **
106719c65091SMatthew Wilcox **	SCR_COPY   sets the NO FLUSH option by default.
106819c65091SMatthew Wilcox **	SCR_COPY_F does not set this option.
106919c65091SMatthew Wilcox **
107019c65091SMatthew Wilcox **	For chips which do not support this option,
107119c65091SMatthew Wilcox **	ncr_copy_and_bind() will remove this bit.
107219c65091SMatthew Wilcox **-----------------------------------------------------------
107319c65091SMatthew Wilcox */
107419c65091SMatthew Wilcox 
107519c65091SMatthew Wilcox #define SCR_NO_FLUSH 0x01000000
107619c65091SMatthew Wilcox 
107719c65091SMatthew Wilcox #define SCR_COPY(n) (0xc0000000 | SCR_NO_FLUSH | (n))
107819c65091SMatthew Wilcox #define SCR_COPY_F(n) (0xc0000000 | (n))
107919c65091SMatthew Wilcox 
108019c65091SMatthew Wilcox /*-----------------------------------------------------------
108119c65091SMatthew Wilcox **
108219c65091SMatthew Wilcox **	Register move and binary operations
108319c65091SMatthew Wilcox **
108419c65091SMatthew Wilcox **-----------------------------------------------------------
108519c65091SMatthew Wilcox **
108619c65091SMatthew Wilcox **	SFBR_REG (reg, op, data)        reg  = SFBR op data
108719c65091SMatthew Wilcox **	<< 0 >>
108819c65091SMatthew Wilcox **
108919c65091SMatthew Wilcox **	REG_SFBR (reg, op, data)        SFBR = reg op data
109019c65091SMatthew Wilcox **	<< 0 >>
109119c65091SMatthew Wilcox **
109219c65091SMatthew Wilcox **	REG_REG  (reg, op, data)        reg  = reg op data
109319c65091SMatthew Wilcox **	<< 0 >>
109419c65091SMatthew Wilcox **
109519c65091SMatthew Wilcox **-----------------------------------------------------------
109619c65091SMatthew Wilcox **	On 810A, 860, 825A, 875, 895 and 896 chips the content
109719c65091SMatthew Wilcox **	of SFBR register can be used as data (SCR_SFBR_DATA).
109819c65091SMatthew Wilcox **	The 896 has additionnal IO registers starting at
109919c65091SMatthew Wilcox **	offset 0x80. Bit 7 of register offset is stored in
110019c65091SMatthew Wilcox **	bit 7 of the SCRIPTS instruction first DWORD.
110119c65091SMatthew Wilcox **-----------------------------------------------------------
110219c65091SMatthew Wilcox */
110319c65091SMatthew Wilcox 
110419c65091SMatthew Wilcox #define SCR_REG_OFS(ofs) ((((ofs) & 0x7f) << 16ul) + ((ofs) & 0x80))
110519c65091SMatthew Wilcox 
110619c65091SMatthew Wilcox #define SCR_SFBR_REG(reg,op,data) \
110719c65091SMatthew Wilcox         (0x68000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
110819c65091SMatthew Wilcox 
110919c65091SMatthew Wilcox #define SCR_REG_SFBR(reg,op,data) \
111019c65091SMatthew Wilcox         (0x70000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
111119c65091SMatthew Wilcox 
111219c65091SMatthew Wilcox #define SCR_REG_REG(reg,op,data) \
111319c65091SMatthew Wilcox         (0x78000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
111419c65091SMatthew Wilcox 
111519c65091SMatthew Wilcox 
111619c65091SMatthew Wilcox #define      SCR_LOAD   0x00000000
111719c65091SMatthew Wilcox #define      SCR_SHL    0x01000000
111819c65091SMatthew Wilcox #define      SCR_OR     0x02000000
111919c65091SMatthew Wilcox #define      SCR_XOR    0x03000000
112019c65091SMatthew Wilcox #define      SCR_AND    0x04000000
112119c65091SMatthew Wilcox #define      SCR_SHR    0x05000000
112219c65091SMatthew Wilcox #define      SCR_ADD    0x06000000
112319c65091SMatthew Wilcox #define      SCR_ADDC   0x07000000
112419c65091SMatthew Wilcox 
112519c65091SMatthew Wilcox #define      SCR_SFBR_DATA   (0x00800000>>8ul)	/* Use SFBR as data */
112619c65091SMatthew Wilcox 
112719c65091SMatthew Wilcox /*-----------------------------------------------------------
112819c65091SMatthew Wilcox **
112919c65091SMatthew Wilcox **	FROM_REG (reg)		  SFBR = reg
113019c65091SMatthew Wilcox **	<< 0 >>
113119c65091SMatthew Wilcox **
113219c65091SMatthew Wilcox **	TO_REG	 (reg)		  reg  = SFBR
113319c65091SMatthew Wilcox **	<< 0 >>
113419c65091SMatthew Wilcox **
113519c65091SMatthew Wilcox **	LOAD_REG (reg, data)	  reg  = <data>
113619c65091SMatthew Wilcox **	<< 0 >>
113719c65091SMatthew Wilcox **
113819c65091SMatthew Wilcox **	LOAD_SFBR(data) 	  SFBR = <data>
113919c65091SMatthew Wilcox **	<< 0 >>
114019c65091SMatthew Wilcox **
114119c65091SMatthew Wilcox **-----------------------------------------------------------
114219c65091SMatthew Wilcox */
114319c65091SMatthew Wilcox 
114419c65091SMatthew Wilcox #define	SCR_FROM_REG(reg) \
114519c65091SMatthew Wilcox 	SCR_REG_SFBR(reg,SCR_OR,0)
114619c65091SMatthew Wilcox 
114719c65091SMatthew Wilcox #define	SCR_TO_REG(reg) \
114819c65091SMatthew Wilcox 	SCR_SFBR_REG(reg,SCR_OR,0)
114919c65091SMatthew Wilcox 
115019c65091SMatthew Wilcox #define	SCR_LOAD_REG(reg,data) \
115119c65091SMatthew Wilcox 	SCR_REG_REG(reg,SCR_LOAD,data)
115219c65091SMatthew Wilcox 
115319c65091SMatthew Wilcox #define SCR_LOAD_SFBR(data) \
115419c65091SMatthew Wilcox         (SCR_REG_SFBR (gpreg, SCR_LOAD, data))
115519c65091SMatthew Wilcox 
115619c65091SMatthew Wilcox /*-----------------------------------------------------------
115719c65091SMatthew Wilcox **
115819c65091SMatthew Wilcox **	LOAD  from memory   to register.
115919c65091SMatthew Wilcox **	STORE from register to memory.
116019c65091SMatthew Wilcox **
116119c65091SMatthew Wilcox **	Only supported by 810A, 860, 825A, 875, 895 and 896.
116219c65091SMatthew Wilcox **
116319c65091SMatthew Wilcox **-----------------------------------------------------------
116419c65091SMatthew Wilcox **
116519c65091SMatthew Wilcox **	LOAD_ABS (LEN)
116619c65091SMatthew Wilcox **	<<start address>>
116719c65091SMatthew Wilcox **
116819c65091SMatthew Wilcox **	LOAD_REL (LEN)        (DSA relative)
116919c65091SMatthew Wilcox **	<<dsa_offset>>
117019c65091SMatthew Wilcox **
117119c65091SMatthew Wilcox **-----------------------------------------------------------
117219c65091SMatthew Wilcox */
117319c65091SMatthew Wilcox 
117419c65091SMatthew Wilcox #define SCR_REG_OFS2(ofs) (((ofs) & 0xff) << 16ul)
117519c65091SMatthew Wilcox #define SCR_NO_FLUSH2	0x02000000
117619c65091SMatthew Wilcox #define SCR_DSA_REL2	0x10000000
117719c65091SMatthew Wilcox 
117819c65091SMatthew Wilcox #define SCR_LOAD_R(reg, how, n) \
117919c65091SMatthew Wilcox         (0xe1000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
118019c65091SMatthew Wilcox 
118119c65091SMatthew Wilcox #define SCR_STORE_R(reg, how, n) \
118219c65091SMatthew Wilcox         (0xe0000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
118319c65091SMatthew Wilcox 
118419c65091SMatthew Wilcox #define SCR_LOAD_ABS(reg, n)	SCR_LOAD_R(reg, SCR_NO_FLUSH2, n)
118519c65091SMatthew Wilcox #define SCR_LOAD_REL(reg, n)	SCR_LOAD_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2, n)
118619c65091SMatthew Wilcox #define SCR_LOAD_ABS_F(reg, n)	SCR_LOAD_R(reg, 0, n)
118719c65091SMatthew Wilcox #define SCR_LOAD_REL_F(reg, n)	SCR_LOAD_R(reg, SCR_DSA_REL2, n)
118819c65091SMatthew Wilcox 
118919c65091SMatthew Wilcox #define SCR_STORE_ABS(reg, n)	SCR_STORE_R(reg, SCR_NO_FLUSH2, n)
119019c65091SMatthew Wilcox #define SCR_STORE_REL(reg, n)	SCR_STORE_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2,n)
119119c65091SMatthew Wilcox #define SCR_STORE_ABS_F(reg, n)	SCR_STORE_R(reg, 0, n)
119219c65091SMatthew Wilcox #define SCR_STORE_REL_F(reg, n)	SCR_STORE_R(reg, SCR_DSA_REL2, n)
119319c65091SMatthew Wilcox 
119419c65091SMatthew Wilcox 
119519c65091SMatthew Wilcox /*-----------------------------------------------------------
119619c65091SMatthew Wilcox **
119719c65091SMatthew Wilcox **	Waiting for Disconnect or Reselect
119819c65091SMatthew Wilcox **
119919c65091SMatthew Wilcox **-----------------------------------------------------------
120019c65091SMatthew Wilcox **
120119c65091SMatthew Wilcox **	JUMP            [ | IFTRUE/IFFALSE ( ... ) ]
120219c65091SMatthew Wilcox **	<<address>>
120319c65091SMatthew Wilcox **
120419c65091SMatthew Wilcox **	JUMPR           [ | IFTRUE/IFFALSE ( ... ) ]
120519c65091SMatthew Wilcox **	<<distance>>
120619c65091SMatthew Wilcox **
120719c65091SMatthew Wilcox **	CALL            [ | IFTRUE/IFFALSE ( ... ) ]
120819c65091SMatthew Wilcox **	<<address>>
120919c65091SMatthew Wilcox **
121019c65091SMatthew Wilcox **	CALLR           [ | IFTRUE/IFFALSE ( ... ) ]
121119c65091SMatthew Wilcox **	<<distance>>
121219c65091SMatthew Wilcox **
121319c65091SMatthew Wilcox **	RETURN          [ | IFTRUE/IFFALSE ( ... ) ]
121419c65091SMatthew Wilcox **	<<dummy>>
121519c65091SMatthew Wilcox **
121619c65091SMatthew Wilcox **	INT             [ | IFTRUE/IFFALSE ( ... ) ]
121719c65091SMatthew Wilcox **	<<ident>>
121819c65091SMatthew Wilcox **
121919c65091SMatthew Wilcox **	INT_FLY         [ | IFTRUE/IFFALSE ( ... ) ]
122019c65091SMatthew Wilcox **	<<ident>>
122119c65091SMatthew Wilcox **
122219c65091SMatthew Wilcox **	Conditions:
122319c65091SMatthew Wilcox **	     WHEN (phase)
122419c65091SMatthew Wilcox **	     IF   (phase)
122519c65091SMatthew Wilcox **	     CARRYSET
122619c65091SMatthew Wilcox **	     DATA (data, mask)
122719c65091SMatthew Wilcox **
122819c65091SMatthew Wilcox **-----------------------------------------------------------
122919c65091SMatthew Wilcox */
123019c65091SMatthew Wilcox 
123119c65091SMatthew Wilcox #define SCR_NO_OP       0x80000000
123219c65091SMatthew Wilcox #define SCR_JUMP        0x80080000
123319c65091SMatthew Wilcox #define SCR_JUMP64      0x80480000
123419c65091SMatthew Wilcox #define SCR_JUMPR       0x80880000
123519c65091SMatthew Wilcox #define SCR_CALL        0x88080000
123619c65091SMatthew Wilcox #define SCR_CALLR       0x88880000
123719c65091SMatthew Wilcox #define SCR_RETURN      0x90080000
123819c65091SMatthew Wilcox #define SCR_INT         0x98080000
123919c65091SMatthew Wilcox #define SCR_INT_FLY     0x98180000
124019c65091SMatthew Wilcox 
124119c65091SMatthew Wilcox #define IFFALSE(arg)   (0x00080000 | (arg))
124219c65091SMatthew Wilcox #define IFTRUE(arg)    (0x00000000 | (arg))
124319c65091SMatthew Wilcox 
124419c65091SMatthew Wilcox #define WHEN(phase)    (0x00030000 | (phase))
124519c65091SMatthew Wilcox #define IF(phase)      (0x00020000 | (phase))
124619c65091SMatthew Wilcox 
124719c65091SMatthew Wilcox #define DATA(D)        (0x00040000 | ((D) & 0xff))
124819c65091SMatthew Wilcox #define MASK(D,M)      (0x00040000 | (((M ^ 0xff) & 0xff) << 8ul)|((D) & 0xff))
124919c65091SMatthew Wilcox 
125019c65091SMatthew Wilcox #define CARRYSET       (0x00200000)
125119c65091SMatthew Wilcox 
125219c65091SMatthew Wilcox /*-----------------------------------------------------------
125319c65091SMatthew Wilcox **
125419c65091SMatthew Wilcox **	SCSI  constants.
125519c65091SMatthew Wilcox **
125619c65091SMatthew Wilcox **-----------------------------------------------------------
125719c65091SMatthew Wilcox */
125819c65091SMatthew Wilcox 
125919c65091SMatthew Wilcox /*
126019c65091SMatthew Wilcox **	Status
126119c65091SMatthew Wilcox */
126219c65091SMatthew Wilcox 
126319c65091SMatthew Wilcox #define	S_GOOD		(0x00)
126419c65091SMatthew Wilcox #define	S_CHECK_COND	(0x02)
126519c65091SMatthew Wilcox #define	S_COND_MET	(0x04)
126619c65091SMatthew Wilcox #define	S_BUSY		(0x08)
126719c65091SMatthew Wilcox #define	S_INT		(0x10)
126819c65091SMatthew Wilcox #define	S_INT_COND_MET	(0x14)
126919c65091SMatthew Wilcox #define	S_CONFLICT	(0x18)
127019c65091SMatthew Wilcox #define	S_TERMINATED	(0x20)
127119c65091SMatthew Wilcox #define	S_QUEUE_FULL	(0x28)
127219c65091SMatthew Wilcox #define	S_ILLEGAL	(0xff)
127319c65091SMatthew Wilcox #define	S_SENSE		(0x80)
127419c65091SMatthew Wilcox 
127519c65091SMatthew Wilcox /*
127619c65091SMatthew Wilcox  * End of ncrreg from FreeBSD
127719c65091SMatthew Wilcox  */
12781da177e4SLinus Torvalds 
12791da177e4SLinus Torvalds /*
12801da177e4SLinus Torvalds 	Build a scatter/gather entry.
12811da177e4SLinus Torvalds 	see sym53c8xx_2/sym_hipd.h for more detailed sym_build_sge()
12821da177e4SLinus Torvalds 	implementation ;)
12831da177e4SLinus Torvalds  */
12841da177e4SLinus Torvalds 
12851da177e4SLinus Torvalds #define ncr_build_sge(np, data, badd, len)	\
12861da177e4SLinus Torvalds do {						\
12871da177e4SLinus Torvalds 	(data)->addr = cpu_to_scr(badd);	\
12881da177e4SLinus Torvalds 	(data)->size = cpu_to_scr(len);		\
12891da177e4SLinus Torvalds } while (0)
12901da177e4SLinus Torvalds 
12911da177e4SLinus Torvalds /*==========================================================
12921da177e4SLinus Torvalds **
12931da177e4SLinus Torvalds **	Structures used by the detection routine to transmit
12941da177e4SLinus Torvalds **	device configuration to the attach function.
12951da177e4SLinus Torvalds **
12961da177e4SLinus Torvalds **==========================================================
12971da177e4SLinus Torvalds */
12981da177e4SLinus Torvalds struct ncr_slot {
12991da177e4SLinus Torvalds 	u_long	base;
13001da177e4SLinus Torvalds 	u_long	base_2;
13011da177e4SLinus Torvalds 	u_long	base_c;
13021da177e4SLinus Torvalds 	u_long	base_2_c;
13031da177e4SLinus Torvalds 	void __iomem *base_v;
13041da177e4SLinus Torvalds 	void __iomem *base_2_v;
13051da177e4SLinus Torvalds 	int	irq;
13061da177e4SLinus Torvalds /* port and reg fields to use INB, OUTB macros */
13071da177e4SLinus Torvalds 	volatile struct ncr_reg	__iomem *reg;
13081da177e4SLinus Torvalds };
13091da177e4SLinus Torvalds 
13101da177e4SLinus Torvalds /*==========================================================
13111da177e4SLinus Torvalds **
13121da177e4SLinus Torvalds **	Structure used by detection routine to save data on
13131da177e4SLinus Torvalds **	each detected board for attach.
13141da177e4SLinus Torvalds **
13151da177e4SLinus Torvalds **==========================================================
13161da177e4SLinus Torvalds */
13171da177e4SLinus Torvalds struct ncr_device {
13181da177e4SLinus Torvalds 	struct device  *dev;
13191da177e4SLinus Torvalds 	struct ncr_slot  slot;
13201da177e4SLinus Torvalds 	struct ncr_chip  chip;
13211da177e4SLinus Torvalds 	u_char host_id;
13221da177e4SLinus Torvalds 	u8 differential;
13231da177e4SLinus Torvalds };
13241da177e4SLinus Torvalds 
13251da177e4SLinus Torvalds extern struct Scsi_Host *ncr_attach(struct scsi_host_template *tpnt, int unit, struct ncr_device *device);
13261da177e4SLinus Torvalds extern int ncr53c8xx_release(struct Scsi_Host *host);
13271da177e4SLinus Torvalds irqreturn_t ncr53c8xx_intr(int irq, void *dev_id, struct pt_regs * regs);
13281da177e4SLinus Torvalds extern int ncr53c8xx_init(void);
13291da177e4SLinus Torvalds extern void ncr53c8xx_exit(void);
13301da177e4SLinus Torvalds 
13311da177e4SLinus Torvalds #endif /* NCR53C8XX_H */
1332