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 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 interupt stuff */
33 unsigned long jstart
; /* Jiffies at start */
34 unsigned int failed
:1; /* Failure flag */
35 unsigned int p_busy
:1; /* Parport sharing busy flag */
41 mode: PPA_AUTODETECT, \
44 ppa_tq: {0, 0, ppa_interrupt, NULL}, \
51 #include <linux/parport.h>
54 static ppa_struct ppa_hosts
[NO_HOSTS
] =
55 {PPA_EMPTY
, PPA_EMPTY
, PPA_EMPTY
, PPA_EMPTY
};
57 #define PPA_BASE(x) ppa_hosts[(x)].base
59 void ppa_wakeup(void *ref
)
61 ppa_struct
*ppa_dev
= (ppa_struct
*) ref
;
66 if (parport_claim(ppa_dev
->dev
)) {
67 printk("ppa: bug in ppa_wakeup\n");
71 ppa_dev
->base
= ppa_dev
->dev
->port
->base
;
73 ppa_dev
->cur_cmd
->SCp
.phase
++;
77 int ppa_release(struct Scsi_Host
*host
)
79 int host_no
= host
->unique_id
;
81 printk("Releasing ppa%i\n", host_no
);
82 parport_unregister_device(ppa_hosts
[host_no
].dev
);
86 static int ppa_pb_claim(int host_no
)
88 if (parport_claim(ppa_hosts
[host_no
].dev
)) {
89 ppa_hosts
[host_no
].p_busy
= 1;
92 if (ppa_hosts
[host_no
].cur_cmd
)
93 ppa_hosts
[host_no
].cur_cmd
->SCp
.phase
++;
97 #define ppa_pb_release(x) parport_release(ppa_hosts[(x)].dev)
99 /***************************************************************************
100 * Parallel port probing routines *
101 ***************************************************************************/
104 Scsi_Host_Template driver_template
= PPA
;
105 #include "scsi_module.c"
109 * Start of Chipset kludges
112 int ppa_detect(Scsi_Host_Template
* host
)
114 struct Scsi_Host
*hreg
;
116 int i
, nhosts
, try_again
;
117 struct parport
*pb
= parport_enumerate();
119 printk("ppa: Version %s\n", PPA_VERSION
);
124 printk("ppa: parport reports no devices.\n");
128 for (i
= 0; pb
; i
++, pb
= pb
->next
) {
132 parport_register_device(pb
, "ppa", NULL
, ppa_wakeup
,
133 NULL
, 0, (void *) &ppa_hosts
[i
]);
135 if (!ppa_hosts
[i
].dev
)
138 /* Claim the bus so it remembers what we do to the control
139 * registers. [ CTR and ECP ]
141 if (ppa_pb_claim(i
)) {
142 unsigned long now
= jiffies
;
143 while (ppa_hosts
[i
].p_busy
) {
144 schedule(); /* We are safe to schedule here */
145 if (time_after(jiffies
, now
+ 3 * HZ
)) {
146 printk(KERN_ERR
"ppa%d: failed to claim parport because a "
147 "pardevice is owning the port for too longtime!\n",
153 ppb
= PPA_BASE(i
) = ppa_hosts
[i
].dev
->port
->base
;
155 modes
= ppa_hosts
[i
].dev
->port
->modes
;
157 /* Mode detection works up the chain of speed
158 * This avoids a nasty if-then-else-if-... tree
160 ppa_hosts
[i
].mode
= PPA_NIBBLE
;
162 if (modes
& PARPORT_MODE_PCPS2
)
163 ppa_hosts
[i
].mode
= PPA_PS2
;
165 if (modes
& PARPORT_MODE_PCECPPS2
) {
167 ppa_hosts
[i
].mode
= PPA_PS2
;
169 if (modes
& PARPORT_MODE_PCECPEPP
)
172 /* Done configuration */
176 parport_unregister_device(ppa_hosts
[i
].dev
);
179 /* now the glue ... */
180 switch (ppa_hosts
[i
].mode
) {
192 default: /* Never gets here */
196 host
->can_queue
= PPA_CAN_QUEUE
;
197 host
->sg_tablesize
= ppa_sg
;
198 hreg
= scsi_register(host
, 0);
199 hreg
->io_port
= pb
->base
;
200 hreg
->n_io_port
= ports
;
201 hreg
->dma_channel
= -1;
203 ppa_hosts
[i
].host
= hreg
->host_no
;
207 if (try_again
== 1) {
208 printk("WARNING - no ppa compatible devices found.\n");
209 printk(" As of 31/Aug/1998 Iomega started shipping parallel\n");
210 printk(" port ZIP drives with a different interface which is\n");
211 printk(" supported by the imm (ZIP Plus) driver. If the\n");
212 printk(" cable is marked with \"AutoDetect\", this is what has\n");
213 printk(" happened.\n");
219 return 1; /* return number of hosts detected */
222 /* This is to give the ppa driver a way to modify the timings (and other
223 * parameters) by writing to the /proc/scsi/ppa/0 file.
224 * Very simple method really... (To simple, no error checking :( )
225 * Reason: Kernel hackers HATE having to unload and reload modules for
227 * Also gives a method to use a script to obtain optimum timings (TODO)
230 static inline int ppa_proc_write(int hostno
, char *buffer
, int length
)
234 if ((length
> 5) && (strncmp(buffer
, "mode=", 5) == 0)) {
235 x
= simple_strtoul(buffer
+ 5, NULL
, 0);
236 ppa_hosts
[hostno
].mode
= x
;
239 printk("ppa /proc: invalid variable\n");
243 int ppa_proc_info(char *buffer
, char **start
, off_t offset
,
244 int length
, int hostno
, int inout
)
249 for (i
= 0; i
< 4; i
++)
250 if (ppa_hosts
[i
].host
== hostno
)
254 return ppa_proc_write(i
, buffer
, length
);
256 len
+= sprintf(buffer
+ len
, "Version : %s\n", PPA_VERSION
);
257 len
+= sprintf(buffer
+ len
, "Parport : %s\n", ppa_hosts
[i
].dev
->port
->name
);
258 len
+= sprintf(buffer
+ len
, "Mode : %s\n", PPA_MODE_STRING
[ppa_hosts
[i
].mode
]);
260 /* Request for beyond end of buffer */
264 *start
= buffer
+ offset
;
271 static int device_check(int host_no
);
274 #define ppa_fail(x,y) printk("ppa: ppa_fail(%i) from %s at line %d\n",\
275 y, __FUNCTION__, __LINE__); ppa_fail_func(x,y);
276 static inline void ppa_fail_func(int host_no
, int error_code
)
278 static inline void ppa_fail(int host_no
, int error_code
)
281 /* If we fail a device then we trash status / message bytes */
282 if (ppa_hosts
[host_no
].cur_cmd
) {
283 ppa_hosts
[host_no
].cur_cmd
->result
= error_code
<< 16;
284 ppa_hosts
[host_no
].failed
= 1;
289 * Wait for the high bit to be set.
291 * In principle, this could be tied to an interrupt, but the adapter
292 * doesn't appear to be designed to support interrupts. We spin on
293 * the 0x80 ready bit.
295 static unsigned char ppa_wait(int host_no
)
298 unsigned short ppb
= PPA_BASE(host_no
);
307 while (!(r
& 0x80) && (k
));
310 * return some status information.
311 * Semantics: 0xc0 = ZIP wants more data
312 * 0xd0 = ZIP wants to send more data
313 * 0xe0 = ZIP is expecting SCSI command data
314 * 0xf0 = end of transfer, ZIP is sending status
319 /* Counter expired - Time out occured */
320 ppa_fail(host_no
, DID_TIME_OUT
);
321 printk("ppa timeout in ppa_wait\n");
322 return 0; /* command timed out */
326 * output a string, in whatever mode is available, according to the
329 static inline void epp_reset(unsigned short ppb
)
335 w_str(ppb
, i
& 0xfe);
338 static inline void ecp_sync(unsigned short ppb
)
342 if ((r_ecr(ppb
) & 0xe0) != 0x80)
345 for (i
= 0; i
< 100; i
++) {
346 if (r_ecr(ppb
) & 0x01)
350 printk("ppa: ECP sync failed as data still present in FIFO.\n");
353 static int ppa_byte_out(unsigned short base
, const char *buffer
, int len
)
357 for (i
= len
; i
; i
--) {
358 w_dtr(base
, *buffer
++);
362 return 1; /* All went well - we hope! */
365 static int ppa_byte_in(unsigned short base
, char *buffer
, int len
)
369 for (i
= len
; i
; i
--) {
370 *buffer
++ = r_dtr(base
);
374 return 1; /* All went well - we hope! */
377 static int ppa_nibble_in(unsigned short base
, char *buffer
, int len
)
383 h
= r_str(base
) & 0xf0;
385 *buffer
++ = h
| ((r_str(base
) & 0xf0) >> 4);
387 return 1; /* All went well - we hope! */
390 static int ppa_out(int host_no
, char *buffer
, int len
)
393 unsigned short ppb
= PPA_BASE(host_no
);
395 r
= ppa_wait(host_no
);
397 if ((r
& 0x50) != 0x40) {
398 ppa_fail(host_no
, DID_ERROR
);
401 switch (ppa_hosts
[host_no
].mode
) {
404 /* 8 bit output, with a loop */
405 r
= ppa_byte_out(ppb
, buffer
, len
);
413 #ifdef CONFIG_SCSI_IZIP_EPP16
414 if (!(((long) buffer
| len
) & 0x01))
415 outsw(ppb
+ 4, buffer
, len
>> 1);
417 if (!(((long) buffer
| len
) & 0x03))
418 outsl(ppb
+ 4, buffer
, len
>> 2);
421 outsb(ppb
+ 4, buffer
, len
);
423 r
= !(r_str(ppb
) & 0x01);
429 printk("PPA: bug in ppa_out()\n");
435 static int ppa_in(int host_no
, char *buffer
, int len
)
438 unsigned short ppb
= PPA_BASE(host_no
);
440 r
= ppa_wait(host_no
);
442 if ((r
& 0x50) != 0x50) {
443 ppa_fail(host_no
, DID_ERROR
);
446 switch (ppa_hosts
[host_no
].mode
) {
448 /* 4 bit input, with a loop */
449 r
= ppa_nibble_in(ppb
, buffer
, len
);
454 /* 8 bit input, with a loop */
456 r
= ppa_byte_in(ppb
, buffer
, len
);
466 #ifdef CONFIG_SCSI_IZIP_EPP16
467 if (!(((long) buffer
| len
) & 0x01))
468 insw(ppb
+ 4, buffer
, len
>> 1);
470 if (!(((long) buffer
| len
) & 0x03))
471 insl(ppb
+ 4, buffer
, len
>> 2);
474 insb(ppb
+ 4, buffer
, len
);
476 r
= !(r_str(ppb
) & 0x01);
482 printk("PPA: bug in ppa_ins()\n");
489 /* end of ppa_io.h */
490 static inline void ppa_d_pulse(unsigned short ppb
, unsigned char b
)
500 static void ppa_disconnect(int host_no
)
502 unsigned short ppb
= PPA_BASE(host_no
);
505 ppa_d_pulse(ppb
, 0x3c);
506 ppa_d_pulse(ppb
, 0x20);
507 ppa_d_pulse(ppb
, 0xf);
510 static inline void ppa_c_pulse(unsigned short ppb
, unsigned char b
)
519 static inline void ppa_connect(int host_no
, int flag
)
521 unsigned short ppb
= PPA_BASE(host_no
);
524 ppa_c_pulse(ppb
, 0x3c);
525 ppa_c_pulse(ppb
, 0x20);
526 if ((flag
== CONNECT_EPP_MAYBE
) &&
527 IN_EPP_MODE(ppa_hosts
[host_no
].mode
))
528 ppa_c_pulse(ppb
, 0xcf);
530 ppa_c_pulse(ppb
, 0x8f);
533 static int ppa_select(int host_no
, int target
)
536 unsigned short ppb
= PPA_BASE(host_no
);
539 * Bit 6 (0x40) is the device selected bit.
540 * First we must wait till the current device goes off line...
545 } while ((r_str(ppb
) & 0x40) && (k
));
549 w_dtr(ppb
, (1 << target
));
552 w_dtr(ppb
, 0x80); /* This is NOT the initator */
559 while (!(r_str(ppb
) & 0x40) && (k
));
567 * This is based on a trace of what the Iomega DOS 'guest' driver does.
568 * I've tried several different kinds of parallel ports with guest and
569 * coded this to react in the same ways that it does.
571 * The return value from this function is just a hint about where the
572 * handshaking failed.
575 static int ppa_init(int host_no
)
578 unsigned short ppb
= PPA_BASE(host_no
);
580 #if defined(CONFIG_PARPORT) || defined(CONFIG_PARPORT_MODULE)
581 if (ppa_pb_claim(host_no
))
582 while (ppa_hosts
[host_no
].p_busy
)
583 schedule(); /* We can safe schedule here */
586 ppa_disconnect(host_no
);
587 ppa_connect(host_no
, CONNECT_NORMAL
);
589 retv
= 2; /* Failed */
592 if ((r_str(ppb
) & 0x08) == 0x08)
596 if ((r_str(ppb
) & 0x08) == 0x00)
600 ppa_reset_pulse(ppb
);
601 udelay(1000); /* Allow devices to settle down */
602 ppa_disconnect(host_no
);
603 udelay(1000); /* Another delay to allow devices to settle */
606 retv
= device_check(host_no
);
608 ppa_pb_release(host_no
);
612 static inline int ppa_send_command(Scsi_Cmnd
* cmd
)
614 int host_no
= cmd
->host
->unique_id
;
617 w_ctr(PPA_BASE(host_no
), 0x0c);
619 for (k
= 0; k
< cmd
->cmd_len
; k
++)
620 if (!ppa_out(host_no
, &cmd
->cmnd
[k
], 1))
626 * The bulk flag enables some optimisations in the data transfer loops,
627 * it should be true for any command that transfers data in integral
628 * numbers of sectors.
630 * The driver appears to remain stable if we speed up the parallel port
631 * i/o in this function, but not elsewhere.
633 static int ppa_completion(Scsi_Cmnd
* cmd
)
638 * 1 Finished data transfer
640 int host_no
= cmd
->host
->unique_id
;
641 unsigned short ppb
= PPA_BASE(host_no
);
642 unsigned long start_jiffies
= jiffies
;
645 int fast
, bulk
, status
;
648 bulk
= ((v
== READ_6
) ||
654 * We only get here if the drive is ready to comunicate,
655 * hence no need for a full ppa_wait.
657 r
= (r_str(ppb
) & 0xf0);
659 while (r
!= (unsigned char) 0xf0) {
661 * If we have been running for more than a full timer tick
664 if (time_after(jiffies
, start_jiffies
+ 1))
667 if (((r
& 0xc0) != 0xc0) || (cmd
->SCp
.this_residual
<= 0)) {
668 ppa_fail(host_no
, DID_ERROR
);
669 return -1; /* ERROR_RETURN */
671 /* determine if we should use burst I/O */ fast
= (bulk
&& (cmd
->SCp
.this_residual
>= PPA_BURST_SIZE
))
672 ? PPA_BURST_SIZE
: 1;
674 if (r
== (unsigned char) 0xc0)
675 status
= ppa_out(host_no
, cmd
->SCp
.ptr
, fast
);
677 status
= ppa_in(host_no
, cmd
->SCp
.ptr
, fast
);
679 cmd
->SCp
.ptr
+= fast
;
680 cmd
->SCp
.this_residual
-= fast
;
683 ppa_fail(host_no
, DID_BUS_BUSY
);
684 return -1; /* ERROR_RETURN */
686 if (cmd
->SCp
.buffer
&& !cmd
->SCp
.this_residual
) {
687 /* if scatter/gather, advance to the next segment */
688 if (cmd
->SCp
.buffers_residual
--) {
690 cmd
->SCp
.this_residual
= cmd
->SCp
.buffer
->length
;
691 cmd
->SCp
.ptr
= cmd
->SCp
.buffer
->address
;
694 /* Now check to see if the drive is ready to comunicate */
695 r
= (r_str(ppb
) & 0xf0);
696 /* If not, drop back down to the scheduler and wait a timer tick */
700 return 1; /* FINISH_RETURN */
703 /* deprecated synchronous interface */
704 int ppa_command(Scsi_Cmnd
* cmd
)
706 static int first_pass
= 1;
707 int host_no
= cmd
->host
->unique_id
;
710 printk("ppa: using non-queuing interface\n");
713 if (ppa_hosts
[host_no
].cur_cmd
) {
714 printk("PPA: bug in ppa_command\n");
717 ppa_hosts
[host_no
].failed
= 0;
718 ppa_hosts
[host_no
].jstart
= jiffies
;
719 ppa_hosts
[host_no
].cur_cmd
= cmd
;
720 cmd
->result
= DID_ERROR
<< 16; /* default return code */
723 ppa_pb_claim(host_no
);
725 while (ppa_engine(&ppa_hosts
[host_no
], cmd
))
728 if (cmd
->SCp
.phase
) /* Only disconnect if we have connected */
729 ppa_disconnect(cmd
->host
->unique_id
);
731 ppa_pb_release(host_no
);
732 ppa_hosts
[host_no
].cur_cmd
= 0;
737 * Since the PPA itself doesn't generate interrupts, we use
738 * the scheduler's task queue to generate a stream of call-backs and
739 * complete the request when the drive is ready.
741 static void ppa_interrupt(void *data
)
743 ppa_struct
*tmp
= (ppa_struct
*) data
;
744 Scsi_Cmnd
*cmd
= tmp
->cur_cmd
;
747 printk("PPA: bug in ppa_interrupt\n");
750 if (ppa_engine(tmp
, cmd
)) {
751 tmp
->ppa_tq
.data
= (void *) tmp
;
752 tmp
->ppa_tq
.sync
= 0;
753 queue_task(&tmp
->ppa_tq
, &tq_timer
);
756 /* Command must of completed hence it is safe to let go... */
758 switch ((cmd
->result
>> 16) & 0xff) {
762 printk("ppa: no device at SCSI ID %i\n", cmd
->target
);
765 printk("ppa: BUS BUSY - EPP timeout detected\n");
768 printk("ppa: unknown timeout\n");
771 printk("ppa: told to abort\n");
774 printk("ppa: parity error (???)\n");
777 printk("ppa: internal driver error\n");
780 printk("ppa: told to reset device\n");
783 printk("ppa: bad interrupt (???)\n");
786 printk("ppa: bad return code (%02x)\n", (cmd
->result
>> 16) & 0xff);
790 if (cmd
->SCp
.phase
> 1)
791 ppa_disconnect(cmd
->host
->unique_id
);
792 if (cmd
->SCp
.phase
> 0)
793 ppa_pb_release(cmd
->host
->unique_id
);
800 static int ppa_engine(ppa_struct
* tmp
, Scsi_Cmnd
* cmd
)
802 int host_no
= cmd
->host
->unique_id
;
803 unsigned short ppb
= PPA_BASE(host_no
);
804 unsigned char l
= 0, h
= 0;
807 /* First check for any errors that may of occured
808 * Here we check for internal errors
813 switch (cmd
->SCp
.phase
) {
814 case 0: /* Phase 0 - Waiting for parport */
815 if ((jiffies
- tmp
->jstart
) > HZ
) {
817 * We waited more than a second
818 * for parport to call us
820 ppa_fail(host_no
, DID_BUS_BUSY
);
823 return 1; /* wait until ppa_wakeup claims parport */
824 case 1: /* Phase 1 - Connected */
825 { /* Perform a sanity check for cable unplugged */
826 int retv
= 2; /* Failed */
828 ppa_connect(host_no
, CONNECT_EPP_MAYBE
);
831 if ((r_str(ppb
) & 0x08) == 0x08)
835 if ((r_str(ppb
) & 0x08) == 0x00)
839 if ((jiffies
- tmp
->jstart
) > (1 * HZ
)) {
840 printk("ppa: Parallel port cable is unplugged!!\n");
841 ppa_fail(host_no
, DID_BUS_BUSY
);
844 ppa_disconnect(host_no
);
845 return 1; /* Try again in a jiffy */
851 case 2: /* Phase 2 - We are now talking to the scsi bus */
852 if (!ppa_select(host_no
, cmd
->target
)) {
853 ppa_fail(host_no
, DID_NO_CONNECT
);
858 case 3: /* Phase 3 - Ready to accept a command */
860 if (!(r_str(ppb
) & 0x80))
863 if (!ppa_send_command(cmd
))
867 case 4: /* Phase 4 - Setup scatter/gather buffers */
869 /* if many buffers are available, start filling the first */
870 cmd
->SCp
.buffer
= (struct scatterlist
*) cmd
->request_buffer
;
871 cmd
->SCp
.this_residual
= cmd
->SCp
.buffer
->length
;
872 cmd
->SCp
.ptr
= cmd
->SCp
.buffer
->address
;
874 /* else fill the only available buffer */
875 cmd
->SCp
.buffer
= NULL
;
876 cmd
->SCp
.this_residual
= cmd
->request_bufflen
;
877 cmd
->SCp
.ptr
= cmd
->request_buffer
;
879 cmd
->SCp
.buffers_residual
= cmd
->use_sg
;
882 case 5: /* Phase 5 - Data transfer stage */
884 if (!(r_str(ppb
) & 0x80))
887 retv
= ppa_completion(cmd
);
894 case 6: /* Phase 6 - Read status/message */
895 cmd
->result
= DID_OK
<< 16;
896 /* Check for data overrun */
897 if (ppa_wait(host_no
) != (unsigned char) 0xf0) {
898 ppa_fail(host_no
, DID_ERROR
);
901 if (ppa_in(host_no
, &l
, 1)) { /* read status byte */
902 /* Check for optional message byte */
903 if (ppa_wait(host_no
) == (unsigned char) 0xf0)
904 ppa_in(host_no
, &h
, 1);
905 cmd
->result
= (DID_OK
<< 16) + (h
<< 8) + (l
& STATUS_MASK
);
907 return 0; /* Finished */
911 printk("ppa: Invalid scsi phase\n");
916 int ppa_queuecommand(Scsi_Cmnd
* cmd
, void (*done
) (Scsi_Cmnd
*))
918 int host_no
= cmd
->host
->unique_id
;
920 if (ppa_hosts
[host_no
].cur_cmd
) {
921 printk("PPA: bug in ppa_queuecommand\n");
924 ppa_hosts
[host_no
].failed
= 0;
925 ppa_hosts
[host_no
].jstart
= jiffies
;
926 ppa_hosts
[host_no
].cur_cmd
= cmd
;
927 cmd
->scsi_done
= done
;
928 cmd
->result
= DID_ERROR
<< 16; /* default return code */
929 cmd
->SCp
.phase
= 0; /* bus free */
931 ppa_pb_claim(host_no
);
933 ppa_hosts
[host_no
].ppa_tq
.data
= ppa_hosts
+ host_no
;
934 ppa_hosts
[host_no
].ppa_tq
.sync
= 0;
935 queue_task(&ppa_hosts
[host_no
].ppa_tq
, &tq_immediate
);
936 mark_bh(IMMEDIATE_BH
);
942 * Apparently the the disk->capacity attribute is off by 1 sector
943 * for all disk drives. We add the one here, but it should really
944 * be done in sd.c. Even if it gets fixed there, this will still
947 int ppa_biosparam(Disk
* disk
, kdev_t dev
, int ip
[])
951 ip
[2] = (disk
->capacity
+ 1) / (ip
[0] * ip
[1]);
955 ip
[2] = (disk
->capacity
+ 1) / (ip
[0] * ip
[1]);
962 int ppa_abort(Scsi_Cmnd
* cmd
)
964 int host_no
= cmd
->host
->unique_id
;
966 * There is no method for aborting commands since Iomega
967 * have tied the SCSI_MESSAGE line high in the interface
970 switch (cmd
->SCp
.phase
) {
971 case 0: /* Do not have access to parport */
972 case 1: /* Have not connected to interface */
973 ppa_hosts
[host_no
].cur_cmd
= NULL
; /* Forget the problem */
976 default: /* SCSI command sent, can not abort */
982 static void ppa_reset_pulse(unsigned int base
)
990 int ppa_reset(Scsi_Cmnd
* cmd
)
992 int host_no
= cmd
->host
->unique_id
;
995 ppa_disconnect(host_no
);
996 ppa_hosts
[host_no
].cur_cmd
= NULL
; /* Forget the problem */
998 ppa_connect(host_no
, CONNECT_NORMAL
);
999 ppa_reset_pulse(PPA_BASE(host_no
));
1000 udelay(1000); /* device settle delay */
1001 ppa_disconnect(host_no
);
1002 udelay(1000); /* device settle delay */
1006 static int device_check(int host_no
)
1008 /* This routine looks for a device and then attempts to use EPP
1009 to send a command. If all goes as planned then EPP is available. */
1011 static char cmd
[6] =
1012 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1013 int loop
, old_mode
, status
, k
, ppb
= PPA_BASE(host_no
);
1016 old_mode
= ppa_hosts
[host_no
].mode
;
1017 for (loop
= 0; loop
< 8; loop
++) {
1018 /* Attempt to use EPP for Test Unit Ready */
1019 if ((ppb
& 0x0007) == 0x0000)
1020 ppa_hosts
[host_no
].mode
= PPA_EPP_32
;
1023 ppa_connect(host_no
, CONNECT_EPP_MAYBE
);
1024 /* Select SCSI device */
1025 if (!ppa_select(host_no
, loop
)) {
1026 ppa_disconnect(host_no
);
1029 printk("ppa: Found device at ID %i, Attempting to use %s\n", loop
,
1030 PPA_MODE_STRING
[ppa_hosts
[host_no
].mode
]);
1032 /* Send SCSI command */
1035 for (l
= 0; (l
< 6) && (status
); l
++)
1036 status
= ppa_out(host_no
, cmd
, 1);
1039 ppa_disconnect(host_no
);
1040 ppa_connect(host_no
, CONNECT_EPP_MAYBE
);
1046 ppa_disconnect(host_no
);
1048 if (ppa_hosts
[host_no
].mode
== PPA_EPP_32
) {
1049 ppa_hosts
[host_no
].mode
= old_mode
;
1052 printk("ppa: Unable to establish communication, aborting driver load.\n");
1056 k
= 1000000; /* 1 Second */
1061 } while (!(l
& 0x80) && (k
));
1066 ppa_disconnect(host_no
);
1067 ppa_connect(host_no
, CONNECT_EPP_MAYBE
);
1068 ppa_reset_pulse(ppb
);
1070 ppa_disconnect(host_no
);
1072 if (ppa_hosts
[host_no
].mode
== PPA_EPP_32
) {
1073 ppa_hosts
[host_no
].mode
= old_mode
;
1076 printk("ppa: Unable to establish communication, aborting driver load.\n");
1079 ppa_disconnect(host_no
);
1080 printk("ppa: Communication established with ID %i using %s\n", loop
,
1081 PPA_MODE_STRING
[ppa_hosts
[host_no
].mode
]);
1082 ppa_connect(host_no
, CONNECT_EPP_MAYBE
);
1083 ppa_reset_pulse(ppb
);
1085 ppa_disconnect(host_no
);
1089 printk("ppa: No devices found, aborting driver load.\n");