2 fit2.c (c) 1998 Grant R. Guenther <grant@torque.net>
3 Under the terms of the GNU General Public License.
5 fit2.c is a low-level protocol driver for the older version
6 of the Fidelity International Technology parallel port adapter.
7 This adapter is used in their TransDisk 2000 and older TransDisk
8 3000 portable hard-drives. As far as I can tell, this device
9 supports 4-bit mode _only_.
11 Newer models of the FIT products use an enhanced protocol.
12 The "fit3" protocol module should support current drives.
16 #define FIT2_VERSION "1.0"
18 #include <linux/module.h>
19 #include <linux/delay.h>
20 #include <linux/kernel.h>
21 #include <linux/types.h>
22 #include <linux/wait.h>
27 #define j44(a,b) (((a>>4)&0x0f)|(b&0xf0))
29 /* cont = 0 - access the IDE register file
30 cont = 1 - access the IDE command set
32 NB: The FIT adapter does not appear to use the control registers.
33 So, we map ALT_STATUS to STATUS and NO-OP writes to the device
34 control register - this means that IDE reset will not work on these
39 static void fit2_write_regr( PIA *pi, int cont, int regr, int val)
41 { if (cont == 1) return;
42 w2(0xc); w0(regr); w2(4); w0(val); w2(5); w0(0); w2(4);
45 static int fit2_read_regr( PIA *pi, int cont, int regr )
50 if (regr != 6) return 0xff;
52 } else r = regr + 0x10;
54 w2(0xc); w0(r); w2(4); w2(5);
63 static void fit2_read_block( PIA *pi, char * buf, int count )
69 for (k=0;k<count/4;k++) {
72 w0(0); a = r1(); w0(1); b = r1();
73 w0(3); c = r1(); w0(2); d = r1();
74 buf[4*k+0] = j44(a,b);
75 buf[4*k+1] = j44(d,c);
78 a = r1(); w0(3); b = r1();
79 w0(1); c = r1(); w0(0); d = r1();
80 buf[4*k+2] = j44(d,c);
81 buf[4*k+3] = j44(a,b);
89 static void fit2_write_block( PIA *pi, char * buf, int count )
95 for (k=0;k<count/2;k++) {
97 w2(5); w0(buf[2*k+1]);
102 static void fit2_connect ( PIA *pi )
104 { pi->saved_r0 = r0();
109 static void fit2_disconnect ( PIA *pi )
115 static void fit2_log_adapter( PIA *pi, char * scratch, int verbose )
117 { printk("%s: fit2 %s, FIT 2000 adapter at 0x%x, delay %d\n",
118 pi->device,FIT2_VERSION,pi->port,pi->delay);
122 static void fit2_init_proto( PIA *pi)
127 static void fit2_release_proto( PIA *pi)
132 struct pi_protocol fit2 = {"fit2",0,1,2,1,1,
150 int init_module(void)
152 { return pi_register( &fit2 ) - 1;
155 void cleanup_module(void)
157 { pi_unregister( &fit2 );
163 MODULE_LICENSE("GPL");