- pre4:
[davej-history.git] / drivers / scsi / 53c7xx.h
blobf579d9573d543d903a949248f7e35800094430e8
1 /*
2 * 53c710 driver. Modified from Drew Eckhardts driver
3 * for 53c810 by Richard Hirst [richard@sleepie.demon.co.uk]
5 * I have left the code for the 53c8xx family in here, because it didn't
6 * seem worth removing it. The possibility of IO_MAPPED chips rather
7 * than MEMORY_MAPPED remains, in case someone wants to add support for
8 * 53c710 chips on Intel PCs (some older machines have them on the
9 * motherboard).
11 * NOTE THERE MAY BE PROBLEMS WITH CASTS IN read8 AND Co.
15 * NCR 53c{7,8}0x0 driver, header file
17 * Sponsored by
18 * iX Multiuser Multitasking Magazine
19 * Hannover, Germany
20 * hm@ix.de
22 * Copyright 1993, 1994, 1995 Drew Eckhardt
23 * Visionary Computing
24 * (Unix and Linux consulting and custom programming)
25 * drew@PoohSticks.ORG
26 * +1 (303) 786-7975
28 * TolerANT and SCSI SCRIPTS are registered trademarks of NCR Corporation.
30 * PRE-ALPHA
32 * For more information, please consult
34 * NCR 53C700/53C700-66
35 * SCSI I/O Processor
36 * Data Manual
38 * NCR 53C810
39 * PCI-SCSI I/O Processor
40 * Data Manual
42 * NCR Microelectronics
43 * 1635 Aeroplaza Drive
44 * Colorado Springs, CO 80916
45 * +1 (719) 578-3400
47 * Toll free literature number
48 * +1 (800) 334-5454
52 #ifndef NCR53c710_H
53 #define NCR53c710_H
54 #include <linux/version.h>
56 /*
57 * Prevent name space pollution in hosts.c, and only provide the
58 * define we need to get the NCR53c7x0 driver into the host template
59 * array.
62 #if defined(HOSTS_C) || defined(MODULE)
63 #include <scsi/scsicam.h>
65 extern int NCR53c7xx_abort(Scsi_Cmnd *);
66 extern int NCR53c7xx_detect(Scsi_Host_Template *tpnt);
67 extern int NCR53c7xx_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
68 extern int NCR53c7xx_reset(Scsi_Cmnd *, unsigned int);
69 #ifdef MODULE
70 extern int NCR53c7xx_release(struct Scsi_Host *);
71 #else
72 #define NCR53c7xx_release NULL
73 #endif
75 #define NCR53c7xx {NULL, NULL, NULL, NULL, \
76 "NCR53c{7,8}xx (rel 17)", NCR53c7xx_detect,\
77 NULL, /* info */ NULL, /* command, deprecated */ NULL, \
78 NCR53c7xx_queue_command, NCR53c7xx_abort, NCR53c7xx_reset, \
79 NULL /* slave attach */, scsicam_bios_param, /* can queue */ 24, \
80 /* id */ 7, 127 /* old SG_ALL */, /* cmd per lun */ 3, \
81 /* present */ 0, /* unchecked isa dma */ 0, DISABLE_CLUSTERING}
83 #endif /* defined(HOSTS_C) || defined(MODULE) */
85 #ifndef HOSTS_C
87 /* SCSI control 0 rw, default = 0xc0 */
88 #define SCNTL0_REG 0x00
89 #define SCNTL0_ARB1 0x80 /* 0 0 = simple arbitration */
90 #define SCNTL0_ARB2 0x40 /* 1 1 = full arbitration */
91 #define SCNTL0_STRT 0x20 /* Start Sequence */
92 #define SCNTL0_WATN 0x10 /* Select with ATN */
93 #define SCNTL0_EPC 0x08 /* Enable parity checking */
94 /* Bit 2 is reserved on 800 series chips */
95 #define SCNTL0_EPG_700 0x04 /* Enable parity generation */
96 #define SCNTL0_AAP 0x02 /* ATN/ on parity error */
97 #define SCNTL0_TRG 0x01 /* Target mode */
99 /* SCSI control 1 rw, default = 0x00 */
101 #define SCNTL1_REG 0x01
102 #define SCNTL1_EXC 0x80 /* Extra Clock Cycle of Data setup */
103 #define SCNTL1_ADB 0x40 /* contents of SODL on bus */
104 #define SCNTL1_ESR_700 0x20 /* Enable SIOP response to selection
105 and reselection */
106 #define SCNTL1_DHP_800 0x20 /* Disable halt on parity error or ATN
107 target mode only */
108 #define SCNTL1_CON 0x10 /* Connected */
109 #define SCNTL1_RST 0x08 /* SCSI RST/ */
110 #define SCNTL1_AESP 0x04 /* Force bad parity */
111 #define SCNTL1_SND_700 0x02 /* Start SCSI send */
112 #define SCNTL1_IARB_800 0x02 /* Immediate Arbitration, start
113 arbitration immediately after
114 busfree is detected */
115 #define SCNTL1_RCV_700 0x01 /* Start SCSI receive */
116 #define SCNTL1_SST_800 0x01 /* Start SCSI transfer */
118 /* SCSI control 2 rw, */
120 #define SCNTL2_REG_800 0x02
121 #define SCNTL2_800_SDU 0x80 /* SCSI disconnect unexpected */
123 /* SCSI control 3 rw */
125 #define SCNTL3_REG_800 0x03
126 #define SCNTL3_800_SCF_SHIFT 4
127 #define SCNTL3_800_SCF_MASK 0x70
128 #define SCNTL3_800_SCF2 0x40 /* Synchronous divisor */
129 #define SCNTL3_800_SCF1 0x20 /* 0x00 = SCLK/3 */
130 #define SCNTL3_800_SCF0 0x10 /* 0x10 = SCLK/1 */
131 /* 0x20 = SCLK/1.5
132 0x30 = SCLK/2
133 0x40 = SCLK/3 */
135 #define SCNTL3_800_CCF_SHIFT 0
136 #define SCNTL3_800_CCF_MASK 0x07
137 #define SCNTL3_800_CCF2 0x04 /* 0x00 50.01 to 66 */
138 #define SCNTL3_800_CCF1 0x02 /* 0x01 16.67 to 25 */
139 #define SCNTL3_800_CCF0 0x01 /* 0x02 25.01 - 37.5
140 0x03 37.51 - 50
141 0x04 50.01 - 66 */
144 * SCSI destination ID rw - the appropriate bit is set for the selected
145 * target ID. This is written by the SCSI SCRIPTS processor.
146 * default = 0x00
148 #define SDID_REG_700 0x02
149 #define SDID_REG_800 0x06
151 #define GP_REG_800 0x07 /* General purpose IO */
152 #define GP_800_IO1 0x02
153 #define GP_800_IO2 0x01
155 /* SCSI interrupt enable rw, default = 0x00 */
156 #define SIEN_REG_700 0x03
157 #define SIEN0_REG_800 0x40
158 #define SIEN_MA 0x80 /* Phase mismatch (ini) or ATN (tgt) */
159 #define SIEN_FC 0x40 /* Function complete */
160 #define SIEN_700_STO 0x20 /* Selection or reselection timeout */
161 #define SIEN_800_SEL 0x20 /* Selected */
162 #define SIEN_700_SEL 0x10 /* Selected or reselected */
163 #define SIEN_800_RESEL 0x10 /* Reselected */
164 #define SIEN_SGE 0x08 /* SCSI gross error */
165 #define SIEN_UDC 0x04 /* Unexpected disconnect */
166 #define SIEN_RST 0x02 /* SCSI RST/ received */
167 #define SIEN_PAR 0x01 /* Parity error */
170 * SCSI chip ID rw
171 * NCR53c700 :
172 * When arbitrating, the highest bit is used, when reselection or selection
173 * occurs, the chip responds to all IDs for which a bit is set.
174 * default = 0x00
175 * NCR53c810 :
176 * Uses bit mapping
178 #define SCID_REG 0x04
179 /* Bit 7 is reserved on 800 series chips */
180 #define SCID_800_RRE 0x40 /* Enable response to reselection */
181 #define SCID_800_SRE 0x20 /* Enable response to selection */
182 /* Bits four and three are reserved on 800 series chips */
183 #define SCID_800_ENC_MASK 0x07 /* Encoded SCSI ID */
185 /* SCSI transfer rw, default = 0x00 */
186 #define SXFER_REG 0x05
187 #define SXFER_DHP 0x80 /* Disable halt on parity */
189 #define SXFER_TP2 0x40 /* Transfer period msb */
190 #define SXFER_TP1 0x20
191 #define SXFER_TP0 0x10 /* lsb */
192 #define SXFER_TP_MASK 0x70
193 /* FIXME : SXFER_TP_SHIFT == 5 is right for '8xx chips */
194 #define SXFER_TP_SHIFT 5
195 #define SXFER_TP_4 0x00 /* Divisors */
196 #define SXFER_TP_5 0x10<<1
197 #define SXFER_TP_6 0x20<<1
198 #define SXFER_TP_7 0x30<<1
199 #define SXFER_TP_8 0x40<<1
200 #define SXFER_TP_9 0x50<<1
201 #define SXFER_TP_10 0x60<<1
202 #define SXFER_TP_11 0x70<<1
204 #define SXFER_MO3 0x08 /* Max offset msb */
205 #define SXFER_MO2 0x04
206 #define SXFER_MO1 0x02
207 #define SXFER_MO0 0x01 /* lsb */
208 #define SXFER_MO_MASK 0x0f
209 #define SXFER_MO_SHIFT 0
212 * SCSI output data latch rw
213 * The contents of this register are driven onto the SCSI bus when
214 * the Assert Data Bus bit of the SCNTL1 register is set and
215 * the CD, IO, and MSG bits of the SOCL register match the SCSI phase
217 #define SODL_REG_700 0x06
218 #define SODL_REG_800 0x54
222 * SCSI output control latch rw, default = 0
223 * Note that when the chip is being manually programmed as an initiator,
224 * the MSG, CD, and IO bits must be set correctly for the phase the target
225 * is driving the bus in. Otherwise no data transfer will occur due to
226 * phase mismatch.
229 #define SOCL_REG 0x07
230 #define SOCL_REQ 0x80 /* REQ */
231 #define SOCL_ACK 0x40 /* ACK */
232 #define SOCL_BSY 0x20 /* BSY */
233 #define SOCL_SEL 0x10 /* SEL */
234 #define SOCL_ATN 0x08 /* ATN */
235 #define SOCL_MSG 0x04 /* MSG */
236 #define SOCL_CD 0x02 /* C/D */
237 #define SOCL_IO 0x01 /* I/O */
240 * SCSI first byte received latch ro
241 * This register contains the first byte received during a block MOVE
242 * SCSI SCRIPTS instruction, including
244 * Initiator mode Target mode
245 * Message in Command
246 * Status Message out
247 * Data in Data out
249 * It also contains the selecting or reselecting device's ID and our
250 * ID.
252 * Note that this is the register the various IF conditionals can
253 * operate on.
255 #define SFBR_REG 0x08
258 * SCSI input data latch ro
259 * In initiator mode, data is latched into this register on the rising
260 * edge of REQ/. In target mode, data is latched on the rising edge of
261 * ACK/
263 #define SIDL_REG_700 0x09
264 #define SIDL_REG_800 0x50
267 * SCSI bus data lines ro
268 * This register reflects the instantaneous status of the SCSI data
269 * lines. Note that SCNTL0 must be set to disable parity checking,
270 * otherwise reading this register will latch new parity.
272 #define SBDL_REG_700 0x0a
273 #define SBDL_REG_800 0x58
275 #define SSID_REG_800 0x0a
276 #define SSID_800_VAL 0x80 /* Exactly two bits asserted at sel */
277 #define SSID_800_ENCID_MASK 0x07 /* Device which performed operation */
281 * SCSI bus control lines rw,
282 * instantaneous readout of control lines
284 #define SBCL_REG 0x0b
285 #define SBCL_REQ 0x80 /* REQ ro */
286 #define SBCL_ACK 0x40 /* ACK ro */
287 #define SBCL_BSY 0x20 /* BSY ro */
288 #define SBCL_SEL 0x10 /* SEL ro */
289 #define SBCL_ATN 0x08 /* ATN ro */
290 #define SBCL_MSG 0x04 /* MSG ro */
291 #define SBCL_CD 0x02 /* C/D ro */
292 #define SBCL_IO 0x01 /* I/O ro */
293 #define SBCL_PHASE_CMDOUT SBCL_CD
294 #define SBCL_PHASE_DATAIN SBCL_IO
295 #define SBCL_PHASE_DATAOUT 0
296 #define SBCL_PHASE_MSGIN (SBCL_CD|SBCL_IO|SBCL_MSG)
297 #define SBCL_PHASE_MSGOUT (SBCL_CD|SBCL_MSG)
298 #define SBCL_PHASE_STATIN (SBCL_CD|SBCL_IO)
299 #define SBCL_PHASE_MASK (SBCL_CD|SBCL_IO|SBCL_MSG)
301 * Synchronous SCSI Clock Control bits
302 * 0 - set by DCNTL
303 * 1 - SCLK / 1.0
304 * 2 - SCLK / 1.5
305 * 3 - SCLK / 2.0
307 #define SBCL_SSCF1 0x02 /* wo, -66 only */
308 #define SBCL_SSCF0 0x01 /* wo, -66 only */
309 #define SBCL_SSCF_MASK 0x03
312 * XXX note : when reading the DSTAT and STAT registers to clear interrupts,
313 * insure that 10 clocks elapse between the two
315 /* DMA status ro */
316 #define DSTAT_REG 0x0c
317 #define DSTAT_DFE 0x80 /* DMA FIFO empty */
318 #define DSTAT_800_MDPE 0x40 /* Master Data Parity Error */
319 #define DSTAT_800_BF 0x20 /* Bus Fault */
320 #define DSTAT_ABRT 0x10 /* Aborted - set on error */
321 #define DSTAT_SSI 0x08 /* SCRIPTS single step interrupt */
322 #define DSTAT_SIR 0x04 /* SCRIPTS interrupt received -
323 set when INT instruction is
324 executed */
325 #define DSTAT_WTD 0x02 /* Watchdog timeout detected */
326 #define DSTAT_OPC 0x01 /* Illegal instruction */
327 #define DSTAT_800_IID 0x01 /* Same thing, different name */
330 /* NCR53c800 moves this stuff into SIST0 */
331 #define SSTAT0_REG 0x0d /* SCSI status 0 ro */
332 #define SIST0_REG_800 0x42
333 #define SSTAT0_MA 0x80 /* ini : phase mismatch,
334 * tgt : ATN/ asserted
336 #define SSTAT0_CMP 0x40 /* function complete */
337 #define SSTAT0_700_STO 0x20 /* Selection or reselection timeout */
338 #define SIST0_800_SEL 0x20 /* Selected */
339 #define SSTAT0_700_SEL 0x10 /* Selected or reselected */
340 #define SIST0_800_RSL 0x10 /* Reselected */
341 #define SSTAT0_SGE 0x08 /* SCSI gross error */
342 #define SSTAT0_UDC 0x04 /* Unexpected disconnect */
343 #define SSTAT0_RST 0x02 /* SCSI RST/ received */
344 #define SSTAT0_PAR 0x01 /* Parity error */
346 /* And uses SSTAT0 for what was SSTAT1 */
348 #define SSTAT1_REG 0x0e /* SCSI status 1 ro */
349 #define SSTAT1_ILF 0x80 /* SIDL full */
350 #define SSTAT1_ORF 0x40 /* SODR full */
351 #define SSTAT1_OLF 0x20 /* SODL full */
352 #define SSTAT1_AIP 0x10 /* Arbitration in progress */
353 #define SSTAT1_LOA 0x08 /* Lost arbitration */
354 #define SSTAT1_WOA 0x04 /* Won arbitration */
355 #define SSTAT1_RST 0x02 /* Instant readout of RST/ */
356 #define SSTAT1_SDP 0x01 /* Instant readout of SDP/ */
358 #define SSTAT2_REG 0x0f /* SCSI status 2 ro */
359 #define SSTAT2_FF3 0x80 /* number of bytes in synchronous */
360 #define SSTAT2_FF2 0x40 /* data FIFO */
361 #define SSTAT2_FF1 0x20
362 #define SSTAT2_FF0 0x10
363 #define SSTAT2_FF_MASK 0xf0
364 #define SSTAT2_FF_SHIFT 4
367 * Latched signals, latched on the leading edge of REQ/ for initiators,
368 * ACK/ for targets.
370 #define SSTAT2_SDP 0x08 /* SDP */
371 #define SSTAT2_MSG 0x04 /* MSG */
372 #define SSTAT2_CD 0x02 /* C/D */
373 #define SSTAT2_IO 0x01 /* I/O */
374 #define SSTAT2_PHASE_CMDOUT SSTAT2_CD
375 #define SSTAT2_PHASE_DATAIN SSTAT2_IO
376 #define SSTAT2_PHASE_DATAOUT 0
377 #define SSTAT2_PHASE_MSGIN (SSTAT2_CD|SSTAT2_IO|SSTAT2_MSG)
378 #define SSTAT2_PHASE_MSGOUT (SSTAT2_CD|SSTAT2_MSG)
379 #define SSTAT2_PHASE_STATIN (SSTAT2_CD|SSTAT2_IO)
380 #define SSTAT2_PHASE_MASK (SSTAT2_CD|SSTAT2_IO|SSTAT2_MSG)
383 /* NCR53c700-66 only */
384 #define SCRATCHA_REG_00 0x10 /* through 0x13 Scratch A rw */
385 /* NCR53c710 and higher */
386 #define DSA_REG 0x10 /* DATA structure address */
388 #define CTEST0_REG_700 0x14 /* Chip test 0 ro */
389 #define CTEST0_REG_800 0x18 /* Chip test 0 rw, general purpose */
390 /* 0x80 - 0x04 are reserved */
391 #define CTEST0_700_RTRG 0x02 /* Real target mode */
392 #define CTEST0_700_DDIR 0x01 /* Data direction, 1 =
393 * SCSI bus to host, 0 =
394 * host to SCSI.
397 #define CTEST1_REG_700 0x15 /* Chip test 1 ro */
398 #define CTEST1_REG_800 0x19 /* Chip test 1 ro */
399 #define CTEST1_FMT3 0x80 /* Identify which byte lanes are empty */
400 #define CTEST1_FMT2 0x40 /* in the DMA FIFO */
401 #define CTEST1_FMT1 0x20
402 #define CTEST1_FMT0 0x10
404 #define CTEST1_FFL3 0x08 /* Identify which bytes lanes are full */
405 #define CTEST1_FFL2 0x04 /* in the DMA FIFO */
406 #define CTEST1_FFL1 0x02
407 #define CTEST1_FFL0 0x01
409 #define CTEST2_REG_700 0x16 /* Chip test 2 ro */
410 #define CTEST2_REG_800 0x1a /* Chip test 2 ro */
412 #define CTEST2_800_DDIR 0x80 /* 1 = SCSI->host */
413 #define CTEST2_800_SIGP 0x40 /* A copy of SIGP in ISTAT.
414 Reading this register clears */
415 #define CTEST2_800_CIO 0x20 /* Configured as IO */.
416 #define CTEST2_800_CM 0x10 /* Configured as memory */
418 /* 0x80 - 0x40 are reserved on 700 series chips */
419 #define CTEST2_700_SOFF 0x20 /* SCSI Offset Compare,
420 * As an initiator, this bit is
421 * one when the synchronous offset
422 * is zero, as a target this bit
423 * is one when the synchronous
424 * offset is at the maximum
425 * defined in SXFER
427 #define CTEST2_700_SFP 0x10 /* SCSI FIFO parity bit,
428 * reading CTEST3 unloads a byte
429 * from the FIFO and sets this
431 #define CTEST2_700_DFP 0x08 /* DMA FIFO parity bit,
432 * reading CTEST6 unloads a byte
433 * from the FIFO and sets this
435 #define CTEST2_TEOP 0x04 /* SCSI true end of process,
436 * indicates a totally finished
437 * transfer
439 #define CTEST2_DREQ 0x02 /* Data request signal */
440 /* 0x01 is reserved on 700 series chips */
441 #define CTEST2_800_DACK 0x01
444 * Chip test 3 ro
445 * Unloads the bottom byte of the eight deep SCSI synchronous FIFO,
446 * check SSTAT2 FIFO full bits to determine size. Note that a GROSS
447 * error results if a read is attempted on this register. Also note
448 * that 16 and 32 bit reads of this register will cause corruption.
450 #define CTEST3_REG_700 0x17
451 /* Chip test 3 rw */
452 #define CTEST3_REG_800 0x1b
453 #define CTEST3_800_V3 0x80 /* Chip revision */
454 #define CTEST3_800_V2 0x40
455 #define CTEST3_800_V1 0x20
456 #define CTEST3_800_V0 0x10
457 #define CTEST3_800_FLF 0x08 /* Flush DMA FIFO */
458 #define CTEST3_800_CLF 0x04 /* Clear DMA FIFO */
459 #define CTEST3_800_FM 0x02 /* Fetch mode pin */
460 /* bit 0 is reserved on 800 series chips */
462 #define CTEST4_REG_700 0x18 /* Chip test 4 rw */
463 #define CTEST4_REG_800 0x21 /* Chip test 4 rw */
464 /* 0x80 is reserved on 700 series chips */
465 #define CTEST4_800_BDIS 0x80 /* Burst mode disable */
466 #define CTEST4_ZMOD 0x40 /* High impedance mode */
467 #define CTEST4_SZM 0x20 /* SCSI bus high impedance */
468 #define CTEST4_700_SLBE 0x10 /* SCSI loopback enabled */
469 #define CTEST4_800_SRTM 0x10 /* Shadow Register Test Mode */
470 #define CTEST4_700_SFWR 0x08 /* SCSI FIFO write enable,
471 * redirects writes from SODL
472 * to the SCSI FIFO.
474 #define CTEST4_800_MPEE 0x08 /* Enable parity checking
475 during master cycles on PCI
476 bus */
479 * These bits send the contents of the CTEST6 register to the appropriate
480 * byte lane of the 32 bit DMA FIFO. Normal operation is zero, otherwise
481 * the high bit means the low two bits select the byte lane.
483 #define CTEST4_FBL2 0x04
484 #define CTEST4_FBL1 0x02
485 #define CTEST4_FBL0 0x01
486 #define CTEST4_FBL_MASK 0x07
487 #define CTEST4_FBL_0 0x04 /* Select DMA FIFO byte lane 0 */
488 #define CTEST4_FBL_1 0x05 /* Select DMA FIFO byte lane 1 */
489 #define CTEST4_FBL_2 0x06 /* Select DMA FIFO byte lane 2 */
490 #define CTEST4_FBL_3 0x07 /* Select DMA FIFO byte lane 3 */
491 #define CTEST4_800_SAVE (CTEST4_800_BDIS)
494 #define CTEST5_REG_700 0x19 /* Chip test 5 rw */
495 #define CTEST5_REG_800 0x22 /* Chip test 5 rw */
497 * Clock Address Incrementor. When set, it increments the
498 * DNAD register to the next bus size boundary. It automatically
499 * resets itself when the operation is complete.
501 #define CTEST5_ADCK 0x80
503 * Clock Byte Counter. When set, it decrements the DBC register to
504 * the next bus size boundary.
506 #define CTEST5_BBCK 0x40
508 * Reset SCSI Offset. Setting this bit to 1 clears the current offset
509 * pointer in the SCSI synchronous offset counter (SSTAT). This bit
510 * is set to 1 if a SCSI Gross Error Condition occurs. The offset should
511 * be cleared when a synchronous transfer fails. When written, it is
512 * automatically cleared after the SCSI synchronous offset counter is
513 * reset.
515 /* Bit 5 is reserved on 800 series chips */
516 #define CTEST5_700_ROFF 0x20
518 * Master Control for Set or Reset pulses. When 1, causes the low
519 * four bits of register to set when set, 0 causes the low bits to
520 * clear when set.
522 #define CTEST5_MASR 0x10
523 #define CTEST5_DDIR 0x08 /* DMA direction */
525 * Bits 2-0 are reserved on 800 series chips
527 #define CTEST5_700_EOP 0x04 /* End of process */
528 #define CTEST5_700_DREQ 0x02 /* Data request */
529 #define CTEST5_700_DACK 0x01 /* Data acknowledge */
532 * Chip test 6 rw - writing to this register writes to the byte
533 * lane in the DMA FIFO as determined by the FBL bits in the CTEST4
534 * register.
536 #define CTEST6_REG_700 0x1a
537 #define CTEST6_REG_800 0x23
539 #define CTEST7_REG 0x1b /* Chip test 7 rw */
540 /* 0x80 - 0x40 are reserved on NCR53c700 and NCR53c700-66 chips */
541 #define CTEST7_10_CDIS 0x80 /* Cache burst disable */
542 #define CTEST7_10_SC1 0x40 /* Snoop control bits */
543 #define CTEST7_10_SC0 0x20
544 #define CTEST7_10_SC_MASK 0x60
545 /* 0x20 is reserved on the NCR53c700 */
546 #define CTEST7_0060_FM 0x20 /* Fetch mode */
547 #define CTEST7_STD 0x10 /* Selection timeout disable */
548 #define CTEST7_DFP 0x08 /* DMA FIFO parity bit for CTEST6 */
549 #define CTEST7_EVP 0x04 /* 1 = host bus even parity, 0 = odd */
550 #define CTEST7_10_TT1 0x02 /* Transfer type */
551 #define CTEST7_00_DC 0x02 /* Set to drive DC low during instruction
552 fetch */
553 #define CTEST7_DIFF 0x01 /* Differential mode */
555 #define CTEST7_SAVE ( CTEST7_EVP | CTEST7_DIFF )
558 #define TEMP_REG 0x1c /* through 0x1f Temporary stack rw */
560 #define DFIFO_REG 0x20 /* DMA FIFO rw */
562 * 0x80 is reserved on the NCR53c710, the CLF and FLF bits have been
563 * moved into the CTEST8 register.
565 #define DFIFO_00_FLF 0x80 /* Flush DMA FIFO to memory */
566 #define DFIFO_00_CLF 0x40 /* Clear DMA and SCSI FIFOs */
567 #define DFIFO_BO6 0x40
568 #define DFIFO_BO5 0x20
569 #define DFIFO_BO4 0x10
570 #define DFIFO_BO3 0x08
571 #define DFIFO_BO2 0x04
572 #define DFIFO_BO1 0x02
573 #define DFIFO_BO0 0x01
574 #define DFIFO_10_BO_MASK 0x7f /* 7 bit counter */
575 #define DFIFO_00_BO_MASK 0x3f /* 6 bit counter */
578 * Interrupt status rw
579 * Note that this is the only register which can be read while SCSI
580 * SCRIPTS are being executed.
582 #define ISTAT_REG_700 0x21
583 #define ISTAT_REG_800 0x14
584 #define ISTAT_ABRT 0x80 /* Software abort, write
585 *1 to abort, wait for interrupt. */
586 /* 0x40 and 0x20 are reserved on NCR53c700 and NCR53c700-66 chips */
587 #define ISTAT_10_SRST 0x40 /* software reset */
588 #define ISTAT_10_SIGP 0x20 /* signal script */
589 /* 0x10 is reserved on NCR53c700 series chips */
590 #define ISTAT_800_SEM 0x10 /* semaphore */
591 #define ISTAT_CON 0x08 /* 1 when connected */
592 #define ISTAT_800_INTF 0x04 /* Interrupt on the fly */
593 #define ISTAT_700_PRE 0x04 /* Pointer register empty.
594 * Set to 1 when DSPS and DSP
595 * registers are empty in pipeline
596 * mode, always set otherwise.
598 #define ISTAT_SIP 0x02 /* SCSI interrupt pending from
599 * SCSI portion of SIOP see
600 * SSTAT0
602 #define ISTAT_DIP 0x01 /* DMA interrupt pending
603 * see DSTAT
606 /* NCR53c700-66 and NCR53c710 only */
607 #define CTEST8_REG 0x22 /* Chip test 8 rw */
608 #define CTEST8_0066_EAS 0x80 /* Enable alternate SCSI clock,
609 * ie read from SCLK/ rather than CLK/
611 #define CTEST8_0066_EFM 0x40 /* Enable fetch and master outputs */
612 #define CTEST8_0066_GRP 0x20 /* Generate Receive Parity for
613 * pass through. This insures that
614 * bad parity won't reach the host
615 * bus.
617 #define CTEST8_0066_TE 0x10 /* TolerANT enable. Enable
618 * active negation, should only
619 * be used for slow SCSI
620 * non-differential.
622 #define CTEST8_0066_HSC 0x08 /* Halt SCSI clock */
623 #define CTEST8_0066_SRA 0x04 /* Shorten REQ/ACK filtering,
624 * must be set for fast SCSI-II
625 * speeds.
627 #define CTEST8_0066_DAS 0x02 /* Disable automatic target/initiator
628 * switching.
630 #define CTEST8_0066_LDE 0x01 /* Last disconnect enable.
631 * The status of pending
632 * disconnect is maintained by
633 * the core, eliminating
634 * the possibility of missing a
635 * selection or reselection
636 * while waiting to fetch a
637 * WAIT DISCONNECT opcode.
640 #define CTEST8_10_V3 0x80 /* Chip revision */
641 #define CTEST8_10_V2 0x40
642 #define CTEST8_10_V1 0x20
643 #define CTEST8_10_V0 0x10
644 #define CTEST8_10_V_MASK 0xf0
645 #define CTEST8_10_FLF 0x08 /* Flush FIFOs */
646 #define CTEST8_10_CLF 0x04 /* Clear FIFOs */
647 #define CTEST8_10_FM 0x02 /* Fetch pin mode */
648 #define CTEST8_10_SM 0x01 /* Snoop pin mode */
652 * The CTEST9 register may be used to differentiate between a
653 * NCR53c700 and a NCR53c710.
655 * Write 0xff to this register.
656 * Read it.
657 * If the contents are 0xff, it is a NCR53c700
658 * If the contents are 0x00, it is a NCR53c700-66 first revision
659 * If the contents are some other value, it is some other NCR53c700-66
661 #define CTEST9_REG_00 0x23 /* Chip test 9 ro */
662 #define LCRC_REG_10 0x23
665 * 0x24 through 0x27 are the DMA byte counter register. Instructions
666 * write their high 8 bits into the DCMD register, the low 24 bits into
667 * the DBC register.
669 * Function is dependent on the command type being executed.
673 #define DBC_REG 0x24
675 * For Block Move Instructions, DBC is a 24 bit quantity representing
676 * the number of bytes to transfer.
677 * For Transfer Control Instructions, DBC is bit fielded as follows :
679 /* Bits 20 - 23 should be clear */
680 #define DBC_TCI_TRUE (1 << 19) /* Jump when true */
681 #define DBC_TCI_COMPARE_DATA (1 << 18) /* Compare data */
682 #define DBC_TCI_COMPARE_PHASE (1 << 17) /* Compare phase with DCMD field */
683 #define DBC_TCI_WAIT_FOR_VALID (1 << 16) /* Wait for REQ */
684 /* Bits 8 - 15 are reserved on some implementations ? */
685 #define DBC_TCI_MASK_MASK 0xff00 /* Mask for data compare */
686 #define DBC_TCI_MASK_SHIFT 8
687 #define DBC_TCI_DATA_MASK 0xff /* Data to be compared */
688 #define DBC_TCI_DATA_SHIFT 0
690 #define DBC_RWRI_IMMEDIATE_MASK 0xff00 /* Immediate data */
691 #define DBC_RWRI_IMMEDIATE_SHIFT 8 /* Amount to shift */
692 #define DBC_RWRI_ADDRESS_MASK 0x3f0000 /* Register address */
693 #define DBC_RWRI_ADDRESS_SHIFT 16
697 * DMA command r/w
699 #define DCMD_REG 0x27
700 #define DCMD_TYPE_MASK 0xc0 /* Masks off type */
701 #define DCMD_TYPE_BMI 0x00 /* Indicates a Block Move instruction */
702 #define DCMD_BMI_IO 0x01 /* I/O, CD, and MSG bits selecting */
703 #define DCMD_BMI_CD 0x02 /* the phase for the block MOVE */
704 #define DCMD_BMI_MSG 0x04 /* instruction */
706 #define DCMD_BMI_OP_MASK 0x18 /* mask for opcode */
707 #define DCMD_BMI_OP_MOVE_T 0x00 /* MOVE */
708 #define DCMD_BMI_OP_MOVE_I 0x08 /* MOVE Initiator */
710 #define DCMD_BMI_INDIRECT 0x20 /* Indirect addressing */
712 #define DCMD_TYPE_TCI 0x80 /* Indicates a Transfer Control
713 instruction */
714 #define DCMD_TCI_IO 0x01 /* I/O, CD, and MSG bits selecting */
715 #define DCMD_TCI_CD 0x02 /* the phase for the block MOVE */
716 #define DCMD_TCI_MSG 0x04 /* instruction */
717 #define DCMD_TCI_OP_MASK 0x38 /* mask for opcode */
718 #define DCMD_TCI_OP_JUMP 0x00 /* JUMP */
719 #define DCMD_TCI_OP_CALL 0x08 /* CALL */
720 #define DCMD_TCI_OP_RETURN 0x10 /* RETURN */
721 #define DCMD_TCI_OP_INT 0x18 /* INT */
723 #define DCMD_TYPE_RWRI 0x40 /* Indicates I/O or register Read/Write
724 instruction */
725 #define DCMD_RWRI_OPC_MASK 0x38 /* Opcode mask */
726 #define DCMD_RWRI_OPC_WRITE 0x28 /* Write SFBR to register */
727 #define DCMD_RWRI_OPC_READ 0x30 /* Read register to SFBR */
728 #define DCMD_RWRI_OPC_MODIFY 0x38 /* Modify in place */
730 #define DCMD_RWRI_OP_MASK 0x07
731 #define DCMD_RWRI_OP_MOVE 0x00
732 #define DCMD_RWRI_OP_SHL 0x01
733 #define DCMD_RWRI_OP_OR 0x02
734 #define DCMD_RWRI_OP_XOR 0x03
735 #define DCMD_RWRI_OP_AND 0x04
736 #define DCMD_RWRI_OP_SHR 0x05
737 #define DCMD_RWRI_OP_ADD 0x06
738 #define DCMD_RWRI_OP_ADDC 0x07
740 #define DCMD_TYPE_MMI 0xc0 /* Indicates a Memory Move instruction
741 (three words) */
744 #define DNAD_REG 0x28 /* through 0x2b DMA next address for
745 data */
746 #define DSP_REG 0x2c /* through 0x2f DMA SCRIPTS pointer rw */
747 #define DSPS_REG 0x30 /* through 0x33 DMA SCRIPTS pointer
748 save rw */
749 #define DMODE_REG_00 0x34 /* DMA mode rw */
750 #define DMODE_00_BL1 0x80 /* Burst length bits */
751 #define DMODE_00_BL0 0x40
752 #define DMODE_BL_MASK 0xc0
753 /* Burst lengths (800) */
754 #define DMODE_BL_2 0x00 /* 2 transfer */
755 #define DMODE_BL_4 0x40 /* 4 transfers */
756 #define DMODE_BL_8 0x80 /* 8 transfers */
757 #define DMODE_BL_16 0xc0 /* 16 transfers */
759 #define DMODE_10_BL_1 0x00 /* 1 transfer */
760 #define DMODE_10_BL_2 0x40 /* 2 transfers */
761 #define DMODE_10_BL_4 0x80 /* 4 transfers */
762 #define DMODE_10_BL_8 0xc0 /* 8 transfers */
763 #define DMODE_10_FC2 0x20 /* Driven to FC2 pin */
764 #define DMODE_10_FC1 0x10 /* Driven to FC1 pin */
765 #define DMODE_710_PD 0x08 /* Program/data on FC0 pin */
766 #define DMODE_710_UO 0x02 /* User prog. output */
768 #define DMODE_700_BW16 0x20 /* Host buswidth = 16 */
769 #define DMODE_700_286 0x10 /* 286 mode */
770 #define DMODE_700_IOM 0x08 /* Transfer to IO port */
771 #define DMODE_700_FAM 0x04 /* Fixed address mode */
772 #define DMODE_700_PIPE 0x02 /* Pipeline mode disables
773 * automatic fetch / exec
775 #define DMODE_MAN 0x01 /* Manual start mode,
776 * requires a 1 to be written
777 * to the start DMA bit in the DCNTL
778 * register to run scripts
781 #define DMODE_700_SAVE ( DMODE_00_BL_MASK | DMODE_00_BW16 | DMODE_00_286 )
783 /* NCR53c800 series only */
784 #define SCRATCHA_REG_800 0x34 /* through 0x37 Scratch A rw */
785 /* NCR53c710 only */
786 #define SCRATCHB_REG_10 0x34 /* through 0x37 scratch B rw */
788 #define DMODE_REG_10 0x38 /* DMA mode rw, NCR53c710 and newer */
789 #define DMODE_800_SIOM 0x20 /* Source IO = 1 */
790 #define DMODE_800_DIOM 0x10 /* Destination IO = 1 */
791 #define DMODE_800_ERL 0x08 /* Enable Read Line */
793 /* 35-38 are reserved on 700 and 700-66 series chips */
794 #define DIEN_REG 0x39 /* DMA interrupt enable rw */
795 /* 0x80, 0x40, and 0x20 are reserved on 700-series chips */
796 #define DIEN_800_MDPE 0x40 /* Master data parity error */
797 #define DIEN_800_BF 0x20 /* BUS fault */
798 #define DIEN_700_BF 0x20 /* BUS fault */
799 #define DIEN_ABRT 0x10 /* Enable aborted interrupt */
800 #define DIEN_SSI 0x08 /* Enable single step interrupt */
801 #define DIEN_SIR 0x04 /* Enable SCRIPTS INT command
802 * interrupt
804 /* 0x02 is reserved on 800 series chips */
805 #define DIEN_700_WTD 0x02 /* Enable watchdog timeout interrupt */
806 #define DIEN_700_OPC 0x01 /* Enable illegal instruction
807 * interrupt
809 #define DIEN_800_IID 0x01 /* Same meaning, different name */
812 * DMA watchdog timer rw
813 * set in 16 CLK input periods.
815 #define DWT_REG 0x3a
817 /* DMA control rw */
818 #define DCNTL_REG 0x3b
819 #define DCNTL_700_CF1 0x80 /* Clock divisor bits */
820 #define DCNTL_700_CF0 0x40
821 #define DCNTL_700_CF_MASK 0xc0
822 /* Clock divisors Divisor SCLK range (MHZ) */
823 #define DCNTL_700_CF_2 0x00 /* 2.0 37.51-50.00 */
824 #define DCNTL_700_CF_1_5 0x40 /* 1.5 25.01-37.50 */
825 #define DCNTL_700_CF_1 0x80 /* 1.0 16.67-25.00 */
826 #define DCNTL_700_CF_3 0xc0 /* 3.0 50.01-66.67 (53c700-66) */
828 #define DCNTL_700_S16 0x20 /* Load scripts 16 bits at a time */
829 #define DCNTL_SSM 0x10 /* Single step mode */
830 #define DCNTL_700_LLM 0x08 /* Low level mode, can only be set
831 * after selection */
832 #define DCNTL_800_IRQM 0x08 /* Totem pole IRQ pin */
833 #define DCNTL_STD 0x04 /* Start DMA / SCRIPTS */
834 /* 0x02 is reserved */
835 #define DCNTL_00_RST 0x01 /* Software reset, resets everything
836 * but 286 mode bit in DMODE. On the
837 * NCR53c710, this bit moved to CTEST8
839 #define DCNTL_10_COM 0x01 /* 700 software compatibility mode */
840 #define DCNTL_10_EA 0x20 /* Enable Ack - needed for MVME16x */
842 #define DCNTL_700_SAVE ( DCNTL_CF_MASK | DCNTL_S16)
845 /* NCR53c700-66 only */
846 #define SCRATCHB_REG_00 0x3c /* through 0x3f scratch b rw */
847 #define SCRATCHB_REG_800 0x5c /* through 0x5f scratch b rw */
848 /* NCR53c710 only */
849 #define ADDER_REG_10 0x3c /* Adder, NCR53c710 only */
851 #define SIEN1_REG_800 0x41
852 #define SIEN1_800_STO 0x04 /* selection/reselection timeout */
853 #define SIEN1_800_GEN 0x02 /* general purpose timer */
854 #define SIEN1_800_HTH 0x01 /* handshake to handshake */
856 #define SIST1_REG_800 0x43
857 #define SIST1_800_STO 0x04 /* selection/reselection timeout */
858 #define SIST1_800_GEN 0x02 /* general purpose timer */
859 #define SIST1_800_HTH 0x01 /* handshake to handshake */
861 #define SLPAR_REG_800 0x44 /* Parity */
863 #define MACNTL_REG_800 0x46 /* Memory access control */
864 #define MACNTL_800_TYP3 0x80
865 #define MACNTL_800_TYP2 0x40
866 #define MACNTL_800_TYP1 0x20
867 #define MACNTL_800_TYP0 0x10
868 #define MACNTL_800_DWR 0x08
869 #define MACNTL_800_DRD 0x04
870 #define MACNTL_800_PSCPT 0x02
871 #define MACNTL_800_SCPTS 0x01
873 #define GPCNTL_REG_800 0x47 /* General Purpose Pin Control */
875 /* Timeouts are expressed such that 0=off, 1=100us, doubling after that */
876 #define STIME0_REG_800 0x48 /* SCSI Timer Register 0 */
877 #define STIME0_800_HTH_MASK 0xf0 /* Handshake to Handshake timeout */
878 #define STIME0_800_HTH_SHIFT 4
879 #define STIME0_800_SEL_MASK 0x0f /* Selection timeout */
880 #define STIME0_800_SEL_SHIFT 0
882 #define STIME1_REG_800 0x49
883 #define STIME1_800_GEN_MASK 0x0f /* General purpose timer */
885 #define RESPID_REG_800 0x4a /* Response ID, bit fielded. 8
886 bits on narrow chips, 16 on WIDE */
888 #define STEST0_REG_800 0x4c
889 #define STEST0_800_SLT 0x08 /* Selection response logic test */
890 #define STEST0_800_ART 0x04 /* Arbitration priority encoder test */
891 #define STEST0_800_SOZ 0x02 /* Synchronous offset zero */
892 #define STEST0_800_SOM 0x01 /* Synchronous offset maximum */
894 #define STEST1_REG_800 0x4d
895 #define STEST1_800_SCLK 0x80 /* Disable SCSI clock */
897 #define STEST2_REG_800 0x4e
898 #define STEST2_800_SCE 0x80 /* Enable SOCL/SODL */
899 #define STEST2_800_ROF 0x40 /* Reset SCSI sync offset */
900 #define STEST2_800_SLB 0x10 /* Enable SCSI loopback mode */
901 #define STEST2_800_SZM 0x08 /* SCSI high impedance mode */
902 #define STEST2_800_EXT 0x02 /* Extend REQ/ACK filter 30 to 60ns */
903 #define STEST2_800_LOW 0x01 /* SCSI low level mode */
905 #define STEST3_REG_800 0x4f
906 #define STEST3_800_TE 0x80 /* Enable active negation */
907 #define STEST3_800_STR 0x40 /* SCSI FIFO test read */
908 #define STEST3_800_HSC 0x20 /* Halt SCSI clock */
909 #define STEST3_800_DSI 0x10 /* Disable single initiator response */
910 #define STEST3_800_TTM 0x04 /* Time test mode */
911 #define STEST3_800_CSF 0x02 /* Clear SCSI FIFO */
912 #define STEST3_800_STW 0x01 /* SCSI FIFO test write */
914 #define OPTION_PARITY 0x1 /* Enable parity checking */
915 #define OPTION_TAGGED_QUEUE 0x2 /* Enable SCSI-II tagged queuing */
916 #define OPTION_700 0x8 /* Always run NCR53c700 scripts */
917 #define OPTION_INTFLY 0x10 /* Use INTFLY interrupts */
918 #define OPTION_DEBUG_INTR 0x20 /* Debug interrupts */
919 #define OPTION_DEBUG_INIT_ONLY 0x40 /* Run initialization code and
920 simple test code, return
921 DID_NO_CONNECT if any SCSI
922 commands are attempted. */
923 #define OPTION_DEBUG_READ_ONLY 0x80 /* Return DID_ERROR if any
924 SCSI write is attempted */
925 #define OPTION_DEBUG_TRACE 0x100 /* Animated trace mode, print
926 each address and instruction
927 executed to debug buffer. */
928 #define OPTION_DEBUG_SINGLE 0x200 /* stop after executing one
929 instruction */
930 #define OPTION_SYNCHRONOUS 0x400 /* Enable sync SCSI. */
931 #define OPTION_MEMORY_MAPPED 0x800 /* NCR registers have valid
932 memory mapping */
933 #define OPTION_IO_MAPPED 0x1000 /* NCR registers have valid
934 I/O mapping */
935 #define OPTION_DEBUG_PROBE_ONLY 0x2000 /* Probe only, don't even init */
936 #define OPTION_DEBUG_TESTS_ONLY 0x4000 /* Probe, init, run selected tests */
937 #define OPTION_DEBUG_TEST0 0x08000 /* Run test 0 */
938 #define OPTION_DEBUG_TEST1 0x10000 /* Run test 1 */
939 #define OPTION_DEBUG_TEST2 0x20000 /* Run test 2 */
940 #define OPTION_DEBUG_DUMP 0x40000 /* Dump commands */
941 #define OPTION_DEBUG_TARGET_LIMIT 0x80000 /* Only talk to target+luns specified */
942 #define OPTION_DEBUG_NCOMMANDS_LIMIT 0x100000 /* Limit the number of commands */
943 #define OPTION_DEBUG_SCRIPT 0x200000 /* Print when checkpoints are passed */
944 #define OPTION_DEBUG_FIXUP 0x400000 /* print fixup values */
945 #define OPTION_DEBUG_DSA 0x800000
946 #define OPTION_DEBUG_CORRUPTION 0x1000000 /* Detect script corruption */
947 #define OPTION_DEBUG_SDTR 0x2000000 /* Debug SDTR problem */
948 #define OPTION_DEBUG_MISMATCH 0x4000000 /* Debug phase mismatches */
949 #define OPTION_DISCONNECT 0x8000000 /* Allow disconnect */
950 #define OPTION_DEBUG_DISCONNECT 0x10000000
951 #define OPTION_ALWAYS_SYNCHRONOUS 0x20000000 /* Negotiate sync. transfers
952 on power up */
953 #define OPTION_DEBUG_QUEUES 0x80000000
954 #define OPTION_DEBUG_ALLOCATION 0x100000000LL
955 #define OPTION_DEBUG_SYNCHRONOUS 0x200000000LL /* Sanity check SXFER and
956 SCNTL3 registers */
957 #define OPTION_NO_ASYNC 0x400000000LL /* Don't automagically send
958 SDTR for async transfers when
959 we haven't been told to do
960 a synchronous transfer. */
961 #define OPTION_NO_PRINT_RACE 0x800000000LL /* Don't print message when
962 the reselect/WAIT DISCONNECT
963 race condition hits */
964 #if !defined(PERM_OPTIONS)
965 #define PERM_OPTIONS 0
966 #endif
969 * Some data which is accessed by the NCR chip must be 4-byte aligned.
970 * For some hosts the default is less than that (eg. 68K uses 2-byte).
971 * Alignment has only been forced where it is important; also if one
972 * 32 bit structure field is aligned then it is assumed that following
973 * 32 bit fields are also aligned. Take care when adding fields
974 * which are other than 32 bit.
977 struct NCR53c7x0_synchronous {
978 u32 select_indirect /* Value used for indirect selection */
979 __attribute__ ((aligned (4)));
980 u32 sscf_710; /* Used to set SSCF bits for 710 */
981 u32 script[8]; /* Size ?? Script used when target is
982 reselected */
983 unsigned char synchronous_want[5]; /* Per target desired SDTR */
985 * Set_synchronous programs these, select_indirect and current settings after
986 * int_debug_should show a match.
988 unsigned char sxfer_sanity, scntl3_sanity;
991 #define CMD_FLAG_SDTR 1 /* Initiating synchronous
992 transfer negotiation */
993 #define CMD_FLAG_WDTR 2 /* Initiating wide transfer
994 negotiation */
995 #define CMD_FLAG_DID_SDTR 4 /* did SDTR */
996 #define CMD_FLAG_DID_WDTR 8 /* did WDTR */
998 struct NCR53c7x0_table_indirect {
999 u32 count;
1000 void *address;
1003 enum ncr_event {
1004 EVENT_NONE = 0,
1006 * Order is IMPORTANT, since these must correspond to the event interrupts
1007 * in 53c7,8xx.scr
1010 EVENT_ISSUE_QUEUE = 0x5000000, /* 0 Command was added to issue queue */
1011 EVENT_START_QUEUE, /* 1 Command moved to start queue */
1012 EVENT_SELECT, /* 2 Command completed selection */
1013 EVENT_DISCONNECT, /* 3 Command disconnected */
1014 EVENT_RESELECT, /* 4 Command reselected */
1015 EVENT_COMPLETE, /* 5 Command completed */
1016 EVENT_IDLE, /* 6 */
1017 EVENT_SELECT_FAILED, /* 7 */
1018 EVENT_BEFORE_SELECT, /* 8 */
1019 EVENT_RESELECT_FAILED /* 9 */
1022 struct NCR53c7x0_event {
1023 enum ncr_event event; /* What type of event */
1024 unsigned char target;
1025 unsigned char lun;
1026 struct timeval time;
1027 u32 *dsa; /* What's in the DSA register now (virt) */
1029 * A few things from that SCSI pid so we know what happened after
1030 * the Scsi_Cmnd structure in question may have disappeared.
1032 unsigned long pid; /* The SCSI PID which caused this
1033 event */
1034 unsigned char cmnd[12];
1038 * Things in the NCR53c7x0_cmd structure are split into two parts :
1040 * 1. A fixed portion, for things which are not accessed directly by static NCR
1041 * code (ie, are referenced only by the Linux side of the driver,
1042 * or only by dynamically generated code).
1044 * 2. The DSA portion, for things which are accessed directly by static NCR
1045 * code.
1047 * This is a little ugly, but it
1048 * 1. Avoids conflicts between the NCR code's picture of the structure, and
1049 * Linux code's idea of what it looks like.
1051 * 2. Minimizes the pain in the Linux side of the code needed
1052 * to calculate real dsa locations for things, etc.
1056 struct NCR53c7x0_cmd {
1057 void *real; /* Real, unaligned address for
1058 free function */
1059 void (* free)(void *, int); /* Command to deallocate; NULL
1060 for structures allocated with
1061 scsi_register, etc. */
1062 Scsi_Cmnd *cmd; /* Associated Scsi_Cmnd
1063 structure, Scsi_Cmnd points
1064 at NCR53c7x0_cmd using
1065 host_scribble structure */
1067 int size; /* scsi_malloc'd size of this
1068 structure */
1070 int flags; /* CMD_* flags */
1072 unsigned char cmnd[12]; /* CDB, copied from Scsi_Cmnd */
1073 int result; /* Copy to Scsi_Cmnd when done */
1075 struct { /* Private non-cached bounce buffer */
1076 unsigned char buf[256];
1077 u32 addr;
1078 u32 len;
1079 } bounce;
1082 * SDTR and WIDE messages are an either/or affair
1083 * in this message, since we will go into message out and send
1084 * _the whole mess_ without dropping out of message out to
1085 * let the target go into message in after sending the first
1086 * message.
1089 unsigned char select[11]; /* Select message, includes
1090 IDENTIFY
1091 (optional) QUEUE TAG
1092 (optional) SDTR or WDTR
1096 volatile struct NCR53c7x0_cmd *next; /* Linux maintained lists (free,
1097 running, eventually finished */
1100 u32 *data_transfer_start; /* Start of data transfer routines */
1101 u32 *data_transfer_end; /* Address after end of data transfer o
1102 routines */
1104 * The following three fields were moved from the DSA proper to here
1105 * since only dynamically generated NCR code refers to them, meaning
1106 * we don't need dsa_* absolutes, and it is simpler to let the
1107 * host code refer to them directly.
1111 * HARD CODED : residual and saved_residual need to agree with the sizes
1112 * used in NCR53c7,8xx.scr.
1114 * FIXME: we want to consider the case where we have odd-length
1115 * scatter/gather buffers and a WIDE transfer, in which case
1116 * we'll need to use the CHAIN MOVE instruction. Ick.
1118 u32 residual[6] __attribute__ ((aligned (4)));
1119 /* Residual data transfer which
1120 allows pointer code to work
1121 right.
1123 [0-1] : Conditional call to
1124 appropriate other transfer
1125 routine.
1126 [2-3] : Residual block transfer
1127 instruction.
1128 [4-5] : Jump to instruction
1129 after splice.
1131 u32 saved_residual[6]; /* Copy of old residual, so we
1132 can get another partial
1133 transfer and still recover
1136 u32 saved_data_pointer; /* Saved data pointer */
1138 u32 dsa_next_addr; /* _Address_ of dsa_next field
1139 in this dsa for RISCy
1140 style constant. */
1142 u32 dsa_addr; /* Address of dsa; RISCy style
1143 constant */
1145 u32 dsa[0]; /* Variable length (depending
1146 on host type, number of scatter /
1147 gather buffers, etc). */
1150 struct NCR53c7x0_break {
1151 u32 *address, old_instruction[2];
1152 struct NCR53c7x0_break *next;
1153 unsigned char old_size; /* Size of old instruction */
1156 /* Indicates that the NCR is not executing code */
1157 #define STATE_HALTED 0
1159 * Indicates that the NCR is executing the wait for select / reselect
1160 * script. Only used when running NCR53c700 compatible scripts, only
1161 * state during which an ABORT is _not_ considered an error condition.
1163 #define STATE_WAITING 1
1164 /* Indicates that the NCR is executing other code. */
1165 #define STATE_RUNNING 2
1167 * Indicates that the NCR was being aborted.
1169 #define STATE_ABORTING 3
1170 /* Indicates that the NCR was successfully aborted. */
1171 #define STATE_ABORTED 4
1172 /* Indicates that the NCR has been disabled due to a fatal error */
1173 #define STATE_DISABLED 5
1176 * Where knowledge of SCSI SCRIPT(tm) specified values are needed
1177 * in an interrupt handler, an interrupt handler exists for each
1178 * different SCSI script so we don't have name space problems.
1180 * Return values of these handlers are as follows :
1182 #define SPECIFIC_INT_NOTHING 0 /* don't even restart */
1183 #define SPECIFIC_INT_RESTART 1 /* restart at the next instruction */
1184 #define SPECIFIC_INT_ABORT 2 /* recoverable error, abort cmd */
1185 #define SPECIFIC_INT_PANIC 3 /* unrecoverable error, panic */
1186 #define SPECIFIC_INT_DONE 4 /* normal command completion */
1187 #define SPECIFIC_INT_BREAK 5 /* break point encountered */
1189 struct NCR53c7x0_hostdata {
1190 int size; /* Size of entire Scsi_Host
1191 structure */
1192 int board; /* set to board type, useful if
1193 we have host specific things,
1194 ie, a general purpose I/O
1195 bit is being used to enable
1196 termination, etc. */
1198 int chip; /* set to chip type; 700-66 is
1199 700-66, rest are last three
1200 digits of part number */
1202 char valid_ids[8]; /* Valid SCSI ID's for adapter */
1204 u32 *dsp; /* dsp to restart with after
1205 all stacked interrupts are
1206 handled. */
1208 unsigned dsp_changed:1; /* Has dsp changed within this
1209 set of stacked interrupts ? */
1211 unsigned char dstat; /* Most recent value of dstat */
1212 unsigned dstat_valid:1;
1214 unsigned expecting_iid:1; /* Expect IID interrupt */
1215 unsigned expecting_sto:1; /* Expect STO interrupt */
1218 * The code stays cleaner if we use variables with function
1219 * pointers and offsets that are unique for the different
1220 * scripts rather than having a slew of switch(hostdata->chip)
1221 * statements.
1223 * It also means that the #defines from the SCSI SCRIPTS(tm)
1224 * don't have to be visible outside of the script-specific
1225 * instructions, preventing name space pollution.
1228 void (* init_fixup)(struct Scsi_Host *host);
1229 void (* init_save_regs)(struct Scsi_Host *host);
1230 void (* dsa_fixup)(struct NCR53c7x0_cmd *cmd);
1231 void (* soft_reset)(struct Scsi_Host *host);
1232 int (* run_tests)(struct Scsi_Host *host);
1235 * Called when DSTAT_SIR is set, indicating an interrupt generated
1236 * by the INT instruction, where values are unique for each SCSI
1237 * script. Should return one of the SPEC_* values.
1240 int (* dstat_sir_intr)(struct Scsi_Host *host, struct NCR53c7x0_cmd *cmd);
1242 int dsa_len; /* Size of DSA structure */
1245 * Location of DSA fields for the SCSI SCRIPT corresponding to this
1246 * chip.
1249 s32 dsa_start;
1250 s32 dsa_end;
1251 s32 dsa_next;
1252 s32 dsa_prev;
1253 s32 dsa_cmnd;
1254 s32 dsa_select;
1255 s32 dsa_msgout;
1256 s32 dsa_cmdout;
1257 s32 dsa_dataout;
1258 s32 dsa_datain;
1259 s32 dsa_msgin;
1260 s32 dsa_msgout_other;
1261 s32 dsa_write_sync;
1262 s32 dsa_write_resume;
1263 s32 dsa_check_reselect;
1264 s32 dsa_status;
1265 s32 dsa_saved_pointer;
1266 s32 dsa_jump_dest;
1269 * Important entry points that generic fixup code needs
1270 * to know about, fixed up.
1273 s32 E_accept_message;
1274 s32 E_command_complete;
1275 s32 E_data_transfer;
1276 s32 E_dsa_code_template;
1277 s32 E_dsa_code_template_end;
1278 s32 E_end_data_transfer;
1279 s32 E_msg_in;
1280 s32 E_initiator_abort;
1281 s32 E_other_transfer;
1282 s32 E_other_in;
1283 s32 E_other_out;
1284 s32 E_target_abort;
1285 s32 E_debug_break;
1286 s32 E_reject_message;
1287 s32 E_respond_message;
1288 s32 E_select;
1289 s32 E_select_msgout;
1290 s32 E_test_0;
1291 s32 E_test_1;
1292 s32 E_test_2;
1293 s32 E_test_3;
1294 s32 E_dsa_zero;
1295 s32 E_cmdout_cmdout;
1296 s32 E_wait_reselect;
1297 s32 E_dsa_code_begin;
1299 long long options; /* Bitfielded set of options enabled */
1300 volatile u32 test_completed; /* Test completed */
1301 int test_running; /* Test currently running */
1302 s32 test_source
1303 __attribute__ ((aligned (4)));
1304 volatile s32 test_dest;
1306 volatile int state; /* state of driver, only used for
1307 OPTION_700 */
1309 unsigned char dmode; /*
1310 * set to the address of the DMODE
1311 * register for this chip.
1313 unsigned char istat; /*
1314 * set to the address of the ISTAT
1315 * register for this chip.
1318 int scsi_clock; /*
1319 * SCSI clock in HZ. 0 may be used
1320 * for unknown, although this will
1321 * disable synchronous negotiation.
1324 volatile int intrs; /* Number of interrupts */
1325 volatile int resets; /* Number of SCSI resets */
1326 unsigned char saved_dmode;
1327 unsigned char saved_ctest4;
1328 unsigned char saved_ctest7;
1329 unsigned char saved_dcntl;
1330 unsigned char saved_scntl3;
1332 unsigned char this_id_mask;
1334 /* Debugger information */
1335 struct NCR53c7x0_break *breakpoints, /* Linked list of all break points */
1336 *breakpoint_current; /* Current breakpoint being stepped
1337 through, NULL if we are running
1338 normally. */
1339 #ifdef NCR_DEBUG
1340 int debug_size; /* Size of debug buffer */
1341 volatile int debug_count; /* Current data count */
1342 volatile char *debug_buf; /* Output ring buffer */
1343 volatile char *debug_write; /* Current write pointer */
1344 volatile char *debug_read; /* Current read pointer */
1345 #endif /* def NCR_DEBUG */
1347 /* XXX - primitive debugging junk, remove when working ? */
1348 int debug_print_limit; /* Number of commands to print
1349 out exhaustive debugging
1350 information for if
1351 OPTION_DEBUG_DUMP is set */
1353 unsigned char debug_lun_limit[16]; /* If OPTION_DEBUG_TARGET_LIMIT
1354 set, puke if commands are sent
1355 to other target/lun combinations */
1357 int debug_count_limit; /* Number of commands to execute
1358 before puking to limit debugging
1359 output */
1362 volatile unsigned idle:1; /* set to 1 if idle */
1365 * Table of synchronous+wide transfer parameters set on a per-target
1366 * basis.
1369 volatile struct NCR53c7x0_synchronous sync[16]
1370 __attribute__ ((aligned (4)));
1372 volatile Scsi_Cmnd *issue_queue
1373 __attribute__ ((aligned (4)));
1374 /* waiting to be issued by
1375 Linux driver */
1376 volatile struct NCR53c7x0_cmd *running_list;
1377 /* commands running, maintained
1378 by Linux driver */
1380 volatile struct NCR53c7x0_cmd *ncrcurrent; /* currently connected
1381 nexus, ONLY valid for
1382 NCR53c700/NCR53c700-66
1385 volatile struct NCR53c7x0_cmd *spare; /* pointer to spare,
1386 allocated at probe time,
1387 which we can use for
1388 initialization */
1389 volatile struct NCR53c7x0_cmd *free;
1390 int max_cmd_size; /* Maximum size of NCR53c7x0_cmd
1391 based on number of
1392 scatter/gather segments, etc.
1394 volatile int num_cmds; /* Number of commands
1395 allocated */
1396 volatile int extra_allocate;
1397 volatile unsigned char cmd_allocated[16]; /* Have we allocated commands
1398 for this target yet? If not,
1399 do so ASAP */
1400 volatile unsigned char busy[16][8]; /* number of commands
1401 executing on each target
1404 * Eventually, I'll switch to a coroutine for calling
1405 * cmd->done(cmd), etc. so that we can overlap interrupt
1406 * processing with this code for maximum performance.
1409 volatile struct NCR53c7x0_cmd *finished_queue;
1411 /* Shared variables between SCRIPT and host driver */
1412 volatile u32 *schedule
1413 __attribute__ ((aligned (4))); /* Array of JUMPs to dsa_begin
1414 routines of various DSAs.
1415 When not in use, replace
1416 with jump to next slot */
1419 volatile unsigned char msg_buf[16]; /* buffer for messages
1420 other than the command
1421 complete message */
1423 /* Per-target default synchronous and WIDE messages */
1424 volatile unsigned char synchronous_want[16][5];
1425 volatile unsigned char wide_want[16][4];
1427 /* Bit fielded set of targets we want to speak synchronously with */
1428 volatile u16 initiate_sdtr;
1429 /* Bit fielded set of targets we want to speak wide with */
1430 volatile u16 initiate_wdtr;
1431 /* Bit fielded list of targets we've talked to. */
1432 volatile u16 talked_to;
1434 /* Array of bit-fielded lun lists that we need to request_sense */
1435 volatile unsigned char request_sense[16];
1437 u32 addr_reconnect_dsa_head
1438 __attribute__ ((aligned (4))); /* RISCy style constant,
1439 address of following */
1440 volatile u32 reconnect_dsa_head;
1441 /* Data identifying nexus we are trying to match during reselection */
1442 volatile unsigned char reselected_identify; /* IDENTIFY message */
1443 volatile unsigned char reselected_tag; /* second byte of queue tag
1444 message or 0 */
1446 /* These were static variables before we moved them */
1448 s32 NCR53c7xx_zero
1449 __attribute__ ((aligned (4)));
1450 s32 NCR53c7xx_sink;
1451 u32 NOP_insn;
1452 char NCR53c7xx_msg_reject;
1453 char NCR53c7xx_msg_abort;
1454 char NCR53c7xx_msg_nop;
1457 * Following item introduced by RGH to support NCRc710, which is
1458 * VERY brain-dead when it come to memory moves
1461 /* DSA save area used only by the NCR chip */
1462 volatile unsigned long saved2_dsa
1463 __attribute__ ((aligned (4)));
1465 volatile unsigned long emulated_intfly
1466 __attribute__ ((aligned (4)));
1468 volatile int event_size, event_index;
1469 volatile struct NCR53c7x0_event *events;
1471 /* If we need to generate code to kill off the currently connected
1472 command, this is where we do it. Should have a BMI instruction
1473 to source or sink the current data, followed by a JUMP
1474 to abort_connected */
1476 u32 *abort_script;
1478 int script_count; /* Size of script in words */
1479 u32 script[0]; /* Relocated SCSI script */
1483 #define IRQ_NONE 255
1484 #define DMA_NONE 255
1485 #define IRQ_AUTO 254
1486 #define DMA_AUTO 254
1488 #define BOARD_GENERIC 0
1490 #define NCR53c7x0_insn_size(insn) \
1491 (((insn) & DCMD_TYPE_MASK) == DCMD_TYPE_MMI ? 3 : 2)
1494 #define NCR53c7x0_local_declare() \
1495 volatile unsigned char *NCR53c7x0_address_memory; \
1496 unsigned int NCR53c7x0_address_io; \
1497 int NCR53c7x0_memory_mapped
1499 #define NCR53c7x0_local_setup(host) \
1500 NCR53c7x0_address_memory = (void *) (host)->base; \
1501 NCR53c7x0_address_io = (unsigned int) (host)->io_port; \
1502 NCR53c7x0_memory_mapped = ((struct NCR53c7x0_hostdata *) \
1503 host->hostdata[0])-> options & OPTION_MEMORY_MAPPED
1505 #ifdef BIG_ENDIAN
1506 /* These could be more efficient, given that we are always memory mapped,
1507 * but they don't give the same problems as the write macros, so leave
1508 * them. */
1509 #define NCR53c7x0_read8(address) \
1510 (NCR53c7x0_memory_mapped ? \
1511 (unsigned int)readb((u32)NCR53c7x0_address_memory + ((u32)(address)^3)) : \
1512 inb(NCR53c7x0_address_io + (address)))
1514 #define NCR53c7x0_read16(address) \
1515 (NCR53c7x0_memory_mapped ? \
1516 (unsigned int)readw((u32)NCR53c7x0_address_memory + ((u32)(address)^2)) : \
1517 inw(NCR53c7x0_address_io + (address)))
1518 #else
1519 #define NCR53c7x0_read8(address) \
1520 (NCR53c7x0_memory_mapped ? \
1521 (unsigned int)readb((u32)NCR53c7x0_address_memory + (u32)(address)) : \
1522 inb(NCR53c7x0_address_io + (address)))
1524 #define NCR53c7x0_read16(address) \
1525 (NCR53c7x0_memory_mapped ? \
1526 (unsigned int)readw((u32)NCR53c7x0_address_memory + (u32)(address)) : \
1527 inw(NCR53c7x0_address_io + (address)))
1528 #endif
1529 #define NCR53c7x0_read32(address) \
1530 (NCR53c7x0_memory_mapped ? \
1531 (unsigned int) readl((u32)NCR53c7x0_address_memory + (u32)(address)) : \
1532 inl(NCR53c7x0_address_io + (address)))
1534 #ifdef BIG_ENDIAN
1535 /* If we are big-endian, then we are not Intel, so probably don't have
1536 * an i/o map as well as a memory map. So, let's assume memory mapped.
1537 * Also, I am having terrible problems trying to persuade the compiler
1538 * not to lay down code which does a read after write for these macros.
1539 * If you remove 'volatile' from writeb() and friends it is ok....
1542 #define NCR53c7x0_write8(address,value) \
1543 *(volatile unsigned char *) \
1544 ((u32)NCR53c7x0_address_memory + ((u32)(address)^3)) = (value)
1546 #define NCR53c7x0_write16(address,value) \
1547 *(volatile unsigned short *) \
1548 ((u32)NCR53c7x0_address_memory + ((u32)(address)^2)) = (value)
1550 #define NCR53c7x0_write32(address,value) \
1551 *(volatile unsigned long *) \
1552 ((u32)NCR53c7x0_address_memory + ((u32)(address))) = (value)
1554 #else
1556 #define NCR53c7x0_write8(address,value) \
1557 (NCR53c7x0_memory_mapped ? \
1558 ({writeb((value), (u32)NCR53c7x0_address_memory + (u32)(address)); mb();}) : \
1559 outb((value), NCR53c7x0_address_io + (address)))
1561 #define NCR53c7x0_write16(address,value) \
1562 (NCR53c7x0_memory_mapped ? \
1563 ({writew((value), (u32)NCR53c7x0_address_memory + (u32)(address)); mb();}) : \
1564 outw((value), NCR53c7x0_address_io + (address)))
1566 #define NCR53c7x0_write32(address,value) \
1567 (NCR53c7x0_memory_mapped ? \
1568 ({writel((value), (u32)NCR53c7x0_address_memory + (u32)(address)); mb();}) : \
1569 outl((value), NCR53c7x0_address_io + (address)))
1571 #endif
1573 /* Patch arbitrary 32 bit words in the script */
1574 #define patch_abs_32(script, offset, symbol, value) \
1575 for (i = 0; i < (sizeof (A_##symbol##_used) / sizeof \
1576 (u32)); ++i) { \
1577 (script)[A_##symbol##_used[i] - (offset)] += (value); \
1578 if (hostdata->options & OPTION_DEBUG_FIXUP) \
1579 printk("scsi%d : %s reference %d at 0x%x in %s is now 0x%x\n",\
1580 host->host_no, #symbol, i, A_##symbol##_used[i] - \
1581 (int)(offset), #script, (script)[A_##symbol##_used[i] - \
1582 (offset)]); \
1585 /* Patch read/write instruction immediate field */
1586 #define patch_abs_rwri_data(script, offset, symbol, value) \
1587 for (i = 0; i < (sizeof (A_##symbol##_used) / sizeof \
1588 (u32)); ++i) \
1589 (script)[A_##symbol##_used[i] - (offset)] = \
1590 ((script)[A_##symbol##_used[i] - (offset)] & \
1591 ~DBC_RWRI_IMMEDIATE_MASK) | \
1592 (((value) << DBC_RWRI_IMMEDIATE_SHIFT) & \
1593 DBC_RWRI_IMMEDIATE_MASK)
1595 /* Patch transfer control instruction data field */
1596 #define patch_abs_tci_data(script, offset, symbol, value) \
1597 for (i = 0; i < (sizeof (A_##symbol##_used) / sizeof \
1598 (u32)); ++i) \
1599 (script)[A_##symbol##_used[i] - (offset)] = \
1600 ((script)[A_##symbol##_used[i] - (offset)] & \
1601 ~DBC_TCI_DATA_MASK) | \
1602 (((value) << DBC_TCI_DATA_SHIFT) & \
1603 DBC_TCI_DATA_MASK)
1605 /* Patch field in dsa structure (assignment should be +=?) */
1606 #define patch_dsa_32(dsa, symbol, word, value) \
1608 (dsa)[(hostdata->##symbol - hostdata->dsa_start) / sizeof(u32) \
1609 + (word)] = (value); \
1610 if (hostdata->options & OPTION_DEBUG_DSA) \
1611 printk("scsi : dsa %s symbol %s(%d) word %d now 0x%x\n", \
1612 #dsa, #symbol, hostdata->##symbol, \
1613 (word), (u32) (value)); \
1616 /* Paranoid people could use panic() here. */
1617 #define FATAL(host) shutdown((host));
1619 #endif /* NCR53c710_C */
1620 #endif /* NCR53c710_H */