7f3ad6216243881c98f0a912f42a47b346bcd89d
[linux-2.6.git] / drivers / scsi / tmscsim.h
1 /***********************************************************************
2 ;*      File Name : TMSCSIM.H                                          *
3 ;*                  TEKRAM DC-390(T) PCI SCSI Bus Master Host Adapter  *
4 ;*                  Device Driver                                      *
5 ;***********************************************************************/
6 /* $Id: tmscsim.h,v 2.15.2.3 2000/11/17 20:52:27 garloff Exp $ */
7
8 #ifndef _TMSCSIM_H
9 #define _TMSCSIM_H
10
11 #include <linux/types.h>
12 #include <linux/config.h>
13
14 #define SCSI_IRQ_NONE 255
15
16 #define MAX_ADAPTER_NUM         4
17 #define MAX_SG_LIST_BUF         16      /* Not used */
18 #define MAX_CMD_PER_LUN         32
19 #define MAX_CMD_QUEUE           MAX_CMD_PER_LUN+MAX_CMD_PER_LUN/2+1     
20 #define MAX_SCSI_ID             8
21 #define MAX_SRB_CNT             MAX_CMD_QUEUE+1 /* Max number of started commands */
22
23 #define SEL_TIMEOUT             153     /* 250 ms selection timeout (@ 40 MHz) */
24
25 #define pci_dma_lo32(a)                 (a & 0xffffffff)
26
27 typedef u8              UCHAR;  /*  8 bits */
28 typedef u16             USHORT; /* 16 bits */
29 typedef u32             UINT;   /* 32 bits */
30 typedef unsigned long   ULONG;  /* 32/64 bits */
31
32 typedef UCHAR           *PUCHAR;
33 typedef USHORT          *PUSHORT;
34 typedef UINT            *PUINT;
35 typedef ULONG           *PULONG;
36 typedef Scsi_Host_Template      *PSHT;
37 typedef struct Scsi_Host        *PSH;
38 typedef Scsi_Device     *PSCSIDEV;
39 typedef Scsi_Cmnd       *PSCSICMD;
40 typedef void            *PVOID;
41 typedef struct scatterlist  *PSGL, SGL;
42
43
44 /*;-----------------------------------------------------------------------*/
45 typedef  struct  _SyncMsg
46 {
47 UCHAR           ExtendMsg;
48 UCHAR           ExtMsgLen;
49 UCHAR           SyncXferReq;
50 UCHAR           Period;
51 UCHAR           ReqOffset;
52 } SyncMsg;
53 /*;-----------------------------------------------------------------------*/
54 typedef  struct  _Capacity
55 {
56 ULONG           BlockCount;
57 ULONG           BlockLength;
58 } Capacity;
59 /*;-----------------------------------------------------------------------*/
60 typedef  struct  _SGentry
61 {
62 ULONG           SGXferDataPtr;
63 ULONG           SGXferDataLen;
64 } SGentry;
65
66 typedef  struct  _SGentry1
67 {
68 ULONG           SGXLen;
69 ULONG           SGXPtr;
70 } SGentry1, *PSGE;
71
72
73 /*
74 ;-----------------------------------------------------------------------
75 ; SCSI Request Block
76 ;-----------------------------------------------------------------------
77 */
78 struct  _SRB
79 {
80 //UCHAR         CmdBlock[12];
81
82 struct _SRB     *pNextSRB;
83 struct _DCB     *pSRBDCB;
84 PSCSICMD        pcmd;
85 PSGL            pSegmentList;
86
87 /* 0x10: */
88 SGL             Segmentx;       /* make a one entry of S/G list table */
89
90 /* 0x1c: */
91 ULONG           SGBusAddr;      /*;a segment starting address as seen by AM53C974A*/
92 ULONG           SGToBeXferLen;  /*; to be xfer length */
93 ULONG           TotalXferredLen;
94 ULONG           SavedTotXLen;
95 UINT            SRBState;
96
97 /* 0x30: */
98 UCHAR           SRBStatus;
99 UCHAR           SRBFlag;        /*; b0-AutoReqSense,b6-Read,b7-write */
100                                 /*; b4-settimeout,b5-Residual valid */
101 UCHAR           AdaptStatus;
102 UCHAR           TargetStatus;
103
104 UCHAR           ScsiPhase;
105 UCHAR           TagNumber;
106 UCHAR           SGIndex;
107 UCHAR           SGcount;
108
109 /* 0x38: */
110 UCHAR           MsgCnt;
111 UCHAR           EndMessage;
112 UCHAR           RetryCnt;
113 UCHAR           SavedSGCount;                   
114
115 ULONG           Saved_Ptr;
116
117 /* 0x40: */
118 UCHAR           MsgInBuf[6];
119 UCHAR           MsgOutBuf[6];
120
121 //UCHAR         IORBFlag;       /*;81h-Reset, 2-retry */
122 /* 0x4c: */
123 };
124
125
126 typedef  struct  _SRB    DC390_SRB, *PSRB;
127
128 /*
129 ;-----------------------------------------------------------------------
130 ; Device Control Block
131 ;-----------------------------------------------------------------------
132 */
133 struct  _DCB
134 {
135 struct _DCB     *pNextDCB;
136 struct _ACB     *pDCBACB;
137
138 /* Aborted Commands */
139 //PSCSICMD      AboIORBhead;
140 //PSCSICMD      AboIORBtail;
141 //ULONG         AboIORBcnt;
142
143 /* 0x08: */
144 /* Queued SRBs */
145 PSRB            pWaitingSRB;
146 PSRB            pWaitLast;
147 PSRB            pGoingSRB;
148 PSRB            pGoingLast;
149 PSRB            pActiveSRB;
150 UCHAR           WaitSRBCnt;     /* Not used */
151 UCHAR           GoingSRBCnt;
152
153 UCHAR           DevType;
154 UCHAR           MaxCommand;
155
156 /* 0x20: */
157 UINT            TagMask;
158
159 UCHAR           TargetID;       /*; SCSI Target ID  (SCSI Only) */
160 UCHAR           TargetLUN;      /*; SCSI Log.  Unit (SCSI Only) */
161 UCHAR           DevMode;
162 UCHAR           DCBFlag;
163
164 UCHAR           CtrlR1;
165 UCHAR           CtrlR3;
166 UCHAR           CtrlR4;
167 UCHAR           Inquiry7;
168
169 /* 0x2c: */
170 UCHAR           SyncMode;       /*; 0:async mode */
171 UCHAR           NegoPeriod;     /*;for nego. */
172 UCHAR           SyncPeriod;     /*;for reg. */
173 UCHAR           SyncOffset;     /*;for reg. and nego.(low nibble) */
174
175 /* 0x30:*/
176 //UCHAR         InqDataBuf[8];
177 //UCHAR         CapacityBuf[8];
178 ///* 0x40: */
179 };
180
181 typedef  struct  _DCB    DC390_DCB, *PDCB;
182 /*
183 ;-----------------------------------------------------------------------
184 ; Adapter Control Block
185 ;-----------------------------------------------------------------------
186 */
187 struct  _ACB
188 {
189 PSH             pScsiHost;
190 struct _ACB     *pNextACB;
191 USHORT          IOPortBase;
192 UCHAR           IRQLevel;
193 UCHAR           status;
194
195 UCHAR           SRBCount;
196 UCHAR           AdapterIndex;   /*; nth Adapter this driver */
197 UCHAR           DCBCnt;
198
199 UCHAR           TagMaxNum;
200 UCHAR           ACBFlag;
201 UCHAR           Gmode2;
202 UCHAR           scan_devices;
203
204 PDCB            pLinkDCB;
205 PDCB            pLastDCB;
206 PDCB            pDCBRunRobin;
207
208 PDCB            pActiveDCB;
209 PSRB            pFreeSRB;
210 PSRB            pTmpSRB;
211
212 UCHAR           msgin123[4];
213 UCHAR           DCBmap[MAX_SCSI_ID];
214 UCHAR           Connected;
215 UCHAR           pad;
216
217 #if defined(USE_SPINLOCKS) && USE_SPINLOCKS > 1 && (defined(CONFIG_SMP) || DEBUG_SPINLOCKS > 0)
218 spinlock_t      lock;
219 #endif
220 UCHAR           sel_timeout;
221 UCHAR           glitch_cfg;
222
223 UCHAR           MsgLen;
224 UCHAR           Ignore_IRQ;     /* Not used */
225
226 PDEVDECL1;                      /* Pointer to PCI cfg. space */
227
228 ULONG           Cmds;
229 UINT            SelLost;
230 UINT            SelConn;
231 UINT            CmdInQ;
232 UINT            CmdOutOfSRB;
233         
234 struct timer_list       Waiting_Timer;
235
236 DC390_SRB       TmpSRB;
237 DC390_SRB       SRB_array[MAX_SRB_CNT];         /* 50 SRBs */
238 };
239
240 typedef  struct  _ACB    DC390_ACB, *PACB;
241
242 /*;-----------------------------------------------------------------------*/
243
244
245 #define BIT31   0x80000000
246 #define BIT30   0x40000000
247 #define BIT29   0x20000000
248 #define BIT28   0x10000000
249 #define BIT27   0x08000000
250 #define BIT26   0x04000000
251 #define BIT25   0x02000000
252 #define BIT24   0x01000000
253 #define BIT23   0x00800000
254 #define BIT22   0x00400000
255 #define BIT21   0x00200000
256 #define BIT20   0x00100000
257 #define BIT19   0x00080000
258 #define BIT18   0x00040000
259 #define BIT17   0x00020000
260 #define BIT16   0x00010000
261 #define BIT15   0x00008000
262 #define BIT14   0x00004000
263 #define BIT13   0x00002000
264 #define BIT12   0x00001000
265 #define BIT11   0x00000800
266 #define BIT10   0x00000400
267 #define BIT9    0x00000200
268 #define BIT8    0x00000100
269 #define BIT7    0x00000080
270 #define BIT6    0x00000040
271 #define BIT5    0x00000020
272 #define BIT4    0x00000010
273 #define BIT3    0x00000008
274 #define BIT2    0x00000004
275 #define BIT1    0x00000002
276 #define BIT0    0x00000001
277
278 /*;---UnitCtrlFlag */
279 #define UNIT_ALLOCATED  BIT0
280 #define UNIT_INFO_CHANGED BIT1
281 #define FORMATING_MEDIA BIT2
282 #define UNIT_RETRY      BIT3
283
284 /*;---UnitFlags */
285 #define DASD_SUPPORT    BIT0
286 #define SCSI_SUPPORT    BIT1
287 #define ASPI_SUPPORT    BIT2
288
289 /*;----SRBState machine definition */
290 #define SRB_FREE        0
291 #define SRB_WAIT        BIT0
292 #define SRB_READY       BIT1
293 #define SRB_MSGOUT      BIT2    /*;arbitration+msg_out 1st byte*/
294 #define SRB_MSGIN       BIT3
295 #define SRB_MSGIN_MULTI BIT4
296 #define SRB_COMMAND     BIT5
297 #define SRB_START_      BIT6    /*;arbitration+msg_out+command_out*/
298 #define SRB_DISCONNECT  BIT7
299 #define SRB_DATA_XFER   BIT8
300 #define SRB_XFERPAD     BIT9
301 #define SRB_STATUS      BIT10
302 #define SRB_COMPLETED   BIT11
303 #define SRB_ABORT_SENT  BIT12
304 #define DO_SYNC_NEGO    BIT13
305 #define SRB_UNEXPECT_RESEL BIT14
306
307 /*;---SRBstatus */
308 #define SRB_OK          BIT0
309 #define ABORTION        BIT1
310 #define OVER_RUN        BIT2
311 #define UNDER_RUN       BIT3
312 #define PARITY_ERROR    BIT4
313 #define SRB_ERROR       BIT5
314
315 /*;---ACBFlag */
316 #define RESET_DEV       BIT0
317 #define RESET_DETECT    BIT1
318 #define RESET_DONE      BIT2
319
320 /*;---DCBFlag */
321 #define ABORT_DEV_      BIT0
322
323 /*;---SRBFlag */
324 #define DATAOUT         BIT7
325 #define DATAIN          BIT6
326 #define RESIDUAL_VALID  BIT5
327 #define ENABLE_TIMER    BIT4
328 #define RESET_DEV0      BIT2
329 #define ABORT_DEV       BIT1
330 #define AUTO_REQSENSE   BIT0
331
332 /*;---Adapter status */
333 #define H_STATUS_GOOD    0
334 #define H_SEL_TIMEOUT    0x11
335 #define H_OVER_UNDER_RUN 0x12
336 #define H_UNEXP_BUS_FREE 0x13
337 #define H_TARGET_PHASE_F 0x14
338 #define H_INVALID_CCB_OP 0x16
339 #define H_LINK_CCB_BAD   0x17
340 #define H_BAD_TARGET_DIR 0x18
341 #define H_DUPLICATE_CCB  0x19
342 #define H_BAD_CCB_OR_SG  0x1A
343 #define H_ABORT          0x0FF
344
345 /*; SCSI Status byte codes*/ 
346 /* The values defined in include/scsi/scsi.h, to be shifted << 1 */
347
348 #define SCSI_STAT_UNEXP_BUS_F   0xFD    /*;  Unexpect Bus Free */
349 #define SCSI_STAT_BUS_RST_DETECT 0xFE   /*;  Scsi Bus Reset detected */
350 #define SCSI_STAT_SEL_TIMEOUT   0xFF    /*;  Selection Time out */
351
352 /* cmd->result */
353 #define RES_TARGET              0x000000FF      /* Target State */
354 #define RES_TARGET_LNX          STATUS_MASK     /* Only official ... */
355 #define RES_ENDMSG              0x0000FF00      /* End Message */
356 #define RES_DID                 0x00FF0000      /* DID_ codes */
357 #define RES_DRV                 0xFF000000      /* DRIVER_ codes */
358
359 #define MK_RES(drv,did,msg,tgt) ((int)(drv)<<24 | (int)(did)<<16 | (int)(msg)<<8 | (int)(tgt))
360 #define MK_RES_LNX(drv,did,msg,tgt) ((int)(drv)<<24 | (int)(did)<<16 | (int)(msg)<<8 | (int)(tgt)<<1)
361
362 #define SET_RES_TARGET(who,tgt) { who &= ~RES_TARGET; who |= (int)(tgt); }
363 #define SET_RES_TARGET_LNX(who,tgt) { who &= ~RES_TARGET_LNX; who |= (int)(tgt) << 1; }
364 #define SET_RES_MSG(who,msg) { who &= ~RES_ENDMSG; who |= (int)(msg) << 8; }
365 #define SET_RES_DID(who,did) { who &= ~RES_DID; who |= (int)(did) << 16; }
366 #define SET_RES_DRV(who,drv) { who &= ~RES_DRV; who |= (int)(drv) << 24; }
367
368 /*;---Sync_Mode */
369 #define SYNC_DISABLE    0
370 #define SYNC_ENABLE     BIT0
371 #define SYNC_NEGO_DONE  BIT1
372 #define WIDE_ENABLE     BIT2    /* Not used ;-) */
373 #define WIDE_NEGO_DONE  BIT3    /* Not used ;-) */
374 #define EN_TAG_QUEUEING BIT4
375 #define EN_ATN_STOP     BIT5
376
377 #define SYNC_NEGO_OFFSET 15
378
379 /*;---SCSI bus phase*/
380 #define SCSI_DATA_OUT   0
381 #define SCSI_DATA_IN    1
382 #define SCSI_COMMAND    2
383 #define SCSI_STATUS_    3
384 #define SCSI_NOP0       4
385 #define SCSI_NOP1       5
386 #define SCSI_MSG_OUT    6
387 #define SCSI_MSG_IN     7
388
389 /*;----SCSI MSG BYTE*/ /* see scsi/scsi.h */ /* One is missing ! */
390 #define ABORT_TAG       0x0d
391
392 /*
393  *      SISC query queue
394  */
395 typedef struct {
396         dma_addr_t              saved_dma_handle;
397 } dc390_cmd_scp_t;
398
399 /*
400 **  Inquiry Data format
401 */
402
403 typedef struct  _SCSIInqData { /* INQUIRY */
404
405         UCHAR    DevType;               /* Periph Qualifier & Periph Dev Type*/
406         UCHAR    RMB_TypeMod;           /* rem media bit & Dev Type Modifier */
407         UCHAR    Vers;                  /* ISO, ECMA, & ANSI versions        */
408         UCHAR    RDF;                   /* AEN, TRMIOP, & response data format*/
409         UCHAR    AddLen;                /* length of additional data         */
410         UCHAR    Res1;                  /* reserved                          */
411         UCHAR    Res2;                  /* reserved                          */
412         UCHAR    Flags;                 /* RelADr,Wbus32,Wbus16,Sync,etc.    */
413         UCHAR    VendorID[8];           /* Vendor Identification             */
414         UCHAR    ProductID[16];         /* Product Identification            */
415         UCHAR    ProductRev[4];         /* Product Revision                  */
416
417
418 } SCSI_INQDATA, *PSCSI_INQDATA;
419
420
421 /*  Inquiry byte 0 masks */
422
423
424 #define SCSI_DEVTYPE        0x1F      /* Peripheral Device Type             */
425 #define SCSI_PERIPHQUAL     0xE0      /* Peripheral Qualifier               */
426 #define TYPE_NODEV          SCSI_DEVTYPE    /* Unknown or no device type    */
427
428
429 /*  Inquiry byte 1 mask */
430
431 #define SCSI_REMOVABLE_MEDIA  0x80    /* Removable Media bit (1=removable)  */
432
433
434 /*  Peripheral Device Type definitions */
435 /*  see include/scsi/scsi.h for the rest */
436
437 #ifndef TYPE_PRINTER
438 # define TYPE_PRINTER            0x02      /* Printer device               */
439 #endif
440 #ifndef TYPE_COMM
441 # define TYPE_COMM               0x09      /* Communications device        */
442 #endif
443
444 /*
445 ** Inquiry flag definitions (Inq data byte 7)
446 */
447
448 #define SCSI_INQ_RELADR       0x80    /* device supports relative addressing*/
449 #define SCSI_INQ_WBUS32       0x40    /* device supports 32 bit data xfers  */
450 #define SCSI_INQ_WBUS16       0x20    /* device supports 16 bit data xfers  */
451 #define SCSI_INQ_SYNC         0x10    /* device supports synchronous xfer   */
452 #define SCSI_INQ_LINKED       0x08    /* device supports linked commands    */
453 #define SCSI_INQ_CMDQUEUE     0x02    /* device supports command queueing   */
454 #define SCSI_INQ_SFTRE        0x01    /* device supports soft resets */
455
456
457 /*
458 ;==========================================================
459 ; EEPROM byte offset
460 ;==========================================================
461 */
462 typedef  struct  _EEprom
463 {
464 UCHAR   EE_MODE1;
465 UCHAR   EE_SPEED;
466 UCHAR   xx1;
467 UCHAR   xx2;
468 } EEprom, *PEEprom;
469
470 #define REAL_EE_ADAPT_SCSI_ID 64
471 #define REAL_EE_MODE2   65
472 #define REAL_EE_DELAY   66
473 #define REAL_EE_TAG_CMD_NUM     67
474
475 #define EE_ADAPT_SCSI_ID 32
476 #define EE_MODE2        33
477 #define EE_DELAY        34
478 #define EE_TAG_CMD_NUM  35
479
480 #define EE_LEN          40
481
482 /*; EE_MODE1 bits definition*/
483 #define PARITY_CHK_     BIT0
484 #define SYNC_NEGO_      BIT1
485 #define EN_DISCONNECT_  BIT2
486 #define SEND_START_     BIT3
487 #define TAG_QUEUEING_   BIT4
488
489 /*; EE_MODE2 bits definition*/
490 #define MORE2_DRV       BIT0
491 #define GREATER_1G      BIT1
492 #define RST_SCSI_BUS    BIT2
493 #define ACTIVE_NEGATION BIT3
494 #define NO_SEEK         BIT4
495 #define LUN_CHECK       BIT5
496
497 #define ENABLE_CE       1
498 #define DISABLE_CE      0
499 #define EEPROM_READ     0x80
500
501 /*
502 ;==========================================================
503 ;       AMD 53C974 Registers bit Definition
504 ;==========================================================
505 */
506 /*
507 ;====================
508 ; SCSI Register
509 ;====================
510 */
511
512 /*; Command Reg.(+0CH) (rw) */
513 #define DMA_COMMAND             BIT7
514 #define NOP_CMD                 0
515 #define CLEAR_FIFO_CMD          1
516 #define RST_DEVICE_CMD          2
517 #define RST_SCSI_BUS_CMD        3
518
519 #define INFO_XFER_CMD           0x10
520 #define INITIATOR_CMD_CMPLTE    0x11
521 #define MSG_ACCEPTED_CMD        0x12
522 #define XFER_PAD_BYTE           0x18
523 #define SET_ATN_CMD             0x1A
524 #define RESET_ATN_CMD           0x1B
525
526 #define SEL_WO_ATN              0x41    /* currently not used */
527 #define SEL_W_ATN               0x42
528 #define SEL_W_ATN_STOP          0x43
529 #define SEL_W_ATN3              0x46
530 #define EN_SEL_RESEL            0x44
531 #define DIS_SEL_RESEL           0x45    /* currently not used */
532 #define RESEL                   0x40    /* " */
533 #define RESEL_ATN3              0x47    /* " */
534
535 #define DATA_XFER_CMD           INFO_XFER_CMD
536
537
538 /*; SCSI Status Reg.(+10H) (r) */
539 #define INTERRUPT               BIT7
540 #define ILLEGAL_OP_ERR          BIT6
541 #define PARITY_ERR              BIT5
542 #define COUNT_2_ZERO            BIT4
543 #define GROUP_CODE_VALID        BIT3
544 #define SCSI_PHASE_MASK         (BIT2+BIT1+BIT0) 
545 /* BIT2: MSG phase; BIT1: C/D physe; BIT0: I/O phase */
546
547 /*; Interrupt Status Reg.(+14H) (r) */
548 #define SCSI_RESET              BIT7
549 #define INVALID_CMD             BIT6
550 #define DISCONNECTED            BIT5
551 #define SERVICE_REQUEST         BIT4
552 #define SUCCESSFUL_OP           BIT3
553 #define RESELECTED              BIT2
554 #define SEL_ATTENTION           BIT1
555 #define SELECTED                BIT0
556
557 /*; Internal State Reg.(+18H) (r) */
558 #define SYNC_OFFSET_FLAG        BIT3
559 #define INTRN_STATE_MASK        (BIT2+BIT1+BIT0)
560 /* 0x04: Sel. successful (w/o stop), 0x01: Sel. successful (w/ stop) */
561
562 /*; Clock Factor Reg.(+24H) (w) */
563 #define CLK_FREQ_40MHZ          0
564 #define CLK_FREQ_35MHZ          (BIT2+BIT1+BIT0)
565 #define CLK_FREQ_30MHZ          (BIT2+BIT1)
566 #define CLK_FREQ_25MHZ          (BIT2+BIT0)
567 #define CLK_FREQ_20MHZ          BIT2
568 #define CLK_FREQ_15MHZ          (BIT1+BIT0)
569 #define CLK_FREQ_10MHZ          BIT1
570
571 /*; Control Reg. 1(+20H) (rw) */
572 #define EXTENDED_TIMING         BIT7
573 #define DIS_INT_ON_SCSI_RST     BIT6
574 #define PARITY_ERR_REPO         BIT4
575 #define SCSI_ID_ON_BUS          (BIT2+BIT1+BIT0) /* host adapter ID */
576
577 /*; Control Reg. 2(+2CH) (rw) */
578 #define EN_FEATURE              BIT6
579 #define EN_SCSI2_CMD            BIT3
580
581 /*; Control Reg. 3(+30H) (rw) */
582 #define ID_MSG_CHECK            BIT7
583 #define EN_QTAG_MSG             BIT6
584 #define EN_GRP2_CMD             BIT5
585 #define FAST_SCSI               BIT4    /* ;10MB/SEC */
586 #define FAST_CLK                BIT3    /* ;25 - 40 MHZ */
587
588 /*; Control Reg. 4(+34H) (rw) */
589 #define EATER_12NS              0
590 #define EATER_25NS              BIT7
591 #define EATER_35NS              BIT6
592 #define EATER_0NS               (BIT7+BIT6)
593 #define REDUCED_POWER           BIT5
594 #define CTRL4_RESERVED          BIT4    /* must be 1 acc. to AM53C974.c */
595 #define NEGATE_REQACKDATA       BIT2
596 #define NEGATE_REQACK           BIT3
597
598 #define GLITCH_TO_NS(x) (((~x>>6 & 2) >> 1) | ((x>>6 & 1) << 1 ^ (x>>6 & 2)))
599 #define NS_TO_GLITCH(y) (((~y<<7) | ~((y<<6) ^ ((y<<5 & 1<<6) | ~0x40))) & 0xc0)
600
601 /*
602 ;====================
603 ; DMA Register
604 ;====================
605 */
606 /*; DMA Command Reg.(+40H) (rw) */
607 #define READ_DIRECTION          BIT7
608 #define WRITE_DIRECTION         0
609 #define EN_DMA_INT              BIT6
610 #define EN_PAGE_INT             BIT5    /* page transfer interrupt enable */
611 #define MAP_TO_MDL              BIT4
612 #define DIAGNOSTIC              BIT2
613 #define DMA_IDLE_CMD            0
614 #define DMA_BLAST_CMD           BIT0
615 #define DMA_ABORT_CMD           BIT1
616 #define DMA_START_CMD           (BIT1+BIT0)
617
618 /*; DMA Status Reg.(+54H) (r) */
619 #define PCI_MS_ABORT            BIT6
620 #define BLAST_COMPLETE          BIT5
621 #define SCSI_INTERRUPT          BIT4
622 #define DMA_XFER_DONE           BIT3
623 #define DMA_XFER_ABORT          BIT2
624 #define DMA_XFER_ERROR          BIT1
625 #define POWER_DOWN              BIT0
626
627 /*; DMA SCSI Bus and Ctrl.(+70H) */
628 #define EN_INT_ON_PCI_ABORT     BIT25
629 #define WRT_ERASE_DMA_STAT      BIT24
630 #define PW_DOWN_CTRL            BIT21
631 #define SCSI_BUSY               BIT20
632 #define SCLK                    BIT19
633 #define SCAM                    BIT18
634 #define SCSI_LINES              0x0003ffff
635
636 /*
637 ;==========================================================
638 ; SCSI Chip register address offset
639 ;==========================================================
640 ;Registers are rw unless declared otherwise 
641 */
642 #define CtcReg_Low      0x00    /* r    curr. transfer count */
643 #define CtcReg_Mid      0x04    /* r */
644 #define CtcReg_High     0x38    /* r */
645 #define ScsiFifo        0x08
646 #define ScsiCmd         0x0C
647 #define Scsi_Status     0x10    /* r */
648 #define INT_Status      0x14    /* r */
649 #define Sync_Period     0x18    /* w */
650 #define Sync_Offset     0x1C    /* w */
651 #define Clk_Factor      0x24    /* w */
652 #define CtrlReg1        0x20    
653 #define CtrlReg2        0x2C
654 #define CtrlReg3        0x30
655 #define CtrlReg4        0x34
656 #define DMA_Cmd         0x40
657 #define DMA_XferCnt     0x44    /* rw   starting transfer count (32 bit) */
658 #define DMA_XferAddr    0x48    /* rw   starting physical address (32 bit) */
659 #define DMA_Wk_ByteCntr 0x4C    /* r    working byte counter */
660 #define DMA_Wk_AddrCntr 0x50    /* r    working address counter */
661 #define DMA_Status      0x54    /* r */
662 #define DMA_MDL_Addr    0x58    /* rw   starting MDL address */
663 #define DMA_Wk_MDL_Cntr 0x5C    /* r    working MDL counter */
664 #define DMA_ScsiBusCtrl 0x70    /* rw   SCSI Bus, PCI/DMA Ctrl */
665
666 #define StcReg_Low      CtcReg_Low      /* w    start transfer count */
667 #define StcReg_Mid      CtcReg_Mid      /* w */
668 #define StcReg_High     CtcReg_High     /* w */
669 #define Scsi_Dest_ID    Scsi_Status     /* w */
670 #define Scsi_TimeOut    INT_Status      /* w */
671 #define Intern_State    Sync_Period     /* r */
672 #define Current_Fifo    Sync_Offset     /* r    Curr. FIFO / int. state */
673
674
675 #define DC390_read8(address)                    \
676         (inb (pACB->IOPortBase + (address)))
677
678 #define DC390_read8_(address, base)             \
679         (inb ((USHORT)(base) + (address)))
680
681 #define DC390_read16(address)                   \
682         (inw (pACB->IOPortBase + (address)))
683
684 #define DC390_read32(address)                   \
685         (inl (pACB->IOPortBase + (address)))
686
687 #define DC390_write8(address,value)             \
688         outb ((value), pACB->IOPortBase + (address))
689
690 #define DC390_write8_(address,value,base)       \
691         outb ((value), (USHORT)(base) + (address))
692
693 #define DC390_write16(address,value)            \
694         outw ((value), pACB->IOPortBase + (address))
695
696 #define DC390_write32(address,value)            \
697         outl ((value), pACB->IOPortBase + (address))
698
699
700 #endif /* _TMSCSIM_H */