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