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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [drivers/] [block/] [paride/] [ktti.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
        ktti.c        (c) 1998  Grant R. Guenther <grant@torque.net>
3
                          Under the terms of the GNU public license.
4
 
5
        ktti.c is a low-level protocol driver for the KT Technology
6
        parallel port adapter.  This adapter is used in the "PHd"
7
        portable hard-drives.  As far as I can tell, this device
8
        supports 4-bit mode _only_.
9
 
10
*/
11
 
12
#define KTTI_VERSION      "1.0"
13
 
14
#include <linux/module.h>
15
#include <linux/delay.h>
16
#include <linux/kernel.h>
17
#include <linux/types.h>
18
#include <asm/io.h>
19
 
20
#include "paride.h"
21
 
22
#define j44(a,b)                (((a>>4)&0x0f)|(b&0xf0))
23
 
24
/* cont = 0 - access the IDE register file
25
   cont = 1 - access the IDE command set
26
*/
27
 
28
static int  cont_map[2] = { 0x10, 0x08 };
29
 
30
static void  ktti_write_regr( PIA *pi, int cont, int regr, int val)
31
 
32
{       int r;
33
 
34
        r = regr + cont_map[cont];
35
 
36
        w0(r); w2(0xb); w2(0xa); w2(3); w2(6);
37
        w0(val); w2(3); w0(0); w2(6); w2(0xb);
38
}
39
 
40
static int ktti_read_regr( PIA *pi, int cont, int regr )
41
 
42
{       int  a, b, r;
43
 
44
        r = regr + cont_map[cont];
45
 
46
        w0(r); w2(0xb); w2(0xa); w2(9); w2(0xc); w2(9);
47
        a = r1(); w2(0xc);  b = r1(); w2(9); w2(0xc); w2(9);
48
        return j44(a,b);
49
 
50
}
51
 
52
static void ktti_read_block( PIA *pi, char * buf, int count )
53
 
54
{       int  k, a, b;
55
 
56
        for (k=0;k<count/2;k++) {
57
                w0(0x10); w2(0xb); w2(0xa); w2(9); w2(0xc); w2(9);
58
                a = r1(); w2(0xc); b = r1(); w2(9);
59
                buf[2*k] = j44(a,b);
60
                a = r1(); w2(0xc); b = r1(); w2(9);
61
                buf[2*k+1] = j44(a,b);
62
        }
63
}
64
 
65
static void ktti_write_block( PIA *pi, char * buf, int count )
66
 
67
{       int k;
68
 
69
        for (k=0;k<count/2;k++) {
70
                w0(0x10); w2(0xb); w2(0xa); w2(3); w2(6);
71
                w0(buf[2*k]); w2(3);
72
                w0(buf[2*k+1]); w2(6);
73
                w2(0xb);
74
        }
75
}
76
 
77
static void ktti_connect ( PIA *pi  )
78
 
79
{       pi->saved_r0 = r0();
80
        pi->saved_r2 = r2();
81
        w2(0xb); w2(0xa); w0(0); w2(3); w2(6);
82
}
83
 
84
static void ktti_disconnect ( PIA *pi )
85
 
86
{       w2(0xb); w2(0xa); w0(0xa0); w2(3); w2(4);
87
        w0(pi->saved_r0);
88
        w2(pi->saved_r2);
89
}
90
 
91
static void ktti_log_adapter( PIA *pi, char * scratch, int verbose )
92
 
93
{       printk("%s: ktti %s, KT adapter at 0x%x, delay %d\n",
94
                pi->device,KTTI_VERSION,pi->port,pi->delay);
95
 
96
}
97
 
98
static void ktti_init_proto( PIA *pi)
99
 
100
{       MOD_INC_USE_COUNT;
101
}
102
 
103
static void ktti_release_proto( PIA *pi)
104
 
105
{       MOD_DEC_USE_COUNT;
106
}
107
 
108
struct pi_protocol ktti = {"ktti",0,1,2,1,1,
109
                           ktti_write_regr,
110
                           ktti_read_regr,
111
                           ktti_write_block,
112
                           ktti_read_block,
113
                           ktti_connect,
114
                           ktti_disconnect,
115
                           0,
116
                           0,
117
                           0,
118
                           ktti_log_adapter,
119
                           ktti_init_proto,
120
                           ktti_release_proto
121
                          };
122
 
123
 
124
#ifdef MODULE
125
 
126
int     init_module(void)
127
 
128
{       return pi_register( &ktti ) - 1;
129
}
130
 
131
void    cleanup_module(void)
132
 
133
{       pi_unregister( &ktti );
134
}
135
 
136
#endif
137
 
138
/* end of ktti.c */

powered by: WebSVN 2.1.0

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