i2c-eg20t: change timeout value 50msec to 1000msec
[zen-stable.git] / drivers / block / paride / ktti.c
blob117ab0e8ccf0afc9156f500d795487fbfd1f4894
1 /*
2 ktti.c (c) 1998 Grant R. Guenther <grant@torque.net>
3 Under the terms of the GNU General Public License.
5 ktti.c is a low-level protocol driver for the KT Technology
6 parallel port adapter. This adapter is used in the "PHd"
7 portable hard-drives. As far as I can tell, this device
8 supports 4-bit mode _only_.
12 #define KTTI_VERSION "1.0"
14 #include <linux/module.h>
15 #include <linux/init.h>
16 #include <linux/delay.h>
17 #include <linux/kernel.h>
18 #include <linux/types.h>
19 #include <linux/wait.h>
20 #include <asm/io.h>
22 #include "paride.h"
24 #define j44(a,b) (((a>>4)&0x0f)|(b&0xf0))
26 /* cont = 0 - access the IDE register file
27 cont = 1 - access the IDE command set
30 static int cont_map[2] = { 0x10, 0x08 };
32 static void ktti_write_regr( PIA *pi, int cont, int regr, int val)
34 { int r;
36 r = regr + cont_map[cont];
38 w0(r); w2(0xb); w2(0xa); w2(3); w2(6);
39 w0(val); w2(3); w0(0); w2(6); w2(0xb);
42 static int ktti_read_regr( PIA *pi, int cont, int regr )
44 { int a, b, r;
46 r = regr + cont_map[cont];
48 w0(r); w2(0xb); w2(0xa); w2(9); w2(0xc); w2(9);
49 a = r1(); w2(0xc); b = r1(); w2(9); w2(0xc); w2(9);
50 return j44(a,b);
54 static void ktti_read_block( PIA *pi, char * buf, int count )
56 { int k, a, b;
58 for (k=0;k<count/2;k++) {
59 w0(0x10); w2(0xb); w2(0xa); w2(9); w2(0xc); w2(9);
60 a = r1(); w2(0xc); b = r1(); w2(9);
61 buf[2*k] = j44(a,b);
62 a = r1(); w2(0xc); b = r1(); w2(9);
63 buf[2*k+1] = j44(a,b);
67 static void ktti_write_block( PIA *pi, char * buf, int count )
69 { int k;
71 for (k=0;k<count/2;k++) {
72 w0(0x10); w2(0xb); w2(0xa); w2(3); w2(6);
73 w0(buf[2*k]); w2(3);
74 w0(buf[2*k+1]); w2(6);
75 w2(0xb);
79 static void ktti_connect ( PIA *pi )
81 { pi->saved_r0 = r0();
82 pi->saved_r2 = r2();
83 w2(0xb); w2(0xa); w0(0); w2(3); w2(6);
86 static void ktti_disconnect ( PIA *pi )
88 { w2(0xb); w2(0xa); w0(0xa0); w2(3); w2(4);
89 w0(pi->saved_r0);
90 w2(pi->saved_r2);
93 static void ktti_log_adapter( PIA *pi, char * scratch, int verbose )
95 { printk("%s: ktti %s, KT adapter at 0x%x, delay %d\n",
96 pi->device,KTTI_VERSION,pi->port,pi->delay);
100 static struct pi_protocol ktti = {
101 .owner = THIS_MODULE,
102 .name = "ktti",
103 .max_mode = 1,
104 .epp_first = 2,
105 .default_delay = 1,
106 .max_units = 1,
107 .write_regr = ktti_write_regr,
108 .read_regr = ktti_read_regr,
109 .write_block = ktti_write_block,
110 .read_block = ktti_read_block,
111 .connect = ktti_connect,
112 .disconnect = ktti_disconnect,
113 .log_adapter = ktti_log_adapter,
116 static int __init ktti_init(void)
118 return paride_register(&ktti);
121 static void __exit ktti_exit(void)
123 paride_unregister(&ktti);
126 MODULE_LICENSE("GPL");
127 module_init(ktti_init)
128 module_exit(ktti_exit)