1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds
31da177e4SLinus Torvalds /* Driver for the Iomega MatchMaker parallel port SCSI HBA embedded in
41da177e4SLinus Torvalds * the Iomega ZIP Plus drive
51da177e4SLinus Torvalds *
6bdca3f20SAdrian Bunk * (c) 1998 David Campbell
71da177e4SLinus Torvalds *
81da177e4SLinus Torvalds * Please note that I live in Perth, Western Australia. GMT+0800
91da177e4SLinus Torvalds */
101da177e4SLinus Torvalds
111da177e4SLinus Torvalds #ifndef _IMM_H
121da177e4SLinus Torvalds #define _IMM_H
131da177e4SLinus Torvalds
141da177e4SLinus Torvalds #define IMM_VERSION "2.05 (for Linux 2.4.0)"
151da177e4SLinus Torvalds
161da177e4SLinus Torvalds /*
171da177e4SLinus Torvalds * 10 Apr 1998 (Good Friday) - Received EN144302 by email from Iomega.
181da177e4SLinus Torvalds * Scarry thing is the level of support from one of their managers.
191da177e4SLinus Torvalds * The onus is now on us (the developers) to shut up and start coding.
201da177e4SLinus Torvalds * 11Apr98 [ 0.10 ]
211da177e4SLinus Torvalds *
221da177e4SLinus Torvalds * --- SNIP ---
231da177e4SLinus Torvalds *
241da177e4SLinus Torvalds * It manages to find the drive which is a good start. Writing data during
251da177e4SLinus Torvalds * data phase is known to be broken (due to requirements of two byte writes).
261da177e4SLinus Torvalds * Removing "Phase" debug messages.
271da177e4SLinus Torvalds *
281da177e4SLinus Torvalds * PS: Took four hours of coding after I bought a drive.
291da177e4SLinus Torvalds * ANZAC Day (Aus "War Veterans Holiday") 25Apr98 [ 0.14 ]
301da177e4SLinus Torvalds *
311da177e4SLinus Torvalds * Ten minutes later after a few fixes.... (LITERALLY!!!)
321da177e4SLinus Torvalds * Have mounted disk, copied file, dismounted disk, remount disk, diff file
331da177e4SLinus Torvalds * ----- It actually works!!! -----
341da177e4SLinus Torvalds * 25Apr98 [ 0.15 ]
351da177e4SLinus Torvalds *
361da177e4SLinus Torvalds * Twenty minutes of mucking around, rearanged the IEEE negotiate mechanism.
371da177e4SLinus Torvalds * Now have byte mode working (only EPP and ECP to go now... :=)
381da177e4SLinus Torvalds * 26Apr98 [ 0.16 ]
391da177e4SLinus Torvalds *
401da177e4SLinus Torvalds * Thirty minutes of further coding results in EPP working on my machine.
411da177e4SLinus Torvalds * 27Apr98 [ 0.17 ]
421da177e4SLinus Torvalds *
431da177e4SLinus Torvalds * Due to work commitments and inability to get a "true" ECP mode functioning
441da177e4SLinus Torvalds * I have decided to code the parport support into imm.
451da177e4SLinus Torvalds * 09Jun98 [ 0.18 ]
461da177e4SLinus Torvalds *
471da177e4SLinus Torvalds * Driver is now out of beta testing.
481da177e4SLinus Torvalds * Support for parport has been added.
491da177e4SLinus Torvalds * Now distributed with the ppa driver.
501da177e4SLinus Torvalds * 12Jun98 [ 2.00 ]
511da177e4SLinus Torvalds *
521da177e4SLinus Torvalds * Err.. It appears that imm-2.00 was broken....
531da177e4SLinus Torvalds * 18Jun98 [ 2.01 ]
541da177e4SLinus Torvalds *
551da177e4SLinus Torvalds * Patch applied to sync this against the Linux 2.1.x kernel code
561da177e4SLinus Torvalds * Included qboot_zip.sh
571da177e4SLinus Torvalds * 21Jun98 [ 2.02 ]
581da177e4SLinus Torvalds *
591da177e4SLinus Torvalds * Other clean ups include the follow changes:
601da177e4SLinus Torvalds * CONFIG_SCSI_PPA_HAVE_PEDANTIC => CONFIG_SCSI_IZIP_EPP16
611da177e4SLinus Torvalds * added CONFIG_SCSI_IZIP_SLOW_CTR option
621da177e4SLinus Torvalds * [2.03]
631da177e4SLinus Torvalds * Fix kernel panic on scsi timeout. 20Aug00 [2.04]
641da177e4SLinus Torvalds *
651da177e4SLinus Torvalds * Avoid io_request_lock problems.
661da177e4SLinus Torvalds * John Cavan <johncavan@home.com> 16Nov00 [2.05]
671da177e4SLinus Torvalds */
681da177e4SLinus Torvalds /* ------ END OF USER CONFIGURABLE PARAMETERS ----- */
691da177e4SLinus Torvalds
701da177e4SLinus Torvalds #include <linux/stddef.h>
711da177e4SLinus Torvalds #include <linux/module.h>
721da177e4SLinus Torvalds #include <linux/kernel.h>
731da177e4SLinus Torvalds #include <linux/ioport.h>
741da177e4SLinus Torvalds #include <linux/delay.h>
751da177e4SLinus Torvalds #include <linux/proc_fs.h>
761da177e4SLinus Torvalds #include <linux/stat.h>
771da177e4SLinus Torvalds #include <linux/blkdev.h>
781da177e4SLinus Torvalds #include <linux/sched.h>
791da177e4SLinus Torvalds #include <linux/interrupt.h>
801da177e4SLinus Torvalds
811da177e4SLinus Torvalds #include <asm/io.h>
821da177e4SLinus Torvalds #include <scsi/scsi_host.h>
831da177e4SLinus Torvalds /* batteries not included :-) */
841da177e4SLinus Torvalds
851da177e4SLinus Torvalds /*
861da177e4SLinus Torvalds * modes in which the driver can operate
871da177e4SLinus Torvalds */
881da177e4SLinus Torvalds #define IMM_AUTODETECT 0 /* Autodetect mode */
891da177e4SLinus Torvalds #define IMM_NIBBLE 1 /* work in standard 4 bit mode */
901da177e4SLinus Torvalds #define IMM_PS2 2 /* PS/2 byte mode */
911da177e4SLinus Torvalds #define IMM_EPP_8 3 /* EPP mode, 8 bit */
921da177e4SLinus Torvalds #define IMM_EPP_16 4 /* EPP mode, 16 bit */
931da177e4SLinus Torvalds #define IMM_EPP_32 5 /* EPP mode, 32 bit */
941da177e4SLinus Torvalds #define IMM_UNKNOWN 6 /* Just in case... */
951da177e4SLinus Torvalds
961da177e4SLinus Torvalds static char *IMM_MODE_STRING[] =
971da177e4SLinus Torvalds {
981da177e4SLinus Torvalds [IMM_AUTODETECT] = "Autodetect",
991da177e4SLinus Torvalds [IMM_NIBBLE] = "SPP",
1001da177e4SLinus Torvalds [IMM_PS2] = "PS/2",
1011da177e4SLinus Torvalds [IMM_EPP_8] = "EPP 8 bit",
1021da177e4SLinus Torvalds [IMM_EPP_16] = "EPP 16 bit",
1031da177e4SLinus Torvalds #ifdef CONFIG_SCSI_IZIP_EPP16
1041da177e4SLinus Torvalds [IMM_EPP_32] = "EPP 16 bit",
1051da177e4SLinus Torvalds #else
1061da177e4SLinus Torvalds [IMM_EPP_32] = "EPP 32 bit",
1071da177e4SLinus Torvalds #endif
1081da177e4SLinus Torvalds [IMM_UNKNOWN] = "Unknown",
1091da177e4SLinus Torvalds };
1101da177e4SLinus Torvalds
1111da177e4SLinus Torvalds /* other options */
1121da177e4SLinus Torvalds #define IMM_BURST_SIZE 512 /* data burst size */
1131da177e4SLinus Torvalds #define IMM_SELECT_TMO 500 /* 500 how long to wait for target ? */
1141da177e4SLinus Torvalds #define IMM_SPIN_TMO 5000 /* 50000 imm_wait loop limiter */
1151da177e4SLinus Torvalds #define IMM_DEBUG 0 /* debugging option */
1161da177e4SLinus Torvalds #define IN_EPP_MODE(x) (x == IMM_EPP_8 || x == IMM_EPP_16 || x == IMM_EPP_32)
1171da177e4SLinus Torvalds
1181da177e4SLinus Torvalds /* args to imm_connect */
1191da177e4SLinus Torvalds #define CONNECT_EPP_MAYBE 1
1201da177e4SLinus Torvalds #define CONNECT_NORMAL 0
1211da177e4SLinus Torvalds
1221da177e4SLinus Torvalds #define r_dtr(x) (unsigned char)inb((x))
1231da177e4SLinus Torvalds #define r_str(x) (unsigned char)inb((x)+1)
1241da177e4SLinus Torvalds #define r_ctr(x) (unsigned char)inb((x)+2)
1251da177e4SLinus Torvalds #define r_epp(x) (unsigned char)inb((x)+4)
1261da177e4SLinus Torvalds #define r_fifo(x) (unsigned char)inb((x)) /* x must be base_hi */
1271da177e4SLinus Torvalds /* On PCI is: base+0x400 != base_hi */
1281da177e4SLinus Torvalds #define r_ecr(x) (unsigned char)inb((x)+2) /* x must be base_hi */
1291da177e4SLinus Torvalds
1301da177e4SLinus Torvalds #define w_dtr(x,y) outb(y, (x))
1311da177e4SLinus Torvalds #define w_str(x,y) outb(y, (x)+1)
1321da177e4SLinus Torvalds #define w_epp(x,y) outb(y, (x)+4)
1331da177e4SLinus Torvalds #define w_fifo(x,y) outb(y, (x)) /* x must be base_hi */
1341da177e4SLinus Torvalds #define w_ecr(x,y) outb(y, (x)+0x2) /* x must be base_hi */
1351da177e4SLinus Torvalds
1361da177e4SLinus Torvalds #ifdef CONFIG_SCSI_IZIP_SLOW_CTR
1371da177e4SLinus Torvalds #define w_ctr(x,y) outb_p(y, (x)+2)
1381da177e4SLinus Torvalds #else
1391da177e4SLinus Torvalds #define w_ctr(x,y) outb(y, (x)+2)
1401da177e4SLinus Torvalds #endif
1411da177e4SLinus Torvalds
imm_scsi_pointer(struct scsi_cmnd * cmd)142*6b66f09cSBart Van Assche static inline struct scsi_pointer *imm_scsi_pointer(struct scsi_cmnd *cmd)
143*6b66f09cSBart Van Assche {
144*6b66f09cSBart Van Assche return scsi_cmd_priv(cmd);
145*6b66f09cSBart Van Assche }
146*6b66f09cSBart Van Assche
1471da177e4SLinus Torvalds static int imm_engine(imm_struct *, struct scsi_cmnd *);
1481da177e4SLinus Torvalds
1491da177e4SLinus Torvalds #endif /* _IMM_H */
150