File: /usr/src/linux/drivers/scsi/sun3_scsi.h

1     /*
2      * Sun3 SCSI stuff by Erik Verbruggen (erik@bigmama.xtdnet.nl)
3      *
4      * Sun3 DMA additions by Sam Creasey (sammy@oh.verio.com)
5      *
6      * Adapted from mac_scsinew.h:
7      */
8     /*
9      * Cumana Generic NCR5380 driver defines
10      *
11      * Copyright 1993, Drew Eckhardt
12      *	Visionary Computing
13      *	(Unix and Linux consulting and custom programming)
14      *	drew@colorado.edu
15      *      +1 (303) 440-4894
16      *
17      * ALPHA RELEASE 1.
18      *
19      * For more information, please consult
20      *
21      * NCR 5380 Family
22      * SCSI Protocol Controller
23      * Databook
24      *
25      * NCR Microelectronics
26      * 1635 Aeroplaza Drive
27      * Colorado Springs, CO 80916
28      * 1+ (719) 578-3400
29      * 1+ (800) 334-5454
30      */
31     
32     /*
33      * $Log: cumana_NCR5380.h,v $
34      */
35     
36     #ifndef SUN3_NCR5380_H
37     #define SUN3_NCR5380_H
38     
39     #define SUN3SCSI_PUBLIC_RELEASE 1
40     
41     /*
42      * Int: level 2 autovector
43      * IO: type 1, base 0x00140000, 5 bits phys space: A<4..0>
44      */
45     #define IRQ_SUN3_SCSI 2
46     #define IOBASE_SUN3_SCSI 0x00140000
47     
48     int sun3scsi_abort (Scsi_Cmnd *);
49     int sun3scsi_detect (Scsi_Host_Template *);
50     int sun3scsi_release (struct Scsi_Host *);
51     const char *sun3scsi_info (struct Scsi_Host *);
52     int sun3scsi_reset(Scsi_Cmnd *, unsigned int);
53     int sun3scsi_queue_command (Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
54     int sun3scsi_proc_info (char *buffer, char **start, off_t offset,
55     			int length, int hostno, int inout);
56     
57     #ifndef NULL
58     #define NULL 0
59     #endif
60     
61     #ifndef CMD_PER_LUN
62     #define CMD_PER_LUN 2
63     #endif
64     
65     #ifndef CAN_QUEUE
66     #define CAN_QUEUE 16
67     #endif
68     
69     #ifndef SG_TABLESIZE
70     #define SG_TABLESIZE SG_NONE
71     #endif
72     
73     #ifndef USE_TAGGED_QUEUING
74     #define	USE_TAGGED_QUEUING 0
75     #endif
76     
77     #include <scsi/scsicam.h>
78     
79     #define SUN3_NCR5380 {							\
80     name:			"Sun3 NCR5380 SCSI",				\
81     detect:			sun3scsi_detect,				\
82     release:		sun3scsi_release,	/* Release */		\
83     info:			sun3scsi_info,					\
84     queuecommand:		sun3scsi_queue_command,				\
85     abort:			sun3scsi_abort,			 		\
86     reset:			sun3scsi_reset,					\
87     bios_param:		scsicam_bios_param,	/* biosparam */		\
88     can_queue:		CAN_QUEUE,		/* can queue */		\
89     this_id:		7,			/* id */		\
90     sg_tablesize:		SG_ALL,			/* sg_tablesize */	\
91     cmd_per_lun:		CMD_PER_LUN,		/* cmd per lun */	\
92     unchecked_isa_dma:	0,			/* unchecked_isa_dma */	\
93     use_clustering:		DISABLE_CLUSTERING				\
94     	}
95     
96     #ifndef HOSTS_C
97     
98     #define NCR5380_implementation_fields \
99         int port, ctrl
100     
101     #define NCR5380_local_declare() \
102             struct Scsi_Host *_instance
103     
104     #define NCR5380_setup(instance) \
105             _instance = instance
106     
107     #define NCR5380_read(reg) sun3scsi_read(reg)
108     #define NCR5380_write(reg, value) sun3scsi_write(reg, value)
109     
110     #define NCR5380_intr sun3scsi_intr
111     #define NCR5380_queue_command sun3scsi_queue_command
112     #define NCR5380_reset sun3scsi_reset
113     #define NCR5380_abort sun3scsi_abort
114     #define NCR5380_proc_info sun3scsi_proc_info
115     #define NCR5380_dma_xfer_len(i, cmd, phase) \
116             sun3scsi_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 : 1)
117     
118     #define NCR5380_dma_write_setup(instance, data, count) sun3scsi_dma_setup(data, count, 1)
119     #define NCR5380_dma_read_setup(instance, data, count) sun3scsi_dma_setup(data, count, 0)
120     #define NCR5380_dma_residual sun3scsi_dma_residual
121     
122     #define BOARD_NORMAL	0
123     #define BOARD_NCR53C400	1
124     
125     /* additional registers - mainly DMA control regs */
126     /* these start at regbase + 8 -- directly after the NCR regs */
127     struct sun3_dma_regs {
128     	unsigned short vmeregs[4];  /* unimpl vme stuff */
129     	unsigned short udc_data; /* udc dma data reg */
130     	unsigned short udc_addr; /* uda dma addr reg */
131     	unsigned short fifo_data; /* fifo data reg, holds extra byte on
132     				     odd dma reads */
133     	unsigned short fifo_count; 
134     	unsigned short csr; /* control/status reg */
135     };
136     
137     /* ucd chip specific regs - live in dvma space */
138     struct sun3_udc_regs {
139          unsigned short rsel; /* select regs to load */
140          unsigned short addr_hi; /* high word of addr */
141          unsigned short addr_lo; /* low word */
142          unsigned short count; /* words to be xfer'd */
143          unsigned short mode_hi; /* high word of channel mode */
144          unsigned short mode_lo; /* low word of channel mode */
145     };
146     
147     /* addresses of the udc registers */
148     #define UDC_MODE 0x38 
149     #define UDC_CSR 0x2e /* command/status */
150     #define UDC_CHN_HI 0x26 /* chain high word */
151     #define UDC_CHN_LO 0x22 /* chain lo word */
152     #define UDC_CURA_HI 0x1a /* cur reg A high */
153     #define UDC_CURA_LO 0x0a /* cur reg A low */
154     #define UDC_CURB_HI 0x12 /* cur reg B high */
155     #define UDC_CURB_LO 0x02 /* cur reg B low */
156     #define UDC_MODE_HI 0x56 /* mode reg high */
157     #define UDC_MODE_LO 0x52 /* mode reg low */
158     #define UDC_COUNT 0x32 /* words to xfer */
159     
160     /* some udc commands */
161     #define UDC_RESET 0
162     #define UDC_CHN_START 0xa0 /* start chain */
163     #define UDC_INT_ENABLE 0x32 /* channel 1 int on */
164     
165     /* udc mode words */
166     #define UDC_MODE_HIWORD 0x40
167     #define UDC_MODE_LSEND 0xc2
168     #define UDC_MODE_LRECV 0xd2
169     
170     /* udc reg selections */
171     #define UDC_RSEL_SEND 0x282
172     #define UDC_RSEL_RECV 0x182
173     
174     /* bits in csr reg */
175     #define CSR_DMA_ACTIVE 0x8000
176     #define CSR_DMA_CONFLICT 0x4000
177     #define CSR_DMA_BUSERR 0x2000
178     
179     #define CSR_FIFO_EMPTY 0x400 /* fifo flushed? */
180     #define CSR_SDB_INT 0x200 /* sbc interrupt pending */
181     #define CSR_DMA_INT 0x100 /* dma interrupt pending */
182     
183     #define CSR_SEND 0x8 /* 1 = send  0 = recv */
184     #define CSR_FIFO 0x2 /* reset fifo */
185     #define CSR_INTR 0x4 /* interrupt enable */
186     #define CSR_SCSI 0x1 
187     
188     // debugging printk's, taken from atari_scsi.h 
189     /* Debugging printk definitions:
190      *
191      *  ARB  -> arbitration
192      *  ASEN -> auto-sense
193      *  DMA  -> DMA
194      *  HSH  -> PIO handshake
195      *  INF  -> information transfer
196      *  INI  -> initialization
197      *  INT  -> interrupt
198      *  LNK  -> linked commands
199      *  MAIN -> NCR5380_main() control flow
200      *  NDAT -> no data-out phase
201      *  NWR  -> no write commands
202      *  PIO  -> PIO transfers
203      *  PDMA -> pseudo DMA (unused on Atari)
204      *  QU   -> queues
205      *  RSL  -> reselections
206      *  SEL  -> selections
207      *  USL  -> usleep cpde (unused on Atari)
208      *  LBS  -> last byte sent (unused on Atari)
209      *  RSS  -> restarting of selections
210      *  EXT  -> extended messages
211      *  ABRT -> aborting and resetting
212      *  TAG  -> queue tag handling
213      *  MER  -> merging of consec. buffers
214      *
215      */
216     
217     
218     
219     #if NDEBUG & NDEBUG_ARBITRATION
220     #define ARB_PRINTK(format, args...) \
221     	printk(KERN_DEBUG format , ## args)
222     #else
223     #define ARB_PRINTK(format, args...)
224     #endif
225     #if NDEBUG & NDEBUG_AUTOSENSE
226     #define ASEN_PRINTK(format, args...) \
227     	printk(KERN_DEBUG format , ## args)
228     #else
229     #define ASEN_PRINTK(format, args...)
230     #endif
231     #if NDEBUG & NDEBUG_DMA
232     #define DMA_PRINTK(format, args...) \
233     	printk(KERN_DEBUG format , ## args)
234     #else
235     #define DMA_PRINTK(format, args...)
236     #endif
237     #if NDEBUG & NDEBUG_HANDSHAKE
238     #define HSH_PRINTK(format, args...) \
239     	printk(KERN_DEBUG format , ## args)
240     #else
241     #define HSH_PRINTK(format, args...)
242     #endif
243     #if NDEBUG & NDEBUG_INFORMATION
244     #define INF_PRINTK(format, args...) \
245     	printk(KERN_DEBUG format , ## args)
246     #else
247     #define INF_PRINTK(format, args...)
248     #endif
249     #if NDEBUG & NDEBUG_INIT
250     #define INI_PRINTK(format, args...) \
251     	printk(KERN_DEBUG format , ## args)
252     #else
253     #define INI_PRINTK(format, args...)
254     #endif
255     #if NDEBUG & NDEBUG_INTR
256     #define INT_PRINTK(format, args...) \
257     	printk(KERN_DEBUG format , ## args)
258     #else
259     #define INT_PRINTK(format, args...)
260     #endif
261     #if NDEBUG & NDEBUG_LINKED
262     #define LNK_PRINTK(format, args...) \
263     	printk(KERN_DEBUG format , ## args)
264     #else
265     #define LNK_PRINTK(format, args...)
266     #endif
267     #if NDEBUG & NDEBUG_MAIN
268     #define MAIN_PRINTK(format, args...) \
269     	printk(KERN_DEBUG format , ## args)
270     #else
271     #define MAIN_PRINTK(format, args...)
272     #endif
273     #if NDEBUG & NDEBUG_NO_DATAOUT
274     #define NDAT_PRINTK(format, args...) \
275     	printk(KERN_DEBUG format , ## args)
276     #else
277     #define NDAT_PRINTK(format, args...)
278     #endif
279     #if NDEBUG & NDEBUG_NO_WRITE
280     #define NWR_PRINTK(format, args...) \
281     	printk(KERN_DEBUG format , ## args)
282     #else
283     #define NWR_PRINTK(format, args...)
284     #endif
285     #if NDEBUG & NDEBUG_PIO
286     #define PIO_PRINTK(format, args...) \
287     	printk(KERN_DEBUG format , ## args)
288     #else
289     #define PIO_PRINTK(format, args...)
290     #endif
291     #if NDEBUG & NDEBUG_PSEUDO_DMA
292     #define PDMA_PRINTK(format, args...) \
293     	printk(KERN_DEBUG format , ## args)
294     #else
295     #define PDMA_PRINTK(format, args...)
296     #endif
297     #if NDEBUG & NDEBUG_QUEUES
298     #define QU_PRINTK(format, args...) \
299     	printk(KERN_DEBUG format , ## args)
300     #else
301     #define QU_PRINTK(format, args...)
302     #endif
303     #if NDEBUG & NDEBUG_RESELECTION
304     #define RSL_PRINTK(format, args...) \
305     	printk(KERN_DEBUG format , ## args)
306     #else
307     #define RSL_PRINTK(format, args...)
308     #endif
309     #if NDEBUG & NDEBUG_SELECTION
310     #define SEL_PRINTK(format, args...) \
311     	printk(KERN_DEBUG format , ## args)
312     #else
313     #define SEL_PRINTK(format, args...)
314     #endif
315     #if NDEBUG & NDEBUG_USLEEP
316     #define USL_PRINTK(format, args...) \
317     	printk(KERN_DEBUG format , ## args)
318     #else
319     #define USL_PRINTK(format, args...)
320     #endif
321     #if NDEBUG & NDEBUG_LAST_BYTE_SENT
322     #define LBS_PRINTK(format, args...) \
323     	printk(KERN_DEBUG format , ## args)
324     #else
325     #define LBS_PRINTK(format, args...)
326     #endif
327     #if NDEBUG & NDEBUG_RESTART_SELECT
328     #define RSS_PRINTK(format, args...) \
329     	printk(KERN_DEBUG format , ## args)
330     #else
331     #define RSS_PRINTK(format, args...)
332     #endif
333     #if NDEBUG & NDEBUG_EXTENDED
334     #define EXT_PRINTK(format, args...) \
335     	printk(KERN_DEBUG format , ## args)
336     #else
337     #define EXT_PRINTK(format, args...)
338     #endif
339     #if NDEBUG & NDEBUG_ABORT
340     #define ABRT_PRINTK(format, args...) \
341     	printk(KERN_DEBUG format , ## args)
342     #else
343     #define ABRT_PRINTK(format, args...)
344     #endif
345     #if NDEBUG & NDEBUG_TAGS
346     #define TAG_PRINTK(format, args...) \
347     	printk(KERN_DEBUG format , ## args)
348     #else
349     #define TAG_PRINTK(format, args...)
350     #endif
351     #if NDEBUG & NDEBUG_MERGING
352     #define MER_PRINTK(format, args...) \
353     	printk(KERN_DEBUG format , ## args)
354     #else
355     #define MER_PRINTK(format, args...)
356     #endif
357     
358     /* conditional macros for NCR5380_print_{,phase,status} */
359     
360     #define NCR_PRINT(mask)	\
361     	((NDEBUG & (mask)) ? NCR5380_print(instance) : (void)0)
362     
363     #define NCR_PRINT_PHASE(mask) \
364     	((NDEBUG & (mask)) ? NCR5380_print_phase(instance) : (void)0)
365     
366     #define NCR_PRINT_STATUS(mask) \
367     	((NDEBUG & (mask)) ? NCR5380_print_status(instance) : (void)0)
368     
369     #define NDEBUG_ANY	0xffffffff
370     
371     
372     
373     #endif /* ndef HOSTS_C */
374     #endif /* SUN3_NCR5380_H */
375     
376