Import 2.3.18pre1
[davej-history.git] / drivers / scsi / ppa.h
blob58aba3473e29d25cb0b8a0cdc7be418d0f1663cf
1 /* Driver for the PPA3 parallel port SCSI HBA embedded in
2 * the Iomega ZIP drive
3 *
4 * (c) 1996 Grant R. Guenther grant@torque.net
5 * David Campbell campbell@torque.net
7 * All comments to David.
8 */
10 #ifndef _PPA_H
11 #define _PPA_H
13 #define PPA_VERSION "2.03 (for Linux 2.2.x)"
15 /*
16 * this driver has been hacked by Matteo Frigo (athena@theory.lcs.mit.edu)
17 * to support EPP and scatter-gather. [0.26-athena]
19 * additional hacks by David Campbell
20 * in response to this driver "mis-behaving" on his machine.
21 * Fixed EPP to handle "software" changing of EPP port data direction.
22 * Chased down EPP timeouts
23 * Made this driver "kernel version friendly" [0.28-athena]
25 * [ Stuff removed ]
27 * Corrected ppa.h for 2.1.x kernels (>=2.1.85)
28 * Modified "Nat Semi Kludge" for extended chipsets
29 * [1.41]
31 * Fixed id_probe for EPP 1.9 chipsets (misdetected as EPP 1.7)
32 * [1.42]
34 * Development solely for 2.1.x kernels from now on!
35 * [2.00]
37 * Hack and slash at the init code (EPP device check routine)
38 * Added INSANE option.
39 * [2.01]
41 * Patch applied to sync against the 2.1.x kernel code
42 * Included qboot_zip.sh
43 * [2.02]
45 * Cleaned up the mess left by someone else trying to fix the
46 * asm section to keep egcc happy. The asm section no longer
47 * exists, the nibble code is *almost* as fast as the asm code
48 * providing it is compiled with egcc.
50 * Other clean ups include the follow changes:
51 * CONFIG_SCSI_PPA_HAVE_PEDANTIC => CONFIG_SCSI_IZIP_EPP16
52 * added CONFIG_SCSI_IZIP_SLOW_CTR option
53 * [2.03]
55 /* ------ END OF USER CONFIGURABLE PARAMETERS ----- */
57 #ifdef PPA_CODE
58 #include <linux/config.h>
59 #include <linux/stddef.h>
60 #include <linux/module.h>
61 #include <linux/kernel.h>
62 #include <linux/tqueue.h>
63 #include <linux/ioport.h>
64 #include <linux/delay.h>
65 #include <linux/proc_fs.h>
66 #include <linux/stat.h>
67 #include <linux/blk.h>
68 #include <linux/sched.h>
69 #include <linux/interrupt.h>
71 #include <asm/io.h>
72 #include "sd.h"
73 #include "hosts.h"
74 /* batteries not included :-) */
77 * modes in which the driver can operate
79 #define PPA_AUTODETECT 0 /* Autodetect mode */
80 #define PPA_NIBBLE 1 /* work in standard 4 bit mode */
81 #define PPA_PS2 2 /* PS/2 byte mode */
82 #define PPA_EPP_8 3 /* EPP mode, 8 bit */
83 #define PPA_EPP_16 4 /* EPP mode, 16 bit */
84 #define PPA_EPP_32 5 /* EPP mode, 32 bit */
85 #define PPA_UNKNOWN 6 /* Just in case... */
87 static char *PPA_MODE_STRING[] =
89 "Autodetect",
90 "SPP",
91 "PS/2",
92 "EPP 8 bit",
93 "EPP 16 bit",
94 #ifdef CONFIG_SCSI_IZIP_EPP16
95 "EPP 16 bit",
96 #else
97 "EPP 32 bit",
98 #endif
99 "Unknown"};
101 /* This is a global option */
102 int ppa_sg = SG_ALL; /* enable/disable scatter-gather. */
104 /* other options */
105 #define PPA_CAN_QUEUE 1 /* use "queueing" interface */
106 #define PPA_BURST_SIZE 512 /* data burst size */
107 #define PPA_SELECT_TMO 5000 /* how long to wait for target ? */
108 #define PPA_SPIN_TMO 50000 /* ppa_wait loop limiter */
109 #define PPA_DEBUG 0 /* debuging option */
110 #define IN_EPP_MODE(x) (x == PPA_EPP_8 || x == PPA_EPP_16 || x == PPA_EPP_32)
112 /* args to ppa_connect */
113 #define CONNECT_EPP_MAYBE 1
114 #define CONNECT_NORMAL 0
116 #define r_dtr(x) (unsigned char)inb((x))
117 #define r_str(x) (unsigned char)inb((x)+1)
118 #define r_ctr(x) (unsigned char)inb((x)+2)
119 #define r_epp(x) (unsigned char)inb((x)+4)
120 #define r_fifo(x) (unsigned char)inb((x)+0x400)
121 #define r_ecr(x) (unsigned char)inb((x)+0x402)
123 #define w_dtr(x,y) outb(y, (x))
124 #define w_str(x,y) outb(y, (x)+1)
125 #define w_epp(x,y) outb(y, (x)+4)
126 #define w_fifo(x,y) outb(y, (x)+0x400)
127 #define w_ecr(x,y) outb(y, (x)+0x402)
129 #ifdef CONFIG_SCSI_IZIP_SLOW_CTR
130 #define w_ctr(x,y) outb_p(y, (x)+2)
131 #else
132 #define w_ctr(x,y) outb(y, (x)+2)
133 #endif
135 static int ppa_engine(ppa_struct *, Scsi_Cmnd *);
136 static int ppa_in(int, char *, int);
137 static int ppa_init(int);
138 static void ppa_interrupt(void *);
139 static int ppa_out(int, char *, int);
141 struct proc_dir_entry proc_scsi_ppa =
142 {PROC_SCSI_PPA, 3, "ppa", S_IFDIR | S_IRUGO | S_IXUGO, 2};
143 #else
144 extern struct proc_dir_entry proc_scsi_ppa;
145 #define ppa_release 0
146 #endif
148 int ppa_detect(Scsi_Host_Template *);
149 const char *ppa_info(struct Scsi_Host *);
150 int ppa_command(Scsi_Cmnd *);
151 int ppa_queuecommand(Scsi_Cmnd *, void (*done) (Scsi_Cmnd *));
152 int ppa_abort(Scsi_Cmnd *);
153 int ppa_reset(Scsi_Cmnd *);
154 int ppa_proc_info(char *, char **, off_t, int, int, int);
155 int ppa_biosparam(Disk *, kdev_t, int *);
157 #define PPA { proc_dir: &proc_scsi_ppa, \
158 proc_info: ppa_proc_info, \
159 name: "Iomega VPI0 (ppa) interface",\
160 detect: ppa_detect, \
161 release: ppa_release, \
162 command: ppa_command, \
163 queuecommand: ppa_queuecommand, \
164 eh_abort_handler: ppa_abort, \
165 eh_device_reset_handler: NULL, \
166 eh_bus_reset_handler: ppa_reset, \
167 eh_host_reset_handler: ppa_reset, \
168 bios_param: ppa_biosparam, \
169 this_id: -1, \
170 sg_tablesize: SG_ALL, \
171 cmd_per_lun: 1, \
172 use_clustering: ENABLE_CLUSTERING \
174 #endif /* _PPA_H */