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.
14 1.01 GRG 1998.05.05 init_proto, release_proto
18 #define ATEN_VERSION "1.01"
20 #include <linux/module.h>
21 #include <linux/init.h>
22 #include <linux/delay.h>
23 #include <linux/kernel.h>
24 #include <linux/wait.h>
25 #include <linux/types.h>
30 #define j44(a,b) ((((a>>4)&0x0f)|(b&0xf0))^0x88)
32 /* cont = 0 - access the IDE register file
33 cont = 1 - access the IDE command set
36 static int cont_map
[2] = { 0x08, 0x20 };
38 static void aten_write_regr( PIA
*pi
, int cont
, int regr
, int val
)
42 r
= regr
+ cont_map
[cont
] + 0x80;
44 w0(r
); w2(0xe); w2(6); w0(val
); w2(7); w2(6); w2(0xc);
47 static int aten_read_regr( PIA
*pi
, int cont
, int regr
)
51 r
= regr
+ cont_map
[cont
] + 0x40;
55 case 0: w0(r
); w2(0xe); w2(6);
57 a
= r1(); w0(0x10); b
= r1(); w2(0xc);
61 w0(r
); w2(0xe); w2(6); w0(0xff);
62 w2(0x27); w2(0x26); w2(0x20);
70 static void aten_read_block( PIA
*pi
, char * buf
, int count
)
76 case 0: w0(0x48); w2(0xe); w2(6);
77 for (k
=0;k
<count
/2;k
++) {
79 a
= r1(); w0(0x58); b
= r1();
80 w2(0); d
= r1(); w0(0x48); c
= r1();
82 buf
[2*k
+1] = j44(a
,b
);
87 case 1: w0(0x58); w2(0xe); w2(6);
88 for (k
=0;k
<count
/2;k
++) {
89 w2(0x27); w2(0x26); w2(0x22);
90 a
= r0(); w2(0x20); b
= r0();
91 buf
[2*k
] = b
; buf
[2*k
+1] = a
;
98 static void aten_write_block( PIA
*pi
, char * buf
, int count
)
102 w0(0x88); w2(0xe); w2(6);
103 for (k
=0;k
<count
/2;k
++) {
104 w0(buf
[2*k
+1]); w2(0xe); w2(6);
105 w0(buf
[2*k
]); w2(7); w2(6);
110 static void aten_connect ( PIA
*pi
)
112 { pi
->saved_r0
= r0();
117 static void aten_disconnect ( PIA
*pi
)
123 static void aten_log_adapter( PIA
*pi
, char * scratch
, int verbose
)
125 { char *mode_string
[2] = {"4-bit","8-bit"};
127 printk("%s: aten %s, ATEN EH-100 at 0x%x, ",
128 pi
->device
,ATEN_VERSION
,pi
->port
);
129 printk("mode %d (%s), delay %d\n",pi
->mode
,
130 mode_string
[pi
->mode
],pi
->delay
);
134 static struct pi_protocol aten
= {
135 .owner
= THIS_MODULE
,
141 .write_regr
= aten_write_regr
,
142 .read_regr
= aten_read_regr
,
143 .write_block
= aten_write_block
,
144 .read_block
= aten_read_block
,
145 .connect
= aten_connect
,
146 .disconnect
= aten_disconnect
,
147 .log_adapter
= aten_log_adapter
,
150 static int __init
aten_init(void)
152 return paride_register(&aten
);
155 static void __exit
aten_exit(void)
157 paride_unregister( &aten
);
160 MODULE_LICENSE("GPL");
161 module_init(aten_init
)
162 module_exit(aten_exit
)