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