1 /*
2 * buslogic.h (C) 1993 David B. Gentzel
3 * Low-level scsi driver for BusLogic adapters
4 * by David B. Gentzel, Whitfield Software Services, Carnegie, PA
5 * (gentzel@nova.enet.dec.com)
6 * Thanks to BusLogic for providing the necessary documentation
7 *
8 * The original version of this driver was derived from aha1542.[ch] which
9 * is Copyright (C) 1992 Tommy Thorn. Much has been reworked, but most of
10 * basic structure and substantial chunks of code still remain.
11 */
12
13 #ifndef _BUSLOGIC_H
14
15 int buslogic_detect(Scsi_Host_Template *);
16 int buslogic_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
17 int buslogic_abort(Scsi_Cmnd *);
18 const char *buslogic_info(void);
19 int buslogic_reset(Scsi_Cmnd *);
20 int buslogic_biosparam(Disk *, int, int *);
21
22 #define BUSLOGIC_CMDLUN 1 /* Do not set this too high. It sucks
23 up lots of memory on machines with > 16Mb
24 because of the huge number of bounce
25 buffers that need to be allocated.
26 For boards that use non-ISA bus, we can
27 bump this in the board detect routine.
28 10/8/94 ERY */
29
30
31 #define BUSLOGIC { NULL, \
32 "BusLogic", \
33 buslogic_detect, \
34 NULL, \
35 buslogic_info, \
36 0, /* no command func */ \
37 buslogic_queuecommand, \
38 buslogic_abort, \
39 buslogic_reset, \
40 0, /* slave_attach NYI */ \
41 buslogic_biosparam, \
42 0, /* set by driver */ \
43 0, /* set by driver */ \
44 0, /* set by driver */ \
45 BUSLOGIC_CMDLUN, \
46 0, \
47 0, /* set by driver */ \
48 ENABLE_CLUSTERING \
49 }
50
51 #ifdef BUSLOGIC_PRIVATE_H
52
53 /* ??? These don't really belong here */
54 #ifndef TRUE
55 # define TRUE 1
56 #endif
57 #ifndef FALSE
58 # define FALSE 0
59 #endif
60
61 #define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr)[0])
62
63 #define PACKED __attribute__((packed))
64
65 #define BD_ABORT 0x0001
66 #define BD_COMMAND 0x0002
67 #define BD_DETECT 0x0004
68 #define BD_INTERRUPT 0x0008
69 #define BD_RESET 0x0010
70
71 /* I/O Port interface */
72 /* READ */
73 #define STATUS(base) (base)
74 #define DACT 0x80 /* Diagnostic Active */
75 #define DFAIL 0x40 /* Diagnostic Failure */
76 #define INREQ 0x20 /* Initialization Required */
77 #define HARDY 0x10 /* Host Adapter Ready */
78 #define CPRBSY 0x08 /* Command/Parameter Register Busy */
79 #define DIRRDY 0x04 /* Data In Register Ready */
80 #define CMDINV 0x01 /* Command Invalid */
81 #define STATMASK 0xFD /* 0x02 is reserved */
82
83 #define DATA_IN(base) (STATUS(base) + 1)
84
85 #define INTERRUPT(base) (STATUS(base) + 2)
86 #define INTV 0x80 /* Interrupt Valid */
87 #define RSTS 0x08 /* SCSI Reset State */
88 #define CMDC 0x04 /* Command Complete */
89 #define MBOR 0x02 /* Mailbox Out Ready */
90 #define IMBL 0x01 /* Incoming Mailbox Loaded */
91 #define INTRMASK 0x8F /* 0x70 are reserved */
92
93 /* WRITE */
94 #define CONTROL(base) STATUS(base)
95 #define RHARD 0x80 /* Hard Reset */
96 #define RSOFT 0x40 /* Soft Reset */
97 #define RINT 0x20 /* Interrupt Reset */
98 #define RSBUS 0x10 /* SCSI Bus Reset */
99
100 #define COMMAND_PARAMETER(base) (STATUS(base) + 1)
101 #define CMD_TSTCMDCINT 0x00 /* Test CMDC Interrupt */
102 #define CMD_INITMB 0x01 /* Initialize Mailbox */
103 #define CMD_START_SCSI 0x02 /* Start Mailbox */
104 #define CMD_START_BIOS 0x03 /* Start BIOS */
105 #define CMD_INQUIRY 0x04 /* Inquire Board ID */
106 #define CMD_ENBOMBRINT 0x05 /* Enable OMBR Interrupt */
107 #define CMD_SETSELTIMOUT 0x06 /* Set SCSI Selection Time-Out */
108 #define CMD_BUSON_TIME 0x07 /* Set Bus-On Time */
109 #define CMD_BUSOFF_TIME 0x08 /* Set Bus-Off Time */
110 #define CMD_BUSXFR_RATE 0x09 /* Set Bus Transfer Rate */
111 #define CMD_INQ_DEVICES 0x0A /* Inquire Installed Devices */
112 #define CMD_RETCONF 0x0B /* Return Configuration */
113 #define CMD_TARGET_MODE 0x0C /* Set Target Mode */
114 #define CMD_INQ_SETUP_INFO 0x0D /* Inquire Set-up Information */
115 #define CMD_WRITE_LCL_RAM 0x1A /* Write Adapter Local RAM */
116 #define CMD_READ_LCL_RAM 0x1B /* Read Adapter Local RAM */
117 #define CMD_WRITE_BM_FIFO 0x1C /* Write Bus Master Chip FIFO */
118 #define CMD_READ_BM_FIFO 0x1D /* Read Bus Master Chip FIFO */
119 #define CMD_ECHO 0x1F /* Echo Data Byte */
120 #define CMD_HA_DIAG 0x20 /* Host Adapter Diagnostic */
121 #define CMD_HA_OPTIONS 0x21 /* Host Adapter Options */
122 #define CMD_INITEXTMB 0x81 /* Initialize Extended Mailbox */
123 #define CMD_INQEXTSETUP 0x8D /* Inquire Extended Set-up Information */
124 #define CMD_WRITE_INQ_BUF 0x9A /* Write Inquiry Data Buffer
125 (Target Mode Only) */
126 #define CMD_READ_INQ_BUF 0x9B /* Read Inquiry Data Buffer
127 (Target Mode Only) */
128
129 #define MBX_NOT_IN_USE 0x00
130 #define MBX_ACTION_START 0x01
131 #define MBX_ACTION_ABORT 0x02
132 #define MBX_COMPLETION_OK 0x01
133 #define MBX_COMPLETION_ABORTED 0x02
134 #define MBX_COMPLETION_NOT_FOUND 0x03
135 #define MBX_COMPLETION_ERROR 0x04
136
137 /* Mailbox Definition */
138 struct mailbox {
139 void *ccbptr; /* lsb, ..., msb */
140 unsigned char btstat;
141 unsigned char sdstat;
142 unsigned char reserved;
143 unsigned char status; /* Command/Status */
144 };
145
146 /* This is used with scatter-gather */
147 struct chain {
148 unsigned long datalen; /* Size of this part of chain */
149 void *dataptr; /* Location of data */
150 };
151
152 #define MAX_CDB 12
153
154 struct ccb { /* Command Control Block */
155 unsigned char op; /* Command Control Block Operation Code */
156 unsigned char dir;
157 unsigned char cdblen; /* SCSI Command Length */
158 unsigned char rsalen; /* Request Sense Allocation Length/Disable */
159 unsigned long datalen; /* Data Length (msb, ..., lsb) */
160 void *dataptr; /* Data Pointer */
161 unsigned char reserved[2];
162 unsigned char hastat; /* Host Adapter Status (HASTAT) */
163 unsigned char tarstat; /* Target Device Status */
164 unsigned char id;
165 unsigned char lun;
166 unsigned char cdb[MAX_CDB];
167 unsigned char ccbcontrol;
168 unsigned char commlinkid; /* Command Linking Identifier */
169 void *linkptr; /* Link Pointer */
170 void *senseptr;
171 };
172
173 #define CCB_OP_INIT 0x00 /* Initiator CCB */
174 #define CCB_OP_TARG 0x01 /* Target CCB */
175 #define CCB_OP_INIT_SG 0x02 /* Initiator CCB with scatter-gather */
176 #define CCB_OP_INIT_R 0x03 /* Initiator CCB with residual data length
177 returned */
178 #define CCB_OP_INIT_SG_R 0x04 /* Initiator CCB with scatter-gather and
179 residual data length returned */
180 #define CCB_OP_BUS_RESET 0x81 /* SCSI bus device reset */
181
182 #endif
183
184 #endif