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/init.h>
24 #include <linux/delay.h>
25 #include <linux/kernel.h>
26 #include <linux/types.h>
27 #include <linux/wait.h>
32 #define j44(a,b) (((a>>3)&0x0f)|((b<<1)&0xf0))
34 #define w7(byte) {out_p(7,byte);}
35 #define r7() (in_p(7) & 0xff)
37 /* cont = 0 - access the IDE register file
38 cont = 1 - access the IDE command set
42 static void fit3_write_regr( PIA
*pi
, int cont
, int regr
, int val
)
44 { if (cont
== 1) return;
49 case 1: w2(0xc); w0(regr
); w2(0x8); w2(0xc);
54 case 2: w2(0xc); w0(regr
); w2(0x8); w2(0xc);
62 static int fit3_read_regr( PIA
*pi
, int cont
, int regr
)
67 if (regr
!= 6) return 0xff;
73 case 0: w2(0xc); w0(regr
+ 0x10); w2(0x8); w2(0xc);
79 case 1: w2(0xc); w0(regr
+ 0x90); w2(0x8); w2(0xc);
80 w2(0xec); w2(0xee); w2(0xef); a
= r0();
84 case 2: w2(0xc); w0(regr
+ 0x90); w2(0x8); w2(0xc);
95 static void fit3_read_block( PIA
*pi
, char * buf
, int count
)
101 case 0: w2(0xc); w0(0x10); w2(0x8); w2(0xc);
102 for (k
=0;k
<count
/2;k
++) {
107 buf
[2*k
] = j44(a
,b
);
108 buf
[2*k
+1] = j44(c
,d
);
113 case 1: w2(0xc); w0(0x90); w2(0x8); w2(0xc);
115 for (k
=0;k
<count
/2;k
++) {
125 case 2: w2(0xc); w0(0x90); w2(0x8); w2(0xc);
127 for (k
=0;k
<count
;k
++) buf
[k
] = r4();
134 static void fit3_write_block( PIA
*pi
, char * buf
, int count
)
141 case 1: w2(0xc); w0(0); w2(0x8); w2(0xc);
142 for (k
=0;k
<count
/2;k
++) {
143 w0(buf
[2*k
]); w2(0xd);
144 w0(buf
[2*k
+1]); w2(0xc);
148 case 2: w2(0xc); w0(0); w2(0x8); w2(0xc);
149 for (k
=0;k
<count
;k
++) w4(buf
[k
]);
155 static void fit3_connect ( PIA
*pi
)
157 { pi
->saved_r0
= r0();
159 w2(0xc); w0(0); w2(0xa);
161 w2(0xc); w0(0x9); w2(0x8); w2(0xc);
165 static void fit3_disconnect ( PIA
*pi
)
167 { w2(0xc); w0(0xa); w2(0x8); w2(0xc);
172 static void fit3_log_adapter( PIA
*pi
, char * scratch
, int verbose
)
174 { char *mode_string
[3] = {"4-bit","8-bit","EPP"};
176 printk("%s: fit3 %s, FIT 3000 adapter at 0x%x, "
177 "mode %d (%s), delay %d\n",
178 pi
->device
,FIT3_VERSION
,pi
->port
,
179 pi
->mode
,mode_string
[pi
->mode
],pi
->delay
);
183 static struct pi_protocol fit3
= {
184 .owner
= THIS_MODULE
,
190 .write_regr
= fit3_write_regr
,
191 .read_regr
= fit3_read_regr
,
192 .write_block
= fit3_write_block
,
193 .read_block
= fit3_read_block
,
194 .connect
= fit3_connect
,
195 .disconnect
= fit3_disconnect
,
196 .log_adapter
= fit3_log_adapter
,
199 static int __init
fit3_init(void)
201 return pi_register(&fit3
)-1;
204 static void __exit
fit3_exit(void)
206 pi_unregister(&fit3
);
209 MODULE_LICENSE("GPL");
210 module_init(fit3_init
)
211 module_exit(fit3_exit
)