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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [drivers/] [block/] [paride/] [on20.c] - Blame information for rev 1777

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

Line No. Rev Author Line
1 1626 jcastillo
/*
2
        on20.c  (c) 1996-8  Grant R. Guenther <grant@torque.net>
3
                            Under the terms of the GNU public license.
4
 
5
        on20.c is a low-level protocol driver for the
6
        Onspec 90c20 parallel to IDE adapter.
7
*/
8
 
9
/* Changes:
10
 
11
        1.01    GRG 1998.05.06 init_proto, release_proto
12
 
13
*/
14
 
15
#define ON20_VERSION    "1.01"
16
 
17
#include <linux/module.h>
18
#include <linux/delay.h>
19
#include <linux/kernel.h>
20
#include <linux/types.h>
21
#include <asm/io.h>
22
 
23
#include "paride.h"
24
 
25
#define op(f)   w2(4);w0(f);w2(5);w2(0xd);w2(5);w2(0xd);w2(5);w2(4);
26
#define vl(v)   w2(4);w0(v);w2(5);w2(7);w2(5);w2(4);
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
*/
33
 
34
static int on20_read_regr( PIA *pi, int cont, int regr )
35
 
36
{       int h,l, r ;
37
 
38
        r = (regr<<2) + 1 + cont;
39
 
40
        op(1); vl(r); op(0);
41
 
42
        switch (pi->mode)  {
43
 
44
        case 0:  w2(4); w2(6); l = r1();
45
                 w2(4); w2(6); h = r1();
46
                 w2(4); w2(6); w2(4); w2(6); w2(4);
47
                 return j44(l,h);
48
 
49
        case 1:  w2(4); w2(0x26); r = r0();
50
                 w2(4); w2(0x26); w2(4);
51
                 return r;
52
 
53
        }
54
        return -1;
55
}
56
 
57
static void on20_write_regr( PIA *pi, int cont, int regr, int val )
58
 
59
{       int r;
60
 
61
        r = (regr<<2) + 1 + cont;
62
 
63
        op(1); vl(r);
64
        op(0); vl(val);
65
        op(0); vl(val);
66
}
67
 
68
static void on20_connect ( PIA *pi)
69
 
70
{       pi->saved_r0 = r0();
71
        pi->saved_r2 = r2();
72
 
73
        w2(4);w0(0);w2(0xc);w2(4);w2(6);w2(4);w2(6);w2(4);
74
        if (pi->mode) { op(2); vl(8); op(2); vl(9); }
75
               else   { op(2); vl(0); op(2); vl(8); }
76
}
77
 
78
static void on20_disconnect ( PIA *pi )
79
 
80
{       w2(4);w0(7);w2(4);w2(0xc);w2(4);
81
        w0(pi->saved_r0);
82
        w2(pi->saved_r2);
83
}
84
 
85
static void on20_read_block( PIA *pi, char * buf, int count )
86
 
87
{       int     k, l, h;
88
 
89
        op(1); vl(1); op(0);
90
 
91
        for (k=0;k<count;k++)
92
            if (pi->mode) {
93
                w2(4); w2(0x26); buf[k] = r0();
94
            } else {
95
                w2(6); l = r1(); w2(4);
96
                w2(6); h = r1(); w2(4);
97
                buf[k] = j44(l,h);
98
            }
99
        w2(4);
100
}
101
 
102
static void on20_write_block(  PIA *pi, char * buf, int count )
103
 
104
{       int     k;
105
 
106
        op(1); vl(1); op(0);
107
 
108
        for (k=0;k<count;k++) { w2(5); w0(buf[k]); w2(7); }
109
        w2(4);
110
}
111
 
112
static void on20_log_adapter( PIA *pi, char * scratch, int verbose )
113
 
114
{       char    *mode_string[2] = {"4-bit","8-bit"};
115
 
116
        printk("%s: on20 %s, OnSpec 90c20 at 0x%x, ",
117
                pi->device,ON20_VERSION,pi->port);
118
        printk("mode %d (%s), delay %d\n",pi->mode,
119
                mode_string[pi->mode],pi->delay);
120
 
121
}
122
 
123
static void on20_init_proto( PIA *pi)
124
 
125
{       MOD_INC_USE_COUNT;
126
}
127
 
128
static void on20_release_proto( PIA *pi)
129
 
130
{       MOD_DEC_USE_COUNT;
131
}
132
 
133
struct pi_protocol on20 = {"on20",0,2,2,1,1,
134
                           on20_write_regr,
135
                           on20_read_regr,
136
                           on20_write_block,
137
                           on20_read_block,
138
                           on20_connect,
139
                           on20_disconnect,
140
                           0,
141
                           0,
142
                           0,
143
                           on20_log_adapter,
144
                           on20_init_proto,
145
                           on20_release_proto
146
                          };
147
 
148
 
149
#ifdef MODULE
150
 
151
int     init_module(void)
152
 
153
{       return pi_register( &on20 ) - 1;
154
}
155
 
156
void    cleanup_module(void)
157
 
158
{       pi_unregister( &on20 );
159
}
160
 
161
#endif
162
 
163
/* end of on20.c */

powered by: WebSVN 2.1.0

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