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