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 #include <linux/module.h>
13 #include <linux/init.h>
14 #include <linux/delay.h>
15 #include <linux/kernel.h>
16 #include <linux/types.h>
17 #include <linux/wait.h>
19 #include "pata_parport.h"
21 #define j44(a,b) (((a>>4)&0x0f)|(b&0xf0))
23 /* cont = 0 - access the IDE register file
24 cont = 1 - access the IDE command set
27 static int cont_map[2] = { 0x10, 0x08 };
29 static void ktti_write_regr(struct pi_adapter *pi, int cont, int regr, int val)
33 r = regr + cont_map[cont];
35 w0(r); w2(0xb); w2(0xa); w2(3); w2(6);
36 w0(val); w2(3); w0(0); w2(6); w2(0xb);
39 static int ktti_read_regr(struct pi_adapter *pi, int cont, int regr)
43 r = regr + cont_map[cont];
45 w0(r); w2(0xb); w2(0xa); w2(9); w2(0xc); w2(9);
46 a = r1(); w2(0xc); b = r1(); w2(9); w2(0xc); w2(9);
51 static void ktti_read_block(struct pi_adapter *pi, char *buf, int count)
55 for (k=0;k<count/2;k++) {
56 w0(0x10); w2(0xb); w2(0xa); w2(9); w2(0xc); w2(9);
57 a = r1(); w2(0xc); b = r1(); w2(9);
59 a = r1(); w2(0xc); b = r1(); w2(9);
60 buf[2*k+1] = j44(a,b);
64 static void ktti_write_block(struct pi_adapter *pi, char *buf, int count)
68 for (k=0;k<count/2;k++) {
69 w0(0x10); w2(0xb); w2(0xa); w2(3); w2(6);
71 w0(buf[2*k+1]); w2(6);
76 static void ktti_connect(struct pi_adapter *pi)
78 { pi->saved_r0 = r0();
80 w2(0xb); w2(0xa); w0(0); w2(3); w2(6);
83 static void ktti_disconnect(struct pi_adapter *pi)
85 { w2(0xb); w2(0xa); w0(0xa0); w2(3); w2(4);
90 static void ktti_log_adapter(struct pi_adapter *pi)
93 dev_info(&pi->dev, "KT adapter at 0x%x, delay %d\n",
97 static struct pi_protocol ktti = {
104 .write_regr = ktti_write_regr,
105 .read_regr = ktti_read_regr,
106 .write_block = ktti_write_block,
107 .read_block = ktti_read_block,
108 .connect = ktti_connect,
109 .disconnect = ktti_disconnect,
110 .log_adapter = ktti_log_adapter,
113 MODULE_LICENSE("GPL");
114 module_pata_parport_driver(ktti);