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 #ifndef AM53C974_H
28 #define AM53C974_H
29
30 #include <linux/scsicam.h>
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 #define DEFAULT_SYNC_NEGOTIATION_ENABLED 0
47 #define DEFAULT_RATE 5
48 #define DEFAULT_SYNC_OFFSET 0
49
50
51
52
53 #define AM53C974_DRIVER_REVISION_MAJOR 0
54 #define AM53C974_DRIVER_REVISION_MINOR 5
55 #define SEPARATOR_LINE \
56 "--------------------------------------------------------------------------\n"
57
58
59
60
61
62
63
64
65
66
67
68
69 #define AM53C974_DEBUG_ABORT
70
71
72
73 #define DEF_CLK 40
74 #define MIN_PERIOD 4
75 #define MAX_PERIOD 13
76 #define MAX_OFFSET 15
77
78 #define DEF_SCSI_TIMEOUT 245
79 #define DEF_STP 8
80 #define DEF_SOF_RAD 0
81 #define DEF_SOF_RAA 0
82 #define DEF_ETM 0
83 #define DEF_PERE 1
84 #define DEF_CLKF 0
85 #define DEF_ENF 1
86 #define DEF_ADIDCHK 0
87 #define DEF_FASTSCSI 1
88 #define DEF_FASTCLK 1
89 #define DEF_GLITCH 1
90 #define DEF_PWD 0
91 #define DEF_RAE 0
92 #define DEF_RADE 1
93
94
95
96 #ifndef PCI_VENDOR_ID_AMD
97 #define PCI_VENDOR_ID_AMD 0x1022
98 #define PCI_DEVICE_ID_AMD_SCSI 0x2020
99 #endif
100 #define PCI_BASE_MASK 0xFFFFFFE0
101 #define PCI_COMMAND_PERREN 0x40
102 #define PCI_SCRATCH_REG_0 0x40
103 #define PCI_SCRATCH_REG_1 0x42
104 #define PCI_SCRATCH_REG_2 0x44
105 #define PCI_SCRATCH_REG_3 0x46
106 #define PCI_SCRATCH_REG_4 0x48
107 #define PCI_SCRATCH_REG_5 0x4A
108 #define PCI_SCRATCH_REG_6 0x4C
109 #define PCI_SCRATCH_REG_7 0x4E
110
111
112 #define CTCLREG 0x00
113 #define CTCMREG 0x04
114 #define CTCHREG 0x38
115 #define STCLREG 0x00
116 #define STCMREG 0x04
117 #define STCHREG 0x38
118 #define FFREG 0x08
119 #define STIMREG 0x14
120
121 #define SDIDREG 0x10
122 #define SDIREG_MASK 0x07
123
124 #define STPREG 0x18
125 #define STPREG_STP 0x1F
126
127 #define CLKFREG 0x24
128 #define CLKFREG_MASK 0x07
129
130 #define CMDREG 0x0C
131 #define CMDREG_DMA 0x80
132 #define CMDREG_IT 0x10
133 #define CMDREG_ICCS 0x11
134 #define CMDREG_MA 0x12
135 #define CMDREG_TPB 0x98
136 #define CMDREG_SATN 0x1A
137 #define CMDREG_RATN 0x1B
138 #define CMDREG_SOAS 0x41
139 #define CMDREG_SAS 0x42
140 #define CMDREG_SASS 0x43
141 #define CMDREG_ESR 0x44
142 #define CMDREG_DSR 0x45
143 #define CMDREG_SA3S 0x46
144 #define CMDREG_NOP 0x00
145 #define CMDREG_CFIFO 0x01
146 #define CMDREG_RDEV 0x02
147 #define CMDREG_RBUS 0x03
148
149 #define STATREG 0x10
150 #define STATREG_INT 0x80
151 #define STATREG_IOE 0x40
152 #define STATREG_PE 0x20
153 #define STATREG_CTZ 0x10
154 #define STATREG_MSG 0x04
155 #define STATREG_CD 0x02
156 #define STATREG_IO 0x01
157 #define STATREG_PHASE 0x07
158
159 #define INSTREG 0x14
160 #define INSTREG_SRST 0x80
161 #define INSTREG_ICMD 0x40
162 #define INSTREG_DIS 0x20
163 #define INSTREG_SR 0x10
164 #define INSTREG_SO 0x08
165 #define INSTREG_RESEL 0x04
166
167 #define ISREG 0x18
168 #define ISREG_SOF 0x08
169 #define ISREG_IS 0x07
170 #define ISREG_OK_NO_STOP 0x04
171 #define ISREG_OK_STOP 0x01
172
173 #define CFIREG 0x1C
174 #define CFIREG_IS 0xE0
175 #define CFIREG_CF 0x1F
176
177 #define SOFREG 0x1C
178 #define SOFREG_RAD 0xC0
179 #define SOFREG_RAA 0x30
180 #define SOFREG_SO 0x0F
181
182 #define CNTLREG1 0x20
183 #define CNTLREG1_ETM 0x80
184 #define CNTLREG1_DISR 0x40
185 #define CNTLREG1_PERE 0x10
186 #define CNTLREG1_SID 0x07
187
188 #define CNTLREG2 0x2C
189 #define CNTLREG2_ENF 0x40
190
191 #define CNTLREG3 0x30
192 #define CNTLREG3_ADIDCHK 0x80
193 #define CNTLREG3_FASTSCSI 0x10
194 #define CNTLREG3_FASTCLK 0x08
195
196 #define CNTLREG4 0x34
197 #define CNTLREG4_GLITCH 0xC0
198 #define CNTLREG4_PWD 0x20
199 #define CNTLREG4_RAE 0x08
200 #define CNTLREG4_RADE 0x04
201 #define CNTLREG4_RES 0x10
202
203
204 #define DMACMD 0x40
205 #define DMACMD_DIR 0x80
206 #define DMACMD_INTE_D 0x40
207 #define DMACMD_INTE_P 0x20
208 #define DMACMD_MDL 0x10
209 #define DMACMD_DIAG 0x04
210 #define DMACMD_IDLE 0x00
211 #define DMACMD_BLAST 0x01
212 #define DMACMD_ABORT 0x02
213 #define DMACMD_START 0x03
214
215 #define DMASTATUS 0x54
216 #define DMASTATUS_BCMPLT 0x20
217 #define DMASTATUS_SCSIINT 0x10
218 #define DMASTATUS_DONE 0x08
219 #define DMASTATUS_ABORT 0x04
220 #define DMASTATUS_ERROR 0x02
221 #define DMASTATUS_PWDN 0x02
222
223 #define DMASTC 0x44
224 #define DMASPA 0x48
225 #define DMAWBC 0x4C
226 #define DMAWAC 0x50
227 #define DMASMDLA 0x58
228 #define DMAWMAC 0x5C
229
230
231 #define PHASE_MSGIN 0x07
232 #define PHASE_MSGOUT 0x06
233 #define PHASE_RES_1 0x05
234 #define PHASE_RES_0 0x04
235 #define PHASE_STATIN 0x03
236 #define PHASE_CMDOUT 0x02
237 #define PHASE_DATAIN 0x01
238 #define PHASE_DATAOUT 0x00
239
240 struct AM53C974_hostdata {
241 volatile unsigned in_reset:1;
242 volatile unsigned aborted:1;
243 volatile unsigned selecting:1;
244 volatile unsigned disconnecting: 1;
245 volatile unsigned dma_busy:1;
246 volatile unsigned char msgout[10];
247 volatile unsigned char last_message[10];
248 volatile Scsi_Cmnd *issue_queue;
249 volatile Scsi_Cmnd *disconnected_queue;
250 volatile Scsi_Cmnd *sel_cmd;
251 volatile Scsi_Cmnd *connected;
252 volatile unsigned char busy[8];
253 unsigned char sync_per[8];
254 unsigned char sync_off[8];
255 unsigned char sync_neg[8];
256 unsigned char sync_en[8];
257 unsigned char max_rate[8];
258 unsigned char max_offset[8];
259 };
260
261 #define AM53C974 { \
262 NULL, \
263 NULL, \
264 NULL, \
265 NULL, \
266 "AM53C974", \
267 AM53C974_detect, \
268 NULL, \
269 AM53C974_info, \
270 AM53C974_command, \
271 AM53C974_queue_command,
272 \
273 AM53C974_abort, \
274 AM53C974_reset, \
275 NULL, \
276 scsicam_bios_param, \
277 12, \
278 -1, \
279 SG_ALL, \
280 1, \
281 0, \
282 0, \
283 DISABLE_CLUSTERING \
284 }
285
286 void AM53C974_setup(char *str, int *ints);
287 int AM53C974_detect(Scsi_Host_Template *tpnt);
288 int AM53C974_biosparm(Disk *disk, int dev, int *info_array);
289 const char *AM53C974_info(struct Scsi_Host *);
290 int AM53C974_command(Scsi_Cmnd *SCpnt);
291 int AM53C974_queue_command(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *));
292 int AM53C974_abort(Scsi_Cmnd *cmd);
293 int AM53C974_reset (Scsi_Cmnd *cmd);
294
295 #define AM53C974_local_declare() unsigned long io_port
296 #define AM53C974_setio(instance) io_port = instance->io_port
297 #define AM53C974_read_8(addr) inb(io_port + (addr))
298 #define AM53C974_write_8(addr,x) outb((x), io_port + (addr))
299 #define AM53C974_read_16(addr) inw(io_port + (addr))
300 #define AM53C974_write_16(addr,x) outw((x), io_port + (addr))
301 #define AM53C974_read_32(addr) inl(io_port + (addr))
302 #define AM53C974_write_32(addr,x) outl((x), io_port + (addr))
303
304 #define AM53C974_poll_int() { do { statreg = AM53C974_read_8(STATREG); } \
305 while (!(statreg & STATREG_INT)) ; \
306 AM53C974_read_8(INSTREG) ; }
307 #define AM53C974_cfifo() (AM53C974_read_8(CFIREG) & CFIREG_CF)
308
309
310 #define TAG_NEXT -1
311 #define TAG_NONE -2
312
313
314
315 typedef struct _override_t {
316 int host_scsi_id;
317 int target_scsi_id;
318 int max_rate;
319 int max_offset;
320 } override_t;
321
322
323 #define AM53C974_PCIREG_OPEN() outb(0xF1, 0xCF8); outb(0, 0xCFA)
324 #define AM53C974_PCIREG_CLOSE() outb(0, 0xCF8)
325 #define AM53C974_PCIREG_READ_BYTE(instance,a) ( inb((a) + (instance)->io_port) )
326 #define AM53C974_PCIREG_READ_WORD(instance,a) ( inw((a) + (instance)->io_port) )
327 #define AM53C974_PCIREG_READ_DWORD(instance,a) ( inl((a) + (instance)->io_port) )
328 #define AM53C974_PCIREG_WRITE_BYTE(instance,x,a) ( outb((x), (a) + (instance)->io_port) )
329 #define AM53C974_PCIREG_WRITE_WORD(instance,x,a) ( outw((x), (a) + (instance)->io_port) )
330 #define AM53C974_PCIREG_WRITE_DWORD(instance,x,a) ( outl((x), (a) + (instance)->io_port) )
331
332 typedef struct _pci_config_t {
333
334 union {
335 unsigned int device_vendor;
336 struct {
337 unsigned short vendor;
338 unsigned short device;
339 } dv;
340 } dv_id;
341 #define _device_vendor dv_id.device_vendor
342 #define _vendor dv_id.dv.vendor
343 #define _device dv_id.dv.device
344 union {
345 unsigned int status_command;
346 struct {
347 unsigned short command;
348 unsigned short status;
349 } sc;
350 } stat_cmd;
351 #define _status_command stat_cmd.status_command
352 #define _command stat_cmd.sc.command
353 #define _status stat_cmd.sc.status
354 union {
355 unsigned int class_revision;
356 struct {
357 unsigned char rev_id;
358 unsigned char prog_if;
359 unsigned char sub_class;
360 unsigned char base_class;
361 } cr;
362 } class_rev;
363 #define _class_revision class_rev.class_revision
364 #define _rev_id class_rev.cr.rev_id
365 #define _prog_if class_rev.cr.prog_if
366 #define _sub_class class_rev.cr.sub_class
367 #define _base_class class_rev.cr.base_class
368 union {
369 unsigned int bist_header_latency_cache;
370 struct {
371 unsigned char cache_line_size;
372 unsigned char latency_timer;
373 unsigned char header_type;
374 unsigned char bist;
375 } bhlc;
376 } bhlc;
377 #define _bist_header_latency_cache bhlc.bist_header_latency_cache
378 #define _cache_line_size bhlc.bhlc.cache_line_size
379 #define _latency_timer bhlc.bhlc.latency_timer
380 #define _header_type bhlc.bhlc.header_type
381 #define _bist bhlc.bhlc.bist
382 unsigned int _base0;
383 unsigned int _base1;
384 unsigned int _base2;
385 unsigned int _base3;
386 unsigned int _base4;
387 unsigned int _base5;
388 unsigned int rsvd1;
389 unsigned int rsvd2;
390 unsigned int _baserom;
391 unsigned int rsvd3;
392 unsigned int rsvd4;
393 union {
394 unsigned int max_min_ipin_iline;
395 struct {
396 unsigned char int_line;
397 unsigned char int_pin;
398 unsigned char min_gnt;
399 unsigned char max_lat;
400 } mmii;
401 } mmii;
402 #define _max_min_ipin_iline mmii.max_min_ipin_iline
403 #define _int_line mmii.mmii.int_line
404 #define _int_pin mmii.mmii.int_pin
405 #define _min_gnt mmii.mmii.min_gnt
406 #define _max_lat mmii.mmii.max_lat
407
408 unsigned short _ioaddr;
409 unsigned int _pcibus;
410 unsigned int _cardnum;
411 } pci_config_t;
412
413 #endif