Deleted Added
full compact
ppbconf.h (50477) ppbconf.h (55939)
1/*-
1/*-
2 * Copyright (c) 1997, 1998 Nicolas Souchu
2 * Copyright (c) 1997, 1998, 1999 Nicolas Souchu
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright

--- 7 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright

--- 7 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/dev/ppbus/ppbconf.h 50477 1999-08-28 01:08:13Z peter $
26 * $FreeBSD: head/sys/dev/ppbus/ppbconf.h 55939 2000-01-14 00:18:06Z nsouch $
27 *
28 */
29#ifndef __PPBCONF_H
30#define __PPBCONF_H
31
32#include <sys/queue.h>
33
34/*

--- 15 unchanged lines hidden (view full) ---

50/* mode aliases */
51#define PPB_SPP PPB_NIBBLE|PPB_PS2
52#define PPB_BYTE PPB_PS2
53
54#define PPB_MASK 0x0f
55#define PPB_OPTIONS_MASK 0xf0
56
57#define PPB_IS_EPP(mode) (mode & PPB_EPP)
27 *
28 */
29#ifndef __PPBCONF_H
30#define __PPBCONF_H
31
32#include <sys/queue.h>
33
34/*

--- 15 unchanged lines hidden (view full) ---

50/* mode aliases */
51#define PPB_SPP PPB_NIBBLE|PPB_PS2
52#define PPB_BYTE PPB_PS2
53
54#define PPB_MASK 0x0f
55#define PPB_OPTIONS_MASK 0xf0
56
57#define PPB_IS_EPP(mode) (mode & PPB_EPP)
58#define PPB_IN_EPP_MODE(dev) (PPB_IS_EPP (ppb_get_mode (dev)))
59#define PPB_IN_NIBBLE_MODE(dev) (ppb_get_mode (dev) & PPB_NIBBLE)
60#define PPB_IN_PS2_MODE(dev) (ppb_get_mode (dev) & PPB_PS2)
58#define PPB_IN_EPP_MODE(bus) (PPB_IS_EPP (ppb_get_mode (bus)))
59#define PPB_IN_NIBBLE_MODE(bus) (ppb_get_mode (bus) & PPB_NIBBLE)
60#define PPB_IN_PS2_MODE(bus) (ppb_get_mode (bus) & PPB_PS2)
61
62#define n(flags) (~(flags) & (flags))
63
64/*
65 * Parallel Port Chipset control bits.
66 */
67#define STROBE 0x01
68#define AUTOFEED 0x02

--- 27 unchanged lines hidden (view full) ---

96 unsigned int timeout:1;
97 unsigned int error:1;
98 unsigned int select:1;
99 unsigned int paper_end:1;
100 unsigned int ack:1;
101 unsigned int busy:1;
102};
103
61
62#define n(flags) (~(flags) & (flags))
63
64/*
65 * Parallel Port Chipset control bits.
66 */
67#define STROBE 0x01
68#define AUTOFEED 0x02

--- 27 unchanged lines hidden (view full) ---

96 unsigned int timeout:1;
97 unsigned int error:1;
98 unsigned int select:1;
99 unsigned int paper_end:1;
100 unsigned int ack:1;
101 unsigned int busy:1;
102};
103
104/* Parallel port bus I/O opcodes */
105#define PPB_OUTSB_EPP 1
106#define PPB_OUTSW_EPP 2
107#define PPB_OUTSL_EPP 3
108#define PPB_INSB_EPP 4
109#define PPB_INSW_EPP 5
110#define PPB_INSL_EPP 6
111#define PPB_RDTR 7
112#define PPB_RSTR 8
113#define PPB_RCTR 9
114#define PPB_REPP_A 10
115#define PPB_REPP_D 11
116#define PPB_RECR 12
117#define PPB_RFIFO 13
118#define PPB_WDTR 14
119#define PPB_WSTR 15
120#define PPB_WCTR 16
121#define PPB_WEPP_A 17
122#define PPB_WEPP_D 18
123#define PPB_WECR 19
124#define PPB_WFIFO 20
125
104/*
105 * How tsleep() is called in ppb_request_bus().
106 */
107#define PPB_DONTWAIT 0
108#define PPB_NOINTR 0
109#define PPB_WAIT 0x1
110#define PPB_INTR 0x2
111#define PPB_POLL 0x4

--- 35 unchanged lines hidden (view full) ---

147struct ppb_context {
148 int valid; /* 1 if the struct is valid */
149 int mode; /* XXX chipset operating mode */
150
151 struct microseq *curpc; /* pc in curmsq */
152 struct microseq *curmsq; /* currently executed microseqence */
153};
154
126/*
127 * How tsleep() is called in ppb_request_bus().
128 */
129#define PPB_DONTWAIT 0
130#define PPB_NOINTR 0
131#define PPB_WAIT 0x1
132#define PPB_INTR 0x2
133#define PPB_POLL 0x4

--- 35 unchanged lines hidden (view full) ---

169struct ppb_context {
170 int valid; /* 1 if the struct is valid */
171 int mode; /* XXX chipset operating mode */
172
173 struct microseq *curpc; /* pc in curmsq */
174 struct microseq *curmsq; /* currently executed microseqence */
175};
176
177/*
178 * List of IVARS available to ppb device drivers
179 */
180#define PPBUS_IVAR_MODE 0
181#define PPBUS_IVAR_AVM 1
182#define PPBUS_IVAR_IRQ 2
183
184/* other fields are reserved to the ppbus internals */
185
155struct ppb_device {
156
186struct ppb_device {
187
157 int id_unit; /* unit of the device */
158 char *name; /* name of the device */
188 const char *name; /* name of the device */
159
160 ushort mode; /* current mode of the device */
161 ushort avm; /* available IEEE1284 modes of
162 * the device */
189
190 ushort mode; /* current mode of the device */
191 ushort avm; /* available IEEE1284 modes of
192 * the device */
193 uint flags; /* flags */
163
164 struct ppb_context ctx; /* context of the device */
165
166 /* mode dependent get msq. If NULL,
167 * IEEE1284 code is used */
168 struct ppb_xfer
169 get_xfer[PPB_MAX_XFER];
170
171 /* mode dependent put msq. If NULL,
172 * IEEE1284 code is used */
173 struct ppb_xfer
174 put_xfer[PPB_MAX_XFER];
194
195 struct ppb_context ctx; /* context of the device */
196
197 /* mode dependent get msq. If NULL,
198 * IEEE1284 code is used */
199 struct ppb_xfer
200 get_xfer[PPB_MAX_XFER];
201
202 /* mode dependent put msq. If NULL,
203 * IEEE1284 code is used */
204 struct ppb_xfer
205 put_xfer[PPB_MAX_XFER];
206
207 struct resource *intr_resource;
208 void *intr_cookie;
175
209
176 void (*intr)(int); /* interrupt handler */
177 void (*bintr)(struct ppb_device *); /* interrupt handler */
178
179 void *drv1, *drv2; /* drivers private data */
210 void *drv1, *drv2; /* drivers private data */
180
181 struct ppb_data *ppb; /* link to the ppbus */
182
183 LIST_ENTRY(ppb_device) chain; /* list of devices on the bus */
184};
185
211};
212
186/*
187 * Parallel Port Bus Adapter structure.
188 */
189struct ppb_adapter {
190
191 void (*intr_handler)(int);
192 void (*reset_epp_timeout)(int);
193 void (*ecp_sync)(int);
194
195 int (*exec_microseq)(int, struct ppb_microseq **);
196
197 int (*setmode)(int, int);
198 int (*read)(int, char *, int, int);
199 int (*write)(int, char *, int, int);
200
201 void (*outsb_epp)(int, char *, int);
202 void (*outsw_epp)(int, char *, int);
203 void (*outsl_epp)(int, char *, int);
204 void (*insb_epp)(int, char *, int);
205 void (*insw_epp)(int, char *, int);
206 void (*insl_epp)(int, char *, int);
207
208 u_char (*r_dtr)(int);
209 u_char (*r_str)(int);
210 u_char (*r_ctr)(int);
211 u_char (*r_epp_A)(int);
212 u_char (*r_epp_D)(int);
213 u_char (*r_ecr)(int);
214 u_char (*r_fifo)(int);
215
216 void (*w_dtr)(int, char);
217 void (*w_str)(int, char);
218 void (*w_ctr)(int, char);
219 void (*w_epp_A)(int, char);
220 void (*w_epp_D)(int, char);
221 void (*w_ecr)(int, char);
222 void (*w_fifo)(int, char);
223};
224
225/*
226 * ppb_link structure.
227 */
228struct ppb_link {
229
230 int adapter_unit; /* unit of the adapter */
231 int base; /* base address of the port */
232 int id_irq; /* != 0 if irq enabled */
233 int accum; /* microseq accum */
234 char *ptr; /* current buffer pointer */
235
213/* EPP standards */
236#define EPP_1_9 0x0 /* default */
237#define EPP_1_7 0x1
214#define EPP_1_9 0x0 /* default */
215#define EPP_1_7 0x1
238
239 int epp_protocol; /* EPP protocol: 0=1.9, 1=1.7 */
240
241 struct ppb_adapter *adapter; /* link to the ppc adapter */
242 struct ppb_data *ppbus; /* link to the ppbus */
243};
244
216
217/* Parallel Port Chipset IVARS */ /* elsewhere XXX */
218#define PPC_IVAR_EPP_PROTO 0
219#define PPC_IVAR_IRQ 1
220
245/*
246 * Maximum size of the PnP info string
247 */
248#define PPB_PnP_STRING_SIZE 256 /* XXX */
249
250/*
251 * Parallel Port Bus structure.
252 */

--- 5 unchanged lines hidden (view full) ---

258#define PPB_PnP_HDC 3
259#define PPB_PnP_PCMCIA 4
260#define PPB_PnP_MEDIA 5
261#define PPB_PnP_FDC 6
262#define PPB_PnP_PORTS 7
263#define PPB_PnP_SCANNER 8
264#define PPB_PnP_DIGICAM 9
265#define PPB_PnP_UNKNOWN 10
221/*
222 * Maximum size of the PnP info string
223 */
224#define PPB_PnP_STRING_SIZE 256 /* XXX */
225
226/*
227 * Parallel Port Bus structure.
228 */

--- 5 unchanged lines hidden (view full) ---

234#define PPB_PnP_HDC 3
235#define PPB_PnP_PCMCIA 4
236#define PPB_PnP_MEDIA 5
237#define PPB_PnP_FDC 6
238#define PPB_PnP_PORTS 7
239#define PPB_PnP_SCANNER 8
240#define PPB_PnP_DIGICAM 9
241#define PPB_PnP_UNKNOWN 10
266 int class_id; /* not a PnP device if class_id < 0 */
242 int class_id; /* not a PnP device if class_id < 0 */
267
243
268 int state; /* current IEEE1284 state */
269 int error; /* last IEEE1284 error */
244 int state; /* current IEEE1284 state */
245 int error; /* last IEEE1284 error */
270
246
271 ushort mode; /* IEEE 1284-1994 mode
272 * NIBBLE, PS2, EPP or ECP */
247 int mode; /* IEEE 1284-1994 mode
248 * NIBBLE, PS2, EPP or ECP */
273
249
274 struct ppb_link *ppb_link; /* link to the adapter */
275 struct ppb_device *ppb_owner; /* device which owns the bus */
276 LIST_HEAD(, ppb_device) ppb_devs; /* list of devices on the bus */
277 LIST_ENTRY(ppb_data) ppb_chain; /* list of busses */
250 void *ppb_owner; /* device which owns the bus */
278};
279
251};
252
280/*
281 * Parallel Port Bus driver structure.
282 */
283struct ppb_driver
284{
285 struct ppb_device *(*probe)(struct ppb_data *ppb);
286 int (*attach)(struct ppb_device *pdp);
287 char *name;
288};
253extern int ppb_attach_device(device_t);
254extern int ppb_request_bus(device_t, device_t, int);
255extern int ppb_release_bus(device_t, device_t);
289
256
290extern struct linker_set ppbdriver_set;
257/* bus related functions */
258extern int ppb_get_status(device_t, struct ppb_status *);
259extern int ppb_poll_bus(device_t, int, char, char, int);
260extern int ppb_reset_epp_timeout(device_t);
261extern int ppb_ecp_sync(device_t);
262extern int ppb_get_epp_protocol(device_t);
263extern int ppb_set_mode(device_t, int); /* returns old mode */
264extern int ppb_get_mode(device_t); /* returns current mode */
265extern int ppb_write(device_t, char *, int, int);
291
266
292extern struct ppb_data *ppb_alloc_bus(void);
293extern struct ppb_data *ppb_next_bus(struct ppb_data *);
294extern struct ppb_data *ppb_lookup_bus(int);
295extern struct ppb_data *ppb_lookup_link(int);
296
297extern int ppb_attach_device(struct ppb_device *);
298extern void ppb_remove_device(struct ppb_device *);
299extern int ppb_attachdevs(struct ppb_data *);
300
301extern int ppb_request_bus(struct ppb_device *, int);
302extern int ppb_release_bus(struct ppb_device *);
303
304extern void ppb_intr(struct ppb_link *);
305
306extern int ppb_poll_device(struct ppb_device *, int, char, char, int);
307
308extern int ppb_reset_epp_timeout(struct ppb_device *);
309extern int ppb_ecp_sync(struct ppb_device *);
310extern int ppb_get_status(struct ppb_device *, struct ppb_status *);
311
312extern int ppb_set_mode(struct ppb_device *, int);
313extern int ppb_write(struct ppb_device *, char *, int, int);
314
315/*
316 * These are defined as macros for speedup.
267/*
268 * These are defined as macros for speedup.
317 */
318#define ppb_get_base_addr(dev) ((dev)->ppb->ppb_link->base)
319#define ppb_get_epp_protocol(dev) ((dev)->ppb->ppb_link->epp_protocol)
320#define ppb_get_irq(dev) ((dev)->ppb->ppb_link->id_irq)
269#define ppb_get_base_addr(dev) ((dev)->ppb->ppb_link->base)
270#define ppb_get_epp_protocol(dev) ((dev)->ppb->ppb_link->epp_protocol)
271#define ppb_get_irq(dev) ((dev)->ppb->ppb_link->id_irq)
272 */
321
273
322#define ppb_get_mode(dev) ((dev)->mode)
323
324/* This set of function access only to the EPP _data_ registers
325 * in 8, 16 and 32 bit modes */
326#define ppb_outsb_epp(dev,buf,cnt) \
327 (*(dev)->ppb->ppb_link->adapter->outsb_epp) \
328 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt)
329#define ppb_outsw_epp(dev,buf,cnt) \
330 (*(dev)->ppb->ppb_link->adapter->outsw_epp) \
331 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt)
332#define ppb_outsl_epp(dev,buf,cnt) \
333 (*(dev)->ppb->ppb_link->adapter->outsl_epp) \
334 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt)
335#define ppb_insb_epp(dev,buf,cnt) \
336 (*(dev)->ppb->ppb_link->adapter->insb_epp) \
337 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt)
338#define ppb_insw_epp(dev,buf,cnt) \
339 (*(dev)->ppb->ppb_link->adapter->insw_epp) \
340 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt)
341#define ppb_insl_epp(dev,buf,cnt) \
342 (*(dev)->ppb->ppb_link->adapter->insl_epp) \
343 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt)
344
345#define ppb_repp_A(dev) (*(dev)->ppb->ppb_link->adapter->r_epp_A) \
346 ((dev)->ppb->ppb_link->adapter_unit)
347#define ppb_repp_D(dev) (*(dev)->ppb->ppb_link->adapter->r_epp_D) \
348 ((dev)->ppb->ppb_link->adapter_unit)
349#define ppb_recr(dev) (*(dev)->ppb->ppb_link->adapter->r_ecr) \
350 ((dev)->ppb->ppb_link->adapter_unit)
351#define ppb_rfifo(dev) (*(dev)->ppb->ppb_link->adapter->r_fifo) \
352 ((dev)->ppb->ppb_link->adapter_unit)
353#define ppb_wepp_A(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_epp_A) \
354 ((dev)->ppb->ppb_link->adapter_unit, byte)
355#define ppb_wepp_D(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_epp_D) \
356 ((dev)->ppb->ppb_link->adapter_unit, byte)
357#define ppb_wecr(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_ecr) \
358 ((dev)->ppb->ppb_link->adapter_unit, byte)
359#define ppb_wfifo(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_fifo) \
360 ((dev)->ppb->ppb_link->adapter_unit, byte)
361
362#define ppb_rdtr(dev) (*(dev)->ppb->ppb_link->adapter->r_dtr) \
363 ((dev)->ppb->ppb_link->adapter_unit)
364#define ppb_rstr(dev) (*(dev)->ppb->ppb_link->adapter->r_str) \
365 ((dev)->ppb->ppb_link->adapter_unit)
366#define ppb_rctr(dev) (*(dev)->ppb->ppb_link->adapter->r_ctr) \
367 ((dev)->ppb->ppb_link->adapter_unit)
368#define ppb_wdtr(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_dtr) \
369 ((dev)->ppb->ppb_link->adapter_unit, byte)
370#define ppb_wstr(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_str) \
371 ((dev)->ppb->ppb_link->adapter_unit, byte)
372#define ppb_wctr(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_ctr) \
373 ((dev)->ppb->ppb_link->adapter_unit, byte)
374
375#endif
274#endif