2 fit3.c (c) 1998 Grant R. Guenther <grant@torque.net>
3 Under the terms of the GNU General Public License.
5 fit3.c is a low-level protocol driver for newer models
6 of the Fidelity International Technology parallel port adapter.
7 This adapter is used in their TransDisk 3000 portable
8 hard-drives, as well as CD-ROM, PD-CD and other devices.
10 The TD-2000 and certain older devices use a different protocol.
11 Try the fit2 protocol module with them.
13 NB: The FIT adapters do not appear to support the control
14 registers. So, we map ALT_STATUS to STATUS and NO-OP writes
15 to the device control register - this means that IDE reset
16 will not work on these devices.
20 #define FIT3_VERSION "1.0"
22 #include <linux/module.h>
23 #include <linux/delay.h>
24 #include <linux/kernel.h>
25 #include <linux/types.h>
26 #include <linux/wait.h>
31 #define j44(a,b) (((a>>3)&0x0f)|((b<<1)&0xf0))
33 #define w7(byte) {out_p(7,byte);}
34 #define r7() (in_p(7) & 0xff)
36 /* cont = 0 - access the IDE register file
37 cont = 1 - access the IDE command set
41 static void fit3_write_regr( PIA *pi, int cont, int regr, int val)
43 { if (cont == 1) return;
48 case 1: w2(0xc); w0(regr); w2(0x8); w2(0xc);
53 case 2: w2(0xc); w0(regr); w2(0x8); w2(0xc);
61 static int fit3_read_regr( PIA *pi, int cont, int regr )
66 if (regr != 6) return 0xff;
72 case 0: w2(0xc); w0(regr + 0x10); w2(0x8); w2(0xc);
78 case 1: w2(0xc); w0(regr + 0x90); w2(0x8); w2(0xc);
79 w2(0xec); w2(0xee); w2(0xef); a = r0();
83 case 2: w2(0xc); w0(regr + 0x90); w2(0x8); w2(0xc);
94 static void fit3_read_block( PIA *pi, char * buf, int count )
100 case 0: w2(0xc); w0(0x10); w2(0x8); w2(0xc);
101 for (k=0;k<count/2;k++) {
106 buf[2*k ] = j44(a,b);
107 buf[2*k+1] = j44(c,d);
112 case 1: w2(0xc); w0(0x90); w2(0x8); w2(0xc);
114 for (k=0;k<count/2;k++) {
124 case 2: w2(0xc); w0(0x90); w2(0x8); w2(0xc);
126 for (k=0;k<count;k++) buf[k] = r4();
133 static void fit3_write_block( PIA *pi, char * buf, int count )
140 case 1: w2(0xc); w0(0); w2(0x8); w2(0xc);
141 for (k=0;k<count/2;k++) {
142 w0(buf[2*k ]); w2(0xd);
143 w0(buf[2*k+1]); w2(0xc);
147 case 2: w2(0xc); w0(0); w2(0x8); w2(0xc);
148 for (k=0;k<count;k++) w4(buf[k]);
154 static void fit3_connect ( PIA *pi )
156 { pi->saved_r0 = r0();
158 w2(0xc); w0(0); w2(0xa);
160 w2(0xc); w0(0x9); w2(0x8); w2(0xc);
164 static void fit3_disconnect ( PIA *pi )
166 { w2(0xc); w0(0xa); w2(0x8); w2(0xc);
171 static void fit3_log_adapter( PIA *pi, char * scratch, int verbose )
173 { char *mode_string[3] = {"4-bit","8-bit","EPP"};
175 printk("%s: fit3 %s, FIT 3000 adapter at 0x%x, "
176 "mode %d (%s), delay %d\n",
177 pi->device,FIT3_VERSION,pi->port,
178 pi->mode,mode_string[pi->mode],pi->delay);
182 static void fit3_init_proto(PIA *pi)
187 static void fit3_release_proto(PIA *pi)
192 struct pi_protocol fit3 = {"fit3",0,3,2,1,1,
210 int init_module(void)
212 { return pi_register( &fit3 ) - 1;
215 void cleanup_module(void)
217 { pi_unregister( &fit3 );
223 MODULE_LICENSE("GPL");