1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 #ifndef NCR53c7x0_H
40 #define NCR53c7x0_H
41
42 #ifdef __alpha__
43
44 # define ncr_readb(a) ((unsigned int)readb((unsigned long)(a)))
45 # define ncr_readw(a) ((unsigned int)readw((unsigned long)(a)))
46 # define ncr_readl(a) ((unsigned int)readl((unsigned long)(a)))
47 # define ncr_writeb(v,a) (writeb((v), (unsigned long)(a)))
48 # define ncr_writew(v,a) (writew((v), (unsigned long)(a)))
49 # define ncr_writel(v,a) (writel((v), (unsigned long)(a)))
50
51 #else
52
53 # define ncr_readb(a) (*(unsigned char*)(a))
54 # define ncr_readw(a) (*(unsigned short*)(a))
55 # define ncr_readl(a) (*(unsigned int*)(a))
56 # define ncr_writeb(v,a) (*(unsigned char*)(a) = (v))
57 # define ncr_writew(v,a) (*(unsigned short*)(a) = (v))
58 # define ncr_writel(v,a) (*(unsigned int*)(a) = (v))
59
60 #endif
61
62
63
64
65
66
67
68
69 #if defined(HOSTS_C) || defined(MODULE)
70 #include <linux/scsicam.h>
71 extern int NCR53c7xx_abort(Scsi_Cmnd *);
72 extern int NCR53c7xx_detect(Scsi_Host_Template *tpnt);
73 extern int NCR53c7xx_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
74 extern int NCR53c7xx_reset(Scsi_Cmnd *);
75 #ifdef MODULE
76 extern int NCR53c7xx_release(struct Scsi_Host *);
77 #else
78 #define NCR53c7xx_release NULL
79 #endif
80
81 #define NCR53c7xx {NULL, NULL, NULL, "NCR53c7xx", \
82 PROC_SCSI_NCR53C7xx, "NCR53c{7,8}xx (rel 4)", NCR53c7xx_detect, \
83 NULL, NULL, NULL, \
84 NCR53c7xx_queue_command, NCR53c7xx_abort, NCR53c7xx_reset, \
85 NULL , scsicam_bios_param, 1, \
86 7, 127 , 1 , \
87 0, 0, DISABLE_CLUSTERING}
88 #endif
89
90 #ifndef HOSTS_C
91
92
93
94
95 #define SCNTL0_REG 0x00
96 #define SCNTL0_ARB1 0x80
97 #define SCNTL0_ARB2 0x40
98 #define SCNTL0_STRT 0x20
99 #define SCNTL0_WATN 0x10
100 #define SCNTL0_EPC 0x08
101
102 #define SCNTL0_EPG_700 0x04
103 #define SCNTL0_AAP 0x02
104 #define SCNTL0_TRG 0x01
105
106
107
108 #define SCNTL1_REG 0x01
109 #define SCNTL1_EXC 0x80
110 #define SCNTL1_ADB 0x40
111 #define SCNTL1_ESR_700 0x20
112
113 #define SCNTL1_DHP_800 0x20
114
115 #define SCNTL1_CON 0x10
116 #define SCNTL1_RST 0x08
117 #define SCNTL1_AESP 0x04
118 #define SCNTL1_SND_700 0x02
119 #define SCNTL1_IARB_800 0x02
120
121
122 #define SCNTL1_RCV_700 0x01
123 #define SCNTL1_SST_800 0x01
124
125
126
127 #define SCNTL2_REG_800 0x02
128 #define SCNTL2_800_SDU 0x80
129
130
131
132 #define SCNTL3_REG_800 0x03
133 #define SCNTL3_800_SCF_SHIFT 4
134 #define SCNTL3_800_SCF_MASK 0x70
135 #define SCNTL3_800_SCF2 0x40
136 #define SCNTL3_800_SCF1 0x20
137 #define SCNTL3_800_SCF0 0x10
138
139
140
141
142 #define SCNTL3_800_CCF_SHIFT 0
143 #define SCNTL3_800_CCF_MASK 0x07
144 #define SCNTL3_800_CCF2 0x04
145 #define SCNTL3_800_CCF1 0x02
146 #define SCNTL3_800_CCF0 0x01
147
148
149
150
151
152
153
154
155 #define SDID_REG_700 0x02
156 #define SDID_REG_800 0x06
157
158 #define GP_REG_800 0x07
159 #define GP_800_IO1 0x02
160 #define GP_800_IO2 0x01
161
162
163
164 #define SIEN_REG_700 0x03
165 #define SIEN0_REG_800 0x40
166 #define SIEN_MA 0x80
167 #define SIEN_FC 0x40
168 #define SIEN_700_STO 0x20
169 #define SIEN_800_SEL 0x20
170 #define SIEN_700_SEL 0x10
171 #define SIEN_800_RESEL 0x10
172 #define SIEN_SGE 0x08
173 #define SIEN_UDC 0x04
174 #define SIEN_RST 0x02
175 #define SIEN_PAR 0x01
176
177
178
179
180
181
182
183
184
185
186 #define SCID_REG 0x04
187
188 #define SCID_800_RRE 0x40
189 #define SCID_800_SRE 0x20
190
191 #define SCID_800_ENC_MASK 0x07
192
193
194 #define SXFER_REG 0x05
195 #define SXFER_DHP 0x80
196
197 #define SXFER_TP2 0x40
198 #define SXFER_TP1 0x20
199 #define SXFER_TP0 0x10
200 #define SXFER_TP_MASK 0x70
201 #define SXFER_TP_SHIFT 4
202 #define SXFER_TP_4 0x00
203 #define SXFER_TP_5 0x10
204 #define SXFER_TP_6 0x20
205 #define SXFER_TP_7 0x30
206 #define SXFER_TP_8 0x40
207 #define SXFER_TP_9 0x50
208 #define SXFER_TP_10 0x60
209 #define SXFER_TP_11 0x70
210
211 #define SXFER_MO3 0x08
212 #define SXFER_MO2 0x04
213 #define SXFER_MO1 0x02
214 #define SXFER_MO0 0x01
215 #define SXFER_MO_MASK 0x0f
216 #define SXFER_MO_SHIFT 0
217
218
219
220
221
222
223
224 #define SODL_REG_700 0x06
225 #define SODL_REG_800 0x54
226
227
228
229
230
231
232
233
234
235
236 #define SBCL_REG 0x0b
237 #define SBCL_REQ 0x80
238 #define SBCL_ACK 0x40
239 #define SBCL_BSY 0x20
240 #define SBCL_SEL 0x10
241 #define SBCL_ATN 0x08
242 #define SBCL_MSG 0x04
243 #define SBCL_CD 0x02
244 #define SBCL_IO 0x01
245 #define SBCL_PHASE_CMDOUT SBCL_CD
246 #define SBCL_PHASE_DATAIN SBCL_IO
247 #define SBCL_PHASE_DATAOUT 0
248 #define SBCL_PHASE_MSGIN (SBCL_CD|SBCL_IO|SBCL_MSG)
249 #define SBCL_PHASE_MSGOUT (SBCL_CD|SBCL_MSG)
250 #define SBCL_PHASE_STATIN (SBCL_CD|SBCL_IO)
251 #define SBCL_PHASE_MASK (SBCL_CD|SBCL_IO|SBCL_MSG)
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269 #define SFBR_REG 0x08
270
271
272
273
274
275
276
277 #define SIDL_REG_700 0x09
278 #define SIDL_REG_800 0x50
279
280
281
282
283
284
285
286 #define SBDL_REG_700 0x0a
287 #define SBDL_REG_800 0x58
288
289 #define SSID_REG_800 0x0a
290 #define SSID_800_VAL 0x80
291 #define SSID_800_ENCID_MASK 0x07
292
293
294
295
296
297
298 #define SOCL_REG 0x0b
299 #define SOCL_REQ 0x80
300 #define SOCL_ACK 0x40
301 #define SOCL_BSY 0x20
302 #define SOCL_SEL 0x10
303 #define SOCL_ATN 0x08
304 #define SOCL_MSG 0x04
305 #define SOCL_CD 0x02
306 #define SOCL_IO 0x01
307
308
309
310
311
312
313
314 #define SBCL_SSCF1 0x02
315 #define SBCL_SSCF0 0x01
316 #define SBCL_SSCF_MASK 0x03
317
318
319
320
321
322
323 #define DSTAT_REG 0x0c
324 #define DSTAT_DFE 0x80
325 #define DSTAT_800_MDPE 0x40
326 #define DSTAT_800_BF 0x20
327 #define DSTAT_ABRT 0x10
328 #define DSTAT_SSI 0x08
329 #define DSTAT_SIR 0x04
330
331
332 #define DSTAT_WTD 0x02
333 #define DSTAT_OPC 0x01
334 #define DSTAT_800_IID 0x01
335
336
337 #define SSTAT0_REG 0x0d
338 #define SIST0_REG_800 0x42
339 #define SSTAT0_MA 0x80
340
341
342 #define SSTAT0_CMP 0x40
343 #define SSTAT0_700_STO 0x20
344 #define SIST0_800_SEL 0x20
345 #define SSTAT0_700_SEL 0x10
346 #define SIST0_800_RSL 0x10
347 #define SSTAT0_SGE 0x08
348 #define SSTAT0_UDC 0x04
349 #define SSTAT0_RST 0x02
350 #define SSTAT0_PAR 0x01
351
352 #define SSTAT1_REG 0x0e
353 #define SSTAT1_ILF 0x80
354 #define SSTAT1_ORF 0x40
355 #define SSTAT1_OLF 0x20
356 #define SSTAT1_AIP 0x10
357 #define SSTAT1_LOA 0x08
358 #define SSTAT1_WOA 0x04
359 #define SSTAT1_RST 0x02
360 #define SSTAT1_SDP 0x01
361
362 #define SSTAT2_REG 0x0f
363 #define SSTAT2_FF3 0x80
364 #define SSTAT2_FF2 0x40
365 #define SSTAT2_FF1 0x20
366 #define SSTAT2_FF0 0x10
367 #define SSTAT2_FF_MASK 0xf0
368
369
370
371
372
373 #define SSTAT2_SDP 0x08
374 #define SSTAT2_MSG 0x04
375 #define SSTAT2_CD 0x02
376 #define SSTAT2_IO 0x01
377
378
379
380 #define SCRATCHA_REG_00 0x10
381
382 #define DSA_REG 0x10
383
384 #define CTEST0_REG_700 0x14
385 #define CTEST0_REG_800 0x18
386
387 #define CTEST0_700_RTRG 0x02
388 #define CTEST0_700_DDIR 0x01
389
390
391
392
393 #define CTEST1_REG_700 0x15
394 #define CTEST1_REG_800 0x19
395 #define CTEST1_FMT3 0x80
396 #define CTEST1_FMT2 0x40
397 #define CTEST1_FMT1 0x20
398 #define CTEST1_FMT0 0x10
399
400 #define CTEST1_FFL3 0x08
401 #define CTEST1_FFL2 0x04
402 #define CTEST1_FFL1 0x02
403 #define CTEST1_FFL0 0x01
404
405 #define CTEST2_REG_700 0x16
406 #define CTEST2_REG_800 0x1a
407
408 #define CTEST2_800_DDIR 0x80
409 #define CTEST2_800_SIGP 0x40
410
411 #define CTEST2_800_CIO 0x20 .
412 #define CTEST2_800_CM 0x10
413
414
415 #define CTEST2_700_SOFF 0x20
416
417
418
419
420
421
422
423 #define CTEST2_700_SFP 0x10
424
425
426
427 #define CTEST2_700_DFP 0x08
428
429
430
431 #define CTEST2_TEOP 0x04
432
433
434
435 #define CTEST2_DREQ 0x02
436
437 #define CTEST2_800_DACK 0x01
438
439
440
441
442
443
444
445
446 #define CTEST3_REG_700 0x17
447
448 #define CTEST3_REG_800 0x1b
449 #define CTEST3_800_V3 0x80
450 #define CTEST3_800_V2 0x40
451 #define CTEST3_800_V1 0x20
452 #define CTEST3_800_V0 0x10
453 #define CTEST3_800_FLF 0x08
454 #define CTEST3_800_CLF 0x04
455 #define CTEST3_800_FM 0x02
456
457
458 #define CTEST4_REG_700 0x18
459 #define CTEST4_REG_800 0x21
460
461 #define CTEST4_800_BDIS 0x80
462 #define CTEST4_ZMOD 0x40
463 #define CTEST4_SZM 0x20
464 #define CTEST4_700_SLBE 0x10
465 #define CTEST4_800_SRTM 0x10
466 #define CTEST4_700_SFWR 0x08
467
468
469
470 #define CTEST4_800_MPEE 0x08
471
472
473
474
475
476
477
478
479 #define CTEST4_FBL2 0x04
480 #define CTEST4_FBL1 0x02
481 #define CTEST4_FBL0 0x01
482 #define CTEST4_FBL_MASK 0x07
483 #define CTEST4_FBL_0 0x04
484 #define CTEST4_FBL_1 0x05
485 #define CTEST4_FBL_2 0x06
486 #define CTEST4_FBL_3 0x07
487 #define CTEST4_800_SAVE (CTEST4_800_BDIS)
488
489
490 #define CTEST5_REG_700 0x19
491 #define CTEST5_REG_800 0x22
492
493
494
495
496
497 #define CTEST5_ADCK 0x80
498
499
500
501
502 #define CTEST5_BBCK 0x40
503
504
505
506
507
508
509
510
511
512 #define CTEST5_700_ROFF 0x20
513
514
515
516
517
518 #define CTEST5_MASR 0x10
519 #define CTEST5_DDIR 0x08
520
521
522
523 #define CTEST5_700_EOP 0x04
524 #define CTEST5_700_DREQ 0x02
525 #define CTEST5_700_DACK 0x01
526
527
528
529
530
531
532 #define CTEST6_REG_700 0x1a
533 #define CTEST6_REG_800 0x23
534
535 #define CTEST7_REG 0x1b
536
537 #define CTEST7_10_CDIS 0x80
538 #define CTEST7_10_SC1 0x40
539 #define CTEST7_10_SC0 0x20
540 #define CTEST7_10_SC_MASK 0x60
541
542 #define CTEST7_0060_FM 0x20
543 #define CTEST7_STD 0x10
544 #define CTEST7_DFP 0x08
545 #define CTEST7_EVP 0x04
546 #define CTEST7_10_TT1 0x02
547 #define CTEST7_00_DC 0x02
548
549 #define CTEST7_DIFF 0x01
550
551 #define CTEST7_SAVE ( CTEST7_EVP | CTEST7_DIFF )
552
553
554 #define TEMP_REG 0x1c
555
556 #define DFIFO_REG 0x20
557
558
559
560
561 #define DFIFO_00_FLF 0x80
562 #define DFIFO_00_CLF 0x40
563 #define DFIFO_BO6 0x40
564 #define DFIFO_BO5 0x20
565 #define DFIFO_BO4 0x10
566 #define DFIFO_BO3 0x08
567 #define DFIFO_BO2 0x04
568 #define DFIFO_BO1 0x02
569 #define DFIFO_BO0 0x01
570 #define DFIFO_10_BO_MASK 0x7f
571 #define DFIFO_00_BO_MASK 0x3f
572
573
574
575
576
577
578 #define ISTAT_REG_700 0x21
579 #define ISTAT_REG_800 0x14
580 #define ISTAT_ABRT 0x80
581
582
583 #define ISTAT_10_SRST 0x40
584 #define ISTAT_10_SIGP 0x20
585
586 #define ISTAT_800_SEM 0x10
587 #define ISTAT_CON 0x08
588 #define ISTAT_800_INTF 0x04
589 #define ISTAT_700_PRE 0x04
590
591
592
593
594 #define ISTAT_SIP 0x02
595
596
597
598 #define ISTAT_DIP 0x01
599
600
601
602
603 #define CTEST8_REG 0x22
604 #define CTEST8_0066_EAS 0x80
605
606
607 #define CTEST8_0066_EFM 0x40
608 #define CTEST8_0066_GRP 0x20
609
610
611
612
613 #define CTEST8_0066_TE 0x10
614
615
616
617
618 #define CTEST8_0066_HSC 0x08
619 #define CTEST8_0066_SRA 0x04
620
621
622
623 #define CTEST8_0066_DAS 0x02
624
625
626 #define CTEST8_0066_LDE 0x01
627
628
629
630
631
632
633
634
635
636 #define CTEST8_10_V3 0x80
637 #define CTEST8_10_V2 0x40
638 #define CTEST8_10_V1 0x20
639 #define CTEST8_10_V0 0x10
640 #define CTEST8_10_V_MASK 0xf0
641 #define CTEST8_10_FLF 0x08
642 #define CTEST8_10_CLF 0x04
643 #define CTEST8_10_FM 0x02
644 #define CTEST8_10_SM 0x01
645
646
647
648
649
650
651
652
653
654
655
656
657 #define CTEST9_REG_00 0x23
658 #define LCRC_REG_10 0x23
659
660
661
662
663
664
665
666
667
668
669 #define DBC_REG 0x24
670
671
672
673
674
675
676 #define DBC_TCI_TRUE (1 << 19)
677 #define DBC_TCI_COMPARE_DATA (1 << 18)
678 #define DBC_TCI_COMPARE_PHASE (1 << 17)
679 #define DBC_TCI_WAIT_FOR_VALID (1 << 16)
680
681 #define DBC_TCI_MASK_MASK 0xff00
682 #define DBC_TCI_MASK_SHIFT 8
683 #define DBC_TCI_DATA_MASK 0xff
684 #define DBC_TCI_DATA_SHIFT 0
685
686 #define DBC_RWRI_IMMEDIATE_MASK 0xff00
687 #define DBC_RWRI_IMMEDIATE_SHIFT 8
688 #define DBC_RWRI_ADDRESS_MASK 0x3f0000
689 #define DBC_RWRI_ADDRESS_SHIFT 16
690
691
692
693
694
695 #define DCMD_REG 0x27
696 #define DCMD_TYPE_MASK 0xc0
697 #define DCMD_TYPE_BMI 0x00
698 #define DCMD_BMI_IO 0x01
699 #define DCMD_BMI_CD 0x02
700 #define DCMD_BMI_MSG 0x04
701
702 #define DCMD_BMI_OP_MASK 0x18
703 #define DCMD_BMI_OP_MOVE_T 0x00
704 #define DCMD_BMI_OP_MOVE_I 0x08
705
706 #define DCMD_BMI_INDIRECT 0x20
707
708 #define DCMD_TYPE_TCI 0x80
709
710 #define DCMD_TCI_IO 0x01
711 #define DCMD_TCI_CD 0x02
712 #define DCMD_TCI_MSG 0x04
713 #define DCMD_TCI_OP_MASK 0x38
714 #define DCMD_TCI_OP_JUMP 0x00
715 #define DCMD_TCI_OP_CALL 0x08
716 #define DCMD_TCI_OP_RETURN 0x10
717 #define DCMD_TCI_OP_INT 0x18
718
719 #define DCMD_TYPE_RWRI 0x40
720
721 #define DCMD_RWRI_OPC_MASK 0x38
722 #define DCMD_RWRI_OPC_WRITE 0x28
723 #define DCMD_RWRI_OPC_READ 0x30
724 #define DCMD_RWRI_OPC_MODIFY 0x38
725
726 #define DCMD_RWRI_OP_MASK 0x07
727 #define DCMD_RWRI_OP_MOVE 0x00
728 #define DCMD_RWRI_OP_SHL 0x01
729 #define DCMD_RWRI_OP_OR 0x02
730 #define DCMD_RWRI_OP_XOR 0x03
731 #define DCMD_RWRI_OP_AND 0x04
732 #define DCMD_RWRI_OP_SHR 0x05
733 #define DCMD_RWRI_OP_ADD 0x06
734 #define DCMD_RWRI_OP_ADDC 0x07
735
736 #define DCMD_TYPE_MMI 0xc0
737
738
739
740 #define DNAD_REG 0x28
741
742 #define DSP_REG 0x2c
743 #define DSPS_REG 0x30
744
745 #define DMODE_REG_00 0x34
746 #define DMODE_00_BL1 0x80
747 #define DMODE_00_BL0 0x40
748 #define DMODE_BL_MASK 0xc0
749
750 #define DMODE_BL_2 0x00
751 #define DMODE_BL_4 0x40
752 #define DMODE_BL_8 0x80
753 #define DMODE_BL_16 0xc0
754
755 #define DMODE_700_BW16 0x20
756 #define DMODE_700_286 0x10
757 #define DMODE_700_IOM 0x08
758 #define DMODE_700_FAM 0x04
759 #define DMODE_700_PIPE 0x02
760
761
762 #define DMODE_MAN 0x01
763
764
765
766
767
768 #define DMODE_700_SAVE ( DMODE_00_BL_MASK | DMODE_00_BW16 | DMODE_00_286 )
769
770
771 #define SCRATCHA_REG_800 0x34
772
773 #define SCRATCB_REG_10 0x34
774
775 #define DMODE_REG_10 0x38
776 #define DMODE_800_SIOM 0x20
777 #define DMODE_800_DIOM 0x10
778 #define DMODE_800_ERL 0x08
779
780
781 #define DIEN_REG 0x39
782
783 #define DIEN_800_MDPE 0x40
784 #define DIEN_800_BF 0x20
785 #define DIEN_ABRT 0x10
786 #define DIEN_SSI 0x08
787 #define DIEN_SIR 0x04
788
789
790
791 #define DIEN_700_WTD 0x02
792 #define DIEN_700_OPC 0x01
793
794
795 #define DIEN_800_IID 0x01
796
797
798
799
800
801 #define DWT_REG 0x3a
802
803
804 #define DCNTL_REG 0x3b
805 #define DCNTL_700_CF1 0x80
806 #define DCNTL_700_CF0 0x40
807 #define DCNTL_700_CF_MASK 0xc0
808
809 #define DCNTL_700_CF_2 0x00
810 #define DCNTL_700_CF_1_5 0x40
811 #define DCNTL_700_CF_1 0x80
812 #define DCNTL_700_CF_3 0xc0
813
814 #define DCNTL_700_S16 0x20
815 #define DCNTL_SSM 0x10
816 #define DCNTL_700_LLM 0x08
817
818 #define DCNTL_800_IRQM 0x08
819 #define DCNTL_STD 0x04
820
821 #define DCNTL_00_RST 0x01
822
823
824
825 #define DCNTL_10_COM 0x01
826
827 #define DCNTL_700_SAVE ( DCNTL_CF_MASK | DCNTL_S16)
828
829
830
831 #define SCRATCHB_REG_00 0x3c
832 #define SCRATCHB_REG_800 0x5c
833
834 #define ADDER_REG_10 0x3c
835
836 #define SIEN1_REG_800 0x41
837 #define SIEN1_800_STO 0x04
838 #define SIEN1_800_GEN 0x02
839 #define SIEN1_800_HTH 0x01
840
841 #define SIST1_REG_800 0x43
842 #define SIST1_800_STO 0x04
843 #define SIST1_800_GEN 0x02
844 #define SIST1_800_HTH 0x01
845
846 #define SLPAR_REG_800 0x44
847
848 #define MACNTL_REG_800 0x46
849 #define MACNTL_800_TYP3 0x80
850 #define MACNTL_800_TYP2 0x40
851 #define MACNTL_800_TYP1 0x20
852 #define MACNTL_800_TYP0 0x10
853 #define MACNTL_800_DWR 0x08
854 #define MACNTL_800_DRD 0x04
855 #define MACNTL_800_PSCPT 0x02
856 #define MACNTL_800_SCPTS 0x01
857
858 #define GPCNTL_REG_800 0x47
859
860
861 #define STIME0_REG_800 0x48
862 #define STIME0_800_HTH_MASK 0xf0
863 #define STIME0_800_HTH_SHIFT 4
864 #define STIME0_800_SEL_MASK 0x0f
865 #define STIME0_800_SEL_SHIFT 0
866
867 #define STIME1_REG_800 0x49
868 #define STIME1_800_GEN_MASK 0x0f
869
870 #define RESPID_REG_800 0x4a
871
872 #define STEST0_REG_800 0x4c
873 #define STEST0_800_SLT 0x08
874 #define STEST0_800_ART 0x04
875 #define STEST0_800_SOZ 0x02
876 #define STEST0_800_SOM 0x01
877
878 #define STEST1_REG_800 0x4d
879 #define STEST1_800_SCLK 0x80
880
881 #define STEST2_REG_800 0x4e
882 #define STEST2_800_SCE 0x80
883 #define STEST2_800_ROF 0x40
884 #define STEST2_800_SLB 0x10
885 #define STEST2_800_SZM 0x08
886 #define STEST2_800_EXT 0x02
887 #define STEST2_800_LOW 0x01
888
889 #define STEST3_REG_800 0x4f
890 #define STEST3_800_TE 0x80
891 #define STEST3_800_STR 0x40
892 #define STEST3_800_HSC 0x20
893 #define STEST3_800_DSI 0x10
894 #define STEST3_800_TTM 0x04
895 #define STEST3_800_CSF 0x02
896 #define STEST3_800_STW 0x01
897
898
899
900
901
902 #define OPTION_PARITY 0x1
903 #define OPTION_TAGGED_QUEUE 0x2
904 #define OPTION_700 0x8
905 #define OPTION_INTFLY 0x10
906 #define OPTION_DEBUG_INTR 0x20
907 #define OPTION_DEBUG_INIT_ONLY 0x40
908
909
910
911 #define OPTION_DEBUG_READ_ONLY 0x80
912
913 #define OPTION_DEBUG_TRACE 0x100
914
915
916 #define OPTION_DEBUG_SINGLE 0x200
917
918 #define OPTION_SYNCHRONOUS 0x400
919 #define OPTION_MEMORY_MAPPED 0x800
920
921 #define OPTION_IO_MAPPED 0x1000
922
923 #define OPTION_DEBUG_PROBE_ONLY 0x2000
924 #define OPTION_DEBUG_TESTS_ONLY 0x4000
925
926 #define OPTION_DEBUG_TEST0 0x08000
927 #define OPTION_DEBUG_TEST1 0x10000
928 #define OPTION_DEBUG_TEST2 0x20000
929
930 #define OPTION_DEBUG_DUMP 0x40000
931 #define OPTION_DEBUG_TARGET_LIMIT 0x80000
932 #define OPTION_DEBUG_NCOMMANDS_LIMIT 0x100000
933 #define OPTION_DEBUG_SCRIPT 0x200000
934 #define OPTION_DEBUG_FIXUP 0x400000
935 #define OPTION_DEBUG_DSA 0x800000
936 #define OPTION_DEBUG_CORRUPTION 0x1000000
937
938 #if !defined(PERM_OPTIONS)
939 #define PERM_OPTIONS 0
940 #endif
941
942 struct NCR53c7x0_synchronous {
943 u32 select_indirect;
944 u32 script[6];
945
946 unsigned renegotiate:1;
947
948 };
949
950 #define CMD_FLAG_SDTR 1
951
952 #define CMD_FLAG_WDTR 2
953
954 #define CMD_FLAG_DID_SDTR 4
955
956 struct NCR53c7x0_table_indirect {
957 u32 count;
958 void *address;
959 };
960
961 struct NCR53c7x0_cmd {
962 void *real;
963 void (* free)(void *);
964
965
966 Scsi_Cmnd *cmd;
967
968
969
970
971 int size;
972
973
974 int flags;
975
976 unsigned char select[11];
977
978
979
980
981
982
983 volatile struct NCR53c7x0_cmd *next, *prev;
984
985
986
987
988
989 long dsa_size;
990
991 u32 *data_transfer_start;
992 u32 *data_transfer_end;
993
994
995 u32 residual[8];
996
997
998
999
1000
1001
1002
1003 u32 dsa[0];
1004
1005
1006 };
1007
1008 struct NCR53c7x0_break {
1009 u32 *address, old_instruction[2];
1010 struct NCR53c7x0_break *next;
1011 unsigned char old_size;
1012 };
1013
1014
1015 #define STATE_HALTED 0
1016
1017
1018
1019
1020
1021 #define STATE_WAITING 1
1022
1023 #define STATE_RUNNING 2
1024
1025
1026
1027 #define STATE_ABORTING 3
1028
1029
1030 #define STATE_ABORTED 4
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040 #define SPECIFIC_INT_NOTHING 0
1041 #define SPECIFIC_INT_RESTART 1
1042 #define SPECIFIC_INT_ABORT 2
1043 #define SPECIFIC_INT_PANIC 3
1044 #define SPECIFIC_INT_DONE 4
1045 #define SPECIFIC_INT_BREAK 5
1046
1047 struct NCR53c7x0_hostdata {
1048 int size;
1049
1050 struct Scsi_Host *next;
1051 int board;
1052
1053
1054
1055
1056
1057 int chip;
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072 unsigned char pci_bus, pci_device_fn;
1073 unsigned pci_valid:1;
1074
1075 u32 *dsp;
1076
1077
1078
1079 unsigned dsp_changed:1;
1080
1081
1082 unsigned char dstat;
1083 unsigned dstat_valid:1;
1084
1085 unsigned expecting_iid:1;
1086 unsigned expecting_sto:1;
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099 void (* init_fixup)(struct Scsi_Host *host);
1100 void (* init_save_regs)(struct Scsi_Host *host);
1101 void (* dsa_fixup)(struct NCR53c7x0_cmd *cmd);
1102 void (* soft_reset)(struct Scsi_Host *host);
1103 int (* run_tests)(struct Scsi_Host *host);
1104
1105
1106
1107
1108
1109
1110
1111 int (* dstat_sir_intr)(struct Scsi_Host *host, struct NCR53c7x0_cmd *cmd);
1112
1113 long dsa_size;
1114
1115
1116
1117
1118
1119
1120 s32 dsa_start;
1121 s32 dsa_end;
1122 s32 dsa_next;
1123 s32 dsa_prev;
1124 s32 dsa_cmnd;
1125 s32 dsa_select;
1126 s32 dsa_msgout;
1127 s32 dsa_cmdout;
1128 s32 dsa_dataout;
1129 s32 dsa_datain;
1130 s32 dsa_msgin;
1131 s32 dsa_msgout_other;
1132 s32 dsa_write_sync;
1133 s32 dsa_write_resume;
1134 s32 dsa_jump_resume;
1135 s32 dsa_check_reselect;
1136 s32 dsa_status;
1137
1138
1139
1140
1141
1142
1143 s32 E_accept_message;
1144 s32 E_dsa_code_template;
1145 s32 E_dsa_code_template_end;
1146 s32 E_command_complete;
1147 s32 E_msg_in;
1148 s32 E_initiator_abort;
1149 s32 E_other_transfer;
1150 s32 E_target_abort;
1151 s32 E_schedule;
1152 s32 E_debug_break;
1153 s32 E_reject_message;
1154 s32 E_respond_message;
1155 s32 E_select;
1156 s32 E_select_msgout;
1157 s32 E_test_0;
1158 s32 E_test_1;
1159 s32 E_test_2;
1160 s32 E_test_3;
1161 s32 E_dsa_zero;
1162 s32 E_dsa_jump_resume;
1163
1164 int options;
1165 volatile u32 test_completed;
1166 int test_running;
1167 int test_source;
1168 volatile int test_dest;
1169
1170 volatile int state;
1171
1172
1173 unsigned char dmode;
1174
1175
1176
1177 unsigned char istat;
1178
1179
1180
1181
1182 int scsi_clock;
1183
1184
1185
1186
1187
1188 volatile int intrs;
1189 unsigned char saved_dmode;
1190 unsigned char saved_ctest4;
1191 unsigned char saved_ctest7;
1192 unsigned char saved_dcntl;
1193 unsigned char saved_scntl3;
1194
1195 unsigned char this_id_mask;
1196
1197
1198 struct NCR53c7x0_break *breakpoints,
1199 *breakpoint_current;
1200
1201
1202 #ifdef NCR_DEBUG
1203 int debug_size;
1204 volatile int debug_count;
1205 volatile char *debug_buf;
1206 volatile char *debug_write;
1207 volatile char *debug_read;
1208 #endif
1209
1210
1211 int debug_print_limit;
1212
1213
1214
1215
1216 unsigned char debug_lun_limit[8];
1217
1218
1219
1220 int debug_count_limit;
1221
1222
1223
1224
1225 volatile unsigned idle:1;
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235 volatile struct NCR53c7x0_synchronous sync[8];
1236
1237 volatile struct NCR53c7x0_cmd *issue_queue;
1238
1239
1240 volatile struct NCR53c7x0_cmd *running_list;
1241
1242
1243 volatile struct NCR53c7x0_cmd *current;
1244
1245
1246
1247
1248 volatile struct NCR53c7x0_cmd *spare;
1249
1250
1251
1252 volatile struct NCR53c7x0_cmd *free;
1253 int max_cmd_size;
1254
1255
1256
1257 volatile int num_cmds;
1258
1259 volatile unsigned char cmd_allocated[8];
1260
1261
1262 volatile unsigned char busy[8][8];
1263
1264
1265
1266
1267
1268
1269
1270
1271 volatile struct NCR53c7x0_cmd *finished_queue;
1272
1273
1274
1275 volatile u32 issue_dsa_head;
1276
1277
1278
1279
1280
1281 u32 *issue_dsa_tail;
1282
1283 volatile unsigned char msg_buf[16];
1284
1285
1286 volatile u32 reconnect_dsa_head;
1287
1288
1289
1290 volatile unsigned char reselected_identify;
1291 volatile unsigned char reselected_tag;
1292
1293
1294
1295 s32 NCR53c7xx_zero;
1296 s32 NCR53c7xx_sink;
1297 char NCR53c7xx_msg_reject;
1298 char NCR53c7xx_msg_abort;
1299 char NCR53c7xx_msg_nop;
1300
1301 int script_count;
1302 u32 script[0];
1303
1304 };
1305
1306 #define IRQ_NONE 255
1307 #define DMA_NONE 255
1308 #define IRQ_AUTO 254
1309 #define DMA_AUTO 254
1310
1311 #define BOARD_GENERIC 0
1312
1313 #define NCR53c7x0_insn_size(insn) \
1314 (((insn) & DCMD_TYPE_MASK) == DCMD_TYPE_MMI ? 3 : 2)
1315
1316
1317 #define NCR53c7x0_local_declare() \
1318 volatile unsigned char *NCR53c7x0_address_memory; \
1319 unsigned int NCR53c7x0_address_io; \
1320 int NCR53c7x0_memory_mapped
1321
1322 #define NCR53c7x0_local_setup(host) \
1323 NCR53c7x0_address_memory = (void *) (host)->base; \
1324 NCR53c7x0_address_io = (unsigned int) (host)->io_port; \
1325 NCR53c7x0_memory_mapped = ((struct NCR53c7x0_hostdata *) \
1326 host->hostdata)-> options & OPTION_MEMORY_MAPPED
1327
1328 #define NCR53c7x0_read8(address) \
1329 (NCR53c7x0_memory_mapped ? \
1330 ncr_readb(NCR53c7x0_address_memory + (address)) : \
1331 inb(NCR53c7x0_address_io + (address)))
1332
1333 #define NCR53c7x0_read16(address) \
1334 (NCR53c7x0_memory_mapped ? \
1335 ncr_readw(NCR53c7x0_address_memory + (address)) : \
1336 inw(NCR53c7x0_address_io + (address)))
1337
1338 #define NCR53c7x0_read32(address) \
1339 (NCR53c7x0_memory_mapped ? \
1340 ncr_readl(NCR53c7x0_address_memory + (address)) : \
1341 inl(NCR53c7x0_address_io + (address)))
1342
1343 #define NCR53c7x0_write8(address,value) \
1344 (NCR53c7x0_memory_mapped ? \
1345 ncr_writeb((value), NCR53c7x0_address_memory + (address)) : \
1346 outb((value), NCR53c7x0_address_io + (address)))
1347
1348 #define NCR53c7x0_write16(address,value) \
1349 (NCR53c7x0_memory_mapped ? \
1350 ncr_writew((value), NCR53c7x0_address_memory + (address)) : \
1351 outw((value), NCR53c7x0_address_io + (address)))
1352
1353 #define NCR53c7x0_write32(address,value) \
1354 (NCR53c7x0_memory_mapped ? \
1355 ncr_writel((value), NCR53c7x0_address_memory + (address)) : \
1356 outl((value), NCR53c7x0_address_io + (address)))
1357
1358 #define patch_abs_32(script, offset, symbol, value) \
1359 for (i = 0; i < (sizeof (A_##symbol##_used) / sizeof \
1360 (u32)); ++i) { \
1361 (script)[A_##symbol##_used[i] - (offset)] += (value); \
1362 if (hostdata->options & OPTION_DEBUG_FIXUP) \
1363 printk("scsi%d : %s reference %d at 0x%x in %s is now 0x%x\n",\
1364 host->host_no, #symbol, i, A_##symbol##_used[i] - \
1365 (int)(offset), #script, (script)[A_##symbol##_used[i] - \
1366 (offset)]); \
1367 }
1368
1369 #define patch_abs_rwri_data(script, offset, symbol, value) \
1370 for (i = 0; i < (sizeof (A_##symbol##_used) / sizeof \
1371 (u32)); ++i) \
1372 (script)[A_##symbol##_used[i] - (offset)] = \
1373 ((script)[A_##symbol##_used[i] - (offset)] & \
1374 ~DBC_RWRI_IMMEDIATE_MASK) | \
1375 (((value) << DBC_RWRI_IMMEDIATE_SHIFT) & \
1376 DBC_RWRI_IMMEDIATE_MASK)
1377
1378 #define patch_dsa_32(dsa, symbol, word, value) \
1379 { \
1380 (dsa)[(hostdata->##symbol - hostdata->dsa_start) / sizeof(u32) \
1381 + (word)] = (value); \
1382 if (hostdata->options & OPTION_DEBUG_DSA) \
1383 printk("scsi : dsa %s symbol %s(%d) word %d now 0x%x\n", \
1384 #dsa, #symbol, hostdata->##symbol, \
1385 (word), (u32)(value)); \
1386 }
1387
1388
1389
1390 #endif
1391 #endif