patch-2.2.0-pre4 linux/drivers/scsi/ppa.c
Next file: linux/drivers/scsi/ppa.h
Previous file: linux/drivers/scsi/imm.h
Back to the patch index
Back to the overall index
- Lines: 454
- Date:
Sat Jan 2 10:21:06 1999
- Orig file:
v2.2.0-pre3/linux/drivers/scsi/ppa.c
- Orig date:
Mon Dec 28 15:00:52 1998
diff -u --recursive --new-file v2.2.0-pre3/linux/drivers/scsi/ppa.c linux/drivers/scsi/ppa.c
@@ -7,8 +7,7 @@
* under the terms of the GNU Public License.
*
* Current Maintainer: David Campbell (Perth, Western Australia, GMT+0800)
- * campbell@gear.torque.net
- * dcampbel@p01.as17.honeywell.com.au
+ * campbell@torque.net
*/
#include <linux/config.h>
@@ -68,7 +67,6 @@
printk("ppa: bug in ppa_wakeup\n");
return;
}
-
ppa_dev->p_busy = 0;
ppa_dev->base = ppa_dev->dev->port->base;
if (ppa_dev->cur_cmd)
@@ -91,7 +89,6 @@
ppa_hosts[host_no].p_busy = 1;
return 1;
}
-
if (ppa_hosts[host_no].cur_cmd)
ppa_hosts[host_no].cur_cmd->SCp.phase++;
return 0;
@@ -133,30 +130,26 @@
ppa_hosts[i].dev =
parport_register_device(pb, "ppa", NULL, ppa_wakeup,
- NULL, 0, (void *) &ppa_hosts[i]);
+ NULL, 0, (void *) &ppa_hosts[i]);
if (!ppa_hosts[i].dev)
- continue;
+ continue;
/* Claim the bus so it remembers what we do to the control
* registers. [ CTR and ECP ]
*/
- if (ppa_pb_claim(i))
- {
+ if (ppa_pb_claim(i)) {
unsigned long now = jiffies;
- while (ppa_hosts[i].p_busy)
- {
+ while (ppa_hosts[i].p_busy) {
schedule(); /* We are safe to schedule here */
- if (time_after(jiffies,now + 3*HZ))
- {
+ if (time_after(jiffies, now + 3 * HZ)) {
printk(KERN_ERR "ppa%d: failed to claim parport because a "
- "pardevice is owning the port for too longtime!\n",
+ "pardevice is owning the port for too longtime!\n",
i);
return 0;
}
}
}
-
ppb = PPA_BASE(i) = ppa_hosts[i].dev->port->base;
w_ctr(ppb, 0x0c);
modes = ppa_hosts[i].dev->port->modes;
@@ -211,8 +204,15 @@
nhosts++;
}
if (nhosts == 0) {
- if (try_again == 1)
+ if (try_again == 1) {
+ printk("WARNING - no ppa compatible devices found.\n");
+ printk(" As of 31/Aug/1998 Iomega started shipping parallel\n");
+ printk(" port ZIP drives with a different interface which is\n");
+ printk(" supported by the imm (ZIP Plus) driver. If the\n");
+ printk(" cable is marked with \"AutoDetect\", this is what has\n");
+ printk(" happened.\n");
return 0;
+ }
try_again = 1;
goto retry_entry;
} else
@@ -227,21 +227,11 @@
* Also gives a method to use a script to obtain optimum timings (TODO)
*/
-static inline int ppa_strncmp(const char *a, const char *b, int len)
-{
- int loop;
- for (loop = 0; loop < len; loop++)
- if (a[loop] != b[loop])
- return 1;
-
- return 0;
-}
-
static inline int ppa_proc_write(int hostno, char *buffer, int length)
{
unsigned long x;
- if ((length > 5) && (ppa_strncmp(buffer, "mode=", 5) == 0)) {
+ if ((length > 5) && (strncmp(buffer, "mode=", 5) == 0)) {
x = simple_strtoul(buffer + 5, NULL, 0);
ppa_hosts[hostno].mode = x;
return length;
@@ -360,245 +350,42 @@
printk("ppa: ECP sync failed as data still present in FIFO.\n");
}
-/*
- * Here is the asm code for the SPP/PS2 protocols for the i386.
- * This has been optimised for speed on 386/486 machines. There will
- * be very little improvement on the current 586+ machines as it is the
- * IO statements which will limit throughput.
- */
-#ifdef __i386__
-#define BYTE_OUT(reg) \
- " movb " #reg ",%%al\n" \
- " outb %%al,(%%dx)\n" \
- " addl $2,%%edx\n" \
- " movb $0x0e,%%al\n" \
- " outb %%al,(%%dx)\n" \
- " movb $0x0c,%%al\n" \
- " outb %%al,(%%dx)\n" \
- " subl $2,%%edx\n"
-
-static inline int ppa_byte_out(unsigned short base, char *buffer, unsigned int len)
+static int ppa_byte_out(unsigned short base, const char *buffer, int len)
{
- /*
- * %eax scratch
- * %ebx Data to transfer
- * %ecx Counter (Don't touch!!)
- * %edx Port
- * %esi Source buffer (mem pointer)
- *
- * In case you are wondering what the last line of the asm does...
- * <output allocation> : <input allocation> : <trashed registers>
- */
- register int d0;
-
- asm("shr $2,%%ecx\n" \
- " jz .no_more_bulk_bo\n" \
- " .p2align 4,,7\n" \
- ".loop_bulk_bo:\n" \
- " movl (%%esi),%%ebx\n" \
- BYTE_OUT(%%bl) \
- BYTE_OUT(%%bh) \
- " rorl $16,%%ebx\n" \
- BYTE_OUT(%%bl) \
- BYTE_OUT(%%bh) \
- " addl $4,%%esi\n" \
- " loop .loop_bulk_bo\n" \
- " .p2align 4,,7\n" \
- ".no_more_bulk_bo:" \
- : "=S"(buffer), "=c"(d0)
- : "1"(len), "d"(base), "0"(buffer)
- : "eax", "ebx");
-
- asm("andl $3,%%ecx\n" \
- " jz .no_more_loose_bo\n" \
- " .p2align 4,,7\n" \
- ".loop_loose_bo:\n" \
- BYTE_OUT((%%esi)) \
- " incl %%esi\n" \
- " loop .loop_loose_bo\n" \
- ".no_more_loose_bo:\n" \
- : "=c"(d0)
- : "0"(len), "d"(base), "S"(buffer)
- : "eax", "ebx");
- return 1; /* All went well - we hope! */
-}
-
-#define BYTE_IN(reg) \
- " inb (%%dx),%%al\n" \
- " movb %%al," #reg "\n" \
- " addl $2,%%edx\n" \
- " movb $0x27,%%al\n" \
- " outb %%al,(%%dx)\n" \
- " movb $0x25,%%al\n" \
- " outb %%al,(%%dx)\n" \
- " subl $2,%%edx\n"
-
-static inline int ppa_byte_in(unsigned short base, char *buffer, int len)
-{
- /*
- * %eax scratch
- * %ebx Data to transfer
- * %ecx Counter (Don't touch!!)
- * %edx Port
- * %esi Source buffer (mem pointer)
- *
- * In case you are wondering what the last line of the asm does...
- * <output allocation> : <input allocation> : <trashed registers>
- */
- register int d0;
-
- asm("shr $2,%%ecx\n" \
- " jz .no_more_bulk_bi\n" \
- " .p2align 4,,7\n" \
- ".loop_bulk_bi:\n" \
- BYTE_IN(%%bl) \
- BYTE_IN(%%bh) \
- " rorl $16,%%ebx\n" \
- BYTE_IN(%%bl) \
- BYTE_IN(%%bh) \
- " rorl $16,%%ebx\n" \
- " movl %%ebx,(%%esi)\n" \
- " addl $4,%%esi\n" \
- " loop .loop_bulk_bi\n" \
- " .p2align 4,,7\n" \
- ".no_more_bulk_bi:" \
- : "=S"(buffer), "=c"(d0)
- : "1"(len), "d"(base), "0"(buffer)
- : "eax", "ebx");
-
- asm("andl $3,%%ecx\n" \
- " jz .no_more_loose_bi\n" \
- " .p2align 4,,7\n" \
- ".loop_loose_bi:\n" \
- BYTE_IN((%%esi)) \
- " incl %%esi\n" \
- " loop .loop_loose_bi\n" \
- ".no_more_loose_bi:\n" \
- : "=c"(d0)
- : "0"(len), "d"(base), "S"(buffer)
- : "eax", "ebx");
- return 1; /* All went well - we hope! */
-}
-
-#define NIBBLE_IN(reg) \
- " incl %%edx\n" \
- " movb $0x04,%%al\n" \
- " outb %%al,(%%dx)\n" \
- " decl %%edx\n" \
- " inb (%%dx),%%al\n" \
- " andb $0xf0,%%al\n" \
- " movb %%al," #reg "\n" \
- " incl %%edx\n" \
- " movb $0x06,%%al\n" \
- " outb %%al,(%%dx)\n" \
- " decl %%edx\n" \
- " inb (%%dx),%%al\n" \
- " shrb $4,%%al\n" \
- " orb %%al," #reg "\n"
-
-static inline int ppa_nibble_in(unsigned short str_p, char *buffer, int len)
-{
- /*
- * %eax scratch
- * %ebx Data to transfer
- * %ecx Counter (Don't touch!!)
- * %edx Port
- * %esi Source buffer (mem pointer)
- *
- * In case you are wondering what the last line of the asm does...
- * <output allocation> : <input allocation> : <trashed registers>
- */
- register int d0;
-
- asm("shr $2,%%ecx\n" \
- " jz .no_more_bulk_ni\n" \
- " .p2align 4,,7\n" \
- ".loop_bulk_ni:\n" \
- NIBBLE_IN(%%bl) \
- NIBBLE_IN(%%bh) \
- " rorl $16,%%ebx\n" \
- NIBBLE_IN(%%bl) \
- NIBBLE_IN(%%bh) \
- " rorl $16,%%ebx\n" \
- " movl %%ebx,(%%esi)\n" \
- " addl $4,%%esi\n" \
- " loop .loop_bulk_ni\n" \
- " .p2align 4,,7\n" \
- ".no_more_bulk_ni:" \
- : "=S"(buffer), "=c"(d0)
- : "1"(len), "d"(str_p), "0"(buffer)
- : "eax", "ebx");
-
- asm("andl $3,%%ecx\n" \
- " jz .no_more_loose_ni\n" \
- " .p2align 4,,7\n" \
- ".loop_loose_ni:\n" \
- NIBBLE_IN((%%esi)) \
- " incl %%esi\n" \
- " loop .loop_loose_ni\n" \
- ".no_more_loose_ni:\n" \
- : "=c"(d0)
- : "0"(len), "d"(str_p), "S"(buffer)
- : "eax", "ebx");
- return 1; /* All went well - we hope! */
-}
-#else /* Old style C routines */
-
-static inline int ppa_byte_out(unsigned short base, const char *buffer, int len)
-{
- unsigned short ctr_p = base + 2;
int i;
for (i = len; i; i--) {
- outb(*buffer++, base);
- outb(0xe, ctr_p);
- outb(0xc, ctr_p);
+ w_dtr(base, *buffer++);
+ w_ctr(base, 0xe);
+ w_ctr(base, 0xc);
}
return 1; /* All went well - we hope! */
}
-static inline int ppa_byte_in(unsigned short base, char *buffer, int len)
+static int ppa_byte_in(unsigned short base, char *buffer, int len)
{
- unsigned short ctr_p = base + 2;
int i;
for (i = len; i; i--) {
- *buffer++ = inb(base);
- outb(0x27, ctr_p);
- outb(0x25, ctr_p);
+ *buffer++ = r_dtr(base);
+ w_ctr(base, 0x27);
+ w_ctr(base, 0x25);
}
return 1; /* All went well - we hope! */
}
-static inline int ppa_nibble_in(unsigned short str_p, char *buffer, int len)
+static int ppa_nibble_in(unsigned short base, char *buffer, int len)
{
- unsigned short ctr_p = str_p + 1;
- unsigned char h, l;
- int i;
+ for (; len; len--) {
+ unsigned char h;
- for (i = len; i; i--) {
- outb(0x4, ctr_p);
- h = inb(str_p);
- outb(0x6, ctr_p);
- l = inb(str_p);
- *buffer++ = (h & 0xf0) | ((l & 0xf0) >> 4);
+ w_ctr(base, 0x4);
+ h = r_str(base) & 0xf0;
+ w_ctr(base, 0x6);
+ *buffer++ = h | ((r_str(base) & 0xf0) >> 4);
}
return 1; /* All went well - we hope! */
}
-#endif
-
-static inline int ppa_epp_out(unsigned short epp_p, unsigned short str_p, const char *buffer, int len)
-{
- int i;
- for (i = len; i; i--) {
- outb(*buffer++, epp_p);
-#ifdef CONFIG_SCSI_PPA_HAVE_PEDANTIC
- if (inb(str_p) & 0x01)
- return 0;
-#endif
- }
- return 1;
-}
static int ppa_out(int host_no, char *buffer, int len)
{
@@ -623,16 +410,17 @@
case PPA_EPP_8:
epp_reset(ppb);
w_ctr(ppb, 0x4);
-#ifdef CONFIG_SCSI_PPA_HAVE_PEDANTIC
- r = ppa_epp_out(ppb + 4, ppb + 1, buffer, len);
+#ifdef CONFIG_SCSI_IZIP_EPP16
+ if (!(((long) buffer | len) & 0x01))
+ outsw(ppb + 4, buffer, len >> 1);
#else
if (!(((long) buffer | len) & 0x03))
outsl(ppb + 4, buffer, len >> 2);
+#endif
else
outsb(ppb + 4, buffer, len);
w_ctr(ppb, 0xc);
r = !(r_str(ppb) & 0x01);
-#endif
w_ctr(ppb, 0xc);
ecp_sync(ppb);
break;
@@ -644,19 +432,6 @@
return r;
}
-static inline int ppa_epp_in(int epp_p, int str_p, char *buffer, int len)
-{
- int i;
- for (i = len; i; i--) {
- *buffer++ = inb(epp_p);
-#ifdef CONFIG_SCSI_PPA_HAVE_PEDANTIC
- if (inb(str_p) & 0x01)
- return 0;
-#endif
- }
- return 1;
-}
-
static int ppa_in(int host_no, char *buffer, int len)
{
int r;
@@ -671,7 +446,7 @@
switch (ppa_hosts[host_no].mode) {
case PPA_NIBBLE:
/* 4 bit input, with a loop */
- r = ppa_nibble_in(ppb + 1, buffer, len);
+ r = ppa_nibble_in(ppb, buffer, len);
w_ctr(ppb, 0xc);
break;
@@ -688,16 +463,17 @@
case PPA_EPP_8:
epp_reset(ppb);
w_ctr(ppb, 0x24);
-#ifdef CONFIG_SCSI_PPA_HAVE_PEDANTIC
- r = ppa_epp_in(ppb + 4, ppb + 1, buffer, len);
+#ifdef CONFIG_SCSI_IZIP_EPP16
+ if (!(((long) buffer | len) & 0x01))
+ insw(ppb + 4, buffer, len >> 1);
#else
if (!(((long) buffer | len) & 0x03))
insl(ppb + 4, buffer, len >> 2);
+#endif
else
insb(ppb + 4, buffer, len);
w_ctr(ppb, 0x2c);
r = !(r_str(ppb) & 0x01);
-#endif
w_ctr(ppb, 0x2c);
ecp_sync(ppb);
break;
@@ -885,7 +661,7 @@
* If we have been running for more than a full timer tick
* then take a rest.
*/
- if (time_after(jiffies,start_jiffies + 1))
+ if (time_after(jiffies, start_jiffies + 1))
return 0;
if (((r & 0xc0) != 0xc0) || (cmd->SCp.this_residual <= 0)) {
@@ -1059,8 +835,7 @@
if ((r_str(ppb) & 0x08) == 0x00)
retv--;
- if (retv)
- {
+ if (retv) {
if ((jiffies - tmp->jstart) > (1 * HZ)) {
printk("ppa: Parallel port cable is unplugged!!\n");
ppa_fail(host_no, DID_BUS_BUSY);
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov