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