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