1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 1996 John Shifflett, GeoLog Consulting
9 * Drew Eckhardt's excellent 'Generic NCR5380' sources from Linux-PC
10 * provided much of the inspiration and some of the code for this
11 * driver. Everything I know about Amiga DMA was gleaned from careful
12 * reading of Hamish Mcdonald's original wd33c93 driver; in fact, I
13 * borrowed shamelessly from all over that source. Thanks Hamish!
15 * _This_ driver is (I feel) an improvement over the old one in
18 * - Target Disconnection/Reconnection is now supported. Any
19 * system with more than one device active on the SCSI bus
20 * will benefit from this. The driver defaults to what I
21 * call 'adaptive disconnect' - meaning that each command
22 * is evaluated individually as to whether or not it should
23 * be run with the option to disconnect/reselect (if the
24 * device chooses), or as a "SCSI-bus-hog".
26 * - Synchronous data transfers are now supported. Because of
27 * a few devices that choke after telling the driver that
28 * they can do sync transfers, we don't automatically use
29 * this faster protocol - it can be enabled via the command-
30 * line on a device-by-device basis.
32 * - Runtime operating parameters can now be specified through
33 * the 'amiboot' or the 'insmod' command line. For amiboot do:
34 * "amiboot [usual stuff] wd33c93=blah,blah,blah"
35 * The defaults should be good for most people. See the comment
36 * for 'setup_strings' below for more details.
38 * - The old driver relied exclusively on what the Western Digital
39 * docs call "Combination Level 2 Commands", which are a great
40 * idea in that the CPU is relieved of a lot of interrupt
41 * overhead. However, by accepting a certain (user-settable)
42 * amount of additional interrupts, this driver achieves
43 * better control over the SCSI bus, and data transfers are
44 * almost as fast while being much easier to define, track,
49 * more speed. linked commands.
52 * People with bug reports, wish-lists, complaints, comments,
53 * or improvements are asked to pah-leeez email me (John Shifflett)
54 * at john@geolog.com or jshiffle@netcom.com! I'm anxious to get
55 * this thing into as good a shape as possible, and I'm positive
56 * there are lots of lurking bugs and "Stupid Places".
60 * Added support for pre -A chips, which don't have advanced features
61 * and will generate CSR_RESEL rather than CSR_RESEL_AM.
62 * Richard Hirst <richard@sleepie.demon.co.uk> August 2000
64 * Added support for Burst Mode DMA and Fast SCSI. Enabled the use of
65 * default_sx_per for asynchronous data transfers. Added adjustment
66 * of transfer periods in sx_table to the actual input-clock.
67 * peter fuerst <post@pfrst.de> February 2007
70 #include <linux/module.h>
72 #include <linux/string.h>
73 #include <linux/delay.h>
74 #include <linux/init.h>
75 #include <linux/interrupt.h>
76 #include <linux/blkdev.h>
78 #include <scsi/scsi.h>
79 #include <scsi/scsi_cmnd.h>
80 #include <scsi/scsi_device.h>
81 #include <scsi/scsi_host.h>
87 #define optimum_sx_per(hostdata) (hostdata)->sx_table[1].period_ns
90 #define WD33C93_VERSION "1.26++"
91 #define WD33C93_DATE "10/Feb/2007"
93 MODULE_AUTHOR("John Shifflett");
94 MODULE_DESCRIPTION("Generic WD33C93 SCSI driver");
95 MODULE_LICENSE("GPL");
98 * 'setup_strings' is a single string used to pass operating parameters and
99 * settings from the kernel/module command-line to the driver. 'setup_args[]'
100 * is an array of strings that define the compile-time default values for
101 * these settings. If Linux boots with an amiboot or insmod command-line,
102 * those settings are combined with 'setup_args[]'. Note that amiboot
103 * command-lines are prefixed with "wd33c93=" while insmod uses a
104 * "setup_strings=" prefix. The driver recognizes the following keywords
105 * (lower case required) and arguments:
107 * - nosync:bitmask -bitmask is a byte where the 1st 7 bits correspond with
108 * the 7 possible SCSI devices. Set a bit to negotiate for
109 * asynchronous transfers on that device. To maintain
110 * backwards compatibility, a command-line such as
111 * "wd33c93=255" will be automatically translated to
112 * "wd33c93=nosync:0xff".
113 * - nodma:x -x = 1 to disable DMA, x = 0 to enable it. Argument is
114 * optional - if not present, same as "nodma:1".
115 * - period:ns -ns is the minimum # of nanoseconds in a SCSI data transfer
116 * period. Default is 500; acceptable values are 250 - 1000.
117 * - disconnect:x -x = 0 to never allow disconnects, 2 to always allow them.
118 * x = 1 does 'adaptive' disconnects, which is the default
119 * and generally the best choice.
120 * - debug:x -If 'DEBUGGING_ON' is defined, x is a bit mask that causes
121 * various types of debug output to printed - see the DB_xxx
122 * defines in wd33c93.h
123 * - clock:x -x = clock input in MHz for WD33c93 chip. Normal values
124 * would be from 8 through 20. Default is 8.
125 * - burst:x -x = 1 to use Burst Mode (or Demand-Mode) DMA, x = 0 to use
126 * Single Byte DMA, which is the default. Argument is
127 * optional - if not present, same as "burst:1".
128 * - fast:x -x = 1 to enable Fast SCSI, which is only effective with
129 * input-clock divisor 4 (WD33C93_FS_16_20), x = 0 to disable
130 * it, which is the default. Argument is optional - if not
131 * present, same as "fast:1".
132 * - next -No argument. Used to separate blocks of keywords when
133 * there's more than one host adapter in the system.
136 * - Numeric arguments can be decimal or the '0x' form of hex notation. There
137 * _must_ be a colon between a keyword and its numeric argument, with no
139 * - Keywords are separated by commas, no spaces, in the standard kernel
140 * command-line manner.
141 * - A keyword in the 'nth' comma-separated command-line member will overwrite
142 * the 'nth' element of setup_args[]. A blank command-line member (in
143 * other words, a comma with no preceding keyword) will _not_ overwrite
144 * the corresponding setup_args[] element.
145 * - If a keyword is used more than once, the first one applies to the first
146 * SCSI host found, the second to the second card, etc, unless the 'next'
147 * keyword is used to change the order.
149 * Some amiboot examples (for insmod, use 'setup_strings' instead of 'wd33c93'):
150 * - wd33c93=nosync:255
153 * - wd33c93=disconnect:2,nosync:0x08,period:250
154 * - wd33c93=debug:0x1c
157 /* Normally, no defaults are specified */
158 static char *setup_args[] = { "", "", "", "", "", "", "", "", "", "" };
160 static char *setup_strings;
161 module_param(setup_strings, charp, 0);
163 static void wd33c93_execute(struct Scsi_Host *instance);
165 #ifdef CONFIG_WD33C93_PIO
167 read_wd33c93(const wd33c93_regs regs, uchar reg_num)
171 outb(reg_num, regs.SASR);
172 data = inb(regs.SCMD);
176 static inline unsigned long
177 read_wd33c93_count(const wd33c93_regs regs)
181 outb(WD_TRANSFER_COUNT_MSB, regs.SASR);
182 value = inb(regs.SCMD) << 16;
183 value |= inb(regs.SCMD) << 8;
184 value |= inb(regs.SCMD);
189 read_aux_stat(const wd33c93_regs regs)
191 return inb(regs.SASR);
195 write_wd33c93(const wd33c93_regs regs, uchar reg_num, uchar value)
197 outb(reg_num, regs.SASR);
198 outb(value, regs.SCMD);
202 write_wd33c93_count(const wd33c93_regs regs, unsigned long value)
204 outb(WD_TRANSFER_COUNT_MSB, regs.SASR);
205 outb((value >> 16) & 0xff, regs.SCMD);
206 outb((value >> 8) & 0xff, regs.SCMD);
207 outb( value & 0xff, regs.SCMD);
210 #define write_wd33c93_cmd(regs, cmd) \
211 write_wd33c93((regs), WD_COMMAND, (cmd))
214 write_wd33c93_cdb(const wd33c93_regs regs, uint len, uchar cmnd[])
218 outb(WD_CDB_1, regs.SASR);
219 for (i=0; i<len; i++)
220 outb(cmnd[i], regs.SCMD);
223 #else /* CONFIG_WD33C93_PIO */
225 read_wd33c93(const wd33c93_regs regs, uchar reg_num)
227 *regs.SASR = reg_num;
233 read_wd33c93_count(const wd33c93_regs regs)
237 *regs.SASR = WD_TRANSFER_COUNT_MSB;
239 value = *regs.SCMD << 16;
240 value |= *regs.SCMD << 8;
247 read_aux_stat(const wd33c93_regs regs)
253 write_wd33c93(const wd33c93_regs regs, uchar reg_num, uchar value)
255 *regs.SASR = reg_num;
262 write_wd33c93_count(const wd33c93_regs regs, unsigned long value)
264 *regs.SASR = WD_TRANSFER_COUNT_MSB;
266 *regs.SCMD = value >> 16;
267 *regs.SCMD = value >> 8;
273 write_wd33c93_cmd(const wd33c93_regs regs, uchar cmd)
275 *regs.SASR = WD_COMMAND;
282 write_wd33c93_cdb(const wd33c93_regs regs, uint len, uchar cmnd[])
286 *regs.SASR = WD_CDB_1;
287 for (i = 0; i < len; i++)
288 *regs.SCMD = cmnd[i];
290 #endif /* CONFIG_WD33C93_PIO */
293 read_1_byte(const wd33c93_regs regs)
298 write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
299 write_wd33c93_cmd(regs, WD_CMD_TRANS_INFO | 0x80);
301 asr = read_aux_stat(regs);
303 x = read_wd33c93(regs, WD_DATA);
304 } while (!(asr & ASR_INT));
309 round_period(unsigned int period, const struct sx_period *sx_table)
313 for (x = 1; sx_table[x].period_ns; x++) {
314 if ((period <= sx_table[x - 0].period_ns) &&
315 (period > sx_table[x - 1].period_ns)) {
323 * Calculate Synchronous Transfer Register value from SDTR code.
326 calc_sync_xfer(unsigned int period, unsigned int offset, unsigned int fast,
327 const struct sx_period *sx_table)
329 /* When doing Fast SCSI synchronous data transfers, the corresponding
330 * value in 'sx_table' is two times the actually used transfer period.
334 if (offset && fast) {
340 period *= 4; /* convert SDTR code to ns */
341 result = sx_table[round_period(period,sx_table)].reg_value;
342 result |= (offset < OPTIMUM_SX_OFF) ? offset : OPTIMUM_SX_OFF;
348 * Calculate SDTR code bytes [3],[4] from period and offset.
351 calc_sync_msg(unsigned int period, unsigned int offset, unsigned int fast,
354 /* 'period' is a "normal"-mode value, like the ones in 'sx_table'. The
355 * actually used transfer period for Fast SCSI synchronous data
356 * transfers is half that value.
365 static int wd33c93_queuecommand_lck(struct scsi_cmnd *cmd)
367 struct WD33C93_hostdata *hostdata;
368 struct scsi_cmnd *tmp;
370 hostdata = (struct WD33C93_hostdata *) cmd->device->host->hostdata;
373 printk("Q-%d-%02x( ", cmd->device->id, cmd->cmnd[0]))
375 /* Set up a few fields in the scsi_cmnd structure for our own use:
376 * - host_scribble is the pointer to the next cmd in the input queue
377 * - result is what you'd expect
379 cmd->host_scribble = NULL;
382 /* We use the Scsi_Pointer structure that's included with each command
383 * as a scratchpad (as it's intended to be used!). The handy thing about
384 * the SCp.xxx fields is that they're always associated with a given
385 * cmd, and are preserved across disconnect-reselect. This means we
386 * can pretty much ignore SAVE_POINTERS and RESTORE_POINTERS messages
387 * if we keep all the critical pointers and counters in SCp:
388 * - SCp.ptr is the pointer into the RAM buffer
389 * - SCp.this_residual is the size of that buffer
390 * - SCp.buffer points to the current scatter-gather buffer
391 * - SCp.buffers_residual tells us how many S.G. buffers there are
392 * - SCp.have_data_in is not used
393 * - SCp.sent_command is not used
394 * - SCp.phase records this command's SRCID_ER bit setting
397 if (scsi_bufflen(cmd)) {
398 cmd->SCp.buffer = scsi_sglist(cmd);
399 cmd->SCp.buffers_residual = scsi_sg_count(cmd) - 1;
400 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
401 cmd->SCp.this_residual = cmd->SCp.buffer->length;
403 cmd->SCp.buffer = NULL;
404 cmd->SCp.buffers_residual = 0;
406 cmd->SCp.this_residual = 0;
409 /* WD docs state that at the conclusion of a "LEVEL2" command, the
410 * status byte can be retrieved from the LUN register. Apparently,
411 * this is the case only for *uninterrupted* LEVEL2 commands! If
412 * there are any unexpected phases entered, even if they are 100%
413 * legal (different devices may choose to do things differently),
414 * the LEVEL2 command sequence is exited. This often occurs prior
415 * to receiving the status byte, in which case the driver does a
416 * status phase interrupt and gets the status byte on its own.
417 * While such a command can then be "resumed" (ie restarted to
418 * finish up as a LEVEL2 command), the LUN register will NOT be
419 * a valid status byte at the command's conclusion, and we must
420 * use the byte obtained during the earlier interrupt. Here, we
421 * preset SCp.Status to an illegal value (0xff) so that when
422 * this command finally completes, we can tell where the actual
423 * status byte is stored.
426 cmd->SCp.Status = ILLEGAL_STATUS_BYTE;
429 * Add the cmd to the end of 'input_Q'. Note that REQUEST SENSE
430 * commands are added to the head of the queue so that the desired
431 * sense data is not lost before REQUEST_SENSE executes.
434 spin_lock_irq(&hostdata->lock);
436 if (!(hostdata->input_Q) || (cmd->cmnd[0] == REQUEST_SENSE)) {
437 cmd->host_scribble = (uchar *) hostdata->input_Q;
438 hostdata->input_Q = cmd;
439 } else { /* find the end of the queue */
440 for (tmp = (struct scsi_cmnd *) hostdata->input_Q;
442 tmp = (struct scsi_cmnd *) tmp->host_scribble) ;
443 tmp->host_scribble = (uchar *) cmd;
446 /* We know that there's at least one command in 'input_Q' now.
447 * Go see if any of them are runnable!
450 wd33c93_execute(cmd->device->host);
452 DB(DB_QUEUE_COMMAND, printk(")Q "))
454 spin_unlock_irq(&hostdata->lock);
458 DEF_SCSI_QCMD(wd33c93_queuecommand)
461 * This routine attempts to start a scsi command. If the host_card is
462 * already connected, we give up immediately. Otherwise, look through
463 * the input_Q, using the first command we find that's intended
464 * for a currently non-busy target/lun.
466 * wd33c93_execute() is always called with interrupts disabled or from
467 * the wd33c93_intr itself, which means that a wd33c93 interrupt
468 * cannot occur while we are in here.
471 wd33c93_execute(struct Scsi_Host *instance)
473 struct WD33C93_hostdata *hostdata =
474 (struct WD33C93_hostdata *) instance->hostdata;
475 const wd33c93_regs regs = hostdata->regs;
476 struct scsi_cmnd *cmd, *prev;
478 DB(DB_EXECUTE, printk("EX("))
479 if (hostdata->selecting || hostdata->connected) {
480 DB(DB_EXECUTE, printk(")EX-0 "))
485 * Search through the input_Q for a command destined
486 * for an idle target/lun.
489 cmd = (struct scsi_cmnd *) hostdata->input_Q;
492 if (!(hostdata->busy[cmd->device->id] &
493 (1 << (cmd->device->lun & 0xff))))
496 cmd = (struct scsi_cmnd *) cmd->host_scribble;
499 /* quit if queue empty or all possible targets are busy */
502 DB(DB_EXECUTE, printk(")EX-1 "))
506 /* remove command from queue */
509 prev->host_scribble = cmd->host_scribble;
511 hostdata->input_Q = (struct scsi_cmnd *) cmd->host_scribble;
513 #ifdef PROC_STATISTICS
514 hostdata->cmd_cnt[cmd->device->id]++;
518 * Start the selection process
521 if (cmd->sc_data_direction == DMA_TO_DEVICE)
522 write_wd33c93(regs, WD_DESTINATION_ID, cmd->device->id);
524 write_wd33c93(regs, WD_DESTINATION_ID, cmd->device->id | DSTID_DPD);
526 /* Now we need to figure out whether or not this command is a good
527 * candidate for disconnect/reselect. We guess to the best of our
528 * ability, based on a set of hierarchical rules. When several
529 * devices are operating simultaneously, disconnects are usually
530 * an advantage. In a single device system, or if only 1 device
531 * is being accessed, transfers usually go faster if disconnects
534 * + Commands should NEVER disconnect if hostdata->disconnect =
535 * DIS_NEVER (this holds for tape drives also), and ALWAYS
536 * disconnect if hostdata->disconnect = DIS_ALWAYS.
537 * + Tape drive commands should always be allowed to disconnect.
538 * + Disconnect should be allowed if disconnected_Q isn't empty.
539 * + Commands should NOT disconnect if input_Q is empty.
540 * + Disconnect should be allowed if there are commands in input_Q
541 * for a different target/lun. In this case, the other commands
542 * should be made disconnect-able, if not already.
544 * I know, I know - this code would flunk me out of any
545 * "C Programming 101" class ever offered. But it's easy
546 * to change around and experiment with for now.
549 cmd->SCp.phase = 0; /* assume no disconnect */
550 if (hostdata->disconnect == DIS_NEVER)
552 if (hostdata->disconnect == DIS_ALWAYS)
554 if (cmd->device->type == 1) /* tape drive? */
556 if (hostdata->disconnected_Q) /* other commands disconnected? */
558 if (!(hostdata->input_Q)) /* input_Q empty? */
560 for (prev = (struct scsi_cmnd *) hostdata->input_Q; prev;
561 prev = (struct scsi_cmnd *) prev->host_scribble) {
562 if ((prev->device->id != cmd->device->id) ||
563 (prev->device->lun != cmd->device->lun)) {
564 for (prev = (struct scsi_cmnd *) hostdata->input_Q; prev;
565 prev = (struct scsi_cmnd *) prev->host_scribble)
576 #ifdef PROC_STATISTICS
577 hostdata->disc_allowed_cnt[cmd->device->id]++;
582 write_wd33c93(regs, WD_SOURCE_ID, ((cmd->SCp.phase) ? SRCID_ER : 0));
584 write_wd33c93(regs, WD_TARGET_LUN, (u8)cmd->device->lun);
585 write_wd33c93(regs, WD_SYNCHRONOUS_TRANSFER,
586 hostdata->sync_xfer[cmd->device->id]);
587 hostdata->busy[cmd->device->id] |= (1 << (cmd->device->lun & 0xFF));
589 if ((hostdata->level2 == L2_NONE) ||
590 (hostdata->sync_stat[cmd->device->id] == SS_UNSET)) {
593 * Do a 'Select-With-ATN' command. This will end with
594 * one of the following interrupts:
595 * CSR_RESEL_AM: failure - can try again later.
596 * CSR_TIMEOUT: failure - give up.
597 * CSR_SELECT: success - proceed.
600 hostdata->selecting = cmd;
602 /* Every target has its own synchronous transfer setting, kept in the
603 * sync_xfer array, and a corresponding status byte in sync_stat[].
604 * Each target's sync_stat[] entry is initialized to SX_UNSET, and its
605 * sync_xfer[] entry is initialized to the default/safe value. SS_UNSET
606 * means that the parameters are undetermined as yet, and that we
607 * need to send an SDTR message to this device after selection is
608 * complete: We set SS_FIRST to tell the interrupt routine to do so.
609 * If we've been asked not to try synchronous transfers on this
610 * target (and _all_ luns within it), we'll still send the SDTR message
611 * later, but at that time we'll negotiate for async by specifying a
612 * sync fifo depth of 0.
614 if (hostdata->sync_stat[cmd->device->id] == SS_UNSET)
615 hostdata->sync_stat[cmd->device->id] = SS_FIRST;
616 hostdata->state = S_SELECTING;
617 write_wd33c93_count(regs, 0); /* guarantee a DATA_PHASE interrupt */
618 write_wd33c93_cmd(regs, WD_CMD_SEL_ATN);
622 * Do a 'Select-With-ATN-Xfer' command. This will end with
623 * one of the following interrupts:
624 * CSR_RESEL_AM: failure - can try again later.
625 * CSR_TIMEOUT: failure - give up.
626 * anything else: success - proceed.
629 hostdata->connected = cmd;
630 write_wd33c93(regs, WD_COMMAND_PHASE, 0);
632 /* copy command_descriptor_block into WD chip
633 * (take advantage of auto-incrementing)
636 write_wd33c93_cdb(regs, cmd->cmd_len, cmd->cmnd);
638 /* The wd33c93 only knows about Group 0, 1, and 5 commands when
639 * it's doing a 'select-and-transfer'. To be safe, we write the
640 * size of the CDB into the OWN_ID register for every case. This
641 * way there won't be problems with vendor-unique, audio, etc.
644 write_wd33c93(regs, WD_OWN_ID, cmd->cmd_len);
646 /* When doing a non-disconnect command with DMA, we can save
647 * ourselves a DATA phase interrupt later by setting everything
651 if ((cmd->SCp.phase == 0) && (hostdata->no_dma == 0)) {
652 if (hostdata->dma_setup(cmd,
653 (cmd->sc_data_direction == DMA_TO_DEVICE) ?
654 DATA_OUT_DIR : DATA_IN_DIR))
655 write_wd33c93_count(regs, 0); /* guarantee a DATA_PHASE interrupt */
657 write_wd33c93_count(regs,
658 cmd->SCp.this_residual);
659 write_wd33c93(regs, WD_CONTROL,
660 CTRL_IDI | CTRL_EDI | hostdata->dma_mode);
661 hostdata->dma = D_DMA_RUNNING;
664 write_wd33c93_count(regs, 0); /* guarantee a DATA_PHASE interrupt */
666 hostdata->state = S_RUNNING_LEVEL2;
667 write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
671 * Since the SCSI bus can handle only 1 connection at a time,
672 * we get out of here now. If the selection fails, or when
673 * the command disconnects, we'll come back to this routine
674 * to search the input_Q again...
678 printk("%s)EX-2 ", (cmd->SCp.phase) ? "d:" : ""))
682 transfer_pio(const wd33c93_regs regs, uchar * buf, int cnt,
683 int data_in_dir, struct WD33C93_hostdata *hostdata)
688 printk("(%p,%d,%s:", buf, cnt, data_in_dir ? "in" : "out"))
690 write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
691 write_wd33c93_count(regs, cnt);
692 write_wd33c93_cmd(regs, WD_CMD_TRANS_INFO);
695 asr = read_aux_stat(regs);
697 *buf++ = read_wd33c93(regs, WD_DATA);
698 } while (!(asr & ASR_INT));
701 asr = read_aux_stat(regs);
703 write_wd33c93(regs, WD_DATA, *buf++);
704 } while (!(asr & ASR_INT));
707 /* Note: we are returning with the interrupt UN-cleared.
708 * Since (presumably) an entire I/O operation has
709 * completed, the bus phase is probably different, and
710 * the interrupt routine will discover this when it
711 * responds to the uncleared int.
717 transfer_bytes(const wd33c93_regs regs, struct scsi_cmnd *cmd,
720 struct WD33C93_hostdata *hostdata;
721 unsigned long length;
723 hostdata = (struct WD33C93_hostdata *) cmd->device->host->hostdata;
725 /* Normally, you'd expect 'this_residual' to be non-zero here.
726 * In a series of scatter-gather transfers, however, this
727 * routine will usually be called with 'this_residual' equal
728 * to 0 and 'buffers_residual' non-zero. This means that a
729 * previous transfer completed, clearing 'this_residual', and
730 * now we need to setup the next scatter-gather buffer as the
731 * source or destination for THIS transfer.
733 if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) {
734 cmd->SCp.buffer = sg_next(cmd->SCp.buffer);
735 --cmd->SCp.buffers_residual;
736 cmd->SCp.this_residual = cmd->SCp.buffer->length;
737 cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);
739 if (!cmd->SCp.this_residual) /* avoid bogus setups */
742 write_wd33c93(regs, WD_SYNCHRONOUS_TRANSFER,
743 hostdata->sync_xfer[cmd->device->id]);
745 /* 'hostdata->no_dma' is TRUE if we don't even want to try DMA.
746 * Update 'this_residual' and 'ptr' after 'transfer_pio()' returns.
749 if (hostdata->no_dma || hostdata->dma_setup(cmd, data_in_dir)) {
750 #ifdef PROC_STATISTICS
753 transfer_pio(regs, (uchar *) cmd->SCp.ptr,
754 cmd->SCp.this_residual, data_in_dir, hostdata);
755 length = cmd->SCp.this_residual;
756 cmd->SCp.this_residual = read_wd33c93_count(regs);
757 cmd->SCp.ptr += (length - cmd->SCp.this_residual);
760 /* We are able to do DMA (in fact, the Amiga hardware is
761 * already going!), so start up the wd33c93 in DMA mode.
762 * We set 'hostdata->dma' = D_DMA_RUNNING so that when the
763 * transfer completes and causes an interrupt, we're
764 * reminded to tell the Amiga to shut down its end. We'll
765 * postpone the updating of 'this_residual' and 'ptr'
770 #ifdef PROC_STATISTICS
773 write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | hostdata->dma_mode);
774 write_wd33c93_count(regs, cmd->SCp.this_residual);
776 if ((hostdata->level2 >= L2_DATA) ||
777 (hostdata->level2 == L2_BASIC && cmd->SCp.phase == 0)) {
778 write_wd33c93(regs, WD_COMMAND_PHASE, 0x45);
779 write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
780 hostdata->state = S_RUNNING_LEVEL2;
782 write_wd33c93_cmd(regs, WD_CMD_TRANS_INFO);
784 hostdata->dma = D_DMA_RUNNING;
789 wd33c93_intr(struct Scsi_Host *instance)
791 struct WD33C93_hostdata *hostdata =
792 (struct WD33C93_hostdata *) instance->hostdata;
793 const wd33c93_regs regs = hostdata->regs;
794 struct scsi_cmnd *patch, *cmd;
795 uchar asr, sr, phs, id, lun, *ucp, msg;
796 unsigned long length, flags;
798 asr = read_aux_stat(regs);
799 if (!(asr & ASR_INT) || (asr & ASR_BSY))
802 spin_lock_irqsave(&hostdata->lock, flags);
804 #ifdef PROC_STATISTICS
808 cmd = (struct scsi_cmnd *) hostdata->connected; /* assume we're connected */
809 sr = read_wd33c93(regs, WD_SCSI_STATUS); /* clear the interrupt */
810 phs = read_wd33c93(regs, WD_COMMAND_PHASE);
812 DB(DB_INTR, printk("{%02x:%02x-", asr, sr))
814 /* After starting a DMA transfer, the next interrupt
815 * is guaranteed to be in response to completion of
816 * the transfer. Since the Amiga DMA hardware runs in
817 * in an open-ended fashion, it needs to be told when
818 * to stop; do that here if D_DMA_RUNNING is true.
819 * Also, we have to update 'this_residual' and 'ptr'
820 * based on the contents of the TRANSFER_COUNT register,
821 * in case the device decided to do an intermediate
822 * disconnect (a device may do this if it has to do a
823 * seek, or just to be nice and let other devices have
824 * some bus time during long transfers). After doing
825 * whatever is needed, we go on and service the WD3393
826 * interrupt normally.
828 if (hostdata->dma == D_DMA_RUNNING) {
830 printk("[%p/%d:", cmd->SCp.ptr, cmd->SCp.this_residual))
831 hostdata->dma_stop(cmd->device->host, cmd, 1);
832 hostdata->dma = D_DMA_OFF;
833 length = cmd->SCp.this_residual;
834 cmd->SCp.this_residual = read_wd33c93_count(regs);
835 cmd->SCp.ptr += (length - cmd->SCp.this_residual);
837 printk("%p/%d]", cmd->SCp.ptr, cmd->SCp.this_residual))
840 /* Respond to the specific WD3393 interrupt - there are quite a few! */
843 DB(DB_INTR, printk("TIMEOUT"))
845 if (hostdata->state == S_RUNNING_LEVEL2)
846 hostdata->connected = NULL;
848 cmd = (struct scsi_cmnd *) hostdata->selecting; /* get a valid cmd */
849 hostdata->selecting = NULL;
852 cmd->result = DID_NO_CONNECT << 16;
853 hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));
854 hostdata->state = S_UNCONNECTED;
858 * There is a window of time within the scsi_done() path
859 * of execution where interrupts are turned back on full
860 * blast and left that way. During that time we could
861 * reconnect to a disconnected command, then we'd bomb
862 * out below. We could also end up executing two commands
863 * at _once_. ...just so you know why the restore_flags()
867 spin_unlock_irqrestore(&hostdata->lock, flags);
869 /* We are not connected to a target - check to see if there
870 * are commands waiting to be executed.
873 wd33c93_execute(instance);
876 /* Note: this interrupt should not occur in a LEVEL2 command */
879 DB(DB_INTR, printk("SELECT"))
880 hostdata->connected = cmd =
881 (struct scsi_cmnd *) hostdata->selecting;
882 hostdata->selecting = NULL;
884 /* construct an IDENTIFY message with correct disconnect bit */
886 hostdata->outgoing_msg[0] = IDENTIFY(0, cmd->device->lun);
888 hostdata->outgoing_msg[0] |= 0x40;
890 if (hostdata->sync_stat[cmd->device->id] == SS_FIRST) {
892 hostdata->sync_stat[cmd->device->id] = SS_WAITING;
894 /* Tack on a 2nd message to ask about synchronous transfers. If we've
895 * been asked to do only asynchronous transfers on this device, we
896 * request a fifo depth of 0, which is equivalent to async - should
897 * solve the problems some people have had with GVP's Guru ROM.
900 hostdata->outgoing_msg[1] = EXTENDED_MESSAGE;
901 hostdata->outgoing_msg[2] = 3;
902 hostdata->outgoing_msg[3] = EXTENDED_SDTR;
903 if (hostdata->no_sync & (1 << cmd->device->id)) {
904 calc_sync_msg(hostdata->default_sx_per, 0,
905 0, hostdata->outgoing_msg + 4);
907 calc_sync_msg(optimum_sx_per(hostdata),
910 hostdata->outgoing_msg + 4);
912 hostdata->outgoing_len = 6;
914 ucp = hostdata->outgoing_msg + 1;
915 printk(" sending SDTR %02x03%02x%02x%02x ",
916 ucp[0], ucp[2], ucp[3], ucp[4]);
919 hostdata->outgoing_len = 1;
921 hostdata->state = S_CONNECTED;
922 spin_unlock_irqrestore(&hostdata->lock, flags);
925 case CSR_XFER_DONE | PHS_DATA_IN:
926 case CSR_UNEXP | PHS_DATA_IN:
927 case CSR_SRV_REQ | PHS_DATA_IN:
929 printk("IN-%d.%d", cmd->SCp.this_residual,
930 cmd->SCp.buffers_residual))
931 transfer_bytes(regs, cmd, DATA_IN_DIR);
932 if (hostdata->state != S_RUNNING_LEVEL2)
933 hostdata->state = S_CONNECTED;
934 spin_unlock_irqrestore(&hostdata->lock, flags);
937 case CSR_XFER_DONE | PHS_DATA_OUT:
938 case CSR_UNEXP | PHS_DATA_OUT:
939 case CSR_SRV_REQ | PHS_DATA_OUT:
941 printk("OUT-%d.%d", cmd->SCp.this_residual,
942 cmd->SCp.buffers_residual))
943 transfer_bytes(regs, cmd, DATA_OUT_DIR);
944 if (hostdata->state != S_RUNNING_LEVEL2)
945 hostdata->state = S_CONNECTED;
946 spin_unlock_irqrestore(&hostdata->lock, flags);
949 /* Note: this interrupt should not occur in a LEVEL2 command */
951 case CSR_XFER_DONE | PHS_COMMAND:
952 case CSR_UNEXP | PHS_COMMAND:
953 case CSR_SRV_REQ | PHS_COMMAND:
954 DB(DB_INTR, printk("CMND-%02x", cmd->cmnd[0]))
955 transfer_pio(regs, cmd->cmnd, cmd->cmd_len, DATA_OUT_DIR,
957 hostdata->state = S_CONNECTED;
958 spin_unlock_irqrestore(&hostdata->lock, flags);
961 case CSR_XFER_DONE | PHS_STATUS:
962 case CSR_UNEXP | PHS_STATUS:
963 case CSR_SRV_REQ | PHS_STATUS:
964 DB(DB_INTR, printk("STATUS="))
965 cmd->SCp.Status = read_1_byte(regs);
966 DB(DB_INTR, printk("%02x", cmd->SCp.Status))
967 if (hostdata->level2 >= L2_BASIC) {
968 sr = read_wd33c93(regs, WD_SCSI_STATUS); /* clear interrupt */
970 hostdata->state = S_RUNNING_LEVEL2;
971 write_wd33c93(regs, WD_COMMAND_PHASE, 0x50);
972 write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
974 hostdata->state = S_CONNECTED;
976 spin_unlock_irqrestore(&hostdata->lock, flags);
979 case CSR_XFER_DONE | PHS_MESS_IN:
980 case CSR_UNEXP | PHS_MESS_IN:
981 case CSR_SRV_REQ | PHS_MESS_IN:
982 DB(DB_INTR, printk("MSG_IN="))
984 msg = read_1_byte(regs);
985 sr = read_wd33c93(regs, WD_SCSI_STATUS); /* clear interrupt */
988 hostdata->incoming_msg[hostdata->incoming_ptr] = msg;
989 if (hostdata->incoming_msg[0] == EXTENDED_MESSAGE)
990 msg = EXTENDED_MESSAGE;
992 hostdata->incoming_ptr = 0;
994 cmd->SCp.Message = msg;
997 case COMMAND_COMPLETE:
998 DB(DB_INTR, printk("CCMP"))
999 write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
1000 hostdata->state = S_PRE_CMP_DISC;
1004 DB(DB_INTR, printk("SDP"))
1005 write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
1006 hostdata->state = S_CONNECTED;
1009 case RESTORE_POINTERS:
1010 DB(DB_INTR, printk("RDP"))
1011 if (hostdata->level2 >= L2_BASIC) {
1012 write_wd33c93(regs, WD_COMMAND_PHASE, 0x45);
1013 write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
1014 hostdata->state = S_RUNNING_LEVEL2;
1016 write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
1017 hostdata->state = S_CONNECTED;
1022 DB(DB_INTR, printk("DIS"))
1023 cmd->device->disconnect = 1;
1024 write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
1025 hostdata->state = S_PRE_TMP_DISC;
1028 case MESSAGE_REJECT:
1029 DB(DB_INTR, printk("REJ"))
1033 if (hostdata->sync_stat[cmd->device->id] == SS_WAITING) {
1034 hostdata->sync_stat[cmd->device->id] = SS_SET;
1035 /* we want default_sx_per, not DEFAULT_SX_PER */
1036 hostdata->sync_xfer[cmd->device->id] =
1037 calc_sync_xfer(hostdata->default_sx_per
1038 / 4, 0, 0, hostdata->sx_table);
1040 write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
1041 hostdata->state = S_CONNECTED;
1044 case EXTENDED_MESSAGE:
1045 DB(DB_INTR, printk("EXT"))
1047 ucp = hostdata->incoming_msg;
1050 printk("%02x", ucp[hostdata->incoming_ptr]);
1052 /* Is this the last byte of the extended message? */
1054 if ((hostdata->incoming_ptr >= 2) &&
1055 (hostdata->incoming_ptr == (ucp[1] + 1))) {
1057 switch (ucp[2]) { /* what's the EXTENDED code? */
1059 /* default to default async period */
1060 id = calc_sync_xfer(hostdata->
1061 default_sx_per / 4, 0,
1062 0, hostdata->sx_table);
1063 if (hostdata->sync_stat[cmd->device->id] !=
1066 /* A device has sent an unsolicited SDTR message; rather than go
1067 * through the effort of decoding it and then figuring out what
1068 * our reply should be, we're just gonna say that we have a
1069 * synchronous fifo depth of 0. This will result in asynchronous
1070 * transfers - not ideal but so much easier.
1071 * Actually, this is OK because it assures us that if we don't
1072 * specifically ask for sync transfers, we won't do any.
1075 write_wd33c93_cmd(regs, WD_CMD_ASSERT_ATN); /* want MESS_OUT */
1076 hostdata->outgoing_msg[0] =
1078 hostdata->outgoing_msg[1] = 3;
1079 hostdata->outgoing_msg[2] =
1081 calc_sync_msg(hostdata->
1083 0, hostdata->outgoing_msg + 3);
1084 hostdata->outgoing_len = 5;
1086 if (ucp[4]) /* well, sync transfer */
1087 id = calc_sync_xfer(ucp[3], ucp[4],
1089 hostdata->sx_table);
1090 else if (ucp[3]) /* very unlikely... */
1091 id = calc_sync_xfer(ucp[3], ucp[4],
1092 0, hostdata->sx_table);
1094 hostdata->sync_xfer[cmd->device->id] = id;
1096 printk(" sync_xfer=%02x\n",
1097 hostdata->sync_xfer[cmd->device->id]);
1099 hostdata->sync_stat[cmd->device->id] =
1101 write_wd33c93_cmd(regs,
1103 hostdata->state = S_CONNECTED;
1106 write_wd33c93_cmd(regs, WD_CMD_ASSERT_ATN); /* want MESS_OUT */
1107 printk("sending WDTR ");
1108 hostdata->outgoing_msg[0] =
1110 hostdata->outgoing_msg[1] = 2;
1111 hostdata->outgoing_msg[2] =
1113 hostdata->outgoing_msg[3] = 0; /* 8 bit transfer width */
1114 hostdata->outgoing_len = 4;
1115 write_wd33c93_cmd(regs,
1117 hostdata->state = S_CONNECTED;
1120 write_wd33c93_cmd(regs, WD_CMD_ASSERT_ATN); /* want MESS_OUT */
1122 ("Rejecting Unknown Extended Message(%02x). ",
1124 hostdata->outgoing_msg[0] =
1126 hostdata->outgoing_len = 1;
1127 write_wd33c93_cmd(regs,
1129 hostdata->state = S_CONNECTED;
1132 hostdata->incoming_ptr = 0;
1135 /* We need to read more MESS_IN bytes for the extended message */
1138 hostdata->incoming_ptr++;
1139 write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
1140 hostdata->state = S_CONNECTED;
1145 printk("Rejecting Unknown Message(%02x) ", msg);
1146 write_wd33c93_cmd(regs, WD_CMD_ASSERT_ATN); /* want MESS_OUT */
1147 hostdata->outgoing_msg[0] = MESSAGE_REJECT;
1148 hostdata->outgoing_len = 1;
1149 write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
1150 hostdata->state = S_CONNECTED;
1152 spin_unlock_irqrestore(&hostdata->lock, flags);
1155 /* Note: this interrupt will occur only after a LEVEL2 command */
1157 case CSR_SEL_XFER_DONE:
1159 /* Make sure that reselection is enabled at this point - it may
1160 * have been turned off for the command that just completed.
1163 write_wd33c93(regs, WD_SOURCE_ID, SRCID_ER);
1165 DB(DB_INTR, printk("SX-DONE"))
1166 cmd->SCp.Message = COMMAND_COMPLETE;
1167 lun = read_wd33c93(regs, WD_TARGET_LUN);
1168 DB(DB_INTR, printk(":%d.%d", cmd->SCp.Status, lun))
1169 hostdata->connected = NULL;
1170 hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));
1171 hostdata->state = S_UNCONNECTED;
1172 if (cmd->SCp.Status == ILLEGAL_STATUS_BYTE)
1173 cmd->SCp.Status = lun;
1174 if (cmd->cmnd[0] == REQUEST_SENSE
1175 && cmd->SCp.Status != SAM_STAT_GOOD) {
1176 set_host_byte(cmd, DID_ERROR);
1178 set_host_byte(cmd, DID_OK);
1179 scsi_msg_to_host_byte(cmd, cmd->SCp.Message);
1180 set_status_byte(cmd, cmd->SCp.Status);
1184 /* We are no longer connected to a target - check to see if
1185 * there are commands waiting to be executed.
1187 spin_unlock_irqrestore(&hostdata->lock, flags);
1188 wd33c93_execute(instance);
1191 ("%02x:%02x:%02x: Unknown SEL_XFER_DONE phase!!---",
1193 spin_unlock_irqrestore(&hostdata->lock, flags);
1197 /* Note: this interrupt will occur only after a LEVEL2 command */
1200 DB(DB_INTR, printk("SDP"))
1201 hostdata->state = S_RUNNING_LEVEL2;
1202 write_wd33c93(regs, WD_COMMAND_PHASE, 0x41);
1203 write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
1204 spin_unlock_irqrestore(&hostdata->lock, flags);
1207 case CSR_XFER_DONE | PHS_MESS_OUT:
1208 case CSR_UNEXP | PHS_MESS_OUT:
1209 case CSR_SRV_REQ | PHS_MESS_OUT:
1210 DB(DB_INTR, printk("MSG_OUT="))
1212 /* To get here, we've probably requested MESSAGE_OUT and have
1213 * already put the correct bytes in outgoing_msg[] and filled
1214 * in outgoing_len. We simply send them out to the SCSI bus.
1215 * Sometimes we get MESSAGE_OUT phase when we're not expecting
1216 * it - like when our SDTR message is rejected by a target. Some
1217 * targets send the REJECT before receiving all of the extended
1218 * message, and then seem to go back to MESSAGE_OUT for a byte
1219 * or two. Not sure why, or if I'm doing something wrong to
1220 * cause this to happen. Regardless, it seems that sending
1221 * NOP messages in these situations results in no harm and
1222 * makes everyone happy.
1224 if (hostdata->outgoing_len == 0) {
1225 hostdata->outgoing_len = 1;
1226 hostdata->outgoing_msg[0] = NOP;
1228 transfer_pio(regs, hostdata->outgoing_msg,
1229 hostdata->outgoing_len, DATA_OUT_DIR, hostdata);
1230 DB(DB_INTR, printk("%02x", hostdata->outgoing_msg[0]))
1231 hostdata->outgoing_len = 0;
1232 hostdata->state = S_CONNECTED;
1233 spin_unlock_irqrestore(&hostdata->lock, flags);
1236 case CSR_UNEXP_DISC:
1238 /* I think I've seen this after a request-sense that was in response
1239 * to an error condition, but not sure. We certainly need to do
1240 * something when we get this interrupt - the question is 'what?'.
1241 * Let's think positively, and assume some command has finished
1242 * in a legal manner (like a command that provokes a request-sense),
1243 * so we treat it as a normal command-complete-disconnect.
1246 /* Make sure that reselection is enabled at this point - it may
1247 * have been turned off for the command that just completed.
1250 write_wd33c93(regs, WD_SOURCE_ID, SRCID_ER);
1252 printk(" - Already disconnected! ");
1253 hostdata->state = S_UNCONNECTED;
1254 spin_unlock_irqrestore(&hostdata->lock, flags);
1257 DB(DB_INTR, printk("UNEXP_DISC"))
1258 hostdata->connected = NULL;
1259 hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));
1260 hostdata->state = S_UNCONNECTED;
1261 if (cmd->cmnd[0] == REQUEST_SENSE &&
1262 cmd->SCp.Status != SAM_STAT_GOOD) {
1263 set_host_byte(cmd, DID_ERROR);
1265 set_host_byte(cmd, DID_OK);
1266 scsi_msg_to_host_byte(cmd, cmd->SCp.Message);
1267 set_status_byte(cmd, cmd->SCp.Status);
1271 /* We are no longer connected to a target - check to see if
1272 * there are commands waiting to be executed.
1274 /* look above for comments on scsi_done() */
1275 spin_unlock_irqrestore(&hostdata->lock, flags);
1276 wd33c93_execute(instance);
1281 /* Make sure that reselection is enabled at this point - it may
1282 * have been turned off for the command that just completed.
1285 write_wd33c93(regs, WD_SOURCE_ID, SRCID_ER);
1286 DB(DB_INTR, printk("DISC"))
1288 printk(" - Already disconnected! ");
1289 hostdata->state = S_UNCONNECTED;
1291 switch (hostdata->state) {
1292 case S_PRE_CMP_DISC:
1293 hostdata->connected = NULL;
1294 hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));
1295 hostdata->state = S_UNCONNECTED;
1296 DB(DB_INTR, printk(":%d", cmd->SCp.Status))
1297 if (cmd->cmnd[0] == REQUEST_SENSE
1298 && cmd->SCp.Status != SAM_STAT_GOOD) {
1299 set_host_byte(cmd, DID_ERROR);
1301 set_host_byte(cmd, DID_OK);
1302 scsi_msg_to_host_byte(cmd, cmd->SCp.Message);
1303 set_status_byte(cmd, cmd->SCp.Status);
1307 case S_PRE_TMP_DISC:
1308 case S_RUNNING_LEVEL2:
1309 cmd->host_scribble = (uchar *) hostdata->disconnected_Q;
1310 hostdata->disconnected_Q = cmd;
1311 hostdata->connected = NULL;
1312 hostdata->state = S_UNCONNECTED;
1314 #ifdef PROC_STATISTICS
1315 hostdata->disc_done_cnt[cmd->device->id]++;
1320 printk("*** Unexpected DISCONNECT interrupt! ***");
1321 hostdata->state = S_UNCONNECTED;
1324 /* We are no longer connected to a target - check to see if
1325 * there are commands waiting to be executed.
1327 spin_unlock_irqrestore(&hostdata->lock, flags);
1328 wd33c93_execute(instance);
1333 DB(DB_INTR, printk("RESEL%s", sr == CSR_RESEL_AM ? "_AM" : ""))
1335 /* Old chips (pre -A ???) don't have advanced features and will
1336 * generate CSR_RESEL. In that case we have to extract the LUN the
1337 * hard way (see below).
1338 * First we have to make sure this reselection didn't
1339 * happen during Arbitration/Selection of some other device.
1340 * If yes, put losing command back on top of input_Q.
1342 if (hostdata->level2 <= L2_NONE) {
1344 if (hostdata->selecting) {
1345 cmd = (struct scsi_cmnd *) hostdata->selecting;
1346 hostdata->selecting = NULL;
1347 hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));
1348 cmd->host_scribble =
1349 (uchar *) hostdata->input_Q;
1350 hostdata->input_Q = cmd;
1358 hostdata->busy[cmd->device->id] &=
1359 ~(1 << (cmd->device->lun & 0xff));
1360 cmd->host_scribble =
1361 (uchar *) hostdata->input_Q;
1362 hostdata->input_Q = cmd;
1365 ("---%02x:%02x:%02x-TROUBLE: Intrusive ReSelect!---",
1374 /* OK - find out which device reselected us. */
1376 id = read_wd33c93(regs, WD_SOURCE_ID);
1379 /* and extract the lun from the ID message. (Note that we don't
1380 * bother to check for a valid message here - I guess this is
1381 * not the right way to go, but...)
1384 if (sr == CSR_RESEL_AM) {
1385 lun = read_wd33c93(regs, WD_DATA);
1386 if (hostdata->level2 < L2_RESELECT)
1387 write_wd33c93_cmd(regs, WD_CMD_NEGATE_ACK);
1390 /* Old chip; wait for msgin phase to pick up the LUN. */
1391 for (lun = 255; lun; lun--) {
1392 if ((asr = read_aux_stat(regs)) & ASR_INT)
1396 if (!(asr & ASR_INT)) {
1398 ("wd33c93: Reselected without IDENTIFY\n");
1401 /* Verify this is a change to MSG_IN and read the message */
1402 sr = read_wd33c93(regs, WD_SCSI_STATUS);
1404 if (sr == (CSR_ABORT | PHS_MESS_IN) ||
1405 sr == (CSR_UNEXP | PHS_MESS_IN) ||
1406 sr == (CSR_SRV_REQ | PHS_MESS_IN)) {
1407 /* Got MSG_IN, grab target LUN */
1408 lun = read_1_byte(regs);
1409 /* Now we expect a 'paused with ACK asserted' int.. */
1410 asr = read_aux_stat(regs);
1411 if (!(asr & ASR_INT)) {
1413 asr = read_aux_stat(regs);
1414 if (!(asr & ASR_INT))
1416 ("wd33c93: No int after LUN on RESEL (%02x)\n",
1419 sr = read_wd33c93(regs, WD_SCSI_STATUS);
1421 if (sr != CSR_MSGIN)
1423 ("wd33c93: Not paused with ACK on RESEL (%02x)\n",
1426 write_wd33c93_cmd(regs,
1430 ("wd33c93: Not MSG_IN on reselect (%02x)\n",
1437 /* Now we look for the command that's reconnecting. */
1439 cmd = (struct scsi_cmnd *) hostdata->disconnected_Q;
1442 if (id == cmd->device->id && lun == (u8)cmd->device->lun)
1445 cmd = (struct scsi_cmnd *) cmd->host_scribble;
1448 /* Hmm. Couldn't find a valid command.... What to do? */
1452 ("---TROUBLE: target %d.%d not in disconnect queue---",
1454 spin_unlock_irqrestore(&hostdata->lock, flags);
1458 /* Ok, found the command - now start it up again. */
1461 patch->host_scribble = cmd->host_scribble;
1463 hostdata->disconnected_Q =
1464 (struct scsi_cmnd *) cmd->host_scribble;
1465 hostdata->connected = cmd;
1467 /* We don't need to worry about 'initialize_SCp()' or 'hostdata->busy[]'
1468 * because these things are preserved over a disconnect.
1469 * But we DO need to fix the DPD bit so it's correct for this command.
1472 if (cmd->sc_data_direction == DMA_TO_DEVICE)
1473 write_wd33c93(regs, WD_DESTINATION_ID, cmd->device->id);
1475 write_wd33c93(regs, WD_DESTINATION_ID,
1476 cmd->device->id | DSTID_DPD);
1477 if (hostdata->level2 >= L2_RESELECT) {
1478 write_wd33c93_count(regs, 0); /* we want a DATA_PHASE interrupt */
1479 write_wd33c93(regs, WD_COMMAND_PHASE, 0x45);
1480 write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
1481 hostdata->state = S_RUNNING_LEVEL2;
1483 hostdata->state = S_CONNECTED;
1485 spin_unlock_irqrestore(&hostdata->lock, flags);
1489 printk("--UNKNOWN INTERRUPT:%02x:%02x:%02x--", asr, sr, phs);
1490 spin_unlock_irqrestore(&hostdata->lock, flags);
1493 DB(DB_INTR, printk("} "))
1498 reset_wd33c93(struct Scsi_Host *instance)
1500 struct WD33C93_hostdata *hostdata =
1501 (struct WD33C93_hostdata *) instance->hostdata;
1502 const wd33c93_regs regs = hostdata->regs;
1505 #ifdef CONFIG_SGI_IP22
1508 extern void sgiwd93_reset(unsigned long);
1509 /* wait 'til the chip gets some time for us */
1510 while ((read_aux_stat(regs) & ASR_BSY) && busycount++ < 100)
1513 * there are scsi devices out there, which manage to lock up
1514 * the wd33c93 in a busy condition. In this state it won't
1515 * accept the reset command. The only way to solve this is to
1516 * give the chip a hardware reset (if possible). The code below
1517 * does this for the SGI Indy, where this is possible
1520 if (read_aux_stat(regs) & ASR_BSY)
1521 sgiwd93_reset(instance->base); /* yeah, give it the hard one */
1525 write_wd33c93(regs, WD_OWN_ID, OWNID_EAF | OWNID_RAF |
1526 instance->this_id | hostdata->clock_freq);
1527 write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
1528 write_wd33c93(regs, WD_SYNCHRONOUS_TRANSFER,
1529 calc_sync_xfer(hostdata->default_sx_per / 4,
1530 DEFAULT_SX_OFF, 0, hostdata->sx_table));
1531 write_wd33c93(regs, WD_COMMAND, WD_CMD_RESET);
1534 #ifdef CONFIG_MVME147_SCSI
1535 udelay(25); /* The old wd33c93 on MVME147 needs this, at least */
1538 while (!(read_aux_stat(regs) & ASR_INT))
1540 sr = read_wd33c93(regs, WD_SCSI_STATUS);
1542 hostdata->microcode = read_wd33c93(regs, WD_CDB_1);
1544 hostdata->chip = C_WD33C93;
1545 else if (sr == 0x01) {
1546 write_wd33c93(regs, WD_QUEUE_TAG, 0xa5); /* any random number */
1547 sr = read_wd33c93(regs, WD_QUEUE_TAG);
1549 hostdata->chip = C_WD33C93B;
1550 write_wd33c93(regs, WD_QUEUE_TAG, 0);
1552 hostdata->chip = C_WD33C93A;
1554 hostdata->chip = C_UNKNOWN_CHIP;
1556 if (hostdata->chip != C_WD33C93B) /* Fast SCSI unavailable */
1559 write_wd33c93(regs, WD_TIMEOUT_PERIOD, TIMEOUT_PERIOD_VALUE);
1560 write_wd33c93(regs, WD_CONTROL, CTRL_IDI | CTRL_EDI | CTRL_POLLED);
1564 wd33c93_host_reset(struct scsi_cmnd * SCpnt)
1566 struct Scsi_Host *instance;
1567 struct WD33C93_hostdata *hostdata;
1570 instance = SCpnt->device->host;
1571 spin_lock_irq(instance->host_lock);
1572 hostdata = (struct WD33C93_hostdata *) instance->hostdata;
1574 printk("scsi%d: reset. ", instance->host_no);
1575 disable_irq(instance->irq);
1577 hostdata->dma_stop(instance, NULL, 0);
1578 for (i = 0; i < 8; i++) {
1579 hostdata->busy[i] = 0;
1580 hostdata->sync_xfer[i] =
1581 calc_sync_xfer(DEFAULT_SX_PER / 4, DEFAULT_SX_OFF,
1582 0, hostdata->sx_table);
1583 hostdata->sync_stat[i] = SS_UNSET; /* using default sync values */
1585 hostdata->input_Q = NULL;
1586 hostdata->selecting = NULL;
1587 hostdata->connected = NULL;
1588 hostdata->disconnected_Q = NULL;
1589 hostdata->state = S_UNCONNECTED;
1590 hostdata->dma = D_DMA_OFF;
1591 hostdata->incoming_ptr = 0;
1592 hostdata->outgoing_len = 0;
1594 reset_wd33c93(instance);
1595 SCpnt->result = DID_RESET << 16;
1596 enable_irq(instance->irq);
1597 spin_unlock_irq(instance->host_lock);
1602 wd33c93_abort(struct scsi_cmnd * cmd)
1604 struct Scsi_Host *instance;
1605 struct WD33C93_hostdata *hostdata;
1607 struct scsi_cmnd *tmp, *prev;
1609 disable_irq(cmd->device->host->irq);
1611 instance = cmd->device->host;
1612 hostdata = (struct WD33C93_hostdata *) instance->hostdata;
1613 regs = hostdata->regs;
1616 * Case 1 : If the command hasn't been issued yet, we simply remove it
1620 tmp = (struct scsi_cmnd *) hostdata->input_Q;
1625 prev->host_scribble = cmd->host_scribble;
1628 (struct scsi_cmnd *) cmd->host_scribble;
1629 cmd->host_scribble = NULL;
1630 cmd->result = DID_ABORT << 16;
1632 ("scsi%d: Abort - removing command from input_Q. ",
1634 enable_irq(cmd->device->host->irq);
1639 tmp = (struct scsi_cmnd *) tmp->host_scribble;
1643 * Case 2 : If the command is connected, we're going to fail the abort
1644 * and let the high level SCSI driver retry at a later time or
1647 * Timeouts, and therefore aborted commands, will be highly unlikely
1648 * and handling them cleanly in this situation would make the common
1649 * case of noresets less efficient, and would pollute our code. So,
1653 if (hostdata->connected == cmd) {
1655 unsigned long timeout;
1657 printk("scsi%d: Aborting connected command - ",
1660 printk("stopping DMA - ");
1661 if (hostdata->dma == D_DMA_RUNNING) {
1662 hostdata->dma_stop(instance, cmd, 0);
1663 hostdata->dma = D_DMA_OFF;
1666 printk("sending wd33c93 ABORT command - ");
1667 write_wd33c93(regs, WD_CONTROL,
1668 CTRL_IDI | CTRL_EDI | CTRL_POLLED);
1669 write_wd33c93_cmd(regs, WD_CMD_ABORT);
1671 /* Now we have to attempt to flush out the FIFO... */
1673 printk("flushing fifo - ");
1676 asr = read_aux_stat(regs);
1678 read_wd33c93(regs, WD_DATA);
1679 } while (!(asr & ASR_INT) && timeout-- > 0);
1680 sr = read_wd33c93(regs, WD_SCSI_STATUS);
1682 ("asr=%02x, sr=%02x, %ld bytes un-transferred (timeout=%ld) - ",
1683 asr, sr, read_wd33c93_count(regs), timeout);
1686 * Abort command processed.
1688 * We must disconnect.
1691 printk("sending wd33c93 DISCONNECT command - ");
1692 write_wd33c93_cmd(regs, WD_CMD_DISCONNECT);
1695 asr = read_aux_stat(regs);
1696 while ((asr & ASR_CIP) && timeout-- > 0)
1697 asr = read_aux_stat(regs);
1698 sr = read_wd33c93(regs, WD_SCSI_STATUS);
1699 printk("asr=%02x, sr=%02x.", asr, sr);
1701 hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));
1702 hostdata->connected = NULL;
1703 hostdata->state = S_UNCONNECTED;
1704 cmd->result = DID_ABORT << 16;
1707 wd33c93_execute(instance);
1709 enable_irq(cmd->device->host->irq);
1715 * Case 3: If the command is currently disconnected from the bus,
1716 * we're not going to expend much effort here: Let's just return
1717 * an ABORT_SNOOZE and hope for the best...
1720 tmp = (struct scsi_cmnd *) hostdata->disconnected_Q;
1724 ("scsi%d: Abort - command found on disconnected_Q - ",
1726 printk("Abort SNOOZE. ");
1727 enable_irq(cmd->device->host->irq);
1730 tmp = (struct scsi_cmnd *) tmp->host_scribble;
1734 * Case 4 : If we reached this point, the command was not found in any of
1737 * We probably reached this point because of an unlikely race condition
1738 * between the command completing successfully and the abortion code,
1739 * so we won't panic, but we will notify the user in case something really
1744 wd33c93_execute(instance);
1746 enable_irq(cmd->device->host->irq);
1747 printk("scsi%d: warning : SCSI command probably completed successfully"
1748 " before abortion. ", instance->host_no);
1752 #define MAX_WD33C93_HOSTS 4
1753 #define MAX_SETUP_ARGS ARRAY_SIZE(setup_args)
1754 #define SETUP_BUFFER_SIZE 200
1755 static char setup_buffer[SETUP_BUFFER_SIZE];
1756 static char setup_used[MAX_SETUP_ARGS];
1757 static int done_setup = 0;
1760 wd33c93_setup(char *str)
1765 /* The kernel does some processing of the command-line before calling
1766 * this function: If it begins with any decimal or hex number arguments,
1767 * ints[0] = how many numbers found and ints[1] through [n] are the values
1768 * themselves. str points to where the non-numeric arguments (if any)
1769 * start: We do our own parsing of those. We construct synthetic 'nosync'
1770 * keywords out of numeric args (to maintain compatibility with older
1771 * versions) and then add the rest of the arguments.
1777 strncpy(p1, str, SETUP_BUFFER_SIZE - strlen(setup_buffer));
1778 setup_buffer[SETUP_BUFFER_SIZE - 1] = '\0';
1781 while (*p1 && (i < MAX_SETUP_ARGS)) {
1782 p2 = strchr(p1, ',');
1794 for (i = 0; i < MAX_SETUP_ARGS; i++)
1800 __setup("wd33c93=", wd33c93_setup);
1802 /* check_setup_args() returns index if key found, 0 if not
1805 check_setup_args(char *key, int *flags, int *val, char *buf)
1810 for (x = 0; x < MAX_SETUP_ARGS; x++) {
1813 if (!strncmp(setup_args[x], key, strlen(key)))
1815 if (!strncmp(setup_args[x], "next", strlen("next")))
1818 if (x == MAX_SETUP_ARGS)
1821 cp = setup_args[x] + strlen(key);
1826 if ((*cp >= '0') && (*cp <= '9')) {
1827 *val = simple_strtoul(cp, NULL, 0);
1833 * Calculate internal data-transfer-clock cycle from input-clock
1834 * frequency (/MHz) and fill 'sx_table'.
1836 * The original driver used to rely on a fixed sx_table, containing periods
1837 * for (only) the lower limits of the respective input-clock-frequency ranges
1838 * (8-10/12-15/16-20 MHz). Although it seems, that no problems occurred with
1839 * this setting so far, it might be desirable to adjust the transfer periods
1840 * closer to the really attached, possibly 25% higher, input-clock, since
1841 * - the wd33c93 may really use a significant shorter period, than it has
1842 * negotiated (eg. thrashing the target, which expects 4/8MHz, with 5/10MHz
1844 * - the wd33c93 may ask the target for a lower transfer rate, than the target
1845 * is capable of (eg. negotiating for an assumed minimum of 252ns instead of
1846 * possible 200ns, which indeed shows up in tests as an approx. 10% lower
1849 static inline unsigned int
1850 round_4(unsigned int x)
1863 calc_sx_table(unsigned int mhz, struct sx_period sx_table[9])
1867 d = 2; /* divisor for 8-10 MHz input-clock */
1869 d = 3; /* divisor for 12-15 MHz input-clock */
1871 d = 4; /* divisor for 16-20 MHz input-clock */
1873 d = (100000 * d) / 2 / mhz; /* 100 x DTCC / nanosec */
1875 sx_table[0].period_ns = 1;
1876 sx_table[0].reg_value = 0x20;
1877 for (i = 1; i < 8; i++) {
1878 sx_table[i].period_ns = round_4((i+1)*d / 100);
1879 sx_table[i].reg_value = (i+1)*0x10;
1881 sx_table[7].reg_value = 0;
1882 sx_table[8].period_ns = 0;
1883 sx_table[8].reg_value = 0;
1887 * check and, maybe, map an init- or "clock:"- argument.
1890 set_clk_freq(int freq, int *mhz)
1893 if (WD33C93_FS_8_10 == freq)
1895 else if (WD33C93_FS_12_15 == freq)
1897 else if (WD33C93_FS_16_20 == freq)
1899 else if (freq > 7 && freq < 11)
1900 x = WD33C93_FS_8_10;
1901 else if (freq > 11 && freq < 16)
1902 x = WD33C93_FS_12_15;
1903 else if (freq > 15 && freq < 21)
1904 x = WD33C93_FS_16_20;
1906 /* Hmm, wouldn't it be safer to assume highest freq here? */
1907 x = WD33C93_FS_8_10;
1915 * to be used with the resync: fast: ... options
1917 static inline void set_resync ( struct WD33C93_hostdata *hd, int mask )
1920 for (i = 0; i < 8; i++)
1921 if (mask & (1 << i))
1922 hd->sync_stat[i] = SS_UNSET;
1926 wd33c93_init(struct Scsi_Host *instance, const wd33c93_regs regs,
1927 dma_setup_t setup, dma_stop_t stop, int clock_freq)
1929 struct WD33C93_hostdata *hostdata;
1935 if (!done_setup && setup_strings)
1936 wd33c93_setup(setup_strings);
1938 hostdata = (struct WD33C93_hostdata *) instance->hostdata;
1940 hostdata->regs = regs;
1941 hostdata->clock_freq = set_clk_freq(clock_freq, &i);
1942 calc_sx_table(i, hostdata->sx_table);
1943 hostdata->dma_setup = setup;
1944 hostdata->dma_stop = stop;
1945 hostdata->dma_bounce_buffer = NULL;
1946 hostdata->dma_bounce_len = 0;
1947 for (i = 0; i < 8; i++) {
1948 hostdata->busy[i] = 0;
1949 hostdata->sync_xfer[i] =
1950 calc_sync_xfer(DEFAULT_SX_PER / 4, DEFAULT_SX_OFF,
1951 0, hostdata->sx_table);
1952 hostdata->sync_stat[i] = SS_UNSET; /* using default sync values */
1953 #ifdef PROC_STATISTICS
1954 hostdata->cmd_cnt[i] = 0;
1955 hostdata->disc_allowed_cnt[i] = 0;
1956 hostdata->disc_done_cnt[i] = 0;
1959 hostdata->input_Q = NULL;
1960 hostdata->selecting = NULL;
1961 hostdata->connected = NULL;
1962 hostdata->disconnected_Q = NULL;
1963 hostdata->state = S_UNCONNECTED;
1964 hostdata->dma = D_DMA_OFF;
1965 hostdata->level2 = L2_BASIC;
1966 hostdata->disconnect = DIS_ADAPTIVE;
1967 hostdata->args = DEBUG_DEFAULTS;
1968 hostdata->incoming_ptr = 0;
1969 hostdata->outgoing_len = 0;
1970 hostdata->default_sx_per = DEFAULT_SX_PER;
1971 hostdata->no_dma = 0; /* default is DMA enabled */
1973 #ifdef PROC_INTERFACE
1974 hostdata->proc = PR_VERSION | PR_INFO | PR_STATISTICS |
1975 PR_CONNECTED | PR_INPUTQ | PR_DISCQ | PR_STOP;
1976 #ifdef PROC_STATISTICS
1977 hostdata->dma_cnt = 0;
1978 hostdata->pio_cnt = 0;
1979 hostdata->int_cnt = 0;
1983 if (check_setup_args("clock", &flags, &val, buf)) {
1984 hostdata->clock_freq = set_clk_freq(val, &val);
1985 calc_sx_table(val, hostdata->sx_table);
1988 if (check_setup_args("nosync", &flags, &val, buf))
1989 hostdata->no_sync = val;
1991 if (check_setup_args("nodma", &flags, &val, buf))
1992 hostdata->no_dma = (val == -1) ? 1 : val;
1994 if (check_setup_args("period", &flags, &val, buf))
1995 hostdata->default_sx_per =
1996 hostdata->sx_table[round_period((unsigned int) val,
1997 hostdata->sx_table)].period_ns;
1999 if (check_setup_args("disconnect", &flags, &val, buf)) {
2000 if ((val >= DIS_NEVER) && (val <= DIS_ALWAYS))
2001 hostdata->disconnect = val;
2003 hostdata->disconnect = DIS_ADAPTIVE;
2006 if (check_setup_args("level2", &flags, &val, buf))
2007 hostdata->level2 = val;
2009 if (check_setup_args("debug", &flags, &val, buf))
2010 hostdata->args = val & DB_MASK;
2012 if (check_setup_args("burst", &flags, &val, buf))
2013 hostdata->dma_mode = val ? CTRL_BURST:CTRL_DMA;
2015 if (WD33C93_FS_16_20 == hostdata->clock_freq /* divisor 4 */
2016 && check_setup_args("fast", &flags, &val, buf))
2017 hostdata->fast = !!val;
2019 if ((i = check_setup_args("next", &flags, &val, buf))) {
2021 setup_used[--i] = 1;
2023 #ifdef PROC_INTERFACE
2024 if (check_setup_args("proc", &flags, &val, buf))
2025 hostdata->proc = val;
2028 spin_lock_irq(&hostdata->lock);
2029 reset_wd33c93(instance);
2030 spin_unlock_irq(&hostdata->lock);
2032 printk("wd33c93-%d: chip=%s/%d no_sync=0x%x no_dma=%d",
2034 (hostdata->chip == C_WD33C93) ? "WD33c93" : (hostdata->chip ==
2036 "WD33c93A" : (hostdata->chip ==
2037 C_WD33C93B) ? "WD33c93B" : "unknown",
2038 hostdata->microcode, hostdata->no_sync, hostdata->no_dma);
2040 printk(" debug_flags=0x%02x\n", hostdata->args);
2042 printk(" debugging=OFF\n");
2044 printk(" setup_args=");
2045 for (i = 0; i < MAX_SETUP_ARGS; i++)
2046 printk("%s,", setup_args[i]);
2048 printk(" Version %s - %s\n", WD33C93_VERSION, WD33C93_DATE);
2051 int wd33c93_write_info(struct Scsi_Host *instance, char *buf, int len)
2053 #ifdef PROC_INTERFACE
2055 struct WD33C93_hostdata *hd;
2058 hd = (struct WD33C93_hostdata *) instance->hostdata;
2060 /* We accept the following
2061 * keywords (same format as command-line, but arguments are not optional):
2075 for (bp = buf; *bp; ) {
2076 while (',' == *bp || ' ' == *bp)
2078 if (!strncmp(bp, "debug:", 6)) {
2079 hd->args = simple_strtoul(bp+6, &bp, 0) & DB_MASK;
2080 } else if (!strncmp(bp, "disconnect:", 11)) {
2081 x = simple_strtoul(bp+11, &bp, 0);
2082 if (x < DIS_NEVER || x > DIS_ALWAYS)
2085 } else if (!strncmp(bp, "period:", 7)) {
2086 x = simple_strtoul(bp+7, &bp, 0);
2087 hd->default_sx_per =
2088 hd->sx_table[round_period((unsigned int) x,
2089 hd->sx_table)].period_ns;
2090 } else if (!strncmp(bp, "resync:", 7)) {
2091 set_resync(hd, (int)simple_strtoul(bp+7, &bp, 0));
2092 } else if (!strncmp(bp, "proc:", 5)) {
2093 hd->proc = simple_strtoul(bp+5, &bp, 0);
2094 } else if (!strncmp(bp, "nodma:", 6)) {
2095 hd->no_dma = simple_strtoul(bp+6, &bp, 0);
2096 } else if (!strncmp(bp, "level2:", 7)) {
2097 hd->level2 = simple_strtoul(bp+7, &bp, 0);
2098 } else if (!strncmp(bp, "burst:", 6)) {
2100 simple_strtol(bp+6, &bp, 0) ? CTRL_BURST:CTRL_DMA;
2101 } else if (!strncmp(bp, "fast:", 5)) {
2102 x = !!simple_strtol(bp+5, &bp, 0);
2104 set_resync(hd, 0xff);
2106 } else if (!strncmp(bp, "nosync:", 7)) {
2107 x = simple_strtoul(bp+7, &bp, 0);
2108 set_resync(hd, x ^ hd->no_sync);
2111 break; /* unknown keyword,syntax-error,... */
2121 wd33c93_show_info(struct seq_file *m, struct Scsi_Host *instance)
2123 #ifdef PROC_INTERFACE
2124 struct WD33C93_hostdata *hd;
2125 struct scsi_cmnd *cmd;
2128 hd = (struct WD33C93_hostdata *) instance->hostdata;
2130 spin_lock_irq(&hd->lock);
2131 if (hd->proc & PR_VERSION)
2132 seq_printf(m, "\nVersion %s - %s.",
2133 WD33C93_VERSION, WD33C93_DATE);
2135 if (hd->proc & PR_INFO) {
2136 seq_printf(m, "\nclock_freq=%02x no_sync=%02x no_dma=%d"
2137 " dma_mode=%02x fast=%d",
2138 hd->clock_freq, hd->no_sync, hd->no_dma, hd->dma_mode, hd->fast);
2139 seq_puts(m, "\nsync_xfer[] = ");
2140 for (x = 0; x < 7; x++)
2141 seq_printf(m, "\t%02x", hd->sync_xfer[x]);
2142 seq_puts(m, "\nsync_stat[] = ");
2143 for (x = 0; x < 7; x++)
2144 seq_printf(m, "\t%02x", hd->sync_stat[x]);
2146 #ifdef PROC_STATISTICS
2147 if (hd->proc & PR_STATISTICS) {
2148 seq_puts(m, "\ncommands issued: ");
2149 for (x = 0; x < 7; x++)
2150 seq_printf(m, "\t%ld", hd->cmd_cnt[x]);
2151 seq_puts(m, "\ndisconnects allowed:");
2152 for (x = 0; x < 7; x++)
2153 seq_printf(m, "\t%ld", hd->disc_allowed_cnt[x]);
2154 seq_puts(m, "\ndisconnects done: ");
2155 for (x = 0; x < 7; x++)
2156 seq_printf(m, "\t%ld", hd->disc_done_cnt[x]);
2158 "\ninterrupts: %ld, DATA_PHASE ints: %ld DMA, %ld PIO",
2159 hd->int_cnt, hd->dma_cnt, hd->pio_cnt);
2162 if (hd->proc & PR_CONNECTED) {
2163 seq_puts(m, "\nconnected: ");
2164 if (hd->connected) {
2165 cmd = (struct scsi_cmnd *) hd->connected;
2166 seq_printf(m, " %d:%llu(%02x)",
2167 cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
2170 if (hd->proc & PR_INPUTQ) {
2171 seq_puts(m, "\ninput_Q: ");
2172 cmd = (struct scsi_cmnd *) hd->input_Q;
2174 seq_printf(m, " %d:%llu(%02x)",
2175 cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
2176 cmd = (struct scsi_cmnd *) cmd->host_scribble;
2179 if (hd->proc & PR_DISCQ) {
2180 seq_puts(m, "\ndisconnected_Q:");
2181 cmd = (struct scsi_cmnd *) hd->disconnected_Q;
2183 seq_printf(m, " %d:%llu(%02x)",
2184 cmd->device->id, cmd->device->lun, cmd->cmnd[0]);
2185 cmd = (struct scsi_cmnd *) cmd->host_scribble;
2189 spin_unlock_irq(&hd->lock);
2190 #endif /* PROC_INTERFACE */
2194 EXPORT_SYMBOL(wd33c93_host_reset);
2195 EXPORT_SYMBOL(wd33c93_init);
2196 EXPORT_SYMBOL(wd33c93_abort);
2197 EXPORT_SYMBOL(wd33c93_queuecommand);
2198 EXPORT_SYMBOL(wd33c93_intr);
2199 EXPORT_SYMBOL(wd33c93_show_info);
2200 EXPORT_SYMBOL(wd33c93_write_info);