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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [drivers/] [block/] [paride/] [aten.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
        aten.c  (c) 1997-8  Grant R. Guenther <grant@torque.net>
3
                            Under the terms of the GNU public license.
4
 
5
        aten.c is a low-level protocol driver for the ATEN EH-100
6
        parallel port adapter.  The EH-100 supports 4-bit and 8-bit
7
        modes only.  There is also an EH-132 which supports EPP mode
8
        transfers.  The EH-132 is not yet supported.
9
 
10
*/
11
 
12
/* Changes:
13
 
14
        1.01    GRG 1998.05.05  init_proto, release_proto
15
 
16
*/
17
 
18
#define ATEN_VERSION      "1.01"
19
 
20
#include <linux/module.h>
21
#include <linux/delay.h>
22
#include <linux/kernel.h>
23
#include <linux/types.h>
24
#include <asm/io.h>
25
 
26
#include "paride.h"
27
 
28
#define j44(a,b)                ((((a>>4)&0x0f)|(b&0xf0))^0x88)
29
 
30
/* cont = 0 - access the IDE register file
31
   cont = 1 - access the IDE command set
32
*/
33
 
34
static int  cont_map[2] = { 0x08, 0x20 };
35
 
36
static void  aten_write_regr( PIA *pi, int cont, int regr, int val)
37
 
38
{       int r;
39
 
40
        r = regr + cont_map[cont] + 0x80;
41
 
42
        w0(r); w2(0xe); w2(6); w0(val); w2(7); w2(6); w2(0xc);
43
}
44
 
45
static int aten_read_regr( PIA *pi, int cont, int regr )
46
 
47
{       int  a, b, r;
48
 
49
        r = regr + cont_map[cont] + 0x40;
50
 
51
        switch (pi->mode) {
52
 
53
        case 0: w0(r); w2(0xe); w2(6);
54
                w2(7); w2(6); w2(0);
55
                a = r1(); w0(0x10); b = r1(); w2(0xc);
56
                return j44(a,b);
57
 
58
        case 1: r |= 0x10;
59
                w0(r); w2(0xe); w2(6); w0(0xff);
60
                w2(0x27); w2(0x26); w2(0x20);
61
                a = r0();
62
                w2(0x26); w2(0xc);
63
                return a;
64
        }
65
        return -1;
66
}
67
 
68
static void aten_read_block( PIA *pi, char * buf, int count )
69
 
70
{       int  k, a, b, c, d;
71
 
72
        switch (pi->mode) {
73
 
74
        case 0:  w0(0x48); w2(0xe); w2(6);
75
                for (k=0;k<count/2;k++) {
76
                        w2(7); w2(6); w2(2);
77
                        a = r1(); w0(0x58); b = r1();
78
                        w2(0); d = r1(); w0(0x48); c = r1();
79
                        buf[2*k] = j44(c,d);
80
                        buf[2*k+1] = j44(a,b);
81
                }
82
                w2(0xc);
83
                break;
84
 
85
        case 1: w0(0x58); w2(0xe); w2(6);
86
                for (k=0;k<count/2;k++) {
87
                        w2(0x27); w2(0x26); w2(0x22);
88
                        a = r0(); w2(0x20); b = r0();
89
                        buf[2*k] = b; buf[2*k+1] = a;
90
                }
91
                w2(0x26); w2(0xc);
92
                break;
93
        }
94
}
95
 
96
static void aten_write_block( PIA *pi, char * buf, int count )
97
 
98
{       int k;
99
 
100
        w0(0x88); w2(0xe); w2(6);
101
        for (k=0;k<count/2;k++) {
102
                w0(buf[2*k+1]); w2(0xe); w2(6);
103
                w0(buf[2*k]); w2(7); w2(6);
104
        }
105
        w2(0xc);
106
}
107
 
108
static void aten_connect ( PIA *pi  )
109
 
110
{       pi->saved_r0 = r0();
111
        pi->saved_r2 = r2();
112
        w2(0xc);
113
}
114
 
115
static void aten_disconnect ( PIA *pi )
116
 
117
{       w0(pi->saved_r0);
118
        w2(pi->saved_r2);
119
}
120
 
121
static void aten_log_adapter( PIA *pi, char * scratch, int verbose )
122
 
123
{       char    *mode_string[2] = {"4-bit","8-bit"};
124
 
125
        printk("%s: aten %s, ATEN EH-100 at 0x%x, ",
126
                pi->device,ATEN_VERSION,pi->port);
127
        printk("mode %d (%s), delay %d\n",pi->mode,
128
                mode_string[pi->mode],pi->delay);
129
 
130
}
131
 
132
static void aten_init_proto( PIA *pi )
133
 
134
{       MOD_INC_USE_COUNT;
135
}
136
 
137
static void aten_release_proto( PIA *pi )
138
 
139
{       MOD_DEC_USE_COUNT;
140
}
141
 
142
struct pi_protocol aten = {"aten",0,2,2,1,1,
143
                           aten_write_regr,
144
                           aten_read_regr,
145
                           aten_write_block,
146
                           aten_read_block,
147
                           aten_connect,
148
                           aten_disconnect,
149
                           0,
150
                           0,
151
                           0,
152
                           aten_log_adapter,
153
                           aten_init_proto,
154
                           aten_release_proto
155
                          };
156
 
157
 
158
#ifdef MODULE
159
 
160
int     init_module(void)
161
 
162
{       return pi_register( &aten ) - 1;
163
}
164
 
165
void    cleanup_module(void)
166
 
167
{       pi_unregister( &aten );
168
}
169
 
170
#endif
171
 
172
/* end of aten.c */

powered by: WebSVN 2.1.0

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