Back to home page

OSCL-LXR

 
 

    


0001 /* 
0002         fit2.c        (c) 1998  Grant R. Guenther <grant@torque.net>
0003                           Under the terms of the GNU General Public License.
0004 
0005     fit2.c is a low-level protocol driver for the older version
0006         of the Fidelity International Technology parallel port adapter.  
0007     This adapter is used in their TransDisk 2000 and older TransDisk
0008     3000 portable hard-drives.  As far as I can tell, this device
0009     supports 4-bit mode _only_.  
0010 
0011     Newer models of the FIT products use an enhanced protocol.
0012     The "fit3" protocol module should support current drives.
0013 
0014 */
0015 
0016 #define FIT2_VERSION      "1.0"
0017 
0018 #include <linux/module.h>
0019 #include <linux/init.h>
0020 #include <linux/delay.h>
0021 #include <linux/kernel.h>
0022 #include <linux/types.h>
0023 #include <linux/wait.h>
0024 #include <asm/io.h>
0025 
0026 #include "paride.h"
0027 
0028 #define j44(a,b)                (((a>>4)&0x0f)|(b&0xf0))
0029 
0030 /* cont = 0 - access the IDE register file 
0031    cont = 1 - access the IDE command set 
0032 
0033 NB:  The FIT adapter does not appear to use the control registers.
0034 So, we map ALT_STATUS to STATUS and NO-OP writes to the device
0035 control register - this means that IDE reset will not work on these
0036 devices.
0037 
0038 */
0039 
0040 static void  fit2_write_regr( PIA *pi, int cont, int regr, int val)
0041 
0042 {   if (cont == 1) return;
0043     w2(0xc); w0(regr); w2(4); w0(val); w2(5); w0(0); w2(4);
0044 }
0045 
0046 static int fit2_read_regr( PIA *pi, int cont, int regr )
0047 
0048 {   int  a, b, r;
0049 
0050     if (cont) {
0051       if (regr != 6) return 0xff;
0052       r = 7;
0053     } else r = regr + 0x10;
0054 
0055     w2(0xc); w0(r); w2(4); w2(5); 
0056              w0(0); a = r1();
0057              w0(1); b = r1();
0058     w2(4);
0059 
0060     return j44(a,b);
0061 
0062 }
0063 
0064 static void fit2_read_block( PIA *pi, char * buf, int count )
0065 
0066 {   int  k, a, b, c, d;
0067 
0068     w2(0xc); w0(0x10);
0069 
0070     for (k=0;k<count/4;k++) {
0071 
0072         w2(4); w2(5);
0073         w0(0); a = r1(); w0(1); b = r1();
0074         w0(3); c = r1(); w0(2); d = r1(); 
0075         buf[4*k+0] = j44(a,b);
0076         buf[4*k+1] = j44(d,c);
0077 
0078                 w2(4); w2(5);
0079                        a = r1(); w0(3); b = r1();
0080                 w0(1); c = r1(); w0(0); d = r1(); 
0081                 buf[4*k+2] = j44(d,c);
0082                 buf[4*k+3] = j44(a,b);
0083 
0084     }
0085 
0086     w2(4);
0087 
0088 }
0089 
0090 static void fit2_write_block( PIA *pi, char * buf, int count )
0091 
0092 {   int k;
0093 
0094 
0095     w2(0xc); w0(0); 
0096     for (k=0;k<count/2;k++) {
0097         w2(4); w0(buf[2*k]); 
0098         w2(5); w0(buf[2*k+1]);
0099     }
0100     w2(4);
0101 }
0102 
0103 static void fit2_connect ( PIA *pi  )
0104 
0105 {       pi->saved_r0 = r0();
0106         pi->saved_r2 = r2();
0107     w2(0xcc); 
0108 }
0109 
0110 static void fit2_disconnect ( PIA *pi )
0111 
0112 {       w0(pi->saved_r0);
0113         w2(pi->saved_r2);
0114 } 
0115 
0116 static void fit2_log_adapter( PIA *pi, char * scratch, int verbose )
0117 
0118 {       printk("%s: fit2 %s, FIT 2000 adapter at 0x%x, delay %d\n",
0119                 pi->device,FIT2_VERSION,pi->port,pi->delay);
0120 
0121 }
0122 
0123 static struct pi_protocol fit2 = {
0124     .owner      = THIS_MODULE,
0125     .name       = "fit2",
0126     .max_mode   = 1,
0127     .epp_first  = 2,
0128     .default_delay  = 1,
0129     .max_units  = 1,
0130     .write_regr = fit2_write_regr,
0131     .read_regr  = fit2_read_regr,
0132     .write_block    = fit2_write_block,
0133     .read_block = fit2_read_block,
0134     .connect    = fit2_connect,
0135     .disconnect = fit2_disconnect,
0136     .log_adapter    = fit2_log_adapter,
0137 };
0138 
0139 static int __init fit2_init(void)
0140 {
0141     return paride_register(&fit2);
0142 }
0143 
0144 static void __exit fit2_exit(void)
0145 {
0146     paride_unregister(&fit2);
0147 }
0148 
0149 MODULE_LICENSE("GPL");
0150 module_init(fit2_init)
0151 module_exit(fit2_exit)