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

Subversion Repositories or1k

[/] [or1k/] [tags/] [before_ORP/] [uclinux/] [uClinux-2.0.x/] [drivers/] [block/] [paride/] [fit2.c] - Blame information for rev 199

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
2
        fit2.c        (c) 1998  Grant R. Guenther <grant@torque.net>
3
                          Under the terms of the GNU 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/delay.h>
20
#include <linux/kernel.h>
21
#include <linux/types.h>
22
#include <asm/io.h>
23
 
24
#include "paride.h"
25
 
26
#define j44(a,b)                (((a>>4)&0x0f)|(b&0xf0))
27
 
28
/* cont = 0 - access the IDE register file
29
   cont = 1 - access the IDE command set
30
 
31
NB:  The FIT adapter does not appear to use the control registers.
32
So, we map ALT_STATUS to STATUS and NO-OP writes to the device
33
control register - this means that IDE reset will not work on these
34
devices.
35
 
36
*/
37
 
38
static void  fit2_write_regr( PIA *pi, int cont, int regr, int val)
39
 
40
{       if (cont == 1) return;
41
        w2(0xc); w0(regr); w2(4); w0(val); w2(5); w0(0); w2(4);
42
}
43
 
44
static int fit2_read_regr( PIA *pi, int cont, int regr )
45
 
46
{       int  a, b, r;
47
 
48
        if (cont) {
49
          if (regr != 6) return 0xff;
50
          r = 7;
51
        } else r = regr + 0x10;
52
 
53
        w2(0xc); w0(r); w2(4); w2(5);
54
                 w0(0); a = r1();
55
                 w0(1); b = r1();
56
        w2(4);
57
 
58
        return j44(a,b);
59
 
60
}
61
 
62
static void fit2_read_block( PIA *pi, char * buf, int count )
63
 
64
{       int  k, a, b, c, d;
65
 
66
        w2(0xc); w0(0x10);
67
 
68
        for (k=0;k<count/4;k++) {
69
 
70
                w2(4); w2(5);
71
                w0(0); a = r1(); w0(1); b = r1();
72
                w0(3); c = r1(); w0(2); d = r1();
73
                buf[4*k+0] = j44(a,b);
74
                buf[4*k+1] = j44(d,c);
75
 
76
                w2(4); w2(5);
77
                       a = r1(); w0(3); b = r1();
78
                w0(1); c = r1(); w0(0); d = r1();
79
                buf[4*k+2] = j44(d,c);
80
                buf[4*k+3] = j44(a,b);
81
 
82
        }
83
 
84
        w2(4);
85
 
86
}
87
 
88
static void fit2_write_block( PIA *pi, char * buf, int count )
89
 
90
{       int k;
91
 
92
 
93
        w2(0xc); w0(0);
94
        for (k=0;k<count/2;k++) {
95
                w2(4); w0(buf[2*k]);
96
                w2(5); w0(buf[2*k+1]);
97
        }
98
        w2(4);
99
}
100
 
101
static void fit2_connect ( PIA *pi  )
102
 
103
{       pi->saved_r0 = r0();
104
        pi->saved_r2 = r2();
105
        w2(0xcc);
106
}
107
 
108
static void fit2_disconnect ( PIA *pi )
109
 
110
{       w0(pi->saved_r0);
111
        w2(pi->saved_r2);
112
}
113
 
114
static void fit2_log_adapter( PIA *pi, char * scratch, int verbose )
115
 
116
{       printk("%s: fit2 %s, FIT 2000 adapter at 0x%x, delay %d\n",
117
                pi->device,FIT2_VERSION,pi->port,pi->delay);
118
 
119
}
120
 
121
static void fit2_init_proto( PIA *pi)
122
 
123
{       MOD_INC_USE_COUNT;
124
}
125
 
126
static void fit2_release_proto( PIA *pi)
127
 
128
{       MOD_DEC_USE_COUNT;
129
}
130
 
131
struct pi_protocol fit2 = {"fit2",0,1,2,1,1,
132
                           fit2_write_regr,
133
                           fit2_read_regr,
134
                           fit2_write_block,
135
                           fit2_read_block,
136
                           fit2_connect,
137
                           fit2_disconnect,
138
                           0,
139
                           0,
140
                           0,
141
                           fit2_log_adapter,
142
                           fit2_init_proto,
143
                           fit2_release_proto
144
                          };
145
 
146
 
147
#ifdef MODULE
148
 
149
int     init_module(void)
150
 
151
{       return pi_register( &fit2 ) - 1;
152
}
153
 
154
void    cleanup_module(void)
155
 
156
{       pi_unregister( &fit2 );
157
}
158
 
159
#endif
160
 
161
/* end of fit2.c */

powered by: WebSVN 2.1.0

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