xref: /openbmc/linux/drivers/scsi/ncr53c8xx.h (revision 19c65091c133a98b20d867c94b1b1380a79e4b81)
11da177e4SLinus Torvalds /******************************************************************************
21da177e4SLinus Torvalds **  Device driver for the PCI-SCSI NCR538XX controller family.
31da177e4SLinus Torvalds **
41da177e4SLinus Torvalds **  Copyright (C) 1994  Wolfgang Stanglmeier
5*19c65091SMatthew 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 **
40*19c65091SMatthew Wilcox **  NVRAM detection and reading.
41*19c65091SMatthew Wilcox **    Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
42*19c65091SMatthew Wilcox **
43*19c65091SMatthew Wilcox **  Added support for MIPS big endian systems.
44*19c65091SMatthew Wilcox **    Carsten Langgaard, carstenl@mips.com
45*19c65091SMatthew Wilcox **    Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
46*19c65091SMatthew Wilcox **
47*19c65091SMatthew Wilcox **  Added support for HP PARISC big endian systems.
48*19c65091SMatthew Wilcox **    Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
49*19c65091SMatthew Wilcox **
501da177e4SLinus Torvalds *******************************************************************************
511da177e4SLinus Torvalds */
521da177e4SLinus Torvalds 
531da177e4SLinus Torvalds #ifndef NCR53C8XX_H
541da177e4SLinus Torvalds #define NCR53C8XX_H
551da177e4SLinus Torvalds 
56*19c65091SMatthew Wilcox #include <linux/config.h>
571da177e4SLinus Torvalds #include <scsi/scsi_host.h>
581da177e4SLinus Torvalds 
59*19c65091SMatthew Wilcox /*
60*19c65091SMatthew Wilcox **	If you want a driver as small as possible, do not define the
61*19c65091SMatthew Wilcox **	following options.
62*19c65091SMatthew Wilcox */
63*19c65091SMatthew Wilcox #define SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
64*19c65091SMatthew Wilcox #define SCSI_NCR_DEBUG_INFO_SUPPORT
65*19c65091SMatthew Wilcox 
66*19c65091SMatthew Wilcox /*
67*19c65091SMatthew Wilcox **	To disable integrity checking, do not define the
68*19c65091SMatthew Wilcox **	following option.
69*19c65091SMatthew Wilcox */
70*19c65091SMatthew Wilcox #ifdef	CONFIG_SCSI_NCR53C8XX_INTEGRITY_CHECK
71*19c65091SMatthew Wilcox #	define SCSI_NCR_ENABLE_INTEGRITY_CHECK
72*19c65091SMatthew Wilcox #endif
73*19c65091SMatthew Wilcox 
74*19c65091SMatthew Wilcox /* ---------------------------------------------------------------------
75*19c65091SMatthew Wilcox ** Take into account kernel configured parameters.
76*19c65091SMatthew Wilcox ** Most of these options can be overridden at startup by a command line.
77*19c65091SMatthew Wilcox ** ---------------------------------------------------------------------
78*19c65091SMatthew Wilcox */
79*19c65091SMatthew Wilcox 
80*19c65091SMatthew Wilcox /*
81*19c65091SMatthew Wilcox  * For Ultra2 and Ultra3 SCSI support option, use special features.
82*19c65091SMatthew Wilcox  *
83*19c65091SMatthew Wilcox  * Value (default) means:
84*19c65091SMatthew Wilcox  *	bit 0 : all features enabled, except:
85*19c65091SMatthew Wilcox  *		bit 1 : PCI Write And Invalidate.
86*19c65091SMatthew Wilcox  *		bit 2 : Data Phase Mismatch handling from SCRIPTS.
87*19c65091SMatthew Wilcox  *
88*19c65091SMatthew Wilcox  * Use boot options ncr53c8xx=specf:1 if you want all chip features to be
89*19c65091SMatthew Wilcox  * enabled by the driver.
90*19c65091SMatthew Wilcox  */
91*19c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_SPECIAL_FEATURES		(3)
92*19c65091SMatthew Wilcox 
93*19c65091SMatthew Wilcox #define SCSI_NCR_MAX_SYNC			(80)
94*19c65091SMatthew Wilcox 
95*19c65091SMatthew Wilcox /*
96*19c65091SMatthew Wilcox  * Allow tags from 2 to 256, default 8
97*19c65091SMatthew Wilcox  */
98*19c65091SMatthew Wilcox #ifdef	CONFIG_SCSI_NCR53C8XX_MAX_TAGS
99*19c65091SMatthew Wilcox #if	CONFIG_SCSI_NCR53C8XX_MAX_TAGS < 2
100*19c65091SMatthew Wilcox #define SCSI_NCR_MAX_TAGS	(2)
101*19c65091SMatthew Wilcox #elif	CONFIG_SCSI_NCR53C8XX_MAX_TAGS > 256
102*19c65091SMatthew Wilcox #define SCSI_NCR_MAX_TAGS	(256)
103*19c65091SMatthew Wilcox #else
104*19c65091SMatthew Wilcox #define	SCSI_NCR_MAX_TAGS	CONFIG_SCSI_NCR53C8XX_MAX_TAGS
105*19c65091SMatthew Wilcox #endif
106*19c65091SMatthew Wilcox #else
107*19c65091SMatthew Wilcox #define SCSI_NCR_MAX_TAGS	(8)
108*19c65091SMatthew Wilcox #endif
109*19c65091SMatthew Wilcox 
110*19c65091SMatthew Wilcox /*
111*19c65091SMatthew Wilcox  * Allow tagged command queuing support if configured with default number
112*19c65091SMatthew Wilcox  * of tags set to max (see above).
113*19c65091SMatthew Wilcox  */
114*19c65091SMatthew Wilcox #ifdef	CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS
115*19c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_DEFAULT_TAGS	CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS
116*19c65091SMatthew Wilcox #elif	defined CONFIG_SCSI_NCR53C8XX_TAGGED_QUEUE
117*19c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_DEFAULT_TAGS	SCSI_NCR_MAX_TAGS
118*19c65091SMatthew Wilcox #else
119*19c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_DEFAULT_TAGS	(0)
120*19c65091SMatthew Wilcox #endif
121*19c65091SMatthew Wilcox 
122*19c65091SMatthew Wilcox /*
123*19c65091SMatthew Wilcox  * Immediate arbitration
124*19c65091SMatthew Wilcox  */
125*19c65091SMatthew Wilcox #if defined(CONFIG_SCSI_NCR53C8XX_IARB)
126*19c65091SMatthew Wilcox #define SCSI_NCR_IARB_SUPPORT
127*19c65091SMatthew Wilcox #endif
128*19c65091SMatthew Wilcox 
129*19c65091SMatthew Wilcox /*
130*19c65091SMatthew Wilcox  * Sync transfer frequency at startup.
131*19c65091SMatthew Wilcox  * Allow from 5Mhz to 80Mhz default 20 Mhz.
132*19c65091SMatthew Wilcox  */
133*19c65091SMatthew Wilcox #ifndef	CONFIG_SCSI_NCR53C8XX_SYNC
134*19c65091SMatthew Wilcox #define	CONFIG_SCSI_NCR53C8XX_SYNC	(20)
135*19c65091SMatthew Wilcox #elif	CONFIG_SCSI_NCR53C8XX_SYNC > SCSI_NCR_MAX_SYNC
136*19c65091SMatthew Wilcox #undef	CONFIG_SCSI_NCR53C8XX_SYNC
137*19c65091SMatthew Wilcox #define	CONFIG_SCSI_NCR53C8XX_SYNC	SCSI_NCR_MAX_SYNC
138*19c65091SMatthew Wilcox #endif
139*19c65091SMatthew Wilcox 
140*19c65091SMatthew Wilcox #if	CONFIG_SCSI_NCR53C8XX_SYNC == 0
141*19c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_DEFAULT_SYNC	(255)
142*19c65091SMatthew Wilcox #elif	CONFIG_SCSI_NCR53C8XX_SYNC <= 5
143*19c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_DEFAULT_SYNC	(50)
144*19c65091SMatthew Wilcox #elif	CONFIG_SCSI_NCR53C8XX_SYNC <= 20
145*19c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_DEFAULT_SYNC	(250/(CONFIG_SCSI_NCR53C8XX_SYNC))
146*19c65091SMatthew Wilcox #elif	CONFIG_SCSI_NCR53C8XX_SYNC <= 33
147*19c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_DEFAULT_SYNC	(11)
148*19c65091SMatthew Wilcox #elif	CONFIG_SCSI_NCR53C8XX_SYNC <= 40
149*19c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_DEFAULT_SYNC	(10)
150*19c65091SMatthew Wilcox #else
151*19c65091SMatthew Wilcox #define	SCSI_NCR_SETUP_DEFAULT_SYNC 	(9)
152*19c65091SMatthew Wilcox #endif
153*19c65091SMatthew Wilcox 
154*19c65091SMatthew Wilcox /*
155*19c65091SMatthew Wilcox  * Disallow disconnections at boot-up
156*19c65091SMatthew Wilcox  */
157*19c65091SMatthew Wilcox #ifdef CONFIG_SCSI_NCR53C8XX_NO_DISCONNECT
158*19c65091SMatthew Wilcox #define SCSI_NCR_SETUP_DISCONNECTION	(0)
159*19c65091SMatthew Wilcox #else
160*19c65091SMatthew Wilcox #define SCSI_NCR_SETUP_DISCONNECTION	(1)
161*19c65091SMatthew Wilcox #endif
162*19c65091SMatthew Wilcox 
163*19c65091SMatthew Wilcox /*
164*19c65091SMatthew Wilcox  * Force synchronous negotiation for all targets
165*19c65091SMatthew Wilcox  */
166*19c65091SMatthew Wilcox #ifdef CONFIG_SCSI_NCR53C8XX_FORCE_SYNC_NEGO
167*19c65091SMatthew Wilcox #define SCSI_NCR_SETUP_FORCE_SYNC_NEGO	(1)
168*19c65091SMatthew Wilcox #else
169*19c65091SMatthew Wilcox #define SCSI_NCR_SETUP_FORCE_SYNC_NEGO	(0)
170*19c65091SMatthew Wilcox #endif
171*19c65091SMatthew Wilcox 
172*19c65091SMatthew Wilcox /*
173*19c65091SMatthew Wilcox  * Disable master parity checking (flawed hardwares need that)
174*19c65091SMatthew Wilcox  */
175*19c65091SMatthew Wilcox #ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_MPARITY_CHECK
176*19c65091SMatthew Wilcox #define SCSI_NCR_SETUP_MASTER_PARITY	(0)
177*19c65091SMatthew Wilcox #else
178*19c65091SMatthew Wilcox #define SCSI_NCR_SETUP_MASTER_PARITY	(1)
179*19c65091SMatthew Wilcox #endif
180*19c65091SMatthew Wilcox 
181*19c65091SMatthew Wilcox /*
182*19c65091SMatthew Wilcox  * Disable scsi parity checking (flawed devices may need that)
183*19c65091SMatthew Wilcox  */
184*19c65091SMatthew Wilcox #ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_PARITY_CHECK
185*19c65091SMatthew Wilcox #define SCSI_NCR_SETUP_SCSI_PARITY	(0)
186*19c65091SMatthew Wilcox #else
187*19c65091SMatthew Wilcox #define SCSI_NCR_SETUP_SCSI_PARITY	(1)
188*19c65091SMatthew Wilcox #endif
189*19c65091SMatthew Wilcox 
190*19c65091SMatthew Wilcox /*
191*19c65091SMatthew Wilcox  * Settle time after reset at boot-up
192*19c65091SMatthew Wilcox  */
193*19c65091SMatthew Wilcox #define SCSI_NCR_SETUP_SETTLE_TIME	(2)
194*19c65091SMatthew Wilcox 
195*19c65091SMatthew Wilcox /*
196*19c65091SMatthew Wilcox **	Bridge quirks work-around option defaulted to 1.
197*19c65091SMatthew Wilcox */
198*19c65091SMatthew Wilcox #ifndef	SCSI_NCR_PCIQ_WORK_AROUND_OPT
199*19c65091SMatthew Wilcox #define	SCSI_NCR_PCIQ_WORK_AROUND_OPT	1
200*19c65091SMatthew Wilcox #endif
201*19c65091SMatthew Wilcox 
202*19c65091SMatthew Wilcox /*
203*19c65091SMatthew Wilcox **	Work-around common bridge misbehaviour.
204*19c65091SMatthew Wilcox **
205*19c65091SMatthew Wilcox **	- Do not flush posted writes in the opposite
206*19c65091SMatthew Wilcox **	  direction on read.
207*19c65091SMatthew Wilcox **	- May reorder DMA writes to memory.
208*19c65091SMatthew Wilcox **
209*19c65091SMatthew Wilcox **	This option should not affect performances
210*19c65091SMatthew Wilcox **	significantly, so it is the default.
211*19c65091SMatthew Wilcox */
212*19c65091SMatthew Wilcox #if	SCSI_NCR_PCIQ_WORK_AROUND_OPT == 1
213*19c65091SMatthew Wilcox #define	SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM
214*19c65091SMatthew Wilcox #define	SCSI_NCR_PCIQ_MAY_REORDER_WRITES
215*19c65091SMatthew Wilcox #define	SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS
216*19c65091SMatthew Wilcox 
217*19c65091SMatthew Wilcox /*
218*19c65091SMatthew Wilcox **	Same as option 1, but also deal with
219*19c65091SMatthew Wilcox **	misconfigured interrupts.
220*19c65091SMatthew Wilcox **
221*19c65091SMatthew Wilcox **	- Edge triggerred instead of level sensitive.
222*19c65091SMatthew Wilcox **	- No interrupt line connected.
223*19c65091SMatthew Wilcox **	- IRQ number misconfigured.
224*19c65091SMatthew Wilcox **
225*19c65091SMatthew Wilcox **	If no interrupt is delivered, the driver will
226*19c65091SMatthew Wilcox **	catch the interrupt conditions 10 times per
227*19c65091SMatthew Wilcox **	second. No need to say that this option is
228*19c65091SMatthew Wilcox **	not recommended.
229*19c65091SMatthew Wilcox */
230*19c65091SMatthew Wilcox #elif	SCSI_NCR_PCIQ_WORK_AROUND_OPT == 2
231*19c65091SMatthew Wilcox #define	SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM
232*19c65091SMatthew Wilcox #define	SCSI_NCR_PCIQ_MAY_REORDER_WRITES
233*19c65091SMatthew Wilcox #define	SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS
234*19c65091SMatthew Wilcox #define	SCSI_NCR_PCIQ_BROKEN_INTR
235*19c65091SMatthew Wilcox 
236*19c65091SMatthew Wilcox /*
237*19c65091SMatthew Wilcox **	Some bridge designers decided to flush
238*19c65091SMatthew Wilcox **	everything prior to deliver the interrupt.
239*19c65091SMatthew Wilcox **	This option tries to deal with such a
240*19c65091SMatthew Wilcox **	behaviour.
241*19c65091SMatthew Wilcox */
242*19c65091SMatthew Wilcox #elif	SCSI_NCR_PCIQ_WORK_AROUND_OPT == 3
243*19c65091SMatthew Wilcox #define	SCSI_NCR_PCIQ_SYNC_ON_INTR
244*19c65091SMatthew Wilcox #endif
245*19c65091SMatthew Wilcox 
246*19c65091SMatthew Wilcox /*
247*19c65091SMatthew Wilcox **	Other parameters not configurable with "make config"
248*19c65091SMatthew Wilcox **	Avoid to change these constants, unless you know what you are doing.
249*19c65091SMatthew Wilcox */
250*19c65091SMatthew Wilcox 
251*19c65091SMatthew Wilcox #define SCSI_NCR_ALWAYS_SIMPLE_TAG
252*19c65091SMatthew Wilcox #define SCSI_NCR_MAX_SCATTER	(127)
253*19c65091SMatthew Wilcox #define SCSI_NCR_MAX_TARGET	(16)
254*19c65091SMatthew Wilcox 
255*19c65091SMatthew Wilcox /*
256*19c65091SMatthew Wilcox **   Compute some desirable value for CAN_QUEUE
257*19c65091SMatthew Wilcox **   and CMD_PER_LUN.
258*19c65091SMatthew Wilcox **   The driver will use lower values if these
259*19c65091SMatthew Wilcox **   ones appear to be too large.
260*19c65091SMatthew Wilcox */
261*19c65091SMatthew Wilcox #define SCSI_NCR_CAN_QUEUE	(8*SCSI_NCR_MAX_TAGS + 2*SCSI_NCR_MAX_TARGET)
262*19c65091SMatthew Wilcox #define SCSI_NCR_CMD_PER_LUN	(SCSI_NCR_MAX_TAGS)
263*19c65091SMatthew Wilcox 
264*19c65091SMatthew Wilcox #define SCSI_NCR_SG_TABLESIZE	(SCSI_NCR_MAX_SCATTER)
265*19c65091SMatthew Wilcox #define SCSI_NCR_TIMER_INTERVAL	(HZ)
266*19c65091SMatthew Wilcox 
267*19c65091SMatthew Wilcox #if 1 /* defined CONFIG_SCSI_MULTI_LUN */
268*19c65091SMatthew Wilcox #define SCSI_NCR_MAX_LUN	(16)
269*19c65091SMatthew Wilcox #else
270*19c65091SMatthew Wilcox #define SCSI_NCR_MAX_LUN	(1)
271*19c65091SMatthew Wilcox #endif
272*19c65091SMatthew Wilcox 
273*19c65091SMatthew Wilcox /*
274*19c65091SMatthew Wilcox  *  IO functions definition for big/little endian CPU support.
275*19c65091SMatthew Wilcox  *  For now, the NCR is only supported in little endian addressing mode,
276*19c65091SMatthew Wilcox  */
277*19c65091SMatthew Wilcox 
278*19c65091SMatthew Wilcox #ifdef	__BIG_ENDIAN
279*19c65091SMatthew Wilcox 
280*19c65091SMatthew Wilcox #define	inw_l2b		inw
281*19c65091SMatthew Wilcox #define	inl_l2b		inl
282*19c65091SMatthew Wilcox #define	outw_b2l	outw
283*19c65091SMatthew Wilcox #define	outl_b2l	outl
284*19c65091SMatthew Wilcox 
285*19c65091SMatthew Wilcox #define	readb_raw	readb
286*19c65091SMatthew Wilcox #define	writeb_raw	writeb
287*19c65091SMatthew Wilcox 
288*19c65091SMatthew Wilcox #if defined(SCSI_NCR_BIG_ENDIAN)
289*19c65091SMatthew Wilcox #define	readw_l2b	__raw_readw
290*19c65091SMatthew Wilcox #define	readl_l2b	__raw_readl
291*19c65091SMatthew Wilcox #define	writew_b2l	__raw_writew
292*19c65091SMatthew Wilcox #define	writel_b2l	__raw_writel
293*19c65091SMatthew Wilcox #define	readw_raw	__raw_readw
294*19c65091SMatthew Wilcox #define	readl_raw	__raw_readl
295*19c65091SMatthew Wilcox #define	writew_raw	__raw_writew
296*19c65091SMatthew Wilcox #define	writel_raw	__raw_writel
297*19c65091SMatthew Wilcox #else	/* Other big-endian */
298*19c65091SMatthew Wilcox #define	readw_l2b	readw
299*19c65091SMatthew Wilcox #define	readl_l2b	readl
300*19c65091SMatthew Wilcox #define	writew_b2l	writew
301*19c65091SMatthew Wilcox #define	writel_b2l	writel
302*19c65091SMatthew Wilcox #define	readw_raw	readw
303*19c65091SMatthew Wilcox #define	readl_raw	readl
304*19c65091SMatthew Wilcox #define	writew_raw	writew
305*19c65091SMatthew Wilcox #define	writel_raw	writel
306*19c65091SMatthew Wilcox #endif
307*19c65091SMatthew Wilcox 
308*19c65091SMatthew Wilcox #else	/* little endian */
309*19c65091SMatthew Wilcox 
310*19c65091SMatthew Wilcox #define	inw_raw		inw
311*19c65091SMatthew Wilcox #define	inl_raw		inl
312*19c65091SMatthew Wilcox #define	outw_raw	outw
313*19c65091SMatthew Wilcox #define	outl_raw	outl
314*19c65091SMatthew Wilcox 
315*19c65091SMatthew Wilcox #define	readb_raw	readb
316*19c65091SMatthew Wilcox #define	readw_raw	readw
317*19c65091SMatthew Wilcox #define	readl_raw	readl
318*19c65091SMatthew Wilcox #define	writeb_raw	writeb
319*19c65091SMatthew Wilcox #define	writew_raw	writew
320*19c65091SMatthew Wilcox #define	writel_raw	writel
321*19c65091SMatthew Wilcox 
322*19c65091SMatthew Wilcox #endif
323*19c65091SMatthew Wilcox 
324*19c65091SMatthew Wilcox #if !defined(__hppa__) && !defined(__mips__)
325*19c65091SMatthew Wilcox #ifdef	SCSI_NCR_BIG_ENDIAN
326*19c65091SMatthew Wilcox #error	"The NCR in BIG ENDIAN addressing mode is not (yet) supported"
327*19c65091SMatthew Wilcox #endif
328*19c65091SMatthew Wilcox #endif
329*19c65091SMatthew Wilcox 
330*19c65091SMatthew Wilcox #define MEMORY_BARRIER()	mb()
331*19c65091SMatthew Wilcox 
332*19c65091SMatthew Wilcox 
333*19c65091SMatthew Wilcox /*
334*19c65091SMatthew Wilcox  *  If the NCR uses big endian addressing mode over the
335*19c65091SMatthew Wilcox  *  PCI, actual io register addresses for byte and word
336*19c65091SMatthew Wilcox  *  accesses must be changed according to lane routing.
337*19c65091SMatthew Wilcox  *  Btw, ncr_offb() and ncr_offw() macros only apply to
338*19c65091SMatthew Wilcox  *  constants and so donnot generate bloated code.
339*19c65091SMatthew Wilcox  */
340*19c65091SMatthew Wilcox 
341*19c65091SMatthew Wilcox #if	defined(SCSI_NCR_BIG_ENDIAN)
342*19c65091SMatthew Wilcox 
343*19c65091SMatthew Wilcox #define ncr_offb(o)	(((o)&~3)+((~((o)&3))&3))
344*19c65091SMatthew Wilcox #define ncr_offw(o)	(((o)&~3)+((~((o)&3))&2))
345*19c65091SMatthew Wilcox 
346*19c65091SMatthew Wilcox #else
347*19c65091SMatthew Wilcox 
348*19c65091SMatthew Wilcox #define ncr_offb(o)	(o)
349*19c65091SMatthew Wilcox #define ncr_offw(o)	(o)
350*19c65091SMatthew Wilcox 
351*19c65091SMatthew Wilcox #endif
352*19c65091SMatthew Wilcox 
353*19c65091SMatthew Wilcox /*
354*19c65091SMatthew Wilcox  *  If the CPU and the NCR use same endian-ness addressing,
355*19c65091SMatthew Wilcox  *  no byte reordering is needed for script patching.
356*19c65091SMatthew Wilcox  *  Macro cpu_to_scr() is to be used for script patching.
357*19c65091SMatthew Wilcox  *  Macro scr_to_cpu() is to be used for getting a DWORD
358*19c65091SMatthew Wilcox  *  from the script.
359*19c65091SMatthew Wilcox  */
360*19c65091SMatthew Wilcox 
361*19c65091SMatthew Wilcox #if	defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)
362*19c65091SMatthew Wilcox 
363*19c65091SMatthew Wilcox #define cpu_to_scr(dw)	cpu_to_le32(dw)
364*19c65091SMatthew Wilcox #define scr_to_cpu(dw)	le32_to_cpu(dw)
365*19c65091SMatthew Wilcox 
366*19c65091SMatthew Wilcox #elif	defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)
367*19c65091SMatthew Wilcox 
368*19c65091SMatthew Wilcox #define cpu_to_scr(dw)	cpu_to_be32(dw)
369*19c65091SMatthew Wilcox #define scr_to_cpu(dw)	be32_to_cpu(dw)
370*19c65091SMatthew Wilcox 
371*19c65091SMatthew Wilcox #else
372*19c65091SMatthew Wilcox 
373*19c65091SMatthew Wilcox #define cpu_to_scr(dw)	(dw)
374*19c65091SMatthew Wilcox #define scr_to_cpu(dw)	(dw)
375*19c65091SMatthew Wilcox 
376*19c65091SMatthew Wilcox #endif
377*19c65091SMatthew Wilcox 
378*19c65091SMatthew Wilcox /*
379*19c65091SMatthew Wilcox  *  Access to the controller chip.
380*19c65091SMatthew Wilcox  *
381*19c65091SMatthew Wilcox  *  If the CPU and the NCR use same endian-ness addressing,
382*19c65091SMatthew Wilcox  *  no byte reordering is needed for accessing chip io
383*19c65091SMatthew Wilcox  *  registers. Functions suffixed by '_raw' are assumed
384*19c65091SMatthew Wilcox  *  to access the chip over the PCI without doing byte
385*19c65091SMatthew Wilcox  *  reordering. Functions suffixed by '_l2b' are
386*19c65091SMatthew Wilcox  *  assumed to perform little-endian to big-endian byte
387*19c65091SMatthew Wilcox  *  reordering, those suffixed by '_b2l' blah, blah,
388*19c65091SMatthew Wilcox  *  blah, ...
389*19c65091SMatthew Wilcox  */
390*19c65091SMatthew Wilcox 
391*19c65091SMatthew Wilcox /*
392*19c65091SMatthew Wilcox  *  MEMORY mapped IO input / output
393*19c65091SMatthew Wilcox  */
394*19c65091SMatthew Wilcox 
395*19c65091SMatthew Wilcox #define INB_OFF(o)		readb_raw((char __iomem *)np->reg + ncr_offb(o))
396*19c65091SMatthew Wilcox #define OUTB_OFF(o, val)	writeb_raw((val), (char __iomem *)np->reg + ncr_offb(o))
397*19c65091SMatthew Wilcox 
398*19c65091SMatthew Wilcox #if	defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)
399*19c65091SMatthew Wilcox 
400*19c65091SMatthew Wilcox #define INW_OFF(o)		readw_l2b((char __iomem *)np->reg + ncr_offw(o))
401*19c65091SMatthew Wilcox #define INL_OFF(o)		readl_l2b((char __iomem *)np->reg + (o))
402*19c65091SMatthew Wilcox 
403*19c65091SMatthew Wilcox #define OUTW_OFF(o, val)	writew_b2l((val), (char __iomem *)np->reg + ncr_offw(o))
404*19c65091SMatthew Wilcox #define OUTL_OFF(o, val)	writel_b2l((val), (char __iomem *)np->reg + (o))
405*19c65091SMatthew Wilcox 
406*19c65091SMatthew Wilcox #elif	defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)
407*19c65091SMatthew Wilcox 
408*19c65091SMatthew Wilcox #define INW_OFF(o)		readw_b2l((char __iomem *)np->reg + ncr_offw(o))
409*19c65091SMatthew Wilcox #define INL_OFF(o)		readl_b2l((char __iomem *)np->reg + (o))
410*19c65091SMatthew Wilcox 
411*19c65091SMatthew Wilcox #define OUTW_OFF(o, val)	writew_l2b((val), (char __iomem *)np->reg + ncr_offw(o))
412*19c65091SMatthew Wilcox #define OUTL_OFF(o, val)	writel_l2b((val), (char __iomem *)np->reg + (o))
413*19c65091SMatthew Wilcox 
414*19c65091SMatthew Wilcox #else
415*19c65091SMatthew Wilcox 
416*19c65091SMatthew Wilcox #ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
417*19c65091SMatthew Wilcox /* Only 8 or 32 bit transfers allowed */
418*19c65091SMatthew Wilcox #define INW_OFF(o)		(readb((char __iomem *)np->reg + ncr_offw(o)) << 8 | readb((char __iomem *)np->reg + ncr_offw(o) + 1))
419*19c65091SMatthew Wilcox #else
420*19c65091SMatthew Wilcox #define INW_OFF(o)		readw_raw((char __iomem *)np->reg + ncr_offw(o))
421*19c65091SMatthew Wilcox #endif
422*19c65091SMatthew Wilcox #define INL_OFF(o)		readl_raw((char __iomem *)np->reg + (o))
423*19c65091SMatthew Wilcox 
424*19c65091SMatthew Wilcox #ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
425*19c65091SMatthew Wilcox /* Only 8 or 32 bit transfers allowed */
426*19c65091SMatthew 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)
427*19c65091SMatthew Wilcox #else
428*19c65091SMatthew Wilcox #define OUTW_OFF(o, val)	writew_raw((val), (char __iomem *)np->reg + ncr_offw(o))
429*19c65091SMatthew Wilcox #endif
430*19c65091SMatthew Wilcox #define OUTL_OFF(o, val)	writel_raw((val), (char __iomem *)np->reg + (o))
431*19c65091SMatthew Wilcox 
432*19c65091SMatthew Wilcox #endif
433*19c65091SMatthew Wilcox 
434*19c65091SMatthew Wilcox #define INB(r)		INB_OFF (offsetof(struct ncr_reg,r))
435*19c65091SMatthew Wilcox #define INW(r)		INW_OFF (offsetof(struct ncr_reg,r))
436*19c65091SMatthew Wilcox #define INL(r)		INL_OFF (offsetof(struct ncr_reg,r))
437*19c65091SMatthew Wilcox 
438*19c65091SMatthew Wilcox #define OUTB(r, val)	OUTB_OFF (offsetof(struct ncr_reg,r), (val))
439*19c65091SMatthew Wilcox #define OUTW(r, val)	OUTW_OFF (offsetof(struct ncr_reg,r), (val))
440*19c65091SMatthew Wilcox #define OUTL(r, val)	OUTL_OFF (offsetof(struct ncr_reg,r), (val))
441*19c65091SMatthew Wilcox 
442*19c65091SMatthew Wilcox /*
443*19c65091SMatthew Wilcox  *  Set bit field ON, OFF
444*19c65091SMatthew Wilcox  */
445*19c65091SMatthew Wilcox 
446*19c65091SMatthew Wilcox #define OUTONB(r, m)	OUTB(r, INB(r) | (m))
447*19c65091SMatthew Wilcox #define OUTOFFB(r, m)	OUTB(r, INB(r) & ~(m))
448*19c65091SMatthew Wilcox #define OUTONW(r, m)	OUTW(r, INW(r) | (m))
449*19c65091SMatthew Wilcox #define OUTOFFW(r, m)	OUTW(r, INW(r) & ~(m))
450*19c65091SMatthew Wilcox #define OUTONL(r, m)	OUTL(r, INL(r) | (m))
451*19c65091SMatthew Wilcox #define OUTOFFL(r, m)	OUTL(r, INL(r) & ~(m))
452*19c65091SMatthew Wilcox 
453*19c65091SMatthew Wilcox /*
454*19c65091SMatthew Wilcox  *  We normally want the chip to have a consistent view
455*19c65091SMatthew Wilcox  *  of driver internal data structures when we restart it.
456*19c65091SMatthew Wilcox  *  Thus these macros.
457*19c65091SMatthew Wilcox  */
458*19c65091SMatthew Wilcox #define OUTL_DSP(v)				\
459*19c65091SMatthew Wilcox 	do {					\
460*19c65091SMatthew Wilcox 		MEMORY_BARRIER();		\
461*19c65091SMatthew Wilcox 		OUTL (nc_dsp, (v));		\
462*19c65091SMatthew Wilcox 	} while (0)
463*19c65091SMatthew Wilcox 
464*19c65091SMatthew Wilcox #define OUTONB_STD()				\
465*19c65091SMatthew Wilcox 	do {					\
466*19c65091SMatthew Wilcox 		MEMORY_BARRIER();		\
467*19c65091SMatthew Wilcox 		OUTONB (nc_dcntl, (STD|NOCOM));	\
468*19c65091SMatthew Wilcox 	} while (0)
469*19c65091SMatthew Wilcox 
470*19c65091SMatthew Wilcox 
471*19c65091SMatthew Wilcox /*
472*19c65091SMatthew Wilcox **   NCR53C8XX devices features table.
473*19c65091SMatthew Wilcox */
474*19c65091SMatthew Wilcox struct ncr_chip {
475*19c65091SMatthew Wilcox 	unsigned short	revision_id;
476*19c65091SMatthew Wilcox 	unsigned char	burst_max;	/* log-base-2 of max burst */
477*19c65091SMatthew Wilcox 	unsigned char	offset_max;
478*19c65091SMatthew Wilcox 	unsigned char	nr_divisor;
479*19c65091SMatthew Wilcox 	unsigned int	features;
480*19c65091SMatthew Wilcox #define FE_LED0		(1<<0)
481*19c65091SMatthew Wilcox #define FE_WIDE		(1<<1)    /* Wide data transfers */
482*19c65091SMatthew Wilcox #define FE_ULTRA	(1<<2)	  /* Ultra speed 20Mtrans/sec */
483*19c65091SMatthew Wilcox #define FE_DBLR		(1<<4)	  /* Clock doubler present */
484*19c65091SMatthew Wilcox #define FE_QUAD		(1<<5)	  /* Clock quadrupler present */
485*19c65091SMatthew Wilcox #define FE_ERL		(1<<6)    /* Enable read line */
486*19c65091SMatthew Wilcox #define FE_CLSE		(1<<7)    /* Cache line size enable */
487*19c65091SMatthew Wilcox #define FE_WRIE		(1<<8)    /* Write & Invalidate enable */
488*19c65091SMatthew Wilcox #define FE_ERMP		(1<<9)    /* Enable read multiple */
489*19c65091SMatthew Wilcox #define FE_BOF		(1<<10)   /* Burst opcode fetch */
490*19c65091SMatthew Wilcox #define FE_DFS		(1<<11)   /* DMA fifo size */
491*19c65091SMatthew Wilcox #define FE_PFEN		(1<<12)   /* Prefetch enable */
492*19c65091SMatthew Wilcox #define FE_LDSTR	(1<<13)   /* Load/Store supported */
493*19c65091SMatthew Wilcox #define FE_RAM		(1<<14)   /* On chip RAM present */
494*19c65091SMatthew Wilcox #define FE_VARCLK	(1<<15)   /* SCSI clock may vary */
495*19c65091SMatthew Wilcox #define FE_RAM8K	(1<<16)   /* On chip RAM sized 8Kb */
496*19c65091SMatthew Wilcox #define FE_64BIT	(1<<17)   /* Have a 64-bit PCI interface */
497*19c65091SMatthew Wilcox #define FE_IO256	(1<<18)   /* Requires full 256 bytes in PCI space */
498*19c65091SMatthew Wilcox #define FE_NOPM		(1<<19)   /* Scripts handles phase mismatch */
499*19c65091SMatthew Wilcox #define FE_LEDC		(1<<20)   /* Hardware control of LED */
500*19c65091SMatthew Wilcox #define FE_DIFF		(1<<21)   /* Support Differential SCSI */
501*19c65091SMatthew Wilcox #define FE_66MHZ 	(1<<23)   /* 66MHz PCI Support */
502*19c65091SMatthew Wilcox #define FE_DAC	 	(1<<24)   /* Support DAC cycles (64 bit addressing) */
503*19c65091SMatthew Wilcox #define FE_ISTAT1 	(1<<25)   /* Have ISTAT1, MBOX0, MBOX1 registers */
504*19c65091SMatthew Wilcox #define FE_DAC_IN_USE	(1<<26)	  /* Platform does DAC cycles */
505*19c65091SMatthew Wilcox #define FE_EHP		(1<<27)   /* 720: Even host parity */
506*19c65091SMatthew Wilcox #define FE_MUX		(1<<28)   /* 720: Multiplexed bus */
507*19c65091SMatthew Wilcox #define FE_EA		(1<<29)   /* 720: Enable Ack */
508*19c65091SMatthew Wilcox 
509*19c65091SMatthew Wilcox #define FE_CACHE_SET	(FE_ERL|FE_CLSE|FE_WRIE|FE_ERMP)
510*19c65091SMatthew Wilcox #define FE_SCSI_SET	(FE_WIDE|FE_ULTRA|FE_DBLR|FE_QUAD|F_CLK80)
511*19c65091SMatthew Wilcox #define FE_SPECIAL_SET	(FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_RAM)
512*19c65091SMatthew Wilcox };
513*19c65091SMatthew Wilcox 
514*19c65091SMatthew Wilcox 
515*19c65091SMatthew Wilcox /*
516*19c65091SMatthew Wilcox **	Driver setup structure.
517*19c65091SMatthew Wilcox **
518*19c65091SMatthew Wilcox **	This structure is initialized from linux config options.
519*19c65091SMatthew Wilcox **	It can be overridden at boot-up by the boot command line.
520*19c65091SMatthew Wilcox */
521*19c65091SMatthew Wilcox #define SCSI_NCR_MAX_EXCLUDES 8
522*19c65091SMatthew Wilcox struct ncr_driver_setup {
523*19c65091SMatthew Wilcox 	u8	master_parity;
524*19c65091SMatthew Wilcox 	u8	scsi_parity;
525*19c65091SMatthew Wilcox 	u8	disconnection;
526*19c65091SMatthew Wilcox 	u8	special_features;
527*19c65091SMatthew Wilcox 	u8	force_sync_nego;
528*19c65091SMatthew Wilcox 	u8	reverse_probe;
529*19c65091SMatthew Wilcox 	u8	pci_fix_up;
530*19c65091SMatthew Wilcox 	u8	use_nvram;
531*19c65091SMatthew Wilcox 	u8	verbose;
532*19c65091SMatthew Wilcox 	u8	default_tags;
533*19c65091SMatthew Wilcox 	u16	default_sync;
534*19c65091SMatthew Wilcox 	u16	debug;
535*19c65091SMatthew Wilcox 	u8	burst_max;
536*19c65091SMatthew Wilcox 	u8	led_pin;
537*19c65091SMatthew Wilcox 	u8	max_wide;
538*19c65091SMatthew Wilcox 	u8	settle_delay;
539*19c65091SMatthew Wilcox 	u8	diff_support;
540*19c65091SMatthew Wilcox 	u8	irqm;
541*19c65091SMatthew Wilcox 	u8	bus_check;
542*19c65091SMatthew Wilcox 	u8	optimize;
543*19c65091SMatthew Wilcox 	u8	recovery;
544*19c65091SMatthew Wilcox 	u8	host_id;
545*19c65091SMatthew Wilcox 	u16	iarb;
546*19c65091SMatthew Wilcox 	u32	excludes[SCSI_NCR_MAX_EXCLUDES];
547*19c65091SMatthew Wilcox 	char	tag_ctrl[100];
548*19c65091SMatthew Wilcox };
549*19c65091SMatthew Wilcox 
550*19c65091SMatthew Wilcox /*
551*19c65091SMatthew Wilcox **	Initial setup.
552*19c65091SMatthew Wilcox **	Can be overriden at startup by a command line.
553*19c65091SMatthew Wilcox */
554*19c65091SMatthew Wilcox #define SCSI_NCR_DRIVER_SETUP			\
555*19c65091SMatthew Wilcox {						\
556*19c65091SMatthew Wilcox 	SCSI_NCR_SETUP_MASTER_PARITY,		\
557*19c65091SMatthew Wilcox 	SCSI_NCR_SETUP_SCSI_PARITY,		\
558*19c65091SMatthew Wilcox 	SCSI_NCR_SETUP_DISCONNECTION,		\
559*19c65091SMatthew Wilcox 	SCSI_NCR_SETUP_SPECIAL_FEATURES,	\
560*19c65091SMatthew Wilcox 	SCSI_NCR_SETUP_FORCE_SYNC_NEGO,		\
561*19c65091SMatthew Wilcox 	0,					\
562*19c65091SMatthew Wilcox 	0,					\
563*19c65091SMatthew Wilcox 	1,					\
564*19c65091SMatthew Wilcox 	0,					\
565*19c65091SMatthew Wilcox 	SCSI_NCR_SETUP_DEFAULT_TAGS,		\
566*19c65091SMatthew Wilcox 	SCSI_NCR_SETUP_DEFAULT_SYNC,		\
567*19c65091SMatthew Wilcox 	0x00,					\
568*19c65091SMatthew Wilcox 	7,					\
569*19c65091SMatthew Wilcox 	0,					\
570*19c65091SMatthew Wilcox 	1,					\
571*19c65091SMatthew Wilcox 	SCSI_NCR_SETUP_SETTLE_TIME,		\
572*19c65091SMatthew Wilcox 	0,					\
573*19c65091SMatthew Wilcox 	0,					\
574*19c65091SMatthew Wilcox 	1,					\
575*19c65091SMatthew Wilcox 	0,					\
576*19c65091SMatthew Wilcox 	0,					\
577*19c65091SMatthew Wilcox 	255,					\
578*19c65091SMatthew Wilcox 	0x00					\
579*19c65091SMatthew Wilcox }
580*19c65091SMatthew Wilcox 
581*19c65091SMatthew Wilcox /*
582*19c65091SMatthew Wilcox **	Boot fail safe setup.
583*19c65091SMatthew Wilcox **	Override initial setup from boot command line:
584*19c65091SMatthew Wilcox **	ncr53c8xx=safe:y
585*19c65091SMatthew Wilcox */
586*19c65091SMatthew Wilcox #define SCSI_NCR_DRIVER_SAFE_SETUP		\
587*19c65091SMatthew Wilcox {						\
588*19c65091SMatthew Wilcox 	0,					\
589*19c65091SMatthew Wilcox 	1,					\
590*19c65091SMatthew Wilcox 	0,					\
591*19c65091SMatthew Wilcox 	0,					\
592*19c65091SMatthew Wilcox 	0,					\
593*19c65091SMatthew Wilcox 	0,					\
594*19c65091SMatthew Wilcox 	0,					\
595*19c65091SMatthew Wilcox 	1,					\
596*19c65091SMatthew Wilcox 	2,					\
597*19c65091SMatthew Wilcox 	0,					\
598*19c65091SMatthew Wilcox 	255,					\
599*19c65091SMatthew Wilcox 	0x00,					\
600*19c65091SMatthew Wilcox 	255,					\
601*19c65091SMatthew Wilcox 	0,					\
602*19c65091SMatthew Wilcox 	0,					\
603*19c65091SMatthew Wilcox 	10,					\
604*19c65091SMatthew Wilcox 	1,					\
605*19c65091SMatthew Wilcox 	1,					\
606*19c65091SMatthew Wilcox 	1,					\
607*19c65091SMatthew Wilcox 	0,					\
608*19c65091SMatthew Wilcox 	0,					\
609*19c65091SMatthew Wilcox 	255					\
610*19c65091SMatthew Wilcox }
611*19c65091SMatthew Wilcox 
612*19c65091SMatthew Wilcox /**************** ORIGINAL CONTENT of ncrreg.h from FreeBSD ******************/
613*19c65091SMatthew Wilcox 
614*19c65091SMatthew Wilcox /*-----------------------------------------------------------------
615*19c65091SMatthew Wilcox **
616*19c65091SMatthew Wilcox **	The ncr 53c810 register structure.
617*19c65091SMatthew Wilcox **
618*19c65091SMatthew Wilcox **-----------------------------------------------------------------
619*19c65091SMatthew Wilcox */
620*19c65091SMatthew Wilcox 
621*19c65091SMatthew Wilcox struct ncr_reg {
622*19c65091SMatthew Wilcox /*00*/  u8	nc_scntl0;    /* full arb., ena parity, par->ATN  */
623*19c65091SMatthew Wilcox 
624*19c65091SMatthew Wilcox /*01*/  u8	nc_scntl1;    /* no reset                         */
625*19c65091SMatthew Wilcox         #define   ISCON   0x10  /* connected to scsi		    */
626*19c65091SMatthew Wilcox         #define   CRST    0x08  /* force reset                      */
627*19c65091SMatthew Wilcox         #define   IARB    0x02  /* immediate arbitration            */
628*19c65091SMatthew Wilcox 
629*19c65091SMatthew Wilcox /*02*/  u8	nc_scntl2;    /* no disconnect expected           */
630*19c65091SMatthew Wilcox 	#define   SDU     0x80  /* cmd: disconnect will raise error */
631*19c65091SMatthew Wilcox 	#define   CHM     0x40  /* sta: chained mode                */
632*19c65091SMatthew Wilcox 	#define   WSS     0x08  /* sta: wide scsi send           [W]*/
633*19c65091SMatthew Wilcox 	#define   WSR     0x01  /* sta: wide scsi received       [W]*/
634*19c65091SMatthew Wilcox 
635*19c65091SMatthew Wilcox /*03*/  u8	nc_scntl3;    /* cnf system clock dependent       */
636*19c65091SMatthew Wilcox 	#define   EWS     0x08  /* cmd: enable wide scsi         [W]*/
637*19c65091SMatthew Wilcox 	#define   ULTRA   0x80  /* cmd: ULTRA enable                */
638*19c65091SMatthew Wilcox 				/* bits 0-2, 7 rsvd for C1010       */
639*19c65091SMatthew Wilcox 
640*19c65091SMatthew Wilcox /*04*/  u8	nc_scid;	/* cnf host adapter scsi address    */
641*19c65091SMatthew Wilcox 	#define   RRE     0x40  /* r/w:e enable response to resel.  */
642*19c65091SMatthew Wilcox 	#define   SRE     0x20  /* r/w:e enable response to select  */
643*19c65091SMatthew Wilcox 
644*19c65091SMatthew Wilcox /*05*/  u8	nc_sxfer;	/* ### Sync speed and count         */
645*19c65091SMatthew Wilcox 				/* bits 6-7 rsvd for C1010          */
646*19c65091SMatthew Wilcox 
647*19c65091SMatthew Wilcox /*06*/  u8	nc_sdid;	/* ### Destination-ID               */
648*19c65091SMatthew Wilcox 
649*19c65091SMatthew Wilcox /*07*/  u8	nc_gpreg;	/* ??? IO-Pins                      */
650*19c65091SMatthew Wilcox 
651*19c65091SMatthew Wilcox /*08*/  u8	nc_sfbr;	/* ### First byte in phase          */
652*19c65091SMatthew Wilcox 
653*19c65091SMatthew Wilcox /*09*/  u8	nc_socl;
654*19c65091SMatthew Wilcox 	#define   CREQ	  0x80	/* r/w: SCSI-REQ                    */
655*19c65091SMatthew Wilcox 	#define   CACK	  0x40	/* r/w: SCSI-ACK                    */
656*19c65091SMatthew Wilcox 	#define   CBSY	  0x20	/* r/w: SCSI-BSY                    */
657*19c65091SMatthew Wilcox 	#define   CSEL	  0x10	/* r/w: SCSI-SEL                    */
658*19c65091SMatthew Wilcox 	#define   CATN	  0x08	/* r/w: SCSI-ATN                    */
659*19c65091SMatthew Wilcox 	#define   CMSG	  0x04	/* r/w: SCSI-MSG                    */
660*19c65091SMatthew Wilcox 	#define   CC_D	  0x02	/* r/w: SCSI-C_D                    */
661*19c65091SMatthew Wilcox 	#define   CI_O	  0x01	/* r/w: SCSI-I_O                    */
662*19c65091SMatthew Wilcox 
663*19c65091SMatthew Wilcox /*0a*/  u8	nc_ssid;
664*19c65091SMatthew Wilcox 
665*19c65091SMatthew Wilcox /*0b*/  u8	nc_sbcl;
666*19c65091SMatthew Wilcox 
667*19c65091SMatthew Wilcox /*0c*/  u8	nc_dstat;
668*19c65091SMatthew Wilcox         #define   DFE     0x80  /* sta: dma fifo empty              */
669*19c65091SMatthew Wilcox         #define   MDPE    0x40  /* int: master data parity error    */
670*19c65091SMatthew Wilcox         #define   BF      0x20  /* int: script: bus fault           */
671*19c65091SMatthew Wilcox         #define   ABRT    0x10  /* int: script: command aborted     */
672*19c65091SMatthew Wilcox         #define   SSI     0x08  /* int: script: single step         */
673*19c65091SMatthew Wilcox         #define   SIR     0x04  /* int: script: interrupt instruct. */
674*19c65091SMatthew Wilcox         #define   IID     0x01  /* int: script: illegal instruct.   */
675*19c65091SMatthew Wilcox 
676*19c65091SMatthew Wilcox /*0d*/  u8	nc_sstat0;
677*19c65091SMatthew Wilcox         #define   ILF     0x80  /* sta: data in SIDL register lsb   */
678*19c65091SMatthew Wilcox         #define   ORF     0x40  /* sta: data in SODR register lsb   */
679*19c65091SMatthew Wilcox         #define   OLF     0x20  /* sta: data in SODL register lsb   */
680*19c65091SMatthew Wilcox         #define   AIP     0x10  /* sta: arbitration in progress     */
681*19c65091SMatthew Wilcox         #define   LOA     0x08  /* sta: arbitration lost            */
682*19c65091SMatthew Wilcox         #define   WOA     0x04  /* sta: arbitration won             */
683*19c65091SMatthew Wilcox         #define   IRST    0x02  /* sta: scsi reset signal           */
684*19c65091SMatthew Wilcox         #define   SDP     0x01  /* sta: scsi parity signal          */
685*19c65091SMatthew Wilcox 
686*19c65091SMatthew Wilcox /*0e*/  u8	nc_sstat1;
687*19c65091SMatthew Wilcox 	#define   FF3210  0xf0	/* sta: bytes in the scsi fifo      */
688*19c65091SMatthew Wilcox 
689*19c65091SMatthew Wilcox /*0f*/  u8	nc_sstat2;
690*19c65091SMatthew Wilcox         #define   ILF1    0x80  /* sta: data in SIDL register msb[W]*/
691*19c65091SMatthew Wilcox         #define   ORF1    0x40  /* sta: data in SODR register msb[W]*/
692*19c65091SMatthew Wilcox         #define   OLF1    0x20  /* sta: data in SODL register msb[W]*/
693*19c65091SMatthew Wilcox         #define   DM      0x04  /* sta: DIFFSENS mismatch (895/6 only) */
694*19c65091SMatthew Wilcox         #define   LDSC    0x02  /* sta: disconnect & reconnect      */
695*19c65091SMatthew Wilcox 
696*19c65091SMatthew Wilcox /*10*/  u8	nc_dsa;	/* --> Base page                    */
697*19c65091SMatthew Wilcox /*11*/  u8	nc_dsa1;
698*19c65091SMatthew Wilcox /*12*/  u8	nc_dsa2;
699*19c65091SMatthew Wilcox /*13*/  u8	nc_dsa3;
700*19c65091SMatthew Wilcox 
701*19c65091SMatthew Wilcox /*14*/  u8	nc_istat;	/* --> Main Command and status      */
702*19c65091SMatthew Wilcox         #define   CABRT   0x80  /* cmd: abort current operation     */
703*19c65091SMatthew Wilcox         #define   SRST    0x40  /* mod: reset chip                  */
704*19c65091SMatthew Wilcox         #define   SIGP    0x20  /* r/w: message from host to ncr    */
705*19c65091SMatthew Wilcox         #define   SEM     0x10  /* r/w: message between host + ncr  */
706*19c65091SMatthew Wilcox         #define   CON     0x08  /* sta: connected to scsi           */
707*19c65091SMatthew Wilcox         #define   INTF    0x04  /* sta: int on the fly (reset by wr)*/
708*19c65091SMatthew Wilcox         #define   SIP     0x02  /* sta: scsi-interrupt              */
709*19c65091SMatthew Wilcox         #define   DIP     0x01  /* sta: host/script interrupt       */
710*19c65091SMatthew Wilcox 
711*19c65091SMatthew Wilcox /*15*/  u8	nc_istat1;	/* 896 and later cores only */
712*19c65091SMatthew Wilcox         #define   FLSH    0x04  /* sta: chip is flushing            */
713*19c65091SMatthew Wilcox         #define   SRUN    0x02  /* sta: scripts are running         */
714*19c65091SMatthew Wilcox         #define   SIRQD   0x01  /* r/w: disable INT pin             */
715*19c65091SMatthew Wilcox 
716*19c65091SMatthew Wilcox /*16*/  u8	nc_mbox0;	/* 896 and later cores only */
717*19c65091SMatthew Wilcox /*17*/  u8	nc_mbox1;	/* 896 and later cores only */
718*19c65091SMatthew Wilcox 
719*19c65091SMatthew Wilcox /*18*/	u8	nc_ctest0;
720*19c65091SMatthew Wilcox 	#define   EHP     0x04	/* 720 even host parity             */
721*19c65091SMatthew Wilcox /*19*/  u8	nc_ctest1;
722*19c65091SMatthew Wilcox 
723*19c65091SMatthew Wilcox /*1a*/  u8	nc_ctest2;
724*19c65091SMatthew Wilcox 	#define   CSIGP   0x40
725*19c65091SMatthew Wilcox 				/* bits 0-2,7 rsvd for C1010        */
726*19c65091SMatthew Wilcox 
727*19c65091SMatthew Wilcox /*1b*/  u8	nc_ctest3;
728*19c65091SMatthew Wilcox 	#define   FLF     0x08  /* cmd: flush dma fifo              */
729*19c65091SMatthew Wilcox 	#define   CLF	  0x04	/* cmd: clear dma fifo		    */
730*19c65091SMatthew Wilcox 	#define   FM      0x02  /* mod: fetch pin mode              */
731*19c65091SMatthew Wilcox 	#define   WRIE    0x01  /* mod: write and invalidate enable */
732*19c65091SMatthew Wilcox 				/* bits 4-7 rsvd for C1010          */
733*19c65091SMatthew Wilcox 
734*19c65091SMatthew Wilcox /*1c*/  u32    nc_temp;	/* ### Temporary stack              */
735*19c65091SMatthew Wilcox 
736*19c65091SMatthew Wilcox /*20*/	u8	nc_dfifo;
737*19c65091SMatthew Wilcox /*21*/  u8	nc_ctest4;
738*19c65091SMatthew Wilcox 	#define   MUX     0x80  /* 720 host bus multiplex mode      */
739*19c65091SMatthew Wilcox 	#define   BDIS    0x80  /* mod: burst disable               */
740*19c65091SMatthew Wilcox 	#define   MPEE    0x08  /* mod: master parity error enable  */
741*19c65091SMatthew Wilcox 
742*19c65091SMatthew Wilcox /*22*/  u8	nc_ctest5;
743*19c65091SMatthew Wilcox 	#define   DFS     0x20  /* mod: dma fifo size               */
744*19c65091SMatthew Wilcox 				/* bits 0-1, 3-7 rsvd for C1010          */
745*19c65091SMatthew Wilcox /*23*/  u8	nc_ctest6;
746*19c65091SMatthew Wilcox 
747*19c65091SMatthew Wilcox /*24*/  u32    nc_dbc;	/* ### Byte count and command       */
748*19c65091SMatthew Wilcox /*28*/  u32    nc_dnad;	/* ### Next command register        */
749*19c65091SMatthew Wilcox /*2c*/  u32    nc_dsp;	/* --> Script Pointer               */
750*19c65091SMatthew Wilcox /*30*/  u32    nc_dsps;	/* --> Script pointer save/opcode#2 */
751*19c65091SMatthew Wilcox 
752*19c65091SMatthew Wilcox /*34*/  u8	nc_scratcha;  /* Temporary register a            */
753*19c65091SMatthew Wilcox /*35*/  u8	nc_scratcha1;
754*19c65091SMatthew Wilcox /*36*/  u8	nc_scratcha2;
755*19c65091SMatthew Wilcox /*37*/  u8	nc_scratcha3;
756*19c65091SMatthew Wilcox 
757*19c65091SMatthew Wilcox /*38*/  u8	nc_dmode;
758*19c65091SMatthew Wilcox 	#define   BL_2    0x80  /* mod: burst length shift value +2 */
759*19c65091SMatthew Wilcox 	#define   BL_1    0x40  /* mod: burst length shift value +1 */
760*19c65091SMatthew Wilcox 	#define   ERL     0x08  /* mod: enable read line            */
761*19c65091SMatthew Wilcox 	#define   ERMP    0x04  /* mod: enable read multiple        */
762*19c65091SMatthew Wilcox 	#define   BOF     0x02  /* mod: burst op code fetch         */
763*19c65091SMatthew Wilcox 
764*19c65091SMatthew Wilcox /*39*/  u8	nc_dien;
765*19c65091SMatthew Wilcox /*3a*/  u8	nc_sbr;
766*19c65091SMatthew Wilcox 
767*19c65091SMatthew Wilcox /*3b*/  u8	nc_dcntl;	/* --> Script execution control     */
768*19c65091SMatthew Wilcox 	#define   CLSE    0x80  /* mod: cache line size enable      */
769*19c65091SMatthew Wilcox 	#define   PFF     0x40  /* cmd: pre-fetch flush             */
770*19c65091SMatthew Wilcox 	#define   PFEN    0x20  /* mod: pre-fetch enable            */
771*19c65091SMatthew Wilcox 	#define   EA      0x20  /* mod: 720 enable-ack              */
772*19c65091SMatthew Wilcox 	#define   SSM     0x10  /* mod: single step mode            */
773*19c65091SMatthew Wilcox 	#define   IRQM    0x08  /* mod: irq mode (1 = totem pole !) */
774*19c65091SMatthew Wilcox 	#define   STD     0x04  /* cmd: start dma mode              */
775*19c65091SMatthew Wilcox 	#define   IRQD    0x02  /* mod: irq disable                 */
776*19c65091SMatthew Wilcox  	#define	  NOCOM   0x01	/* cmd: protect sfbr while reselect */
777*19c65091SMatthew Wilcox 				/* bits 0-1 rsvd for C1010          */
778*19c65091SMatthew Wilcox 
779*19c65091SMatthew Wilcox /*3c*/  u32	nc_adder;
780*19c65091SMatthew Wilcox 
781*19c65091SMatthew Wilcox /*40*/  u16	nc_sien;	/* -->: interrupt enable            */
782*19c65091SMatthew Wilcox /*42*/  u16	nc_sist;	/* <--: interrupt status            */
783*19c65091SMatthew Wilcox         #define   SBMC    0x1000/* sta: SCSI Bus Mode Change (895/6 only) */
784*19c65091SMatthew Wilcox         #define   STO     0x0400/* sta: timeout (select)            */
785*19c65091SMatthew Wilcox         #define   GEN     0x0200/* sta: timeout (general)           */
786*19c65091SMatthew Wilcox         #define   HTH     0x0100/* sta: timeout (handshake)         */
787*19c65091SMatthew Wilcox         #define   MA      0x80  /* sta: phase mismatch              */
788*19c65091SMatthew Wilcox         #define   CMP     0x40  /* sta: arbitration complete        */
789*19c65091SMatthew Wilcox         #define   SEL     0x20  /* sta: selected by another device  */
790*19c65091SMatthew Wilcox         #define   RSL     0x10  /* sta: reselected by another device*/
791*19c65091SMatthew Wilcox         #define   SGE     0x08  /* sta: gross error (over/underflow)*/
792*19c65091SMatthew Wilcox         #define   UDC     0x04  /* sta: unexpected disconnect       */
793*19c65091SMatthew Wilcox         #define   RST     0x02  /* sta: scsi bus reset detected     */
794*19c65091SMatthew Wilcox         #define   PAR     0x01  /* sta: scsi parity error           */
795*19c65091SMatthew Wilcox 
796*19c65091SMatthew Wilcox /*44*/  u8	nc_slpar;
797*19c65091SMatthew Wilcox /*45*/  u8	nc_swide;
798*19c65091SMatthew Wilcox /*46*/  u8	nc_macntl;
799*19c65091SMatthew Wilcox /*47*/  u8	nc_gpcntl;
800*19c65091SMatthew Wilcox /*48*/  u8	nc_stime0;    /* cmd: timeout for select&handshake*/
801*19c65091SMatthew Wilcox /*49*/  u8	nc_stime1;    /* cmd: timeout user defined        */
802*19c65091SMatthew Wilcox /*4a*/  u16   nc_respid;    /* sta: Reselect-IDs                */
803*19c65091SMatthew Wilcox 
804*19c65091SMatthew Wilcox /*4c*/  u8	nc_stest0;
805*19c65091SMatthew Wilcox 
806*19c65091SMatthew Wilcox /*4d*/  u8	nc_stest1;
807*19c65091SMatthew Wilcox 	#define   SCLK    0x80	/* Use the PCI clock as SCSI clock	*/
808*19c65091SMatthew Wilcox 	#define   DBLEN   0x08	/* clock doubler running		*/
809*19c65091SMatthew Wilcox 	#define   DBLSEL  0x04	/* clock doubler selected		*/
810*19c65091SMatthew Wilcox 
811*19c65091SMatthew Wilcox 
812*19c65091SMatthew Wilcox /*4e*/  u8	nc_stest2;
813*19c65091SMatthew Wilcox 	#define   ROF     0x40	/* reset scsi offset (after gross error!) */
814*19c65091SMatthew Wilcox 	#define   DIF     0x20  /* 720 SCSI differential mode             */
815*19c65091SMatthew Wilcox 	#define   EXT     0x02  /* extended filtering                     */
816*19c65091SMatthew Wilcox 
817*19c65091SMatthew Wilcox /*4f*/  u8	nc_stest3;
818*19c65091SMatthew Wilcox 	#define   TE     0x80	/* c: tolerAnt enable */
819*19c65091SMatthew Wilcox 	#define   HSC    0x20	/* c: Halt SCSI Clock */
820*19c65091SMatthew Wilcox 	#define   CSF    0x02	/* c: clear scsi fifo */
821*19c65091SMatthew Wilcox 
822*19c65091SMatthew Wilcox /*50*/  u16   nc_sidl;	/* Lowlevel: latched from scsi data */
823*19c65091SMatthew Wilcox /*52*/  u8	nc_stest4;
824*19c65091SMatthew Wilcox 	#define   SMODE  0xc0	/* SCSI bus mode      (895/6 only) */
825*19c65091SMatthew Wilcox 	#define    SMODE_HVD 0x40	/* High Voltage Differential       */
826*19c65091SMatthew Wilcox 	#define    SMODE_SE  0x80	/* Single Ended                    */
827*19c65091SMatthew Wilcox 	#define    SMODE_LVD 0xc0	/* Low Voltage Differential        */
828*19c65091SMatthew Wilcox 	#define   LCKFRQ 0x20	/* Frequency Lock (895/6 only)     */
829*19c65091SMatthew Wilcox 				/* bits 0-5 rsvd for C1010          */
830*19c65091SMatthew Wilcox 
831*19c65091SMatthew Wilcox /*53*/  u8	nc_53_;
832*19c65091SMatthew Wilcox /*54*/  u16	nc_sodl;	/* Lowlevel: data out to scsi data  */
833*19c65091SMatthew Wilcox /*56*/	u8	nc_ccntl0;	/* Chip Control 0 (896)             */
834*19c65091SMatthew Wilcox 	#define   ENPMJ  0x80	/* Enable Phase Mismatch Jump       */
835*19c65091SMatthew Wilcox 	#define   PMJCTL 0x40	/* Phase Mismatch Jump Control      */
836*19c65091SMatthew Wilcox 	#define   ENNDJ  0x20	/* Enable Non Data PM Jump          */
837*19c65091SMatthew Wilcox 	#define   DISFC  0x10	/* Disable Auto FIFO Clear          */
838*19c65091SMatthew Wilcox 	#define   DILS   0x02	/* Disable Internal Load/Store      */
839*19c65091SMatthew Wilcox 	#define   DPR    0x01	/* Disable Pipe Req                 */
840*19c65091SMatthew Wilcox 
841*19c65091SMatthew Wilcox /*57*/	u8	nc_ccntl1;	/* Chip Control 1 (896)             */
842*19c65091SMatthew Wilcox 	#define   ZMOD   0x80	/* High Impedance Mode              */
843*19c65091SMatthew Wilcox 	#define	  DIC	 0x10	/* Disable Internal Cycles	    */
844*19c65091SMatthew Wilcox 	#define   DDAC   0x08	/* Disable Dual Address Cycle       */
845*19c65091SMatthew Wilcox 	#define   XTIMOD 0x04	/* 64-bit Table Ind. Indexing Mode  */
846*19c65091SMatthew Wilcox 	#define   EXTIBMV 0x02	/* Enable 64-bit Table Ind. BMOV    */
847*19c65091SMatthew Wilcox 	#define   EXDBMV 0x01	/* Enable 64-bit Direct BMOV        */
848*19c65091SMatthew Wilcox 
849*19c65091SMatthew Wilcox /*58*/  u16	nc_sbdl;	/* Lowlevel: data from scsi data    */
850*19c65091SMatthew Wilcox /*5a*/  u16	nc_5a_;
851*19c65091SMatthew Wilcox 
852*19c65091SMatthew Wilcox /*5c*/  u8	nc_scr0;	/* Working register B               */
853*19c65091SMatthew Wilcox /*5d*/  u8	nc_scr1;	/*                                  */
854*19c65091SMatthew Wilcox /*5e*/  u8	nc_scr2;	/*                                  */
855*19c65091SMatthew Wilcox /*5f*/  u8	nc_scr3;	/*                                  */
856*19c65091SMatthew Wilcox 
857*19c65091SMatthew Wilcox /*60*/  u8	nc_scrx[64];	/* Working register C-R             */
858*19c65091SMatthew Wilcox /*a0*/	u32	nc_mmrs;	/* Memory Move Read Selector        */
859*19c65091SMatthew Wilcox /*a4*/	u32	nc_mmws;	/* Memory Move Write Selector       */
860*19c65091SMatthew Wilcox /*a8*/	u32	nc_sfs;		/* Script Fetch Selector            */
861*19c65091SMatthew Wilcox /*ac*/	u32	nc_drs;		/* DSA Relative Selector            */
862*19c65091SMatthew Wilcox /*b0*/	u32	nc_sbms;	/* Static Block Move Selector       */
863*19c65091SMatthew Wilcox /*b4*/	u32	nc_dbms;	/* Dynamic Block Move Selector      */
864*19c65091SMatthew Wilcox /*b8*/	u32	nc_dnad64;	/* DMA Next Address 64              */
865*19c65091SMatthew Wilcox /*bc*/	u16	nc_scntl4;	/* C1010 only                       */
866*19c65091SMatthew Wilcox 	#define   U3EN   0x80	/* Enable Ultra 3                   */
867*19c65091SMatthew Wilcox 	#define   AIPEN	 0x40   /* Allow check upper byte lanes     */
868*19c65091SMatthew Wilcox 	#define   XCLKH_DT 0x08 /* Extra clock of data hold on DT
869*19c65091SMatthew Wilcox 					transfer edge	            */
870*19c65091SMatthew Wilcox 	#define   XCLKH_ST 0x04 /* Extra clock of data hold on ST
871*19c65091SMatthew Wilcox 					transfer edge	            */
872*19c65091SMatthew Wilcox 
873*19c65091SMatthew Wilcox /*be*/  u8	nc_aipcntl0;	/* Epat Control 1 C1010 only        */
874*19c65091SMatthew Wilcox /*bf*/  u8	nc_aipcntl1;	/* AIP Control C1010_66 Only        */
875*19c65091SMatthew Wilcox 
876*19c65091SMatthew Wilcox /*c0*/	u32	nc_pmjad1;	/* Phase Mismatch Jump Address 1    */
877*19c65091SMatthew Wilcox /*c4*/	u32	nc_pmjad2;	/* Phase Mismatch Jump Address 2    */
878*19c65091SMatthew Wilcox /*c8*/	u8	nc_rbc;		/* Remaining Byte Count             */
879*19c65091SMatthew Wilcox /*c9*/	u8	nc_rbc1;	/*                                  */
880*19c65091SMatthew Wilcox /*ca*/	u8	nc_rbc2;	/*                                  */
881*19c65091SMatthew Wilcox /*cb*/	u8	nc_rbc3;	/*                                  */
882*19c65091SMatthew Wilcox 
883*19c65091SMatthew Wilcox /*cc*/	u8	nc_ua;		/* Updated Address                  */
884*19c65091SMatthew Wilcox /*cd*/	u8	nc_ua1;		/*                                  */
885*19c65091SMatthew Wilcox /*ce*/	u8	nc_ua2;		/*                                  */
886*19c65091SMatthew Wilcox /*cf*/	u8	nc_ua3;		/*                                  */
887*19c65091SMatthew Wilcox /*d0*/	u32	nc_esa;		/* Entry Storage Address            */
888*19c65091SMatthew Wilcox /*d4*/	u8	nc_ia;		/* Instruction Address              */
889*19c65091SMatthew Wilcox /*d5*/	u8	nc_ia1;
890*19c65091SMatthew Wilcox /*d6*/	u8	nc_ia2;
891*19c65091SMatthew Wilcox /*d7*/	u8	nc_ia3;
892*19c65091SMatthew Wilcox /*d8*/	u32	nc_sbc;		/* SCSI Byte Count (3 bytes only)   */
893*19c65091SMatthew Wilcox /*dc*/	u32	nc_csbc;	/* Cumulative SCSI Byte Count       */
894*19c65091SMatthew Wilcox 
895*19c65091SMatthew Wilcox 				/* Following for C1010 only         */
896*19c65091SMatthew Wilcox /*e0*/  u16	nc_crcpad;	/* CRC Value                        */
897*19c65091SMatthew Wilcox /*e2*/  u8	nc_crccntl0;	/* CRC control register             */
898*19c65091SMatthew Wilcox 	#define   SNDCRC  0x10	/* Send CRC Request                 */
899*19c65091SMatthew Wilcox /*e3*/  u8	nc_crccntl1;	/* CRC control register             */
900*19c65091SMatthew Wilcox /*e4*/  u32	nc_crcdata;	/* CRC data register                */
901*19c65091SMatthew Wilcox /*e8*/  u32	nc_e8_;		/* rsvd 			    */
902*19c65091SMatthew Wilcox /*ec*/  u32	nc_ec_;		/* rsvd 			    */
903*19c65091SMatthew Wilcox /*f0*/  u16	nc_dfbc;	/* DMA FIFO byte count              */
904*19c65091SMatthew Wilcox 
905*19c65091SMatthew Wilcox };
906*19c65091SMatthew Wilcox 
907*19c65091SMatthew Wilcox /*-----------------------------------------------------------
908*19c65091SMatthew Wilcox **
909*19c65091SMatthew Wilcox **	Utility macros for the script.
910*19c65091SMatthew Wilcox **
911*19c65091SMatthew Wilcox **-----------------------------------------------------------
912*19c65091SMatthew Wilcox */
913*19c65091SMatthew Wilcox 
914*19c65091SMatthew Wilcox #define REGJ(p,r) (offsetof(struct ncr_reg, p ## r))
915*19c65091SMatthew Wilcox #define REG(r) REGJ (nc_, r)
916*19c65091SMatthew Wilcox 
917*19c65091SMatthew Wilcox typedef u32 ncrcmd;
918*19c65091SMatthew Wilcox 
919*19c65091SMatthew Wilcox /*-----------------------------------------------------------
920*19c65091SMatthew Wilcox **
921*19c65091SMatthew Wilcox **	SCSI phases
922*19c65091SMatthew Wilcox **
923*19c65091SMatthew Wilcox **	DT phases illegal for ncr driver.
924*19c65091SMatthew Wilcox **
925*19c65091SMatthew Wilcox **-----------------------------------------------------------
926*19c65091SMatthew Wilcox */
927*19c65091SMatthew Wilcox 
928*19c65091SMatthew Wilcox #define	SCR_DATA_OUT	0x00000000
929*19c65091SMatthew Wilcox #define	SCR_DATA_IN	0x01000000
930*19c65091SMatthew Wilcox #define	SCR_COMMAND	0x02000000
931*19c65091SMatthew Wilcox #define	SCR_STATUS	0x03000000
932*19c65091SMatthew Wilcox #define SCR_DT_DATA_OUT	0x04000000
933*19c65091SMatthew Wilcox #define SCR_DT_DATA_IN	0x05000000
934*19c65091SMatthew Wilcox #define SCR_MSG_OUT	0x06000000
935*19c65091SMatthew Wilcox #define SCR_MSG_IN      0x07000000
936*19c65091SMatthew Wilcox 
937*19c65091SMatthew Wilcox #define SCR_ILG_OUT	0x04000000
938*19c65091SMatthew Wilcox #define SCR_ILG_IN	0x05000000
939*19c65091SMatthew Wilcox 
940*19c65091SMatthew Wilcox /*-----------------------------------------------------------
941*19c65091SMatthew Wilcox **
942*19c65091SMatthew Wilcox **	Data transfer via SCSI.
943*19c65091SMatthew Wilcox **
944*19c65091SMatthew Wilcox **-----------------------------------------------------------
945*19c65091SMatthew Wilcox **
946*19c65091SMatthew Wilcox **	MOVE_ABS (LEN)
947*19c65091SMatthew Wilcox **	<<start address>>
948*19c65091SMatthew Wilcox **
949*19c65091SMatthew Wilcox **	MOVE_IND (LEN)
950*19c65091SMatthew Wilcox **	<<dnad_offset>>
951*19c65091SMatthew Wilcox **
952*19c65091SMatthew Wilcox **	MOVE_TBL
953*19c65091SMatthew Wilcox **	<<dnad_offset>>
954*19c65091SMatthew Wilcox **
955*19c65091SMatthew Wilcox **-----------------------------------------------------------
956*19c65091SMatthew Wilcox */
957*19c65091SMatthew Wilcox 
958*19c65091SMatthew Wilcox #define OPC_MOVE          0x08000000
959*19c65091SMatthew Wilcox 
960*19c65091SMatthew Wilcox #define SCR_MOVE_ABS(l) ((0x00000000 | OPC_MOVE) | (l))
961*19c65091SMatthew Wilcox #define SCR_MOVE_IND(l) ((0x20000000 | OPC_MOVE) | (l))
962*19c65091SMatthew Wilcox #define SCR_MOVE_TBL     (0x10000000 | OPC_MOVE)
963*19c65091SMatthew Wilcox 
964*19c65091SMatthew Wilcox #define SCR_CHMOV_ABS(l) ((0x00000000) | (l))
965*19c65091SMatthew Wilcox #define SCR_CHMOV_IND(l) ((0x20000000) | (l))
966*19c65091SMatthew Wilcox #define SCR_CHMOV_TBL     (0x10000000)
967*19c65091SMatthew Wilcox 
968*19c65091SMatthew Wilcox struct scr_tblmove {
969*19c65091SMatthew Wilcox         u32  size;
970*19c65091SMatthew Wilcox         u32  addr;
971*19c65091SMatthew Wilcox };
972*19c65091SMatthew Wilcox 
973*19c65091SMatthew Wilcox /*-----------------------------------------------------------
974*19c65091SMatthew Wilcox **
975*19c65091SMatthew Wilcox **	Selection
976*19c65091SMatthew Wilcox **
977*19c65091SMatthew Wilcox **-----------------------------------------------------------
978*19c65091SMatthew Wilcox **
979*19c65091SMatthew Wilcox **	SEL_ABS | SCR_ID (0..15)    [ | REL_JMP]
980*19c65091SMatthew Wilcox **	<<alternate_address>>
981*19c65091SMatthew Wilcox **
982*19c65091SMatthew Wilcox **	SEL_TBL | << dnad_offset>>  [ | REL_JMP]
983*19c65091SMatthew Wilcox **	<<alternate_address>>
984*19c65091SMatthew Wilcox **
985*19c65091SMatthew Wilcox **-----------------------------------------------------------
986*19c65091SMatthew Wilcox */
987*19c65091SMatthew Wilcox 
988*19c65091SMatthew Wilcox #define	SCR_SEL_ABS	0x40000000
989*19c65091SMatthew Wilcox #define	SCR_SEL_ABS_ATN	0x41000000
990*19c65091SMatthew Wilcox #define	SCR_SEL_TBL	0x42000000
991*19c65091SMatthew Wilcox #define	SCR_SEL_TBL_ATN	0x43000000
992*19c65091SMatthew Wilcox 
993*19c65091SMatthew Wilcox 
994*19c65091SMatthew Wilcox #ifdef SCSI_NCR_BIG_ENDIAN
995*19c65091SMatthew Wilcox struct scr_tblsel {
996*19c65091SMatthew Wilcox         u8	sel_scntl3;
997*19c65091SMatthew Wilcox         u8	sel_id;
998*19c65091SMatthew Wilcox         u8	sel_sxfer;
999*19c65091SMatthew Wilcox         u8	sel_scntl4;
1000*19c65091SMatthew Wilcox };
1001*19c65091SMatthew Wilcox #else
1002*19c65091SMatthew Wilcox struct scr_tblsel {
1003*19c65091SMatthew Wilcox         u8	sel_scntl4;
1004*19c65091SMatthew Wilcox         u8	sel_sxfer;
1005*19c65091SMatthew Wilcox         u8	sel_id;
1006*19c65091SMatthew Wilcox         u8	sel_scntl3;
1007*19c65091SMatthew Wilcox };
1008*19c65091SMatthew Wilcox #endif
1009*19c65091SMatthew Wilcox 
1010*19c65091SMatthew Wilcox #define SCR_JMP_REL     0x04000000
1011*19c65091SMatthew Wilcox #define SCR_ID(id)	(((u32)(id)) << 16)
1012*19c65091SMatthew Wilcox 
1013*19c65091SMatthew Wilcox /*-----------------------------------------------------------
1014*19c65091SMatthew Wilcox **
1015*19c65091SMatthew Wilcox **	Waiting for Disconnect or Reselect
1016*19c65091SMatthew Wilcox **
1017*19c65091SMatthew Wilcox **-----------------------------------------------------------
1018*19c65091SMatthew Wilcox **
1019*19c65091SMatthew Wilcox **	WAIT_DISC
1020*19c65091SMatthew Wilcox **	dummy: <<alternate_address>>
1021*19c65091SMatthew Wilcox **
1022*19c65091SMatthew Wilcox **	WAIT_RESEL
1023*19c65091SMatthew Wilcox **	<<alternate_address>>
1024*19c65091SMatthew Wilcox **
1025*19c65091SMatthew Wilcox **-----------------------------------------------------------
1026*19c65091SMatthew Wilcox */
1027*19c65091SMatthew Wilcox 
1028*19c65091SMatthew Wilcox #define	SCR_WAIT_DISC	0x48000000
1029*19c65091SMatthew Wilcox #define SCR_WAIT_RESEL  0x50000000
1030*19c65091SMatthew Wilcox 
1031*19c65091SMatthew Wilcox /*-----------------------------------------------------------
1032*19c65091SMatthew Wilcox **
1033*19c65091SMatthew Wilcox **	Bit Set / Reset
1034*19c65091SMatthew Wilcox **
1035*19c65091SMatthew Wilcox **-----------------------------------------------------------
1036*19c65091SMatthew Wilcox **
1037*19c65091SMatthew Wilcox **	SET (flags {|.. })
1038*19c65091SMatthew Wilcox **
1039*19c65091SMatthew Wilcox **	CLR (flags {|.. })
1040*19c65091SMatthew Wilcox **
1041*19c65091SMatthew Wilcox **-----------------------------------------------------------
1042*19c65091SMatthew Wilcox */
1043*19c65091SMatthew Wilcox 
1044*19c65091SMatthew Wilcox #define SCR_SET(f)     (0x58000000 | (f))
1045*19c65091SMatthew Wilcox #define SCR_CLR(f)     (0x60000000 | (f))
1046*19c65091SMatthew Wilcox 
1047*19c65091SMatthew Wilcox #define	SCR_CARRY	0x00000400
1048*19c65091SMatthew Wilcox #define	SCR_TRG		0x00000200
1049*19c65091SMatthew Wilcox #define	SCR_ACK		0x00000040
1050*19c65091SMatthew Wilcox #define	SCR_ATN		0x00000008
1051*19c65091SMatthew Wilcox 
1052*19c65091SMatthew Wilcox 
1053*19c65091SMatthew Wilcox 
1054*19c65091SMatthew Wilcox 
1055*19c65091SMatthew Wilcox /*-----------------------------------------------------------
1056*19c65091SMatthew Wilcox **
1057*19c65091SMatthew Wilcox **	Memory to memory move
1058*19c65091SMatthew Wilcox **
1059*19c65091SMatthew Wilcox **-----------------------------------------------------------
1060*19c65091SMatthew Wilcox **
1061*19c65091SMatthew Wilcox **	COPY (bytecount)
1062*19c65091SMatthew Wilcox **	<< source_address >>
1063*19c65091SMatthew Wilcox **	<< destination_address >>
1064*19c65091SMatthew Wilcox **
1065*19c65091SMatthew Wilcox **	SCR_COPY   sets the NO FLUSH option by default.
1066*19c65091SMatthew Wilcox **	SCR_COPY_F does not set this option.
1067*19c65091SMatthew Wilcox **
1068*19c65091SMatthew Wilcox **	For chips which do not support this option,
1069*19c65091SMatthew Wilcox **	ncr_copy_and_bind() will remove this bit.
1070*19c65091SMatthew Wilcox **-----------------------------------------------------------
1071*19c65091SMatthew Wilcox */
1072*19c65091SMatthew Wilcox 
1073*19c65091SMatthew Wilcox #define SCR_NO_FLUSH 0x01000000
1074*19c65091SMatthew Wilcox 
1075*19c65091SMatthew Wilcox #define SCR_COPY(n) (0xc0000000 | SCR_NO_FLUSH | (n))
1076*19c65091SMatthew Wilcox #define SCR_COPY_F(n) (0xc0000000 | (n))
1077*19c65091SMatthew Wilcox 
1078*19c65091SMatthew Wilcox /*-----------------------------------------------------------
1079*19c65091SMatthew Wilcox **
1080*19c65091SMatthew Wilcox **	Register move and binary operations
1081*19c65091SMatthew Wilcox **
1082*19c65091SMatthew Wilcox **-----------------------------------------------------------
1083*19c65091SMatthew Wilcox **
1084*19c65091SMatthew Wilcox **	SFBR_REG (reg, op, data)        reg  = SFBR op data
1085*19c65091SMatthew Wilcox **	<< 0 >>
1086*19c65091SMatthew Wilcox **
1087*19c65091SMatthew Wilcox **	REG_SFBR (reg, op, data)        SFBR = reg op data
1088*19c65091SMatthew Wilcox **	<< 0 >>
1089*19c65091SMatthew Wilcox **
1090*19c65091SMatthew Wilcox **	REG_REG  (reg, op, data)        reg  = reg op data
1091*19c65091SMatthew Wilcox **	<< 0 >>
1092*19c65091SMatthew Wilcox **
1093*19c65091SMatthew Wilcox **-----------------------------------------------------------
1094*19c65091SMatthew Wilcox **	On 810A, 860, 825A, 875, 895 and 896 chips the content
1095*19c65091SMatthew Wilcox **	of SFBR register can be used as data (SCR_SFBR_DATA).
1096*19c65091SMatthew Wilcox **	The 896 has additionnal IO registers starting at
1097*19c65091SMatthew Wilcox **	offset 0x80. Bit 7 of register offset is stored in
1098*19c65091SMatthew Wilcox **	bit 7 of the SCRIPTS instruction first DWORD.
1099*19c65091SMatthew Wilcox **-----------------------------------------------------------
1100*19c65091SMatthew Wilcox */
1101*19c65091SMatthew Wilcox 
1102*19c65091SMatthew Wilcox #define SCR_REG_OFS(ofs) ((((ofs) & 0x7f) << 16ul) + ((ofs) & 0x80))
1103*19c65091SMatthew Wilcox 
1104*19c65091SMatthew Wilcox #define SCR_SFBR_REG(reg,op,data) \
1105*19c65091SMatthew Wilcox         (0x68000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
1106*19c65091SMatthew Wilcox 
1107*19c65091SMatthew Wilcox #define SCR_REG_SFBR(reg,op,data) \
1108*19c65091SMatthew Wilcox         (0x70000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
1109*19c65091SMatthew Wilcox 
1110*19c65091SMatthew Wilcox #define SCR_REG_REG(reg,op,data) \
1111*19c65091SMatthew Wilcox         (0x78000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
1112*19c65091SMatthew Wilcox 
1113*19c65091SMatthew Wilcox 
1114*19c65091SMatthew Wilcox #define      SCR_LOAD   0x00000000
1115*19c65091SMatthew Wilcox #define      SCR_SHL    0x01000000
1116*19c65091SMatthew Wilcox #define      SCR_OR     0x02000000
1117*19c65091SMatthew Wilcox #define      SCR_XOR    0x03000000
1118*19c65091SMatthew Wilcox #define      SCR_AND    0x04000000
1119*19c65091SMatthew Wilcox #define      SCR_SHR    0x05000000
1120*19c65091SMatthew Wilcox #define      SCR_ADD    0x06000000
1121*19c65091SMatthew Wilcox #define      SCR_ADDC   0x07000000
1122*19c65091SMatthew Wilcox 
1123*19c65091SMatthew Wilcox #define      SCR_SFBR_DATA   (0x00800000>>8ul)	/* Use SFBR as data */
1124*19c65091SMatthew Wilcox 
1125*19c65091SMatthew Wilcox /*-----------------------------------------------------------
1126*19c65091SMatthew Wilcox **
1127*19c65091SMatthew Wilcox **	FROM_REG (reg)		  SFBR = reg
1128*19c65091SMatthew Wilcox **	<< 0 >>
1129*19c65091SMatthew Wilcox **
1130*19c65091SMatthew Wilcox **	TO_REG	 (reg)		  reg  = SFBR
1131*19c65091SMatthew Wilcox **	<< 0 >>
1132*19c65091SMatthew Wilcox **
1133*19c65091SMatthew Wilcox **	LOAD_REG (reg, data)	  reg  = <data>
1134*19c65091SMatthew Wilcox **	<< 0 >>
1135*19c65091SMatthew Wilcox **
1136*19c65091SMatthew Wilcox **	LOAD_SFBR(data) 	  SFBR = <data>
1137*19c65091SMatthew Wilcox **	<< 0 >>
1138*19c65091SMatthew Wilcox **
1139*19c65091SMatthew Wilcox **-----------------------------------------------------------
1140*19c65091SMatthew Wilcox */
1141*19c65091SMatthew Wilcox 
1142*19c65091SMatthew Wilcox #define	SCR_FROM_REG(reg) \
1143*19c65091SMatthew Wilcox 	SCR_REG_SFBR(reg,SCR_OR,0)
1144*19c65091SMatthew Wilcox 
1145*19c65091SMatthew Wilcox #define	SCR_TO_REG(reg) \
1146*19c65091SMatthew Wilcox 	SCR_SFBR_REG(reg,SCR_OR,0)
1147*19c65091SMatthew Wilcox 
1148*19c65091SMatthew Wilcox #define	SCR_LOAD_REG(reg,data) \
1149*19c65091SMatthew Wilcox 	SCR_REG_REG(reg,SCR_LOAD,data)
1150*19c65091SMatthew Wilcox 
1151*19c65091SMatthew Wilcox #define SCR_LOAD_SFBR(data) \
1152*19c65091SMatthew Wilcox         (SCR_REG_SFBR (gpreg, SCR_LOAD, data))
1153*19c65091SMatthew Wilcox 
1154*19c65091SMatthew Wilcox /*-----------------------------------------------------------
1155*19c65091SMatthew Wilcox **
1156*19c65091SMatthew Wilcox **	LOAD  from memory   to register.
1157*19c65091SMatthew Wilcox **	STORE from register to memory.
1158*19c65091SMatthew Wilcox **
1159*19c65091SMatthew Wilcox **	Only supported by 810A, 860, 825A, 875, 895 and 896.
1160*19c65091SMatthew Wilcox **
1161*19c65091SMatthew Wilcox **-----------------------------------------------------------
1162*19c65091SMatthew Wilcox **
1163*19c65091SMatthew Wilcox **	LOAD_ABS (LEN)
1164*19c65091SMatthew Wilcox **	<<start address>>
1165*19c65091SMatthew Wilcox **
1166*19c65091SMatthew Wilcox **	LOAD_REL (LEN)        (DSA relative)
1167*19c65091SMatthew Wilcox **	<<dsa_offset>>
1168*19c65091SMatthew Wilcox **
1169*19c65091SMatthew Wilcox **-----------------------------------------------------------
1170*19c65091SMatthew Wilcox */
1171*19c65091SMatthew Wilcox 
1172*19c65091SMatthew Wilcox #define SCR_REG_OFS2(ofs) (((ofs) & 0xff) << 16ul)
1173*19c65091SMatthew Wilcox #define SCR_NO_FLUSH2	0x02000000
1174*19c65091SMatthew Wilcox #define SCR_DSA_REL2	0x10000000
1175*19c65091SMatthew Wilcox 
1176*19c65091SMatthew Wilcox #define SCR_LOAD_R(reg, how, n) \
1177*19c65091SMatthew Wilcox         (0xe1000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
1178*19c65091SMatthew Wilcox 
1179*19c65091SMatthew Wilcox #define SCR_STORE_R(reg, how, n) \
1180*19c65091SMatthew Wilcox         (0xe0000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
1181*19c65091SMatthew Wilcox 
1182*19c65091SMatthew Wilcox #define SCR_LOAD_ABS(reg, n)	SCR_LOAD_R(reg, SCR_NO_FLUSH2, n)
1183*19c65091SMatthew Wilcox #define SCR_LOAD_REL(reg, n)	SCR_LOAD_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2, n)
1184*19c65091SMatthew Wilcox #define SCR_LOAD_ABS_F(reg, n)	SCR_LOAD_R(reg, 0, n)
1185*19c65091SMatthew Wilcox #define SCR_LOAD_REL_F(reg, n)	SCR_LOAD_R(reg, SCR_DSA_REL2, n)
1186*19c65091SMatthew Wilcox 
1187*19c65091SMatthew Wilcox #define SCR_STORE_ABS(reg, n)	SCR_STORE_R(reg, SCR_NO_FLUSH2, n)
1188*19c65091SMatthew Wilcox #define SCR_STORE_REL(reg, n)	SCR_STORE_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2,n)
1189*19c65091SMatthew Wilcox #define SCR_STORE_ABS_F(reg, n)	SCR_STORE_R(reg, 0, n)
1190*19c65091SMatthew Wilcox #define SCR_STORE_REL_F(reg, n)	SCR_STORE_R(reg, SCR_DSA_REL2, n)
1191*19c65091SMatthew Wilcox 
1192*19c65091SMatthew Wilcox 
1193*19c65091SMatthew Wilcox /*-----------------------------------------------------------
1194*19c65091SMatthew Wilcox **
1195*19c65091SMatthew Wilcox **	Waiting for Disconnect or Reselect
1196*19c65091SMatthew Wilcox **
1197*19c65091SMatthew Wilcox **-----------------------------------------------------------
1198*19c65091SMatthew Wilcox **
1199*19c65091SMatthew Wilcox **	JUMP            [ | IFTRUE/IFFALSE ( ... ) ]
1200*19c65091SMatthew Wilcox **	<<address>>
1201*19c65091SMatthew Wilcox **
1202*19c65091SMatthew Wilcox **	JUMPR           [ | IFTRUE/IFFALSE ( ... ) ]
1203*19c65091SMatthew Wilcox **	<<distance>>
1204*19c65091SMatthew Wilcox **
1205*19c65091SMatthew Wilcox **	CALL            [ | IFTRUE/IFFALSE ( ... ) ]
1206*19c65091SMatthew Wilcox **	<<address>>
1207*19c65091SMatthew Wilcox **
1208*19c65091SMatthew Wilcox **	CALLR           [ | IFTRUE/IFFALSE ( ... ) ]
1209*19c65091SMatthew Wilcox **	<<distance>>
1210*19c65091SMatthew Wilcox **
1211*19c65091SMatthew Wilcox **	RETURN          [ | IFTRUE/IFFALSE ( ... ) ]
1212*19c65091SMatthew Wilcox **	<<dummy>>
1213*19c65091SMatthew Wilcox **
1214*19c65091SMatthew Wilcox **	INT             [ | IFTRUE/IFFALSE ( ... ) ]
1215*19c65091SMatthew Wilcox **	<<ident>>
1216*19c65091SMatthew Wilcox **
1217*19c65091SMatthew Wilcox **	INT_FLY         [ | IFTRUE/IFFALSE ( ... ) ]
1218*19c65091SMatthew Wilcox **	<<ident>>
1219*19c65091SMatthew Wilcox **
1220*19c65091SMatthew Wilcox **	Conditions:
1221*19c65091SMatthew Wilcox **	     WHEN (phase)
1222*19c65091SMatthew Wilcox **	     IF   (phase)
1223*19c65091SMatthew Wilcox **	     CARRYSET
1224*19c65091SMatthew Wilcox **	     DATA (data, mask)
1225*19c65091SMatthew Wilcox **
1226*19c65091SMatthew Wilcox **-----------------------------------------------------------
1227*19c65091SMatthew Wilcox */
1228*19c65091SMatthew Wilcox 
1229*19c65091SMatthew Wilcox #define SCR_NO_OP       0x80000000
1230*19c65091SMatthew Wilcox #define SCR_JUMP        0x80080000
1231*19c65091SMatthew Wilcox #define SCR_JUMP64      0x80480000
1232*19c65091SMatthew Wilcox #define SCR_JUMPR       0x80880000
1233*19c65091SMatthew Wilcox #define SCR_CALL        0x88080000
1234*19c65091SMatthew Wilcox #define SCR_CALLR       0x88880000
1235*19c65091SMatthew Wilcox #define SCR_RETURN      0x90080000
1236*19c65091SMatthew Wilcox #define SCR_INT         0x98080000
1237*19c65091SMatthew Wilcox #define SCR_INT_FLY     0x98180000
1238*19c65091SMatthew Wilcox 
1239*19c65091SMatthew Wilcox #define IFFALSE(arg)   (0x00080000 | (arg))
1240*19c65091SMatthew Wilcox #define IFTRUE(arg)    (0x00000000 | (arg))
1241*19c65091SMatthew Wilcox 
1242*19c65091SMatthew Wilcox #define WHEN(phase)    (0x00030000 | (phase))
1243*19c65091SMatthew Wilcox #define IF(phase)      (0x00020000 | (phase))
1244*19c65091SMatthew Wilcox 
1245*19c65091SMatthew Wilcox #define DATA(D)        (0x00040000 | ((D) & 0xff))
1246*19c65091SMatthew Wilcox #define MASK(D,M)      (0x00040000 | (((M ^ 0xff) & 0xff) << 8ul)|((D) & 0xff))
1247*19c65091SMatthew Wilcox 
1248*19c65091SMatthew Wilcox #define CARRYSET       (0x00200000)
1249*19c65091SMatthew Wilcox 
1250*19c65091SMatthew Wilcox /*-----------------------------------------------------------
1251*19c65091SMatthew Wilcox **
1252*19c65091SMatthew Wilcox **	SCSI  constants.
1253*19c65091SMatthew Wilcox **
1254*19c65091SMatthew Wilcox **-----------------------------------------------------------
1255*19c65091SMatthew Wilcox */
1256*19c65091SMatthew Wilcox 
1257*19c65091SMatthew Wilcox /*
1258*19c65091SMatthew Wilcox **	Messages
1259*19c65091SMatthew Wilcox */
1260*19c65091SMatthew Wilcox 
1261*19c65091SMatthew Wilcox #define	M_COMPLETE	COMMAND_COMPLETE
1262*19c65091SMatthew Wilcox #define	M_EXTENDED	EXTENDED_MESSAGE
1263*19c65091SMatthew Wilcox #define	M_SAVE_DP	SAVE_POINTERS
1264*19c65091SMatthew Wilcox #define	M_RESTORE_DP	RESTORE_POINTERS
1265*19c65091SMatthew Wilcox #define	M_DISCONNECT	DISCONNECT
1266*19c65091SMatthew Wilcox #define	M_ID_ERROR	INITIATOR_ERROR
1267*19c65091SMatthew Wilcox #define	M_ABORT		ABORT_TASK_SET
1268*19c65091SMatthew Wilcox #define	M_REJECT	MESSAGE_REJECT
1269*19c65091SMatthew Wilcox #define	M_NOOP		NOP
1270*19c65091SMatthew Wilcox #define	M_PARITY	MSG_PARITY_ERROR
1271*19c65091SMatthew Wilcox #define	M_LCOMPLETE	LINKED_CMD_COMPLETE
1272*19c65091SMatthew Wilcox #define	M_FCOMPLETE	LINKED_FLG_CMD_COMPLETE
1273*19c65091SMatthew Wilcox #define	M_RESET		TARGET_RESET
1274*19c65091SMatthew Wilcox #define	M_ABORT_TAG	ABORT_TASK
1275*19c65091SMatthew Wilcox #define	M_CLEAR_QUEUE	CLEAR_TASK_SET
1276*19c65091SMatthew Wilcox #define	M_INIT_REC	INITIATE_RECOVERY
1277*19c65091SMatthew Wilcox #define	M_REL_REC	RELEASE_RECOVERY
1278*19c65091SMatthew Wilcox #define	M_TERMINATE	(0x11)
1279*19c65091SMatthew Wilcox #define	M_SIMPLE_TAG	SIMPLE_QUEUE_TAG
1280*19c65091SMatthew Wilcox #define	M_HEAD_TAG	HEAD_OF_QUEUE_TAG
1281*19c65091SMatthew Wilcox #define	M_ORDERED_TAG	ORDERED_QUEUE_TAG
1282*19c65091SMatthew Wilcox #define	M_IGN_RESIDUE	IGNORE_WIDE_RESIDUE
1283*19c65091SMatthew Wilcox #define	M_IDENTIFY   	(0x80)
1284*19c65091SMatthew Wilcox 
1285*19c65091SMatthew Wilcox #define	M_X_MODIFY_DP	EXTENDED_MODIFY_DATA_POINTER
1286*19c65091SMatthew Wilcox #define	M_X_SYNC_REQ	EXTENDED_SDTR
1287*19c65091SMatthew Wilcox #define	M_X_WIDE_REQ	EXTENDED_WDTR
1288*19c65091SMatthew Wilcox #define	M_X_PPR_REQ	EXTENDED_PPR
1289*19c65091SMatthew Wilcox 
1290*19c65091SMatthew Wilcox /*
1291*19c65091SMatthew Wilcox **	Status
1292*19c65091SMatthew Wilcox */
1293*19c65091SMatthew Wilcox 
1294*19c65091SMatthew Wilcox #define	S_GOOD		(0x00)
1295*19c65091SMatthew Wilcox #define	S_CHECK_COND	(0x02)
1296*19c65091SMatthew Wilcox #define	S_COND_MET	(0x04)
1297*19c65091SMatthew Wilcox #define	S_BUSY		(0x08)
1298*19c65091SMatthew Wilcox #define	S_INT		(0x10)
1299*19c65091SMatthew Wilcox #define	S_INT_COND_MET	(0x14)
1300*19c65091SMatthew Wilcox #define	S_CONFLICT	(0x18)
1301*19c65091SMatthew Wilcox #define	S_TERMINATED	(0x20)
1302*19c65091SMatthew Wilcox #define	S_QUEUE_FULL	(0x28)
1303*19c65091SMatthew Wilcox #define	S_ILLEGAL	(0xff)
1304*19c65091SMatthew Wilcox #define	S_SENSE		(0x80)
1305*19c65091SMatthew Wilcox 
1306*19c65091SMatthew Wilcox /*
1307*19c65091SMatthew Wilcox  * End of ncrreg from FreeBSD
1308*19c65091SMatthew Wilcox  */
13091da177e4SLinus Torvalds 
13101da177e4SLinus Torvalds /*
13111da177e4SLinus Torvalds 	Build a scatter/gather entry.
13121da177e4SLinus Torvalds 	see sym53c8xx_2/sym_hipd.h for more detailed sym_build_sge()
13131da177e4SLinus Torvalds 	implementation ;)
13141da177e4SLinus Torvalds  */
13151da177e4SLinus Torvalds 
13161da177e4SLinus Torvalds #define ncr_build_sge(np, data, badd, len)	\
13171da177e4SLinus Torvalds do {						\
13181da177e4SLinus Torvalds 	(data)->addr = cpu_to_scr(badd);	\
13191da177e4SLinus Torvalds 	(data)->size = cpu_to_scr(len);		\
13201da177e4SLinus Torvalds } while (0)
13211da177e4SLinus Torvalds 
13221da177e4SLinus Torvalds /*==========================================================
13231da177e4SLinus Torvalds **
13241da177e4SLinus Torvalds **	Structures used by the detection routine to transmit
13251da177e4SLinus Torvalds **	device configuration to the attach function.
13261da177e4SLinus Torvalds **
13271da177e4SLinus Torvalds **==========================================================
13281da177e4SLinus Torvalds */
13291da177e4SLinus Torvalds struct ncr_slot {
13301da177e4SLinus Torvalds 	u_long	base;
13311da177e4SLinus Torvalds 	u_long	base_2;
13321da177e4SLinus Torvalds 	u_long	base_c;
13331da177e4SLinus Torvalds 	u_long	base_2_c;
13341da177e4SLinus Torvalds 	void __iomem *base_v;
13351da177e4SLinus Torvalds 	void __iomem *base_2_v;
13361da177e4SLinus Torvalds 	int	irq;
13371da177e4SLinus Torvalds /* port and reg fields to use INB, OUTB macros */
13381da177e4SLinus Torvalds 	volatile struct ncr_reg	__iomem *reg;
13391da177e4SLinus Torvalds };
13401da177e4SLinus Torvalds 
13411da177e4SLinus Torvalds /*==========================================================
13421da177e4SLinus Torvalds **
13431da177e4SLinus Torvalds **	Structure used by detection routine to save data on
13441da177e4SLinus Torvalds **	each detected board for attach.
13451da177e4SLinus Torvalds **
13461da177e4SLinus Torvalds **==========================================================
13471da177e4SLinus Torvalds */
13481da177e4SLinus Torvalds struct ncr_device {
13491da177e4SLinus Torvalds 	struct device  *dev;
13501da177e4SLinus Torvalds 	struct ncr_slot  slot;
13511da177e4SLinus Torvalds 	struct ncr_chip  chip;
13521da177e4SLinus Torvalds 	u_char host_id;
13531da177e4SLinus Torvalds 	u8 differential;
13541da177e4SLinus Torvalds };
13551da177e4SLinus Torvalds 
13561da177e4SLinus Torvalds extern struct Scsi_Host *ncr_attach(struct scsi_host_template *tpnt, int unit, struct ncr_device *device);
13571da177e4SLinus Torvalds extern int ncr53c8xx_release(struct Scsi_Host *host);
13581da177e4SLinus Torvalds irqreturn_t ncr53c8xx_intr(int irq, void *dev_id, struct pt_regs * regs);
13591da177e4SLinus Torvalds extern int ncr53c8xx_init(void);
13601da177e4SLinus Torvalds extern void ncr53c8xx_exit(void);
13611da177e4SLinus Torvalds 
13621da177e4SLinus Torvalds #endif /* NCR53C8XX_H */
1363