diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/block/paride/ktti.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'drivers/block/paride/ktti.c')
-rw-r--r-- | drivers/block/paride/ktti.c | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/drivers/block/paride/ktti.c b/drivers/block/paride/ktti.c new file mode 100644 index 000000000000..6c7edbfba9a0 --- /dev/null +++ b/drivers/block/paride/ktti.c | |||
@@ -0,0 +1,128 @@ | |||
1 | /* | ||
2 | ktti.c (c) 1998 Grant R. Guenther <grant@torque.net> | ||
3 | Under the terms of the GNU General Public License. | ||
4 | |||
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_. | ||
9 | |||
10 | */ | ||
11 | |||
12 | #define KTTI_VERSION "1.0" | ||
13 | |||
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> | ||
21 | |||
22 | #include "paride.h" | ||
23 | |||
24 | #define j44(a,b) (((a>>4)&0x0f)|(b&0xf0)) | ||
25 | |||
26 | /* cont = 0 - access the IDE register file | ||
27 | cont = 1 - access the IDE command set | ||
28 | */ | ||
29 | |||
30 | static int cont_map[2] = { 0x10, 0x08 }; | ||
31 | |||
32 | static void ktti_write_regr( PIA *pi, int cont, int regr, int val) | ||
33 | |||
34 | { int r; | ||
35 | |||
36 | r = regr + cont_map[cont]; | ||
37 | |||
38 | w0(r); w2(0xb); w2(0xa); w2(3); w2(6); | ||
39 | w0(val); w2(3); w0(0); w2(6); w2(0xb); | ||
40 | } | ||
41 | |||
42 | static int ktti_read_regr( PIA *pi, int cont, int regr ) | ||
43 | |||
44 | { int a, b, r; | ||
45 | |||
46 | r = regr + cont_map[cont]; | ||
47 | |||
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); | ||
51 | |||
52 | } | ||
53 | |||
54 | static void ktti_read_block( PIA *pi, char * buf, int count ) | ||
55 | |||
56 | { int k, a, b; | ||
57 | |||
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); | ||
64 | } | ||
65 | } | ||
66 | |||
67 | static void ktti_write_block( PIA *pi, char * buf, int count ) | ||
68 | |||
69 | { int k; | ||
70 | |||
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); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | static void ktti_connect ( PIA *pi ) | ||
80 | |||
81 | { pi->saved_r0 = r0(); | ||
82 | pi->saved_r2 = r2(); | ||
83 | w2(0xb); w2(0xa); w0(0); w2(3); w2(6); | ||
84 | } | ||
85 | |||
86 | static void ktti_disconnect ( PIA *pi ) | ||
87 | |||
88 | { w2(0xb); w2(0xa); w0(0xa0); w2(3); w2(4); | ||
89 | w0(pi->saved_r0); | ||
90 | w2(pi->saved_r2); | ||
91 | } | ||
92 | |||
93 | static void ktti_log_adapter( PIA *pi, char * scratch, int verbose ) | ||
94 | |||
95 | { printk("%s: ktti %s, KT adapter at 0x%x, delay %d\n", | ||
96 | pi->device,KTTI_VERSION,pi->port,pi->delay); | ||
97 | |||
98 | } | ||
99 | |||
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, | ||
114 | }; | ||
115 | |||
116 | static int __init ktti_init(void) | ||
117 | { | ||
118 | return pi_register(&ktti)-1; | ||
119 | } | ||
120 | |||
121 | static void __exit ktti_exit(void) | ||
122 | { | ||
123 | pi_unregister(&ktti); | ||
124 | } | ||
125 | |||
126 | MODULE_LICENSE("GPL"); | ||
127 | module_init(ktti_init) | ||
128 | module_exit(ktti_exit) | ||