aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/paride/fit2.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/block/paride/fit2.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/fit2.c')
-rw-r--r--drivers/block/paride/fit2.c151
1 files changed, 151 insertions, 0 deletions
diff --git a/drivers/block/paride/fit2.c b/drivers/block/paride/fit2.c
new file mode 100644
index 000000000000..e0f0691d8bc2
--- /dev/null
+++ b/drivers/block/paride/fit2.c
@@ -0,0 +1,151 @@
1/*
2 fit2.c (c) 1998 Grant R. Guenther <grant@torque.net>
3 Under the terms of the GNU General Public License.
4
5 fit2.c is a low-level protocol driver for the older version
6 of the Fidelity International Technology parallel port adapter.
7 This adapter is used in their TransDisk 2000 and older TransDisk
8 3000 portable hard-drives. As far as I can tell, this device
9 supports 4-bit mode _only_.
10
11 Newer models of the FIT products use an enhanced protocol.
12 The "fit3" protocol module should support current drives.
13
14*/
15
16#define FIT2_VERSION "1.0"
17
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/delay.h>
21#include <linux/kernel.h>
22#include <linux/types.h>
23#include <linux/wait.h>
24#include <asm/io.h>
25
26#include "paride.h"
27
28#define j44(a,b) (((a>>4)&0x0f)|(b&0xf0))
29
30/* cont = 0 - access the IDE register file
31 cont = 1 - access the IDE command set
32
33NB: The FIT adapter does not appear to use the control registers.
34So, we map ALT_STATUS to STATUS and NO-OP writes to the device
35control register - this means that IDE reset will not work on these
36devices.
37
38*/
39
40static void fit2_write_regr( PIA *pi, int cont, int regr, int val)
41
42{ if (cont == 1) return;
43 w2(0xc); w0(regr); w2(4); w0(val); w2(5); w0(0); w2(4);
44}
45
46static int fit2_read_regr( PIA *pi, int cont, int regr )
47
48{ int a, b, r;
49
50 if (cont) {
51 if (regr != 6) return 0xff;
52 r = 7;
53 } else r = regr + 0x10;
54
55 w2(0xc); w0(r); w2(4); w2(5);
56 w0(0); a = r1();
57 w0(1); b = r1();
58 w2(4);
59
60 return j44(a,b);
61
62}
63
64static void fit2_read_block( PIA *pi, char * buf, int count )
65
66{ int k, a, b, c, d;
67
68 w2(0xc); w0(0x10);
69
70 for (k=0;k<count/4;k++) {
71
72 w2(4); w2(5);
73 w0(0); a = r1(); w0(1); b = r1();
74 w0(3); c = r1(); w0(2); d = r1();
75 buf[4*k+0] = j44(a,b);
76 buf[4*k+1] = j44(d,c);
77
78 w2(4); w2(5);
79 a = r1(); w0(3); b = r1();
80 w0(1); c = r1(); w0(0); d = r1();
81 buf[4*k+2] = j44(d,c);
82 buf[4*k+3] = j44(a,b);
83
84 }
85
86 w2(4);
87
88}
89
90static void fit2_write_block( PIA *pi, char * buf, int count )
91
92{ int k;
93
94
95 w2(0xc); w0(0);
96 for (k=0;k<count/2;k++) {
97 w2(4); w0(buf[2*k]);
98 w2(5); w0(buf[2*k+1]);
99 }
100 w2(4);
101}
102
103static void fit2_connect ( PIA *pi )
104
105{ pi->saved_r0 = r0();
106 pi->saved_r2 = r2();
107 w2(0xcc);
108}
109
110static void fit2_disconnect ( PIA *pi )
111
112{ w0(pi->saved_r0);
113 w2(pi->saved_r2);
114}
115
116static void fit2_log_adapter( PIA *pi, char * scratch, int verbose )
117
118{ printk("%s: fit2 %s, FIT 2000 adapter at 0x%x, delay %d\n",
119 pi->device,FIT2_VERSION,pi->port,pi->delay);
120
121}
122
123static struct pi_protocol fit2 = {
124 .owner = THIS_MODULE,
125 .name = "fit2",
126 .max_mode = 1,
127 .epp_first = 2,
128 .default_delay = 1,
129 .max_units = 1,
130 .write_regr = fit2_write_regr,
131 .read_regr = fit2_read_regr,
132 .write_block = fit2_write_block,
133 .read_block = fit2_read_block,
134 .connect = fit2_connect,
135 .disconnect = fit2_disconnect,
136 .log_adapter = fit2_log_adapter,
137};
138
139static int __init fit2_init(void)
140{
141 return pi_register(&fit2)-1;
142}
143
144static void __exit fit2_exit(void)
145{
146 pi_unregister(&fit2);
147}
148
149MODULE_LICENSE("GPL");
150module_init(fit2_init)
151module_exit(fit2_exit)