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 #ifndef NCR5380_H
29 #define NCR5380_H
30
31 #define NCR5380_PUBLIC_RELEASE 3
32
33 #define NDEBUG_ARBITRATION 0x1
34 #define NDEBUG_AUTOSENSE 0x2
35 #define NDEBUG_DMA 0x4
36 #define NDEBUG_HANDSHAKE 0x8
37 #define NDEBUG_INFORMATION 0x10
38 #define NDEBUG_INIT 0x20
39 #define NDEBUG_INTR 0x40
40 #define NDEBUG_LINKED 0x80
41 #define NDEBUG_MAIN 0x100
42 #define NDEBUG_NO_DATAOUT 0x200
43 #define NDEBUG_NO_WRITE 0x400
44 #define NDEBUG_PIO 0x800
45 #define NDEBUG_PSEUDO_DMA 0x1000
46 #define NDEBUG_QUEUES 0x2000
47 #define NDEBUG_RESELECTION 0x4000
48 #define NDEBUG_SELECTION 0x8000
49 #define NDEBUG_USLEEP 0x10000
50
51
52
53
54
55
56
57
58 #define OUTPUT_DATA_REG 0
59 #define CURRENT_SCSI_DATA_REG 0
60
61 #define INITIATOR_COMMAND_REG 1
62 #define ICR_ASSERT_RST 0x80
63 #define ICR_ARBITRATION_PROGRESS 0x40
64 #define ICR_TRI_STATE 0x40
65 #define ICR_ARBITRATION_LOST 0x20
66 #define ICR_DIFF_ENABLE 0x20
67 #define ICR_ASSERT_ACK 0x10
68 #define ICR_ASSERT_BSY 0x08
69 #define ICR_ASSERT_SEL 0x04
70 #define ICR_ASSERT_ATN 0x02
71 #define ICR_ASSERT_DATA 0x01
72
73 #ifdef DIFFERENTIAL
74 #define ICR_BASE ICR_DIFF_ENABLE
75 #else
76 #define ICR_BASE 0
77 #endif
78
79 #define MODE_REG 2
80
81
82
83
84
85 #define MR_BLOCK_DMA_MODE 0x80
86 #define MR_TARGET 0x40
87 #define MR_ENABLE_PAR_CHECK 0x20
88 #define MR_ENABLE_PAR_INTR 0x10
89 #define MR_ENABLE_EOP_INTR 0x08
90 #define MR_MONITOR_BSY 0x04
91 #define MR_DMA_MODE 0x02
92 #define MR_ARBITRATE 0x01
93
94 #ifdef PARITY
95 #define MR_BASE MR_ENABLE_PAR_CHECK
96 #else
97 #define MR_BASE 0
98 #endif
99
100 #define TARGET_COMMAND_REG 3
101 #define TCR_LAST_BYTE_SENT 0x80
102 #define TCR_ASSERT_REQ 0x08
103 #define TCR_ASSERT_MSG 0x04
104 #define TCR_ASSERT_CD 0x02
105 #define TCR_ASSERT_IO 0x01
106
107 #define STATUS_REG 4
108
109
110
111
112 #define SR_RST 0x80
113 #define SR_BSY 0x40
114 #define SR_REQ 0x20
115 #define SR_MSG 0x10
116 #define SR_CD 0x08
117 #define SR_IO 0x04
118 #define SR_SEL 0x02
119 #define SR_DBP 0x01
120
121
122
123
124
125 #define SELECT_ENABLE_REG 4
126
127 #define BUS_AND_STATUS_REG 5
128 #define BASR_END_DMA_TRANSFER 0x80
129 #define BASR_DRQ 0x40
130 #define BASR_PARITY_ERROR 0x20
131 #define BASR_IRQ 0x10
132 #define BASR_PHASE_MATCH 0x08
133 #define BASR_BUSY_ERROR 0x04
134 #define BASR_ATN 0x02
135 #define BASR_ACK 0x01
136
137
138 #define START_DMA_SEND_REG 5
139
140
141
142
143
144 #define INPUT_DATA_REGISTER 6
145
146
147 #define START_DMA_TARGET_RECIEVE_REG 6
148
149
150 #define RESET_PARITY_INTERRUPT_REG 7
151
152
153 #define START_DMA_INITIATOR_RECIEVE_REG 7
154
155
156 #define PHASE_MASK (SR_MSG | SR_CD | SR_IO)
157
158 #define PHASE_DATAOUT 0
159 #define PHASE_DATAIN SR_IO
160 #define PHASE_CMDOUT SR_CD
161 #define PHASE_STATIN (SR_CD | SR_IO)
162 #define PHASE_MSGOUT (SR_MSG | SR_CD)
163 #define PHASE_MSGIN (SR_MSG | SR_CD | SR_IO)
164 #define PHASE_UNKNOWN 0xff
165
166
167
168
169
170
171
172 #define PHASE_SR_TO_TCR(phase) ((phase) >> 2)
173
174
175
176
177
178
179
180 #define DISCONNECT_NONE 0
181 #define DISCONNECT_TIME_TO_DATA 1
182 #define DISCONNECT_LONG 2
183
184
185
186
187
188 #define TAG_NEXT -1
189 #define TAG_NONE -2
190
191
192
193
194
195
196
197
198
199 #define IRQ_NONE 255
200 #define IRQ_AUTO 254
201
202
203 #ifndef ASM
204 struct NCR5380_hostdata {
205 NCR5380_implementation_fields;
206 unsigned char id_mask, id_higher_mask;
207 volatile unsigned char busy[8];
208 #ifdef REAL_DMA
209 volatile int dma_len;
210 #endif
211 volatile unsigned char last_message;
212 volatile Scsi_Cmnd *connected;
213 volatile Scsi_Cmnd *issue_queue;
214 volatile Scsi_Cmnd *disconnected_queue;
215 #ifdef USLEEP
216 unsigned long time_expires;
217 struct Scsi_Host *next_timer;
218 #endif
219 };
220
221 #ifdef __KERNEL__
222 static struct Scsi_Host *first_instance;
223
224 #if defined(AUTOPROBE_IRQ)
225 static int NCR5380_probe_irq (struct Scsi_Host *instance, int possible);
226 #endif
227 static void NCR5380_init (struct Scsi_Host *instance);
228 static void NCR5380_information_transfer (struct Scsi_Host *instance);
229 static void NCR5380_intr (int irq);
230 static void NCR5380_main (void);
231 static void NCR5380_print_options (struct Scsi_Host *instance);
232 #ifndef NCR5380_abort
233 static
234 #endif
235 int NCR5380_abort (Scsi_Cmnd *cmd, int code);
236 #ifndef NCR5380_reset
237 static
238 #endif
239 int NCR5380_reset (Scsi_Cmnd *);
240 #ifndef NCR5380_queue_command
241 static
242 #endif
243 int NCR5380_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *));
244
245
246 static void NCR5380_reselect (struct Scsi_Host *instance);
247 static int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag);
248 #if defined(PSEUDO_DMA) || defined(REAL_DMA)
249 static int NCR5380_transfer_dma (struct Scsi_Host *instance,
250 unsigned char *phase, int *count, unsigned char **data);
251 #endif
252 static int NCR5380_transfer_pio (struct Scsi_Host *instance,
253 unsigned char *phase, int *count, unsigned char **data);
254
255 #endif __KERNEL_
256 #endif
257 #endif