1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * (c) 1998 Grant R. Guenther <grant@torque.net>
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_.
11 #include <linux/module.h>
12 #include <linux/init.h>
13 #include <linux/delay.h>
14 #include <linux/kernel.h>
15 #include <linux/types.h>
16 #include <linux/wait.h>
18 #include "pata_parport.h"
20 #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
26 static int cont_map
[2] = { 0x10, 0x08 };
28 static void ktti_write_regr(struct pi_adapter
*pi
, int cont
, int regr
, int val
)
30 int r
= regr
+ cont_map
[cont
];
32 w0(r
); w2(0xb); w2(0xa); w2(3); w2(6);
33 w0(val
); w2(3); w0(0); w2(6); w2(0xb);
36 static int ktti_read_regr(struct pi_adapter
*pi
, int cont
, int regr
)
40 r
= regr
+ cont_map
[cont
];
42 w0(r
); w2(0xb); w2(0xa); w2(9); w2(0xc); w2(9);
43 a
= r1(); w2(0xc); b
= r1(); w2(9); w2(0xc); w2(9);
47 static void ktti_read_block(struct pi_adapter
*pi
, char *buf
, int count
)
51 for (k
= 0; k
< count
/ 2; k
++) {
52 w0(0x10); w2(0xb); w2(0xa); w2(9); w2(0xc); w2(9);
53 a
= r1(); w2(0xc); b
= r1(); w2(9);
55 a
= r1(); w2(0xc); b
= r1(); w2(9);
56 buf
[2*k
+1] = j44(a
, b
);
60 static void ktti_write_block(struct pi_adapter
*pi
, char *buf
, int count
)
64 for (k
= 0; k
< count
/ 2; k
++) {
65 w0(0x10); w2(0xb); w2(0xa); w2(3); w2(6);
66 w0(buf
[2 * k
]); w2(3);
67 w0(buf
[2 * k
+ 1]); w2(6);
72 static void ktti_connect(struct pi_adapter
*pi
)
76 w2(0xb); w2(0xa); w0(0); w2(3); w2(6);
79 static void ktti_disconnect(struct pi_adapter
*pi
)
81 w2(0xb); w2(0xa); w0(0xa0); w2(3); w2(4);
86 static void ktti_log_adapter(struct pi_adapter
*pi
)
88 dev_info(&pi
->dev
, "KT adapter at 0x%x, delay %d\n",
92 static struct pi_protocol ktti
= {
99 .write_regr
= ktti_write_regr
,
100 .read_regr
= ktti_read_regr
,
101 .write_block
= ktti_write_block
,
102 .read_block
= ktti_read_block
,
103 .connect
= ktti_connect
,
104 .disconnect
= ktti_disconnect
,
105 .log_adapter
= ktti_log_adapter
,
108 MODULE_LICENSE("GPL");
109 MODULE_AUTHOR("Grant R. Guenther <grant@torque.net>");
110 MODULE_DESCRIPTION("KT Technology parallel port IDE adapter protocol driver");
111 module_pata_parport_driver(ktti
);