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