aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/in2000.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/scsi/in2000.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/scsi/in2000.c')
-rw-r--r--drivers/scsi/in2000.c2323
1 files changed, 2323 insertions, 0 deletions
diff --git a/drivers/scsi/in2000.c b/drivers/scsi/in2000.c
new file mode 100644
index 000000000000..0bb0369efb2d
--- /dev/null
+++ b/drivers/scsi/in2000.c
@@ -0,0 +1,2323 @@
1/*
2 * in2000.c - Linux device driver for the
3 * Always IN2000 ISA SCSI card.
4 *
5 * Copyright (c) 1996 John Shifflett, GeoLog Consulting
6 * john@geolog.com
7 * jshiffle@netcom.com
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
12 * any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * For the avoidance of doubt the "preferred form" of this code is one which
20 * is in an open non patent encumbered format. Where cryptographic key signing
21 * forms part of the process of creating an executable the information
22 * including keys needed to generate an equivalently functional executable
23 * are deemed to be part of the source code.
24 *
25 * Drew Eckhardt's excellent 'Generic NCR5380' sources provided
26 * much of the inspiration and some of the code for this driver.
27 * The Linux IN2000 driver distributed in the Linux kernels through
28 * version 1.2.13 was an extremely valuable reference on the arcane
29 * (and still mysterious) workings of the IN2000's fifo. It also
30 * is where I lifted in2000_biosparam(), the gist of the card
31 * detection scheme, and other bits of code. Many thanks to the
32 * talented and courageous people who wrote, contributed to, and
33 * maintained that driver (including Brad McLean, Shaun Savage,
34 * Bill Earnest, Larry Doolittle, Roger Sunshine, John Luckey,
35 * Matt Postiff, Peter Lu, zerucha@shell.portal.com, and Eric
36 * Youngdale). I should also mention the driver written by
37 * Hamish Macdonald for the (GASP!) Amiga A2091 card, included
38 * in the Linux-m68k distribution; it gave me a good initial
39 * understanding of the proper way to run a WD33c93 chip, and I
40 * ended up stealing lots of code from it.
41 *
42 * _This_ driver is (I feel) an improvement over the old one in
43 * several respects:
44 * - All problems relating to the data size of a SCSI request are
45 * gone (as far as I know). The old driver couldn't handle
46 * swapping to partitions because that involved 4k blocks, nor
47 * could it deal with the st.c tape driver unmodified, because
48 * that usually involved 4k - 32k blocks. The old driver never
49 * quite got away from a morbid dependence on 2k block sizes -
50 * which of course is the size of the card's fifo.
51 *
52 * - Target Disconnection/Reconnection is now supported. Any
53 * system with more than one device active on the SCSI bus
54 * will benefit from this. The driver defaults to what I'm
55 * calling 'adaptive disconnect' - meaning that each command
56 * is evaluated individually as to whether or not it should
57 * be run with the option to disconnect/reselect (if the
58 * device chooses), or as a "SCSI-bus-hog".
59 *
60 * - Synchronous data transfers are now supported. Because there
61 * are a few devices (and many improperly terminated systems)
62 * that choke when doing sync, the default is sync DISABLED
63 * for all devices. This faster protocol can (and should!)
64 * be enabled on selected devices via the command-line.
65 *
66 * - Runtime operating parameters can now be specified through
67 * either the LILO or the 'insmod' command line. For LILO do:
68 * "in2000=blah,blah,blah"
69 * and with insmod go like:
70 * "insmod /usr/src/linux/modules/in2000.o setup_strings=blah,blah"
71 * The defaults should be good for most people. See the comment
72 * for 'setup_strings' below for more details.
73 *
74 * - The old driver relied exclusively on what the Western Digital
75 * docs call "Combination Level 2 Commands", which are a great
76 * idea in that the CPU is relieved of a lot of interrupt
77 * overhead. However, by accepting a certain (user-settable)
78 * amount of additional interrupts, this driver achieves
79 * better control over the SCSI bus, and data transfers are
80 * almost as fast while being much easier to define, track,
81 * and debug.
82 *
83 * - You can force detection of a card whose BIOS has been disabled.
84 *
85 * - Multiple IN2000 cards might almost be supported. I've tried to
86 * keep it in mind, but have no way to test...
87 *
88 *
89 * TODO:
90 * tagged queuing. multiple cards.
91 *
92 *
93 * NOTE:
94 * When using this or any other SCSI driver as a module, you'll
95 * find that with the stock kernel, at most _two_ SCSI hard
96 * drives will be linked into the device list (ie, usable).
97 * If your IN2000 card has more than 2 disks on its bus, you
98 * might want to change the define of 'SD_EXTRA_DEVS' in the
99 * 'hosts.h' file from 2 to whatever is appropriate. It took
100 * me a while to track down this surprisingly obscure and
101 * undocumented little "feature".
102 *
103 *
104 * People with bug reports, wish-lists, complaints, comments,
105 * or improvements are asked to pah-leeez email me (John Shifflett)
106 * at john@geolog.com or jshiffle@netcom.com! I'm anxious to get
107 * this thing into as good a shape as possible, and I'm positive
108 * there are lots of lurking bugs and "Stupid Places".
109 *
110 * Updated for Linux 2.5 by Alan Cox <alan@redhat.com>
111 * - Using new_eh handler
112 * - Hopefully got all the locking right again
113 * See "FIXME" notes for items that could do with more work
114 */
115
116#include <linux/module.h>
117#include <linux/blkdev.h>
118#include <linux/interrupt.h>
119#include <linux/string.h>
120#include <linux/delay.h>
121#include <linux/proc_fs.h>
122#include <linux/ioport.h>
123#include <linux/stat.h>
124
125#include <asm/io.h>
126#include <asm/system.h>
127
128#include "scsi.h"
129#include <scsi/scsi_host.h>
130
131#define IN2000_VERSION "1.33-2.5"
132#define IN2000_DATE "2002/11/03"
133
134#include "in2000.h"
135
136
137/*
138 * 'setup_strings' is a single string used to pass operating parameters and
139 * settings from the kernel/module command-line to the driver. 'setup_args[]'
140 * is an array of strings that define the compile-time default values for
141 * these settings. If Linux boots with a LILO or insmod command-line, those
142 * settings are combined with 'setup_args[]'. Note that LILO command-lines
143 * are prefixed with "in2000=" while insmod uses a "setup_strings=" prefix.
144 * The driver recognizes the following keywords (lower case required) and
145 * arguments:
146 *
147 * - ioport:addr -Where addr is IO address of a (usually ROM-less) card.
148 * - noreset -No optional args. Prevents SCSI bus reset at boot time.
149 * - nosync:x -x is a bitmask where the 1st 7 bits correspond with
150 * the 7 possible SCSI devices (bit 0 for device #0, etc).
151 * Set a bit to PREVENT sync negotiation on that device.
152 * The driver default is sync DISABLED on all devices.
153 * - period:ns -ns is the minimum # of nanoseconds in a SCSI data transfer
154 * period. Default is 500; acceptable values are 250 - 1000.
155 * - disconnect:x -x = 0 to never allow disconnects, 2 to always allow them.
156 * x = 1 does 'adaptive' disconnects, which is the default
157 * and generally the best choice.
158 * - debug:x -If 'DEBUGGING_ON' is defined, x is a bitmask that causes
159 * various types of debug output to printed - see the DB_xxx
160 * defines in in2000.h
161 * - proc:x -If 'PROC_INTERFACE' is defined, x is a bitmask that
162 * determines how the /proc interface works and what it
163 * does - see the PR_xxx defines in in2000.h
164 *
165 * Syntax Notes:
166 * - Numeric arguments can be decimal or the '0x' form of hex notation. There
167 * _must_ be a colon between a keyword and its numeric argument, with no
168 * spaces.
169 * - Keywords are separated by commas, no spaces, in the standard kernel
170 * command-line manner.
171 * - A keyword in the 'nth' comma-separated command-line member will overwrite
172 * the 'nth' element of setup_args[]. A blank command-line member (in
173 * other words, a comma with no preceding keyword) will _not_ overwrite
174 * the corresponding setup_args[] element.
175 *
176 * A few LILO examples (for insmod, use 'setup_strings' instead of 'in2000'):
177 * - in2000=ioport:0x220,noreset
178 * - in2000=period:250,disconnect:2,nosync:0x03
179 * - in2000=debug:0x1e
180 * - in2000=proc:3
181 */
182
183/* Normally, no defaults are specified... */
184static char *setup_args[] = { "", "", "", "", "", "", "", "", "" };
185
186/* filled in by 'insmod' */
187static char *setup_strings;
188
189module_param(setup_strings, charp, 0);
190
191static inline uchar read_3393(struct IN2000_hostdata *hostdata, uchar reg_num)
192{
193 write1_io(reg_num, IO_WD_ADDR);
194 return read1_io(IO_WD_DATA);
195}
196
197
198#define READ_AUX_STAT() read1_io(IO_WD_ASR)
199
200
201static inline void write_3393(struct IN2000_hostdata *hostdata, uchar reg_num, uchar value)
202{
203 write1_io(reg_num, IO_WD_ADDR);
204 write1_io(value, IO_WD_DATA);
205}
206
207
208static inline void write_3393_cmd(struct IN2000_hostdata *hostdata, uchar cmd)
209{
210/* while (READ_AUX_STAT() & ASR_CIP)
211 printk("|");*/
212 write1_io(WD_COMMAND, IO_WD_ADDR);
213 write1_io(cmd, IO_WD_DATA);
214}
215
216
217static uchar read_1_byte(struct IN2000_hostdata *hostdata)
218{
219 uchar asr, x = 0;
220
221 write_3393(hostdata, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
222 write_3393_cmd(hostdata, WD_CMD_TRANS_INFO | 0x80);
223 do {
224 asr = READ_AUX_STAT();
225 if (asr & ASR_DBR)
226 x = read_3393(hostdata, WD_DATA);
227 } while (!(asr & ASR_INT));
228 return x;
229}
230
231
232static void write_3393_count(struct IN2000_hostdata *hostdata, unsigned long value)
233{
234 write1_io(WD_TRANSFER_COUNT_MSB, IO_WD_ADDR);
235 write1_io((value >> 16), IO_WD_DATA);
236 write1_io((value >> 8), IO_WD_DATA);
237 write1_io(value, IO_WD_DATA);
238}
239
240
241static unsigned long read_3393_count(struct IN2000_hostdata *hostdata)
242{
243 unsigned long value;
244
245 write1_io(WD_TRANSFER_COUNT_MSB, IO_WD_ADDR);
246 value = read1_io(IO_WD_DATA) << 16;
247 value |= read1_io(IO_WD_DATA) << 8;
248 value |= read1_io(IO_WD_DATA);
249 return value;
250}
251
252
253/* The 33c93 needs to be told which direction a command transfers its
254 * data; we use this function to figure it out. Returns true if there
255 * will be a DATA_OUT phase with this command, false otherwise.
256 * (Thanks to Joerg Dorchain for the research and suggestion.)
257 */
258static int is_dir_out(Scsi_Cmnd * cmd)
259{
260 switch (cmd->cmnd[0]) {
261 case WRITE_6:
262 case WRITE_10:
263 case WRITE_12:
264 case WRITE_LONG:
265 case WRITE_SAME:
266 case WRITE_BUFFER:
267 case WRITE_VERIFY:
268 case WRITE_VERIFY_12:
269 case COMPARE:
270 case COPY:
271 case COPY_VERIFY:
272 case SEARCH_EQUAL:
273 case SEARCH_HIGH:
274 case SEARCH_LOW:
275 case SEARCH_EQUAL_12:
276 case SEARCH_HIGH_12:
277 case SEARCH_LOW_12:
278 case FORMAT_UNIT:
279 case REASSIGN_BLOCKS:
280 case RESERVE:
281 case MODE_SELECT:
282 case MODE_SELECT_10:
283 case LOG_SELECT:
284 case SEND_DIAGNOSTIC:
285 case CHANGE_DEFINITION:
286 case UPDATE_BLOCK:
287 case SET_WINDOW:
288 case MEDIUM_SCAN:
289 case SEND_VOLUME_TAG:
290 case 0xea:
291 return 1;
292 default:
293 return 0;
294 }
295}
296
297
298
299static struct sx_period sx_table[] = {
300 {1, 0x20},
301 {252, 0x20},
302 {376, 0x30},
303 {500, 0x40},
304 {624, 0x50},
305 {752, 0x60},
306 {876, 0x70},
307 {1000, 0x00},
308 {0, 0}
309};
310
311static int round_period(unsigned int period)
312{
313 int x;
314
315 for (x = 1; sx_table[x].period_ns; x++) {
316 if ((period <= sx_table[x - 0].period_ns) && (period > sx_table[x - 1].period_ns)) {
317 return x;
318 }
319 }
320 return 7;
321}
322
323static uchar calc_sync_xfer(unsigned int period, unsigned int offset)
324{
325 uchar result;
326
327 period *= 4; /* convert SDTR code to ns */
328 result = sx_table[round_period(period)].reg_value;
329 result |= (offset < OPTIMUM_SX_OFF) ? offset : OPTIMUM_SX_OFF;
330 return result;
331}
332
333
334
335static void in2000_execute(struct Scsi_Host *instance);
336
337static int in2000_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
338{
339 struct Scsi_Host *instance;
340 struct IN2000_hostdata *hostdata;
341 Scsi_Cmnd *tmp;
342
343 instance = cmd->device->host;
344 hostdata = (struct IN2000_hostdata *) instance->hostdata;
345
346 DB(DB_QUEUE_COMMAND, printk("Q-%d-%02x-%ld(", cmd->device->id, cmd->cmnd[0], cmd->pid))
347
348/* Set up a few fields in the Scsi_Cmnd structure for our own use:
349 * - host_scribble is the pointer to the next cmd in the input queue
350 * - scsi_done points to the routine we call when a cmd is finished
351 * - result is what you'd expect
352 */
353 cmd->host_scribble = NULL;
354 cmd->scsi_done = done;
355 cmd->result = 0;
356
357/* We use the Scsi_Pointer structure that's included with each command
358 * as a scratchpad (as it's intended to be used!). The handy thing about
359 * the SCp.xxx fields is that they're always associated with a given
360 * cmd, and are preserved across disconnect-reselect. This means we
361 * can pretty much ignore SAVE_POINTERS and RESTORE_POINTERS messages
362 * if we keep all the critical pointers and counters in SCp:
363 * - SCp.ptr is the pointer into the RAM buffer
364 * - SCp.this_residual is the size of that buffer
365 * - SCp.buffer points to the current scatter-gather buffer
366 * - SCp.buffers_residual tells us how many S.G. buffers there are
367 * - SCp.have_data_in helps keep track of >2048 byte transfers
368 * - SCp.sent_command is not used
369 * - SCp.phase records this command's SRCID_ER bit setting
370 */
371
372 if (cmd->use_sg) {
373 cmd->SCp.buffer = (struct scatterlist *) cmd->buffer;
374 cmd->SCp.buffers_residual = cmd->use_sg - 1;
375 cmd->SCp.ptr = (char *) page_address(cmd->SCp.buffer->page) + cmd->SCp.buffer->offset;
376 cmd->SCp.this_residual = cmd->SCp.buffer->length;
377 } else {
378 cmd->SCp.buffer = NULL;
379 cmd->SCp.buffers_residual = 0;
380 cmd->SCp.ptr = (char *) cmd->request_buffer;
381 cmd->SCp.this_residual = cmd->request_bufflen;
382 }
383 cmd->SCp.have_data_in = 0;
384
385/* We don't set SCp.phase here - that's done in in2000_execute() */
386
387/* WD docs state that at the conclusion of a "LEVEL2" command, the
388 * status byte can be retrieved from the LUN register. Apparently,
389 * this is the case only for *uninterrupted* LEVEL2 commands! If
390 * there are any unexpected phases entered, even if they are 100%
391 * legal (different devices may choose to do things differently),
392 * the LEVEL2 command sequence is exited. This often occurs prior
393 * to receiving the status byte, in which case the driver does a
394 * status phase interrupt and gets the status byte on its own.
395 * While such a command can then be "resumed" (ie restarted to
396 * finish up as a LEVEL2 command), the LUN register will NOT be
397 * a valid status byte at the command's conclusion, and we must
398 * use the byte obtained during the earlier interrupt. Here, we
399 * preset SCp.Status to an illegal value (0xff) so that when
400 * this command finally completes, we can tell where the actual
401 * status byte is stored.
402 */
403
404 cmd->SCp.Status = ILLEGAL_STATUS_BYTE;
405
406/* We need to disable interrupts before messing with the input
407 * queue and calling in2000_execute().
408 */
409
410 /*
411 * Add the cmd to the end of 'input_Q'. Note that REQUEST_SENSE
412 * commands are added to the head of the queue so that the desired
413 * sense data is not lost before REQUEST_SENSE executes.
414 */
415
416 if (!(hostdata->input_Q) || (cmd->cmnd[0] == REQUEST_SENSE)) {
417 cmd->host_scribble = (uchar *) hostdata->input_Q;
418 hostdata->input_Q = cmd;
419 } else { /* find the end of the queue */
420 for (tmp = (Scsi_Cmnd *) hostdata->input_Q; tmp->host_scribble; tmp = (Scsi_Cmnd *) tmp->host_scribble);
421 tmp->host_scribble = (uchar *) cmd;
422 }
423
424/* We know that there's at least one command in 'input_Q' now.
425 * Go see if any of them are runnable!
426 */
427
428 in2000_execute(cmd->device->host);
429
430 DB(DB_QUEUE_COMMAND, printk(")Q-%ld ", cmd->pid))
431 return 0;
432}
433
434
435
436/*
437 * This routine attempts to start a scsi command. If the host_card is
438 * already connected, we give up immediately. Otherwise, look through
439 * the input_Q, using the first command we find that's intended
440 * for a currently non-busy target/lun.
441 * Note that this function is always called with interrupts already
442 * disabled (either from in2000_queuecommand() or in2000_intr()).
443 */
444static void in2000_execute(struct Scsi_Host *instance)
445{
446 struct IN2000_hostdata *hostdata;
447 Scsi_Cmnd *cmd, *prev;
448 int i;
449 unsigned short *sp;
450 unsigned short f;
451 unsigned short flushbuf[16];
452
453
454 hostdata = (struct IN2000_hostdata *) instance->hostdata;
455
456 DB(DB_EXECUTE, printk("EX("))
457
458 if (hostdata->selecting || hostdata->connected) {
459
460 DB(DB_EXECUTE, printk(")EX-0 "))
461
462 return;
463 }
464
465 /*
466 * Search through the input_Q for a command destined
467 * for an idle target/lun.
468 */
469
470 cmd = (Scsi_Cmnd *) hostdata->input_Q;
471 prev = NULL;
472 while (cmd) {
473 if (!(hostdata->busy[cmd->device->id] & (1 << cmd->device->lun)))
474 break;
475 prev = cmd;
476 cmd = (Scsi_Cmnd *) cmd->host_scribble;
477 }
478
479 /* quit if queue empty or all possible targets are busy */
480
481 if (!cmd) {
482
483 DB(DB_EXECUTE, printk(")EX-1 "))
484
485 return;
486 }
487
488 /* remove command from queue */
489
490 if (prev)
491 prev->host_scribble = cmd->host_scribble;
492 else
493 hostdata->input_Q = (Scsi_Cmnd *) cmd->host_scribble;
494
495#ifdef PROC_STATISTICS
496 hostdata->cmd_cnt[cmd->device->id]++;
497#endif
498
499/*
500 * Start the selection process
501 */
502
503 if (is_dir_out(cmd))
504 write_3393(hostdata, WD_DESTINATION_ID, cmd->device->id);
505 else
506 write_3393(hostdata, WD_DESTINATION_ID, cmd->device->id | DSTID_DPD);
507
508/* Now we need to figure out whether or not this command is a good
509 * candidate for disconnect/reselect. We guess to the best of our
510 * ability, based on a set of hierarchical rules. When several
511 * devices are operating simultaneously, disconnects are usually
512 * an advantage. In a single device system, or if only 1 device
513 * is being accessed, transfers usually go faster if disconnects
514 * are not allowed:
515 *
516 * + Commands should NEVER disconnect if hostdata->disconnect =
517 * DIS_NEVER (this holds for tape drives also), and ALWAYS
518 * disconnect if hostdata->disconnect = DIS_ALWAYS.
519 * + Tape drive commands should always be allowed to disconnect.
520 * + Disconnect should be allowed if disconnected_Q isn't empty.
521 * + Commands should NOT disconnect if input_Q is empty.
522 * + Disconnect should be allowed if there are commands in input_Q
523 * for a different target/lun. In this case, the other commands
524 * should be made disconnect-able, if not already.
525 *
526 * I know, I know - this code would flunk me out of any
527 * "C Programming 101" class ever offered. But it's easy
528 * to change around and experiment with for now.
529 */
530
531 cmd->SCp.phase = 0; /* assume no disconnect */
532 if (hostdata->disconnect == DIS_NEVER)
533 goto no;
534 if (hostdata->disconnect == DIS_ALWAYS)
535 goto yes;
536 if (cmd->device->type == 1) /* tape drive? */
537 goto yes;
538 if (hostdata->disconnected_Q) /* other commands disconnected? */
539 goto yes;
540 if (!(hostdata->input_Q)) /* input_Q empty? */
541 goto no;
542 for (prev = (Scsi_Cmnd *) hostdata->input_Q; prev; prev = (Scsi_Cmnd *) prev->host_scribble) {
543 if ((prev->device->id != cmd->device->id) || (prev->device->lun != cmd->device->lun)) {
544 for (prev = (Scsi_Cmnd *) hostdata->input_Q; prev; prev = (Scsi_Cmnd *) prev->host_scribble)
545 prev->SCp.phase = 1;
546 goto yes;
547 }
548 }
549 goto no;
550
551 yes:
552 cmd->SCp.phase = 1;
553
554#ifdef PROC_STATISTICS
555 hostdata->disc_allowed_cnt[cmd->device->id]++;
556#endif
557
558 no:
559 write_3393(hostdata, WD_SOURCE_ID, ((cmd->SCp.phase) ? SRCID_ER : 0));
560
561 write_3393(hostdata, WD_TARGET_LUN, cmd->device->lun);
562 write_3393(hostdata, WD_SYNCHRONOUS_TRANSFER, hostdata->sync_xfer[cmd->device->id]);
563 hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun);
564
565 if ((hostdata->level2 <= L2_NONE) || (hostdata->sync_stat[cmd->device->id] == SS_UNSET)) {
566
567 /*
568 * Do a 'Select-With-ATN' command. This will end with
569 * one of the following interrupts:
570 * CSR_RESEL_AM: failure - can try again later.
571 * CSR_TIMEOUT: failure - give up.
572 * CSR_SELECT: success - proceed.
573 */
574
575 hostdata->selecting = cmd;
576
577/* Every target has its own synchronous transfer setting, kept in
578 * the sync_xfer array, and a corresponding status byte in sync_stat[].
579 * Each target's sync_stat[] entry is initialized to SS_UNSET, and its
580 * sync_xfer[] entry is initialized to the default/safe value. SS_UNSET
581 * means that the parameters are undetermined as yet, and that we
582 * need to send an SDTR message to this device after selection is
583 * complete. We set SS_FIRST to tell the interrupt routine to do so,
584 * unless we don't want to even _try_ synchronous transfers: In this
585 * case we set SS_SET to make the defaults final.
586 */
587 if (hostdata->sync_stat[cmd->device->id] == SS_UNSET) {
588 if (hostdata->sync_off & (1 << cmd->device->id))
589 hostdata->sync_stat[cmd->device->id] = SS_SET;
590 else
591 hostdata->sync_stat[cmd->device->id] = SS_FIRST;
592 }
593 hostdata->state = S_SELECTING;
594 write_3393_count(hostdata, 0); /* this guarantees a DATA_PHASE interrupt */
595 write_3393_cmd(hostdata, WD_CMD_SEL_ATN);
596 }
597
598 else {
599
600 /*
601 * Do a 'Select-With-ATN-Xfer' command. This will end with
602 * one of the following interrupts:
603 * CSR_RESEL_AM: failure - can try again later.
604 * CSR_TIMEOUT: failure - give up.
605 * anything else: success - proceed.
606 */
607
608 hostdata->connected = cmd;
609 write_3393(hostdata, WD_COMMAND_PHASE, 0);
610
611 /* copy command_descriptor_block into WD chip
612 * (take advantage of auto-incrementing)
613 */
614
615 write1_io(WD_CDB_1, IO_WD_ADDR);
616 for (i = 0; i < cmd->cmd_len; i++)
617 write1_io(cmd->cmnd[i], IO_WD_DATA);
618
619 /* The wd33c93 only knows about Group 0, 1, and 5 commands when
620 * it's doing a 'select-and-transfer'. To be safe, we write the
621 * size of the CDB into the OWN_ID register for every case. This
622 * way there won't be problems with vendor-unique, audio, etc.
623 */
624
625 write_3393(hostdata, WD_OWN_ID, cmd->cmd_len);
626
627 /* When doing a non-disconnect command, we can save ourselves a DATA
628 * phase interrupt later by setting everything up now. With writes we
629 * need to pre-fill the fifo; if there's room for the 32 flush bytes,
630 * put them in there too - that'll avoid a fifo interrupt. Reads are
631 * somewhat simpler.
632 * KLUDGE NOTE: It seems that you can't completely fill the fifo here:
633 * This results in the IO_FIFO_COUNT register rolling over to zero,
634 * and apparently the gate array logic sees this as empty, not full,
635 * so the 3393 chip is never signalled to start reading from the
636 * fifo. Or maybe it's seen as a permanent fifo interrupt condition.
637 * Regardless, we fix this by temporarily pretending that the fifo
638 * is 16 bytes smaller. (I see now that the old driver has a comment
639 * about "don't fill completely" in an analogous place - must be the
640 * same deal.) This results in CDROM, swap partitions, and tape drives
641 * needing an extra interrupt per write command - I think we can live
642 * with that!
643 */
644
645 if (!(cmd->SCp.phase)) {
646 write_3393_count(hostdata, cmd->SCp.this_residual);
647 write_3393(hostdata, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_BUS);
648 write1_io(0, IO_FIFO_WRITE); /* clear fifo counter, write mode */
649
650 if (is_dir_out(cmd)) {
651 hostdata->fifo = FI_FIFO_WRITING;
652 if ((i = cmd->SCp.this_residual) > (IN2000_FIFO_SIZE - 16))
653 i = IN2000_FIFO_SIZE - 16;
654 cmd->SCp.have_data_in = i; /* this much data in fifo */
655 i >>= 1; /* Gulp. Assuming modulo 2. */
656 sp = (unsigned short *) cmd->SCp.ptr;
657 f = hostdata->io_base + IO_FIFO;
658
659#ifdef FAST_WRITE_IO
660
661 FAST_WRITE2_IO();
662#else
663 while (i--)
664 write2_io(*sp++, IO_FIFO);
665
666#endif
667
668 /* Is there room for the flush bytes? */
669
670 if (cmd->SCp.have_data_in <= ((IN2000_FIFO_SIZE - 16) - 32)) {
671 sp = flushbuf;
672 i = 16;
673
674#ifdef FAST_WRITE_IO
675
676 FAST_WRITE2_IO();
677#else
678 while (i--)
679 write2_io(0, IO_FIFO);
680
681#endif
682
683 }
684 }
685
686 else {
687 write1_io(0, IO_FIFO_READ); /* put fifo in read mode */
688 hostdata->fifo = FI_FIFO_READING;
689 cmd->SCp.have_data_in = 0; /* nothing transferred yet */
690 }
691
692 } else {
693 write_3393_count(hostdata, 0); /* this guarantees a DATA_PHASE interrupt */
694 }
695 hostdata->state = S_RUNNING_LEVEL2;
696 write_3393_cmd(hostdata, WD_CMD_SEL_ATN_XFER);
697 }
698
699 /*
700 * Since the SCSI bus can handle only 1 connection at a time,
701 * we get out of here now. If the selection fails, or when
702 * the command disconnects, we'll come back to this routine
703 * to search the input_Q again...
704 */
705
706 DB(DB_EXECUTE, printk("%s%ld)EX-2 ", (cmd->SCp.phase) ? "d:" : "", cmd->pid))
707
708}
709
710
711
712static void transfer_pio(uchar * buf, int cnt, int data_in_dir, struct IN2000_hostdata *hostdata)
713{
714 uchar asr;
715
716 DB(DB_TRANSFER, printk("(%p,%d,%s)", buf, cnt, data_in_dir ? "in" : "out"))
717
718 write_3393(hostdata, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
719 write_3393_count(hostdata, cnt);
720 write_3393_cmd(hostdata, WD_CMD_TRANS_INFO);
721 if (data_in_dir) {
722 do {
723 asr = READ_AUX_STAT();
724 if (asr & ASR_DBR)
725 *buf++ = read_3393(hostdata, WD_DATA);
726 } while (!(asr & ASR_INT));
727 } else {
728 do {
729 asr = READ_AUX_STAT();
730 if (asr & ASR_DBR)
731 write_3393(hostdata, WD_DATA, *buf++);
732 } while (!(asr & ASR_INT));
733 }
734
735 /* Note: we are returning with the interrupt UN-cleared.
736 * Since (presumably) an entire I/O operation has
737 * completed, the bus phase is probably different, and
738 * the interrupt routine will discover this when it
739 * responds to the uncleared int.
740 */
741
742}
743
744
745
746static void transfer_bytes(Scsi_Cmnd * cmd, int data_in_dir)
747{
748 struct IN2000_hostdata *hostdata;
749 unsigned short *sp;
750 unsigned short f;
751 int i;
752
753 hostdata = (struct IN2000_hostdata *) cmd->device->host->hostdata;
754
755/* Normally, you'd expect 'this_residual' to be non-zero here.
756 * In a series of scatter-gather transfers, however, this
757 * routine will usually be called with 'this_residual' equal
758 * to 0 and 'buffers_residual' non-zero. This means that a
759 * previous transfer completed, clearing 'this_residual', and
760 * now we need to setup the next scatter-gather buffer as the
761 * source or destination for THIS transfer.
762 */
763 if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) {
764 ++cmd->SCp.buffer;
765 --cmd->SCp.buffers_residual;
766 cmd->SCp.this_residual = cmd->SCp.buffer->length;
767 cmd->SCp.ptr = page_address(cmd->SCp.buffer->page) + cmd->SCp.buffer->offset;
768 }
769
770/* Set up hardware registers */
771
772 write_3393(hostdata, WD_SYNCHRONOUS_TRANSFER, hostdata->sync_xfer[cmd->device->id]);
773 write_3393_count(hostdata, cmd->SCp.this_residual);
774 write_3393(hostdata, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_BUS);
775 write1_io(0, IO_FIFO_WRITE); /* zero counter, assume write */
776
777/* Reading is easy. Just issue the command and return - we'll
778 * get an interrupt later when we have actual data to worry about.
779 */
780
781 if (data_in_dir) {
782 write1_io(0, IO_FIFO_READ);
783 if ((hostdata->level2 >= L2_DATA) || (hostdata->level2 == L2_BASIC && cmd->SCp.phase == 0)) {
784 write_3393(hostdata, WD_COMMAND_PHASE, 0x45);
785 write_3393_cmd(hostdata, WD_CMD_SEL_ATN_XFER);
786 hostdata->state = S_RUNNING_LEVEL2;
787 } else
788 write_3393_cmd(hostdata, WD_CMD_TRANS_INFO);
789 hostdata->fifo = FI_FIFO_READING;
790 cmd->SCp.have_data_in = 0;
791 return;
792 }
793
794/* Writing is more involved - we'll start the WD chip and write as
795 * much data to the fifo as we can right now. Later interrupts will
796 * write any bytes that don't make it at this stage.
797 */
798
799 if ((hostdata->level2 >= L2_DATA) || (hostdata->level2 == L2_BASIC && cmd->SCp.phase == 0)) {
800 write_3393(hostdata, WD_COMMAND_PHASE, 0x45);
801 write_3393_cmd(hostdata, WD_CMD_SEL_ATN_XFER);
802 hostdata->state = S_RUNNING_LEVEL2;
803 } else
804 write_3393_cmd(hostdata, WD_CMD_TRANS_INFO);
805 hostdata->fifo = FI_FIFO_WRITING;
806 sp = (unsigned short *) cmd->SCp.ptr;
807
808 if ((i = cmd->SCp.this_residual) > IN2000_FIFO_SIZE)
809 i = IN2000_FIFO_SIZE;
810 cmd->SCp.have_data_in = i;
811 i >>= 1; /* Gulp. We assume this_residual is modulo 2 */
812 f = hostdata->io_base + IO_FIFO;
813
814#ifdef FAST_WRITE_IO
815
816 FAST_WRITE2_IO();
817#else
818 while (i--)
819 write2_io(*sp++, IO_FIFO);
820
821#endif
822
823}
824
825
826/* We need to use spin_lock_irqsave() & spin_unlock_irqrestore() in this
827 * function in order to work in an SMP environment. (I'd be surprised
828 * if the driver is ever used by anyone on a real multi-CPU motherboard,
829 * but it _does_ need to be able to compile and run in an SMP kernel.)
830 */
831
832static irqreturn_t in2000_intr(int irqnum, void *dev_id, struct pt_regs *ptregs)
833{
834 struct Scsi_Host *instance = dev_id;
835 struct IN2000_hostdata *hostdata;
836 Scsi_Cmnd *patch, *cmd;
837 uchar asr, sr, phs, id, lun, *ucp, msg;
838 int i, j;
839 unsigned long length;
840 unsigned short *sp;
841 unsigned short f;
842 unsigned long flags;
843
844 hostdata = (struct IN2000_hostdata *) instance->hostdata;
845
846/* Get the spin_lock and disable further ints, for SMP */
847
848 spin_lock_irqsave(instance->host_lock, flags);
849
850#ifdef PROC_STATISTICS
851 hostdata->int_cnt++;
852#endif
853
854/* The IN2000 card has 2 interrupt sources OR'ed onto its IRQ line - the
855 * WD3393 chip and the 2k fifo (which is actually a dual-port RAM combined
856 * with a big logic array, so it's a little different than what you might
857 * expect). As far as I know, there's no reason that BOTH can't be active
858 * at the same time, but there's a problem: while we can read the 3393
859 * to tell if _it_ wants an interrupt, I don't know of a way to ask the
860 * fifo the same question. The best we can do is check the 3393 and if
861 * it _isn't_ the source of the interrupt, then we can be pretty sure
862 * that the fifo is the culprit.
863 * UPDATE: I have it on good authority (Bill Earnest) that bit 0 of the
864 * IO_FIFO_COUNT register mirrors the fifo interrupt state. I
865 * assume that bit clear means interrupt active. As it turns
866 * out, the driver really doesn't need to check for this after
867 * all, so my remarks above about a 'problem' can safely be
868 * ignored. The way the logic is set up, there's no advantage
869 * (that I can see) to worrying about it.
870 *
871 * It seems that the fifo interrupt signal is negated when we extract
872 * bytes during read or write bytes during write.
873 * - fifo will interrupt when data is moving from it to the 3393, and
874 * there are 31 (or less?) bytes left to go. This is sort of short-
875 * sighted: what if you don't WANT to do more? In any case, our
876 * response is to push more into the fifo - either actual data or
877 * dummy bytes if need be. Note that we apparently have to write at
878 * least 32 additional bytes to the fifo after an interrupt in order
879 * to get it to release the ones it was holding on to - writing fewer
880 * than 32 will result in another fifo int.
881 * UPDATE: Again, info from Bill Earnest makes this more understandable:
882 * 32 bytes = two counts of the fifo counter register. He tells
883 * me that the fifo interrupt is a non-latching signal derived
884 * from a straightforward boolean interpretation of the 7
885 * highest bits of the fifo counter and the fifo-read/fifo-write
886 * state. Who'd a thought?
887 */
888
889 write1_io(0, IO_LED_ON);
890 asr = READ_AUX_STAT();
891 if (!(asr & ASR_INT)) { /* no WD33c93 interrupt? */
892
893/* Ok. This is definitely a FIFO-only interrupt.
894 *
895 * If FI_FIFO_READING is set, there are up to 2048 bytes waiting to be read,
896 * maybe more to come from the SCSI bus. Read as many as we can out of the
897 * fifo and into memory at the location of SCp.ptr[SCp.have_data_in], and
898 * update have_data_in afterwards.
899 *
900 * If we have FI_FIFO_WRITING, the FIFO has almost run out of bytes to move
901 * into the WD3393 chip (I think the interrupt happens when there are 31
902 * bytes left, but it may be fewer...). The 3393 is still waiting, so we
903 * shove some more into the fifo, which gets things moving again. If the
904 * original SCSI command specified more than 2048 bytes, there may still
905 * be some of that data left: fine - use it (from SCp.ptr[SCp.have_data_in]).
906 * Don't forget to update have_data_in. If we've already written out the
907 * entire buffer, feed 32 dummy bytes to the fifo - they're needed to
908 * push out the remaining real data.
909 * (Big thanks to Bill Earnest for getting me out of the mud in here.)
910 */
911
912 cmd = (Scsi_Cmnd *) hostdata->connected; /* assume we're connected */
913 CHECK_NULL(cmd, "fifo_int")
914
915 if (hostdata->fifo == FI_FIFO_READING) {
916
917 DB(DB_FIFO, printk("{R:%02x} ", read1_io(IO_FIFO_COUNT)))
918
919 sp = (unsigned short *) (cmd->SCp.ptr + cmd->SCp.have_data_in);
920 i = read1_io(IO_FIFO_COUNT) & 0xfe;
921 i <<= 2; /* # of words waiting in the fifo */
922 f = hostdata->io_base + IO_FIFO;
923
924#ifdef FAST_READ_IO
925
926 FAST_READ2_IO();
927#else
928 while (i--)
929 *sp++ = read2_io(IO_FIFO);
930
931#endif
932
933 i = sp - (unsigned short *) (cmd->SCp.ptr + cmd->SCp.have_data_in);
934 i <<= 1;
935 cmd->SCp.have_data_in += i;
936 }
937
938 else if (hostdata->fifo == FI_FIFO_WRITING) {
939
940 DB(DB_FIFO, printk("{W:%02x} ", read1_io(IO_FIFO_COUNT)))
941
942/* If all bytes have been written to the fifo, flush out the stragglers.
943 * Note that while writing 16 dummy words seems arbitrary, we don't
944 * have another choice that I can see. What we really want is to read
945 * the 3393 transfer count register (that would tell us how many bytes
946 * needed flushing), but the TRANSFER_INFO command hasn't completed
947 * yet (not enough bytes!) and that register won't be accessible. So,
948 * we use 16 words - a number obtained through trial and error.
949 * UPDATE: Bill says this is exactly what Always does, so there.
950 * More thanks due him for help in this section.
951 */
952 if (cmd->SCp.this_residual == cmd->SCp.have_data_in) {
953 i = 16;
954 while (i--) /* write 32 dummy bytes */
955 write2_io(0, IO_FIFO);
956 }
957
958/* If there are still bytes left in the SCSI buffer, write as many as we
959 * can out to the fifo.
960 */
961
962 else {
963 sp = (unsigned short *) (cmd->SCp.ptr + cmd->SCp.have_data_in);
964 i = cmd->SCp.this_residual - cmd->SCp.have_data_in; /* bytes yet to go */
965 j = read1_io(IO_FIFO_COUNT) & 0xfe;
966 j <<= 2; /* how many words the fifo has room for */
967 if ((j << 1) > i)
968 j = (i >> 1);
969 while (j--)
970 write2_io(*sp++, IO_FIFO);
971
972 i = sp - (unsigned short *) (cmd->SCp.ptr + cmd->SCp.have_data_in);
973 i <<= 1;
974 cmd->SCp.have_data_in += i;
975 }
976 }
977
978 else {
979 printk("*** Spurious FIFO interrupt ***");
980 }
981
982 write1_io(0, IO_LED_OFF);
983
984/* release the SMP spin_lock and restore irq state */
985 spin_unlock_irqrestore(instance->host_lock, flags);
986 return IRQ_HANDLED;
987 }
988
989/* This interrupt was triggered by the WD33c93 chip. The fifo interrupt
990 * may also be asserted, but we don't bother to check it: we get more
991 * detailed info from FIFO_READING and FIFO_WRITING (see below).
992 */
993
994 cmd = (Scsi_Cmnd *) hostdata->connected; /* assume we're connected */
995 sr = read_3393(hostdata, WD_SCSI_STATUS); /* clear the interrupt */
996 phs = read_3393(hostdata, WD_COMMAND_PHASE);
997
998 if (!cmd && (sr != CSR_RESEL_AM && sr != CSR_TIMEOUT && sr != CSR_SELECT)) {
999 printk("\nNR:wd-intr-1\n");
1000 write1_io(0, IO_LED_OFF);
1001
1002/* release the SMP spin_lock and restore irq state */
1003 spin_unlock_irqrestore(instance->host_lock, flags);
1004 return IRQ_HANDLED;
1005 }
1006
1007 DB(DB_INTR, printk("{%02x:%02x-", asr, sr))
1008
1009/* After starting a FIFO-based transfer, the next _WD3393_ interrupt is
1010 * guaranteed to be in response to the completion of the transfer.
1011 * If we were reading, there's probably data in the fifo that needs
1012 * to be copied into RAM - do that here. Also, we have to update
1013 * 'this_residual' and 'ptr' based on the contents of the
1014 * TRANSFER_COUNT register, in case the device decided to do an
1015 * intermediate disconnect (a device may do this if it has to
1016 * do a seek, or just to be nice and let other devices have
1017 * some bus time during long transfers).
1018 * After doing whatever is necessary with the fifo, we go on and
1019 * service the WD3393 interrupt normally.
1020 */
1021 if (hostdata->fifo == FI_FIFO_READING) {
1022
1023/* buffer index = start-of-buffer + #-of-bytes-already-read */
1024
1025 sp = (unsigned short *) (cmd->SCp.ptr + cmd->SCp.have_data_in);
1026
1027/* bytes remaining in fifo = (total-wanted - #-not-got) - #-already-read */
1028
1029 i = (cmd->SCp.this_residual - read_3393_count(hostdata)) - cmd->SCp.have_data_in;
1030 i >>= 1; /* Gulp. We assume this will always be modulo 2 */
1031 f = hostdata->io_base + IO_FIFO;
1032
1033#ifdef FAST_READ_IO
1034
1035 FAST_READ2_IO();
1036#else
1037 while (i--)
1038 *sp++ = read2_io(IO_FIFO);
1039
1040#endif
1041
1042 hostdata->fifo = FI_FIFO_UNUSED;
1043 length = cmd->SCp.this_residual;
1044 cmd->SCp.this_residual = read_3393_count(hostdata);
1045 cmd->SCp.ptr += (length - cmd->SCp.this_residual);
1046
1047 DB(DB_TRANSFER, printk("(%p,%d)", cmd->SCp.ptr, cmd->SCp.this_residual))
1048
1049 }
1050
1051 else if (hostdata->fifo == FI_FIFO_WRITING) {
1052 hostdata->fifo = FI_FIFO_UNUSED;
1053 length = cmd->SCp.this_residual;
1054 cmd->SCp.this_residual = read_3393_count(hostdata);
1055 cmd->SCp.ptr += (length - cmd->SCp.this_residual);
1056
1057 DB(DB_TRANSFER, printk("(%p,%d)", cmd->SCp.ptr, cmd->SCp.this_residual))
1058
1059 }
1060
1061/* Respond to the specific WD3393 interrupt - there are quite a few! */
1062
1063 switch (sr) {
1064
1065 case CSR_TIMEOUT:
1066 DB(DB_INTR, printk("TIMEOUT"))
1067
1068 if (hostdata->state == S_RUNNING_LEVEL2)
1069 hostdata->connected = NULL;
1070 else {
1071 cmd = (Scsi_Cmnd *) hostdata->selecting; /* get a valid cmd */
1072 CHECK_NULL(cmd, "csr_timeout")
1073 hostdata->selecting = NULL;
1074 }
1075
1076 cmd->result = DID_NO_CONNECT << 16;
1077 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
1078 hostdata->state = S_UNCONNECTED;
1079 cmd->scsi_done(cmd);
1080
1081/* We are not connected to a target - check to see if there
1082 * are commands waiting to be executed.
1083 */
1084
1085 in2000_execute(instance);
1086 break;
1087
1088
1089/* Note: this interrupt should not occur in a LEVEL2 command */
1090
1091 case CSR_SELECT:
1092 DB(DB_INTR, printk("SELECT"))
1093 hostdata->connected = cmd = (Scsi_Cmnd *) hostdata->selecting;
1094 CHECK_NULL(cmd, "csr_select")
1095 hostdata->selecting = NULL;
1096
1097 /* construct an IDENTIFY message with correct disconnect bit */
1098
1099 hostdata->outgoing_msg[0] = (0x80 | 0x00 | cmd->device->lun);
1100 if (cmd->SCp.phase)
1101 hostdata->outgoing_msg[0] |= 0x40;
1102
1103 if (hostdata->sync_stat[cmd->device->id] == SS_FIRST) {
1104#ifdef SYNC_DEBUG
1105 printk(" sending SDTR ");
1106#endif
1107
1108 hostdata->sync_stat[cmd->device->id] = SS_WAITING;
1109
1110 /* tack on a 2nd message to ask about synchronous transfers */
1111
1112 hostdata->outgoing_msg[1] = EXTENDED_MESSAGE;
1113 hostdata->outgoing_msg[2] = 3;
1114 hostdata->outgoing_msg[3] = EXTENDED_SDTR;
1115 hostdata->outgoing_msg[4] = OPTIMUM_SX_PER / 4;
1116 hostdata->outgoing_msg[5] = OPTIMUM_SX_OFF;
1117 hostdata->outgoing_len = 6;
1118 } else
1119 hostdata->outgoing_len = 1;
1120
1121 hostdata->state = S_CONNECTED;
1122 break;
1123
1124
1125 case CSR_XFER_DONE | PHS_DATA_IN:
1126 case CSR_UNEXP | PHS_DATA_IN:
1127 case CSR_SRV_REQ | PHS_DATA_IN:
1128 DB(DB_INTR, printk("IN-%d.%d", cmd->SCp.this_residual, cmd->SCp.buffers_residual))
1129 transfer_bytes(cmd, DATA_IN_DIR);
1130 if (hostdata->state != S_RUNNING_LEVEL2)
1131 hostdata->state = S_CONNECTED;
1132 break;
1133
1134
1135 case CSR_XFER_DONE | PHS_DATA_OUT:
1136 case CSR_UNEXP | PHS_DATA_OUT:
1137 case CSR_SRV_REQ | PHS_DATA_OUT:
1138 DB(DB_INTR, printk("OUT-%d.%d", cmd->SCp.this_residual, cmd->SCp.buffers_residual))
1139 transfer_bytes(cmd, DATA_OUT_DIR);
1140 if (hostdata->state != S_RUNNING_LEVEL2)
1141 hostdata->state = S_CONNECTED;
1142 break;
1143
1144
1145/* Note: this interrupt should not occur in a LEVEL2 command */
1146
1147 case CSR_XFER_DONE | PHS_COMMAND:
1148 case CSR_UNEXP | PHS_COMMAND:
1149 case CSR_SRV_REQ | PHS_COMMAND:
1150 DB(DB_INTR, printk("CMND-%02x,%ld", cmd->cmnd[0], cmd->pid))
1151 transfer_pio(cmd->cmnd, cmd->cmd_len, DATA_OUT_DIR, hostdata);
1152 hostdata->state = S_CONNECTED;
1153 break;
1154
1155
1156 case CSR_XFER_DONE | PHS_STATUS:
1157 case CSR_UNEXP | PHS_STATUS:
1158 case CSR_SRV_REQ | PHS_STATUS:
1159 DB(DB_INTR, printk("STATUS="))
1160
1161 cmd->SCp.Status = read_1_byte(hostdata);
1162 DB(DB_INTR, printk("%02x", cmd->SCp.Status))
1163 if (hostdata->level2 >= L2_BASIC) {
1164 sr = read_3393(hostdata, WD_SCSI_STATUS); /* clear interrupt */
1165 hostdata->state = S_RUNNING_LEVEL2;
1166 write_3393(hostdata, WD_COMMAND_PHASE, 0x50);
1167 write_3393_cmd(hostdata, WD_CMD_SEL_ATN_XFER);
1168 } else {
1169 hostdata->state = S_CONNECTED;
1170 }
1171 break;
1172
1173
1174 case CSR_XFER_DONE | PHS_MESS_IN:
1175 case CSR_UNEXP | PHS_MESS_IN:
1176 case CSR_SRV_REQ | PHS_MESS_IN:
1177 DB(DB_INTR, printk("MSG_IN="))
1178
1179 msg = read_1_byte(hostdata);
1180 sr = read_3393(hostdata, WD_SCSI_STATUS); /* clear interrupt */
1181
1182 hostdata->incoming_msg[hostdata->incoming_ptr] = msg;
1183 if (hostdata->incoming_msg[0] == EXTENDED_MESSAGE)
1184 msg = EXTENDED_MESSAGE;
1185 else
1186 hostdata->incoming_ptr = 0;
1187
1188 cmd->SCp.Message = msg;
1189 switch (msg) {
1190
1191 case COMMAND_COMPLETE:
1192 DB(DB_INTR, printk("CCMP-%ld", cmd->pid))
1193 write_3393_cmd(hostdata, WD_CMD_NEGATE_ACK);
1194 hostdata->state = S_PRE_CMP_DISC;
1195 break;
1196
1197 case SAVE_POINTERS:
1198 DB(DB_INTR, printk("SDP"))
1199 write_3393_cmd(hostdata, WD_CMD_NEGATE_ACK);
1200 hostdata->state = S_CONNECTED;
1201 break;
1202
1203 case RESTORE_POINTERS:
1204 DB(DB_INTR, printk("RDP"))
1205 if (hostdata->level2 >= L2_BASIC) {
1206 write_3393(hostdata, WD_COMMAND_PHASE, 0x45);
1207 write_3393_cmd(hostdata, WD_CMD_SEL_ATN_XFER);
1208 hostdata->state = S_RUNNING_LEVEL2;
1209 } else {
1210 write_3393_cmd(hostdata, WD_CMD_NEGATE_ACK);
1211 hostdata->state = S_CONNECTED;
1212 }
1213 break;
1214
1215 case DISCONNECT:
1216 DB(DB_INTR, printk("DIS"))
1217 cmd->device->disconnect = 1;
1218 write_3393_cmd(hostdata, WD_CMD_NEGATE_ACK);
1219 hostdata->state = S_PRE_TMP_DISC;
1220 break;
1221
1222 case MESSAGE_REJECT:
1223 DB(DB_INTR, printk("REJ"))
1224#ifdef SYNC_DEBUG
1225 printk("-REJ-");
1226#endif
1227 if (hostdata->sync_stat[cmd->device->id] == SS_WAITING)
1228 hostdata->sync_stat[cmd->device->id] = SS_SET;
1229 write_3393_cmd(hostdata, WD_CMD_NEGATE_ACK);
1230 hostdata->state = S_CONNECTED;
1231 break;
1232
1233 case EXTENDED_MESSAGE:
1234 DB(DB_INTR, printk("EXT"))
1235
1236 ucp = hostdata->incoming_msg;
1237
1238#ifdef SYNC_DEBUG
1239 printk("%02x", ucp[hostdata->incoming_ptr]);
1240#endif
1241 /* Is this the last byte of the extended message? */
1242
1243 if ((hostdata->incoming_ptr >= 2) && (hostdata->incoming_ptr == (ucp[1] + 1))) {
1244
1245 switch (ucp[2]) { /* what's the EXTENDED code? */
1246 case EXTENDED_SDTR:
1247 id = calc_sync_xfer(ucp[3], ucp[4]);
1248 if (hostdata->sync_stat[cmd->device->id] != SS_WAITING) {
1249
1250/* A device has sent an unsolicited SDTR message; rather than go
1251 * through the effort of decoding it and then figuring out what
1252 * our reply should be, we're just gonna say that we have a
1253 * synchronous fifo depth of 0. This will result in asynchronous
1254 * transfers - not ideal but so much easier.
1255 * Actually, this is OK because it assures us that if we don't
1256 * specifically ask for sync transfers, we won't do any.
1257 */
1258
1259 write_3393_cmd(hostdata, WD_CMD_ASSERT_ATN); /* want MESS_OUT */
1260 hostdata->outgoing_msg[0] = EXTENDED_MESSAGE;
1261 hostdata->outgoing_msg[1] = 3;
1262 hostdata->outgoing_msg[2] = EXTENDED_SDTR;
1263 hostdata->outgoing_msg[3] = hostdata->default_sx_per / 4;
1264 hostdata->outgoing_msg[4] = 0;
1265 hostdata->outgoing_len = 5;
1266 hostdata->sync_xfer[cmd->device->id] = calc_sync_xfer(hostdata->default_sx_per / 4, 0);
1267 } else {
1268 hostdata->sync_xfer[cmd->device->id] = id;
1269 }
1270#ifdef SYNC_DEBUG
1271 printk("sync_xfer=%02x", hostdata->sync_xfer[cmd->device->id]);
1272#endif
1273 hostdata->sync_stat[cmd->device->id] = SS_SET;
1274 write_3393_cmd(hostdata, WD_CMD_NEGATE_ACK);
1275 hostdata->state = S_CONNECTED;
1276 break;
1277 case EXTENDED_WDTR:
1278 write_3393_cmd(hostdata, WD_CMD_ASSERT_ATN); /* want MESS_OUT */
1279 printk("sending WDTR ");
1280 hostdata->outgoing_msg[0] = EXTENDED_MESSAGE;
1281 hostdata->outgoing_msg[1] = 2;
1282 hostdata->outgoing_msg[2] = EXTENDED_WDTR;
1283 hostdata->outgoing_msg[3] = 0; /* 8 bit transfer width */
1284 hostdata->outgoing_len = 4;
1285 write_3393_cmd(hostdata, WD_CMD_NEGATE_ACK);
1286 hostdata->state = S_CONNECTED;
1287 break;
1288 default:
1289 write_3393_cmd(hostdata, WD_CMD_ASSERT_ATN); /* want MESS_OUT */
1290 printk("Rejecting Unknown Extended Message(%02x). ", ucp[2]);
1291 hostdata->outgoing_msg[0] = MESSAGE_REJECT;
1292 hostdata->outgoing_len = 1;
1293 write_3393_cmd(hostdata, WD_CMD_NEGATE_ACK);
1294 hostdata->state = S_CONNECTED;
1295 break;
1296 }
1297 hostdata->incoming_ptr = 0;
1298 }
1299
1300 /* We need to read more MESS_IN bytes for the extended message */
1301
1302 else {
1303 hostdata->incoming_ptr++;
1304 write_3393_cmd(hostdata, WD_CMD_NEGATE_ACK);
1305 hostdata->state = S_CONNECTED;
1306 }
1307 break;
1308
1309 default:
1310 printk("Rejecting Unknown Message(%02x) ", msg);
1311 write_3393_cmd(hostdata, WD_CMD_ASSERT_ATN); /* want MESS_OUT */
1312 hostdata->outgoing_msg[0] = MESSAGE_REJECT;
1313 hostdata->outgoing_len = 1;
1314 write_3393_cmd(hostdata, WD_CMD_NEGATE_ACK);
1315 hostdata->state = S_CONNECTED;
1316 }
1317 break;
1318
1319
1320/* Note: this interrupt will occur only after a LEVEL2 command */
1321
1322 case CSR_SEL_XFER_DONE:
1323
1324/* Make sure that reselection is enabled at this point - it may
1325 * have been turned off for the command that just completed.
1326 */
1327
1328 write_3393(hostdata, WD_SOURCE_ID, SRCID_ER);
1329 if (phs == 0x60) {
1330 DB(DB_INTR, printk("SX-DONE-%ld", cmd->pid))
1331 cmd->SCp.Message = COMMAND_COMPLETE;
1332 lun = read_3393(hostdata, WD_TARGET_LUN);
1333 DB(DB_INTR, printk(":%d.%d", cmd->SCp.Status, lun))
1334 hostdata->connected = NULL;
1335 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
1336 hostdata->state = S_UNCONNECTED;
1337 if (cmd->SCp.Status == ILLEGAL_STATUS_BYTE)
1338 cmd->SCp.Status = lun;
1339 if (cmd->cmnd[0] == REQUEST_SENSE && cmd->SCp.Status != GOOD)
1340 cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16);
1341 else
1342 cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
1343 cmd->scsi_done(cmd);
1344
1345/* We are no longer connected to a target - check to see if
1346 * there are commands waiting to be executed.
1347 */
1348
1349 in2000_execute(instance);
1350 } else {
1351 printk("%02x:%02x:%02x-%ld: Unknown SEL_XFER_DONE phase!!---", asr, sr, phs, cmd->pid);
1352 }
1353 break;
1354
1355
1356/* Note: this interrupt will occur only after a LEVEL2 command */
1357
1358 case CSR_SDP:
1359 DB(DB_INTR, printk("SDP"))
1360 hostdata->state = S_RUNNING_LEVEL2;
1361 write_3393(hostdata, WD_COMMAND_PHASE, 0x41);
1362 write_3393_cmd(hostdata, WD_CMD_SEL_ATN_XFER);
1363 break;
1364
1365
1366 case CSR_XFER_DONE | PHS_MESS_OUT:
1367 case CSR_UNEXP | PHS_MESS_OUT:
1368 case CSR_SRV_REQ | PHS_MESS_OUT:
1369 DB(DB_INTR, printk("MSG_OUT="))
1370
1371/* To get here, we've probably requested MESSAGE_OUT and have
1372 * already put the correct bytes in outgoing_msg[] and filled
1373 * in outgoing_len. We simply send them out to the SCSI bus.
1374 * Sometimes we get MESSAGE_OUT phase when we're not expecting
1375 * it - like when our SDTR message is rejected by a target. Some
1376 * targets send the REJECT before receiving all of the extended
1377 * message, and then seem to go back to MESSAGE_OUT for a byte
1378 * or two. Not sure why, or if I'm doing something wrong to
1379 * cause this to happen. Regardless, it seems that sending
1380 * NOP messages in these situations results in no harm and
1381 * makes everyone happy.
1382 */
1383 if (hostdata->outgoing_len == 0) {
1384 hostdata->outgoing_len = 1;
1385 hostdata->outgoing_msg[0] = NOP;
1386 }
1387 transfer_pio(hostdata->outgoing_msg, hostdata->outgoing_len, DATA_OUT_DIR, hostdata);
1388 DB(DB_INTR, printk("%02x", hostdata->outgoing_msg[0]))
1389 hostdata->outgoing_len = 0;
1390 hostdata->state = S_CONNECTED;
1391 break;
1392
1393
1394 case CSR_UNEXP_DISC:
1395
1396/* I think I've seen this after a request-sense that was in response
1397 * to an error condition, but not sure. We certainly need to do
1398 * something when we get this interrupt - the question is 'what?'.
1399 * Let's think positively, and assume some command has finished
1400 * in a legal manner (like a command that provokes a request-sense),
1401 * so we treat it as a normal command-complete-disconnect.
1402 */
1403
1404
1405/* Make sure that reselection is enabled at this point - it may
1406 * have been turned off for the command that just completed.
1407 */
1408
1409 write_3393(hostdata, WD_SOURCE_ID, SRCID_ER);
1410 if (cmd == NULL) {
1411 printk(" - Already disconnected! ");
1412 hostdata->state = S_UNCONNECTED;
1413
1414/* release the SMP spin_lock and restore irq state */
1415 spin_unlock_irqrestore(instance->host_lock, flags);
1416 return IRQ_HANDLED;
1417 }
1418 DB(DB_INTR, printk("UNEXP_DISC-%ld", cmd->pid))
1419 hostdata->connected = NULL;
1420 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
1421 hostdata->state = S_UNCONNECTED;
1422 if (cmd->cmnd[0] == REQUEST_SENSE && cmd->SCp.Status != GOOD)
1423 cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16);
1424 else
1425 cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
1426 cmd->scsi_done(cmd);
1427
1428/* We are no longer connected to a target - check to see if
1429 * there are commands waiting to be executed.
1430 */
1431
1432 in2000_execute(instance);
1433 break;
1434
1435
1436 case CSR_DISC:
1437
1438/* Make sure that reselection is enabled at this point - it may
1439 * have been turned off for the command that just completed.
1440 */
1441
1442 write_3393(hostdata, WD_SOURCE_ID, SRCID_ER);
1443 DB(DB_INTR, printk("DISC-%ld", cmd->pid))
1444 if (cmd == NULL) {
1445 printk(" - Already disconnected! ");
1446 hostdata->state = S_UNCONNECTED;
1447 }
1448 switch (hostdata->state) {
1449 case S_PRE_CMP_DISC:
1450 hostdata->connected = NULL;
1451 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
1452 hostdata->state = S_UNCONNECTED;
1453 DB(DB_INTR, printk(":%d", cmd->SCp.Status))
1454 if (cmd->cmnd[0] == REQUEST_SENSE && cmd->SCp.Status != GOOD)
1455 cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16);
1456 else
1457 cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
1458 cmd->scsi_done(cmd);
1459 break;
1460 case S_PRE_TMP_DISC:
1461 case S_RUNNING_LEVEL2:
1462 cmd->host_scribble = (uchar *) hostdata->disconnected_Q;
1463 hostdata->disconnected_Q = cmd;
1464 hostdata->connected = NULL;
1465 hostdata->state = S_UNCONNECTED;
1466
1467#ifdef PROC_STATISTICS
1468 hostdata->disc_done_cnt[cmd->device->id]++;
1469#endif
1470
1471 break;
1472 default:
1473 printk("*** Unexpected DISCONNECT interrupt! ***");
1474 hostdata->state = S_UNCONNECTED;
1475 }
1476
1477/* We are no longer connected to a target - check to see if
1478 * there are commands waiting to be executed.
1479 */
1480
1481 in2000_execute(instance);
1482 break;
1483
1484
1485 case CSR_RESEL_AM:
1486 DB(DB_INTR, printk("RESEL"))
1487
1488 /* First we have to make sure this reselection didn't */
1489 /* happen during Arbitration/Selection of some other device. */
1490 /* If yes, put losing command back on top of input_Q. */
1491 if (hostdata->level2 <= L2_NONE) {
1492
1493 if (hostdata->selecting) {
1494 cmd = (Scsi_Cmnd *) hostdata->selecting;
1495 hostdata->selecting = NULL;
1496 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
1497 cmd->host_scribble = (uchar *) hostdata->input_Q;
1498 hostdata->input_Q = cmd;
1499 }
1500 }
1501
1502 else {
1503
1504 if (cmd) {
1505 if (phs == 0x00) {
1506 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
1507 cmd->host_scribble = (uchar *) hostdata->input_Q;
1508 hostdata->input_Q = cmd;
1509 } else {
1510 printk("---%02x:%02x:%02x-TROUBLE: Intrusive ReSelect!---", asr, sr, phs);
1511 while (1)
1512 printk("\r");
1513 }
1514 }
1515
1516 }
1517
1518 /* OK - find out which device reselected us. */
1519
1520 id = read_3393(hostdata, WD_SOURCE_ID);
1521 id &= SRCID_MASK;
1522
1523 /* and extract the lun from the ID message. (Note that we don't
1524 * bother to check for a valid message here - I guess this is
1525 * not the right way to go, but....)
1526 */
1527
1528 lun = read_3393(hostdata, WD_DATA);
1529 if (hostdata->level2 < L2_RESELECT)
1530 write_3393_cmd(hostdata, WD_CMD_NEGATE_ACK);
1531 lun &= 7;
1532
1533 /* Now we look for the command that's reconnecting. */
1534
1535 cmd = (Scsi_Cmnd *) hostdata->disconnected_Q;
1536 patch = NULL;
1537 while (cmd) {
1538 if (id == cmd->device->id && lun == cmd->device->lun)
1539 break;
1540 patch = cmd;
1541 cmd = (Scsi_Cmnd *) cmd->host_scribble;
1542 }
1543
1544 /* Hmm. Couldn't find a valid command.... What to do? */
1545
1546 if (!cmd) {
1547 printk("---TROUBLE: target %d.%d not in disconnect queue---", id, lun);
1548 break;
1549 }
1550
1551 /* Ok, found the command - now start it up again. */
1552
1553 if (patch)
1554 patch->host_scribble = cmd->host_scribble;
1555 else
1556 hostdata->disconnected_Q = (Scsi_Cmnd *) cmd->host_scribble;
1557 hostdata->connected = cmd;
1558
1559 /* We don't need to worry about 'initialize_SCp()' or 'hostdata->busy[]'
1560 * because these things are preserved over a disconnect.
1561 * But we DO need to fix the DPD bit so it's correct for this command.
1562 */
1563
1564 if (is_dir_out(cmd))
1565 write_3393(hostdata, WD_DESTINATION_ID, cmd->device->id);
1566 else
1567 write_3393(hostdata, WD_DESTINATION_ID, cmd->device->id | DSTID_DPD);
1568 if (hostdata->level2 >= L2_RESELECT) {
1569 write_3393_count(hostdata, 0); /* we want a DATA_PHASE interrupt */
1570 write_3393(hostdata, WD_COMMAND_PHASE, 0x45);
1571 write_3393_cmd(hostdata, WD_CMD_SEL_ATN_XFER);
1572 hostdata->state = S_RUNNING_LEVEL2;
1573 } else
1574 hostdata->state = S_CONNECTED;
1575
1576 DB(DB_INTR, printk("-%ld", cmd->pid))
1577 break;
1578
1579 default:
1580 printk("--UNKNOWN INTERRUPT:%02x:%02x:%02x--", asr, sr, phs);
1581 }
1582
1583 write1_io(0, IO_LED_OFF);
1584
1585 DB(DB_INTR, printk("} "))
1586
1587/* release the SMP spin_lock and restore irq state */
1588 spin_unlock_irqrestore(instance->host_lock, flags);
1589 return IRQ_HANDLED;
1590}
1591
1592
1593
1594#define RESET_CARD 0
1595#define RESET_CARD_AND_BUS 1
1596#define B_FLAG 0x80
1597
1598/*
1599 * Caller must hold instance lock!
1600 */
1601
1602static int reset_hardware(struct Scsi_Host *instance, int type)
1603{
1604 struct IN2000_hostdata *hostdata;
1605 int qt, x;
1606
1607 hostdata = (struct IN2000_hostdata *) instance->hostdata;
1608
1609 write1_io(0, IO_LED_ON);
1610 if (type == RESET_CARD_AND_BUS) {
1611 write1_io(0, IO_CARD_RESET);
1612 x = read1_io(IO_HARDWARE);
1613 }
1614 x = read_3393(hostdata, WD_SCSI_STATUS); /* clear any WD intrpt */
1615 write_3393(hostdata, WD_OWN_ID, instance->this_id | OWNID_EAF | OWNID_RAF | OWNID_FS_8);
1616 write_3393(hostdata, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
1617 write_3393(hostdata, WD_SYNCHRONOUS_TRANSFER, calc_sync_xfer(hostdata->default_sx_per / 4, DEFAULT_SX_OFF));
1618
1619 write1_io(0, IO_FIFO_WRITE); /* clear fifo counter */
1620 write1_io(0, IO_FIFO_READ); /* start fifo out in read mode */
1621 write_3393(hostdata, WD_COMMAND, WD_CMD_RESET);
1622 /* FIXME: timeout ?? */
1623 while (!(READ_AUX_STAT() & ASR_INT))
1624 cpu_relax(); /* wait for RESET to complete */
1625
1626 x = read_3393(hostdata, WD_SCSI_STATUS); /* clear interrupt */
1627
1628 write_3393(hostdata, WD_QUEUE_TAG, 0xa5); /* any random number */
1629 qt = read_3393(hostdata, WD_QUEUE_TAG);
1630 if (qt == 0xa5) {
1631 x |= B_FLAG;
1632 write_3393(hostdata, WD_QUEUE_TAG, 0);
1633 }
1634 write_3393(hostdata, WD_TIMEOUT_PERIOD, TIMEOUT_PERIOD_VALUE);
1635 write_3393(hostdata, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
1636 write1_io(0, IO_LED_OFF);
1637 return x;
1638}
1639
1640
1641
1642static int in2000_bus_reset(Scsi_Cmnd * cmd)
1643{
1644 struct Scsi_Host *instance;
1645 struct IN2000_hostdata *hostdata;
1646 int x;
1647
1648 instance = cmd->device->host;
1649 hostdata = (struct IN2000_hostdata *) instance->hostdata;
1650
1651 printk(KERN_WARNING "scsi%d: Reset. ", instance->host_no);
1652
1653 /* do scsi-reset here */
1654
1655 reset_hardware(instance, RESET_CARD_AND_BUS);
1656 for (x = 0; x < 8; x++) {
1657 hostdata->busy[x] = 0;
1658 hostdata->sync_xfer[x] = calc_sync_xfer(DEFAULT_SX_PER / 4, DEFAULT_SX_OFF);
1659 hostdata->sync_stat[x] = SS_UNSET; /* using default sync values */
1660 }
1661 hostdata->input_Q = NULL;
1662 hostdata->selecting = NULL;
1663 hostdata->connected = NULL;
1664 hostdata->disconnected_Q = NULL;
1665 hostdata->state = S_UNCONNECTED;
1666 hostdata->fifo = FI_FIFO_UNUSED;
1667 hostdata->incoming_ptr = 0;
1668 hostdata->outgoing_len = 0;
1669
1670 cmd->result = DID_RESET << 16;
1671 return SUCCESS;
1672}
1673
1674static int in2000_host_reset(Scsi_Cmnd * cmd)
1675{
1676 return FAILED;
1677}
1678
1679static int in2000_device_reset(Scsi_Cmnd * cmd)
1680{
1681 return FAILED;
1682}
1683
1684
1685static int in2000_abort(Scsi_Cmnd * cmd)
1686{
1687 struct Scsi_Host *instance;
1688 struct IN2000_hostdata *hostdata;
1689 Scsi_Cmnd *tmp, *prev;
1690 uchar sr, asr;
1691 unsigned long timeout;
1692
1693 instance = cmd->device->host;
1694 hostdata = (struct IN2000_hostdata *) instance->hostdata;
1695
1696 printk(KERN_DEBUG "scsi%d: Abort-", instance->host_no);
1697 printk("(asr=%02x,count=%ld,resid=%d,buf_resid=%d,have_data=%d,FC=%02x)- ", READ_AUX_STAT(), read_3393_count(hostdata), cmd->SCp.this_residual, cmd->SCp.buffers_residual, cmd->SCp.have_data_in, read1_io(IO_FIFO_COUNT));
1698
1699/*
1700 * Case 1 : If the command hasn't been issued yet, we simply remove it
1701 * from the inout_Q.
1702 */
1703
1704 tmp = (Scsi_Cmnd *) hostdata->input_Q;
1705 prev = NULL;
1706 while (tmp) {
1707 if (tmp == cmd) {
1708 if (prev)
1709 prev->host_scribble = cmd->host_scribble;
1710 cmd->host_scribble = NULL;
1711 cmd->result = DID_ABORT << 16;
1712 printk(KERN_WARNING "scsi%d: Abort - removing command %ld from input_Q. ", instance->host_no, cmd->pid);
1713 cmd->scsi_done(cmd);
1714 return SUCCESS;
1715 }
1716 prev = tmp;
1717 tmp = (Scsi_Cmnd *) tmp->host_scribble;
1718 }
1719
1720/*
1721 * Case 2 : If the command is connected, we're going to fail the abort
1722 * and let the high level SCSI driver retry at a later time or
1723 * issue a reset.
1724 *
1725 * Timeouts, and therefore aborted commands, will be highly unlikely
1726 * and handling them cleanly in this situation would make the common
1727 * case of noresets less efficient, and would pollute our code. So,
1728 * we fail.
1729 */
1730
1731 if (hostdata->connected == cmd) {
1732
1733 printk(KERN_WARNING "scsi%d: Aborting connected command %ld - ", instance->host_no, cmd->pid);
1734
1735 printk("sending wd33c93 ABORT command - ");
1736 write_3393(hostdata, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
1737 write_3393_cmd(hostdata, WD_CMD_ABORT);
1738
1739/* Now we have to attempt to flush out the FIFO... */
1740
1741 printk("flushing fifo - ");
1742 timeout = 1000000;
1743 do {
1744 asr = READ_AUX_STAT();
1745 if (asr & ASR_DBR)
1746 read_3393(hostdata, WD_DATA);
1747 } while (!(asr & ASR_INT) && timeout-- > 0);
1748 sr = read_3393(hostdata, WD_SCSI_STATUS);
1749 printk("asr=%02x, sr=%02x, %ld bytes un-transferred (timeout=%ld) - ", asr, sr, read_3393_count(hostdata), timeout);
1750
1751 /*
1752 * Abort command processed.
1753 * Still connected.
1754 * We must disconnect.
1755 */
1756
1757 printk("sending wd33c93 DISCONNECT command - ");
1758 write_3393_cmd(hostdata, WD_CMD_DISCONNECT);
1759
1760 timeout = 1000000;
1761 asr = READ_AUX_STAT();
1762 while ((asr & ASR_CIP) && timeout-- > 0)
1763 asr = READ_AUX_STAT();
1764 sr = read_3393(hostdata, WD_SCSI_STATUS);
1765 printk("asr=%02x, sr=%02x.", asr, sr);
1766
1767 hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
1768 hostdata->connected = NULL;
1769 hostdata->state = S_UNCONNECTED;
1770 cmd->result = DID_ABORT << 16;
1771 cmd->scsi_done(cmd);
1772
1773 in2000_execute(instance);
1774
1775 return SUCCESS;
1776 }
1777
1778/*
1779 * Case 3: If the command is currently disconnected from the bus,
1780 * we're not going to expend much effort here: Let's just return
1781 * an ABORT_SNOOZE and hope for the best...
1782 */
1783
1784 for (tmp = (Scsi_Cmnd *) hostdata->disconnected_Q; tmp; tmp = (Scsi_Cmnd *) tmp->host_scribble)
1785 if (cmd == tmp) {
1786 printk(KERN_DEBUG "scsi%d: unable to abort disconnected command.\n", instance->host_no);
1787 return FAILED;
1788 }
1789
1790/*
1791 * Case 4 : If we reached this point, the command was not found in any of
1792 * the queues.
1793 *
1794 * We probably reached this point because of an unlikely race condition
1795 * between the command completing successfully and the abortion code,
1796 * so we won't panic, but we will notify the user in case something really
1797 * broke.
1798 */
1799
1800 in2000_execute(instance);
1801
1802 printk("scsi%d: warning : SCSI command probably completed successfully" " before abortion. ", instance->host_no);
1803 return SUCCESS;
1804}
1805
1806
1807
1808#define MAX_IN2000_HOSTS 3
1809#define MAX_SETUP_ARGS (sizeof(setup_args) / sizeof(char *))
1810#define SETUP_BUFFER_SIZE 200
1811static char setup_buffer[SETUP_BUFFER_SIZE];
1812static char setup_used[MAX_SETUP_ARGS];
1813static int done_setup = 0;
1814
1815static void __init in2000_setup(char *str, int *ints)
1816{
1817 int i;
1818 char *p1, *p2;
1819
1820 strlcpy(setup_buffer, str, SETUP_BUFFER_SIZE);
1821 p1 = setup_buffer;
1822 i = 0;
1823 while (*p1 && (i < MAX_SETUP_ARGS)) {
1824 p2 = strchr(p1, ',');
1825 if (p2) {
1826 *p2 = '\0';
1827 if (p1 != p2)
1828 setup_args[i] = p1;
1829 p1 = p2 + 1;
1830 i++;
1831 } else {
1832 setup_args[i] = p1;
1833 break;
1834 }
1835 }
1836 for (i = 0; i < MAX_SETUP_ARGS; i++)
1837 setup_used[i] = 0;
1838 done_setup = 1;
1839}
1840
1841
1842/* check_setup_args() returns index if key found, 0 if not
1843 */
1844
1845static int __init check_setup_args(char *key, int *val, char *buf)
1846{
1847 int x;
1848 char *cp;
1849
1850 for (x = 0; x < MAX_SETUP_ARGS; x++) {
1851 if (setup_used[x])
1852 continue;
1853 if (!strncmp(setup_args[x], key, strlen(key)))
1854 break;
1855 }
1856 if (x == MAX_SETUP_ARGS)
1857 return 0;
1858 setup_used[x] = 1;
1859 cp = setup_args[x] + strlen(key);
1860 *val = -1;
1861 if (*cp != ':')
1862 return ++x;
1863 cp++;
1864 if ((*cp >= '0') && (*cp <= '9')) {
1865 *val = simple_strtoul(cp, NULL, 0);
1866 }
1867 return ++x;
1868}
1869
1870
1871
1872/* The "correct" (ie portable) way to access memory-mapped hardware
1873 * such as the IN2000 EPROM and dip switch is through the use of
1874 * special macros declared in 'asm/io.h'. We use readb() and readl()
1875 * when reading from the card's BIOS area in in2000_detect().
1876 */
1877static u32 bios_tab[] in2000__INITDATA = {
1878 0xc8000,
1879 0xd0000,
1880 0xd8000,
1881 0
1882};
1883
1884static unsigned short base_tab[] in2000__INITDATA = {
1885 0x220,
1886 0x200,
1887 0x110,
1888 0x100,
1889};
1890
1891static int int_tab[] in2000__INITDATA = {
1892 15,
1893 14,
1894 11,
1895 10
1896};
1897
1898
1899static int __init in2000_detect(Scsi_Host_Template * tpnt)
1900{
1901 struct Scsi_Host *instance;
1902 struct IN2000_hostdata *hostdata;
1903 int detect_count;
1904 int bios;
1905 int x;
1906 unsigned short base;
1907 uchar switches;
1908 uchar hrev;
1909 unsigned long flags;
1910 int val;
1911 char buf[32];
1912
1913/* Thanks to help from Bill Earnest, probing for IN2000 cards is a
1914 * pretty straightforward and fool-proof operation. There are 3
1915 * possible locations for the IN2000 EPROM in memory space - if we
1916 * find a BIOS signature, we can read the dip switch settings from
1917 * the byte at BIOS+32 (shadowed in by logic on the card). From 2
1918 * of the switch bits we get the card's address in IO space. There's
1919 * an image of the dip switch there, also, so we have a way to back-
1920 * check that this really is an IN2000 card. Very nifty. Use the
1921 * 'ioport:xx' command-line parameter if your BIOS EPROM is absent
1922 * or disabled.
1923 */
1924
1925 if (!done_setup && setup_strings)
1926 in2000_setup(setup_strings, NULL);
1927
1928 detect_count = 0;
1929 for (bios = 0; bios_tab[bios]; bios++) {
1930 if (check_setup_args("ioport", &val, buf)) {
1931 base = val;
1932 switches = ~inb(base + IO_SWITCHES) & 0xff;
1933 printk("Forcing IN2000 detection at IOport 0x%x ", base);
1934 bios = 2;
1935 }
1936/*
1937 * There have been a couple of BIOS versions with different layouts
1938 * for the obvious ID strings. We look for the 2 most common ones and
1939 * hope that they cover all the cases...
1940 */
1941 else if (isa_readl(bios_tab[bios] + 0x10) == 0x41564f4e || isa_readl(bios_tab[bios] + 0x30) == 0x61776c41) {
1942 printk("Found IN2000 BIOS at 0x%x ", (unsigned int) bios_tab[bios]);
1943
1944/* Read the switch image that's mapped into EPROM space */
1945
1946 switches = ~((isa_readb(bios_tab[bios] + 0x20) & 0xff));
1947
1948/* Find out where the IO space is */
1949
1950 x = switches & (SW_ADDR0 | SW_ADDR1);
1951 base = base_tab[x];
1952
1953/* Check for the IN2000 signature in IO space. */
1954
1955 x = ~inb(base + IO_SWITCHES) & 0xff;
1956 if (x != switches) {
1957 printk("Bad IO signature: %02x vs %02x.\n", x, switches);
1958 continue;
1959 }
1960 } else
1961 continue;
1962
1963/* OK. We have a base address for the IO ports - run a few safety checks */
1964
1965 if (!(switches & SW_BIT7)) { /* I _think_ all cards do this */
1966 printk("There is no IN-2000 SCSI card at IOport 0x%03x!\n", base);
1967 continue;
1968 }
1969
1970/* Let's assume any hardware version will work, although the driver
1971 * has only been tested on 0x21, 0x22, 0x25, 0x26, and 0x27. We'll
1972 * print out the rev number for reference later, but accept them all.
1973 */
1974
1975 hrev = inb(base + IO_HARDWARE);
1976
1977 /* Bit 2 tells us if interrupts are disabled */
1978 if (switches & SW_DISINT) {
1979 printk("The IN-2000 SCSI card at IOport 0x%03x ", base);
1980 printk("is not configured for interrupt operation!\n");
1981 printk("This driver requires an interrupt: cancelling detection.\n");
1982 continue;
1983 }
1984
1985/* Ok. We accept that there's an IN2000 at ioaddr 'base'. Now
1986 * initialize it.
1987 */
1988
1989 tpnt->proc_name = "in2000";
1990 instance = scsi_register(tpnt, sizeof(struct IN2000_hostdata));
1991 if (instance == NULL)
1992 continue;
1993 detect_count++;
1994 hostdata = (struct IN2000_hostdata *) instance->hostdata;
1995 instance->io_port = hostdata->io_base = base;
1996 hostdata->dip_switch = switches;
1997 hostdata->hrev = hrev;
1998
1999 write1_io(0, IO_FIFO_WRITE); /* clear fifo counter */
2000 write1_io(0, IO_FIFO_READ); /* start fifo out in read mode */
2001 write1_io(0, IO_INTR_MASK); /* allow all ints */
2002 x = int_tab[(switches & (SW_INT0 | SW_INT1)) >> SW_INT_SHIFT];
2003 if (request_irq(x, in2000_intr, SA_INTERRUPT, "in2000", instance)) {
2004 printk("in2000_detect: Unable to allocate IRQ.\n");
2005 detect_count--;
2006 continue;
2007 }
2008 instance->irq = x;
2009 instance->n_io_port = 13;
2010 request_region(base, 13, "in2000"); /* lock in this IO space for our use */
2011
2012 for (x = 0; x < 8; x++) {
2013 hostdata->busy[x] = 0;
2014 hostdata->sync_xfer[x] = calc_sync_xfer(DEFAULT_SX_PER / 4, DEFAULT_SX_OFF);
2015 hostdata->sync_stat[x] = SS_UNSET; /* using default sync values */
2016#ifdef PROC_STATISTICS
2017 hostdata->cmd_cnt[x] = 0;
2018 hostdata->disc_allowed_cnt[x] = 0;
2019 hostdata->disc_done_cnt[x] = 0;
2020#endif
2021 }
2022 hostdata->input_Q = NULL;
2023 hostdata->selecting = NULL;
2024 hostdata->connected = NULL;
2025 hostdata->disconnected_Q = NULL;
2026 hostdata->state = S_UNCONNECTED;
2027 hostdata->fifo = FI_FIFO_UNUSED;
2028 hostdata->level2 = L2_BASIC;
2029 hostdata->disconnect = DIS_ADAPTIVE;
2030 hostdata->args = DEBUG_DEFAULTS;
2031 hostdata->incoming_ptr = 0;
2032 hostdata->outgoing_len = 0;
2033 hostdata->default_sx_per = DEFAULT_SX_PER;
2034
2035/* Older BIOS's had a 'sync on/off' switch - use its setting */
2036
2037 if (isa_readl(bios_tab[bios] + 0x10) == 0x41564f4e && (switches & SW_SYNC_DOS5))
2038 hostdata->sync_off = 0x00; /* sync defaults to on */
2039 else
2040 hostdata->sync_off = 0xff; /* sync defaults to off */
2041
2042#ifdef PROC_INTERFACE
2043 hostdata->proc = PR_VERSION | PR_INFO | PR_STATISTICS | PR_CONNECTED | PR_INPUTQ | PR_DISCQ | PR_STOP;
2044#ifdef PROC_STATISTICS
2045 hostdata->int_cnt = 0;
2046#endif
2047#endif
2048
2049 if (check_setup_args("nosync", &val, buf))
2050 hostdata->sync_off = val;
2051
2052 if (check_setup_args("period", &val, buf))
2053 hostdata->default_sx_per = sx_table[round_period((unsigned int) val)].period_ns;
2054
2055 if (check_setup_args("disconnect", &val, buf)) {
2056 if ((val >= DIS_NEVER) && (val <= DIS_ALWAYS))
2057 hostdata->disconnect = val;
2058 else
2059 hostdata->disconnect = DIS_ADAPTIVE;
2060 }
2061
2062 if (check_setup_args("noreset", &val, buf))
2063 hostdata->args ^= A_NO_SCSI_RESET;
2064
2065 if (check_setup_args("level2", &val, buf))
2066 hostdata->level2 = val;
2067
2068 if (check_setup_args("debug", &val, buf))
2069 hostdata->args = (val & DB_MASK);
2070
2071#ifdef PROC_INTERFACE
2072 if (check_setup_args("proc", &val, buf))
2073 hostdata->proc = val;
2074#endif
2075
2076
2077 /* FIXME: not strictly needed I think but the called code expects
2078 to be locked */
2079 spin_lock_irqsave(instance->host_lock, flags);
2080 x = reset_hardware(instance, (hostdata->args & A_NO_SCSI_RESET) ? RESET_CARD : RESET_CARD_AND_BUS);
2081 spin_unlock_irqrestore(instance->host_lock, flags);
2082
2083 hostdata->microcode = read_3393(hostdata, WD_CDB_1);
2084 if (x & 0x01) {
2085 if (x & B_FLAG)
2086 hostdata->chip = C_WD33C93B;
2087 else
2088 hostdata->chip = C_WD33C93A;
2089 } else
2090 hostdata->chip = C_WD33C93;
2091
2092 printk("dip_switch=%02x irq=%d ioport=%02x floppy=%s sync/DOS5=%s ", (switches & 0x7f), instance->irq, hostdata->io_base, (switches & SW_FLOPPY) ? "Yes" : "No", (switches & SW_SYNC_DOS5) ? "Yes" : "No");
2093 printk("hardware_ver=%02x chip=%s microcode=%02x\n", hrev, (hostdata->chip == C_WD33C93) ? "WD33c93" : (hostdata->chip == C_WD33C93A) ? "WD33c93A" : (hostdata->chip == C_WD33C93B) ? "WD33c93B" : "unknown", hostdata->microcode);
2094#ifdef DEBUGGING_ON
2095 printk("setup_args = ");
2096 for (x = 0; x < MAX_SETUP_ARGS; x++)
2097 printk("%s,", setup_args[x]);
2098 printk("\n");
2099#endif
2100 if (hostdata->sync_off == 0xff)
2101 printk("Sync-transfer DISABLED on all devices: ENABLE from command-line\n");
2102 printk("IN2000 driver version %s - %s\n", IN2000_VERSION, IN2000_DATE);
2103 }
2104
2105 return detect_count;
2106}
2107
2108static int in2000_release(struct Scsi_Host *shost)
2109{
2110 if (shost->irq)
2111 free_irq(shost->irq, shost);
2112 if (shost->io_port && shost->n_io_port)
2113 release_region(shost->io_port, shost->n_io_port);
2114 return 0;
2115}
2116
2117/* NOTE: I lifted this function straight out of the old driver,
2118 * and have not tested it. Presumably it does what it's
2119 * supposed to do...
2120 */
2121
2122static int in2000_biosparam(struct scsi_device *sdev, struct block_device *bdev, sector_t capacity, int *iinfo)
2123{
2124 int size;
2125
2126 size = capacity;
2127 iinfo[0] = 64;
2128 iinfo[1] = 32;
2129 iinfo[2] = size >> 11;
2130
2131/* This should approximate the large drive handling that the DOS ASPI manager
2132 uses. Drives very near the boundaries may not be handled correctly (i.e.
2133 near 2.0 Gb and 4.0 Gb) */
2134
2135 if (iinfo[2] > 1024) {
2136 iinfo[0] = 64;
2137 iinfo[1] = 63;
2138 iinfo[2] = (unsigned long) capacity / (iinfo[0] * iinfo[1]);
2139 }
2140 if (iinfo[2] > 1024) {
2141 iinfo[0] = 128;
2142 iinfo[1] = 63;
2143 iinfo[2] = (unsigned long) capacity / (iinfo[0] * iinfo[1]);
2144 }
2145 if (iinfo[2] > 1024) {
2146 iinfo[0] = 255;
2147 iinfo[1] = 63;
2148 iinfo[2] = (unsigned long) capacity / (iinfo[0] * iinfo[1]);
2149 }
2150 return 0;
2151}
2152
2153
2154static int in2000_proc_info(struct Scsi_Host *instance, char *buf, char **start, off_t off, int len, int in)
2155{
2156
2157#ifdef PROC_INTERFACE
2158
2159 char *bp;
2160 char tbuf[128];
2161 unsigned long flags;
2162 struct IN2000_hostdata *hd;
2163 Scsi_Cmnd *cmd;
2164 int x, i;
2165 static int stop = 0;
2166
2167 hd = (struct IN2000_hostdata *) instance->hostdata;
2168
2169/* If 'in' is TRUE we need to _read_ the proc file. We accept the following
2170 * keywords (same format as command-line, but only ONE per read):
2171 * debug
2172 * disconnect
2173 * period
2174 * resync
2175 * proc
2176 */
2177
2178 if (in) {
2179 buf[len] = '\0';
2180 bp = buf;
2181 if (!strncmp(bp, "debug:", 6)) {
2182 bp += 6;
2183 hd->args = simple_strtoul(bp, NULL, 0) & DB_MASK;
2184 } else if (!strncmp(bp, "disconnect:", 11)) {
2185 bp += 11;
2186 x = simple_strtoul(bp, NULL, 0);
2187 if (x < DIS_NEVER || x > DIS_ALWAYS)
2188 x = DIS_ADAPTIVE;
2189 hd->disconnect = x;
2190 } else if (!strncmp(bp, "period:", 7)) {
2191 bp += 7;
2192 x = simple_strtoul(bp, NULL, 0);
2193 hd->default_sx_per = sx_table[round_period((unsigned int) x)].period_ns;
2194 } else if (!strncmp(bp, "resync:", 7)) {
2195 bp += 7;
2196 x = simple_strtoul(bp, NULL, 0);
2197 for (i = 0; i < 7; i++)
2198 if (x & (1 << i))
2199 hd->sync_stat[i] = SS_UNSET;
2200 } else if (!strncmp(bp, "proc:", 5)) {
2201 bp += 5;
2202 hd->proc = simple_strtoul(bp, NULL, 0);
2203 } else if (!strncmp(bp, "level2:", 7)) {
2204 bp += 7;
2205 hd->level2 = simple_strtoul(bp, NULL, 0);
2206 }
2207 return len;
2208 }
2209
2210 spin_lock_irqsave(instance->host_lock, flags);
2211 bp = buf;
2212 *bp = '\0';
2213 if (hd->proc & PR_VERSION) {
2214 sprintf(tbuf, "\nVersion %s - %s. Compiled %s %s", IN2000_VERSION, IN2000_DATE, __DATE__, __TIME__);
2215 strcat(bp, tbuf);
2216 }
2217 if (hd->proc & PR_INFO) {
2218 sprintf(tbuf, "\ndip_switch=%02x: irq=%d io=%02x floppy=%s sync/DOS5=%s", (hd->dip_switch & 0x7f), instance->irq, hd->io_base, (hd->dip_switch & 0x40) ? "Yes" : "No", (hd->dip_switch & 0x20) ? "Yes" : "No");
2219 strcat(bp, tbuf);
2220 strcat(bp, "\nsync_xfer[] = ");
2221 for (x = 0; x < 7; x++) {
2222 sprintf(tbuf, "\t%02x", hd->sync_xfer[x]);
2223 strcat(bp, tbuf);
2224 }
2225 strcat(bp, "\nsync_stat[] = ");
2226 for (x = 0; x < 7; x++) {
2227 sprintf(tbuf, "\t%02x", hd->sync_stat[x]);
2228 strcat(bp, tbuf);
2229 }
2230 }
2231#ifdef PROC_STATISTICS
2232 if (hd->proc & PR_STATISTICS) {
2233 strcat(bp, "\ncommands issued: ");
2234 for (x = 0; x < 7; x++) {
2235 sprintf(tbuf, "\t%ld", hd->cmd_cnt[x]);
2236 strcat(bp, tbuf);
2237 }
2238 strcat(bp, "\ndisconnects allowed:");
2239 for (x = 0; x < 7; x++) {
2240 sprintf(tbuf, "\t%ld", hd->disc_allowed_cnt[x]);
2241 strcat(bp, tbuf);
2242 }
2243 strcat(bp, "\ndisconnects done: ");
2244 for (x = 0; x < 7; x++) {
2245 sprintf(tbuf, "\t%ld", hd->disc_done_cnt[x]);
2246 strcat(bp, tbuf);
2247 }
2248 sprintf(tbuf, "\ninterrupts: \t%ld", hd->int_cnt);
2249 strcat(bp, tbuf);
2250 }
2251#endif
2252 if (hd->proc & PR_CONNECTED) {
2253 strcat(bp, "\nconnected: ");
2254 if (hd->connected) {
2255 cmd = (Scsi_Cmnd *) hd->connected;
2256 sprintf(tbuf, " %ld-%d:%d(%02x)", cmd->pid, cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
2257 strcat(bp, tbuf);
2258 }
2259 }
2260 if (hd->proc & PR_INPUTQ) {
2261 strcat(bp, "\ninput_Q: ");
2262 cmd = (Scsi_Cmnd *) hd->input_Q;
2263 while (cmd) {
2264 sprintf(tbuf, " %ld-%d:%d(%02x)", cmd->pid, cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
2265 strcat(bp, tbuf);
2266 cmd = (Scsi_Cmnd *) cmd->host_scribble;
2267 }
2268 }
2269 if (hd->proc & PR_DISCQ) {
2270 strcat(bp, "\ndisconnected_Q:");
2271 cmd = (Scsi_Cmnd *) hd->disconnected_Q;
2272 while (cmd) {
2273 sprintf(tbuf, " %ld-%d:%d(%02x)", cmd->pid, cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
2274 strcat(bp, tbuf);
2275 cmd = (Scsi_Cmnd *) cmd->host_scribble;
2276 }
2277 }
2278 if (hd->proc & PR_TEST) {
2279 ; /* insert your own custom function here */
2280 }
2281 strcat(bp, "\n");
2282 spin_unlock_irqrestore(instance->host_lock, flags);
2283 *start = buf;
2284 if (stop) {
2285 stop = 0;
2286 return 0; /* return 0 to signal end-of-file */
2287 }
2288 if (off > 0x40000) /* ALWAYS stop after 256k bytes have been read */
2289 stop = 1;
2290 if (hd->proc & PR_STOP) /* stop every other time */
2291 stop = 1;
2292 return strlen(bp);
2293
2294#else /* PROC_INTERFACE */
2295
2296 return 0;
2297
2298#endif /* PROC_INTERFACE */
2299
2300}
2301
2302MODULE_LICENSE("GPL");
2303
2304
2305static Scsi_Host_Template driver_template = {
2306 .proc_name = "in2000",
2307 .proc_info = in2000_proc_info,
2308 .name = "Always IN2000",
2309 .detect = in2000_detect,
2310 .release = in2000_release,
2311 .queuecommand = in2000_queuecommand,
2312 .eh_abort_handler = in2000_abort,
2313 .eh_bus_reset_handler = in2000_bus_reset,
2314 .eh_device_reset_handler = in2000_device_reset,
2315 .eh_host_reset_handler = in2000_host_reset,
2316 .bios_param = in2000_biosparam,
2317 .can_queue = IN2000_CAN_Q,
2318 .this_id = IN2000_HOST_ID,
2319 .sg_tablesize = IN2000_SG,
2320 .cmd_per_lun = IN2000_CPL,
2321 .use_clustering = DISABLE_CLUSTERING,
2322};
2323#include "scsi_module.c"