1 // SPDX-License-Identifier: GPL-2.0-or-later
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.
19 #include <linux/module.h>
20 #include <linux/init.h>
21 #include <linux/delay.h>
22 #include <linux/kernel.h>
23 #include <linux/types.h>
24 #include <linux/wait.h>
26 #include "pata_parport.h"
28 #define j44(a, b) (((a >> 3) & 0x0f) | ((b << 1) & 0xf0))
30 #define w7(byte) out_p(7, byte)
31 #define r7() (in_p(7) & 0xff)
34 * cont = 0 - access the IDE register file
35 * cont = 1 - access the IDE command set
38 static void fit3_write_regr(struct pi_adapter *pi, int cont, int regr, int val)
46 w2(0xc); w0(regr); w2(0x8); w2(0xc);
51 w2(0xc); w0(regr); w2(0x8); w2(0xc);
58 static int fit3_read_regr(struct pi_adapter *pi, int cont, int regr)
70 w2(0xc); w0(regr + 0x10); w2(0x8); w2(0xc);
76 w2(0xc); w0(regr + 0x90); w2(0x8); w2(0xc);
77 w2(0xec); w2(0xee); w2(0xef); a = r0();
81 w2(0xc); w0(regr + 0x90); w2(0x8); w2(0xc);
91 static void fit3_read_block(struct pi_adapter *pi, char *buf, int count)
97 w2(0xc); w0(0x10); w2(0x8); w2(0xc);
98 for (k = 0; k < count / 2; k++) {
103 buf[2 * k] = j44(a, b);
104 buf[2 * k + 1] = j44(c, d);
109 w2(0xc); w0(0x90); w2(0x8); w2(0xc);
111 for (k = 0; k < count / 2; k++) {
121 w2(0xc); w0(0x90); w2(0x8); w2(0xc);
123 for (k = 0; k < count; k++)
130 static void fit3_write_block(struct pi_adapter *pi, char *buf, int count)
137 w2(0xc); w0(0); w2(0x8); w2(0xc);
138 for (k = 0; k < count / 2; k++) {
139 w0(buf[2 * k]); w2(0xd);
140 w0(buf[2 * k + 1]); w2(0xc);
144 w2(0xc); w0(0); w2(0x8); w2(0xc);
145 for (k = 0; k < count; k++)
152 static void fit3_connect(struct pi_adapter *pi)
156 w2(0xc); w0(0); w2(0xa);
163 static void fit3_disconnect(struct pi_adapter *pi)
165 w2(0xc); w0(0xa); w2(0x8); w2(0xc);
170 static void fit3_log_adapter(struct pi_adapter *pi)
172 char *mode_string[3] = { "4-bit", "8-bit", "EPP"};
175 "FIT 3000 adapter at 0x%x, mode %d (%s), delay %d\n",
176 pi->port, pi->mode, mode_string[pi->mode], pi->delay);
179 static struct pi_protocol fit3 = {
180 .owner = THIS_MODULE,
186 .write_regr = fit3_write_regr,
187 .read_regr = fit3_read_regr,
188 .write_block = fit3_write_block,
189 .read_block = fit3_read_block,
190 .connect = fit3_connect,
191 .disconnect = fit3_disconnect,
192 .log_adapter = fit3_log_adapter,
195 MODULE_LICENSE("GPL");
197 MODULE_DESCRIPTION("Fidelity International Technology parallel port IDE adapter"
198 "(newer models) protocol driver");
199 module_pata_parport_driver(fit3);