2 on20.c (c) 1996 Grant R. Guenther <grant@torque.net>
3 Under the terms of the GNU public license.
5 on20.c is a low-level protocol driver for the
6 Onspec 90c20 parallel to IDE adapter.
9 #define ON20_VERSION "1.0"
11 #include <linux/module.h>
12 #include <linux/delay.h>
13 #include <linux/kernel.h>
14 #include <linux/types.h>
19 #define op(f) w2(4);w0(f);w2(5);w2(0xd);w2(5);w2(0xd);w2(5);w2(4);
20 #define vl(v) w2(4);w0(v);w2(5);w2(7);w2(5);w2(4);
22 #define j44(a,b) (((a>>4)&0x0f)|(b&0xf0))
24 /* cont = 0 - access the IDE register file
25 cont = 1 - access the IDE command set
28 static int on20_read_regr( PIA
*pi
, int cont
, int regr
)
32 r
= (regr
<<2) + 1 + cont
;
38 case 0: w2(4); w2(6); l
= r1();
39 w2(4); w2(6); h
= r1();
40 w2(4); w2(6); w2(4); w2(6); w2(4);
43 case 1: w2(4); w2(0x26); r
= r0();
44 w2(4); w2(0x26); w2(4);
51 static void on20_write_regr( PIA
*pi
, int cont
, int regr
, int val
)
55 r
= (regr
<<2) + 1 + cont
;
62 static void on20_connect ( PIA
*pi
)
64 { pi
->saved_r0
= r0();
67 w2(4);w0(0);w2(0xc);w2(4);w2(6);w2(4);w2(6);w2(4);
68 if (pi
->mode
) { op(2); vl(8); op(2); vl(9); }
69 else { op(2); vl(0); op(2); vl(8); }
72 static void on20_disconnect ( PIA
*pi
)
74 { w2(4);w0(7);w2(4);w2(0xc);w2(4);
79 static void on20_read_block( PIA
*pi
, char * buf
, int count
)
87 w2(4); w2(0x26); buf
[k
] = r0();
89 w2(6); l
= r1(); w2(4);
90 w2(6); h
= r1(); w2(4);
96 static void on20_write_block( PIA
*pi
, char * buf
, int count
)
102 for (k
=0;k
<count
;k
++) { w2(5); w0(buf
[k
]); w2(7); }
106 static void on20_log_adapter( PIA
*pi
, char * scratch
, int verbose
)
108 { char *mode_string
[2] = {"4-bit","8-bit"};
110 printk("%s: on20 %s, OnSpec 90c20 at 0x%x, ",
111 pi
->device
,ON20_VERSION
,pi
->port
);
112 printk("mode %d (%s), delay %d\n",pi
->mode
,
113 mode_string
[pi
->mode
],pi
->delay
);
117 static void on20_inc_use ( void )
122 static void on20_dec_use ( void )
127 struct pi_protocol on20
= {"on20",0,2,2,1,1,
145 int init_module(void)
147 { return pi_register( &on20
) - 1;
150 void cleanup_module(void)
152 { pi_unregister( &on20
);