19 #define EPAT_VERSION "1.02"
21 #include <linux/module.h>
24 #include <linux/kernel.h>
25 #include <linux/types.h>
26 #include <linux/wait.h>
31 #define j44(a,b) (((a>>4)&0x0f)+(b&0xf0))
32 #define j53(a,b) (((a>>3)&0x1f)+((b<<4)&0xe0))
38 "used in any recent Imation SuperDisk (LS-120) drive.");
45 static int cont_map[3] = { 0x18, 0x10, 0 };
51 r = regr + cont_map[
cont];
57 case 2:
w0(0x60+r);
w2(1);
w0(val);
w2(4);
62 case 5:
w3(0x40+r);
w4(val);
68 static int epat_read_regr(
PIA *pi,
int cont,
int regr )
72 r = regr + cont_map[
cont];
76 case 0:
w0(r);
w2(1);
w2(3);
80 case 1:
w0(0x40+r);
w2(1);
w2(4);
81 a =
r1(); b =
r2();
w0(0xff);
84 case 2:
w0(0x20+r);
w2(1);
w2(0x25);
90 case 5:
w3(r);
w2(0x24); a =
r4();
w2(4);
97 static void epat_read_block(
PIA *pi,
char *
buf,
int count )
103 case 0:
w0(7);
w2(1);
w2(3);
w0(0xff);
105 for(k=0;k<
count;k++) {
106 if (k == count-1)
w0(0xfd);
109 else {
w2(4+ph); b =
r1(); }
116 case 1:
w0(0x47);
w2(1);
w2(5);
w0(0xff);
118 for(k=0;k<
count;k++) {
119 if (k == count-1)
w0(0xfd);
128 case 2:
w0(0x27);
w2(1);
w2(0x25);
w0(0);
130 for(k=0;k<count-1;k++) {
135 w2(0x26);
w2(0x27); buf[count-1] =
r0();
139 case 3:
w3(0x80);
w2(0x24);
140 for(k=0;k<count-1;k++) buf[k] =
r4();
141 w2(4);
w3(0xa0);
w2(0x24); buf[count-1] =
r4();
145 case 4:
w3(0x80);
w2(0x24);
146 for(k=0;k<(count/2)-1;k++) ((
u16 *)
buf)[k] =
r4w();
148 w2(4);
w3(0xa0);
w2(0x24); buf[count-1] =
r4();
152 case 5:
w3(0x80);
w2(0x24);
153 for(k=0;k<(count/4)-1;k++) ((
u32 *)
buf)[k] =
r4l();
154 for(k=count-4;k<count-1;k++) buf[k] =
r4();
155 w2(4);
w3(0xa0);
w2(0x24); buf[count-1] =
r4();
162 static void epat_write_block(
PIA *pi,
char * buf,
int count )
170 case 2:
w0(0x67);
w2(1);
w2(5);
172 for(k=0;k<
count;k++) {
181 for(k=0;k<
count;k++)
w4(buf[k]);
186 for(k=0;k<(count/2);k++)
w4w(((
u16 *)buf)[
k]);
191 for(k=0;k<(count/4);k++)
w4l(((
u32 *)buf)[
k]);
200 #define WR(r,v) epat_write_regr(pi,2,r,v)
201 #define RR(r) (epat_read_regr(pi,2,r))
205 #define WRi(r,v) epat_write_regr(pi,0,r,v)
206 #define RRi(r) (epat_read_regr(pi,0,r))
210 #define CPP(x) w2(4);w0(0x22);w0(0xaa);w0(0x55);w0(0);w0(0xff);\
211 w0(0x87);w0(0x78);w0(x);w2(4);w2(5);w2(4);w0(0xff);
213 static void epat_connect (
PIA *pi )
224 WR(0x8,0x12);
WR(0
xc,0x14);
WR(0x12,0x10);
241 WR(8,0x10);
WR(0
xc,0x14);
WR(0xa,0x38);
WR(0x12,0x10);
245 static void epat_disconnect (
PIA *pi)
263 for (k=0;k<256;k++) {
266 if (
RRi(2) != (k^0xaa)) e[
j]++;
273 WR(0x13,1);
WR(0x13,0);
WR(0xa,0x11);
274 epat_read_block(pi,scratch,512);
276 for (k=0;k<256;k++) {
277 if ((scratch[2*k] & 0xff) != k) f++;
278 if ((scratch[2*k+1] & 0xff) != (0xff-k)) f++;
283 printk(
"%s: epat: port 0x%x, mode %d, ccr %x, test=(%d,%d,%d)\n",
287 return (e[0] && e[1]) ||
f;
290 static void epat_log_adapter(
PIA *pi,
char * scratch,
int verbose )
293 char *mode_string[6] =
294 {
"4-bit",
"5/3",
"8-bit",
"EPP-8",
"EPP-16",
"EPP-32"};
301 printk(
"%s: epat %s, Shuttle EPAT chip %x at 0x%x, ",
315 .write_regr = epat_write_regr,
316 .read_regr = epat_read_regr,
317 .write_block = epat_write_block,
318 .read_block = epat_read_block,
319 .connect = epat_connect,
320 .disconnect = epat_disconnect,
321 .test_proto = epat_test_proto,
322 .log_adapter = epat_log_adapter,
325 static int __init epat_init(
void)
327 #ifdef CONFIG_PARIDE_EPATC8
333 static void __exit epat_exit(
void)