18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family
48c2ecf20Sopenharmony_ci * of PCI-SCSI IO processors.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright (C) 1999-2001  Gerard Roudier <groudier@free.fr>
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * This driver is derived from the Linux sym53c8xx driver.
98c2ecf20Sopenharmony_ci * Copyright (C) 1998-2000  Gerard Roudier
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The sym53c8xx driver is derived from the ncr53c8xx driver that had been
128c2ecf20Sopenharmony_ci * a port of the FreeBSD ncr driver to Linux-1.2.13.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * The original ncr driver has been written for 386bsd and FreeBSD by
158c2ecf20Sopenharmony_ci *         Wolfgang Stanglmeier        <wolf@cologne.de>
168c2ecf20Sopenharmony_ci *         Stefan Esser                <se@mi.Uni-Koeln.de>
178c2ecf20Sopenharmony_ci * Copyright (C) 1994  Wolfgang Stanglmeier
188c2ecf20Sopenharmony_ci *
198c2ecf20Sopenharmony_ci * Other major contributions:
208c2ecf20Sopenharmony_ci *
218c2ecf20Sopenharmony_ci * NVRAM detection and reading.
228c2ecf20Sopenharmony_ci * Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
238c2ecf20Sopenharmony_ci *
248c2ecf20Sopenharmony_ci *-----------------------------------------------------------------------------
258c2ecf20Sopenharmony_ci */
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#ifndef SYM_DEFS_H
288c2ecf20Sopenharmony_ci#define SYM_DEFS_H
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define SYM_VERSION "2.2.3"
318c2ecf20Sopenharmony_ci#define SYM_DRIVER_NAME	"sym-" SYM_VERSION
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/*
348c2ecf20Sopenharmony_ci *	SYM53C8XX device features descriptor.
358c2ecf20Sopenharmony_ci */
368c2ecf20Sopenharmony_cistruct sym_chip {
378c2ecf20Sopenharmony_ci	u_short	device_id;
388c2ecf20Sopenharmony_ci	u_short	revision_id;
398c2ecf20Sopenharmony_ci	char	*name;
408c2ecf20Sopenharmony_ci	u_char	burst_max;	/* log-base-2 of max burst */
418c2ecf20Sopenharmony_ci	u_char	offset_max;
428c2ecf20Sopenharmony_ci	u_char	nr_divisor;
438c2ecf20Sopenharmony_ci	u_char	lp_probe_bit;
448c2ecf20Sopenharmony_ci	u_int	features;
458c2ecf20Sopenharmony_ci#define FE_LED0		(1<<0)
468c2ecf20Sopenharmony_ci#define FE_WIDE		(1<<1)    /* Wide data transfers */
478c2ecf20Sopenharmony_ci#define FE_ULTRA	(1<<2)	  /* Ultra speed 20Mtrans/sec */
488c2ecf20Sopenharmony_ci#define FE_ULTRA2	(1<<3)	  /* Ultra 2 - 40 Mtrans/sec */
498c2ecf20Sopenharmony_ci#define FE_DBLR		(1<<4)	  /* Clock doubler present */
508c2ecf20Sopenharmony_ci#define FE_QUAD		(1<<5)	  /* Clock quadrupler present */
518c2ecf20Sopenharmony_ci#define FE_ERL		(1<<6)    /* Enable read line */
528c2ecf20Sopenharmony_ci#define FE_CLSE		(1<<7)    /* Cache line size enable */
538c2ecf20Sopenharmony_ci#define FE_WRIE		(1<<8)    /* Write & Invalidate enable */
548c2ecf20Sopenharmony_ci#define FE_ERMP		(1<<9)    /* Enable read multiple */
558c2ecf20Sopenharmony_ci#define FE_BOF		(1<<10)   /* Burst opcode fetch */
568c2ecf20Sopenharmony_ci#define FE_DFS		(1<<11)   /* DMA fifo size */
578c2ecf20Sopenharmony_ci#define FE_PFEN		(1<<12)   /* Prefetch enable */
588c2ecf20Sopenharmony_ci#define FE_LDSTR	(1<<13)   /* Load/Store supported */
598c2ecf20Sopenharmony_ci#define FE_RAM		(1<<14)   /* On chip RAM present */
608c2ecf20Sopenharmony_ci#define FE_VARCLK	(1<<15)   /* Clock frequency may vary */
618c2ecf20Sopenharmony_ci#define FE_RAM8K	(1<<16)   /* On chip RAM sized 8Kb */
628c2ecf20Sopenharmony_ci#define FE_64BIT	(1<<17)   /* 64-bit PCI BUS interface */
638c2ecf20Sopenharmony_ci#define FE_IO256	(1<<18)   /* Requires full 256 bytes in PCI space */
648c2ecf20Sopenharmony_ci#define FE_NOPM		(1<<19)   /* Scripts handles phase mismatch */
658c2ecf20Sopenharmony_ci#define FE_LEDC		(1<<20)   /* Hardware control of LED */
668c2ecf20Sopenharmony_ci#define FE_ULTRA3	(1<<21)	  /* Ultra 3 - 80 Mtrans/sec DT */
678c2ecf20Sopenharmony_ci#define FE_66MHZ	(1<<22)	  /* 66MHz PCI support */
688c2ecf20Sopenharmony_ci#define FE_CRC		(1<<23)	  /* CRC support */
698c2ecf20Sopenharmony_ci#define FE_DIFF		(1<<24)	  /* SCSI HVD support */
708c2ecf20Sopenharmony_ci#define FE_DFBC		(1<<25)	  /* Have DFBC register */
718c2ecf20Sopenharmony_ci#define FE_LCKFRQ	(1<<26)	  /* Have LCKFRQ */
728c2ecf20Sopenharmony_ci#define FE_C10		(1<<27)	  /* Various C10 core (mis)features */
738c2ecf20Sopenharmony_ci#define FE_U3EN		(1<<28)	  /* U3EN bit usable */
748c2ecf20Sopenharmony_ci#define FE_DAC		(1<<29)	  /* Support PCI DAC (64 bit addressing) */
758c2ecf20Sopenharmony_ci#define FE_ISTAT1 	(1<<30)   /* Have ISTAT1, MBOX0, MBOX1 registers */
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci#define FE_CACHE_SET	(FE_ERL|FE_CLSE|FE_WRIE|FE_ERMP)
788c2ecf20Sopenharmony_ci#define FE_CACHE0_SET	(FE_CACHE_SET & ~FE_ERL)
798c2ecf20Sopenharmony_ci};
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci/*
828c2ecf20Sopenharmony_ci *	SYM53C8XX IO register data structure.
838c2ecf20Sopenharmony_ci */
848c2ecf20Sopenharmony_cistruct sym_reg {
858c2ecf20Sopenharmony_ci/*00*/  u8	nc_scntl0;	/* full arb., ena parity, par->ATN  */
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci/*01*/  u8	nc_scntl1;	/* no reset                         */
888c2ecf20Sopenharmony_ci        #define   ISCON   0x10  /* connected to scsi		    */
898c2ecf20Sopenharmony_ci        #define   CRST    0x08  /* force reset                      */
908c2ecf20Sopenharmony_ci        #define   IARB    0x02  /* immediate arbitration            */
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci/*02*/  u8	nc_scntl2;	/* no disconnect expected           */
938c2ecf20Sopenharmony_ci	#define   SDU     0x80  /* cmd: disconnect will raise error */
948c2ecf20Sopenharmony_ci	#define   CHM     0x40  /* sta: chained mode                */
958c2ecf20Sopenharmony_ci	#define   WSS     0x08  /* sta: wide scsi send           [W]*/
968c2ecf20Sopenharmony_ci	#define   WSR     0x01  /* sta: wide scsi received       [W]*/
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci/*03*/  u8	nc_scntl3;	/* cnf system clock dependent       */
998c2ecf20Sopenharmony_ci	#define   EWS     0x08  /* cmd: enable wide scsi         [W]*/
1008c2ecf20Sopenharmony_ci	#define   ULTRA   0x80  /* cmd: ULTRA enable                */
1018c2ecf20Sopenharmony_ci				/* bits 0-2, 7 rsvd for C1010       */
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci/*04*/  u8	nc_scid;	/* cnf host adapter scsi address    */
1048c2ecf20Sopenharmony_ci	#define   RRE     0x40  /* r/w:e enable response to resel.  */
1058c2ecf20Sopenharmony_ci	#define   SRE     0x20  /* r/w:e enable response to select  */
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci/*05*/  u8	nc_sxfer;	/* ### Sync speed and count         */
1088c2ecf20Sopenharmony_ci				/* bits 6-7 rsvd for C1010          */
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci/*06*/  u8	nc_sdid;	/* ### Destination-ID               */
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci/*07*/  u8	nc_gpreg;	/* ??? IO-Pins                      */
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci/*08*/  u8	nc_sfbr;	/* ### First byte received          */
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci/*09*/  u8	nc_socl;
1178c2ecf20Sopenharmony_ci	#define   CREQ	  0x80	/* r/w: SCSI-REQ                    */
1188c2ecf20Sopenharmony_ci	#define   CACK	  0x40	/* r/w: SCSI-ACK                    */
1198c2ecf20Sopenharmony_ci	#define   CBSY	  0x20	/* r/w: SCSI-BSY                    */
1208c2ecf20Sopenharmony_ci	#define   CSEL	  0x10	/* r/w: SCSI-SEL                    */
1218c2ecf20Sopenharmony_ci	#define   CATN	  0x08	/* r/w: SCSI-ATN                    */
1228c2ecf20Sopenharmony_ci	#define   CMSG	  0x04	/* r/w: SCSI-MSG                    */
1238c2ecf20Sopenharmony_ci	#define   CC_D	  0x02	/* r/w: SCSI-C_D                    */
1248c2ecf20Sopenharmony_ci	#define   CI_O	  0x01	/* r/w: SCSI-I_O                    */
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci/*0a*/  u8	nc_ssid;
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci/*0b*/  u8	nc_sbcl;
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci/*0c*/  u8	nc_dstat;
1318c2ecf20Sopenharmony_ci        #define   DFE     0x80  /* sta: dma fifo empty              */
1328c2ecf20Sopenharmony_ci        #define   MDPE    0x40  /* int: master data parity error    */
1338c2ecf20Sopenharmony_ci        #define   BF      0x20  /* int: script: bus fault           */
1348c2ecf20Sopenharmony_ci        #define   ABRT    0x10  /* int: script: command aborted     */
1358c2ecf20Sopenharmony_ci        #define   SSI     0x08  /* int: script: single step         */
1368c2ecf20Sopenharmony_ci        #define   SIR     0x04  /* int: script: interrupt instruct. */
1378c2ecf20Sopenharmony_ci        #define   IID     0x01  /* int: script: illegal instruct.   */
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci/*0d*/  u8	nc_sstat0;
1408c2ecf20Sopenharmony_ci        #define   ILF     0x80  /* sta: data in SIDL register lsb   */
1418c2ecf20Sopenharmony_ci        #define   ORF     0x40  /* sta: data in SODR register lsb   */
1428c2ecf20Sopenharmony_ci        #define   OLF     0x20  /* sta: data in SODL register lsb   */
1438c2ecf20Sopenharmony_ci        #define   AIP     0x10  /* sta: arbitration in progress     */
1448c2ecf20Sopenharmony_ci        #define   LOA     0x08  /* sta: arbitration lost            */
1458c2ecf20Sopenharmony_ci        #define   WOA     0x04  /* sta: arbitration won             */
1468c2ecf20Sopenharmony_ci        #define   IRST    0x02  /* sta: scsi reset signal           */
1478c2ecf20Sopenharmony_ci        #define   SDP     0x01  /* sta: scsi parity signal          */
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci/*0e*/  u8	nc_sstat1;
1508c2ecf20Sopenharmony_ci	#define   FF3210  0xf0	/* sta: bytes in the scsi fifo      */
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci/*0f*/  u8	nc_sstat2;
1538c2ecf20Sopenharmony_ci        #define   ILF1    0x80  /* sta: data in SIDL register msb[W]*/
1548c2ecf20Sopenharmony_ci        #define   ORF1    0x40  /* sta: data in SODR register msb[W]*/
1558c2ecf20Sopenharmony_ci        #define   OLF1    0x20  /* sta: data in SODL register msb[W]*/
1568c2ecf20Sopenharmony_ci        #define   DM      0x04  /* sta: DIFFSENS mismatch (895/6 only) */
1578c2ecf20Sopenharmony_ci        #define   LDSC    0x02  /* sta: disconnect & reconnect      */
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci/*10*/  u8	nc_dsa;		/* --> Base page                    */
1608c2ecf20Sopenharmony_ci/*11*/  u8	nc_dsa1;
1618c2ecf20Sopenharmony_ci/*12*/  u8	nc_dsa2;
1628c2ecf20Sopenharmony_ci/*13*/  u8	nc_dsa3;
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci/*14*/  u8	nc_istat;	/* --> Main Command and status      */
1658c2ecf20Sopenharmony_ci        #define   CABRT   0x80  /* cmd: abort current operation     */
1668c2ecf20Sopenharmony_ci        #define   SRST    0x40  /* mod: reset chip                  */
1678c2ecf20Sopenharmony_ci        #define   SIGP    0x20  /* r/w: message from host to script */
1688c2ecf20Sopenharmony_ci        #define   SEM     0x10  /* r/w: message between host + script  */
1698c2ecf20Sopenharmony_ci        #define   CON     0x08  /* sta: connected to scsi           */
1708c2ecf20Sopenharmony_ci        #define   INTF    0x04  /* sta: int on the fly (reset by wr)*/
1718c2ecf20Sopenharmony_ci        #define   SIP     0x02  /* sta: scsi-interrupt              */
1728c2ecf20Sopenharmony_ci        #define   DIP     0x01  /* sta: host/script interrupt       */
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci/*15*/  u8	nc_istat1;	/* 896 only */
1758c2ecf20Sopenharmony_ci        #define   FLSH    0x04  /* sta: chip is flushing            */
1768c2ecf20Sopenharmony_ci        #define   SCRUN   0x02  /* sta: scripts are running         */
1778c2ecf20Sopenharmony_ci        #define   SIRQD   0x01  /* r/w: disable INT pin             */
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci/*16*/  u8	nc_mbox0;	/* 896 only */
1808c2ecf20Sopenharmony_ci/*17*/  u8	nc_mbox1;	/* 896 only */
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci/*18*/	u8	nc_ctest0;
1838c2ecf20Sopenharmony_ci/*19*/  u8	nc_ctest1;
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci/*1a*/  u8	nc_ctest2;
1868c2ecf20Sopenharmony_ci	#define   CSIGP   0x40
1878c2ecf20Sopenharmony_ci				/* bits 0-2,7 rsvd for C1010        */
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci/*1b*/  u8	nc_ctest3;
1908c2ecf20Sopenharmony_ci	#define   FLF     0x08  /* cmd: flush dma fifo              */
1918c2ecf20Sopenharmony_ci	#define   CLF	  0x04	/* cmd: clear dma fifo		    */
1928c2ecf20Sopenharmony_ci	#define   FM      0x02  /* mod: fetch pin mode              */
1938c2ecf20Sopenharmony_ci	#define   WRIE    0x01  /* mod: write and invalidate enable */
1948c2ecf20Sopenharmony_ci				/* bits 4-7 rsvd for C1010          */
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci/*1c*/  u32	nc_temp;	/* ### Temporary stack              */
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ci/*20*/	u8	nc_dfifo;
1998c2ecf20Sopenharmony_ci/*21*/  u8	nc_ctest4;
2008c2ecf20Sopenharmony_ci	#define   BDIS    0x80  /* mod: burst disable               */
2018c2ecf20Sopenharmony_ci	#define   MPEE    0x08  /* mod: master parity error enable  */
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci/*22*/  u8	nc_ctest5;
2048c2ecf20Sopenharmony_ci	#define   DFS     0x20  /* mod: dma fifo size               */
2058c2ecf20Sopenharmony_ci				/* bits 0-1, 3-7 rsvd for C1010     */
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_ci/*23*/  u8	nc_ctest6;
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci/*24*/  u32	nc_dbc;		/* ### Byte count and command       */
2108c2ecf20Sopenharmony_ci/*28*/  u32	nc_dnad;	/* ### Next command register        */
2118c2ecf20Sopenharmony_ci/*2c*/  u32	nc_dsp;		/* --> Script Pointer               */
2128c2ecf20Sopenharmony_ci/*30*/  u32	nc_dsps;	/* --> Script pointer save/opcode#2 */
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci/*34*/  u8	nc_scratcha;	/* Temporary register a            */
2158c2ecf20Sopenharmony_ci/*35*/  u8	nc_scratcha1;
2168c2ecf20Sopenharmony_ci/*36*/  u8	nc_scratcha2;
2178c2ecf20Sopenharmony_ci/*37*/  u8	nc_scratcha3;
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci/*38*/  u8	nc_dmode;
2208c2ecf20Sopenharmony_ci	#define   BL_2    0x80  /* mod: burst length shift value +2 */
2218c2ecf20Sopenharmony_ci	#define   BL_1    0x40  /* mod: burst length shift value +1 */
2228c2ecf20Sopenharmony_ci	#define   ERL     0x08  /* mod: enable read line            */
2238c2ecf20Sopenharmony_ci	#define   ERMP    0x04  /* mod: enable read multiple        */
2248c2ecf20Sopenharmony_ci	#define   BOF     0x02  /* mod: burst op code fetch         */
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci/*39*/  u8	nc_dien;
2278c2ecf20Sopenharmony_ci/*3a*/  u8	nc_sbr;
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci/*3b*/  u8	nc_dcntl;	/* --> Script execution control     */
2308c2ecf20Sopenharmony_ci	#define   CLSE    0x80  /* mod: cache line size enable      */
2318c2ecf20Sopenharmony_ci	#define   PFF     0x40  /* cmd: pre-fetch flush             */
2328c2ecf20Sopenharmony_ci	#define   PFEN    0x20  /* mod: pre-fetch enable            */
2338c2ecf20Sopenharmony_ci	#define   SSM     0x10  /* mod: single step mode            */
2348c2ecf20Sopenharmony_ci	#define   IRQM    0x08  /* mod: irq mode (1 = totem pole !) */
2358c2ecf20Sopenharmony_ci	#define   STD     0x04  /* cmd: start dma mode              */
2368c2ecf20Sopenharmony_ci	#define   IRQD    0x02  /* mod: irq disable                 */
2378c2ecf20Sopenharmony_ci 	#define	  NOCOM   0x01	/* cmd: protect sfbr while reselect */
2388c2ecf20Sopenharmony_ci				/* bits 0-1 rsvd for C1010          */
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci/*3c*/  u32	nc_adder;
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci/*40*/  u16	nc_sien;	/* -->: interrupt enable            */
2438c2ecf20Sopenharmony_ci/*42*/  u16	nc_sist;	/* <--: interrupt status            */
2448c2ecf20Sopenharmony_ci        #define   SBMC    0x1000/* sta: SCSI Bus Mode Change (895/6 only) */
2458c2ecf20Sopenharmony_ci        #define   STO     0x0400/* sta: timeout (select)            */
2468c2ecf20Sopenharmony_ci        #define   GEN     0x0200/* sta: timeout (general)           */
2478c2ecf20Sopenharmony_ci        #define   HTH     0x0100/* sta: timeout (handshake)         */
2488c2ecf20Sopenharmony_ci        #define   MA      0x80  /* sta: phase mismatch              */
2498c2ecf20Sopenharmony_ci        #define   CMP     0x40  /* sta: arbitration complete        */
2508c2ecf20Sopenharmony_ci        #define   SEL     0x20  /* sta: selected by another device  */
2518c2ecf20Sopenharmony_ci        #define   RSL     0x10  /* sta: reselected by another device*/
2528c2ecf20Sopenharmony_ci        #define   SGE     0x08  /* sta: gross error (over/underflow)*/
2538c2ecf20Sopenharmony_ci        #define   UDC     0x04  /* sta: unexpected disconnect       */
2548c2ecf20Sopenharmony_ci        #define   RST     0x02  /* sta: scsi bus reset detected     */
2558c2ecf20Sopenharmony_ci        #define   PAR     0x01  /* sta: scsi parity error           */
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci/*44*/  u8	nc_slpar;
2588c2ecf20Sopenharmony_ci/*45*/  u8	nc_swide;
2598c2ecf20Sopenharmony_ci/*46*/  u8	nc_macntl;
2608c2ecf20Sopenharmony_ci/*47*/  u8	nc_gpcntl;
2618c2ecf20Sopenharmony_ci/*48*/  u8	nc_stime0;	/* cmd: timeout for select&handshake*/
2628c2ecf20Sopenharmony_ci/*49*/  u8	nc_stime1;	/* cmd: timeout user defined        */
2638c2ecf20Sopenharmony_ci/*4a*/  u16	nc_respid;	/* sta: Reselect-IDs                */
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci/*4c*/  u8	nc_stest0;
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci/*4d*/  u8	nc_stest1;
2688c2ecf20Sopenharmony_ci	#define   SCLK    0x80	/* Use the PCI clock as SCSI clock	*/
2698c2ecf20Sopenharmony_ci	#define   DBLEN   0x08	/* clock doubler running		*/
2708c2ecf20Sopenharmony_ci	#define   DBLSEL  0x04	/* clock doubler selected		*/
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci/*4e*/  u8	nc_stest2;
2748c2ecf20Sopenharmony_ci	#define   ROF     0x40	/* reset scsi offset (after gross error!) */
2758c2ecf20Sopenharmony_ci	#define   EXT     0x02  /* extended filtering                     */
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci/*4f*/  u8	nc_stest3;
2788c2ecf20Sopenharmony_ci	#define   TE     0x80	/* c: tolerAnt enable */
2798c2ecf20Sopenharmony_ci	#define   HSC    0x20	/* c: Halt SCSI Clock */
2808c2ecf20Sopenharmony_ci	#define   CSF    0x02	/* c: clear scsi fifo */
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci/*50*/  u16	nc_sidl;	/* Lowlevel: latched from scsi data */
2838c2ecf20Sopenharmony_ci/*52*/  u8	nc_stest4;
2848c2ecf20Sopenharmony_ci	#define   SMODE  0xc0	/* SCSI bus mode      (895/6 only) */
2858c2ecf20Sopenharmony_ci	#define    SMODE_HVD 0x40	/* High Voltage Differential       */
2868c2ecf20Sopenharmony_ci	#define    SMODE_SE  0x80	/* Single Ended                    */
2878c2ecf20Sopenharmony_ci	#define    SMODE_LVD 0xc0	/* Low Voltage Differential        */
2888c2ecf20Sopenharmony_ci	#define   LCKFRQ 0x20	/* Frequency Lock (895/6 only)     */
2898c2ecf20Sopenharmony_ci				/* bits 0-5 rsvd for C1010         */
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ci/*53*/  u8	nc_53_;
2928c2ecf20Sopenharmony_ci/*54*/  u16	nc_sodl;	/* Lowlevel: data out to scsi data  */
2938c2ecf20Sopenharmony_ci/*56*/	u8	nc_ccntl0;	/* Chip Control 0 (896)             */
2948c2ecf20Sopenharmony_ci	#define   ENPMJ  0x80	/* Enable Phase Mismatch Jump       */
2958c2ecf20Sopenharmony_ci	#define   PMJCTL 0x40	/* Phase Mismatch Jump Control      */
2968c2ecf20Sopenharmony_ci	#define   ENNDJ  0x20	/* Enable Non Data PM Jump          */
2978c2ecf20Sopenharmony_ci	#define   DISFC  0x10	/* Disable Auto FIFO Clear          */
2988c2ecf20Sopenharmony_ci	#define   DILS   0x02	/* Disable Internal Load/Store      */
2998c2ecf20Sopenharmony_ci	#define   DPR    0x01	/* Disable Pipe Req                 */
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci/*57*/	u8	nc_ccntl1;	/* Chip Control 1 (896)             */
3028c2ecf20Sopenharmony_ci	#define   ZMOD   0x80	/* High Impedance Mode              */
3038c2ecf20Sopenharmony_ci	#define   DDAC   0x08	/* Disable Dual Address Cycle       */
3048c2ecf20Sopenharmony_ci	#define   XTIMOD 0x04	/* 64-bit Table Ind. Indexing Mode  */
3058c2ecf20Sopenharmony_ci	#define   EXTIBMV 0x02	/* Enable 64-bit Table Ind. BMOV    */
3068c2ecf20Sopenharmony_ci	#define   EXDBMV 0x01	/* Enable 64-bit Direct BMOV        */
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_ci/*58*/  u16	nc_sbdl;	/* Lowlevel: data from scsi data    */
3098c2ecf20Sopenharmony_ci/*5a*/  u16	nc_5a_;
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci/*5c*/  u8	nc_scr0;	/* Working register B               */
3128c2ecf20Sopenharmony_ci/*5d*/  u8	nc_scr1;
3138c2ecf20Sopenharmony_ci/*5e*/  u8	nc_scr2;
3148c2ecf20Sopenharmony_ci/*5f*/  u8	nc_scr3;
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci/*60*/  u8	nc_scrx[64];	/* Working register C-R             */
3178c2ecf20Sopenharmony_ci/*a0*/	u32	nc_mmrs;	/* Memory Move Read Selector        */
3188c2ecf20Sopenharmony_ci/*a4*/	u32	nc_mmws;	/* Memory Move Write Selector       */
3198c2ecf20Sopenharmony_ci/*a8*/	u32	nc_sfs;		/* Script Fetch Selector            */
3208c2ecf20Sopenharmony_ci/*ac*/	u32	nc_drs;		/* DSA Relative Selector            */
3218c2ecf20Sopenharmony_ci/*b0*/	u32	nc_sbms;	/* Static Block Move Selector       */
3228c2ecf20Sopenharmony_ci/*b4*/	u32	nc_dbms;	/* Dynamic Block Move Selector      */
3238c2ecf20Sopenharmony_ci/*b8*/	u32	nc_dnad64;	/* DMA Next Address 64              */
3248c2ecf20Sopenharmony_ci/*bc*/	u16	nc_scntl4;	/* C1010 only                       */
3258c2ecf20Sopenharmony_ci	#define   U3EN    0x80	/* Enable Ultra 3                   */
3268c2ecf20Sopenharmony_ci	#define   AIPCKEN 0x40  /* AIP checking enable              */
3278c2ecf20Sopenharmony_ci				/* Also enable AIP generation on C10-33*/
3288c2ecf20Sopenharmony_ci	#define   XCLKH_DT 0x08 /* Extra clock of data hold on DT edge */
3298c2ecf20Sopenharmony_ci	#define   XCLKH_ST 0x04 /* Extra clock of data hold on ST edge */
3308c2ecf20Sopenharmony_ci	#define   XCLKS_DT 0x02 /* Extra clock of data set  on DT edge */
3318c2ecf20Sopenharmony_ci	#define   XCLKS_ST 0x01 /* Extra clock of data set  on ST edge */
3328c2ecf20Sopenharmony_ci/*be*/	u8	nc_aipcntl0;	/* AIP Control 0 C1010 only         */
3338c2ecf20Sopenharmony_ci/*bf*/	u8	nc_aipcntl1;	/* AIP Control 1 C1010 only         */
3348c2ecf20Sopenharmony_ci	#define DISAIP  0x08	/* Disable AIP generation C10-66 only  */
3358c2ecf20Sopenharmony_ci/*c0*/	u32	nc_pmjad1;	/* Phase Mismatch Jump Address 1    */
3368c2ecf20Sopenharmony_ci/*c4*/	u32	nc_pmjad2;	/* Phase Mismatch Jump Address 2    */
3378c2ecf20Sopenharmony_ci/*c8*/	u8	nc_rbc;		/* Remaining Byte Count             */
3388c2ecf20Sopenharmony_ci/*c9*/	u8	nc_rbc1;
3398c2ecf20Sopenharmony_ci/*ca*/	u8	nc_rbc2;
3408c2ecf20Sopenharmony_ci/*cb*/	u8	nc_rbc3;
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ci/*cc*/	u8	nc_ua;		/* Updated Address                  */
3438c2ecf20Sopenharmony_ci/*cd*/	u8	nc_ua1;
3448c2ecf20Sopenharmony_ci/*ce*/	u8	nc_ua2;
3458c2ecf20Sopenharmony_ci/*cf*/	u8	nc_ua3;
3468c2ecf20Sopenharmony_ci/*d0*/	u32	nc_esa;		/* Entry Storage Address            */
3478c2ecf20Sopenharmony_ci/*d4*/	u8	nc_ia;		/* Instruction Address              */
3488c2ecf20Sopenharmony_ci/*d5*/	u8	nc_ia1;
3498c2ecf20Sopenharmony_ci/*d6*/	u8	nc_ia2;
3508c2ecf20Sopenharmony_ci/*d7*/	u8	nc_ia3;
3518c2ecf20Sopenharmony_ci/*d8*/	u32	nc_sbc;		/* SCSI Byte Count (3 bytes only)   */
3528c2ecf20Sopenharmony_ci/*dc*/	u32	nc_csbc;	/* Cumulative SCSI Byte Count       */
3538c2ecf20Sopenharmony_ci                                /* Following for C1010 only         */
3548c2ecf20Sopenharmony_ci/*e0*/	u16    nc_crcpad;	/* CRC Value                        */
3558c2ecf20Sopenharmony_ci/*e2*/	u8     nc_crccntl0;	/* CRC control register             */
3568c2ecf20Sopenharmony_ci	#define   SNDCRC  0x10	/* Send CRC Request                 */
3578c2ecf20Sopenharmony_ci/*e3*/	u8     nc_crccntl1;	/* CRC control register             */
3588c2ecf20Sopenharmony_ci/*e4*/	u32    nc_crcdata;	/* CRC data register                */
3598c2ecf20Sopenharmony_ci/*e8*/	u32    nc_e8_;
3608c2ecf20Sopenharmony_ci/*ec*/	u32    nc_ec_;
3618c2ecf20Sopenharmony_ci/*f0*/	u16    nc_dfbc;		/* DMA FIFO byte count              */
3628c2ecf20Sopenharmony_ci};
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci/*-----------------------------------------------------------
3658c2ecf20Sopenharmony_ci *
3668c2ecf20Sopenharmony_ci *	Utility macros for the script.
3678c2ecf20Sopenharmony_ci *
3688c2ecf20Sopenharmony_ci *-----------------------------------------------------------
3698c2ecf20Sopenharmony_ci */
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_ci#define REGJ(p,r) (offsetof(struct sym_reg, p ## r))
3728c2ecf20Sopenharmony_ci#define REG(r) REGJ (nc_, r)
3738c2ecf20Sopenharmony_ci
3748c2ecf20Sopenharmony_ci/*-----------------------------------------------------------
3758c2ecf20Sopenharmony_ci *
3768c2ecf20Sopenharmony_ci *	SCSI phases
3778c2ecf20Sopenharmony_ci *
3788c2ecf20Sopenharmony_ci *-----------------------------------------------------------
3798c2ecf20Sopenharmony_ci */
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_ci#define	SCR_DATA_OUT	0x00000000
3828c2ecf20Sopenharmony_ci#define	SCR_DATA_IN	0x01000000
3838c2ecf20Sopenharmony_ci#define	SCR_COMMAND	0x02000000
3848c2ecf20Sopenharmony_ci#define	SCR_STATUS	0x03000000
3858c2ecf20Sopenharmony_ci#define	SCR_DT_DATA_OUT	0x04000000
3868c2ecf20Sopenharmony_ci#define	SCR_DT_DATA_IN	0x05000000
3878c2ecf20Sopenharmony_ci#define SCR_MSG_OUT	0x06000000
3888c2ecf20Sopenharmony_ci#define SCR_MSG_IN      0x07000000
3898c2ecf20Sopenharmony_ci/* DT phases are illegal for non Ultra3 mode */
3908c2ecf20Sopenharmony_ci#define SCR_ILG_OUT	0x04000000
3918c2ecf20Sopenharmony_ci#define SCR_ILG_IN	0x05000000
3928c2ecf20Sopenharmony_ci
3938c2ecf20Sopenharmony_ci/*-----------------------------------------------------------
3948c2ecf20Sopenharmony_ci *
3958c2ecf20Sopenharmony_ci *	Data transfer via SCSI.
3968c2ecf20Sopenharmony_ci *
3978c2ecf20Sopenharmony_ci *-----------------------------------------------------------
3988c2ecf20Sopenharmony_ci *
3998c2ecf20Sopenharmony_ci *	MOVE_ABS (LEN)
4008c2ecf20Sopenharmony_ci *	<<start address>>
4018c2ecf20Sopenharmony_ci *
4028c2ecf20Sopenharmony_ci *	MOVE_IND (LEN)
4038c2ecf20Sopenharmony_ci *	<<dnad_offset>>
4048c2ecf20Sopenharmony_ci *
4058c2ecf20Sopenharmony_ci *	MOVE_TBL
4068c2ecf20Sopenharmony_ci *	<<dnad_offset>>
4078c2ecf20Sopenharmony_ci *
4088c2ecf20Sopenharmony_ci *-----------------------------------------------------------
4098c2ecf20Sopenharmony_ci */
4108c2ecf20Sopenharmony_ci
4118c2ecf20Sopenharmony_ci#define OPC_MOVE          0x08000000
4128c2ecf20Sopenharmony_ci
4138c2ecf20Sopenharmony_ci#define SCR_MOVE_ABS(l) ((0x00000000 | OPC_MOVE) | (l))
4148c2ecf20Sopenharmony_ci/* #define SCR_MOVE_IND(l) ((0x20000000 | OPC_MOVE) | (l)) */
4158c2ecf20Sopenharmony_ci#define SCR_MOVE_TBL     (0x10000000 | OPC_MOVE)
4168c2ecf20Sopenharmony_ci
4178c2ecf20Sopenharmony_ci#define SCR_CHMOV_ABS(l) ((0x00000000) | (l))
4188c2ecf20Sopenharmony_ci/* #define SCR_CHMOV_IND(l) ((0x20000000) | (l)) */
4198c2ecf20Sopenharmony_ci#define SCR_CHMOV_TBL     (0x10000000)
4208c2ecf20Sopenharmony_ci
4218c2ecf20Sopenharmony_ci#ifdef SYM_CONF_TARGET_ROLE_SUPPORT
4228c2ecf20Sopenharmony_ci/* We steal the `indirect addressing' flag for target mode MOVE in scripts */
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_ci#define OPC_TCHMOVE        0x08000000
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_ci#define SCR_TCHMOVE_ABS(l) ((0x20000000 | OPC_TCHMOVE) | (l))
4278c2ecf20Sopenharmony_ci#define SCR_TCHMOVE_TBL     (0x30000000 | OPC_TCHMOVE)
4288c2ecf20Sopenharmony_ci
4298c2ecf20Sopenharmony_ci#define SCR_TMOV_ABS(l)    ((0x20000000) | (l))
4308c2ecf20Sopenharmony_ci#define SCR_TMOV_TBL        (0x30000000)
4318c2ecf20Sopenharmony_ci#endif
4328c2ecf20Sopenharmony_ci
4338c2ecf20Sopenharmony_cistruct sym_tblmove {
4348c2ecf20Sopenharmony_ci        u32  size;
4358c2ecf20Sopenharmony_ci        u32  addr;
4368c2ecf20Sopenharmony_ci};
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_ci/*-----------------------------------------------------------
4398c2ecf20Sopenharmony_ci *
4408c2ecf20Sopenharmony_ci *	Selection
4418c2ecf20Sopenharmony_ci *
4428c2ecf20Sopenharmony_ci *-----------------------------------------------------------
4438c2ecf20Sopenharmony_ci *
4448c2ecf20Sopenharmony_ci *	SEL_ABS | SCR_ID (0..15)    [ | REL_JMP]
4458c2ecf20Sopenharmony_ci *	<<alternate_address>>
4468c2ecf20Sopenharmony_ci *
4478c2ecf20Sopenharmony_ci *	SEL_TBL | << dnad_offset>>  [ | REL_JMP]
4488c2ecf20Sopenharmony_ci *	<<alternate_address>>
4498c2ecf20Sopenharmony_ci *
4508c2ecf20Sopenharmony_ci *-----------------------------------------------------------
4518c2ecf20Sopenharmony_ci */
4528c2ecf20Sopenharmony_ci
4538c2ecf20Sopenharmony_ci#define	SCR_SEL_ABS	0x40000000
4548c2ecf20Sopenharmony_ci#define	SCR_SEL_ABS_ATN	0x41000000
4558c2ecf20Sopenharmony_ci#define	SCR_SEL_TBL	0x42000000
4568c2ecf20Sopenharmony_ci#define	SCR_SEL_TBL_ATN	0x43000000
4578c2ecf20Sopenharmony_ci
4588c2ecf20Sopenharmony_ci#ifdef SYM_CONF_TARGET_ROLE_SUPPORT
4598c2ecf20Sopenharmony_ci#define	SCR_RESEL_ABS     0x40000000
4608c2ecf20Sopenharmony_ci#define	SCR_RESEL_ABS_ATN 0x41000000
4618c2ecf20Sopenharmony_ci#define	SCR_RESEL_TBL     0x42000000
4628c2ecf20Sopenharmony_ci#define	SCR_RESEL_TBL_ATN 0x43000000
4638c2ecf20Sopenharmony_ci#endif
4648c2ecf20Sopenharmony_ci
4658c2ecf20Sopenharmony_cistruct sym_tblsel {
4668c2ecf20Sopenharmony_ci        u_char  sel_scntl4;	/* C1010 only */
4678c2ecf20Sopenharmony_ci        u_char  sel_sxfer;
4688c2ecf20Sopenharmony_ci        u_char  sel_id;
4698c2ecf20Sopenharmony_ci        u_char  sel_scntl3;
4708c2ecf20Sopenharmony_ci};
4718c2ecf20Sopenharmony_ci
4728c2ecf20Sopenharmony_ci#define SCR_JMP_REL     0x04000000
4738c2ecf20Sopenharmony_ci#define SCR_ID(id)	(((u32)(id)) << 16)
4748c2ecf20Sopenharmony_ci
4758c2ecf20Sopenharmony_ci/*-----------------------------------------------------------
4768c2ecf20Sopenharmony_ci *
4778c2ecf20Sopenharmony_ci *	Waiting for Disconnect or Reselect
4788c2ecf20Sopenharmony_ci *
4798c2ecf20Sopenharmony_ci *-----------------------------------------------------------
4808c2ecf20Sopenharmony_ci *
4818c2ecf20Sopenharmony_ci *	WAIT_DISC
4828c2ecf20Sopenharmony_ci *	dummy: <<alternate_address>>
4838c2ecf20Sopenharmony_ci *
4848c2ecf20Sopenharmony_ci *	WAIT_RESEL
4858c2ecf20Sopenharmony_ci *	<<alternate_address>>
4868c2ecf20Sopenharmony_ci *
4878c2ecf20Sopenharmony_ci *-----------------------------------------------------------
4888c2ecf20Sopenharmony_ci */
4898c2ecf20Sopenharmony_ci
4908c2ecf20Sopenharmony_ci#define	SCR_WAIT_DISC	0x48000000
4918c2ecf20Sopenharmony_ci#define SCR_WAIT_RESEL  0x50000000
4928c2ecf20Sopenharmony_ci
4938c2ecf20Sopenharmony_ci#ifdef SYM_CONF_TARGET_ROLE_SUPPORT
4948c2ecf20Sopenharmony_ci#define	SCR_DISCONNECT	0x48000000
4958c2ecf20Sopenharmony_ci#endif
4968c2ecf20Sopenharmony_ci
4978c2ecf20Sopenharmony_ci/*-----------------------------------------------------------
4988c2ecf20Sopenharmony_ci *
4998c2ecf20Sopenharmony_ci *	Bit Set / Reset
5008c2ecf20Sopenharmony_ci *
5018c2ecf20Sopenharmony_ci *-----------------------------------------------------------
5028c2ecf20Sopenharmony_ci *
5038c2ecf20Sopenharmony_ci *	SET (flags {|.. })
5048c2ecf20Sopenharmony_ci *
5058c2ecf20Sopenharmony_ci *	CLR (flags {|.. })
5068c2ecf20Sopenharmony_ci *
5078c2ecf20Sopenharmony_ci *-----------------------------------------------------------
5088c2ecf20Sopenharmony_ci */
5098c2ecf20Sopenharmony_ci
5108c2ecf20Sopenharmony_ci#define SCR_SET(f)     (0x58000000 | (f))
5118c2ecf20Sopenharmony_ci#define SCR_CLR(f)     (0x60000000 | (f))
5128c2ecf20Sopenharmony_ci
5138c2ecf20Sopenharmony_ci#define	SCR_CARRY	0x00000400
5148c2ecf20Sopenharmony_ci#define	SCR_TRG		0x00000200
5158c2ecf20Sopenharmony_ci#define	SCR_ACK		0x00000040
5168c2ecf20Sopenharmony_ci#define	SCR_ATN		0x00000008
5178c2ecf20Sopenharmony_ci
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_ci/*-----------------------------------------------------------
5208c2ecf20Sopenharmony_ci *
5218c2ecf20Sopenharmony_ci *	Memory to memory move
5228c2ecf20Sopenharmony_ci *
5238c2ecf20Sopenharmony_ci *-----------------------------------------------------------
5248c2ecf20Sopenharmony_ci *
5258c2ecf20Sopenharmony_ci *	COPY (bytecount)
5268c2ecf20Sopenharmony_ci *	<< source_address >>
5278c2ecf20Sopenharmony_ci *	<< destination_address >>
5288c2ecf20Sopenharmony_ci *
5298c2ecf20Sopenharmony_ci *	SCR_COPY   sets the NO FLUSH option by default.
5308c2ecf20Sopenharmony_ci *	SCR_COPY_F does not set this option.
5318c2ecf20Sopenharmony_ci *
5328c2ecf20Sopenharmony_ci *	For chips which do not support this option,
5338c2ecf20Sopenharmony_ci *	sym_fw_bind_script() will remove this bit.
5348c2ecf20Sopenharmony_ci *
5358c2ecf20Sopenharmony_ci *-----------------------------------------------------------
5368c2ecf20Sopenharmony_ci */
5378c2ecf20Sopenharmony_ci
5388c2ecf20Sopenharmony_ci#define SCR_NO_FLUSH 0x01000000
5398c2ecf20Sopenharmony_ci
5408c2ecf20Sopenharmony_ci#define SCR_COPY(n) (0xc0000000 | SCR_NO_FLUSH | (n))
5418c2ecf20Sopenharmony_ci#define SCR_COPY_F(n) (0xc0000000 | (n))
5428c2ecf20Sopenharmony_ci
5438c2ecf20Sopenharmony_ci/*-----------------------------------------------------------
5448c2ecf20Sopenharmony_ci *
5458c2ecf20Sopenharmony_ci *	Register move and binary operations
5468c2ecf20Sopenharmony_ci *
5478c2ecf20Sopenharmony_ci *-----------------------------------------------------------
5488c2ecf20Sopenharmony_ci *
5498c2ecf20Sopenharmony_ci *	SFBR_REG (reg, op, data)        reg  = SFBR op data
5508c2ecf20Sopenharmony_ci *	<< 0 >>
5518c2ecf20Sopenharmony_ci *
5528c2ecf20Sopenharmony_ci *	REG_SFBR (reg, op, data)        SFBR = reg op data
5538c2ecf20Sopenharmony_ci *	<< 0 >>
5548c2ecf20Sopenharmony_ci *
5558c2ecf20Sopenharmony_ci *	REG_REG  (reg, op, data)        reg  = reg op data
5568c2ecf20Sopenharmony_ci *	<< 0 >>
5578c2ecf20Sopenharmony_ci *
5588c2ecf20Sopenharmony_ci *-----------------------------------------------------------
5598c2ecf20Sopenharmony_ci *
5608c2ecf20Sopenharmony_ci *	On 825A, 875, 895 and 896 chips the content
5618c2ecf20Sopenharmony_ci *	of SFBR register can be used as data (SCR_SFBR_DATA).
5628c2ecf20Sopenharmony_ci *	The 896 has additionnal IO registers starting at
5638c2ecf20Sopenharmony_ci *	offset 0x80. Bit 7 of register offset is stored in
5648c2ecf20Sopenharmony_ci *	bit 7 of the SCRIPTS instruction first DWORD.
5658c2ecf20Sopenharmony_ci *
5668c2ecf20Sopenharmony_ci *-----------------------------------------------------------
5678c2ecf20Sopenharmony_ci */
5688c2ecf20Sopenharmony_ci
5698c2ecf20Sopenharmony_ci#define SCR_REG_OFS(ofs) ((((ofs) & 0x7f) << 16ul) + ((ofs) & 0x80))
5708c2ecf20Sopenharmony_ci
5718c2ecf20Sopenharmony_ci#define SCR_SFBR_REG(reg,op,data) \
5728c2ecf20Sopenharmony_ci        (0x68000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
5738c2ecf20Sopenharmony_ci
5748c2ecf20Sopenharmony_ci#define SCR_REG_SFBR(reg,op,data) \
5758c2ecf20Sopenharmony_ci        (0x70000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
5768c2ecf20Sopenharmony_ci
5778c2ecf20Sopenharmony_ci#define SCR_REG_REG(reg,op,data) \
5788c2ecf20Sopenharmony_ci        (0x78000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
5798c2ecf20Sopenharmony_ci
5808c2ecf20Sopenharmony_ci
5818c2ecf20Sopenharmony_ci#define      SCR_LOAD   0x00000000
5828c2ecf20Sopenharmony_ci#define      SCR_SHL    0x01000000
5838c2ecf20Sopenharmony_ci#define      SCR_OR     0x02000000
5848c2ecf20Sopenharmony_ci#define      SCR_XOR    0x03000000
5858c2ecf20Sopenharmony_ci#define      SCR_AND    0x04000000
5868c2ecf20Sopenharmony_ci#define      SCR_SHR    0x05000000
5878c2ecf20Sopenharmony_ci#define      SCR_ADD    0x06000000
5888c2ecf20Sopenharmony_ci#define      SCR_ADDC   0x07000000
5898c2ecf20Sopenharmony_ci
5908c2ecf20Sopenharmony_ci#define      SCR_SFBR_DATA   (0x00800000>>8ul)	/* Use SFBR as data */
5918c2ecf20Sopenharmony_ci
5928c2ecf20Sopenharmony_ci/*-----------------------------------------------------------
5938c2ecf20Sopenharmony_ci *
5948c2ecf20Sopenharmony_ci *	FROM_REG (reg)		  SFBR = reg
5958c2ecf20Sopenharmony_ci *	<< 0 >>
5968c2ecf20Sopenharmony_ci *
5978c2ecf20Sopenharmony_ci *	TO_REG	 (reg)		  reg  = SFBR
5988c2ecf20Sopenharmony_ci *	<< 0 >>
5998c2ecf20Sopenharmony_ci *
6008c2ecf20Sopenharmony_ci *	LOAD_REG (reg, data)	  reg  = <data>
6018c2ecf20Sopenharmony_ci *	<< 0 >>
6028c2ecf20Sopenharmony_ci *
6038c2ecf20Sopenharmony_ci *	LOAD_SFBR(data) 	  SFBR = <data>
6048c2ecf20Sopenharmony_ci *	<< 0 >>
6058c2ecf20Sopenharmony_ci *
6068c2ecf20Sopenharmony_ci *-----------------------------------------------------------
6078c2ecf20Sopenharmony_ci */
6088c2ecf20Sopenharmony_ci
6098c2ecf20Sopenharmony_ci#define	SCR_FROM_REG(reg) \
6108c2ecf20Sopenharmony_ci	SCR_REG_SFBR(reg,SCR_OR,0)
6118c2ecf20Sopenharmony_ci
6128c2ecf20Sopenharmony_ci#define	SCR_TO_REG(reg) \
6138c2ecf20Sopenharmony_ci	SCR_SFBR_REG(reg,SCR_OR,0)
6148c2ecf20Sopenharmony_ci
6158c2ecf20Sopenharmony_ci#define	SCR_LOAD_REG(reg,data) \
6168c2ecf20Sopenharmony_ci	SCR_REG_REG(reg,SCR_LOAD,data)
6178c2ecf20Sopenharmony_ci
6188c2ecf20Sopenharmony_ci#define SCR_LOAD_SFBR(data) \
6198c2ecf20Sopenharmony_ci        (SCR_REG_SFBR (gpreg, SCR_LOAD, data))
6208c2ecf20Sopenharmony_ci
6218c2ecf20Sopenharmony_ci/*-----------------------------------------------------------
6228c2ecf20Sopenharmony_ci *
6238c2ecf20Sopenharmony_ci *	LOAD  from memory   to register.
6248c2ecf20Sopenharmony_ci *	STORE from register to memory.
6258c2ecf20Sopenharmony_ci *
6268c2ecf20Sopenharmony_ci *	Only supported by 810A, 860, 825A, 875, 895 and 896.
6278c2ecf20Sopenharmony_ci *
6288c2ecf20Sopenharmony_ci *-----------------------------------------------------------
6298c2ecf20Sopenharmony_ci *
6308c2ecf20Sopenharmony_ci *	LOAD_ABS (LEN)
6318c2ecf20Sopenharmony_ci *	<<start address>>
6328c2ecf20Sopenharmony_ci *
6338c2ecf20Sopenharmony_ci *	LOAD_REL (LEN)        (DSA relative)
6348c2ecf20Sopenharmony_ci *	<<dsa_offset>>
6358c2ecf20Sopenharmony_ci *
6368c2ecf20Sopenharmony_ci *-----------------------------------------------------------
6378c2ecf20Sopenharmony_ci */
6388c2ecf20Sopenharmony_ci
6398c2ecf20Sopenharmony_ci#define SCR_REG_OFS2(ofs) (((ofs) & 0xff) << 16ul)
6408c2ecf20Sopenharmony_ci#define SCR_NO_FLUSH2	0x02000000
6418c2ecf20Sopenharmony_ci#define SCR_DSA_REL2	0x10000000
6428c2ecf20Sopenharmony_ci
6438c2ecf20Sopenharmony_ci#define SCR_LOAD_R(reg, how, n) \
6448c2ecf20Sopenharmony_ci        (0xe1000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
6458c2ecf20Sopenharmony_ci
6468c2ecf20Sopenharmony_ci#define SCR_STORE_R(reg, how, n) \
6478c2ecf20Sopenharmony_ci        (0xe0000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
6488c2ecf20Sopenharmony_ci
6498c2ecf20Sopenharmony_ci#define SCR_LOAD_ABS(reg, n)	SCR_LOAD_R(reg, SCR_NO_FLUSH2, n)
6508c2ecf20Sopenharmony_ci#define SCR_LOAD_REL(reg, n)	SCR_LOAD_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2, n)
6518c2ecf20Sopenharmony_ci#define SCR_LOAD_ABS_F(reg, n)	SCR_LOAD_R(reg, 0, n)
6528c2ecf20Sopenharmony_ci#define SCR_LOAD_REL_F(reg, n)	SCR_LOAD_R(reg, SCR_DSA_REL2, n)
6538c2ecf20Sopenharmony_ci
6548c2ecf20Sopenharmony_ci#define SCR_STORE_ABS(reg, n)	SCR_STORE_R(reg, SCR_NO_FLUSH2, n)
6558c2ecf20Sopenharmony_ci#define SCR_STORE_REL(reg, n)	SCR_STORE_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2,n)
6568c2ecf20Sopenharmony_ci#define SCR_STORE_ABS_F(reg, n)	SCR_STORE_R(reg, 0, n)
6578c2ecf20Sopenharmony_ci#define SCR_STORE_REL_F(reg, n)	SCR_STORE_R(reg, SCR_DSA_REL2, n)
6588c2ecf20Sopenharmony_ci
6598c2ecf20Sopenharmony_ci
6608c2ecf20Sopenharmony_ci/*-----------------------------------------------------------
6618c2ecf20Sopenharmony_ci *
6628c2ecf20Sopenharmony_ci *	Waiting for Disconnect or Reselect
6638c2ecf20Sopenharmony_ci *
6648c2ecf20Sopenharmony_ci *-----------------------------------------------------------
6658c2ecf20Sopenharmony_ci *
6668c2ecf20Sopenharmony_ci *	JUMP            [ | IFTRUE/IFFALSE ( ... ) ]
6678c2ecf20Sopenharmony_ci *	<<address>>
6688c2ecf20Sopenharmony_ci *
6698c2ecf20Sopenharmony_ci *	JUMPR           [ | IFTRUE/IFFALSE ( ... ) ]
6708c2ecf20Sopenharmony_ci *	<<distance>>
6718c2ecf20Sopenharmony_ci *
6728c2ecf20Sopenharmony_ci *	CALL            [ | IFTRUE/IFFALSE ( ... ) ]
6738c2ecf20Sopenharmony_ci *	<<address>>
6748c2ecf20Sopenharmony_ci *
6758c2ecf20Sopenharmony_ci *	CALLR           [ | IFTRUE/IFFALSE ( ... ) ]
6768c2ecf20Sopenharmony_ci *	<<distance>>
6778c2ecf20Sopenharmony_ci *
6788c2ecf20Sopenharmony_ci *	RETURN          [ | IFTRUE/IFFALSE ( ... ) ]
6798c2ecf20Sopenharmony_ci *	<<dummy>>
6808c2ecf20Sopenharmony_ci *
6818c2ecf20Sopenharmony_ci *	INT             [ | IFTRUE/IFFALSE ( ... ) ]
6828c2ecf20Sopenharmony_ci *	<<ident>>
6838c2ecf20Sopenharmony_ci *
6848c2ecf20Sopenharmony_ci *	INT_FLY         [ | IFTRUE/IFFALSE ( ... ) ]
6858c2ecf20Sopenharmony_ci *	<<ident>>
6868c2ecf20Sopenharmony_ci *
6878c2ecf20Sopenharmony_ci *	Conditions:
6888c2ecf20Sopenharmony_ci *	     WHEN (phase)
6898c2ecf20Sopenharmony_ci *	     IF   (phase)
6908c2ecf20Sopenharmony_ci *	     CARRYSET
6918c2ecf20Sopenharmony_ci *	     DATA (data, mask)
6928c2ecf20Sopenharmony_ci *
6938c2ecf20Sopenharmony_ci *-----------------------------------------------------------
6948c2ecf20Sopenharmony_ci */
6958c2ecf20Sopenharmony_ci
6968c2ecf20Sopenharmony_ci#define SCR_NO_OP       0x80000000
6978c2ecf20Sopenharmony_ci#define SCR_JUMP        0x80080000
6988c2ecf20Sopenharmony_ci#define SCR_JUMP64      0x80480000
6998c2ecf20Sopenharmony_ci#define SCR_JUMPR       0x80880000
7008c2ecf20Sopenharmony_ci#define SCR_CALL        0x88080000
7018c2ecf20Sopenharmony_ci#define SCR_CALLR       0x88880000
7028c2ecf20Sopenharmony_ci#define SCR_RETURN      0x90080000
7038c2ecf20Sopenharmony_ci#define SCR_INT         0x98080000
7048c2ecf20Sopenharmony_ci#define SCR_INT_FLY     0x98180000
7058c2ecf20Sopenharmony_ci
7068c2ecf20Sopenharmony_ci#define IFFALSE(arg)   (0x00080000 | (arg))
7078c2ecf20Sopenharmony_ci#define IFTRUE(arg)    (0x00000000 | (arg))
7088c2ecf20Sopenharmony_ci
7098c2ecf20Sopenharmony_ci#define WHEN(phase)    (0x00030000 | (phase))
7108c2ecf20Sopenharmony_ci#define IF(phase)      (0x00020000 | (phase))
7118c2ecf20Sopenharmony_ci
7128c2ecf20Sopenharmony_ci#define DATA(D)        (0x00040000 | ((D) & 0xff))
7138c2ecf20Sopenharmony_ci#define MASK(D,M)      (0x00040000 | (((M ^ 0xff) & 0xff) << 8ul)|((D) & 0xff))
7148c2ecf20Sopenharmony_ci
7158c2ecf20Sopenharmony_ci#define CARRYSET       (0x00200000)
7168c2ecf20Sopenharmony_ci
7178c2ecf20Sopenharmony_ci/*-----------------------------------------------------------
7188c2ecf20Sopenharmony_ci *
7198c2ecf20Sopenharmony_ci *	SCSI  constants.
7208c2ecf20Sopenharmony_ci *
7218c2ecf20Sopenharmony_ci *-----------------------------------------------------------
7228c2ecf20Sopenharmony_ci */
7238c2ecf20Sopenharmony_ci
7248c2ecf20Sopenharmony_ci/*
7258c2ecf20Sopenharmony_ci *	Messages
7268c2ecf20Sopenharmony_ci */
7278c2ecf20Sopenharmony_ci
7288c2ecf20Sopenharmony_ci#define	M_COMPLETE	COMMAND_COMPLETE
7298c2ecf20Sopenharmony_ci#define	M_EXTENDED	EXTENDED_MESSAGE
7308c2ecf20Sopenharmony_ci#define	M_SAVE_DP	SAVE_POINTERS
7318c2ecf20Sopenharmony_ci#define	M_RESTORE_DP	RESTORE_POINTERS
7328c2ecf20Sopenharmony_ci#define	M_DISCONNECT	DISCONNECT
7338c2ecf20Sopenharmony_ci#define	M_ID_ERROR	INITIATOR_ERROR
7348c2ecf20Sopenharmony_ci#define	M_ABORT		ABORT_TASK_SET
7358c2ecf20Sopenharmony_ci#define	M_REJECT	MESSAGE_REJECT
7368c2ecf20Sopenharmony_ci#define	M_NOOP		NOP
7378c2ecf20Sopenharmony_ci#define	M_PARITY	MSG_PARITY_ERROR
7388c2ecf20Sopenharmony_ci#define	M_LCOMPLETE	LINKED_CMD_COMPLETE
7398c2ecf20Sopenharmony_ci#define	M_FCOMPLETE	LINKED_FLG_CMD_COMPLETE
7408c2ecf20Sopenharmony_ci#define	M_RESET		TARGET_RESET
7418c2ecf20Sopenharmony_ci#define	M_ABORT_TAG	ABORT_TASK
7428c2ecf20Sopenharmony_ci#define	M_CLEAR_QUEUE	CLEAR_TASK_SET
7438c2ecf20Sopenharmony_ci#define	M_INIT_REC	INITIATE_RECOVERY
7448c2ecf20Sopenharmony_ci#define	M_REL_REC	RELEASE_RECOVERY
7458c2ecf20Sopenharmony_ci#define	M_TERMINATE	(0x11)
7468c2ecf20Sopenharmony_ci#define	M_SIMPLE_TAG	SIMPLE_QUEUE_TAG
7478c2ecf20Sopenharmony_ci#define	M_HEAD_TAG	HEAD_OF_QUEUE_TAG
7488c2ecf20Sopenharmony_ci#define	M_ORDERED_TAG	ORDERED_QUEUE_TAG
7498c2ecf20Sopenharmony_ci#define	M_IGN_RESIDUE	IGNORE_WIDE_RESIDUE
7508c2ecf20Sopenharmony_ci
7518c2ecf20Sopenharmony_ci#define	M_X_MODIFY_DP	EXTENDED_MODIFY_DATA_POINTER
7528c2ecf20Sopenharmony_ci#define	M_X_SYNC_REQ	EXTENDED_SDTR
7538c2ecf20Sopenharmony_ci#define	M_X_WIDE_REQ	EXTENDED_WDTR
7548c2ecf20Sopenharmony_ci#define	M_X_PPR_REQ	EXTENDED_PPR
7558c2ecf20Sopenharmony_ci
7568c2ecf20Sopenharmony_ci/*
7578c2ecf20Sopenharmony_ci *	PPR protocol options
7588c2ecf20Sopenharmony_ci */
7598c2ecf20Sopenharmony_ci#define	PPR_OPT_IU	(0x01)
7608c2ecf20Sopenharmony_ci#define	PPR_OPT_DT	(0x02)
7618c2ecf20Sopenharmony_ci#define	PPR_OPT_QAS	(0x04)
7628c2ecf20Sopenharmony_ci#define PPR_OPT_MASK	(0x07)
7638c2ecf20Sopenharmony_ci
7648c2ecf20Sopenharmony_ci/*
7658c2ecf20Sopenharmony_ci *	Status
7668c2ecf20Sopenharmony_ci */
7678c2ecf20Sopenharmony_ci
7688c2ecf20Sopenharmony_ci#define	S_GOOD		SAM_STAT_GOOD
7698c2ecf20Sopenharmony_ci#define	S_CHECK_COND	SAM_STAT_CHECK_CONDITION
7708c2ecf20Sopenharmony_ci#define	S_COND_MET	SAM_STAT_CONDITION_MET
7718c2ecf20Sopenharmony_ci#define	S_BUSY		SAM_STAT_BUSY
7728c2ecf20Sopenharmony_ci#define	S_INT		SAM_STAT_INTERMEDIATE
7738c2ecf20Sopenharmony_ci#define	S_INT_COND_MET	SAM_STAT_INTERMEDIATE_CONDITION_MET
7748c2ecf20Sopenharmony_ci#define	S_CONFLICT	SAM_STAT_RESERVATION_CONFLICT
7758c2ecf20Sopenharmony_ci#define	S_TERMINATED	SAM_STAT_COMMAND_TERMINATED
7768c2ecf20Sopenharmony_ci#define	S_QUEUE_FULL	SAM_STAT_TASK_SET_FULL
7778c2ecf20Sopenharmony_ci#define	S_ILLEGAL	(0xff)
7788c2ecf20Sopenharmony_ci
7798c2ecf20Sopenharmony_ci#endif /* defined SYM_DEFS_H */
780