0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef FAS216_H
0010 #define FAS216_H
0011
0012 #include <scsi/scsi_eh.h>
0013
0014 #include "queue.h"
0015 #include "msgqueue.h"
0016
0017
0018
0019
0020 #define REG_CTCL (0)
0021 #define REG_STCL (0)
0022
0023
0024 #define REG_CTCM (1)
0025 #define REG_STCM (1)
0026
0027
0028 #define REG_FF (2)
0029
0030
0031 #define REG_CMD (3)
0032 #define CMD_NOP 0x00
0033 #define CMD_FLUSHFIFO 0x01
0034 #define CMD_RESETCHIP 0x02
0035 #define CMD_RESETSCSI 0x03
0036
0037 #define CMD_TRANSFERINFO 0x10
0038 #define CMD_INITCMDCOMPLETE 0x11
0039 #define CMD_MSGACCEPTED 0x12
0040 #define CMD_PADBYTES 0x18
0041 #define CMD_SETATN 0x1a
0042 #define CMD_RSETATN 0x1b
0043
0044 #define CMD_SELECTWOATN 0x41
0045 #define CMD_SELECTATN 0x42
0046 #define CMD_SELECTATNSTOP 0x43
0047 #define CMD_ENABLESEL 0x44
0048 #define CMD_DISABLESEL 0x45
0049 #define CMD_SELECTATN3 0x46
0050 #define CMD_RESEL3 0x47
0051
0052 #define CMD_WITHDMA 0x80
0053
0054
0055 #define REG_STAT (4)
0056 #define STAT_IO (1 << 0)
0057 #define STAT_CD (1 << 1)
0058 #define STAT_MSG (1 << 2)
0059 #define STAT_TRANSFERDONE (1 << 3)
0060 #define STAT_TRANSFERCNTZ (1 << 4)
0061 #define STAT_PARITYERROR (1 << 5)
0062 #define STAT_REALBAD (1 << 6)
0063 #define STAT_INT (1 << 7)
0064
0065 #define STAT_BUSMASK (STAT_MSG|STAT_CD|STAT_IO)
0066 #define STAT_DATAOUT (0)
0067 #define STAT_DATAIN (STAT_IO)
0068 #define STAT_COMMAND (STAT_CD)
0069 #define STAT_STATUS (STAT_CD|STAT_IO)
0070 #define STAT_MESGOUT (STAT_MSG|STAT_CD)
0071 #define STAT_MESGIN (STAT_MSG|STAT_CD|STAT_IO)
0072
0073
0074 #define REG_SDID (4)
0075 #define BUSID(target) ((target) & 7)
0076
0077
0078 #define REG_INST (5)
0079 #define INST_SELWOATN (1 << 0)
0080 #define INST_SELATN (1 << 1)
0081 #define INST_RESELECTED (1 << 2)
0082 #define INST_FUNCDONE (1 << 3)
0083 #define INST_BUSSERVICE (1 << 4)
0084 #define INST_DISCONNECT (1 << 5)
0085 #define INST_ILLEGALCMD (1 << 6)
0086 #define INST_BUSRESET (1 << 7)
0087
0088
0089 #define REG_STIM (5)
0090
0091
0092 #define REG_IS (6)
0093 #define IS_BITS 0x07
0094 #define IS_SELARB 0x00
0095 #define IS_MSGBYTESENT 0x01
0096 #define IS_NOTCOMMAND 0x02
0097 #define IS_EARLYPHASE 0x03
0098 #define IS_COMPLETE 0x04
0099 #define IS_SOF 0x08
0100
0101
0102 #define REG_STP (6)
0103
0104
0105 #define REG_SOF (7)
0106
0107
0108 #define REG_CFIS (7)
0109 #define CFIS_CF 0x1f
0110 #define CFIS_IS 0xe0
0111
0112
0113 #define REG_CNTL1 (8)
0114 #define CNTL1_CID (7 << 0)
0115 #define CNTL1_STE (1 << 3)
0116 #define CNTL1_PERE (1 << 4)
0117 #define CNTL1_PTE (1 << 5)
0118 #define CNTL1_DISR (1 << 6)
0119 #define CNTL1_ETM (1 << 7)
0120
0121
0122 #define REG_CLKF (9)
0123 #define CLKF_F37MHZ 0x00
0124 #define CLKF_F10MHZ 0x02
0125 #define CLKF_F12MHZ 0x03
0126 #define CLKF_F17MHZ 0x04
0127 #define CLKF_F22MHZ 0x05
0128 #define CLKF_F27MHZ 0x06
0129 #define CLKF_F32MHZ 0x07
0130
0131
0132 #define REG_FTM (10)
0133 #define TEST_FTM 0x01
0134 #define TEST_FIM 0x02
0135 #define TEST_FHI 0x04
0136
0137
0138 #define REG_CNTL2 (11)
0139 #define CNTL2_PGDP (1 << 0)
0140 #define CNTL2_PGRP (1 << 1)
0141 #define CNTL2_ACDPE (1 << 2)
0142 #define CNTL2_S2FE (1 << 3)
0143 #define CNTL2_TSDR (1 << 4)
0144 #define CNTL2_SBO (1 << 5)
0145 #define CNTL2_ENF (1 << 6)
0146 #define CNTL2_DAE (1 << 7)
0147
0148
0149 #define REG_CNTL3 (12)
0150 #define CNTL3_BS8 (1 << 0)
0151 #define CNTL3_MDM (1 << 1)
0152 #define CNTL3_LBTM (1 << 2)
0153 #define CNTL3_FASTCLK (1 << 3)
0154 #define CNTL3_FASTSCSI (1 << 4)
0155 #define CNTL3_G2CB (1 << 5)
0156 #define CNTL3_QTAG (1 << 6)
0157 #define CNTL3_ADIDCHK (1 << 7)
0158
0159
0160 #define REG_CTCH (14)
0161 #define REG_STCH (14)
0162
0163
0164 #define REG_ID (14)
0165
0166
0167 #define REG_DAL (15)
0168
0169 typedef enum {
0170 PHASE_IDLE,
0171 PHASE_SELECTION,
0172 PHASE_SELSTEPS,
0173 PHASE_COMMAND,
0174 PHASE_MESSAGESENT,
0175 PHASE_DATAOUT,
0176 PHASE_DATAIN,
0177 PHASE_MSGIN,
0178 PHASE_MSGIN_DISCONNECT,
0179 PHASE_MSGOUT,
0180 PHASE_MSGOUT_EXPECT,
0181 PHASE_STATUS,
0182 PHASE_DONE
0183 } phase_t;
0184
0185 typedef enum {
0186 DMA_OUT,
0187 DMA_IN
0188 } fasdmadir_t;
0189
0190 typedef enum {
0191 fasdma_none,
0192 fasdma_pio,
0193 fasdma_pseudo,
0194 fasdma_real_block,
0195 fasdma_real_all
0196 } fasdmatype_t;
0197
0198 typedef enum {
0199 neg_wait,
0200 neg_inprogress,
0201 neg_complete,
0202 neg_targcomplete,
0203 neg_invalid
0204 } neg_t;
0205
0206 #define MAGIC 0x441296bdUL
0207 #define NR_MSGS 8
0208
0209 #define FASCAP_DMA (1 << 0)
0210 #define FASCAP_PSEUDODMA (1 << 1)
0211
0212 typedef struct {
0213 unsigned long magic_start;
0214 spinlock_t host_lock;
0215 struct Scsi_Host *host;
0216 struct scsi_cmnd *SCpnt;
0217 struct scsi_cmnd *origSCpnt;
0218 struct scsi_cmnd *reqSCpnt;
0219 struct scsi_cmnd *rstSCpnt;
0220 struct scsi_cmnd *pending_SCpnt[8];
0221 int next_pending;
0222
0223
0224
0225
0226 wait_queue_head_t eh_wait;
0227 struct timer_list eh_timer;
0228 unsigned int rst_dev_status;
0229 unsigned int rst_bus_status;
0230
0231
0232 struct {
0233 phase_t phase;
0234 void __iomem *io_base;
0235 unsigned int io_shift;
0236 unsigned char cfg[4];
0237 const char *type;
0238 unsigned int irq;
0239 int dma;
0240
0241 struct scsi_pointer SCp;
0242
0243 MsgQueue_t msgs;
0244
0245 unsigned int async_stp;
0246 unsigned char msgin_fifo;
0247 unsigned char message[256];
0248
0249 unsigned char disconnectable:1;
0250 unsigned char aborting:1;
0251 } scsi;
0252
0253
0254 struct {
0255 unsigned int queues;
0256 unsigned int removes;
0257 unsigned int fins;
0258 unsigned int reads;
0259 unsigned int writes;
0260 unsigned int miscs;
0261 unsigned int disconnects;
0262 unsigned int aborts;
0263 unsigned int bus_resets;
0264 unsigned int host_resets;
0265 } stats;
0266
0267
0268 struct {
0269 unsigned char clockrate;
0270 unsigned char select_timeout;
0271 unsigned char sync_max_depth;
0272 unsigned char wide_max_size;
0273 unsigned char cntl3;
0274 unsigned int asyncperiod;
0275 unsigned int capabilities;
0276 unsigned int disconnect_ok:1;
0277 } ifcfg;
0278
0279
0280 struct {
0281 Queue_t issue;
0282 Queue_t disconnected;
0283 } queues;
0284
0285
0286 struct fas216_device {
0287 unsigned char disconnect_ok:1;
0288 unsigned char parity_enabled:1;
0289 unsigned char parity_check:1;
0290 unsigned char period;
0291 unsigned char stp;
0292 unsigned char sof;
0293 unsigned char wide_xfer;
0294 neg_t sync_state;
0295 neg_t wide_state;
0296 } device[8];
0297 unsigned long busyluns[64/sizeof(unsigned long)];
0298
0299
0300 struct {
0301 fasdmatype_t transfer_type;
0302 fasdmatype_t (*setup) (struct Scsi_Host *host, struct scsi_pointer *SCp, fasdmadir_t direction, fasdmatype_t min_dma);
0303 void (*pseudo)(struct Scsi_Host *host, struct scsi_pointer *SCp, fasdmadir_t direction, int transfer);
0304 void (*stop) (struct Scsi_Host *host, struct scsi_pointer *SCp);
0305 } dma;
0306
0307
0308 int internal_done;
0309 struct scsi_eh_save ses;
0310 unsigned long magic_end;
0311 } FAS216_Info;
0312
0313
0314 struct fas216_cmd_priv {
0315
0316
0317
0318 struct scsi_pointer scsi_pointer;
0319 void (*scsi_done)(struct scsi_cmnd *cmd);
0320 };
0321
0322 static inline struct fas216_cmd_priv *fas216_cmd_priv(struct scsi_cmnd *cmd)
0323 {
0324 return scsi_cmd_priv(cmd);
0325 }
0326
0327
0328
0329
0330
0331
0332 extern int fas216_init (struct Scsi_Host *instance);
0333
0334
0335
0336
0337
0338
0339 extern int fas216_add (struct Scsi_Host *instance, struct device *dev);
0340
0341
0342
0343
0344
0345
0346
0347 extern int fas216_queue_command(struct Scsi_Host *h, struct scsi_cmnd *SCpnt);
0348
0349
0350
0351
0352
0353
0354
0355 extern int fas216_noqueue_command(struct Scsi_Host *, struct scsi_cmnd *);
0356
0357
0358
0359
0360
0361 extern irqreturn_t fas216_intr (FAS216_Info *info);
0362
0363 extern void fas216_remove (struct Scsi_Host *instance);
0364
0365
0366
0367
0368
0369
0370 extern void fas216_release (struct Scsi_Host *instance);
0371
0372 extern void fas216_print_host(FAS216_Info *info, struct seq_file *m);
0373 extern void fas216_print_stats(FAS216_Info *info, struct seq_file *m);
0374 extern void fas216_print_devices(FAS216_Info *info, struct seq_file *m);
0375
0376
0377
0378
0379
0380
0381 extern int fas216_eh_abort(struct scsi_cmnd *SCpnt);
0382
0383
0384
0385
0386
0387
0388 extern int fas216_eh_device_reset(struct scsi_cmnd *SCpnt);
0389
0390
0391
0392
0393
0394
0395 extern int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt);
0396
0397
0398
0399
0400
0401
0402 extern int fas216_eh_host_reset(struct scsi_cmnd *SCpnt);
0403
0404 #endif