3 * Denis Peter, MPL AG Switzerland
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 * Most of these definitions are derived from
25 * linux/drivers/scsi/sym53c8xx_defs.h
29 #ifndef _SYM53C8XX_DEFS_H
30 #define _SYM53C8XX_DEFS_H
33 #define SCNTL0 0x00 /* full arb., ena parity, par->ATN */
35 #define SCNTL1 0x01 /* no reset */
36 #define ISCON 0x10 /* connected to scsi */
37 #define CRST 0x08 /* force reset */
38 #define IARB 0x02 /* immediate arbitration */
40 #define SCNTL2 0x02 /* no disconnect expected */
41 #define SDU 0x80 /* cmd: disconnect will raise error */
42 #define CHM 0x40 /* sta: chained mode */
43 #define WSS 0x08 /* sta: wide scsi send [W]*/
44 #define WSR 0x01 /* sta: wide scsi received [W]*/
46 #define SCNTL3 0x03 /* cnf system clock dependent */
47 #define EWS 0x08 /* cmd: enable wide scsi [W]*/
48 #define ULTRA 0x80 /* cmd: ULTRA enable */
49 /* bits 0-2, 7 rsvd for C1010 */
51 #define SCID 0x04 /* cnf host adapter scsi address */
52 #define RRE 0x40 /* r/w:e enable response to resel. */
53 #define SRE 0x20 /* r/w:e enable response to select */
55 #define SXFER 0x05 /* ### Sync speed and count */
56 /* bits 6-7 rsvd for C1010 */
58 #define SDID 0x06 /* ### Destination-ID */
60 #define GPREG 0x07 /* ??? IO-Pins */
62 #define SFBR 0x08 /* ### First byte in phase */
65 #define CREQ 0x80 /* r/w: SCSI-REQ */
66 #define CACK 0x40 /* r/w: SCSI-ACK */
67 #define CBSY 0x20 /* r/w: SCSI-BSY */
68 #define CSEL 0x10 /* r/w: SCSI-SEL */
69 #define CATN 0x08 /* r/w: SCSI-ATN */
70 #define CMSG 0x04 /* r/w: SCSI-MSG */
71 #define CC_D 0x02 /* r/w: SCSI-C_D */
72 #define CI_O 0x01 /* r/w: SCSI-I_O */
79 #define DFE 0x80 /* sta: dma fifo empty */
80 #define MDPE 0x40 /* int: master data parity error */
81 #define BF 0x20 /* int: script: bus fault */
82 #define ABRT 0x10 /* int: script: command aborted */
83 #define SSI 0x08 /* int: script: single step */
84 #define SIR 0x04 /* int: script: interrupt instruct. */
85 #define IID 0x01 /* int: script: illegal instruct. */
88 #define ILF 0x80 /* sta: data in SIDL register lsb */
89 #define ORF 0x40 /* sta: data in SODR register lsb */
90 #define OLF 0x20 /* sta: data in SODL register lsb */
91 #define AIP 0x10 /* sta: arbitration in progress */
92 #define LOA 0x08 /* sta: arbitration lost */
93 #define WOA 0x04 /* sta: arbitration won */
94 #define IRST 0x02 /* sta: scsi reset signal */
95 #define SDP 0x01 /* sta: scsi parity signal */
98 #define FF3210 0xf0 /* sta: bytes in the scsi fifo */
101 #define ILF1 0x80 /* sta: data in SIDL register msb[W]*/
102 #define ORF1 0x40 /* sta: data in SODR register msb[W]*/
103 #define OLF1 0x20 /* sta: data in SODL register msb[W]*/
104 #define DM 0x04 /* sta: DIFFSENS mismatch (895/6 only) */
105 #define LDSC 0x02 /* sta: disconnect & reconnect */
107 #define DSA 0x10 /* --> Base page */
112 #define ISTAT 0x14 /* --> Main Command and status */
113 #define CABRT 0x80 /* cmd: abort current operation */
114 #define SRST 0x40 /* mod: reset chip */
115 #define SIGP 0x20 /* r/w: message from host to ncr */
116 #define SEM 0x10 /* r/w: message between host + ncr */
117 #define CON 0x08 /* sta: connected to scsi */
118 #define INTF 0x04 /* sta: int on the fly (reset by wr)*/
119 #define SIP 0x02 /* sta: scsi-interrupt */
120 #define DIP 0x01 /* sta: host/script interrupt */
127 /* bits 0-2,7 rsvd for C1010 */
130 #define FLF 0x08 /* cmd: flush dma fifo */
131 #define CLF 0x04 /* cmd: clear dma fifo */
132 #define FM 0x02 /* mod: fetch pin mode */
133 #define WRIE 0x01 /* mod: write and invalidate enable */
134 /* bits 4-7 rsvd for C1010 */
138 #define BDIS 0x80 /* mod: burst disable */
139 #define MPEE 0x08 /* mod: master parity error enable */
142 #define DFS 0x20 /* mod: dma fifo size */
143 /* bits 0-1, 3-7 rsvd for C1010 */
146 #define DBC 0x24 /* ### Byte count and command */
147 #define DNAD 0x28 /* ### Next command register */
148 #define DSP 0x2c /* --> Script Pointer */
149 #define DSPS 0x30 /* --> Script pointer save/opcode#2 */
151 #define SCRATCHA 0x34 /* Temporary register a */
152 #define SCRATCHA1 0x35
153 #define SCRATCHA2 0x36
154 #define SCRATCHA3 0x37
157 #define BL_2 0x80 /* mod: burst length shift value +2 */
158 #define BL_1 0x40 /* mod: burst length shift value +1 */
159 #define ERL 0x08 /* mod: enable read line */
160 #define ERMP 0x04 /* mod: enable read multiple */
161 #define BOF 0x02 /* mod: burst op code fetch */
162 #define MAN 0x01 /* mod: manual start */
167 #define DCNTL 0x3b /* --> Script execution control */
168 #define CLSE 0x80 /* mod: cache line size enable */
169 #define PFF 0x40 /* cmd: pre-fetch flush */
170 #define PFEN 0x20 /* mod: pre-fetch enable */
171 #define SSM 0x10 /* mod: single step mode */
172 #define IRQM 0x08 /* mod: irq mode (1 = totem pole !) */
173 #define STD 0x04 /* cmd: start dma mode */
174 #define IRQD 0x02 /* mod: irq disable */
175 #define NOCOM 0x01 /* cmd: protect sfbr while reselect */
176 /* bits 0-1 rsvd for C1010 */
180 #define SIEN 0x40 /* -->: interrupt enable */
181 #define SIST 0x42 /* <--: interrupt status */
182 #define SBMC 0x1000/* sta: SCSI Bus Mode Change (895/6 only) */
183 #define STO 0x0400/* sta: timeout (select) */
184 #define GEN 0x0200/* sta: timeout (general) */
185 #define HTH 0x0100/* sta: timeout (handshake) */
186 #define MA 0x80 /* sta: phase mismatch */
187 #define CMP 0x40 /* sta: arbitration complete */
188 #define SEL 0x20 /* sta: selected by another device */
189 #define RSL 0x10 /* sta: reselected by another device*/
190 #define SGE 0x08 /* sta: gross error (over/underflow)*/
191 #define UDC 0x04 /* sta: unexpected disconnect */
192 #define RST 0x02 /* sta: scsi bus reset detected */
193 #define PAR 0x01 /* sta: scsi parity error */
199 #define STIME0 0x48 /* cmd: timeout for select&handshake*/
200 #define STIME1 0x49 /* cmd: timeout user defined */
201 #define RESPID 0x4a /* sta: Reselect-IDs */
206 #define SCLK 0x80 /* Use the PCI clock as SCSI clock */
207 #define DBLEN 0x08 /* clock doubler running */
208 #define DBLSEL 0x04 /* clock doubler selected */
212 #define ROF 0x40 /* reset scsi offset (after gross error!) */
213 #define EXT 0x02 /* extended filtering */
216 #define TE 0x80 /* c: tolerAnt enable */
217 #define HSC 0x20 /* c: Halt SCSI Clock */
218 #define CSF 0x02 /* c: clear scsi fifo */
220 #define SIDL 0x50 /* Lowlevel: latched from scsi data */
222 #define SMODE 0xc0 /* SCSI bus mode (895/6 only) */
223 #define SMODE_HVD 0x40 /* High Voltage Differential */
224 #define SMODE_SE 0x80 /* Single Ended */
225 #define SMODE_LVD 0xc0 /* Low Voltage Differential */
226 #define LCKFRQ 0x20 /* Frequency Lock (895/6 only) */
227 /* bits 0-5 rsvd for C1010 */
229 #define SODL 0x54 /* Lowlevel: data out to scsi data */
231 #define SBDL 0x58 /* Lowlevel: data from scsi data */
234 /*-----------------------------------------------------------
236 ** Utility macros for the script.
238 **-----------------------------------------------------------
243 /*-----------------------------------------------------------
247 ** DT phases illegal for ncr driver.
249 **-----------------------------------------------------------
252 #define SCR_DATA_OUT 0x00000000
253 #define SCR_DATA_IN 0x01000000
254 #define SCR_COMMAND 0x02000000
255 #define SCR_STATUS 0x03000000
256 #define SCR_DT_DATA_OUT 0x04000000
257 #define SCR_DT_DATA_IN 0x05000000
258 #define SCR_MSG_OUT 0x06000000
259 #define SCR_MSG_IN 0x07000000
261 #define SCR_ILG_OUT 0x04000000
262 #define SCR_ILG_IN 0x05000000
264 /*-----------------------------------------------------------
266 ** Data transfer via SCSI.
268 **-----------------------------------------------------------
279 **-----------------------------------------------------------
282 #define OPC_MOVE 0x08000000
284 #define SCR_MOVE_ABS(l) ((0x00000000 | OPC_MOVE) | (l))
285 #define SCR_MOVE_IND(l) ((0x20000000 | OPC_MOVE) | (l))
286 #define SCR_MOVE_TBL (0x10000000 | OPC_MOVE)
288 #define SCR_CHMOV_ABS(l) ((0x00000000) | (l))
289 #define SCR_CHMOV_IND(l) ((0x20000000) | (l))
290 #define SCR_CHMOV_TBL (0x10000000)
293 /*-----------------------------------------------------------
297 **-----------------------------------------------------------
299 ** SEL_ABS | SCR_ID (0..15) [ | REL_JMP]
300 ** <<alternate_address>>
302 ** SEL_TBL | << dnad_offset>> [ | REL_JMP]
303 ** <<alternate_address>>
305 **-----------------------------------------------------------
308 #define SCR_SEL_ABS 0x40000000
309 #define SCR_SEL_ABS_ATN 0x41000000
310 #define SCR_SEL_TBL 0x42000000
311 #define SCR_SEL_TBL_ATN 0x43000000
314 #define SCR_JMP_REL 0x04000000
315 #define SCR_ID(id) (((unsigned long)(id)) << 16)
317 /*-----------------------------------------------------------
319 ** Waiting for Disconnect or Reselect
321 **-----------------------------------------------------------
324 ** dummy: <<alternate_address>>
327 ** <<alternate_address>>
329 **-----------------------------------------------------------
332 #define SCR_WAIT_DISC 0x48000000
333 #define SCR_WAIT_RESEL 0x50000000
335 /*-----------------------------------------------------------
339 **-----------------------------------------------------------
341 ** SET (flags {|.. })
343 ** CLR (flags {|.. })
345 **-----------------------------------------------------------
348 #define SCR_SET(f) (0x58000000 | (f))
349 #define SCR_CLR(f) (0x60000000 | (f))
351 #define SCR_CARRY 0x00000400
352 #define SCR_TRG 0x00000200
353 #define SCR_ACK 0x00000040
354 #define SCR_ATN 0x00000008
357 /*-----------------------------------------------------------
359 ** Memory to memory move
361 **-----------------------------------------------------------
364 ** << source_address >>
365 ** << destination_address >>
367 ** SCR_COPY sets the NO FLUSH option by default.
368 ** SCR_COPY_F does not set this option.
370 ** For chips which do not support this option,
371 ** ncr_copy_and_bind() will remove this bit.
372 **-----------------------------------------------------------
375 #define SCR_NO_FLUSH 0x01000000
377 #define SCR_COPY(n) (0xc0000000 | SCR_NO_FLUSH | (n))
378 #define SCR_COPY_F(n) (0xc0000000 | (n))
380 /*-----------------------------------------------------------
382 ** Register move and binary operations
384 **-----------------------------------------------------------
386 ** SFBR_REG (reg, op, data) reg = SFBR op data
389 ** REG_SFBR (reg, op, data) SFBR = reg op data
392 ** REG_REG (reg, op, data) reg = reg op data
395 **-----------------------------------------------------------
396 ** On 810A, 860, 825A, 875, 895 and 896 chips the content
397 ** of SFBR register can be used as data (SCR_SFBR_DATA).
398 ** The 896 has additionnal IO registers starting at
399 ** offset 0x80. Bit 7 of register offset is stored in
400 ** bit 7 of the SCRIPTS instruction first DWORD.
401 **-----------------------------------------------------------
404 #define SCR_REG_OFS(ofs) ((((ofs) & 0x7f) << 16ul)) /* + ((ofs) & 0x80)) */
406 #define SCR_SFBR_REG(reg,op,data) \
407 (0x68000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
409 #define SCR_REG_SFBR(reg,op,data) \
410 (0x70000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
412 #define SCR_REG_REG(reg,op,data) \
413 (0x78000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
416 #define SCR_LOAD 0x00000000
417 #define SCR_SHL 0x01000000
418 #define SCR_OR 0x02000000
419 #define SCR_XOR 0x03000000
420 #define SCR_AND 0x04000000
421 #define SCR_SHR 0x05000000
422 #define SCR_ADD 0x06000000
423 #define SCR_ADDC 0x07000000
425 #define SCR_SFBR_DATA (0x00800000>>8ul) /* Use SFBR as data */
427 /*-----------------------------------------------------------
429 ** FROM_REG (reg) SFBR = reg
432 ** TO_REG (reg) reg = SFBR
435 ** LOAD_REG (reg, data) reg = <data>
438 ** LOAD_SFBR(data) SFBR = <data>
441 **-----------------------------------------------------------
444 #define SCR_FROM_REG(reg) \
445 SCR_REG_SFBR(reg,SCR_OR,0)
447 #define SCR_TO_REG(reg) \
448 SCR_SFBR_REG(reg,SCR_OR,0)
450 #define SCR_LOAD_REG(reg,data) \
451 SCR_REG_REG(reg,SCR_LOAD,data)
453 #define SCR_LOAD_SFBR(data) \
454 (SCR_REG_SFBR (gpreg, SCR_LOAD, data))
456 /*-----------------------------------------------------------
458 ** LOAD from memory to register.
459 ** STORE from register to memory.
461 ** Only supported by 810A, 860, 825A, 875, 895 and 896.
463 **-----------------------------------------------------------
468 ** LOAD_REL (LEN) (DSA relative)
471 **-----------------------------------------------------------
474 #define SCR_REG_OFS2(ofs) (((ofs) & 0xff) << 16ul)
475 #define SCR_NO_FLUSH2 0x02000000
476 #define SCR_DSA_REL2 0x10000000
478 #define SCR_LOAD_R(reg, how, n) \
479 (0xe1000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
481 #define SCR_STORE_R(reg, how, n) \
482 (0xe0000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
484 #define SCR_LOAD_ABS(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2, n)
485 #define SCR_LOAD_REL(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2, n)
486 #define SCR_LOAD_ABS_F(reg, n) SCR_LOAD_R(reg, 0, n)
487 #define SCR_LOAD_REL_F(reg, n) SCR_LOAD_R(reg, SCR_DSA_REL2, n)
489 #define SCR_STORE_ABS(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2, n)
490 #define SCR_STORE_REL(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2,n)
491 #define SCR_STORE_ABS_F(reg, n) SCR_STORE_R(reg, 0, n)
492 #define SCR_STORE_REL_F(reg, n) SCR_STORE_R(reg, SCR_DSA_REL2, n)
495 /*-----------------------------------------------------------
497 ** Waiting for Disconnect or Reselect
499 **-----------------------------------------------------------
501 ** JUMP [ | IFTRUE/IFFALSE ( ... ) ]
504 ** JUMPR [ | IFTRUE/IFFALSE ( ... ) ]
507 ** CALL [ | IFTRUE/IFFALSE ( ... ) ]
510 ** CALLR [ | IFTRUE/IFFALSE ( ... ) ]
513 ** RETURN [ | IFTRUE/IFFALSE ( ... ) ]
516 ** INT [ | IFTRUE/IFFALSE ( ... ) ]
519 ** INT_FLY [ | IFTRUE/IFFALSE ( ... ) ]
528 **-----------------------------------------------------------
531 #define SCR_NO_OP 0x80000000
532 #define SCR_JUMP 0x80080000
533 #define SCR_JUMP64 0x80480000
534 #define SCR_JUMPR 0x80880000
535 #define SCR_CALL 0x88080000
536 #define SCR_CALLR 0x88880000
537 #define SCR_RETURN 0x90080000
538 #define SCR_INT 0x98080000
539 #define SCR_INT_FLY 0x98180000
541 #define IFFALSE(arg) (0x00080000 | (arg))
542 #define IFTRUE(arg) (0x00000000 | (arg))
544 #define WHEN(phase) (0x00030000 | (phase))
545 #define IF(phase) (0x00020000 | (phase))
547 #define DATA(D) (0x00040000 | ((D) & 0xff))
548 #define MASK(D,M) (0x00040000 | (((M ^ 0xff) & 0xff) << 8ul)|((D) & 0xff))
550 #define CARRYSET (0x00200000)
553 #define SIR_COMPLETE 0x10000000
555 #define SIR_SEL_ATN_NO_MSG_OUT 0x00000001
556 #define SIR_CMD_OUT_ILL_PH 0x00000002
557 #define SIR_STATUS_ILL_PH 0x00000003
558 #define SIR_MSG_RECEIVED 0x00000004
559 #define SIR_DATA_IN_ERR 0x00000005
560 #define SIR_DATA_OUT_ERR 0x00000006
561 #define SIR_SCRIPT_ERROR 0x00000007
562 #define SIR_MSG_OUT_NO_CMD 0x00000008
563 #define SIR_MSG_OVER7 0x00000009
565 #define INT_ON_FY 0x00000080
567 /* Hardware errors are defined in scsi.h */
569 #define SCSI_IDENTIFY 0xC0