26 #define FRPW_VERSION "1.03"
28 #include <linux/module.h>
31 #include <linux/kernel.h>
32 #include <linux/types.h>
33 #include <linux/wait.h>
38 #define cec4 w2(0xc);w2(0xe);w2(0xe);w2(0xc);w2(4);w2(4);w2(4);
39 #define j44(l,h) (((l>>4)&0x0f)|(h&0xf0))
45 static int cont_map[2] = { 0x08, 0x10 };
47 static int frpw_read_regr(
PIA *pi,
int cont,
int regr )
51 r = regr + cont_map[
cont];
67 r = regr + cont_map[
cont];
74 static void frpw_read_block_int(
PIA *pi,
char *
buf,
int count,
int regr )
81 for (k=0;k<
count;k++) {
92 for (k=0;k<
count;k++) {
100 case 2:
w2(4);
w0(regr + 0x80);
cec4;
101 for (k=0;k<
count;k++) buf[k] =
r4();
106 case 3:
w2(4);
w0(regr + 0x80);
cec4;
107 for (k=0;k<count-2;k++) buf[k] =
r4();
114 case 4:
w2(4);
w0(regr + 0x80);
cec4;
115 for (k=0;k<(count/2)-1;k++) ((
u16 *)
buf)[k] =
r4w();
122 case 5:
w2(4);
w0(regr + 0x80);
cec4;
123 for (k=0;k<(count/4)-1;k++) ((
u32 *)
buf)[k] =
r4l();
135 static void frpw_read_block(
PIA *pi,
char * buf,
int count)
137 { frpw_read_block_int(pi,buf,count,0x08);
140 static void frpw_write_block(
PIA *pi,
char * buf,
int count )
149 for (k=0;k<
count;k++) {
157 for (k=0;k<
count;k++)
w4(buf[k]);
162 for (k=0;k<count/2;k++)
w4w(((
u16 *)buf)[k]);
167 for (k=0;k<count/4;k++)
w4l(((
u32 *)buf)[k]);
173 static void frpw_connect (
PIA *pi )
180 static void frpw_disconnect (
PIA *pi )
191 static int frpw_test_pnp (
PIA *pi )
195 {
int olddelay,
a,
b;
197 #ifdef FRPW_HARD_RESET
202 olddelay = pi->
delay;
209 a =
r1() & 0xff;
w2(4); b =
r1() & 0xff;
212 pi->
delay = olddelay;
216 return ((~a&0x40) && (b&0x40));
234 printk(
"%s: frpw: Xilinx does not support mode %d\n",
241 printk(
"%s: frpw: ASIC does not support mode 2\n",
248 frpw_write_regr(pi,0,6,0xa0+j*0x10);
249 for (k=0;k<256;k++) {
250 frpw_write_regr(pi,0,2,k^0xaa);
251 frpw_write_regr(pi,0,3,k^0x55);
252 if (frpw_read_regr(pi,0,2) != (k^0xaa)) e[
j]++;
258 frpw_read_block_int(pi,scratch,512,0x10);
260 for (k=0;k<128;k++)
if (scratch[k] != k) r++;
264 printk(
"%s: frpw: port 0x%x, chip %ld, mode %d, test=(%d,%d,%d)\n",
268 return (r || (e[0] && e[1]));
272 static void frpw_log_adapter(
PIA *pi,
char * scratch,
int verbose )
274 {
char *mode_string[6] = {
"4-bit",
"8-bit",
"EPP",
275 "EPP-8",
"EPP-16",
"EPP-32"};
277 printk(
"%s: frpw %s, Freecom (%s) adapter at 0x%x, ", pi->
device,
291 .write_regr = frpw_write_regr,
292 .read_regr = frpw_read_regr,
293 .write_block = frpw_write_block,
294 .read_block = frpw_read_block,
295 .connect = frpw_connect,
296 .disconnect = frpw_disconnect,
297 .test_proto = frpw_test_proto,
298 .log_adapter = frpw_log_adapter,
301 static int __init frpw_init(
void)
306 static void __exit frpw_exit(
void)