21 #define KBIC_VERSION "1.01"
23 #include <linux/module.h>
26 #include <linux/kernel.h>
27 #include <linux/types.h>
28 #include <linux/wait.h>
33 #define r12w() (delay_p,inw(pi->port+1)&0xffff)
35 #define j44(a,b) ((((a>>4)&0x0f)|(b&0xf0))^0x88)
36 #define j53(w) (((w>>3)&0x1f)|((w>>4)&0xe0))
43 static int cont_map[2] = { 0x80, 0x40 };
45 static int kbic_read_regr(
PIA *pi,
int cont,
int regr )
53 case 0:
w0(regr|0x18|s);
w2(4);
w2(6);
w2(4);
w2(1);
w0(8);
57 case 1:
w0(regr|0x38|s);
w2(4);
w2(6);
w2(4);
w2(5);
w0(8);
61 case 2:
w0(regr|0x08|s);
w2(4);
w2(6);
w2(4);
w2(0xa5);
w2(0xa1);
67 case 5:
w0(0x20|s);
w2(4);
w2(6);
w2(4);
w3(regr);
75 static void kbic_write_regr(
PIA *pi,
int cont,
int regr,
int val)
85 case 2:
w0(regr|0x10|s);
w2(4);
w2(6);
w2(4);
91 case 5:
w0(0x20|s);
w2(4);
w2(6);
w2(4);
w3(regr);
99 static void k951_connect (
PIA *pi )
106 static void k951_disconnect (
PIA *pi )
112 #define CCP(x) w2(0xc4);w0(0xaa);w0(0x55);w0(0);w0(0xff);w0(0x87);\
113 w0(0x78);w0(x);w2(0xc5);w2(0xc4);w0(0xff);
115 static void k971_connect (
PIA *pi )
123 static void k971_disconnect (
PIA *pi )
134 static void kbic_read_block(
PIA *pi,
char *
buf,
int count )
140 case 0:
w0(0x98);
w2(4);
w2(6);
w2(4);
141 for (k=0;k<count/2;k++) {
147 buf[2*k+1] =
j44(a,b);
152 case 1:
w0(0xb8);
w2(4);
w2(6);
w2(4);
153 for (k=0;k<count/4;k++) {
165 case 2:
w0(0x88);
w2(4);
w2(6);
w2(4);
166 for (k=0;k<count/2;k++) {
167 w2(0xa0);
w2(0xa1); buf[2*
k] =
r0();
168 w2(0xa5); buf[2*k+1] =
r0();
174 for (k=0;k<
count;k++) buf[k] =
r4();
179 for (k=0;k<count/2;k++) ((
u16 *)buf)[
k] =
r4w();
184 for (k=0;k<count/4;k++) ((
u32 *)buf)[
k] =
r4l();
192 static void kbic_write_block(
PIA *pi,
char * buf,
int count )
200 case 2:
w0(0x90);
w2(4);
w2(6);
w2(4);
201 for(k=0;k<count/2;k++) {
202 w0(buf[2*k+1]);
w2(0);
w2(4);
203 w0(buf[2*k]);
w2(5);
w2(4);
208 for(k=0;k<count/2;k++) {
216 for(k=0;k<count/2;k++)
w4w(pi_swab16(buf,k));
221 for(k=0;k<count/4;k++)
w4l(pi_swab32(buf,k));
229 static void kbic_log_adapter(
PIA *pi,
char *
scratch,
232 {
char *mode_string[6] = {
"4-bit",
"5/3",
"8-bit",
233 "EPP-8",
"EPP_16",
"EPP-32"};
235 printk(
"%s: kbic %s, KingByte %s at 0x%x, ",
244 { kbic_log_adapter(pi,scratch,verbose,
"KBIC-951A");
249 { kbic_log_adapter(pi,scratch,verbose,
"KBIC-971A");
259 .write_regr = kbic_write_regr,
260 .read_regr = kbic_read_regr,
261 .write_block = kbic_write_block,
262 .read_block = kbic_read_block,
263 .connect = k951_connect,
264 .disconnect = k951_disconnect,
265 .log_adapter = k951_log_adapter,
275 .write_regr = kbic_write_regr,
276 .read_regr = kbic_read_regr,
277 .write_block = kbic_write_block,
278 .read_block = kbic_read_block,
279 .connect = k971_connect,
280 .disconnect = k971_disconnect,
281 .log_adapter = k971_log_adapter,
284 static int __init kbic_init(
void)
297 static void __exit kbic_exit(
void)