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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [drivers/] [block/] [paride/] [paride.h] - Blame information for rev 1626

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

Line No. Rev Author Line
1 1626 jcastillo
/*
2
        paride.h        (c) 1997-8  Grant R. Guenther <grant@torque.net>
3
                                    Under the terms of the GPL.
4
 
5
   This file defines the interface between the high-level parallel
6
   IDE device drivers (pd, pf, pcd, pt) and the adapter chips.
7
 
8
*/
9
 
10
/* Changes:
11
 
12
        1.01    GRG 1998.05.05  init_proto, release_proto
13
*/
14
 
15
#define PARIDE_H_VERSION        "1.01"
16
 
17
/* Some adapters need to know what kind of device they are in
18
 
19
   Values for devtype:
20
*/
21
 
22
#define PI_PD   0        /* IDE disk */
23
#define PI_PCD  1       /* ATAPI CDrom */
24
#define PI_PF   2       /* ATAPI disk */
25
#define PI_PT   3       /* ATAPI tape */
26
#define PI_PG   4       /* ATAPI generic */
27
 
28
/* The paride module contains no state, instead the drivers allocate
29
   a pi_adapter data structure and pass it to paride in every operation.
30
 
31
*/
32
 
33
struct pi_adapter  {
34
 
35
        struct pi_protocol *proto;   /* adapter protocol */
36
        int     port;                /* base address of parallel port */
37
        int     mode;                /* transfer mode in use */
38
        int     delay;               /* adapter delay setting */
39
        int     devtype;             /* device type: PI_PD etc. */
40
        char    *device;             /* name of driver */
41
        int     unit;                /* unit number for chained adapters */
42
        int     saved_r0;            /* saved port state */
43
        int     saved_r2;            /* saved port state */
44
        int     reserved;            /* number of ports reserved */
45
        int     private;             /* for protocol module */
46
 
47
        struct wait_queue *parq;     /* semaphore for parport sharing */
48
        void    *pardev;             /* pointer to pardevice */
49
        char    *parname;            /* parport name */
50
        int     claimed;             /* parport has already been claimed */
51
        void (*claim_cont)(void);    /* continuation for parport wait */
52
};
53
 
54
typedef struct pi_adapter PIA;
55
 
56
/* functions exported by paride to the high level drivers */
57
 
58
extern int pi_init(PIA *pi,
59
        int autoprobe,          /* 1 to autoprobe */
60
        int port,               /* base port address */
61
        int mode,               /* -1 for autoprobe */
62
        int unit,               /* unit number, if supported */
63
        int protocol,           /* protocol to use */
64
        int delay,              /* -1 to use adapter specific default */
65
        char * scratch,         /* address of 512 byte buffer */
66
        int devtype,            /* device type: PI_PD, PI_PCD, etc ... */
67
        int verbose,            /* log verbose data while probing */
68
        char *device            /* name of the driver */
69
        );                      /* returns 0 on failure, 1 on success */
70
 
71
extern void pi_release(PIA *pi);
72
 
73
/* registers are addressed as (cont,regr)
74
 
75
        cont: 0 for command register file, 1 for control register(s)
76
        regr: 0-7 for register number.
77
 
78
*/
79
 
80
extern void pi_write_regr(PIA *pi, int cont, int regr, int val);
81
 
82
extern int pi_read_regr(PIA *pi, int cont, int regr);
83
 
84
extern void pi_write_block(PIA *pi, char * buf, int count);
85
 
86
extern void pi_read_block(PIA *pi, char * buf, int count);
87
 
88
extern void pi_connect(PIA *pi);
89
 
90
extern void pi_disconnect(PIA *pi);
91
 
92
extern void pi_do_claimed(PIA *pi, void (*cont)(void));
93
 
94
/* macros and functions exported to the protocol modules */
95
 
96
#define delay_p                 (pi->delay?udelay(pi->delay):0)
97
#define out_p(offs,byte)        outb(byte,pi->port+offs); delay_p;
98
#define in_p(offs)              (delay_p,inb(pi->port+offs))
99
 
100
#define w0(byte)                {out_p(0,byte);}
101
#define r0()                    (in_p(0) & 0xff)
102
#define w1(byte)                {out_p(1,byte);}
103
#define r1()                    (in_p(1) & 0xff)
104
#define w2(byte)                {out_p(2,byte);}
105
#define r2()                    (in_p(2) & 0xff)
106
#define w3(byte)                {out_p(3,byte);}
107
#define w4(byte)                {out_p(4,byte);}
108
#define r4()                    (in_p(4) & 0xff)
109
#define w4w(data)               {outw(data,pi->port+4); delay_p;}
110
#define w4l(data)               {outl(data,pi->port+4); delay_p;}
111
#define r4w()                   (delay_p,inw(pi->port+4)&0xffff)
112
#define r4l()                   (delay_p,inl(pi->port+4)&0xffffffff)
113
 
114
static inline u16 pi_swab16( char *b, int k)
115
 
116
{       union { u16 u; char t[2]; } r;
117
 
118
        r.t[0]=b[2*k+1]; r.t[1]=b[2*k];
119
        return r.u;
120
}
121
 
122
static inline u32 pi_swab32( char *b, int k)
123
 
124
{       union { u32 u; char f[4]; } r;
125
 
126
        r.f[0]=b[4*k+1]; r.f[1]=b[4*k];
127
        r.f[2]=b[4*k+3]; r.f[3]=b[4*k+2];
128
        return r.u;
129
}
130
 
131
struct pi_protocol {
132
 
133
        char    name[8];        /* name for this protocol */
134
        int     index;          /* index into protocol table */
135
 
136
        int     max_mode;       /* max mode number */
137
        int     epp_first;      /* modes >= this use 8 ports */
138
 
139
        int     default_delay;  /* delay parameter if not specified */
140
        int     max_units;      /* max chained units probed for */
141
 
142
        void (*write_regr)(PIA *,int,int,int);
143
        int  (*read_regr)(PIA *,int,int);
144
        void (*write_block)(PIA *,char *,int);
145
        void (*read_block)(PIA *,char *,int);
146
 
147
        void (*connect)(PIA *);
148
        void (*disconnect)(PIA *);
149
 
150
        int  (*test_port)(PIA *);
151
        int  (*probe_unit)(PIA *);
152
        int  (*test_proto)(PIA *,char *,int);
153
        void (*log_adapter)(PIA *,char *,int);
154
 
155
        void (*init_proto)(PIA *);
156
        void (*release_proto)(PIA *);
157
};
158
 
159
typedef struct pi_protocol PIP;
160
 
161
extern int pi_register( PIP * );
162
extern void pi_unregister ( PIP * );
163
 
164
/* end of paride.h */

powered by: WebSVN 2.1.0

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