1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * (c) 1997-8 Grant R. Guenther <grant@torque.net>
5 * aten.c is a low-level protocol driver for the ATEN EH-100
6 * parallel port adapter. The EH-100 supports 4-bit and 8-bit
7 * modes only. There is also an EH-132 which supports EPP mode
8 * transfers. The EH-132 is not yet supported.
11 #include <linux/module.h>
12 #include <linux/init.h>
13 #include <linux/delay.h>
14 #include <linux/kernel.h>
15 #include <linux/wait.h>
16 #include <linux/types.h>
18 #include "pata_parport.h"
20 #define j44(a,b) ((((a>>4)&0x0f)|(b&0xf0))^0x88)
23 * cont = 0 - access the IDE register file
24 * cont = 1 - access the IDE command set
26 static int cont_map[2] = { 0x08, 0x20 };
28 static void aten_write_regr(struct pi_adapter *pi, int cont, int regr, int val)
30 int r = regr + cont_map[cont] + 0x80;
32 w0(r); w2(0xe); w2(6); w0(val); w2(7); w2(6); w2(0xc);
35 static int aten_read_regr(struct pi_adapter *pi, int cont, int regr)
39 r = regr + cont_map[cont] + 0x40;
44 w0(r); w2(0xe); w2(6);
46 a = r1(); w0(0x10); b = r1(); w2(0xc);
51 w0(r); w2(0xe); w2(6); w0(0xff);
52 w2(0x27); w2(0x26); w2(0x20);
60 static void aten_read_block(struct pi_adapter *pi, char *buf, int count)
67 w0(0x48); w2(0xe); w2(6);
68 for (k = 0; k < count / 2; k++) {
70 a = r1(); w0(0x58); b = r1();
71 w2(0); d = r1(); w0(0x48); c = r1();
72 buf[2 * k] = j44(c, d);
73 buf[2 * k + 1] = j44(a, b);
79 w0(0x58); w2(0xe); w2(6);
80 for (k = 0; k < count / 2; k++) {
81 w2(0x27); w2(0x26); w2(0x22);
82 a = r0(); w2(0x20); b = r0();
91 static void aten_write_block(struct pi_adapter *pi, char *buf, int count)
95 w0(0x88); w2(0xe); w2(6);
96 for (k = 0; k < count / 2; k++) {
97 w0(buf[2 * k + 1]); w2(0xe); w2(6);
98 w0(buf[2 * k]); w2(7); w2(6);
103 static void aten_connect(struct pi_adapter *pi)
110 static void aten_disconnect(struct pi_adapter *pi)
116 static void aten_log_adapter(struct pi_adapter *pi)
118 char *mode_string[2] = { "4-bit", "8-bit" };
121 "ATEN EH-100 at 0x%x, mode %d (%s), delay %d\n",
122 pi->port, pi->mode, mode_string[pi->mode], pi->delay);
125 static struct pi_protocol aten = {
126 .owner = THIS_MODULE,
132 .write_regr = aten_write_regr,
133 .read_regr = aten_read_regr,
134 .write_block = aten_write_block,
135 .read_block = aten_read_block,
136 .connect = aten_connect,
137 .disconnect = aten_disconnect,
138 .log_adapter = aten_log_adapter,
141 MODULE_LICENSE("GPL");
142 MODULE_AUTHOR("Grant R. Guenther <grant@torque.net>");
143 MODULE_DESCRIPTION("ATEN EH-100 parallel port IDE adapter protocol driver");
144 module_pata_parport_driver(aten);