OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [uclinux/] [uClinux-2.0.x/] [drivers/] [block/] [paride/] [fit3.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
2
        fit3.c        (c) 1998  Grant R. Guenther <grant@torque.net>
3
                          Under the terms of the GNU public license.
4
 
5
        fit3.c is a low-level protocol driver for newer models
6
        of the Fidelity International Technology parallel port adapter.
7
        This adapter is used in their TransDisk 3000 portable
8
        hard-drives, as well as CD-ROM, PD-CD and other devices.
9
 
10
        The TD-2000 and certain older devices use a different protocol.
11
        Try the fit2 protocol module with them.
12
 
13
        NB:  The FIT adapters do not appear to support the control
14
        registers.  So, we map ALT_STATUS to STATUS and NO-OP writes
15
        to the device control register - this means that IDE reset
16
        will not work on these devices.
17
 
18
*/
19
 
20
#define FIT3_VERSION      "1.0"
21
 
22
#include <linux/module.h>
23
#include <linux/delay.h>
24
#include <linux/kernel.h>
25
#include <linux/types.h>
26
#include <asm/io.h>
27
 
28
#include "paride.h"
29
 
30
#define j44(a,b)                (((a>>3)&0x0f)|((b<<1)&0xf0))
31
 
32
#define w7(byte)                {out_p(7,byte);}
33
#define r7()                    (in_p(7) & 0xff)
34
 
35
/* cont = 0 - access the IDE register file
36
   cont = 1 - access the IDE command set
37
 
38
*/
39
 
40
static void  fit3_write_regr( PIA *pi, int cont, int regr, int val)
41
 
42
{       if (cont == 1) return;
43
 
44
        switch (pi->mode) {
45
 
46
        case 0:
47
        case 1: w2(0xc); w0(regr); w2(0x8); w2(0xc);
48
                w0(val); w2(0xd);
49
                w0(0);   w2(0xc);
50
                break;
51
 
52
        case 2: w2(0xc); w0(regr); w2(0x8); w2(0xc);
53
                w4(val); w4(0);
54
                w2(0xc);
55
                break;
56
 
57
        }
58
}
59
 
60
static int fit3_read_regr( PIA *pi, int cont, int regr )
61
 
62
{       int  a, b;
63
 
64
        if (cont) {
65
          if (regr != 6) return 0xff;
66
          regr = 7;
67
        }
68
 
69
        switch (pi->mode) {
70
 
71
        case 0: w2(0xc); w0(regr + 0x10); w2(0x8); w2(0xc);
72
                w2(0xd); a = r1();
73
                w2(0xf); b = r1();
74
                w2(0xc);
75
                return j44(a,b);
76
 
77
        case 1: w2(0xc); w0(regr + 0x90); w2(0x8); w2(0xc);
78
                w2(0xec); w2(0xee); w2(0xef); a = r0();
79
                w2(0xc);
80
                return a;
81
 
82
        case 2: w2(0xc); w0(regr + 0x90); w2(0x8); w2(0xc);
83
                w2(0xec);
84
                a = r4(); b = r4();
85
                w2(0xc);
86
                return a;
87
 
88
        }
89
        return -1;
90
 
91
}
92
 
93
static void fit3_read_block( PIA *pi, char * buf, int count )
94
 
95
{       int  k, a, b, c, d;
96
 
97
        switch (pi->mode) {
98
 
99
        case 0: w2(0xc); w0(0x10); w2(0x8); w2(0xc);
100
                for (k=0;k<count/2;k++) {
101
                    w2(0xd); a = r1();
102
                    w2(0xf); b = r1();
103
                    w2(0xc); c = r1();
104
                    w2(0xe); d = r1();
105
                    buf[2*k  ] = j44(a,b);
106
                    buf[2*k+1] = j44(c,d);
107
                }
108
                w2(0xc);
109
                break;
110
 
111
        case 1: w2(0xc); w0(0x90); w2(0x8); w2(0xc);
112
                w2(0xec); w2(0xee);
113
                for (k=0;k<count/2;k++) {
114
                    w2(0xef); a = r0();
115
                    w2(0xee); b = r0();
116
                    buf[2*k  ] = a;
117
                    buf[2*k+1] = b;
118
                }
119
                w2(0xec);
120
                w2(0xc);
121
                break;
122
 
123
        case 2: w2(0xc); w0(0x90); w2(0x8); w2(0xc);
124
                w2(0xec);
125
                for (k=0;k<count;k++) buf[k] = r4();
126
                w2(0xc);
127
                break;
128
 
129
        }
130
}
131
 
132
static void fit3_write_block( PIA *pi, char * buf, int count )
133
 
134
{       int k;
135
 
136
        switch (pi->mode) {
137
 
138
        case 0:
139
        case 1: w2(0xc); w0(0); w2(0x8); w2(0xc);
140
                for (k=0;k<count/2;k++) {
141
                    w0(buf[2*k  ]); w2(0xd);
142
                    w0(buf[2*k+1]); w2(0xc);
143
                }
144
                break;
145
 
146
        case 2: w2(0xc); w0(0); w2(0x8); w2(0xc);
147
                for (k=0;k<count;k++) w4(buf[k]);
148
                w2(0xc);
149
                break;
150
        }
151
}
152
 
153
static void fit3_connect ( PIA *pi  )
154
 
155
{       pi->saved_r0 = r0();
156
        pi->saved_r2 = r2();
157
        w2(0xc); w0(0); w2(0xa);
158
        if (pi->mode == 2) {
159
                w2(0xc); w0(0x9); w2(0x8); w2(0xc);
160
                }
161
}
162
 
163
static void fit3_disconnect ( PIA *pi )
164
 
165
{       w2(0xc); w0(0xa); w2(0x8); w2(0xc);
166
        w0(pi->saved_r0);
167
        w2(pi->saved_r2);
168
}
169
 
170
static void fit3_log_adapter( PIA *pi, char * scratch, int verbose )
171
 
172
{       char    *mode_string[3] = {"4-bit","8-bit","EPP"};
173
 
174
        printk("%s: fit3 %s, FIT 3000 adapter at 0x%x, "
175
               "mode %d (%s), delay %d\n",
176
                pi->device,FIT3_VERSION,pi->port,
177
                pi->mode,mode_string[pi->mode],pi->delay);
178
 
179
}
180
 
181
static void fit3_init_proto(PIA *pi)
182
 
183
{       MOD_INC_USE_COUNT;
184
}
185
 
186
static void fit3_release_proto(PIA *pi)
187
 
188
{       MOD_DEC_USE_COUNT;
189
}
190
 
191
struct pi_protocol fit3 = {"fit3",0,3,2,1,1,
192
                           fit3_write_regr,
193
                           fit3_read_regr,
194
                           fit3_write_block,
195
                           fit3_read_block,
196
                           fit3_connect,
197
                           fit3_disconnect,
198
                           0,
199
                           0,
200
                           0,
201
                           fit3_log_adapter,
202
                           fit3_init_proto,
203
                           fit3_release_proto
204
                          };
205
 
206
 
207
#ifdef MODULE
208
 
209
int     init_module(void)
210
 
211
{       return pi_register( &fit3 ) - 1;
212
}
213
 
214
void    cleanup_module(void)
215
 
216
{       pi_unregister( &fit3 );
217
}
218
 
219
#endif
220
 
221
/* end of fit3.c */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.