xref: /openbmc/linux/drivers/scsi/initio.h (revision 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2)
1*1da177e4SLinus Torvalds /**************************************************************************
2*1da177e4SLinus Torvalds  * Initio 9100 device driver for Linux.
3*1da177e4SLinus Torvalds  *
4*1da177e4SLinus Torvalds  * Copyright (c) 1994-1998 Initio Corporation
5*1da177e4SLinus Torvalds  * All rights reserved.
6*1da177e4SLinus Torvalds  *
7*1da177e4SLinus Torvalds  * This program is free software; you can redistribute it and/or modify
8*1da177e4SLinus Torvalds  * it under the terms of the GNU General Public License as published by
9*1da177e4SLinus Torvalds  * the Free Software Foundation; either version 2, or (at your option)
10*1da177e4SLinus Torvalds  * any later version.
11*1da177e4SLinus Torvalds  *
12*1da177e4SLinus Torvalds  * This program is distributed in the hope that it will be useful,
13*1da177e4SLinus Torvalds  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14*1da177e4SLinus Torvalds  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*1da177e4SLinus Torvalds  * GNU General Public License for more details.
16*1da177e4SLinus Torvalds  *
17*1da177e4SLinus Torvalds  * You should have received a copy of the GNU General Public License
18*1da177e4SLinus Torvalds  * along with this program; see the file COPYING.  If not, write to
19*1da177e4SLinus Torvalds  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20*1da177e4SLinus Torvalds  *
21*1da177e4SLinus Torvalds  * --------------------------------------------------------------------------
22*1da177e4SLinus Torvalds  *
23*1da177e4SLinus Torvalds  * Redistribution and use in source and binary forms, with or without
24*1da177e4SLinus Torvalds  * modification, are permitted provided that the following conditions
25*1da177e4SLinus Torvalds  * are met:
26*1da177e4SLinus Torvalds  * 1. Redistributions of source code must retain the above copyright
27*1da177e4SLinus Torvalds  *    notice, this list of conditions, and the following disclaimer,
28*1da177e4SLinus Torvalds  *    without modification, immediately at the beginning of the file.
29*1da177e4SLinus Torvalds  * 2. Redistributions in binary form must reproduce the above copyright
30*1da177e4SLinus Torvalds  *    notice, this list of conditions and the following disclaimer in the
31*1da177e4SLinus Torvalds  *    documentation and/or other materials provided with the distribution.
32*1da177e4SLinus Torvalds  * 3. The name of the author may not be used to endorse or promote products
33*1da177e4SLinus Torvalds  *    derived from this software without specific prior written permission.
34*1da177e4SLinus Torvalds  *
35*1da177e4SLinus Torvalds  * Where this Software is combined with software released under the terms of
36*1da177e4SLinus Torvalds  * the GNU General Public License ("GPL") and the terms of the GPL would require the
37*1da177e4SLinus Torvalds  * combined work to also be released under the terms of the GPL, the terms
38*1da177e4SLinus Torvalds  * and conditions of this License will apply in addition to those of the
39*1da177e4SLinus Torvalds  * GPL with the exception of any terms or conditions of this License that
40*1da177e4SLinus Torvalds  * conflict with, or are expressly prohibited by, the GPL.
41*1da177e4SLinus Torvalds  *
42*1da177e4SLinus Torvalds  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
43*1da177e4SLinus Torvalds  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44*1da177e4SLinus Torvalds  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45*1da177e4SLinus Torvalds  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
46*1da177e4SLinus Torvalds  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47*1da177e4SLinus Torvalds  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
48*1da177e4SLinus Torvalds  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49*1da177e4SLinus Torvalds  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
50*1da177e4SLinus Torvalds  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
51*1da177e4SLinus Torvalds  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52*1da177e4SLinus Torvalds  * SUCH DAMAGE.
53*1da177e4SLinus Torvalds  *
54*1da177e4SLinus Torvalds  **************************************************************************/
55*1da177e4SLinus Torvalds 
56*1da177e4SLinus Torvalds 
57*1da177e4SLinus Torvalds #include <linux/config.h>
58*1da177e4SLinus Torvalds #include <linux/types.h>
59*1da177e4SLinus Torvalds 
60*1da177e4SLinus Torvalds #define ULONG   unsigned long
61*1da177e4SLinus Torvalds #define USHORT  unsigned short
62*1da177e4SLinus Torvalds #define UCHAR   unsigned char
63*1da177e4SLinus Torvalds #define BYTE    unsigned char
64*1da177e4SLinus Torvalds #define WORD    unsigned short
65*1da177e4SLinus Torvalds #define DWORD   unsigned long
66*1da177e4SLinus Torvalds #define UBYTE   unsigned char
67*1da177e4SLinus Torvalds #define UWORD   unsigned short
68*1da177e4SLinus Torvalds #define UDWORD  unsigned long
69*1da177e4SLinus Torvalds #define U32     u32
70*1da177e4SLinus Torvalds 
71*1da177e4SLinus Torvalds #define TOTAL_SG_ENTRY		32
72*1da177e4SLinus Torvalds #define MAX_SUPPORTED_ADAPTERS  8
73*1da177e4SLinus Torvalds #define MAX_OFFSET		15
74*1da177e4SLinus Torvalds #define MAX_TARGETS		16
75*1da177e4SLinus Torvalds 
76*1da177e4SLinus Torvalds typedef struct {
77*1da177e4SLinus Torvalds 	unsigned short base;
78*1da177e4SLinus Torvalds 	unsigned short vec;
79*1da177e4SLinus Torvalds } i91u_config;
80*1da177e4SLinus Torvalds 
81*1da177e4SLinus Torvalds /***************************************/
82*1da177e4SLinus Torvalds /*  Tulip Configuration Register Set */
83*1da177e4SLinus Torvalds /***************************************/
84*1da177e4SLinus Torvalds #define TUL_PVID        0x00	/* Vendor ID                    */
85*1da177e4SLinus Torvalds #define TUL_PDID        0x02	/* Device ID                    */
86*1da177e4SLinus Torvalds #define TUL_PCMD        0x04	/* Command                      */
87*1da177e4SLinus Torvalds #define TUL_PSTUS       0x06	/* Status                       */
88*1da177e4SLinus Torvalds #define TUL_PRID        0x08	/* Revision number              */
89*1da177e4SLinus Torvalds #define TUL_PPI         0x09	/* Programming interface        */
90*1da177e4SLinus Torvalds #define TUL_PSC         0x0A	/* Sub Class                    */
91*1da177e4SLinus Torvalds #define TUL_PBC         0x0B	/* Base Class                   */
92*1da177e4SLinus Torvalds #define TUL_PCLS        0x0C	/* Cache line size              */
93*1da177e4SLinus Torvalds #define TUL_PLTR        0x0D	/* Latency timer                */
94*1da177e4SLinus Torvalds #define TUL_PHDT        0x0E	/* Header type                  */
95*1da177e4SLinus Torvalds #define TUL_PBIST       0x0F	/* BIST                         */
96*1da177e4SLinus Torvalds #define TUL_PBAD        0x10	/* Base address                 */
97*1da177e4SLinus Torvalds #define TUL_PBAD1       0x14	/* Base address                 */
98*1da177e4SLinus Torvalds #define TUL_PBAD2       0x18	/* Base address                 */
99*1da177e4SLinus Torvalds #define TUL_PBAD3       0x1C	/* Base address                 */
100*1da177e4SLinus Torvalds #define TUL_PBAD4       0x20	/* Base address                 */
101*1da177e4SLinus Torvalds #define TUL_PBAD5       0x24	/* Base address                 */
102*1da177e4SLinus Torvalds #define TUL_PRSVD       0x28	/* Reserved                     */
103*1da177e4SLinus Torvalds #define TUL_PRSVD1      0x2C	/* Reserved                     */
104*1da177e4SLinus Torvalds #define TUL_PRAD        0x30	/* Expansion ROM base address   */
105*1da177e4SLinus Torvalds #define TUL_PRSVD2      0x34	/* Reserved                     */
106*1da177e4SLinus Torvalds #define TUL_PRSVD3      0x38	/* Reserved                     */
107*1da177e4SLinus Torvalds #define TUL_PINTL       0x3C	/* Interrupt line               */
108*1da177e4SLinus Torvalds #define TUL_PINTP       0x3D	/* Interrupt pin                */
109*1da177e4SLinus Torvalds #define TUL_PIGNT       0x3E	/* MIN_GNT                      */
110*1da177e4SLinus Torvalds #define TUL_PMGNT       0x3F	/* MAX_GNT                      */
111*1da177e4SLinus Torvalds 
112*1da177e4SLinus Torvalds /************************/
113*1da177e4SLinus Torvalds /*  Jasmin Register Set */
114*1da177e4SLinus Torvalds /************************/
115*1da177e4SLinus Torvalds #define TUL_HACFG0      0x40	/* H/A Configuration Register 0         */
116*1da177e4SLinus Torvalds #define TUL_HACFG1      0x41	/* H/A Configuration Register 1         */
117*1da177e4SLinus Torvalds #define TUL_HACFG2      0x42	/* H/A Configuration Register 2         */
118*1da177e4SLinus Torvalds 
119*1da177e4SLinus Torvalds #define TUL_SDCFG0      0x44	/* SCSI Device Configuration 0          */
120*1da177e4SLinus Torvalds #define TUL_SDCFG1      0x45	/* SCSI Device Configuration 1          */
121*1da177e4SLinus Torvalds #define TUL_SDCFG2      0x46	/* SCSI Device Configuration 2          */
122*1da177e4SLinus Torvalds #define TUL_SDCFG3      0x47	/* SCSI Device Configuration 3          */
123*1da177e4SLinus Torvalds 
124*1da177e4SLinus Torvalds #define TUL_GINTS       0x50	/* Global Interrupt Status Register     */
125*1da177e4SLinus Torvalds #define TUL_GIMSK       0x52	/* Global Interrupt MASK Register       */
126*1da177e4SLinus Torvalds #define TUL_GCTRL       0x54	/* Global Control Register              */
127*1da177e4SLinus Torvalds #define TUL_GCTRL_EEPROM_BIT    0x04
128*1da177e4SLinus Torvalds #define TUL_GCTRL1      0x55	/* Global Control Register              */
129*1da177e4SLinus Torvalds #define TUL_DMACFG      0x5B	/* DMA configuration                    */
130*1da177e4SLinus Torvalds #define TUL_NVRAM       0x5D	/* Non-volatile RAM port                */
131*1da177e4SLinus Torvalds 
132*1da177e4SLinus Torvalds #define TUL_SCnt0       0x80	/* 00 R/W Transfer Counter Low          */
133*1da177e4SLinus Torvalds #define TUL_SCnt1       0x81	/* 01 R/W Transfer Counter Mid          */
134*1da177e4SLinus Torvalds #define TUL_SCnt2       0x82	/* 02 R/W Transfer Count High           */
135*1da177e4SLinus Torvalds #define TUL_SFifoCnt    0x83	/* 03 R   FIFO counter                  */
136*1da177e4SLinus Torvalds #define TUL_SIntEnable  0x84	/* 03 W   Interrupt enble               */
137*1da177e4SLinus Torvalds #define TUL_SInt        0x84	/* 04 R   Interrupt Register            */
138*1da177e4SLinus Torvalds #define TUL_SCtrl0      0x85	/* 05 W   Control 0                     */
139*1da177e4SLinus Torvalds #define TUL_SStatus0    0x85	/* 05 R   Status 0                      */
140*1da177e4SLinus Torvalds #define TUL_SCtrl1      0x86	/* 06 W   Control 1                     */
141*1da177e4SLinus Torvalds #define TUL_SStatus1    0x86	/* 06 R   Status 1                      */
142*1da177e4SLinus Torvalds #define TUL_SConfig     0x87	/* 07 W   Configuration                 */
143*1da177e4SLinus Torvalds #define TUL_SStatus2    0x87	/* 07 R   Status 2                      */
144*1da177e4SLinus Torvalds #define TUL_SPeriod     0x88	/* 08 W   Sync. Transfer Period & Offset */
145*1da177e4SLinus Torvalds #define TUL_SOffset     0x88	/* 08 R   Offset                        */
146*1da177e4SLinus Torvalds #define TUL_SScsiId     0x89	/* 09 W   SCSI ID                       */
147*1da177e4SLinus Torvalds #define TUL_SBusId      0x89	/* 09 R   SCSI BUS ID                   */
148*1da177e4SLinus Torvalds #define TUL_STimeOut    0x8A	/* 0A W   Sel/Resel Time Out Register   */
149*1da177e4SLinus Torvalds #define TUL_SIdent      0x8A	/* 0A R   Identify Message Register     */
150*1da177e4SLinus Torvalds #define TUL_SAvail      0x8A	/* 0A R   Availiable Counter Register   */
151*1da177e4SLinus Torvalds #define TUL_SData       0x8B	/* 0B R/W SCSI data in/out              */
152*1da177e4SLinus Torvalds #define TUL_SFifo       0x8C	/* 0C R/W FIFO                          */
153*1da177e4SLinus Torvalds #define TUL_SSignal     0x90	/* 10 R/W SCSI signal in/out            */
154*1da177e4SLinus Torvalds #define TUL_SCmd        0x91	/* 11 R/W Command                       */
155*1da177e4SLinus Torvalds #define TUL_STest0      0x92	/* 12 R/W Test0                         */
156*1da177e4SLinus Torvalds #define TUL_STest1      0x93	/* 13 R/W Test1                         */
157*1da177e4SLinus Torvalds #define TUL_SCFG1	0x94	/* 14 R/W Configuration                 */
158*1da177e4SLinus Torvalds 
159*1da177e4SLinus Torvalds #define TUL_XAddH       0xC0	/*DMA Transfer Physical Address         */
160*1da177e4SLinus Torvalds #define TUL_XAddW       0xC8	/*DMA Current Transfer Physical Address */
161*1da177e4SLinus Torvalds #define TUL_XCntH       0xD0	/*DMA Transfer Counter                  */
162*1da177e4SLinus Torvalds #define TUL_XCntW       0xD4	/*DMA Current Transfer Counter          */
163*1da177e4SLinus Torvalds #define TUL_XCmd        0xD8	/*DMA Command Register                  */
164*1da177e4SLinus Torvalds #define TUL_Int         0xDC	/*Interrupt Register                    */
165*1da177e4SLinus Torvalds #define TUL_XStatus     0xDD	/*DMA status Register                   */
166*1da177e4SLinus Torvalds #define TUL_Mask        0xE0	/*Interrupt Mask Register               */
167*1da177e4SLinus Torvalds #define TUL_XCtrl       0xE4	/*DMA Control Register                  */
168*1da177e4SLinus Torvalds #define TUL_XCtrl1      0xE5	/*DMA Control Register 1                */
169*1da177e4SLinus Torvalds #define TUL_XFifo       0xE8	/*DMA FIFO                              */
170*1da177e4SLinus Torvalds 
171*1da177e4SLinus Torvalds #define TUL_WCtrl       0xF7	/*Bus master wait state control         */
172*1da177e4SLinus Torvalds #define TUL_DCtrl       0xFB	/*DMA delay control                     */
173*1da177e4SLinus Torvalds 
174*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
175*1da177e4SLinus Torvalds /*   bit definition for Command register of Configuration Space Header  */
176*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
177*1da177e4SLinus Torvalds #define BUSMS           0x04	/* BUS MASTER Enable                    */
178*1da177e4SLinus Torvalds #define IOSPA           0x01	/* IO Space Enable                      */
179*1da177e4SLinus Torvalds 
180*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
181*1da177e4SLinus Torvalds /* Command Codes of Tulip SCSI Command register                         */
182*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
183*1da177e4SLinus Torvalds #define TSC_EN_RESEL    0x80	/* Enable Reselection                   */
184*1da177e4SLinus Torvalds #define TSC_CMD_COMP    0x84	/* Command Complete Sequence            */
185*1da177e4SLinus Torvalds #define TSC_SEL         0x01	/* Select Without ATN Sequence          */
186*1da177e4SLinus Torvalds #define TSC_SEL_ATN     0x11	/* Select With ATN Sequence             */
187*1da177e4SLinus Torvalds #define TSC_SEL_ATN_DMA 0x51	/* Select With ATN Sequence with DMA    */
188*1da177e4SLinus Torvalds #define TSC_SEL_ATN3    0x31	/* Select With ATN3 Sequence            */
189*1da177e4SLinus Torvalds #define TSC_SEL_ATNSTOP 0x12	/* Select With ATN and Stop Sequence    */
190*1da177e4SLinus Torvalds #define TSC_SELATNSTOP  0x1E	/* Select With ATN and Stop Sequence    */
191*1da177e4SLinus Torvalds 
192*1da177e4SLinus Torvalds #define TSC_SEL_ATN_DIRECT_IN   0x95	/* Select With ATN Sequence     */
193*1da177e4SLinus Torvalds #define TSC_SEL_ATN_DIRECT_OUT  0x15	/* Select With ATN Sequence     */
194*1da177e4SLinus Torvalds #define TSC_SEL_ATN3_DIRECT_IN  0xB5	/* Select With ATN3 Sequence    */
195*1da177e4SLinus Torvalds #define TSC_SEL_ATN3_DIRECT_OUT 0x35	/* Select With ATN3 Sequence    */
196*1da177e4SLinus Torvalds #define TSC_XF_DMA_OUT_DIRECT   0x06	/* DMA Xfer Infomation out      */
197*1da177e4SLinus Torvalds #define TSC_XF_DMA_IN_DIRECT    0x86	/* DMA Xfer Infomation in       */
198*1da177e4SLinus Torvalds 
199*1da177e4SLinus Torvalds #define TSC_XF_DMA_OUT  0x43	/* DMA Xfer Infomation out              */
200*1da177e4SLinus Torvalds #define TSC_XF_DMA_IN   0xC3	/* DMA Xfer Infomation in               */
201*1da177e4SLinus Torvalds #define TSC_XF_FIFO_OUT 0x03	/* FIFO Xfer Infomation out             */
202*1da177e4SLinus Torvalds #define TSC_XF_FIFO_IN  0x83	/* FIFO Xfer Infomation in              */
203*1da177e4SLinus Torvalds 
204*1da177e4SLinus Torvalds #define TSC_MSG_ACCEPT  0x0F	/* Message Accept                       */
205*1da177e4SLinus Torvalds 
206*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
207*1da177e4SLinus Torvalds /* bit definition for Tulip SCSI Control 0 Register                     */
208*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
209*1da177e4SLinus Torvalds #define TSC_RST_SEQ     0x20	/* Reset sequence counter               */
210*1da177e4SLinus Torvalds #define TSC_FLUSH_FIFO  0x10	/* Flush FIFO                           */
211*1da177e4SLinus Torvalds #define TSC_ABT_CMD     0x04	/* Abort command (sequence)             */
212*1da177e4SLinus Torvalds #define TSC_RST_CHIP    0x02	/* Reset SCSI Chip                      */
213*1da177e4SLinus Torvalds #define TSC_RST_BUS     0x01	/* Reset SCSI Bus                       */
214*1da177e4SLinus Torvalds 
215*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
216*1da177e4SLinus Torvalds /* bit definition for Tulip SCSI Control 1 Register                     */
217*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
218*1da177e4SLinus Torvalds #define TSC_EN_SCAM     0x80	/* Enable SCAM                          */
219*1da177e4SLinus Torvalds #define TSC_TIMER       0x40	/* Select timeout unit                  */
220*1da177e4SLinus Torvalds #define TSC_EN_SCSI2    0x20	/* SCSI-2 mode                          */
221*1da177e4SLinus Torvalds #define TSC_PWDN        0x10	/* Power down mode                      */
222*1da177e4SLinus Torvalds #define TSC_WIDE_CPU    0x08	/* Wide CPU                             */
223*1da177e4SLinus Torvalds #define TSC_HW_RESELECT 0x04	/* Enable HW reselect                   */
224*1da177e4SLinus Torvalds #define TSC_EN_BUS_OUT  0x02	/* Enable SCSI data bus out latch       */
225*1da177e4SLinus Torvalds #define TSC_EN_BUS_IN   0x01	/* Enable SCSI data bus in latch        */
226*1da177e4SLinus Torvalds 
227*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
228*1da177e4SLinus Torvalds /* bit definition for Tulip SCSI Configuration Register                 */
229*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
230*1da177e4SLinus Torvalds #define TSC_EN_LATCH    0x80	/* Enable phase latch                   */
231*1da177e4SLinus Torvalds #define TSC_INITIATOR   0x40	/* Initiator mode                       */
232*1da177e4SLinus Torvalds #define TSC_EN_SCSI_PAR 0x20	/* Enable SCSI parity                   */
233*1da177e4SLinus Torvalds #define TSC_DMA_8BIT    0x10	/* Alternate dma 8-bits mode            */
234*1da177e4SLinus Torvalds #define TSC_DMA_16BIT   0x08	/* Alternate dma 16-bits mode           */
235*1da177e4SLinus Torvalds #define TSC_EN_WDACK    0x04	/* Enable DACK while wide SCSI xfer     */
236*1da177e4SLinus Torvalds #define TSC_ALT_PERIOD  0x02	/* Alternate sync period mode           */
237*1da177e4SLinus Torvalds #define TSC_DIS_SCSIRST 0x01	/* Disable SCSI bus reset us            */
238*1da177e4SLinus Torvalds 
239*1da177e4SLinus Torvalds #define TSC_INITDEFAULT (TSC_INITIATOR | TSC_EN_LATCH | TSC_ALT_PERIOD | TSC_DIS_SCSIRST)
240*1da177e4SLinus Torvalds 
241*1da177e4SLinus Torvalds #define TSC_WIDE_SCSI   0x80	/* Enable Wide SCSI                     */
242*1da177e4SLinus Torvalds 
243*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
244*1da177e4SLinus Torvalds /* bit definition for Tulip SCSI signal Register                        */
245*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
246*1da177e4SLinus Torvalds #define TSC_RST_ACK     0x00	/* Release ACK signal                   */
247*1da177e4SLinus Torvalds #define TSC_RST_ATN     0x00	/* Release ATN signal                   */
248*1da177e4SLinus Torvalds #define TSC_RST_BSY     0x00	/* Release BSY signal                   */
249*1da177e4SLinus Torvalds 
250*1da177e4SLinus Torvalds #define TSC_SET_ACK     0x40	/* ACK signal                           */
251*1da177e4SLinus Torvalds #define TSC_SET_ATN     0x08	/* ATN signal                           */
252*1da177e4SLinus Torvalds 
253*1da177e4SLinus Torvalds #define TSC_REQI        0x80	/* REQ signal                           */
254*1da177e4SLinus Torvalds #define TSC_ACKI        0x40	/* ACK signal                           */
255*1da177e4SLinus Torvalds #define TSC_BSYI        0x20	/* BSY signal                           */
256*1da177e4SLinus Torvalds #define TSC_SELI        0x10	/* SEL signal                           */
257*1da177e4SLinus Torvalds #define TSC_ATNI        0x08	/* ATN signal                           */
258*1da177e4SLinus Torvalds #define TSC_MSGI        0x04	/* MSG signal                           */
259*1da177e4SLinus Torvalds #define TSC_CDI         0x02	/* C/D signal                           */
260*1da177e4SLinus Torvalds #define TSC_IOI         0x01	/* I/O signal                           */
261*1da177e4SLinus Torvalds 
262*1da177e4SLinus Torvalds 
263*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
264*1da177e4SLinus Torvalds /* bit definition for Tulip SCSI Status 0 Register                      */
265*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
266*1da177e4SLinus Torvalds #define TSS_INT_PENDING 0x80	/* Interrupt pending            */
267*1da177e4SLinus Torvalds #define TSS_SEQ_ACTIVE  0x40	/* Sequencer active             */
268*1da177e4SLinus Torvalds #define TSS_XFER_CNT    0x20	/* Transfer counter zero        */
269*1da177e4SLinus Torvalds #define TSS_FIFO_EMPTY  0x10	/* FIFO empty                   */
270*1da177e4SLinus Torvalds #define TSS_PAR_ERROR   0x08	/* SCSI parity error            */
271*1da177e4SLinus Torvalds #define TSS_PH_MASK     0x07	/* SCSI phase mask              */
272*1da177e4SLinus Torvalds 
273*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
274*1da177e4SLinus Torvalds /* bit definition for Tulip SCSI Status 1 Register                      */
275*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
276*1da177e4SLinus Torvalds #define TSS_STATUS_RCV  0x08	/* Status received              */
277*1da177e4SLinus Torvalds #define TSS_MSG_SEND    0x40	/* Message sent                 */
278*1da177e4SLinus Torvalds #define TSS_CMD_PH_CMP  0x20	/* command phase done              */
279*1da177e4SLinus Torvalds #define TSS_DATA_PH_CMP 0x10	/* Data phase done              */
280*1da177e4SLinus Torvalds #define TSS_STATUS_SEND 0x08	/* Status sent                  */
281*1da177e4SLinus Torvalds #define TSS_XFER_CMP    0x04	/* Transfer completed           */
282*1da177e4SLinus Torvalds #define TSS_SEL_CMP     0x02	/* Selection completed          */
283*1da177e4SLinus Torvalds #define TSS_ARB_CMP     0x01	/* Arbitration completed        */
284*1da177e4SLinus Torvalds 
285*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
286*1da177e4SLinus Torvalds /* bit definition for Tulip SCSI Status 2 Register                      */
287*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
288*1da177e4SLinus Torvalds #define TSS_CMD_ABTED   0x80	/* Command aborted              */
289*1da177e4SLinus Torvalds #define TSS_OFFSET_0    0x40	/* Offset counter zero          */
290*1da177e4SLinus Torvalds #define TSS_FIFO_FULL   0x20	/* FIFO full                    */
291*1da177e4SLinus Torvalds #define TSS_TIMEOUT_0   0x10	/* Timeout counter zero         */
292*1da177e4SLinus Torvalds #define TSS_BUSY_RLS    0x08	/* Busy release                 */
293*1da177e4SLinus Torvalds #define TSS_PH_MISMATCH 0x04	/* Phase mismatch               */
294*1da177e4SLinus Torvalds #define TSS_SCSI_BUS_EN 0x02	/* SCSI data bus enable         */
295*1da177e4SLinus Torvalds #define TSS_SCSIRST     0x01	/* SCSI bus reset in progress   */
296*1da177e4SLinus Torvalds 
297*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
298*1da177e4SLinus Torvalds /* bit definition for Tulip SCSI Interrupt Register                     */
299*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
300*1da177e4SLinus Torvalds #define TSS_RESEL_INT   0x80	/* Reselected interrupt         */
301*1da177e4SLinus Torvalds #define TSS_SEL_TIMEOUT 0x40	/* Selected/reselected timeout  */
302*1da177e4SLinus Torvalds #define TSS_BUS_SERV    0x20
303*1da177e4SLinus Torvalds #define TSS_SCSIRST_INT 0x10	/* SCSI bus reset detected      */
304*1da177e4SLinus Torvalds #define TSS_DISC_INT    0x08	/* Disconnected interrupt       */
305*1da177e4SLinus Torvalds #define TSS_SEL_INT     0x04	/* Select interrupt             */
306*1da177e4SLinus Torvalds #define TSS_SCAM_SEL    0x02	/* SCAM selected                */
307*1da177e4SLinus Torvalds #define TSS_FUNC_COMP   0x01
308*1da177e4SLinus Torvalds 
309*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
310*1da177e4SLinus Torvalds /* SCSI Phase Codes.                                                    */
311*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
312*1da177e4SLinus Torvalds #define DATA_OUT        0
313*1da177e4SLinus Torvalds #define DATA_IN         1	/* 4                            */
314*1da177e4SLinus Torvalds #define CMD_OUT         2
315*1da177e4SLinus Torvalds #define STATUS_IN       3	/* 6                            */
316*1da177e4SLinus Torvalds #define MSG_OUT         6	/* 3                            */
317*1da177e4SLinus Torvalds #define MSG_IN          7
318*1da177e4SLinus Torvalds 
319*1da177e4SLinus Torvalds 
320*1da177e4SLinus Torvalds 
321*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
322*1da177e4SLinus Torvalds /* Command Codes of Tulip xfer Command register                         */
323*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
324*1da177e4SLinus Torvalds #define TAX_X_FORC      0x02
325*1da177e4SLinus Torvalds #define TAX_X_ABT       0x04
326*1da177e4SLinus Torvalds #define TAX_X_CLR_FIFO  0x08
327*1da177e4SLinus Torvalds 
328*1da177e4SLinus Torvalds #define TAX_X_IN        0x21
329*1da177e4SLinus Torvalds #define TAX_X_OUT       0x01
330*1da177e4SLinus Torvalds #define TAX_SG_IN       0xA1
331*1da177e4SLinus Torvalds #define TAX_SG_OUT      0x81
332*1da177e4SLinus Torvalds 
333*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
334*1da177e4SLinus Torvalds /* Tulip Interrupt Register                                             */
335*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
336*1da177e4SLinus Torvalds #define XCMP            0x01
337*1da177e4SLinus Torvalds #define FCMP            0x02
338*1da177e4SLinus Torvalds #define XABT            0x04
339*1da177e4SLinus Torvalds #define XERR            0x08
340*1da177e4SLinus Torvalds #define SCMP            0x10
341*1da177e4SLinus Torvalds #define IPEND           0x80
342*1da177e4SLinus Torvalds 
343*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
344*1da177e4SLinus Torvalds /* Tulip DMA Status Register                                            */
345*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
346*1da177e4SLinus Torvalds #define XPEND           0x01	/* Transfer pending             */
347*1da177e4SLinus Torvalds #define FEMPTY          0x02	/* FIFO empty                   */
348*1da177e4SLinus Torvalds 
349*1da177e4SLinus Torvalds 
350*1da177e4SLinus Torvalds 
351*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
352*1da177e4SLinus Torvalds /* bit definition for TUL_GCTRL                                         */
353*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
354*1da177e4SLinus Torvalds #define EXTSG           0x80
355*1da177e4SLinus Torvalds #define EXTAD           0x60
356*1da177e4SLinus Torvalds #define SEG4K           0x08
357*1da177e4SLinus Torvalds #define EEPRG           0x04
358*1da177e4SLinus Torvalds #define MRMUL           0x02
359*1da177e4SLinus Torvalds 
360*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
361*1da177e4SLinus Torvalds /* bit definition for TUL_NVRAM                                         */
362*1da177e4SLinus Torvalds /*----------------------------------------------------------------------*/
363*1da177e4SLinus Torvalds #define SE2CS           0x08
364*1da177e4SLinus Torvalds #define SE2CLK          0x04
365*1da177e4SLinus Torvalds #define SE2DO           0x02
366*1da177e4SLinus Torvalds #define SE2DI           0x01
367*1da177e4SLinus Torvalds 
368*1da177e4SLinus Torvalds 
369*1da177e4SLinus Torvalds /************************************************************************/
370*1da177e4SLinus Torvalds /*              Scatter-Gather Element Structure                        */
371*1da177e4SLinus Torvalds /************************************************************************/
372*1da177e4SLinus Torvalds typedef struct SG_Struc {
373*1da177e4SLinus Torvalds 	U32 SG_Ptr;		/* Data Pointer */
374*1da177e4SLinus Torvalds 	U32 SG_Len;		/* Data Length */
375*1da177e4SLinus Torvalds } SG;
376*1da177e4SLinus Torvalds 
377*1da177e4SLinus Torvalds /***********************************************************************
378*1da177e4SLinus Torvalds 		SCSI Control Block
379*1da177e4SLinus Torvalds ************************************************************************/
380*1da177e4SLinus Torvalds typedef struct Scsi_Ctrl_Blk {
381*1da177e4SLinus Torvalds 	struct Scsi_Ctrl_Blk *SCB_NxtScb;
382*1da177e4SLinus Torvalds 	UBYTE SCB_Status;	/*4 */
383*1da177e4SLinus Torvalds 	UBYTE SCB_NxtStat;	/*5 */
384*1da177e4SLinus Torvalds 	UBYTE SCB_Mode;		/*6 */
385*1da177e4SLinus Torvalds 	UBYTE SCB_Msgin;	/*7 SCB_Res0 */
386*1da177e4SLinus Torvalds 	UWORD SCB_SGIdx;	/*8 */
387*1da177e4SLinus Torvalds 	UWORD SCB_SGMax;	/*A */
388*1da177e4SLinus Torvalds #ifdef ALPHA
389*1da177e4SLinus Torvalds 	U32 SCB_Reserved[2];	/*C */
390*1da177e4SLinus Torvalds #else
391*1da177e4SLinus Torvalds 	U32 SCB_Reserved[3];	/*C */
392*1da177e4SLinus Torvalds #endif
393*1da177e4SLinus Torvalds 
394*1da177e4SLinus Torvalds 	U32 SCB_XferLen;	/*18 Current xfer len           */
395*1da177e4SLinus Torvalds 	U32 SCB_TotXLen;	/*1C Total xfer len             */
396*1da177e4SLinus Torvalds 	U32 SCB_PAddr;		/*20 SCB phy. Addr. */
397*1da177e4SLinus Torvalds 
398*1da177e4SLinus Torvalds 	UBYTE SCB_Opcode;	/*24 SCB command code */
399*1da177e4SLinus Torvalds 	UBYTE SCB_Flags;	/*25 SCB Flags */
400*1da177e4SLinus Torvalds 	UBYTE SCB_Target;	/*26 Target Id */
401*1da177e4SLinus Torvalds 	UBYTE SCB_Lun;		/*27 Lun */
402*1da177e4SLinus Torvalds 	U32 SCB_BufPtr;		/*28 Data Buffer Pointer */
403*1da177e4SLinus Torvalds 	U32 SCB_BufLen;		/*2C Data Allocation Length */
404*1da177e4SLinus Torvalds 	UBYTE SCB_SGLen;	/*30 SG list # */
405*1da177e4SLinus Torvalds 	UBYTE SCB_SenseLen;	/*31 Sense Allocation Length */
406*1da177e4SLinus Torvalds 	UBYTE SCB_HaStat;	/*32 */
407*1da177e4SLinus Torvalds 	UBYTE SCB_TaStat;	/*33 */
408*1da177e4SLinus Torvalds 	UBYTE SCB_CDBLen;	/*34 CDB Length */
409*1da177e4SLinus Torvalds 	UBYTE SCB_Ident;	/*35 Identify */
410*1da177e4SLinus Torvalds 	UBYTE SCB_TagMsg;	/*36 Tag Message */
411*1da177e4SLinus Torvalds 	UBYTE SCB_TagId;	/*37 Queue Tag */
412*1da177e4SLinus Torvalds 	UBYTE SCB_CDB[12];	/*38 */
413*1da177e4SLinus Torvalds 	U32 SCB_SGPAddr;	/*44 SG List/Sense Buf phy. Addr. */
414*1da177e4SLinus Torvalds 	U32 SCB_SensePtr;	/*48 Sense data pointer */
415*1da177e4SLinus Torvalds 	void (*SCB_Post) (BYTE *, BYTE *);	/*4C POST routine */
416*1da177e4SLinus Torvalds 	struct scsi_cmnd *SCB_Srb;	/*50 SRB Pointer */
417*1da177e4SLinus Torvalds 	SG SCB_SGList[TOTAL_SG_ENTRY];	/*54 Start of SG list */
418*1da177e4SLinus Torvalds } SCB;
419*1da177e4SLinus Torvalds 
420*1da177e4SLinus Torvalds /* Bit Definition for SCB_Status */
421*1da177e4SLinus Torvalds #define SCB_RENT        0x01
422*1da177e4SLinus Torvalds #define SCB_PEND        0x02
423*1da177e4SLinus Torvalds #define SCB_CONTIG      0x04	/* Contigent Allegiance */
424*1da177e4SLinus Torvalds #define SCB_SELECT      0x08
425*1da177e4SLinus Torvalds #define SCB_BUSY        0x10
426*1da177e4SLinus Torvalds #define SCB_DONE        0x20
427*1da177e4SLinus Torvalds 
428*1da177e4SLinus Torvalds 
429*1da177e4SLinus Torvalds /* Opcodes of SCB_Opcode */
430*1da177e4SLinus Torvalds #define ExecSCSI        0x1
431*1da177e4SLinus Torvalds #define BusDevRst       0x2
432*1da177e4SLinus Torvalds #define AbortCmd        0x3
433*1da177e4SLinus Torvalds 
434*1da177e4SLinus Torvalds 
435*1da177e4SLinus Torvalds /* Bit Definition for SCB_Mode */
436*1da177e4SLinus Torvalds #define SCM_RSENS       0x01	/* request sense mode */
437*1da177e4SLinus Torvalds 
438*1da177e4SLinus Torvalds 
439*1da177e4SLinus Torvalds /* Bit Definition for SCB_Flags */
440*1da177e4SLinus Torvalds #define SCF_DONE        0x01
441*1da177e4SLinus Torvalds #define SCF_POST        0x02
442*1da177e4SLinus Torvalds #define SCF_SENSE       0x04
443*1da177e4SLinus Torvalds #define SCF_DIR         0x18
444*1da177e4SLinus Torvalds #define SCF_NO_DCHK     0x00
445*1da177e4SLinus Torvalds #define SCF_DIN         0x08
446*1da177e4SLinus Torvalds #define SCF_DOUT        0x10
447*1da177e4SLinus Torvalds #define SCF_NO_XF       0x18
448*1da177e4SLinus Torvalds #define SCF_WR_VF       0x20	/* Write verify turn on         */
449*1da177e4SLinus Torvalds #define SCF_POLL        0x40
450*1da177e4SLinus Torvalds #define SCF_SG          0x80
451*1da177e4SLinus Torvalds 
452*1da177e4SLinus Torvalds /* Error Codes for SCB_HaStat */
453*1da177e4SLinus Torvalds #define HOST_SEL_TOUT   0x11
454*1da177e4SLinus Torvalds #define HOST_DO_DU      0x12
455*1da177e4SLinus Torvalds #define HOST_BUS_FREE   0x13
456*1da177e4SLinus Torvalds #define HOST_BAD_PHAS   0x14
457*1da177e4SLinus Torvalds #define HOST_INV_CMD    0x16
458*1da177e4SLinus Torvalds #define HOST_ABORTED    0x1A	/* 07/21/98 */
459*1da177e4SLinus Torvalds #define HOST_SCSI_RST   0x1B
460*1da177e4SLinus Torvalds #define HOST_DEV_RST    0x1C
461*1da177e4SLinus Torvalds 
462*1da177e4SLinus Torvalds /* Error Codes for SCB_TaStat */
463*1da177e4SLinus Torvalds #define TARGET_CHKCOND  0x02
464*1da177e4SLinus Torvalds #define TARGET_BUSY     0x08
465*1da177e4SLinus Torvalds #define INI_QUEUE_FULL	0x28
466*1da177e4SLinus Torvalds 
467*1da177e4SLinus Torvalds /* SCSI MESSAGE */
468*1da177e4SLinus Torvalds #define MSG_COMP        0x00
469*1da177e4SLinus Torvalds #define MSG_EXTEND      0x01
470*1da177e4SLinus Torvalds #define MSG_SDP         0x02
471*1da177e4SLinus Torvalds #define MSG_RESTORE     0x03
472*1da177e4SLinus Torvalds #define MSG_DISC        0x04
473*1da177e4SLinus Torvalds #define MSG_IDE         0x05
474*1da177e4SLinus Torvalds #define MSG_ABORT       0x06
475*1da177e4SLinus Torvalds #define MSG_REJ         0x07
476*1da177e4SLinus Torvalds #define MSG_NOP         0x08
477*1da177e4SLinus Torvalds #define MSG_PARITY      0x09
478*1da177e4SLinus Torvalds #define MSG_LINK_COMP   0x0A
479*1da177e4SLinus Torvalds #define MSG_LINK_FLAG   0x0B
480*1da177e4SLinus Torvalds #define MSG_DEVRST      0x0C
481*1da177e4SLinus Torvalds #define MSG_ABORT_TAG   0x0D
482*1da177e4SLinus Torvalds 
483*1da177e4SLinus Torvalds /* Queue tag msg: Simple_quque_tag, Head_of_queue_tag, Ordered_queue_tag */
484*1da177e4SLinus Torvalds #define MSG_STAG        0x20
485*1da177e4SLinus Torvalds #define MSG_HTAG        0x21
486*1da177e4SLinus Torvalds #define MSG_OTAG        0x22
487*1da177e4SLinus Torvalds 
488*1da177e4SLinus Torvalds #define MSG_IGNOREWIDE  0x23
489*1da177e4SLinus Torvalds 
490*1da177e4SLinus Torvalds #define MSG_IDENT   0x80
491*1da177e4SLinus Torvalds 
492*1da177e4SLinus Torvalds /***********************************************************************
493*1da177e4SLinus Torvalds 		Target Device Control Structure
494*1da177e4SLinus Torvalds **********************************************************************/
495*1da177e4SLinus Torvalds 
496*1da177e4SLinus Torvalds typedef struct Tar_Ctrl_Struc {
497*1da177e4SLinus Torvalds 	UWORD TCS_Flags;	/* 0 */
498*1da177e4SLinus Torvalds 	UBYTE TCS_JS_Period;	/* 2 */
499*1da177e4SLinus Torvalds 	UBYTE TCS_SConfig0;	/* 3 */
500*1da177e4SLinus Torvalds 
501*1da177e4SLinus Torvalds 	UWORD TCS_DrvFlags;	/* 4 */
502*1da177e4SLinus Torvalds 	UBYTE TCS_DrvHead;	/* 6 */
503*1da177e4SLinus Torvalds 	UBYTE TCS_DrvSector;	/* 7 */
504*1da177e4SLinus Torvalds } TCS;
505*1da177e4SLinus Torvalds 
506*1da177e4SLinus Torvalds /***********************************************************************
507*1da177e4SLinus Torvalds 		Target Device Control Structure
508*1da177e4SLinus Torvalds **********************************************************************/
509*1da177e4SLinus Torvalds 
510*1da177e4SLinus Torvalds /* Bit Definition for TCF_Flags */
511*1da177e4SLinus Torvalds #define TCF_SCSI_RATE           0x0007
512*1da177e4SLinus Torvalds #define TCF_EN_DISC             0x0008
513*1da177e4SLinus Torvalds #define TCF_NO_SYNC_NEGO        0x0010
514*1da177e4SLinus Torvalds #define TCF_NO_WDTR             0x0020
515*1da177e4SLinus Torvalds #define TCF_EN_255              0x0040
516*1da177e4SLinus Torvalds #define TCF_EN_START            0x0080
517*1da177e4SLinus Torvalds #define TCF_WDTR_DONE           0x0100
518*1da177e4SLinus Torvalds #define TCF_SYNC_DONE           0x0200
519*1da177e4SLinus Torvalds #define TCF_BUSY                0x0400
520*1da177e4SLinus Torvalds 
521*1da177e4SLinus Torvalds 
522*1da177e4SLinus Torvalds /* Bit Definition for TCF_DrvFlags */
523*1da177e4SLinus Torvalds #define TCF_DRV_BUSY            0x01	/* Indicate target busy(driver) */
524*1da177e4SLinus Torvalds #define TCF_DRV_EN_TAG          0x0800
525*1da177e4SLinus Torvalds #define TCF_DRV_255_63          0x0400
526*1da177e4SLinus Torvalds 
527*1da177e4SLinus Torvalds typedef struct I91u_Adpt_Struc {
528*1da177e4SLinus Torvalds 	UWORD ADPT_BIOS;	/* 0 */
529*1da177e4SLinus Torvalds 	UWORD ADPT_BASE;	/* 1 */
530*1da177e4SLinus Torvalds 	UBYTE ADPT_Bus;		/* 2 */
531*1da177e4SLinus Torvalds 	UBYTE ADPT_Device;	/* 3 */
532*1da177e4SLinus Torvalds 	UBYTE ADPT_INTR;	/* 4 */
533*1da177e4SLinus Torvalds } INI_ADPT_STRUCT;
534*1da177e4SLinus Torvalds 
535*1da177e4SLinus Torvalds 
536*1da177e4SLinus Torvalds /***********************************************************************
537*1da177e4SLinus Torvalds 	      Host Adapter Control Structure
538*1da177e4SLinus Torvalds ************************************************************************/
539*1da177e4SLinus Torvalds typedef struct Ha_Ctrl_Struc {
540*1da177e4SLinus Torvalds 	UWORD HCS_Base;		/* 00 */
541*1da177e4SLinus Torvalds 	UWORD HCS_BIOS;		/* 02 */
542*1da177e4SLinus Torvalds 	UBYTE HCS_Intr;		/* 04 */
543*1da177e4SLinus Torvalds 	UBYTE HCS_SCSI_ID;	/* 05 */
544*1da177e4SLinus Torvalds 	UBYTE HCS_MaxTar;	/* 06 */
545*1da177e4SLinus Torvalds 	UBYTE HCS_NumScbs;	/* 07 */
546*1da177e4SLinus Torvalds 
547*1da177e4SLinus Torvalds 	UBYTE HCS_Flags;	/* 08 */
548*1da177e4SLinus Torvalds 	UBYTE HCS_Index;	/* 09 */
549*1da177e4SLinus Torvalds 	UBYTE HCS_HaId;		/* 0A */
550*1da177e4SLinus Torvalds 	UBYTE HCS_Config;	/* 0B */
551*1da177e4SLinus Torvalds 	UWORD HCS_IdMask;	/* 0C */
552*1da177e4SLinus Torvalds 	UBYTE HCS_Semaph;	/* 0E */
553*1da177e4SLinus Torvalds 	UBYTE HCS_Phase;	/* 0F */
554*1da177e4SLinus Torvalds 	UBYTE HCS_JSStatus0;	/* 10 */
555*1da177e4SLinus Torvalds 	UBYTE HCS_JSInt;	/* 11 */
556*1da177e4SLinus Torvalds 	UBYTE HCS_JSStatus1;	/* 12 */
557*1da177e4SLinus Torvalds 	UBYTE HCS_SConf1;	/* 13 */
558*1da177e4SLinus Torvalds 
559*1da177e4SLinus Torvalds 	UBYTE HCS_Msg[8];	/* 14 */
560*1da177e4SLinus Torvalds 	SCB *HCS_NxtAvail;	/* 1C */
561*1da177e4SLinus Torvalds 	SCB *HCS_Scb;		/* 20 */
562*1da177e4SLinus Torvalds 	SCB *HCS_ScbEnd;	/* 24 */
563*1da177e4SLinus Torvalds 	SCB *HCS_NxtPend;	/* 28 */
564*1da177e4SLinus Torvalds 	SCB *HCS_NxtContig;	/* 2C */
565*1da177e4SLinus Torvalds 	SCB *HCS_ActScb;	/* 30 */
566*1da177e4SLinus Torvalds 	TCS *HCS_ActTcs;	/* 34 */
567*1da177e4SLinus Torvalds 
568*1da177e4SLinus Torvalds 	SCB *HCS_FirstAvail;	/* 38 */
569*1da177e4SLinus Torvalds 	SCB *HCS_LastAvail;	/* 3C */
570*1da177e4SLinus Torvalds 	SCB *HCS_FirstPend;	/* 40 */
571*1da177e4SLinus Torvalds 	SCB *HCS_LastPend;	/* 44 */
572*1da177e4SLinus Torvalds 	SCB *HCS_FirstBusy;	/* 48 */
573*1da177e4SLinus Torvalds 	SCB *HCS_LastBusy;	/* 4C */
574*1da177e4SLinus Torvalds 	SCB *HCS_FirstDone;	/* 50 */
575*1da177e4SLinus Torvalds 	SCB *HCS_LastDone;	/* 54 */
576*1da177e4SLinus Torvalds 	UBYTE HCS_MaxTags[16];	/* 58 */
577*1da177e4SLinus Torvalds 	UBYTE HCS_ActTags[16];	/* 68 */
578*1da177e4SLinus Torvalds 	TCS HCS_Tcs[MAX_TARGETS];	/* 78 */
579*1da177e4SLinus Torvalds 	spinlock_t HCS_AvailLock;
580*1da177e4SLinus Torvalds 	spinlock_t HCS_SemaphLock;
581*1da177e4SLinus Torvalds 	struct pci_dev *pci_dev;
582*1da177e4SLinus Torvalds } HCS;
583*1da177e4SLinus Torvalds 
584*1da177e4SLinus Torvalds /* Bit Definition for HCB_Config */
585*1da177e4SLinus Torvalds #define HCC_SCSI_RESET          0x01
586*1da177e4SLinus Torvalds #define HCC_EN_PAR              0x02
587*1da177e4SLinus Torvalds #define HCC_ACT_TERM1           0x04
588*1da177e4SLinus Torvalds #define HCC_ACT_TERM2           0x08
589*1da177e4SLinus Torvalds #define HCC_AUTO_TERM           0x10
590*1da177e4SLinus Torvalds #define HCC_EN_PWR              0x80
591*1da177e4SLinus Torvalds 
592*1da177e4SLinus Torvalds /* Bit Definition for HCB_Flags */
593*1da177e4SLinus Torvalds #define HCF_EXPECT_DISC         0x01
594*1da177e4SLinus Torvalds #define HCF_EXPECT_SELECT       0x02
595*1da177e4SLinus Torvalds #define HCF_EXPECT_RESET        0x10
596*1da177e4SLinus Torvalds #define HCF_EXPECT_DONE_DISC    0x20
597*1da177e4SLinus Torvalds 
598*1da177e4SLinus Torvalds /******************************************************************
599*1da177e4SLinus Torvalds 	Serial EEProm
600*1da177e4SLinus Torvalds *******************************************************************/
601*1da177e4SLinus Torvalds 
602*1da177e4SLinus Torvalds typedef struct _NVRAM_SCSI {	/* SCSI channel configuration   */
603*1da177e4SLinus Torvalds 	UCHAR NVM_ChSCSIID;	/* 0Ch -> Channel SCSI ID       */
604*1da177e4SLinus Torvalds 	UCHAR NVM_ChConfig1;	/* 0Dh -> Channel config 1      */
605*1da177e4SLinus Torvalds 	UCHAR NVM_ChConfig2;	/* 0Eh -> Channel config 2      */
606*1da177e4SLinus Torvalds 	UCHAR NVM_NumOfTarg;	/* 0Fh -> Number of SCSI target */
607*1da177e4SLinus Torvalds 	/* SCSI target configuration    */
608*1da177e4SLinus Torvalds 	UCHAR NVM_Targ0Config;	/* 10h -> Target 0 configuration */
609*1da177e4SLinus Torvalds 	UCHAR NVM_Targ1Config;	/* 11h -> Target 1 configuration */
610*1da177e4SLinus Torvalds 	UCHAR NVM_Targ2Config;	/* 12h -> Target 2 configuration */
611*1da177e4SLinus Torvalds 	UCHAR NVM_Targ3Config;	/* 13h -> Target 3 configuration */
612*1da177e4SLinus Torvalds 	UCHAR NVM_Targ4Config;	/* 14h -> Target 4 configuration */
613*1da177e4SLinus Torvalds 	UCHAR NVM_Targ5Config;	/* 15h -> Target 5 configuration */
614*1da177e4SLinus Torvalds 	UCHAR NVM_Targ6Config;	/* 16h -> Target 6 configuration */
615*1da177e4SLinus Torvalds 	UCHAR NVM_Targ7Config;	/* 17h -> Target 7 configuration */
616*1da177e4SLinus Torvalds 	UCHAR NVM_Targ8Config;	/* 18h -> Target 8 configuration */
617*1da177e4SLinus Torvalds 	UCHAR NVM_Targ9Config;	/* 19h -> Target 9 configuration */
618*1da177e4SLinus Torvalds 	UCHAR NVM_TargAConfig;	/* 1Ah -> Target A configuration */
619*1da177e4SLinus Torvalds 	UCHAR NVM_TargBConfig;	/* 1Bh -> Target B configuration */
620*1da177e4SLinus Torvalds 	UCHAR NVM_TargCConfig;	/* 1Ch -> Target C configuration */
621*1da177e4SLinus Torvalds 	UCHAR NVM_TargDConfig;	/* 1Dh -> Target D configuration */
622*1da177e4SLinus Torvalds 	UCHAR NVM_TargEConfig;	/* 1Eh -> Target E configuration */
623*1da177e4SLinus Torvalds 	UCHAR NVM_TargFConfig;	/* 1Fh -> Target F configuration */
624*1da177e4SLinus Torvalds } NVRAM_SCSI;
625*1da177e4SLinus Torvalds 
626*1da177e4SLinus Torvalds typedef struct _NVRAM {
627*1da177e4SLinus Torvalds /*----------header ---------------*/
628*1da177e4SLinus Torvalds 	USHORT NVM_Signature;	/* 0,1: Signature */
629*1da177e4SLinus Torvalds 	UCHAR NVM_Size;		/* 2:   Size of data structure */
630*1da177e4SLinus Torvalds 	UCHAR NVM_Revision;	/* 3:   Revision of data structure */
631*1da177e4SLinus Torvalds 	/* ----Host Adapter Structure ---- */
632*1da177e4SLinus Torvalds 	UCHAR NVM_ModelByte0;	/* 4:   Model number (byte 0) */
633*1da177e4SLinus Torvalds 	UCHAR NVM_ModelByte1;	/* 5:   Model number (byte 1) */
634*1da177e4SLinus Torvalds 	UCHAR NVM_ModelInfo;	/* 6:   Model information         */
635*1da177e4SLinus Torvalds 	UCHAR NVM_NumOfCh;	/* 7:   Number of SCSI channel */
636*1da177e4SLinus Torvalds 	UCHAR NVM_BIOSConfig1;	/* 8:   BIOS configuration 1  */
637*1da177e4SLinus Torvalds 	UCHAR NVM_BIOSConfig2;	/* 9:   BIOS configuration 2  */
638*1da177e4SLinus Torvalds 	UCHAR NVM_HAConfig1;	/* A:   Hoat adapter configuration 1 */
639*1da177e4SLinus Torvalds 	UCHAR NVM_HAConfig2;	/* B:   Hoat adapter configuration 2 */
640*1da177e4SLinus Torvalds 	NVRAM_SCSI NVM_SCSIInfo[2];
641*1da177e4SLinus Torvalds 	UCHAR NVM_reserved[10];
642*1da177e4SLinus Torvalds 	/* ---------- CheckSum ----------       */
643*1da177e4SLinus Torvalds 	USHORT NVM_CheckSum;	/* 0x3E, 0x3F: Checksum of NVRam        */
644*1da177e4SLinus Torvalds } NVRAM, *PNVRAM;
645*1da177e4SLinus Torvalds 
646*1da177e4SLinus Torvalds /* Bios Configuration for nvram->BIOSConfig1                            */
647*1da177e4SLinus Torvalds #define NBC1_ENABLE             0x01	/* BIOS enable                  */
648*1da177e4SLinus Torvalds #define NBC1_8DRIVE             0x02	/* Support more than 2 drives   */
649*1da177e4SLinus Torvalds #define NBC1_REMOVABLE          0x04	/* Support removable drive      */
650*1da177e4SLinus Torvalds #define NBC1_INT19              0x08	/* Intercept int 19h            */
651*1da177e4SLinus Torvalds #define NBC1_BIOSSCAN           0x10	/* Dynamic BIOS scan            */
652*1da177e4SLinus Torvalds #define NBC1_LUNSUPPORT         0x40	/* Support LUN                  */
653*1da177e4SLinus Torvalds 
654*1da177e4SLinus Torvalds /* HA Configuration Byte 1                                              */
655*1da177e4SLinus Torvalds #define NHC1_BOOTIDMASK 0x0F	/* Boot ID number               */
656*1da177e4SLinus Torvalds #define NHC1_LUNMASK    0x70	/* Boot LUN number              */
657*1da177e4SLinus Torvalds #define NHC1_CHANMASK   0x80	/* Boot Channel number          */
658*1da177e4SLinus Torvalds 
659*1da177e4SLinus Torvalds /* Bit definition for nvram->SCSIconfig1                                */
660*1da177e4SLinus Torvalds #define NCC1_BUSRESET           0x01	/* Reset SCSI bus at power up   */
661*1da177e4SLinus Torvalds #define NCC1_PARITYCHK          0x02	/* SCSI parity enable           */
662*1da177e4SLinus Torvalds #define NCC1_ACTTERM1           0x04	/* Enable active terminator 1   */
663*1da177e4SLinus Torvalds #define NCC1_ACTTERM2           0x08	/* Enable active terminator 2   */
664*1da177e4SLinus Torvalds #define NCC1_AUTOTERM           0x10	/* Enable auto terminator       */
665*1da177e4SLinus Torvalds #define NCC1_PWRMGR             0x80	/* Enable power management      */
666*1da177e4SLinus Torvalds 
667*1da177e4SLinus Torvalds /* Bit definition for SCSI Target configuration byte                    */
668*1da177e4SLinus Torvalds #define NTC_DISCONNECT          0x08	/* Enable SCSI disconnect       */
669*1da177e4SLinus Torvalds #define NTC_SYNC                0x10	/* SYNC_NEGO                    */
670*1da177e4SLinus Torvalds #define NTC_NO_WDTR             0x20	/* SYNC_NEGO                    */
671*1da177e4SLinus Torvalds #define NTC_1GIGA               0x40	/* 255 head / 63 sectors (64/32) */
672*1da177e4SLinus Torvalds #define NTC_SPINUP              0x80	/* Start disk drive             */
673*1da177e4SLinus Torvalds 
674*1da177e4SLinus Torvalds /*      Default NVRam values                                            */
675*1da177e4SLinus Torvalds #define INI_SIGNATURE           0xC925
676*1da177e4SLinus Torvalds #define NBC1_DEFAULT            (NBC1_ENABLE)
677*1da177e4SLinus Torvalds #define NCC1_DEFAULT            (NCC1_BUSRESET | NCC1_AUTOTERM | NCC1_PARITYCHK)
678*1da177e4SLinus Torvalds #define NTC_DEFAULT             (NTC_NO_WDTR | NTC_1GIGA | NTC_DISCONNECT)
679*1da177e4SLinus Torvalds 
680*1da177e4SLinus Torvalds /* SCSI related definition                                              */
681*1da177e4SLinus Torvalds #define DISC_NOT_ALLOW          0x80	/* Disconnect is not allowed    */
682*1da177e4SLinus Torvalds #define DISC_ALLOW              0xC0	/* Disconnect is allowed        */
683*1da177e4SLinus Torvalds #define SCSICMD_RequestSense    0x03
684*1da177e4SLinus Torvalds 
685*1da177e4SLinus Torvalds typedef struct _HCSinfo {
686*1da177e4SLinus Torvalds 	ULONG base;
687*1da177e4SLinus Torvalds 	UCHAR vec;
688*1da177e4SLinus Torvalds 	UCHAR bios;		/* High byte of BIOS address */
689*1da177e4SLinus Torvalds 	USHORT BaseAndBios;	/* high byte: pHcsInfo->bios,low byte:pHcsInfo->base */
690*1da177e4SLinus Torvalds } HCSINFO;
691*1da177e4SLinus Torvalds 
692*1da177e4SLinus Torvalds #define TUL_RD(x,y)             (UCHAR)(inb(  (int)((ULONG)(x+y)) ))
693*1da177e4SLinus Torvalds #define TUL_RDLONG(x,y)         (ULONG)(inl((int)((ULONG)(x+y)) ))
694*1da177e4SLinus Torvalds #define TUL_WR(     adr,data)   outb( (UCHAR)(data), (int)(adr))
695*1da177e4SLinus Torvalds #define TUL_WRSHORT(adr,data)   outw( (UWORD)(data), (int)(adr))
696*1da177e4SLinus Torvalds #define TUL_WRLONG( adr,data)   outl( (ULONG)(data), (int)(adr))
697*1da177e4SLinus Torvalds 
698*1da177e4SLinus Torvalds #define SCSI_ABORT_SNOOZE 0
699*1da177e4SLinus Torvalds #define SCSI_ABORT_SUCCESS 1
700*1da177e4SLinus Torvalds #define SCSI_ABORT_PENDING 2
701*1da177e4SLinus Torvalds #define SCSI_ABORT_BUSY 3
702*1da177e4SLinus Torvalds #define SCSI_ABORT_NOT_RUNNING 4
703*1da177e4SLinus Torvalds #define SCSI_ABORT_ERROR 5
704*1da177e4SLinus Torvalds 
705*1da177e4SLinus Torvalds #define SCSI_RESET_SNOOZE 0
706*1da177e4SLinus Torvalds #define SCSI_RESET_PUNT 1
707*1da177e4SLinus Torvalds #define SCSI_RESET_SUCCESS 2
708*1da177e4SLinus Torvalds #define SCSI_RESET_PENDING 3
709*1da177e4SLinus Torvalds #define SCSI_RESET_WAKEUP 4
710*1da177e4SLinus Torvalds #define SCSI_RESET_NOT_RUNNING 5
711*1da177e4SLinus Torvalds #define SCSI_RESET_ERROR 6
712*1da177e4SLinus Torvalds 
713*1da177e4SLinus Torvalds #define SCSI_RESET_SYNCHRONOUS		0x01
714*1da177e4SLinus Torvalds #define SCSI_RESET_ASYNCHRONOUS		0x02
715*1da177e4SLinus Torvalds #define SCSI_RESET_SUGGEST_BUS_RESET	0x04
716*1da177e4SLinus Torvalds #define SCSI_RESET_SUGGEST_HOST_RESET	0x08
717*1da177e4SLinus Torvalds 
718*1da177e4SLinus Torvalds #define SCSI_RESET_BUS_RESET 0x100
719*1da177e4SLinus Torvalds #define SCSI_RESET_HOST_RESET 0x200
720*1da177e4SLinus Torvalds #define SCSI_RESET_ACTION   0xff
721*1da177e4SLinus Torvalds 
722*1da177e4SLinus Torvalds extern void init_i91uAdapter_table(void);
723*1da177e4SLinus Torvalds extern int Addi91u_into_Adapter_table(WORD, WORD, BYTE, BYTE, BYTE);
724*1da177e4SLinus Torvalds extern int tul_ReturnNumberOfAdapters(void);
725*1da177e4SLinus Torvalds extern void get_tulipPCIConfig(HCS * pHCB, int iChannel_index);
726*1da177e4SLinus Torvalds extern int init_tulip(HCS * pHCB, SCB * pSCB, int tul_num_scb, BYTE * pbBiosAdr, int reset_time);
727*1da177e4SLinus Torvalds extern SCB *tul_alloc_scb(HCS * pHCB);
728*1da177e4SLinus Torvalds extern int tul_abort_srb(HCS * pHCB, struct scsi_cmnd * pSRB);
729*1da177e4SLinus Torvalds extern void tul_exec_scb(HCS * pHCB, SCB * pSCB);
730*1da177e4SLinus Torvalds extern void tul_release_scb(HCS * pHCB, SCB * pSCB);
731*1da177e4SLinus Torvalds extern void tul_stop_bm(HCS * pHCB);
732*1da177e4SLinus Torvalds extern int tul_reset_scsi(HCS * pCurHcb, int seconds);
733*1da177e4SLinus Torvalds extern int tul_isr(HCS * pHCB);
734*1da177e4SLinus Torvalds extern int tul_reset(HCS * pHCB, struct scsi_cmnd * pSRB, unsigned char target);
735*1da177e4SLinus Torvalds extern int tul_reset_scsi_bus(HCS * pCurHcb);
736*1da177e4SLinus Torvalds extern int tul_device_reset(HCS * pCurHcb, struct scsi_cmnd *pSrb,
737*1da177e4SLinus Torvalds 		unsigned int target, unsigned int ResetFlags);
738*1da177e4SLinus Torvalds 				/* ---- EXTERNAL VARIABLES ---- */
739*1da177e4SLinus Torvalds extern HCS tul_hcs[];
740