2 ktti.c (c) 1998 Grant R. Guenther <grant@torque.net>
3 Under the terms of the GNU General Public License.
5 ktti.c is a low-level protocol driver for the KT Technology
6 parallel port adapter. This adapter is used in the "PHd"
7 portable hard-drives. As far as I can tell, this device
8 supports 4-bit mode _only_.
12 #define KTTI_VERSION "1.0"
14 #include <linux/module.h>
15 #include <linux/init.h>
16 #include <linux/delay.h>
17 #include <linux/kernel.h>
18 #include <linux/types.h>
19 #include <linux/wait.h>
24 #define j44(a,b) (((a>>4)&0x0f)|(b&0xf0))
26 /* cont = 0 - access the IDE register file
27 cont = 1 - access the IDE command set
30 static int cont_map
[2] = { 0x10, 0x08 };
32 static void ktti_write_regr( PIA
*pi
, int cont
, int regr
, int val
)
36 r
= regr
+ cont_map
[cont
];
38 w0(r
); w2(0xb); w2(0xa); w2(3); w2(6);
39 w0(val
); w2(3); w0(0); w2(6); w2(0xb);
42 static int ktti_read_regr( PIA
*pi
, int cont
, int regr
)
46 r
= regr
+ cont_map
[cont
];
48 w0(r
); w2(0xb); w2(0xa); w2(9); w2(0xc); w2(9);
49 a
= r1(); w2(0xc); b
= r1(); w2(9); w2(0xc); w2(9);
54 static void ktti_read_block( PIA
*pi
, char * buf
, int count
)
58 for (k
=0;k
<count
/2;k
++) {
59 w0(0x10); w2(0xb); w2(0xa); w2(9); w2(0xc); w2(9);
60 a
= r1(); w2(0xc); b
= r1(); w2(9);
62 a
= r1(); w2(0xc); b
= r1(); w2(9);
63 buf
[2*k
+1] = j44(a
,b
);
67 static void ktti_write_block( PIA
*pi
, char * buf
, int count
)
71 for (k
=0;k
<count
/2;k
++) {
72 w0(0x10); w2(0xb); w2(0xa); w2(3); w2(6);
74 w0(buf
[2*k
+1]); w2(6);
79 static void ktti_connect ( PIA
*pi
)
81 { pi
->saved_r0
= r0();
83 w2(0xb); w2(0xa); w0(0); w2(3); w2(6);
86 static void ktti_disconnect ( PIA
*pi
)
88 { w2(0xb); w2(0xa); w0(0xa0); w2(3); w2(4);
93 static void ktti_log_adapter( PIA
*pi
, char * scratch
, int verbose
)
95 { printk("%s: ktti %s, KT adapter at 0x%x, delay %d\n",
96 pi
->device
,KTTI_VERSION
,pi
->port
,pi
->delay
);
100 static struct pi_protocol ktti
= {
101 .owner
= THIS_MODULE
,
107 .write_regr
= ktti_write_regr
,
108 .read_regr
= ktti_read_regr
,
109 .write_block
= ktti_write_block
,
110 .read_block
= ktti_read_block
,
111 .connect
= ktti_connect
,
112 .disconnect
= ktti_disconnect
,
113 .log_adapter
= ktti_log_adapter
,
116 static int __init
ktti_init(void)
118 return paride_register(&ktti
);
121 static void __exit
ktti_exit(void)
123 paride_unregister(&ktti
);
126 MODULE_LICENSE("GPL");
127 module_init(ktti_init
)
128 module_exit(ktti_exit
)