2 aten.c (c) 1997-8 Grant R. Guenther <grant@torque.net>
3 Under the terms of the GNU General Public License.
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.
12 #include <linux/module.h>
13 #include <linux/init.h>
14 #include <linux/delay.h>
15 #include <linux/kernel.h>
16 #include <linux/wait.h>
17 #include <linux/types.h>
19 #include "pata_parport.h"
21 #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
27 static int cont_map[2] = { 0x08, 0x20 };
29 static void aten_write_regr(struct pi_adapter *pi, int cont, int regr, int val)
33 r = regr + cont_map[cont] + 0x80;
35 w0(r); w2(0xe); w2(6); w0(val); w2(7); w2(6); w2(0xc);
38 static int aten_read_regr(struct pi_adapter *pi, int cont, int regr)
42 r = regr + cont_map[cont] + 0x40;
46 case 0: w0(r); w2(0xe); w2(6);
48 a = r1(); w0(0x10); b = r1(); w2(0xc);
52 w0(r); w2(0xe); w2(6); w0(0xff);
53 w2(0x27); w2(0x26); w2(0x20);
61 static void aten_read_block(struct pi_adapter *pi, char *buf, int count)
67 case 0: 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();
73 buf[2*k+1] = j44(a,b);
78 case 1: w0(0x58); w2(0xe); w2(6);
79 for (k=0;k<count/2;k++) {
80 w2(0x27); w2(0x26); w2(0x22);
81 a = r0(); w2(0x20); b = r0();
82 buf[2*k] = b; buf[2*k+1] = a;
89 static void aten_write_block(struct pi_adapter *pi, char *buf, int count)
93 w0(0x88); w2(0xe); w2(6);
94 for (k=0;k<count/2;k++) {
95 w0(buf[2*k+1]); w2(0xe); w2(6);
96 w0(buf[2*k]); w2(7); w2(6);
101 static void aten_connect(struct pi_adapter *pi)
103 { pi->saved_r0 = r0();
108 static void aten_disconnect(struct pi_adapter *pi)
114 static void aten_log_adapter(struct pi_adapter *pi)
116 { char *mode_string[2] = {"4-bit","8-bit"};
118 dev_info(&pi->dev, "ATEN EH-100 at 0x%x, mode %d (%s), delay %d\n",
119 pi->port, pi->mode, mode_string[pi->mode], pi->delay);
122 static struct pi_protocol aten = {
123 .owner = THIS_MODULE,
129 .write_regr = aten_write_regr,
130 .read_regr = aten_read_regr,
131 .write_block = aten_write_block,
132 .read_block = aten_read_block,
133 .connect = aten_connect,
134 .disconnect = aten_disconnect,
135 .log_adapter = aten_log_adapter,
138 MODULE_LICENSE("GPL");
139 module_pata_parport_driver(aten);