1 #ifndef _AHA152X_H
2 #define _AHA152X_H
3
4
5
6
7
8 #if defined(__KERNEL__)
9
10 #include "../block/blk.h"
11 #include "scsi.h"
12 #include <asm/io.h>
13
14 int aha152x_detect(Scsi_Host_Template *);
15 int aha152x_command(Scsi_Cmnd *);
16 int aha152x_queue(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
17 int aha152x_abort(Scsi_Cmnd *);
18 int aha152x_reset(Scsi_Cmnd *);
19 int aha152x_biosparam(Disk *, int, int*);
20
21
22
23 #define AHA152X_MAXQUEUE 7
24
25 #define AHA152X_REVID "Adaptec 152x SCSI driver; $Revision: 1.9 $"
26
27
28 #define AHA152X { NULL, \
29 NULL, \
30 AHA152X_REVID, \
31 aha152x_detect, \
32 NULL, \
33 NULL, \
34 aha152x_command, \
35 aha152x_queue, \
36 aha152x_abort, \
37 aha152x_reset, \
38 0, \
39 aha152x_biosparam, \
40 1, \
41 7, \
42 SG_ALL, \
43 1, \
44 0, \
45 0, \
46 DISABLE_CLUSTERING }
47 #endif
48
49
50
51 #define SCSISEQ (port_base+0x00)
52 #define SXFRCTL0 (port_base+0x01)
53 #define SXFRCTL1 (port_base+0x02)
54 #define SCSISIG (port_base+0x03)
55 #define SCSIRATE (port_base+0x04)
56 #define SELID (port_base+0x05)
57 #define SCSIID SELID
58 #define SCSIDAT (port_base+0x06)
59 #define SCSIBUS (port_base+0x07)
60 #define STCNT0 (port_base+0x08)
61 #define STCNT1 (port_base+0x09)
62 #define STCNT2 (port_base+0x0a)
63 #define SSTAT0 (port_base+0x0b)
64 #define SSTAT1 (port_base+0x0c)
65 #define SSTAT2 (port_base+0x0d)
66 #define SCSITEST (port_base+0x0e)
67 #define SSTAT4 (port_base+0x0f)
68 #define SIMODE0 (port_base+0x10)
69 #define SIMODE1 (port_base+0x11)
70 #define DMACNTRL0 (port_base+0x12)
71 #define DMACNTRL1 (port_base+0x13)
72 #define DMASTAT (port_base+0x14)
73 #define FIFOSTAT (port_base+0x15)
74 #define DATAPORT (port_base+0x16)
75 #define BRSTCNTRL (port_base+0x18)
76 #define PORTA (port_base+0x1a)
77 #define PORTB (port_base+0x1b)
78 #define REV (port_base+0x1c)
79 #define STACK (port_base+0x1d)
80 #define TEST (port_base+0x1e)
81
82
83
84
85
86 #define TEMODEO 0x80
87 #define ENSELO 0x40
88 #define ENSELI 0x20
89 #define ENRESELI 0x10
90 #define ENAUTOATNO 0x08
91 #define ENAUTOATNI 0x04
92 #define ENAUTOATNP 0x02
93 #define SCSIRSTO 0x01
94
95
96 #define SCSIEN 0x80
97 #define DMAEN 0x40
98 #define CH1 0x20
99 #define CLRSTCNT 0x10
100 #define SPIOEN 0x08
101 #define CLRCH1 0x02
102
103
104 #define BITBUCKET 0x80
105 #define SWRAPEN 0x40
106 #define ENSPCHK 0x20
107 #define STIMESEL 0x18
108 #define STIMESEL_ 3
109 #define ENSTIMER 0x04
110 #define BYTEALIGN 0x02
111
112
113 #define CDI 0x80
114 #define IOI 0x40
115 #define MSGI 0x20
116 #define ATNI 0x10
117 #define SELI 0x08
118 #define BSYI 0x04
119 #define REQI 0x02
120 #define ACKI 0x01
121
122
123 #define P_MASK (MSGI|CDI|IOI)
124 #define P_DATAO (0)
125 #define P_DATAI (IOI)
126 #define P_CMD (CDI)
127 #define P_STATUS (CDI|IOI)
128 #define P_MSGO (MSGI|CDI)
129 #define P_MSGI (MSGI|CDI|IOI)
130
131
132 #define CDO 0x80
133 #define IOO 0x40
134 #define MSGO 0x20
135 #define ATNO 0x10
136 #define SELO 0x08
137 #define BSYO 0x04
138 #define REQO 0x02
139 #define ACKO 0x01
140
141
142 #define SXFR 0x70
143 #define SXFR_ 4
144 #define SOFS 0x0f
145
146
147 #define OID 0x70
148 #define OID_ 4
149 #define TID 0x07
150
151
152 #define GETSTCNT() ( (GETPORT(STCNT2)<<16) \
153 + (GETPORT(STCNT1)<< 8) \
154 + GETPORT(STCNT0) )
155
156 #define SETSTCNT(X) { SETPORT(STCNT2, ((X) & 0xFF0000) >> 16); \
157 SETPORT(STCNT1, ((X) & 0x00FF00) >> 8); \
158 SETPORT(STCNT0, ((X) & 0x0000FF) ); }
159
160
161 #define TARGET 0x80
162 #define SELDO 0x40
163 #define SELDI 0x20
164 #define SELINGO 0x10
165 #define SWRAP 0x08
166 #define SDONE 0x04
167 #define SPIORDY 0x02
168 #define DMADONE 0x01
169
170 #define SETSDONE 0x80
171 #define CLRSELDO 0x40
172 #define CLRSELDI 0x20
173 #define CLRSELINGO 0x10
174 #define CLRSWRAP 0x08
175 #define CLRSDONE 0x04
176 #define CLRSPIORDY 0x02
177 #define CLRDMADONE 0x01
178
179
180 #define SELTO 0x80
181 #define ATNTARG 0x40
182 #define SCSIRSTI 0x20
183 #define PHASEMIS 0x10
184 #define BUSFREE 0x08
185 #define SCSIPERR 0x04
186 #define PHASECHG 0x02
187 #define REQINIT 0x01
188
189 #define CLRSELTIMO 0x80
190 #define CLRATNO 0x40
191 #define CLRSCSIRSTI 0x20
192 #define CLRBUSFREE 0x08
193 #define CLRSCSIPERR 0x04
194 #define CLRPHASECHG 0x02
195 #define CLRREQINIT 0x01
196
197
198 #define SOFFSET 0x20
199 #define SEMPTY 0x10
200 #define SFULL 0x08
201 #define SFCNT 0x07
202
203
204 #define SCSICNT 0xf0
205 #define SCSICNT_ 4
206 #define OFFCNT 0x0f
207
208
209 #define SCTESTU 0x08
210 #define SCTESTD 0x04
211 #define STCTEST 0x01
212
213
214 #define SYNCERR 0x04
215 #define FWERR 0x02
216 #define FRERR 0x01
217
218 #define CLRSYNCERR 0x04
219 #define CLRFWERR 0x02
220 #define CLRFRERR 0x01
221
222
223 #define ENSELDO 0x40
224 #define ENSELDI 0x20
225 #define ENSELINGO 0x10
226 #define ENSWRAP 0x08
227 #define ENSDONE 0x04
228 #define ENSPIORDY 0x02
229 #define ENDMADONE 0x01
230
231
232 #define ENSELTIMO 0x80
233 #define ENATNTARG 0x40
234 #define ENSCSIRST 0x20
235 #define ENPHASEMIS 0x10
236 #define ENBUSFREE 0x08
237 #define ENSCSIPERR 0x04
238 #define ENPHASECHG 0x02
239 #define ENREQINIT 0x01
240
241
242 #define ENDMA 0x80
243 #define _8BIT 0x40
244 #define DMA 0x20
245 #define WRITE_READ 0x08
246 #define INTEN 0x04
247 #define RSTFIFO 0x02
248 #define SWINT 0x01
249
250
251 #define PWRDWN 0x80
252 #define STK 0x07
253
254
255 #define ATDONE 0x80
256 #define WORDRDY 0x40
257 #define INTSTAT 0x20
258 #define DFIFOFULL 0x10
259 #define DFIFOEMP 0x08
260
261
262 #define BON 0xf0
263 #define BOFF 0x0f
264
265
266 #define BOFFTMR 0x40
267 #define BONTMR 0x20
268 #define STCNTH 0x10
269 #define STCNTM 0x08
270 #define STCNTL 0x04
271 #define SCSIBLK 0x02
272 #define DMABLK 0x01
273
274
275
276 typedef union {
277 struct {
278 unsigned reserved:2;
279 unsigned tardisc:1;
280 unsigned syncneg:1;
281 unsigned msgclasses:2;
282
283
284
285
286
287 unsigned boot:1;
288 unsigned dma:1;
289 unsigned id:3;
290 unsigned irq:2;
291 unsigned dmachan:2;
292 unsigned parity:1;
293 } fields;
294 unsigned short port;
295 } aha152x_config ;
296
297 #define cf_parity fields.parity
298 #define cf_dmachan fields.dmachan
299 #define cf_irq fields.irq
300 #define cf_id fields.id
301 #define cf_dma fields.dma
302 #define cf_boot fields.boot
303 #define cf_msgclasses fields.msgclasses
304 #define cf_syncneg fields.syncneg
305 #define cf_tardisc fields.tardisc
306 #define cf_port port
307
308
309
310 #define SETPORT(PORT, VAL) \
311 outb( (VAL), (PORT) )
312
313 #define SETPORTP(PORT, VAL) \
314 outb_p( (VAL), (PORT) )
315
316 #define SETPORTW(PORT, VAL) \
317 outw( (VAL), (PORT) )
318
319 #define GETPORT(PORT) \
320 inb( PORT )
321
322 #define GETPORTW(PORT) \
323 inw( PORT )
324
325 #define SETBITS(PORT, BITS) \
326 outb( (inb(PORT) | (BITS)), (PORT) )
327
328 #define CLRBITS(PORT, BITS) \
329 outb( (inb(PORT) & ~(BITS)), (PORT) )
330
331 #define CLRSETBITS(PORT, CLR, SET) \
332 outb( (inb(PORT) & ~(CLR)) | (SET) , (PORT) )
333
334 #define TESTHI(PORT, BITS) \
335 ((inb(PORT) & (BITS)) == BITS)
336
337 #define TESTLO(PORT, BITS) \
338 ((inb(PORT) & (BITS)) == 0)
339
340 #ifdef DEBUG_AHA152X
341 enum {
342 debug_skipports =0x0001,
343 debug_queue =0x0002,
344 debug_intr =0x0004,
345 debug_selection =0x0008,
346 debug_msgo =0x0010,
347 debug_msgi =0x0020,
348 debug_status =0x0040,
349 debug_cmd =0x0080,
350 debug_datai =0x0100,
351 debug_datao =0x0200,
352 debug_abort =0x0400,
353 debug_done =0x0800,
354 debug_biosparam =0x1000,
355 debug_phases =0x2000,
356 debug_queues =0x4000,
357 debug_reset =0x8000,
358 };
359 #endif
360
361 #endif