2 /* Driver for the Iomega MatchMaker parallel port SCSI HBA embedded in
3 * the Iomega ZIP Plus drive
5 * (c) 1998 David Campbell campbell@torque.net
7 * Please note that I live in Perth, Western Australia. GMT+0800
13 #define IMM_VERSION "2.03 (for Linux 2.0.0)"
16 * 10 Apr 1998 (Good Friday) - Received EN144302 by email from Iomega.
17 * Scarry thing is the level of support from one of their managers.
18 * The onus is now on us (the developers) to shut up and start coding.
23 * It manages to find the drive which is a good start. Writing data during
24 * data phase is known to be broken (due to requirements of two byte writes).
25 * Removing "Phase" debug messages.
27 * PS: Took four hours of coding after I bought a drive.
28 * ANZAC Day (Aus "War Veterans Holiday") 25Apr98 [ 0.14 ]
30 * Ten minutes later after a few fixes.... (LITERALLY!!!)
31 * Have mounted disk, copied file, dismounted disk, remount disk, diff file
32 * ----- It actually works!!! -----
35 * Twenty minutes of mucking around, rearanged the IEEE negotiate mechanism.
36 * Now have byte mode working (only EPP and ECP to go now... :=)
39 * Thirty minutes of further coding results in EPP working on my machine.
42 * Due to work commitments and inability to get a "true" ECP mode functioning
43 * I have decided to code the parport support into imm.
46 * Driver is now out of beta testing.
47 * Support for parport has been added.
48 * Now distributed with the ppa driver.
51 * Err.. It appears that imm-2.00 was broken....
54 * Patch applied to sync this against the Linux 2.1.x kernel code
55 * Included qboot_zip.sh
58 * Other clean ups include the follow changes:
59 * CONFIG_SCSI_PPA_HAVE_PEDANTIC => CONFIG_SCSI_IZIP_EPP16
60 * added CONFIG_SCSI_IZIP_SLOW_CTR option
63 /* ------ END OF USER CONFIGURABLE PARAMETERS ----- */
66 #include <linux/config.h>
67 #include <linux/stddef.h>
68 #include <linux/module.h>
69 #include <linux/kernel.h>
70 #include <linux/tqueue.h>
71 #include <linux/ioport.h>
72 #include <linux/delay.h>
73 #include <linux/proc_fs.h>
74 #include <linux/stat.h>
75 #include <linux/blk.h>
76 #include <linux/sched.h>
77 #include <linux/interrupt.h>
82 /* batteries not included :-) */
85 * modes in which the driver can operate
87 #define IMM_AUTODETECT 0 /* Autodetect mode */
88 #define IMM_NIBBLE 1 /* work in standard 4 bit mode */
89 #define IMM_PS2 2 /* PS/2 byte mode */
90 #define IMM_EPP_8 3 /* EPP mode, 8 bit */
91 #define IMM_EPP_16 4 /* EPP mode, 16 bit */
92 #define IMM_EPP_32 5 /* EPP mode, 32 bit */
93 #define IMM_UNKNOWN 6 /* Just in case... */
95 static char *IMM_MODE_STRING
[] =
102 #ifdef CONFIG_SCSI_IZIP_EPP16
109 /* This is a global option */
110 int imm_sg
= SG_ALL
; /* enable/disable scatter-gather. */
113 #define IMM_CAN_QUEUE 1 /* use "queueing" interface */
114 #define IMM_BURST_SIZE 512 /* data burst size */
115 #define IMM_SELECT_TMO 500 /* 500 how long to wait for target ? */
116 #define IMM_SPIN_TMO 5000 /* 50000 imm_wait loop limiter */
117 #define IMM_DEBUG 0 /* debuging option */
118 #define IN_EPP_MODE(x) (x == IMM_EPP_8 || x == IMM_EPP_16 || x == IMM_EPP_32)
120 /* args to imm_connect */
121 #define CONNECT_EPP_MAYBE 1
122 #define CONNECT_NORMAL 0
124 #define r_dtr(x) (unsigned char)inb((x))
125 #define r_str(x) (unsigned char)inb((x)+1)
126 #define r_ctr(x) (unsigned char)inb((x)+2)
127 #define r_epp(x) (unsigned char)inb((x)+4)
128 #define r_fifo(x) (unsigned char)inb((x)) /* x must be base_hi */
129 /* On PCI is: base+0x400 != base_hi */
130 #define r_ecr(x) (unsigned char)inb((x)+2) /* x must be base_hi */
132 #define w_dtr(x,y) outb(y, (x))
133 #define w_str(x,y) outb(y, (x)+1)
134 #define w_epp(x,y) outb(y, (x)+4)
135 #define w_fifo(x,y) outb(y, (x)) /* x must be base_hi */
136 #define w_ecr(x,y) outb(y, (x)+0x2) /* x must be base_hi */
138 #ifdef CONFIG_SCSI_IZIP_SLOW_CTR
139 #define w_ctr(x,y) outb_p(y, (x)+2)
141 #define w_ctr(x,y) outb(y, (x)+2)
144 static int imm_engine(imm_struct
*, Scsi_Cmnd
*);
145 static int imm_in(int, char *, int);
146 static int imm_init(int);
147 static void imm_interrupt(void *);
148 static int imm_out(int, char *, int);
151 #define imm_release 0
154 int imm_detect(Scsi_Host_Template
*);
155 const char *imm_info(struct Scsi_Host
*);
156 int imm_command(Scsi_Cmnd
*);
157 int imm_queuecommand(Scsi_Cmnd
*, void (*done
) (Scsi_Cmnd
*));
158 int imm_abort(Scsi_Cmnd
*);
159 int imm_reset(Scsi_Cmnd
*);
160 int imm_proc_info(char *, char **, off_t
, int, int, int);
161 int imm_biosparam(Disk
*, kdev_t
, int *);
163 #define IMM { proc_name: "imm", \
164 proc_info: imm_proc_info, \
165 name: "Iomega VPI2 (imm) interface",\
166 detect: imm_detect, \
167 release: imm_release, \
168 command: imm_command, \
169 queuecommand: imm_queuecommand, \
170 eh_abort_handler: imm_abort, \
171 eh_device_reset_handler: NULL, \
172 eh_bus_reset_handler: imm_reset, \
173 eh_host_reset_handler: imm_reset, \
174 bios_param: imm_biosparam, \
176 sg_tablesize: SG_ALL, \
178 use_clustering: ENABLE_CLUSTERING \