1 /* ppa.c -- low level driver for the IOMEGA PPA3
2 * parallel port SCSI host adapter.
4 * (The PPA3 is the embedded controller in the ZIP drive.)
6 * (c) 1995,1996 Grant R. Guenther, grant@torque.net,
7 * under the terms of the GNU General Public License.
9 * Current Maintainer: David Campbell (Perth, Western Australia, GMT+0800)
13 #include <linux/config.h>
15 /* The following #define is to avoid a clash with hosts.c */
18 #include <linux/blk.h>
20 #include <linux/parport.h>
23 int ppa_release(struct Scsi_Host *);
24 static void ppa_reset_pulse(unsigned int base);
27 struct pardevice *dev; /* Parport device entry */
28 int base; /* Actual port address */
29 int mode; /* Transfer mode */
30 int host; /* Host number (for proc) */
31 Scsi_Cmnd *cur_cmd; /* Current queued command */
32 struct tq_struct ppa_tq; /* Polling interrupt stuff */
33 unsigned long jstart; /* Jiffies at start */
34 unsigned long recon_tmo; /* How many usecs to wait for reconnection (6th bit) */
35 unsigned int failed:1; /* Failure flag */
36 unsigned int p_busy:1; /* Parport sharing busy flag */
42 mode: PPA_AUTODETECT, \
45 ppa_tq: { routine: ppa_interrupt }, \
47 recon_tmo: PPA_RECON_TMO, \
55 static ppa_struct ppa_hosts[NO_HOSTS] =
56 {PPA_EMPTY, PPA_EMPTY, PPA_EMPTY, PPA_EMPTY};
58 #define PPA_BASE(x) ppa_hosts[(x)].base
60 void ppa_wakeup(void *ref)
62 ppa_struct *ppa_dev = (ppa_struct *) ref;
67 if (parport_claim(ppa_dev->dev)) {
68 printk("ppa: bug in ppa_wakeup\n");
72 ppa_dev->base = ppa_dev->dev->port->base;
74 ppa_dev->cur_cmd->SCp.phase++;
78 int ppa_release(struct Scsi_Host *host)
80 int host_no = host->unique_id;
82 printk("Releasing ppa%i\n", host_no);
83 parport_unregister_device(ppa_hosts[host_no].dev);
87 static int ppa_pb_claim(int host_no)
89 if (parport_claim(ppa_hosts[host_no].dev)) {
90 ppa_hosts[host_no].p_busy = 1;
93 if (ppa_hosts[host_no].cur_cmd)
94 ppa_hosts[host_no].cur_cmd->SCp.phase++;
98 #define ppa_pb_release(x) parport_release(ppa_hosts[(x)].dev)
100 /***************************************************************************
101 * Parallel port probing routines *
102 ***************************************************************************/
104 static Scsi_Host_Template driver_template = PPA;
105 #include "scsi_module.c"
108 * Start of Chipset kludges
111 int ppa_detect(Scsi_Host_Template * host)
113 struct Scsi_Host *hreg;
115 int i, nhosts, try_again;
119 * unlock to allow the lowlevel parport driver to probe
122 spin_unlock_irq(&io_request_lock);
123 pb = parport_enumerate();
125 printk("ppa: Version %s\n", PPA_VERSION);
130 printk("ppa: parport reports no devices.\n");
131 spin_lock_irq(&io_request_lock);
135 for (i = 0; pb; i++, pb = pb->next) {
136 int modes, ppb, ppb_hi;
139 parport_register_device(pb, "ppa", NULL, ppa_wakeup,
140 NULL, 0, (void *) &ppa_hosts[i]);
142 if (!ppa_hosts[i].dev)
145 /* Claim the bus so it remembers what we do to the control
146 * registers. [ CTR and ECP ]
148 if (ppa_pb_claim(i)) {
149 unsigned long now = jiffies;
150 while (ppa_hosts[i].p_busy) {
151 schedule(); /* We are safe to schedule here */
152 if (time_after(jiffies, now + 3 * HZ)) {
153 printk(KERN_ERR "ppa%d: failed to claim parport because a "
154 "pardevice is owning the port for too longtime!\n",
156 parport_unregister_device(ppa_hosts[i].dev);
157 spin_lock_irq(&io_request_lock);
162 ppb = PPA_BASE(i) = ppa_hosts[i].dev->port->base;
163 ppb_hi = ppa_hosts[i].dev->port->base_hi;
165 modes = ppa_hosts[i].dev->port->modes;
167 /* Mode detection works up the chain of speed
168 * This avoids a nasty if-then-else-if-... tree
170 ppa_hosts[i].mode = PPA_NIBBLE;
172 if (modes & PARPORT_MODE_TRISTATE)
173 ppa_hosts[i].mode = PPA_PS2;
175 if (modes & PARPORT_MODE_ECP) {
177 ppa_hosts[i].mode = PPA_PS2;
179 if ((modes & PARPORT_MODE_EPP) && (modes & PARPORT_MODE_ECP))
182 /* Done configuration */
186 parport_unregister_device(ppa_hosts[i].dev);
189 /* now the glue ... */
190 switch (ppa_hosts[i].mode) {
202 default: /* Never gets here */
206 host->can_queue = PPA_CAN_QUEUE;
207 host->sg_tablesize = ppa_sg;
208 hreg = scsi_register(host, 0);
211 hreg->io_port = pb->base;
212 hreg->n_io_port = ports;
213 hreg->dma_channel = -1;
215 ppa_hosts[i].host = hreg->host_no;
219 if (try_again == 1) {
220 printk("WARNING - no ppa compatible devices found.\n");
221 printk(" As of 31/Aug/1998 Iomega started shipping parallel\n");
222 printk(" port ZIP drives with a different interface which is\n");
223 printk(" supported by the imm (ZIP Plus) driver. If the\n");
224 printk(" cable is marked with \"AutoDetect\", this is what has\n");
225 printk(" happened.\n");
226 spin_lock_irq(&io_request_lock);
232 spin_lock_irq(&io_request_lock);
233 return 1; /* return number of hosts detected */
237 /* This is to give the ppa driver a way to modify the timings (and other
238 * parameters) by writing to the /proc/scsi/ppa/0 file.
239 * Very simple method really... (To simple, no error checking :( )
240 * Reason: Kernel hackers HATE having to unload and reload modules for
242 * Also gives a method to use a script to obtain optimum timings (TODO)
245 static inline int ppa_proc_write(int hostno, char *buffer, int length)
249 if ((length > 5) && (strncmp(buffer, "mode=", 5) == 0)) {
250 x = simple_strtoul(buffer + 5, NULL, 0);
251 ppa_hosts[hostno].mode = x;
254 if ((length > 10) && (strncmp(buffer, "recon_tmo=", 10) == 0)) {
255 x = simple_strtoul(buffer + 10, NULL, 0);
256 ppa_hosts[hostno].recon_tmo = x;
257 printk("ppa: recon_tmo set to %ld\n", x);
260 printk("ppa /proc: invalid variable\n");
264 int ppa_proc_info(char *buffer, char **start, off_t offset,
265 int length, int hostno, int inout)
270 for (i = 0; i < 4; i++)
271 if (ppa_hosts[i].host == hostno)
275 return ppa_proc_write(i, buffer, length);
277 len += sprintf(buffer + len, "Version : %s\n", PPA_VERSION);
278 len += sprintf(buffer + len, "Parport : %s\n", ppa_hosts[i].dev->port->name);
279 len += sprintf(buffer + len, "Mode : %s\n", PPA_MODE_STRING[ppa_hosts[i].mode]);
281 len += sprintf(buffer + len, "recon_tmo : %lu\n", ppa_hosts[i].recon_tmo);
284 /* Request for beyond end of buffer */
288 *start = buffer + offset;
295 static int device_check(int host_no);
298 #define ppa_fail(x,y) printk("ppa: ppa_fail(%i) from %s at line %d\n",\
299 y, __FUNCTION__, __LINE__); ppa_fail_func(x,y);
300 static inline void ppa_fail_func(int host_no, int error_code)
302 static inline void ppa_fail(int host_no, int error_code)
305 /* If we fail a device then we trash status / message bytes */
306 if (ppa_hosts[host_no].cur_cmd) {
307 ppa_hosts[host_no].cur_cmd->result = error_code << 16;
308 ppa_hosts[host_no].failed = 1;
313 * Wait for the high bit to be set.
315 * In principle, this could be tied to an interrupt, but the adapter
316 * doesn't appear to be designed to support interrupts. We spin on
317 * the 0x80 ready bit.
319 static unsigned char ppa_wait(int host_no)
322 unsigned short ppb = PPA_BASE(host_no);
326 /* Wait for bit 6 and 7 - PJC */
327 for (r = r_str (ppb); ((r & 0xc0)!=0xc0) && (k); k--) {
333 * return some status information.
334 * Semantics: 0xc0 = ZIP wants more data
335 * 0xd0 = ZIP wants to send more data
336 * 0xe0 = ZIP is expecting SCSI command data
337 * 0xf0 = end of transfer, ZIP is sending status
342 /* Counter expired - Time out occurred */
343 ppa_fail(host_no, DID_TIME_OUT);
344 printk("ppa timeout in ppa_wait\n");
345 return 0; /* command timed out */
349 * Clear EPP Timeout Bit
351 static inline void epp_reset(unsigned short ppb)
357 w_str(ppb, i & 0xfe);
361 * Wait for empty ECP fifo (if we are in ECP fifo mode only)
363 static inline void ecp_sync(unsigned short hostno)
365 int i, ppb_hi=ppa_hosts[hostno].dev->port->base_hi;
367 if (ppb_hi == 0) return;
369 if ((r_ecr(ppb_hi) & 0xe0) == 0x60) { /* mode 011 == ECP fifo mode */
370 for (i = 0; i < 100; i++) {
371 if (r_ecr(ppb_hi) & 0x01)
375 printk("ppa: ECP sync failed as data still present in FIFO.\n");
379 static int ppa_byte_out(unsigned short base, const char *buffer, int len)
383 for (i = len; i; i--) {
384 w_dtr(base, *buffer++);
388 return 1; /* All went well - we hope! */
391 static int ppa_byte_in(unsigned short base, char *buffer, int len)
395 for (i = len; i; i--) {
396 *buffer++ = r_dtr(base);
400 return 1; /* All went well - we hope! */
403 static int ppa_nibble_in(unsigned short base, char *buffer, int len)
409 h = r_str(base) & 0xf0;
411 *buffer++ = h | ((r_str(base) & 0xf0) >> 4);
413 return 1; /* All went well - we hope! */
416 static int ppa_out(int host_no, char *buffer, int len)
419 unsigned short ppb = PPA_BASE(host_no);
421 r = ppa_wait(host_no);
423 if ((r & 0x50) != 0x40) {
424 ppa_fail(host_no, DID_ERROR);
427 switch (ppa_hosts[host_no].mode) {
430 /* 8 bit output, with a loop */
431 r = ppa_byte_out(ppb, buffer, len);
439 #ifdef CONFIG_SCSI_IZIP_EPP16
440 if (!(((long) buffer | len) & 0x01))
441 outsw(ppb + 4, buffer, len >> 1);
443 if (!(((long) buffer | len) & 0x03))
444 outsl(ppb + 4, buffer, len >> 2);
447 outsb(ppb + 4, buffer, len);
449 r = !(r_str(ppb) & 0x01);
455 printk("PPA: bug in ppa_out()\n");
461 static int ppa_in(int host_no, char *buffer, int len)
464 unsigned short ppb = PPA_BASE(host_no);
466 r = ppa_wait(host_no);
468 if ((r & 0x50) != 0x50) {
469 ppa_fail(host_no, DID_ERROR);
472 switch (ppa_hosts[host_no].mode) {
474 /* 4 bit input, with a loop */
475 r = ppa_nibble_in(ppb, buffer, len);
480 /* 8 bit input, with a loop */
482 r = ppa_byte_in(ppb, buffer, len);
492 #ifdef CONFIG_SCSI_IZIP_EPP16
493 if (!(((long) buffer | len) & 0x01))
494 insw(ppb + 4, buffer, len >> 1);
496 if (!(((long) buffer | len) & 0x03))
497 insl(ppb + 4, buffer, len >> 2);
500 insb(ppb + 4, buffer, len);
502 r = !(r_str(ppb) & 0x01);
508 printk("PPA: bug in ppa_ins()\n");
515 /* end of ppa_io.h */
516 static inline void ppa_d_pulse(unsigned short ppb, unsigned char b)
526 static void ppa_disconnect(int host_no)
528 unsigned short ppb = PPA_BASE(host_no);
531 ppa_d_pulse(ppb, 0x3c);
532 ppa_d_pulse(ppb, 0x20);
533 ppa_d_pulse(ppb, 0xf);
536 static inline void ppa_c_pulse(unsigned short ppb, unsigned char b)
545 static inline void ppa_connect(int host_no, int flag)
547 unsigned short ppb = PPA_BASE(host_no);
550 ppa_c_pulse(ppb, 0x3c);
551 ppa_c_pulse(ppb, 0x20);
552 if ((flag == CONNECT_EPP_MAYBE) &&
553 IN_EPP_MODE(ppa_hosts[host_no].mode))
554 ppa_c_pulse(ppb, 0xcf);
556 ppa_c_pulse(ppb, 0x8f);
559 static int ppa_select(int host_no, int target)
562 unsigned short ppb = PPA_BASE(host_no);
565 * Bit 6 (0x40) is the device selected bit.
566 * First we must wait till the current device goes off line...
572 } while ((r_str(ppb) & 0x40) && (k));
576 w_dtr(ppb, (1 << target));
579 w_dtr(ppb, 0x80); /* This is NOT the initator */
587 while (!(r_str(ppb) & 0x40) && (k));
595 * This is based on a trace of what the Iomega DOS 'guest' driver does.
596 * I've tried several different kinds of parallel ports with guest and
597 * coded this to react in the same ways that it does.
599 * The return value from this function is just a hint about where the
600 * handshaking failed.
603 static int ppa_init(int host_no)
606 unsigned short ppb = PPA_BASE(host_no);
608 #if defined(CONFIG_PARPORT) || defined(CONFIG_PARPORT_MODULE)
609 if (ppa_pb_claim(host_no))
610 while (ppa_hosts[host_no].p_busy)
611 schedule(); /* We can safe schedule here */
614 ppa_disconnect(host_no);
615 ppa_connect(host_no, CONNECT_NORMAL);
617 retv = 2; /* Failed */
620 if ((r_str(ppb) & 0x08) == 0x08)
624 if ((r_str(ppb) & 0x08) == 0x00)
628 ppa_reset_pulse(ppb);
629 udelay(1000); /* Allow devices to settle down */
630 ppa_disconnect(host_no);
631 udelay(1000); /* Another delay to allow devices to settle */
634 retv = device_check(host_no);
636 ppa_pb_release(host_no);
640 static inline int ppa_send_command(Scsi_Cmnd * cmd)
642 int host_no = cmd->host->unique_id;
645 w_ctr(PPA_BASE(host_no), 0x0c);
647 for (k = 0; k < cmd->cmd_len; k++)
648 if (!ppa_out(host_no, &cmd->cmnd[k], 1))
654 * The bulk flag enables some optimisations in the data transfer loops,
655 * it should be true for any command that transfers data in integral
656 * numbers of sectors.
658 * The driver appears to remain stable if we speed up the parallel port
659 * i/o in this function, but not elsewhere.
661 static int ppa_completion(Scsi_Cmnd * cmd)
666 * 1 Finished data transfer
668 int host_no = cmd->host->unique_id;
669 unsigned short ppb = PPA_BASE(host_no);
670 unsigned long start_jiffies = jiffies;
673 int fast, bulk, status;
676 bulk = ((v == READ_6) ||
682 * We only get here if the drive is ready to comunicate,
683 * hence no need for a full ppa_wait.
685 r = (r_str(ppb) & 0xf0);
687 while (r != (unsigned char) 0xf0) {
689 * If we have been running for more than a full timer tick
692 if (time_after(jiffies, start_jiffies + 1))
695 if ((cmd->SCp.this_residual <= 0)) {
696 ppa_fail(host_no, DID_ERROR);
697 return -1; /* ERROR_RETURN */
700 /* On some hardware we have SCSI disconnected (6th bit low)
701 * for about 100usecs. It is too expensive to wait a
702 * tick on every loop so we busy wait for no more than
703 * 500usecs to give the drive a chance first. We do not
704 * change things for "normal" hardware since generally
705 * the 6th bit is always high.
706 * This makes the CPU load higher on some hardware
707 * but otherwise we can not get more then 50K/secs
708 * on this problem hardware.
710 if ((r & 0xc0) != 0xc0) {
711 /* Wait for reconnection should be no more than
712 * jiffy/2 = 5ms = 5000 loops
714 unsigned long k = ppa_hosts[host_no].recon_tmo;
715 for (; k && ((r = (r_str(ppb) & 0xf0)) & 0xc0) != 0xc0; k--)
722 /* determine if we should use burst I/O */
723 fast = (bulk && (cmd->SCp.this_residual >= PPA_BURST_SIZE))
724 ? PPA_BURST_SIZE : 1;
726 if (r == (unsigned char) 0xc0)
727 status = ppa_out(host_no, cmd->SCp.ptr, fast);
729 status = ppa_in(host_no, cmd->SCp.ptr, fast);
731 cmd->SCp.ptr += fast;
732 cmd->SCp.this_residual -= fast;
735 ppa_fail(host_no, DID_BUS_BUSY);
736 return -1; /* ERROR_RETURN */
738 if (cmd->SCp.buffer && !cmd->SCp.this_residual) {
739 /* if scatter/gather, advance to the next segment */
740 if (cmd->SCp.buffers_residual--) {
742 cmd->SCp.this_residual = cmd->SCp.buffer->length;
743 cmd->SCp.ptr = cmd->SCp.buffer->address;
746 /* Now check to see if the drive is ready to comunicate */
747 r = (r_str(ppb) & 0xf0);
748 /* If not, drop back down to the scheduler and wait a timer tick */
752 return 1; /* FINISH_RETURN */
755 /* deprecated synchronous interface */
756 int ppa_command(Scsi_Cmnd * cmd)
758 static int first_pass = 1;
759 int host_no = cmd->host->unique_id;
762 printk("ppa: using non-queuing interface\n");
765 if (ppa_hosts[host_no].cur_cmd) {
766 printk("PPA: bug in ppa_command\n");
769 ppa_hosts[host_no].failed = 0;
770 ppa_hosts[host_no].jstart = jiffies;
771 ppa_hosts[host_no].cur_cmd = cmd;
772 cmd->result = DID_ERROR << 16; /* default return code */
775 ppa_pb_claim(host_no);
777 while (ppa_engine(&ppa_hosts[host_no], cmd))
780 if (cmd->SCp.phase) /* Only disconnect if we have connected */
781 ppa_disconnect(cmd->host->unique_id);
783 ppa_pb_release(host_no);
784 ppa_hosts[host_no].cur_cmd = 0;
789 * Since the PPA itself doesn't generate interrupts, we use
790 * the scheduler's task queue to generate a stream of call-backs and
791 * complete the request when the drive is ready.
793 static void ppa_interrupt(void *data)
795 ppa_struct *tmp = (ppa_struct *) data;
796 Scsi_Cmnd *cmd = tmp->cur_cmd;
800 printk("PPA: bug in ppa_interrupt\n");
803 if (ppa_engine(tmp, cmd)) {
804 tmp->ppa_tq.data = (void *) tmp;
805 tmp->ppa_tq.sync = 0;
806 queue_task(&tmp->ppa_tq, &tq_timer);
809 /* Command must of completed hence it is safe to let go... */
811 switch ((cmd->result >> 16) & 0xff) {
815 printk("ppa: no device at SCSI ID %i\n", cmd->target);
818 printk("ppa: BUS BUSY - EPP timeout detected\n");
821 printk("ppa: unknown timeout\n");
824 printk("ppa: told to abort\n");
827 printk("ppa: parity error (???)\n");
830 printk("ppa: internal driver error\n");
833 printk("ppa: told to reset device\n");
836 printk("ppa: bad interrupt (???)\n");
839 printk("ppa: bad return code (%02x)\n", (cmd->result >> 16) & 0xff);
843 if (cmd->SCp.phase > 1)
844 ppa_disconnect(cmd->host->unique_id);
845 if (cmd->SCp.phase > 0)
846 ppa_pb_release(cmd->host->unique_id);
850 spin_lock_irqsave(&io_request_lock, flags);
852 spin_unlock_irqrestore(&io_request_lock, flags);
856 static int ppa_engine(ppa_struct * tmp, Scsi_Cmnd * cmd)
858 int host_no = cmd->host->unique_id;
859 unsigned short ppb = PPA_BASE(host_no);
860 unsigned char l = 0, h = 0;
863 /* First check for any errors that may of occurred
864 * Here we check for internal errors
869 switch (cmd->SCp.phase) {
870 case 0: /* Phase 0 - Waiting for parport */
871 if ((jiffies - tmp->jstart) > HZ) {
873 * We waited more than a second
874 * for parport to call us
876 ppa_fail(host_no, DID_BUS_BUSY);
879 return 1; /* wait until ppa_wakeup claims parport */
880 case 1: /* Phase 1 - Connected */
881 { /* Perform a sanity check for cable unplugged */
882 int retv = 2; /* Failed */
884 ppa_connect(host_no, CONNECT_EPP_MAYBE);
887 if ((r_str(ppb) & 0x08) == 0x08)
891 if ((r_str(ppb) & 0x08) == 0x00)
895 if ((jiffies - tmp->jstart) > (1 * HZ)) {
896 printk("ppa: Parallel port cable is unplugged!!\n");
897 ppa_fail(host_no, DID_BUS_BUSY);
900 ppa_disconnect(host_no);
901 return 1; /* Try again in a jiffy */
907 case 2: /* Phase 2 - We are now talking to the scsi bus */
908 if (!ppa_select(host_no, cmd->target)) {
909 ppa_fail(host_no, DID_NO_CONNECT);
914 case 3: /* Phase 3 - Ready to accept a command */
916 if (!(r_str(ppb) & 0x80))
919 if (!ppa_send_command(cmd))
923 case 4: /* Phase 4 - Setup scatter/gather buffers */
925 /* if many buffers are available, start filling the first */
926 cmd->SCp.buffer = (struct scatterlist *) cmd->request_buffer;
927 cmd->SCp.this_residual = cmd->SCp.buffer->length;
928 cmd->SCp.ptr = cmd->SCp.buffer->address;
930 /* else fill the only available buffer */
931 cmd->SCp.buffer = NULL;
932 cmd->SCp.this_residual = cmd->request_bufflen;
933 cmd->SCp.ptr = cmd->request_buffer;
935 cmd->SCp.buffers_residual = cmd->use_sg;
938 case 5: /* Phase 5 - Data transfer stage */
940 if (!(r_str(ppb) & 0x80))
943 retv = ppa_completion(cmd);
950 case 6: /* Phase 6 - Read status/message */
951 cmd->result = DID_OK << 16;
952 /* Check for data overrun */
953 if (ppa_wait(host_no) != (unsigned char) 0xf0) {
954 ppa_fail(host_no, DID_ERROR);
957 if (ppa_in(host_no, &l, 1)) { /* read status byte */
958 /* Check for optional message byte */
959 if (ppa_wait(host_no) == (unsigned char) 0xf0)
960 ppa_in(host_no, &h, 1);
961 cmd->result = (DID_OK << 16) + (h << 8) + (l & STATUS_MASK);
963 return 0; /* Finished */
967 printk("ppa: Invalid scsi phase\n");
972 int ppa_queuecommand(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
974 int host_no = cmd->host->unique_id;
976 if (ppa_hosts[host_no].cur_cmd) {
977 printk("PPA: bug in ppa_queuecommand\n");
980 ppa_hosts[host_no].failed = 0;
981 ppa_hosts[host_no].jstart = jiffies;
982 ppa_hosts[host_no].cur_cmd = cmd;
983 cmd->scsi_done = done;
984 cmd->result = DID_ERROR << 16; /* default return code */
985 cmd->SCp.phase = 0; /* bus free */
987 ppa_pb_claim(host_no);
989 ppa_hosts[host_no].ppa_tq.data = ppa_hosts + host_no;
990 ppa_hosts[host_no].ppa_tq.sync = 0;
991 queue_task(&ppa_hosts[host_no].ppa_tq, &tq_immediate);
992 mark_bh(IMMEDIATE_BH);
998 * Apparently the disk->capacity attribute is off by 1 sector
999 * for all disk drives. We add the one here, but it should really
1000 * be done in sd.c. Even if it gets fixed there, this will still
1003 int ppa_biosparam(Disk * disk, kdev_t dev, int ip[])
1007 ip[2] = (disk->capacity + 1) / (ip[0] * ip[1]);
1011 ip[2] = (disk->capacity + 1) / (ip[0] * ip[1]);
1018 int ppa_abort(Scsi_Cmnd * cmd)
1020 int host_no = cmd->host->unique_id;
1022 * There is no method for aborting commands since Iomega
1023 * have tied the SCSI_MESSAGE line high in the interface
1026 switch (cmd->SCp.phase) {
1027 case 0: /* Do not have access to parport */
1028 case 1: /* Have not connected to interface */
1029 ppa_hosts[host_no].cur_cmd = NULL; /* Forget the problem */
1032 default: /* SCSI command sent, can not abort */
1038 static void ppa_reset_pulse(unsigned int base)
1046 int ppa_reset(Scsi_Cmnd * cmd)
1048 int host_no = cmd->host->unique_id;
1051 ppa_disconnect(host_no);
1052 ppa_hosts[host_no].cur_cmd = NULL; /* Forget the problem */
1054 ppa_connect(host_no, CONNECT_NORMAL);
1055 ppa_reset_pulse(PPA_BASE(host_no));
1056 udelay(1000); /* device settle delay */
1057 ppa_disconnect(host_no);
1058 udelay(1000); /* device settle delay */
1062 static int device_check(int host_no)
1064 /* This routine looks for a device and then attempts to use EPP
1065 to send a command. If all goes as planned then EPP is available. */
1067 static char cmd[6] =
1068 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1069 int loop, old_mode, status, k, ppb = PPA_BASE(host_no);
1072 old_mode = ppa_hosts[host_no].mode;
1073 for (loop = 0; loop < 8; loop++) {
1074 /* Attempt to use EPP for Test Unit Ready */
1075 if ((ppb & 0x0007) == 0x0000)
1076 ppa_hosts[host_no].mode = PPA_EPP_32;
1079 ppa_connect(host_no, CONNECT_EPP_MAYBE);
1080 /* Select SCSI device */
1081 if (!ppa_select(host_no, loop)) {
1082 ppa_disconnect(host_no);
1085 printk("ppa: Found device at ID %i, Attempting to use %s\n", loop,
1086 PPA_MODE_STRING[ppa_hosts[host_no].mode]);
1088 /* Send SCSI command */
1091 for (l = 0; (l < 6) && (status); l++)
1092 status = ppa_out(host_no, cmd, 1);
1095 ppa_disconnect(host_no);
1096 ppa_connect(host_no, CONNECT_EPP_MAYBE);
1102 ppa_disconnect(host_no);
1104 if (ppa_hosts[host_no].mode == PPA_EPP_32) {
1105 ppa_hosts[host_no].mode = old_mode;
1108 printk("ppa: Unable to establish communication, aborting driver load.\n");
1112 k = 1000000; /* 1 Second */
1117 } while (!(l & 0x80) && (k));
1122 ppa_disconnect(host_no);
1123 ppa_connect(host_no, CONNECT_EPP_MAYBE);
1124 ppa_reset_pulse(ppb);
1126 ppa_disconnect(host_no);
1128 if (ppa_hosts[host_no].mode == PPA_EPP_32) {
1129 ppa_hosts[host_no].mode = old_mode;
1132 printk("ppa: Unable to establish communication, aborting driver load.\n");
1135 ppa_disconnect(host_no);
1136 printk("ppa: Communication established with ID %i using %s\n", loop,
1137 PPA_MODE_STRING[ppa_hosts[host_no].mode]);
1138 ppa_connect(host_no, CONNECT_EPP_MAYBE);
1139 ppa_reset_pulse(ppb);
1141 ppa_disconnect(host_no);
1145 printk("ppa: No devices found, aborting driver load.\n");
1148 MODULE_LICENSE("GPL");