20 #define EPIA_VERSION "1.02"
22 #include <linux/module.h>
25 #include <linux/kernel.h>
26 #include <linux/types.h>
27 #include <linux/wait.h>
40 #define j44(a,b) (((a>>4)&0x0f)+(b&0xf0))
41 #define j53(a,b) (((a>>3)&0x1f)+((b<<4)&0xe0))
47 static int cont_map[2] = { 0, 0x80 };
49 static int epia_read_regr(
PIA *pi,
int cont,
int regr )
53 regr += cont_map[
cont];
57 case 0: r = regr^0x39;
62 case 1: r = regr^0x31;
68 case 2: r = regr^0x29;
75 case 5:
w3(regr);
w2(0x24); a =
r4();
w2(4);
82 static void epia_write_regr(
PIA *pi,
int cont,
int regr,
int val)
86 regr += cont_map[
cont];
92 case 2: r = regr^0x19;
98 case 5: r = regr^0x40;
104 #define WR(r,v) epia_write_regr(pi,0,r,v)
105 #define RR(r) (epia_read_regr(pi,0,r))
113 static void epia_connect (
PIA *pi )
122 w2(0x24);
w2(0x26);
w2(4);
127 static void epia_disconnect (
PIA *pi )
136 static void epia_read_block(
PIA *pi,
char *
buf,
int count )
142 case 0:
w0(0x81);
w2(1);
w2(3);
w0(0xc1);
144 for (k=0;k<
count;k++) {
153 case 1:
w0(0x91);
w2(1);
w0(0x10);
w2(3);
154 w0(0x51);
w2(5);
w0(0xd1);
156 for (k=0;k<
count;k++) {
165 case 2:
w0(0x89);
w2(1);
w2(0x23);
w2(0x21);
167 for (k=0;k<
count;k++) {
175 case 3:
if (count > 512)
WR(0x84,3);
177 for (k=0;k<
count;k++) buf[k] =
r4();
181 case 4:
if (count > 512)
WR(0x84,3);
183 for (k=0;k<count/2;k++) ((
u16 *)buf)[
k] =
r4w();
187 case 5:
if (count > 512)
WR(0x84,3);
189 for (k=0;k<count/4;k++) ((
u32 *)buf)[
k] =
r4l();
196 static void epia_write_block(
PIA *pi,
char * buf,
int count )
205 ph = 0; last = 0x8000;
206 for (k=0;k<
count;k++) {
208 if (d != last) { last =
d;
w0(d); }
215 case 3:
if (count < 512)
WR(0x84,1);
217 for (k=0;k<
count;k++)
w4(buf[k]);
218 if (count < 512)
WR(0x84,0);
221 case 4:
if (count < 512)
WR(0x84,1);
223 for (k=0;k<count/2;k++)
w4w(((
u16 *)buf)[k]);
224 if (count < 512)
WR(0x84,0);
227 case 5:
if (count < 512)
WR(0x84,1);
229 for (k=0;k<count/4;k++)
w4l(((
u32 *)buf)[k]);
230 if (count < 512)
WR(0x84,0);
245 for (k=0;k<256;k++) {
248 if (
RR(2) != (k^0xaa)) e[
j]++;
257 epia_read_block(pi,scratch,512);
258 for (k=0;k<256;k++) {
259 if ((scratch[2*k] & 0xff) != ((k+1) & 0xff)) f++;
260 if ((scratch[2*k+1] & 0xff) != ((-2-k) & 0xff)) f++;
266 printk(
"%s: epia: port 0x%x, mode %d, test=(%d,%d,%d)\n",
270 return (e[0] && e[1]) ||
f;
275 static void epia_log_adapter(
PIA *pi,
char * scratch,
int verbose )
277 {
char *mode_string[6] = {
"4-bit",
"5/3",
"8-bit",
278 "EPP-8",
"EPP-16",
"EPP-32"};
280 printk(
"%s: epia %s, Shuttle EPIA at 0x%x, ",
294 .write_regr = epia_write_regr,
295 .read_regr = epia_read_regr,
296 .write_block = epia_write_block,
297 .read_block = epia_read_block,
298 .connect = epia_connect,
299 .disconnect = epia_disconnect,
300 .test_proto = epia_test_proto,
301 .log_adapter = epia_log_adapter,
304 static int __init epia_init(
void)
309 static void __exit epia_exit(
void)