1
2
3
4
5
6
7
8
9 #ifndef FAS216_H
10 #define FAS216_H
11
12 #include <scsi/scsi_eh.h>
13
14 #include "queue.h"
15 #include "msgqueue.h"
16
17
18
19
20 #define REG_CTCL (0)
21 #define REG_STCL (0)
22
23
24 #define REG_CTCM (1)
25 #define REG_STCM (1)
26
27
28 #define REG_FF (2)
29
30
31 #define REG_CMD (3)
32 #define CMD_NOP 0x00
33 #define CMD_FLUSHFIFO 0x01
34 #define CMD_RESETCHIP 0x02
35 #define CMD_RESETSCSI 0x03
36
37 #define CMD_TRANSFERINFO 0x10
38 #define CMD_INITCMDCOMPLETE 0x11
39 #define CMD_MSGACCEPTED 0x12
40 #define CMD_PADBYTES 0x18
41 #define CMD_SETATN 0x1a
42 #define CMD_RSETATN 0x1b
43
44 #define CMD_SELECTWOATN 0x41
45 #define CMD_SELECTATN 0x42
46 #define CMD_SELECTATNSTOP 0x43
47 #define CMD_ENABLESEL 0x44
48 #define CMD_DISABLESEL 0x45
49 #define CMD_SELECTATN3 0x46
50 #define CMD_RESEL3 0x47
51
52 #define CMD_WITHDMA 0x80
53
54
55 #define REG_STAT (4)
56 #define STAT_IO (1 << 0)
57 #define STAT_CD (1 << 1)
58 #define STAT_MSG (1 << 2)
59 #define STAT_TRANSFERDONE (1 << 3)
60 #define STAT_TRANSFERCNTZ (1 << 4)
61 #define STAT_PARITYERROR (1 << 5)
62 #define STAT_REALBAD (1 << 6)
63 #define STAT_INT (1 << 7)
64
65 #define STAT_BUSMASK (STAT_MSG|STAT_CD|STAT_IO)
66 #define STAT_DATAOUT (0)
67 #define STAT_DATAIN (STAT_IO)
68 #define STAT_COMMAND (STAT_CD)
69 #define STAT_STATUS (STAT_CD|STAT_IO)
70 #define STAT_MESGOUT (STAT_MSG|STAT_CD)
71 #define STAT_MESGIN (STAT_MSG|STAT_CD|STAT_IO)
72
73
74 #define REG_SDID (4)
75 #define BUSID(target) ((target) & 7)
76
77
78 #define REG_INST (5)
79 #define INST_SELWOATN (1 << 0)
80 #define INST_SELATN (1 << 1)
81 #define INST_RESELECTED (1 << 2)
82 #define INST_FUNCDONE (1 << 3)
83 #define INST_BUSSERVICE (1 << 4)
84 #define INST_DISCONNECT (1 << 5)
85 #define INST_ILLEGALCMD (1 << 6)
86 #define INST_BUSRESET (1 << 7)
87
88
89 #define REG_STIM (5)
90
91
92 #define REG_IS (6)
93 #define IS_BITS 0x07
94 #define IS_SELARB 0x00
95 #define IS_MSGBYTESENT 0x01
96 #define IS_NOTCOMMAND 0x02
97 #define IS_EARLYPHASE 0x03
98 #define IS_COMPLETE 0x04
99 #define IS_SOF 0x08
100
101
102 #define REG_STP (6)
103
104
105 #define REG_SOF (7)
106
107
108 #define REG_CFIS (7)
109 #define CFIS_CF 0x1f
110 #define CFIS_IS 0xe0
111
112
113 #define REG_CNTL1 (8)
114 #define CNTL1_CID (7 << 0)
115 #define CNTL1_STE (1 << 3)
116 #define CNTL1_PERE (1 << 4)
117 #define CNTL1_PTE (1 << 5)
118 #define CNTL1_DISR (1 << 6)
119 #define CNTL1_ETM (1 << 7)
120
121
122 #define REG_CLKF (9)
123 #define CLKF_F37MHZ 0x00
124 #define CLKF_F10MHZ 0x02
125 #define CLKF_F12MHZ 0x03
126 #define CLKF_F17MHZ 0x04
127 #define CLKF_F22MHZ 0x05
128 #define CLKF_F27MHZ 0x06
129 #define CLKF_F32MHZ 0x07
130
131
132 #define REG_FTM (10)
133 #define TEST_FTM 0x01
134 #define TEST_FIM 0x02
135 #define TEST_FHI 0x04
136
137
138 #define REG_CNTL2 (11)
139 #define CNTL2_PGDP (1 << 0)
140 #define CNTL2_PGRP (1 << 1)
141 #define CNTL2_ACDPE (1 << 2)
142 #define CNTL2_S2FE (1 << 3)
143 #define CNTL2_TSDR (1 << 4)
144 #define CNTL2_SBO (1 << 5)
145 #define CNTL2_ENF (1 << 6)
146 #define CNTL2_DAE (1 << 7)
147
148
149 #define REG_CNTL3 (12)
150 #define CNTL3_BS8 (1 << 0)
151 #define CNTL3_MDM (1 << 1)
152 #define CNTL3_LBTM (1 << 2)
153 #define CNTL3_FASTCLK (1 << 3)
154 #define CNTL3_FASTSCSI (1 << 4)
155 #define CNTL3_G2CB (1 << 5)
156 #define CNTL3_QTAG (1 << 6)
157 #define CNTL3_ADIDCHK (1 << 7)
158
159
160 #define REG_CTCH (14)
161 #define REG_STCH (14)
162
163
164 #define REG_ID (14)
165
166
167 #define REG_DAL (15)
168
169 typedef enum {
170 PHASE_IDLE,
171 PHASE_SELECTION,
172 PHASE_SELSTEPS,
173 PHASE_COMMAND,
174 PHASE_MESSAGESENT,
175 PHASE_DATAOUT,
176 PHASE_DATAIN,
177 PHASE_MSGIN,
178 PHASE_MSGIN_DISCONNECT,
179 PHASE_MSGOUT,
180 PHASE_MSGOUT_EXPECT,
181 PHASE_STATUS,
182 PHASE_DONE
183 } phase_t;
184
185 typedef enum {
186 DMA_OUT,
187 DMA_IN
188 } fasdmadir_t;
189
190 typedef enum {
191 fasdma_none,
192 fasdma_pio,
193 fasdma_pseudo,
194 fasdma_real_block,
195 fasdma_real_all
196 } fasdmatype_t;
197
198 typedef enum {
199 neg_wait,
200 neg_inprogress,
201 neg_complete,
202 neg_targcomplete,
203 neg_invalid
204 } neg_t;
205
206 #define MAGIC 0x441296bdUL
207 #define NR_MSGS 8
208
209 #define FASCAP_DMA (1 << 0)
210 #define FASCAP_PSEUDODMA (1 << 1)
211
212 typedef struct {
213 unsigned long magic_start;
214 spinlock_t host_lock;
215 struct Scsi_Host *host;
216 struct scsi_cmnd *SCpnt;
217 struct scsi_cmnd *origSCpnt;
218 struct scsi_cmnd *reqSCpnt;
219 struct scsi_cmnd *rstSCpnt;
220 struct scsi_cmnd *pending_SCpnt[8];
221 int next_pending;
222
223
224
225
226 wait_queue_head_t eh_wait;
227 struct timer_list eh_timer;
228 unsigned int rst_dev_status;
229 unsigned int rst_bus_status;
230
231
232 struct {
233 phase_t phase;
234 void __iomem *io_base;
235 unsigned int io_shift;
236 unsigned char cfg[4];
237 const char *type;
238 unsigned int irq;
239 int dma;
240
241 struct scsi_pointer SCp;
242
243 MsgQueue_t msgs;
244
245 unsigned int async_stp;
246 unsigned char msgin_fifo;
247 unsigned char message[256];
248
249 unsigned char disconnectable:1;
250 unsigned char aborting:1;
251 } scsi;
252
253
254 struct {
255 unsigned int queues;
256 unsigned int removes;
257 unsigned int fins;
258 unsigned int reads;
259 unsigned int writes;
260 unsigned int miscs;
261 unsigned int disconnects;
262 unsigned int aborts;
263 unsigned int bus_resets;
264 unsigned int host_resets;
265 } stats;
266
267
268 struct {
269 unsigned char clockrate;
270 unsigned char select_timeout;
271 unsigned char sync_max_depth;
272 unsigned char wide_max_size;
273 unsigned char cntl3;
274 unsigned int asyncperiod;
275 unsigned int capabilities;
276 unsigned int disconnect_ok:1;
277 } ifcfg;
278
279
280 struct {
281 Queue_t issue;
282 Queue_t disconnected;
283 } queues;
284
285
286 struct fas216_device {
287 unsigned char disconnect_ok:1;
288 unsigned char parity_enabled:1;
289 unsigned char parity_check:1;
290 unsigned char period;
291 unsigned char stp;
292 unsigned char sof;
293 unsigned char wide_xfer;
294 neg_t sync_state;
295 neg_t wide_state;
296 } device[8];
297 unsigned long busyluns[64/sizeof(unsigned long)];
298
299
300 struct {
301 fasdmatype_t transfer_type;
302 fasdmatype_t (*setup) (struct Scsi_Host *host, struct scsi_pointer *SCp, fasdmadir_t direction, fasdmatype_t min_dma);
303 void (*pseudo)(struct Scsi_Host *host, struct scsi_pointer *SCp, fasdmadir_t direction, int transfer);
304 void (*stop) (struct Scsi_Host *host, struct scsi_pointer *SCp);
305 } dma;
306
307
308 int internal_done;
309 struct scsi_eh_save ses;
310 unsigned long magic_end;
311 } FAS216_Info;
312
313
314
315
316
317
318 extern int fas216_init (struct Scsi_Host *instance);
319
320
321
322
323
324
325 extern int fas216_add (struct Scsi_Host *instance, struct device *dev);
326
327
328
329
330
331
332
333 extern int fas216_queue_command(struct Scsi_Host *h, struct scsi_cmnd *SCpnt);
334
335
336
337
338
339
340
341 extern int fas216_noqueue_command(struct Scsi_Host *, struct scsi_cmnd *);
342
343
344
345
346
347 extern irqreturn_t fas216_intr (FAS216_Info *info);
348
349 extern void fas216_remove (struct Scsi_Host *instance);
350
351
352
353
354
355
356 extern void fas216_release (struct Scsi_Host *instance);
357
358 extern void fas216_print_host(FAS216_Info *info, struct seq_file *m);
359 extern void fas216_print_stats(FAS216_Info *info, struct seq_file *m);
360 extern void fas216_print_devices(FAS216_Info *info, struct seq_file *m);
361
362
363
364
365
366
367 extern int fas216_eh_abort(struct scsi_cmnd *SCpnt);
368
369
370
371
372
373
374 extern int fas216_eh_device_reset(struct scsi_cmnd *SCpnt);
375
376
377
378
379
380
381 extern int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt);
382
383
384
385
386
387
388 extern int fas216_eh_host_reset(struct scsi_cmnd *SCpnt);
389
390 #endif