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