162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* Driver for the PPA3 parallel port SCSI HBA embedded in 362306a36Sopenharmony_ci * the Iomega ZIP drive 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * (c) 1996 Grant R. Guenther grant@torque.net 662306a36Sopenharmony_ci * David Campbell 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * All comments to David. 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#ifndef _PPA_H 1262306a36Sopenharmony_ci#define _PPA_H 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#define PPA_VERSION "2.07 (for Linux 2.4.x)" 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci/* 1762306a36Sopenharmony_ci * this driver has been hacked by Matteo Frigo (athena@theory.lcs.mit.edu) 1862306a36Sopenharmony_ci * to support EPP and scatter-gather. [0.26-athena] 1962306a36Sopenharmony_ci * 2062306a36Sopenharmony_ci * additional hacks by David Campbell 2162306a36Sopenharmony_ci * in response to this driver "mis-behaving" on his machine. 2262306a36Sopenharmony_ci * Fixed EPP to handle "software" changing of EPP port data direction. 2362306a36Sopenharmony_ci * Chased down EPP timeouts 2462306a36Sopenharmony_ci * Made this driver "kernel version friendly" [0.28-athena] 2562306a36Sopenharmony_ci * 2662306a36Sopenharmony_ci * [ Stuff removed ] 2762306a36Sopenharmony_ci * 2862306a36Sopenharmony_ci * Corrected ppa.h for 2.1.x kernels (>=2.1.85) 2962306a36Sopenharmony_ci * Modified "Nat Semi Kludge" for extended chipsets 3062306a36Sopenharmony_ci * [1.41] 3162306a36Sopenharmony_ci * 3262306a36Sopenharmony_ci * Fixed id_probe for EPP 1.9 chipsets (misdetected as EPP 1.7) 3362306a36Sopenharmony_ci * [1.42] 3462306a36Sopenharmony_ci * 3562306a36Sopenharmony_ci * Development solely for 2.1.x kernels from now on! 3662306a36Sopenharmony_ci * [2.00] 3762306a36Sopenharmony_ci * 3862306a36Sopenharmony_ci * Hack and slash at the init code (EPP device check routine) 3962306a36Sopenharmony_ci * Added INSANE option. 4062306a36Sopenharmony_ci * [2.01] 4162306a36Sopenharmony_ci * 4262306a36Sopenharmony_ci * Patch applied to sync against the 2.1.x kernel code 4362306a36Sopenharmony_ci * Included qboot_zip.sh 4462306a36Sopenharmony_ci * [2.02] 4562306a36Sopenharmony_ci * 4662306a36Sopenharmony_ci * Cleaned up the mess left by someone else trying to fix the 4762306a36Sopenharmony_ci * asm section to keep egcc happy. The asm section no longer 4862306a36Sopenharmony_ci * exists, the nibble code is *almost* as fast as the asm code 4962306a36Sopenharmony_ci * providing it is compiled with egcc. 5062306a36Sopenharmony_ci * 5162306a36Sopenharmony_ci * Other clean ups include the follow changes: 5262306a36Sopenharmony_ci * CONFIG_SCSI_PPA_HAVE_PEDANTIC => CONFIG_SCSI_IZIP_EPP16 5362306a36Sopenharmony_ci * added CONFIG_SCSI_IZIP_SLOW_CTR option 5462306a36Sopenharmony_ci * [2.03] 5562306a36Sopenharmony_ci * 5662306a36Sopenharmony_ci * Use ppa_wait() to check for ready AND connected status bits 5762306a36Sopenharmony_ci * Add ppa_wait() calls to ppa_completion() 5862306a36Sopenharmony_ci * by Peter Cherriman <pjc@ecs.soton.ac.uk> and 5962306a36Sopenharmony_ci * Tim Waugh <twaugh@redhat.com> 6062306a36Sopenharmony_ci * [2.04] 6162306a36Sopenharmony_ci * 6262306a36Sopenharmony_ci * Fix kernel panic on scsi timeout, 2000-08-18 [2.05] 6362306a36Sopenharmony_ci * 6462306a36Sopenharmony_ci * Avoid io_request_lock problems. 6562306a36Sopenharmony_ci * John Cavan <johncavan@home.com> [2.06] 6662306a36Sopenharmony_ci * 6762306a36Sopenharmony_ci * Busy wait for connected status bit in ppa_completion() 6862306a36Sopenharmony_ci * in order to cope with some hardware that has this bit low 6962306a36Sopenharmony_ci * for short periods of time. 7062306a36Sopenharmony_ci * Add udelay() to ppa_select() 7162306a36Sopenharmony_ci * by Peter Cherriman <pjc@ecs.soton.ac.uk> and 7262306a36Sopenharmony_ci * Oleg Makarenko <omakarenko@cyberplat.ru> 7362306a36Sopenharmony_ci * [2.07] 7462306a36Sopenharmony_ci */ 7562306a36Sopenharmony_ci/* ------ END OF USER CONFIGURABLE PARAMETERS ----- */ 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci#include <linux/stddef.h> 7862306a36Sopenharmony_ci#include <linux/module.h> 7962306a36Sopenharmony_ci#include <linux/kernel.h> 8062306a36Sopenharmony_ci#include <linux/ioport.h> 8162306a36Sopenharmony_ci#include <linux/delay.h> 8262306a36Sopenharmony_ci#include <linux/proc_fs.h> 8362306a36Sopenharmony_ci#include <linux/stat.h> 8462306a36Sopenharmony_ci#include <linux/blkdev.h> 8562306a36Sopenharmony_ci#include <linux/sched.h> 8662306a36Sopenharmony_ci#include <linux/interrupt.h> 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci#include <asm/io.h> 8962306a36Sopenharmony_ci#include <scsi/scsi_host.h> 9062306a36Sopenharmony_ci/* batteries not included :-) */ 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci/* 9362306a36Sopenharmony_ci * modes in which the driver can operate 9462306a36Sopenharmony_ci */ 9562306a36Sopenharmony_ci#define PPA_AUTODETECT 0 /* Autodetect mode */ 9662306a36Sopenharmony_ci#define PPA_NIBBLE 1 /* work in standard 4 bit mode */ 9762306a36Sopenharmony_ci#define PPA_PS2 2 /* PS/2 byte mode */ 9862306a36Sopenharmony_ci#define PPA_EPP_8 3 /* EPP mode, 8 bit */ 9962306a36Sopenharmony_ci#define PPA_EPP_16 4 /* EPP mode, 16 bit */ 10062306a36Sopenharmony_ci#define PPA_EPP_32 5 /* EPP mode, 32 bit */ 10162306a36Sopenharmony_ci#define PPA_UNKNOWN 6 /* Just in case... */ 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_cistatic char *PPA_MODE_STRING[] = 10462306a36Sopenharmony_ci{ 10562306a36Sopenharmony_ci "Autodetect", 10662306a36Sopenharmony_ci "SPP", 10762306a36Sopenharmony_ci "PS/2", 10862306a36Sopenharmony_ci "EPP 8 bit", 10962306a36Sopenharmony_ci "EPP 16 bit", 11062306a36Sopenharmony_ci "EPP 32 bit", 11162306a36Sopenharmony_ci "Unknown"}; 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci/* other options */ 11462306a36Sopenharmony_ci#define PPA_BURST_SIZE 512 /* data burst size */ 11562306a36Sopenharmony_ci#define PPA_SELECT_TMO 5000 /* how long to wait for target ? */ 11662306a36Sopenharmony_ci#define PPA_SPIN_TMO 50000 /* ppa_wait loop limiter */ 11762306a36Sopenharmony_ci#define PPA_RECON_TMO 500 /* scsi reconnection loop limiter */ 11862306a36Sopenharmony_ci#define PPA_DEBUG 0 /* debugging option */ 11962306a36Sopenharmony_ci#define IN_EPP_MODE(x) (x == PPA_EPP_8 || x == PPA_EPP_16 || x == PPA_EPP_32) 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci/* args to ppa_connect */ 12262306a36Sopenharmony_ci#define CONNECT_EPP_MAYBE 1 12362306a36Sopenharmony_ci#define CONNECT_NORMAL 0 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci#define r_dtr(x) (unsigned char)inb((x)) 12662306a36Sopenharmony_ci#define r_str(x) (unsigned char)inb((x)+1) 12762306a36Sopenharmony_ci#define r_ctr(x) (unsigned char)inb((x)+2) 12862306a36Sopenharmony_ci#define r_epp(x) (unsigned char)inb((x)+4) 12962306a36Sopenharmony_ci#define r_fifo(x) (unsigned char)inb((x)) /* x must be base_hi */ 13062306a36Sopenharmony_ci /* On PCI is base+0x400 != base_hi */ 13162306a36Sopenharmony_ci#define r_ecr(x) (unsigned char)inb((x)+0x2) /* x must be base_hi */ 13262306a36Sopenharmony_ci 13362306a36Sopenharmony_ci#define w_dtr(x,y) outb(y, (x)) 13462306a36Sopenharmony_ci#define w_str(x,y) outb(y, (x)+1) 13562306a36Sopenharmony_ci#define w_epp(x,y) outb(y, (x)+4) 13662306a36Sopenharmony_ci#define w_fifo(x,y) outb(y, (x)) /* x must be base_hi */ 13762306a36Sopenharmony_ci#define w_ecr(x,y) outb(y, (x)+0x2)/* x must be base_hi */ 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_ci#ifdef CONFIG_SCSI_IZIP_SLOW_CTR 14062306a36Sopenharmony_ci#define w_ctr(x,y) outb_p(y, (x)+2) 14162306a36Sopenharmony_ci#else 14262306a36Sopenharmony_ci#define w_ctr(x,y) outb(y, (x)+2) 14362306a36Sopenharmony_ci#endif 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_cistatic int ppa_engine(ppa_struct *, struct scsi_cmnd *); 14662306a36Sopenharmony_ci 14762306a36Sopenharmony_ci#endif /* _PPA_H */ 148