2 * Copyright (c) 1997, 1998, 1999 Nicolas Souchu
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
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
26 * $FreeBSD: src/sys/dev/ppbus/ppbconf.h,v 1.17.2.1 2000/05/24 00:20:57 n_hibma Exp $
27 * $DragonFly: src/sys/bus/ppbus/ppbconf.h,v 1.2 2003/06/17 04:28:29 dillon Exp $
33 #include <sys/queue.h>
36 * Parallel Port Bus sleep/wakeup queue.
38 #define PPBPRI (PZERO+8)
41 * Parallel Port Chipset mode masks.
42 * NIBBLE mode is supposed to be available under each other modes.
44 #define PPB_COMPATIBLE 0x0 /* Centronics compatible mode */
46 #define PPB_NIBBLE 0x1 /* reverse 4 bit mode */
47 #define PPB_PS2 0x2 /* PS/2 byte mode */
48 #define PPB_EPP 0x4 /* EPP mode, 32 bit */
49 #define PPB_ECP 0x8 /* ECP mode */
52 #define PPB_SPP PPB_NIBBLE|PPB_PS2
53 #define PPB_BYTE PPB_PS2
56 #define PPB_OPTIONS_MASK 0xf0
58 #define PPB_IS_EPP(mode) (mode & PPB_EPP)
59 #define PPB_IN_EPP_MODE(bus) (PPB_IS_EPP (ppb_get_mode (bus)))
60 #define PPB_IN_NIBBLE_MODE(bus) (ppb_get_mode (bus) & PPB_NIBBLE)
61 #define PPB_IN_PS2_MODE(bus) (ppb_get_mode (bus) & PPB_PS2)
63 #define n(flags) (~(flags) & (flags))
66 * Parallel Port Chipset control bits.
72 #define IRQENABLE 0x10
75 #define nSTROBE n(STROBE)
76 #define nAUTOFEED n(AUTOFEED)
78 #define nSELECTIN n(SELECTIN)
82 * Parallel Port Chipset status bits.
92 * Structure to store status information.
97 unsigned int timeout:1;
99 unsigned int select:1;
100 unsigned int paper_end:1;
105 /* Parallel port bus I/O opcodes */
106 #define PPB_OUTSB_EPP 1
107 #define PPB_OUTSW_EPP 2
108 #define PPB_OUTSL_EPP 3
109 #define PPB_INSB_EPP 4
110 #define PPB_INSW_EPP 5
111 #define PPB_INSL_EPP 6
115 #define PPB_REPP_A 10
116 #define PPB_REPP_D 11
122 #define PPB_WEPP_A 17
123 #define PPB_WEPP_D 18
128 * How tsleep() is called in ppb_request_bus().
130 #define PPB_DONTWAIT 0
135 #define PPB_FOREVER -1
138 * Microsequence stuff.
140 #define PPB_MS_MAXLEN 64 /* XXX according to MS_INS_MASK */
141 #define PPB_MS_MAXARGS 3 /* according to MS_ARG_MASK */
143 /* maximum number of mode dependent
144 * submicrosequences for in/out operations
146 #define PPB_MAX_XFER 6
152 int (* f)(void *, char *);
155 struct ppb_microseq {
156 int opcode; /* microins. opcode */
157 union ppb_insarg arg[PPB_MS_MAXARGS]; /* arguments */
160 /* microseqences used for GET/PUT operations */
162 struct ppb_microseq *loop; /* the loop microsequence */
166 * Parallel Port Bus Device structure.
168 struct ppb_data; /* see below */
171 int valid; /* 1 if the struct is valid */
172 int mode; /* XXX chipset operating mode */
174 struct microseq *curpc; /* pc in curmsq */
175 struct microseq *curmsq; /* currently executed microseqence */
179 * List of IVARS available to ppb device drivers
181 #define PPBUS_IVAR_MODE 0
182 #define PPBUS_IVAR_AVM 1
183 #define PPBUS_IVAR_IRQ 2
185 /* other fields are reserved to the ppbus internals */
189 const char *name; /* name of the device */
191 ushort mode; /* current mode of the device */
192 ushort avm; /* available IEEE1284 modes of
194 uint flags; /* flags */
196 struct ppb_context ctx; /* context of the device */
198 /* mode dependent get msq. If NULL,
199 * IEEE1284 code is used */
201 get_xfer[PPB_MAX_XFER];
203 /* mode dependent put msq. If NULL,
204 * IEEE1284 code is used */
206 put_xfer[PPB_MAX_XFER];
208 struct resource *intr_resource;
211 void *drv1, *drv2; /* drivers private data */
215 #define EPP_1_9 0x0 /* default */
218 /* Parallel Port Chipset IVARS */ /* elsewhere XXX */
219 #define PPC_IVAR_EPP_PROTO 0
220 #define PPC_IVAR_IRQ 1
223 * Maximum size of the PnP info string
225 #define PPB_PnP_STRING_SIZE 256 /* XXX */
228 * Parallel Port Bus structure.
232 #define PPB_PnP_PRINTER 0
233 #define PPB_PnP_MODEM 1
234 #define PPB_PnP_NET 2
235 #define PPB_PnP_HDC 3
236 #define PPB_PnP_PCMCIA 4
237 #define PPB_PnP_MEDIA 5
238 #define PPB_PnP_FDC 6
239 #define PPB_PnP_PORTS 7
240 #define PPB_PnP_SCANNER 8
241 #define PPB_PnP_DIGICAM 9
242 #define PPB_PnP_UNKNOWN 10
243 int class_id; /* not a PnP device if class_id < 0 */
245 int state; /* current IEEE1284 state */
246 int error; /* last IEEE1284 error */
248 int mode; /* IEEE 1284-1994 mode
249 * NIBBLE, PS2, EPP or ECP */
251 void *ppb_owner; /* device which owns the bus */
255 extern int ppb_attach_device(device_t);
256 extern int ppb_request_bus(device_t, device_t, int);
257 extern int ppb_release_bus(device_t, device_t);
259 /* bus related functions */
260 extern int ppb_get_status(device_t, struct ppb_status *);
261 extern int ppb_poll_bus(device_t, int, char, char, int);
262 extern int ppb_reset_epp_timeout(device_t);
263 extern int ppb_ecp_sync(device_t);
264 extern int ppb_get_epp_protocol(device_t);
265 extern int ppb_set_mode(device_t, int); /* returns old mode */
266 extern int ppb_get_mode(device_t); /* returns current mode */
267 extern int ppb_write(device_t, char *, int, int);
271 * These are defined as macros for speedup.
272 #define ppb_get_base_addr(dev) ((dev)->ppb->ppb_link->base)
273 #define ppb_get_epp_protocol(dev) ((dev)->ppb->ppb_link->epp_protocol)
274 #define ppb_get_irq(dev) ((dev)->ppb->ppb_link->id_irq)