ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / drivers / scsi / sym53c8xx_2 / sym_defs.h
1 /*
2  * Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family 
3  * of PCI-SCSI IO processors.
4  *
5  * Copyright (C) 1999-2001  Gerard Roudier <groudier@free.fr>
6  *
7  * This driver is derived from the Linux sym53c8xx driver.
8  * Copyright (C) 1998-2000  Gerard Roudier
9  *
10  * The sym53c8xx driver is derived from the ncr53c8xx driver that had been 
11  * a port of the FreeBSD ncr driver to Linux-1.2.13.
12  *
13  * The original ncr driver has been written for 386bsd and FreeBSD by
14  *         Wolfgang Stanglmeier        <wolf@cologne.de>
15  *         Stefan Esser                <se@mi.Uni-Koeln.de>
16  * Copyright (C) 1994  Wolfgang Stanglmeier
17  *
18  * Other major contributions:
19  *
20  * NVRAM detection and reading.
21  * Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
22  *
23  *-----------------------------------------------------------------------------
24  *
25  * Redistribution and use in source and binary forms, with or without
26  * modification, are permitted provided that the following conditions
27  * are met:
28  * 1. Redistributions of source code must retain the above copyright
29  *    notice, this list of conditions and the following disclaimer.
30  * 2. The name of the author may not be used to endorse or promote products
31  *    derived from this software without specific prior written permission.
32  *
33  * Where this Software is combined with software released under the terms of 
34  * the GNU Public License ("GPL") and the terms of the GPL would require the 
35  * combined work to also be released under the terms of the GPL, the terms
36  * and conditions of this License will apply in addition to those of the
37  * GPL with the exception of any terms or conditions of this License that
38  * conflict with, or are expressly prohibited by, the GPL.
39  *
40  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
41  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
44  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50  * SUCH DAMAGE.
51  */
52
53 #ifndef SYM_DEFS_H
54 #define SYM_DEFS_H
55
56 /*
57  *  Vendor.
58  */
59 #define PCI_VENDOR_NCR          0x1000
60
61 /*
62  *  PCI device identifier of SYMBIOS chips.
63  */
64 #define PCI_ID_SYM53C810        1
65 #define PCI_ID_SYM53C810AP      5
66 #define PCI_ID_SYM53C815        4
67 #define PCI_ID_SYM53C820        2
68 #define PCI_ID_SYM53C825        3
69 #define PCI_ID_SYM53C860        6
70 #define PCI_ID_SYM53C875        0xf
71 #define PCI_ID_SYM53C875_2      0x8f
72 #define PCI_ID_SYM53C885        0xd
73 #define PCI_ID_SYM53C895        0xc
74 #define PCI_ID_SYM53C896        0xb
75 #define PCI_ID_SYM53C895A       0x12
76 #define PCI_ID_SYM53C875A       0x13
77 #define PCI_ID_LSI53C1010_33    0x20
78 #define PCI_ID_LSI53C1010_66    0x21
79 #define PCI_ID_LSI53C1510D      0xa
80
81 /*
82  *      SYM53C8XX device features descriptor.
83  */
84 struct sym_pci_chip {
85         u_short device_id;
86         u_short revision_id;
87         char    *name;
88         u_char  burst_max;      /* log-base-2 of max burst */
89         u_char  offset_max;
90         u_char  nr_divisor;
91         u_char  lp_probe_bit;
92         u_int   features;
93 #define FE_LED0         (1<<0)
94 #define FE_WIDE         (1<<1)    /* Wide data transfers */
95 #define FE_ULTRA        (1<<2)    /* Ultra speed 20Mtrans/sec */
96 #define FE_ULTRA2       (1<<3)    /* Ultra 2 - 40 Mtrans/sec */
97 #define FE_DBLR         (1<<4)    /* Clock doubler present */
98 #define FE_QUAD         (1<<5)    /* Clock quadrupler present */
99 #define FE_ERL          (1<<6)    /* Enable read line */
100 #define FE_CLSE         (1<<7)    /* Cache line size enable */
101 #define FE_WRIE         (1<<8)    /* Write & Invalidate enable */
102 #define FE_ERMP         (1<<9)    /* Enable read multiple */
103 #define FE_BOF          (1<<10)   /* Burst opcode fetch */
104 #define FE_DFS          (1<<11)   /* DMA fifo size */
105 #define FE_PFEN         (1<<12)   /* Prefetch enable */
106 #define FE_LDSTR        (1<<13)   /* Load/Store supported */
107 #define FE_RAM          (1<<14)   /* On chip RAM present */
108 #define FE_VARCLK       (1<<15)   /* Clock frequency may vary */
109 #define FE_RAM8K        (1<<16)   /* On chip RAM sized 8Kb */
110 #define FE_64BIT        (1<<17)   /* 64-bit PCI BUS interface */
111 #define FE_IO256        (1<<18)   /* Requires full 256 bytes in PCI space */
112 #define FE_NOPM         (1<<19)   /* Scripts handles phase mismatch */
113 #define FE_LEDC         (1<<20)   /* Hardware control of LED */
114 #define FE_ULTRA3       (1<<21)   /* Ultra 3 - 80 Mtrans/sec DT */
115 #define FE_66MHZ        (1<<22)   /* 66MHz PCI support */
116 #define FE_CRC          (1<<23)   /* CRC support */
117 #define FE_DIFF         (1<<24)   /* SCSI HVD support */
118 #define FE_DFBC         (1<<25)   /* Have DFBC register */
119 #define FE_LCKFRQ       (1<<26)   /* Have LCKFRQ */
120 #define FE_C10          (1<<27)   /* Various C10 core (mis)features */
121 #define FE_U3EN         (1<<28)   /* U3EN bit usable */
122 #define FE_DAC          (1<<29)   /* Support PCI DAC (64 bit addressing) */
123 #define FE_ISTAT1       (1<<30)   /* Have ISTAT1, MBOX0, MBOX1 registers */
124
125 #define FE_CACHE_SET    (FE_ERL|FE_CLSE|FE_WRIE|FE_ERMP)
126 #define FE_CACHE0_SET   (FE_CACHE_SET & ~FE_ERL)
127 };
128
129 /*
130  *      SYM53C8XX IO register data structure.
131  */
132 struct sym_reg {
133 /*00*/  u8      nc_scntl0;      /* full arb., ena parity, par->ATN  */
134
135 /*01*/  u8      nc_scntl1;      /* no reset                         */
136         #define   ISCON   0x10  /* connected to scsi                */
137         #define   CRST    0x08  /* force reset                      */
138         #define   IARB    0x02  /* immediate arbitration            */
139
140 /*02*/  u8      nc_scntl2;      /* no disconnect expected           */
141         #define   SDU     0x80  /* cmd: disconnect will raise error */
142         #define   CHM     0x40  /* sta: chained mode                */
143         #define   WSS     0x08  /* sta: wide scsi send           [W]*/
144         #define   WSR     0x01  /* sta: wide scsi received       [W]*/
145
146 /*03*/  u8      nc_scntl3;      /* cnf system clock dependent       */
147         #define   EWS     0x08  /* cmd: enable wide scsi         [W]*/
148         #define   ULTRA   0x80  /* cmd: ULTRA enable                */
149                                 /* bits 0-2, 7 rsvd for C1010       */
150
151 /*04*/  u8      nc_scid;        /* cnf host adapter scsi address    */
152         #define   RRE     0x40  /* r/w:e enable response to resel.  */
153         #define   SRE     0x20  /* r/w:e enable response to select  */
154
155 /*05*/  u8      nc_sxfer;       /* ### Sync speed and count         */
156                                 /* bits 6-7 rsvd for C1010          */
157
158 /*06*/  u8      nc_sdid;        /* ### Destination-ID               */
159
160 /*07*/  u8      nc_gpreg;       /* ??? IO-Pins                      */
161
162 /*08*/  u8      nc_sfbr;        /* ### First byte received          */
163
164 /*09*/  u8      nc_socl;
165         #define   CREQ    0x80  /* r/w: SCSI-REQ                    */
166         #define   CACK    0x40  /* r/w: SCSI-ACK                    */
167         #define   CBSY    0x20  /* r/w: SCSI-BSY                    */
168         #define   CSEL    0x10  /* r/w: SCSI-SEL                    */
169         #define   CATN    0x08  /* r/w: SCSI-ATN                    */
170         #define   CMSG    0x04  /* r/w: SCSI-MSG                    */
171         #define   CC_D    0x02  /* r/w: SCSI-C_D                    */
172         #define   CI_O    0x01  /* r/w: SCSI-I_O                    */
173
174 /*0a*/  u8      nc_ssid;
175
176 /*0b*/  u8      nc_sbcl;
177
178 /*0c*/  u8      nc_dstat;
179         #define   DFE     0x80  /* sta: dma fifo empty              */
180         #define   MDPE    0x40  /* int: master data parity error    */
181         #define   BF      0x20  /* int: script: bus fault           */
182         #define   ABRT    0x10  /* int: script: command aborted     */
183         #define   SSI     0x08  /* int: script: single step         */
184         #define   SIR     0x04  /* int: script: interrupt instruct. */
185         #define   IID     0x01  /* int: script: illegal instruct.   */
186
187 /*0d*/  u8      nc_sstat0;
188         #define   ILF     0x80  /* sta: data in SIDL register lsb   */
189         #define   ORF     0x40  /* sta: data in SODR register lsb   */
190         #define   OLF     0x20  /* sta: data in SODL register lsb   */
191         #define   AIP     0x10  /* sta: arbitration in progress     */
192         #define   LOA     0x08  /* sta: arbitration lost            */
193         #define   WOA     0x04  /* sta: arbitration won             */
194         #define   IRST    0x02  /* sta: scsi reset signal           */
195         #define   SDP     0x01  /* sta: scsi parity signal          */
196
197 /*0e*/  u8      nc_sstat1;
198         #define   FF3210  0xf0  /* sta: bytes in the scsi fifo      */
199
200 /*0f*/  u8      nc_sstat2;
201         #define   ILF1    0x80  /* sta: data in SIDL register msb[W]*/
202         #define   ORF1    0x40  /* sta: data in SODR register msb[W]*/
203         #define   OLF1    0x20  /* sta: data in SODL register msb[W]*/
204         #define   DM      0x04  /* sta: DIFFSENS mismatch (895/6 only) */
205         #define   LDSC    0x02  /* sta: disconnect & reconnect      */
206
207 /*10*/  u8      nc_dsa;         /* --> Base page                    */
208 /*11*/  u8      nc_dsa1;
209 /*12*/  u8      nc_dsa2;
210 /*13*/  u8      nc_dsa3;
211
212 /*14*/  u8      nc_istat;       /* --> Main Command and status      */
213         #define   CABRT   0x80  /* cmd: abort current operation     */
214         #define   SRST    0x40  /* mod: reset chip                  */
215         #define   SIGP    0x20  /* r/w: message from host to script */
216         #define   SEM     0x10  /* r/w: message between host + script  */
217         #define   CON     0x08  /* sta: connected to scsi           */
218         #define   INTF    0x04  /* sta: int on the fly (reset by wr)*/
219         #define   SIP     0x02  /* sta: scsi-interrupt              */
220         #define   DIP     0x01  /* sta: host/script interrupt       */
221
222 /*15*/  u8      nc_istat1;      /* 896 only */
223         #define   FLSH    0x04  /* sta: chip is flushing            */
224         #define   SCRUN   0x02  /* sta: scripts are running         */
225         #define   SIRQD   0x01  /* r/w: disable INT pin             */
226
227 /*16*/  u8      nc_mbox0;       /* 896 only */
228 /*17*/  u8      nc_mbox1;       /* 896 only */
229
230 /*18*/  u8      nc_ctest0;
231 /*19*/  u8      nc_ctest1;
232
233 /*1a*/  u8      nc_ctest2;
234         #define   CSIGP   0x40
235                                 /* bits 0-2,7 rsvd for C1010        */
236
237 /*1b*/  u8      nc_ctest3;
238         #define   FLF     0x08  /* cmd: flush dma fifo              */
239         #define   CLF     0x04  /* cmd: clear dma fifo              */
240         #define   FM      0x02  /* mod: fetch pin mode              */
241         #define   WRIE    0x01  /* mod: write and invalidate enable */
242                                 /* bits 4-7 rsvd for C1010          */
243
244 /*1c*/  u32     nc_temp;        /* ### Temporary stack              */
245
246 /*20*/  u8      nc_dfifo;
247 /*21*/  u8      nc_ctest4;
248         #define   BDIS    0x80  /* mod: burst disable               */
249         #define   MPEE    0x08  /* mod: master parity error enable  */
250
251 /*22*/  u8      nc_ctest5;
252         #define   DFS     0x20  /* mod: dma fifo size               */
253                                 /* bits 0-1, 3-7 rsvd for C1010     */
254
255 /*23*/  u8      nc_ctest6;
256
257 /*24*/  u32     nc_dbc;         /* ### Byte count and command       */
258 /*28*/  u32     nc_dnad;        /* ### Next command register        */
259 /*2c*/  u32     nc_dsp;         /* --> Script Pointer               */
260 /*30*/  u32     nc_dsps;        /* --> Script pointer save/opcode#2 */
261
262 /*34*/  u8      nc_scratcha;    /* Temporary register a            */
263 /*35*/  u8      nc_scratcha1;
264 /*36*/  u8      nc_scratcha2;
265 /*37*/  u8      nc_scratcha3;
266
267 /*38*/  u8      nc_dmode;
268         #define   BL_2    0x80  /* mod: burst length shift value +2 */
269         #define   BL_1    0x40  /* mod: burst length shift value +1 */
270         #define   ERL     0x08  /* mod: enable read line            */
271         #define   ERMP    0x04  /* mod: enable read multiple        */
272         #define   BOF     0x02  /* mod: burst op code fetch         */
273
274 /*39*/  u8      nc_dien;
275 /*3a*/  u8      nc_sbr;
276
277 /*3b*/  u8      nc_dcntl;       /* --> Script execution control     */
278         #define   CLSE    0x80  /* mod: cache line size enable      */
279         #define   PFF     0x40  /* cmd: pre-fetch flush             */
280         #define   PFEN    0x20  /* mod: pre-fetch enable            */
281         #define   SSM     0x10  /* mod: single step mode            */
282         #define   IRQM    0x08  /* mod: irq mode (1 = totem pole !) */
283         #define   STD     0x04  /* cmd: start dma mode              */
284         #define   IRQD    0x02  /* mod: irq disable                 */
285         #define   NOCOM   0x01  /* cmd: protect sfbr while reselect */
286                                 /* bits 0-1 rsvd for C1010          */
287
288 /*3c*/  u32     nc_adder;
289
290 /*40*/  u16     nc_sien;        /* -->: interrupt enable            */
291 /*42*/  u16     nc_sist;        /* <--: interrupt status            */
292         #define   SBMC    0x1000/* sta: SCSI Bus Mode Change (895/6 only) */
293         #define   STO     0x0400/* sta: timeout (select)            */
294         #define   GEN     0x0200/* sta: timeout (general)           */
295         #define   HTH     0x0100/* sta: timeout (handshake)         */
296         #define   MA      0x80  /* sta: phase mismatch              */
297         #define   CMP     0x40  /* sta: arbitration complete        */
298         #define   SEL     0x20  /* sta: selected by another device  */
299         #define   RSL     0x10  /* sta: reselected by another device*/
300         #define   SGE     0x08  /* sta: gross error (over/underflow)*/
301         #define   UDC     0x04  /* sta: unexpected disconnect       */
302         #define   RST     0x02  /* sta: scsi bus reset detected     */
303         #define   PAR     0x01  /* sta: scsi parity error           */
304
305 /*44*/  u8      nc_slpar;
306 /*45*/  u8      nc_swide;
307 /*46*/  u8      nc_macntl;
308 /*47*/  u8      nc_gpcntl;
309 /*48*/  u8      nc_stime0;      /* cmd: timeout for select&handshake*/
310 /*49*/  u8      nc_stime1;      /* cmd: timeout user defined        */
311 /*4a*/  u16     nc_respid;      /* sta: Reselect-IDs                */
312
313 /*4c*/  u8      nc_stest0;
314
315 /*4d*/  u8      nc_stest1;
316         #define   SCLK    0x80  /* Use the PCI clock as SCSI clock      */
317         #define   DBLEN   0x08  /* clock doubler running                */
318         #define   DBLSEL  0x04  /* clock doubler selected               */
319   
320
321 /*4e*/  u8      nc_stest2;
322         #define   ROF     0x40  /* reset scsi offset (after gross error!) */
323         #define   EXT     0x02  /* extended filtering                     */
324
325 /*4f*/  u8      nc_stest3;
326         #define   TE     0x80   /* c: tolerAnt enable */
327         #define   HSC    0x20   /* c: Halt SCSI Clock */
328         #define   CSF    0x02   /* c: clear scsi fifo */
329
330 /*50*/  u16     nc_sidl;        /* Lowlevel: latched from scsi data */
331 /*52*/  u8      nc_stest4;
332         #define   SMODE  0xc0   /* SCSI bus mode      (895/6 only) */
333         #define    SMODE_HVD 0x40       /* High Voltage Differential       */
334         #define    SMODE_SE  0x80       /* Single Ended                    */
335         #define    SMODE_LVD 0xc0       /* Low Voltage Differential        */
336         #define   LCKFRQ 0x20   /* Frequency Lock (895/6 only)     */
337                                 /* bits 0-5 rsvd for C1010         */
338
339 /*53*/  u8      nc_53_;
340 /*54*/  u16     nc_sodl;        /* Lowlevel: data out to scsi data  */
341 /*56*/  u8      nc_ccntl0;      /* Chip Control 0 (896)             */
342         #define   ENPMJ  0x80   /* Enable Phase Mismatch Jump       */
343         #define   PMJCTL 0x40   /* Phase Mismatch Jump Control      */
344         #define   ENNDJ  0x20   /* Enable Non Data PM Jump          */
345         #define   DISFC  0x10   /* Disable Auto FIFO Clear          */
346         #define   DILS   0x02   /* Disable Internal Load/Store      */
347         #define   DPR    0x01   /* Disable Pipe Req                 */
348
349 /*57*/  u8      nc_ccntl1;      /* Chip Control 1 (896)             */
350         #define   ZMOD   0x80   /* High Impedance Mode              */
351         #define   DDAC   0x08   /* Disable Dual Address Cycle       */
352         #define   XTIMOD 0x04   /* 64-bit Table Ind. Indexing Mode  */
353         #define   EXTIBMV 0x02  /* Enable 64-bit Table Ind. BMOV    */
354         #define   EXDBMV 0x01   /* Enable 64-bit Direct BMOV        */
355
356 /*58*/  u16     nc_sbdl;        /* Lowlevel: data from scsi data    */
357 /*5a*/  u16     nc_5a_;
358
359 /*5c*/  u8      nc_scr0;        /* Working register B               */
360 /*5d*/  u8      nc_scr1;
361 /*5e*/  u8      nc_scr2;
362 /*5f*/  u8      nc_scr3;
363
364 /*60*/  u8      nc_scrx[64];    /* Working register C-R             */
365 /*a0*/  u32     nc_mmrs;        /* Memory Move Read Selector        */
366 /*a4*/  u32     nc_mmws;        /* Memory Move Write Selector       */
367 /*a8*/  u32     nc_sfs;         /* Script Fetch Selector            */
368 /*ac*/  u32     nc_drs;         /* DSA Relative Selector            */
369 /*b0*/  u32     nc_sbms;        /* Static Block Move Selector       */
370 /*b4*/  u32     nc_dbms;        /* Dynamic Block Move Selector      */
371 /*b8*/  u32     nc_dnad64;      /* DMA Next Address 64              */
372 /*bc*/  u16     nc_scntl4;      /* C1010 only                       */
373         #define   U3EN    0x80  /* Enable Ultra 3                   */
374         #define   AIPCKEN 0x40  /* AIP checking enable              */
375                                 /* Also enable AIP generation on C10-33*/
376         #define   XCLKH_DT 0x08 /* Extra clock of data hold on DT edge */
377         #define   XCLKH_ST 0x04 /* Extra clock of data hold on ST edge */
378         #define   XCLKS_DT 0x02 /* Extra clock of data set  on DT edge */
379         #define   XCLKS_ST 0x01 /* Extra clock of data set  on ST edge */
380 /*be*/  u8      nc_aipcntl0;    /* AIP Control 0 C1010 only         */
381 /*bf*/  u8      nc_aipcntl1;    /* AIP Control 1 C1010 only         */
382         #define DISAIP  0x08    /* Disable AIP generation C10-66 only  */
383 /*c0*/  u32     nc_pmjad1;      /* Phase Mismatch Jump Address 1    */
384 /*c4*/  u32     nc_pmjad2;      /* Phase Mismatch Jump Address 2    */
385 /*c8*/  u8      nc_rbc;         /* Remaining Byte Count             */
386 /*c9*/  u8      nc_rbc1;
387 /*ca*/  u8      nc_rbc2;
388 /*cb*/  u8      nc_rbc3;
389
390 /*cc*/  u8      nc_ua;          /* Updated Address                  */
391 /*cd*/  u8      nc_ua1;
392 /*ce*/  u8      nc_ua2;
393 /*cf*/  u8      nc_ua3;
394 /*d0*/  u32     nc_esa;         /* Entry Storage Address            */
395 /*d4*/  u8      nc_ia;          /* Instruction Address              */
396 /*d5*/  u8      nc_ia1;
397 /*d6*/  u8      nc_ia2;
398 /*d7*/  u8      nc_ia3;
399 /*d8*/  u32     nc_sbc;         /* SCSI Byte Count (3 bytes only)   */
400 /*dc*/  u32     nc_csbc;        /* Cumulative SCSI Byte Count       */
401                                 /* Following for C1010 only         */
402 /*e0*/  u16    nc_crcpad;       /* CRC Value                        */
403 /*e2*/  u8     nc_crccntl0;     /* CRC control register             */
404         #define   SNDCRC  0x10  /* Send CRC Request                 */
405 /*e3*/  u8     nc_crccntl1;     /* CRC control register             */
406 /*e4*/  u32    nc_crcdata;      /* CRC data register                */
407 /*e8*/  u32    nc_e8_;
408 /*ec*/  u32    nc_ec_;
409 /*f0*/  u16    nc_dfbc;         /* DMA FIFO byte count              */ 
410 };
411
412 /*-----------------------------------------------------------
413  *
414  *      Utility macros for the script.
415  *
416  *-----------------------------------------------------------
417  */
418
419 #define REGJ(p,r) (offsetof(struct sym_reg, p ## r))
420 #define REG(r) REGJ (nc_, r)
421
422 /*-----------------------------------------------------------
423  *
424  *      SCSI phases
425  *
426  *-----------------------------------------------------------
427  */
428
429 #define SCR_DATA_OUT    0x00000000
430 #define SCR_DATA_IN     0x01000000
431 #define SCR_COMMAND     0x02000000
432 #define SCR_STATUS      0x03000000
433 #define SCR_DT_DATA_OUT 0x04000000
434 #define SCR_DT_DATA_IN  0x05000000
435 #define SCR_MSG_OUT     0x06000000
436 #define SCR_MSG_IN      0x07000000
437 /* DT phases are illegal for non Ultra3 mode */
438 #define SCR_ILG_OUT     0x04000000
439 #define SCR_ILG_IN      0x05000000
440
441 /*-----------------------------------------------------------
442  *
443  *      Data transfer via SCSI.
444  *
445  *-----------------------------------------------------------
446  *
447  *      MOVE_ABS (LEN)
448  *      <<start address>>
449  *
450  *      MOVE_IND (LEN)
451  *      <<dnad_offset>>
452  *
453  *      MOVE_TBL
454  *      <<dnad_offset>>
455  *
456  *-----------------------------------------------------------
457  */
458
459 #define OPC_MOVE          0x08000000
460
461 #define SCR_MOVE_ABS(l) ((0x00000000 | OPC_MOVE) | (l))
462 /* #define SCR_MOVE_IND(l) ((0x20000000 | OPC_MOVE) | (l)) */
463 #define SCR_MOVE_TBL     (0x10000000 | OPC_MOVE)
464
465 #define SCR_CHMOV_ABS(l) ((0x00000000) | (l))
466 /* #define SCR_CHMOV_IND(l) ((0x20000000) | (l)) */
467 #define SCR_CHMOV_TBL     (0x10000000)
468
469 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
470 /* We steal the `indirect addressing' flag for target mode MOVE in scripts */
471
472 #define OPC_TCHMOVE        0x08000000
473
474 #define SCR_TCHMOVE_ABS(l) ((0x20000000 | OPC_TCHMOVE) | (l))
475 #define SCR_TCHMOVE_TBL     (0x30000000 | OPC_TCHMOVE)
476
477 #define SCR_TMOV_ABS(l)    ((0x20000000) | (l))
478 #define SCR_TMOV_TBL        (0x30000000)
479 #endif
480
481 struct sym_tblmove {
482         u32  size;
483         u32  addr;
484 };
485
486 /*-----------------------------------------------------------
487  *
488  *      Selection
489  *
490  *-----------------------------------------------------------
491  *
492  *      SEL_ABS | SCR_ID (0..15)    [ | REL_JMP]
493  *      <<alternate_address>>
494  *
495  *      SEL_TBL | << dnad_offset>>  [ | REL_JMP]
496  *      <<alternate_address>>
497  *
498  *-----------------------------------------------------------
499  */
500
501 #define SCR_SEL_ABS     0x40000000
502 #define SCR_SEL_ABS_ATN 0x41000000
503 #define SCR_SEL_TBL     0x42000000
504 #define SCR_SEL_TBL_ATN 0x43000000
505
506 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
507 #define SCR_RESEL_ABS     0x40000000
508 #define SCR_RESEL_ABS_ATN 0x41000000
509 #define SCR_RESEL_TBL     0x42000000
510 #define SCR_RESEL_TBL_ATN 0x43000000
511 #endif
512
513 struct sym_tblsel {
514         u_char  sel_scntl4;     /* C1010 only */
515         u_char  sel_sxfer;
516         u_char  sel_id;
517         u_char  sel_scntl3;
518 };
519
520 #define SCR_JMP_REL     0x04000000
521 #define SCR_ID(id)      (((u32)(id)) << 16)
522
523 /*-----------------------------------------------------------
524  *
525  *      Waiting for Disconnect or Reselect
526  *
527  *-----------------------------------------------------------
528  *
529  *      WAIT_DISC
530  *      dummy: <<alternate_address>>
531  *
532  *      WAIT_RESEL
533  *      <<alternate_address>>
534  *
535  *-----------------------------------------------------------
536  */
537
538 #define SCR_WAIT_DISC   0x48000000
539 #define SCR_WAIT_RESEL  0x50000000
540
541 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
542 #define SCR_DISCONNECT  0x48000000
543 #endif
544
545 /*-----------------------------------------------------------
546  *
547  *      Bit Set / Reset
548  *
549  *-----------------------------------------------------------
550  *
551  *      SET (flags {|.. })
552  *
553  *      CLR (flags {|.. })
554  *
555  *-----------------------------------------------------------
556  */
557
558 #define SCR_SET(f)     (0x58000000 | (f))
559 #define SCR_CLR(f)     (0x60000000 | (f))
560
561 #define SCR_CARRY       0x00000400
562 #define SCR_TRG         0x00000200
563 #define SCR_ACK         0x00000040
564 #define SCR_ATN         0x00000008
565
566
567 /*-----------------------------------------------------------
568  *
569  *      Memory to memory move
570  *
571  *-----------------------------------------------------------
572  *
573  *      COPY (bytecount)
574  *      << source_address >>
575  *      << destination_address >>
576  *
577  *      SCR_COPY   sets the NO FLUSH option by default.
578  *      SCR_COPY_F does not set this option.
579  *
580  *      For chips which do not support this option,
581  *      sym_fw_bind_script() will remove this bit.
582  *
583  *-----------------------------------------------------------
584  */
585
586 #define SCR_NO_FLUSH 0x01000000
587
588 #define SCR_COPY(n) (0xc0000000 | SCR_NO_FLUSH | (n))
589 #define SCR_COPY_F(n) (0xc0000000 | (n))
590
591 /*-----------------------------------------------------------
592  *
593  *      Register move and binary operations
594  *
595  *-----------------------------------------------------------
596  *
597  *      SFBR_REG (reg, op, data)        reg  = SFBR op data
598  *      << 0 >>
599  *
600  *      REG_SFBR (reg, op, data)        SFBR = reg op data
601  *      << 0 >>
602  *
603  *      REG_REG  (reg, op, data)        reg  = reg op data
604  *      << 0 >>
605  *
606  *-----------------------------------------------------------
607  *
608  *      On 825A, 875, 895 and 896 chips the content 
609  *      of SFBR register can be used as data (SCR_SFBR_DATA).
610  *      The 896 has additionnal IO registers starting at 
611  *      offset 0x80. Bit 7 of register offset is stored in 
612  *      bit 7 of the SCRIPTS instruction first DWORD.
613  *
614  *-----------------------------------------------------------
615  */
616
617 #define SCR_REG_OFS(ofs) ((((ofs) & 0x7f) << 16ul) + ((ofs) & 0x80)) 
618
619 #define SCR_SFBR_REG(reg,op,data) \
620         (0x68000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
621
622 #define SCR_REG_SFBR(reg,op,data) \
623         (0x70000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
624
625 #define SCR_REG_REG(reg,op,data) \
626         (0x78000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
627
628
629 #define      SCR_LOAD   0x00000000
630 #define      SCR_SHL    0x01000000
631 #define      SCR_OR     0x02000000
632 #define      SCR_XOR    0x03000000
633 #define      SCR_AND    0x04000000
634 #define      SCR_SHR    0x05000000
635 #define      SCR_ADD    0x06000000
636 #define      SCR_ADDC   0x07000000
637
638 #define      SCR_SFBR_DATA   (0x00800000>>8ul)  /* Use SFBR as data */
639
640 /*-----------------------------------------------------------
641  *
642  *      FROM_REG (reg)            SFBR = reg
643  *      << 0 >>
644  *
645  *      TO_REG   (reg)            reg  = SFBR
646  *      << 0 >>
647  *
648  *      LOAD_REG (reg, data)      reg  = <data>
649  *      << 0 >>
650  *
651  *      LOAD_SFBR(data)           SFBR = <data>
652  *      << 0 >>
653  *
654  *-----------------------------------------------------------
655  */
656
657 #define SCR_FROM_REG(reg) \
658         SCR_REG_SFBR(reg,SCR_OR,0)
659
660 #define SCR_TO_REG(reg) \
661         SCR_SFBR_REG(reg,SCR_OR,0)
662
663 #define SCR_LOAD_REG(reg,data) \
664         SCR_REG_REG(reg,SCR_LOAD,data)
665
666 #define SCR_LOAD_SFBR(data) \
667         (SCR_REG_SFBR (gpreg, SCR_LOAD, data))
668
669 /*-----------------------------------------------------------
670  *
671  *      LOAD  from memory   to register.
672  *      STORE from register to memory.
673  *
674  *      Only supported by 810A, 860, 825A, 875, 895 and 896.
675  *
676  *-----------------------------------------------------------
677  *
678  *      LOAD_ABS (LEN)
679  *      <<start address>>
680  *
681  *      LOAD_REL (LEN)        (DSA relative)
682  *      <<dsa_offset>>
683  *
684  *-----------------------------------------------------------
685  */
686
687 #define SCR_REG_OFS2(ofs) (((ofs) & 0xff) << 16ul)
688 #define SCR_NO_FLUSH2   0x02000000
689 #define SCR_DSA_REL2    0x10000000
690
691 #define SCR_LOAD_R(reg, how, n) \
692         (0xe1000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
693
694 #define SCR_STORE_R(reg, how, n) \
695         (0xe0000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
696
697 #define SCR_LOAD_ABS(reg, n)    SCR_LOAD_R(reg, SCR_NO_FLUSH2, n)
698 #define SCR_LOAD_REL(reg, n)    SCR_LOAD_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2, n)
699 #define SCR_LOAD_ABS_F(reg, n)  SCR_LOAD_R(reg, 0, n)
700 #define SCR_LOAD_REL_F(reg, n)  SCR_LOAD_R(reg, SCR_DSA_REL2, n)
701
702 #define SCR_STORE_ABS(reg, n)   SCR_STORE_R(reg, SCR_NO_FLUSH2, n)
703 #define SCR_STORE_REL(reg, n)   SCR_STORE_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2,n)
704 #define SCR_STORE_ABS_F(reg, n) SCR_STORE_R(reg, 0, n)
705 #define SCR_STORE_REL_F(reg, n) SCR_STORE_R(reg, SCR_DSA_REL2, n)
706
707
708 /*-----------------------------------------------------------
709  *
710  *      Waiting for Disconnect or Reselect
711  *
712  *-----------------------------------------------------------
713  *
714  *      JUMP            [ | IFTRUE/IFFALSE ( ... ) ]
715  *      <<address>>
716  *
717  *      JUMPR           [ | IFTRUE/IFFALSE ( ... ) ]
718  *      <<distance>>
719  *
720  *      CALL            [ | IFTRUE/IFFALSE ( ... ) ]
721  *      <<address>>
722  *
723  *      CALLR           [ | IFTRUE/IFFALSE ( ... ) ]
724  *      <<distance>>
725  *
726  *      RETURN          [ | IFTRUE/IFFALSE ( ... ) ]
727  *      <<dummy>>
728  *
729  *      INT             [ | IFTRUE/IFFALSE ( ... ) ]
730  *      <<ident>>
731  *
732  *      INT_FLY         [ | IFTRUE/IFFALSE ( ... ) ]
733  *      <<ident>>
734  *
735  *      Conditions:
736  *           WHEN (phase)
737  *           IF   (phase)
738  *           CARRYSET
739  *           DATA (data, mask)
740  *
741  *-----------------------------------------------------------
742  */
743
744 #define SCR_NO_OP       0x80000000
745 #define SCR_JUMP        0x80080000
746 #define SCR_JUMP64      0x80480000
747 #define SCR_JUMPR       0x80880000
748 #define SCR_CALL        0x88080000
749 #define SCR_CALLR       0x88880000
750 #define SCR_RETURN      0x90080000
751 #define SCR_INT         0x98080000
752 #define SCR_INT_FLY     0x98180000
753
754 #define IFFALSE(arg)   (0x00080000 | (arg))
755 #define IFTRUE(arg)    (0x00000000 | (arg))
756
757 #define WHEN(phase)    (0x00030000 | (phase))
758 #define IF(phase)      (0x00020000 | (phase))
759
760 #define DATA(D)        (0x00040000 | ((D) & 0xff))
761 #define MASK(D,M)      (0x00040000 | (((M ^ 0xff) & 0xff) << 8ul)|((D) & 0xff))
762
763 #define CARRYSET       (0x00200000)
764
765 /*-----------------------------------------------------------
766  *
767  *      SCSI  constants.
768  *
769  *-----------------------------------------------------------
770  */
771
772 /*
773  *      Messages
774  */
775
776 #define M_COMPLETE      (0x00)
777 #define M_EXTENDED      (0x01)
778 #define M_SAVE_DP       (0x02)
779 #define M_RESTORE_DP    (0x03)
780 #define M_DISCONNECT    (0x04)
781 #define M_ID_ERROR      (0x05)
782 #define M_ABORT         (0x06)
783 #define M_REJECT        (0x07)
784 #define M_NOOP          (0x08)
785 #define M_PARITY        (0x09)
786 #define M_LCOMPLETE     (0x0a)
787 #define M_FCOMPLETE     (0x0b)
788 #define M_RESET         (0x0c)
789 #define M_ABORT_TAG     (0x0d)
790 #define M_CLEAR_QUEUE   (0x0e)
791 #define M_INIT_REC      (0x0f)
792 #define M_REL_REC       (0x10)
793 #define M_TERMINATE     (0x11)
794 #define M_SIMPLE_TAG    (0x20)
795 #define M_HEAD_TAG      (0x21)
796 #define M_ORDERED_TAG   (0x22)
797 #define M_IGN_RESIDUE   (0x23)
798 #define M_IDENTIFY      (0x80)
799
800 #define M_X_MODIFY_DP   (0x00)
801 #define M_X_SYNC_REQ    (0x01)
802 #define M_X_WIDE_REQ    (0x03)
803 #define M_X_PPR_REQ     (0x04)
804
805 /*
806  *      PPR protocol options
807  */
808 #define PPR_OPT_IU      (0x01)
809 #define PPR_OPT_DT      (0x02)
810 #define PPR_OPT_QAS     (0x04)
811 #define PPR_OPT_MASK    (0x07)
812
813 /*
814  *      Status
815  */
816
817 #define S_GOOD          (0x00)
818 #define S_CHECK_COND    (0x02)
819 #define S_COND_MET      (0x04)
820 #define S_BUSY          (0x08)
821 #define S_INT           (0x10)
822 #define S_INT_COND_MET  (0x14)
823 #define S_CONFLICT      (0x18)
824 #define S_TERMINATED    (0x20)
825 #define S_QUEUE_FULL    (0x28)
826 #define S_ILLEGAL       (0xff)
827
828 #endif /* defined SYM_DEFS_H */