1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun /* Driver for the PPA3 parallel port SCSI HBA embedded in 3*4882a593Smuzhiyun * the Iomega ZIP drive 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * (c) 1996 Grant R. Guenther grant@torque.net 6*4882a593Smuzhiyun * David Campbell 7*4882a593Smuzhiyun * 8*4882a593Smuzhiyun * All comments to David. 9*4882a593Smuzhiyun */ 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun #ifndef _PPA_H 12*4882a593Smuzhiyun #define _PPA_H 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun #define PPA_VERSION "2.07 (for Linux 2.4.x)" 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun /* 17*4882a593Smuzhiyun * this driver has been hacked by Matteo Frigo (athena@theory.lcs.mit.edu) 18*4882a593Smuzhiyun * to support EPP and scatter-gather. [0.26-athena] 19*4882a593Smuzhiyun * 20*4882a593Smuzhiyun * additional hacks by David Campbell 21*4882a593Smuzhiyun * in response to this driver "mis-behaving" on his machine. 22*4882a593Smuzhiyun * Fixed EPP to handle "software" changing of EPP port data direction. 23*4882a593Smuzhiyun * Chased down EPP timeouts 24*4882a593Smuzhiyun * Made this driver "kernel version friendly" [0.28-athena] 25*4882a593Smuzhiyun * 26*4882a593Smuzhiyun * [ Stuff removed ] 27*4882a593Smuzhiyun * 28*4882a593Smuzhiyun * Corrected ppa.h for 2.1.x kernels (>=2.1.85) 29*4882a593Smuzhiyun * Modified "Nat Semi Kludge" for extended chipsets 30*4882a593Smuzhiyun * [1.41] 31*4882a593Smuzhiyun * 32*4882a593Smuzhiyun * Fixed id_probe for EPP 1.9 chipsets (misdetected as EPP 1.7) 33*4882a593Smuzhiyun * [1.42] 34*4882a593Smuzhiyun * 35*4882a593Smuzhiyun * Development solely for 2.1.x kernels from now on! 36*4882a593Smuzhiyun * [2.00] 37*4882a593Smuzhiyun * 38*4882a593Smuzhiyun * Hack and slash at the init code (EPP device check routine) 39*4882a593Smuzhiyun * Added INSANE option. 40*4882a593Smuzhiyun * [2.01] 41*4882a593Smuzhiyun * 42*4882a593Smuzhiyun * Patch applied to sync against the 2.1.x kernel code 43*4882a593Smuzhiyun * Included qboot_zip.sh 44*4882a593Smuzhiyun * [2.02] 45*4882a593Smuzhiyun * 46*4882a593Smuzhiyun * Cleaned up the mess left by someone else trying to fix the 47*4882a593Smuzhiyun * asm section to keep egcc happy. The asm section no longer 48*4882a593Smuzhiyun * exists, the nibble code is *almost* as fast as the asm code 49*4882a593Smuzhiyun * providing it is compiled with egcc. 50*4882a593Smuzhiyun * 51*4882a593Smuzhiyun * Other clean ups include the follow changes: 52*4882a593Smuzhiyun * CONFIG_SCSI_PPA_HAVE_PEDANTIC => CONFIG_SCSI_IZIP_EPP16 53*4882a593Smuzhiyun * added CONFIG_SCSI_IZIP_SLOW_CTR option 54*4882a593Smuzhiyun * [2.03] 55*4882a593Smuzhiyun * 56*4882a593Smuzhiyun * Use ppa_wait() to check for ready AND connected status bits 57*4882a593Smuzhiyun * Add ppa_wait() calls to ppa_completion() 58*4882a593Smuzhiyun * by Peter Cherriman <pjc@ecs.soton.ac.uk> and 59*4882a593Smuzhiyun * Tim Waugh <twaugh@redhat.com> 60*4882a593Smuzhiyun * [2.04] 61*4882a593Smuzhiyun * 62*4882a593Smuzhiyun * Fix kernel panic on scsi timeout, 2000-08-18 [2.05] 63*4882a593Smuzhiyun * 64*4882a593Smuzhiyun * Avoid io_request_lock problems. 65*4882a593Smuzhiyun * John Cavan <johncavan@home.com> [2.06] 66*4882a593Smuzhiyun * 67*4882a593Smuzhiyun * Busy wait for connected status bit in ppa_completion() 68*4882a593Smuzhiyun * in order to cope with some hardware that has this bit low 69*4882a593Smuzhiyun * for short periods of time. 70*4882a593Smuzhiyun * Add udelay() to ppa_select() 71*4882a593Smuzhiyun * by Peter Cherriman <pjc@ecs.soton.ac.uk> and 72*4882a593Smuzhiyun * Oleg Makarenko <omakarenko@cyberplat.ru> 73*4882a593Smuzhiyun * [2.07] 74*4882a593Smuzhiyun */ 75*4882a593Smuzhiyun /* ------ END OF USER CONFIGURABLE PARAMETERS ----- */ 76*4882a593Smuzhiyun 77*4882a593Smuzhiyun #include <linux/stddef.h> 78*4882a593Smuzhiyun #include <linux/module.h> 79*4882a593Smuzhiyun #include <linux/kernel.h> 80*4882a593Smuzhiyun #include <linux/ioport.h> 81*4882a593Smuzhiyun #include <linux/delay.h> 82*4882a593Smuzhiyun #include <linux/proc_fs.h> 83*4882a593Smuzhiyun #include <linux/stat.h> 84*4882a593Smuzhiyun #include <linux/blkdev.h> 85*4882a593Smuzhiyun #include <linux/sched.h> 86*4882a593Smuzhiyun #include <linux/interrupt.h> 87*4882a593Smuzhiyun 88*4882a593Smuzhiyun #include <asm/io.h> 89*4882a593Smuzhiyun #include <scsi/scsi_host.h> 90*4882a593Smuzhiyun /* batteries not included :-) */ 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun /* 93*4882a593Smuzhiyun * modes in which the driver can operate 94*4882a593Smuzhiyun */ 95*4882a593Smuzhiyun #define PPA_AUTODETECT 0 /* Autodetect mode */ 96*4882a593Smuzhiyun #define PPA_NIBBLE 1 /* work in standard 4 bit mode */ 97*4882a593Smuzhiyun #define PPA_PS2 2 /* PS/2 byte mode */ 98*4882a593Smuzhiyun #define PPA_EPP_8 3 /* EPP mode, 8 bit */ 99*4882a593Smuzhiyun #define PPA_EPP_16 4 /* EPP mode, 16 bit */ 100*4882a593Smuzhiyun #define PPA_EPP_32 5 /* EPP mode, 32 bit */ 101*4882a593Smuzhiyun #define PPA_UNKNOWN 6 /* Just in case... */ 102*4882a593Smuzhiyun 103*4882a593Smuzhiyun static char *PPA_MODE_STRING[] = 104*4882a593Smuzhiyun { 105*4882a593Smuzhiyun "Autodetect", 106*4882a593Smuzhiyun "SPP", 107*4882a593Smuzhiyun "PS/2", 108*4882a593Smuzhiyun "EPP 8 bit", 109*4882a593Smuzhiyun "EPP 16 bit", 110*4882a593Smuzhiyun #ifdef CONFIG_SCSI_IZIP_EPP16 111*4882a593Smuzhiyun "EPP 16 bit", 112*4882a593Smuzhiyun #else 113*4882a593Smuzhiyun "EPP 32 bit", 114*4882a593Smuzhiyun #endif 115*4882a593Smuzhiyun "Unknown"}; 116*4882a593Smuzhiyun 117*4882a593Smuzhiyun /* other options */ 118*4882a593Smuzhiyun #define PPA_BURST_SIZE 512 /* data burst size */ 119*4882a593Smuzhiyun #define PPA_SELECT_TMO 5000 /* how long to wait for target ? */ 120*4882a593Smuzhiyun #define PPA_SPIN_TMO 50000 /* ppa_wait loop limiter */ 121*4882a593Smuzhiyun #define PPA_RECON_TMO 500 /* scsi reconnection loop limiter */ 122*4882a593Smuzhiyun #define PPA_DEBUG 0 /* debugging option */ 123*4882a593Smuzhiyun #define IN_EPP_MODE(x) (x == PPA_EPP_8 || x == PPA_EPP_16 || x == PPA_EPP_32) 124*4882a593Smuzhiyun 125*4882a593Smuzhiyun /* args to ppa_connect */ 126*4882a593Smuzhiyun #define CONNECT_EPP_MAYBE 1 127*4882a593Smuzhiyun #define CONNECT_NORMAL 0 128*4882a593Smuzhiyun 129*4882a593Smuzhiyun #define r_dtr(x) (unsigned char)inb((x)) 130*4882a593Smuzhiyun #define r_str(x) (unsigned char)inb((x)+1) 131*4882a593Smuzhiyun #define r_ctr(x) (unsigned char)inb((x)+2) 132*4882a593Smuzhiyun #define r_epp(x) (unsigned char)inb((x)+4) 133*4882a593Smuzhiyun #define r_fifo(x) (unsigned char)inb((x)) /* x must be base_hi */ 134*4882a593Smuzhiyun /* On PCI is base+0x400 != base_hi */ 135*4882a593Smuzhiyun #define r_ecr(x) (unsigned char)inb((x)+0x2) /* x must be base_hi */ 136*4882a593Smuzhiyun 137*4882a593Smuzhiyun #define w_dtr(x,y) outb(y, (x)) 138*4882a593Smuzhiyun #define w_str(x,y) outb(y, (x)+1) 139*4882a593Smuzhiyun #define w_epp(x,y) outb(y, (x)+4) 140*4882a593Smuzhiyun #define w_fifo(x,y) outb(y, (x)) /* x must be base_hi */ 141*4882a593Smuzhiyun #define w_ecr(x,y) outb(y, (x)+0x2)/* x must be base_hi */ 142*4882a593Smuzhiyun 143*4882a593Smuzhiyun #ifdef CONFIG_SCSI_IZIP_SLOW_CTR 144*4882a593Smuzhiyun #define w_ctr(x,y) outb_p(y, (x)+2) 145*4882a593Smuzhiyun #else 146*4882a593Smuzhiyun #define w_ctr(x,y) outb(y, (x)+2) 147*4882a593Smuzhiyun #endif 148*4882a593Smuzhiyun 149*4882a593Smuzhiyun static int ppa_engine(ppa_struct *, struct scsi_cmnd *); 150*4882a593Smuzhiyun 151*4882a593Smuzhiyun #endif /* _PPA_H */ 152