1/*- |
2 * Copyright (c) 1997, 1998 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 * |
26 * $Id: ppbconf.h,v 1.6 1998/06/07 19:44:21 phk Exp $ |
27 * 28 */ 29#ifndef __PPBCONF_H 30#define __PPBCONF_H 31 32#include <sys/queue.h> 33 34/* 35 * Parallel Port Bus sleep/wakeup queue. 36 */ 37#define PPBPRI PZERO+8 38 39/* |
40 * Parallel Port Chipset mode masks. 41 * NIBBLE mode is supposed to be available under each other modes. |
42 */ |
43#define PPB_COMPATIBLE 0x0 /* Centronics compatible mode */ 44 45#define PPB_NIBBLE 0x1 /* reverse 4 bit mode */ |
46#define PPB_PS2 0x2 /* PS/2 byte mode */ |
47#define PPB_EPP 0x4 /* EPP mode, 32 bit */ 48#define PPB_ECP 0x8 /* ECP mode */ |
49 |
50#define PPB_SPP PPB_NIBBLE|PPB_PS2 |
51 |
52#define PPB_IS_EPP(mode) (mode & PPB_EPP) |
53#define PPB_IN_EPP_MODE(dev) (PPB_IS_EPP (ppb_get_mode (dev))) 54 |
55#define n(flags) (~(flags) & (flags)) 56 |
57/* 58 * Parallel Port Chipset control bits. 59 */ 60#define STROBE 0x01 61#define AUTOFEED 0x02 62#define nINIT 0x04 63#define SELECTIN 0x08 64#define IRQENABLE 0x10 65#define PCD 0x20 66 |
67#define nSTROBE n(STROBE) 68#define nAUTOFEED n(AUTOFEED) 69#define INIT n(nINIT) 70#define nSELECTIN n(SELECTIN) 71#define nPCD n(PCD) 72 |
73/* 74 * Parallel Port Chipset status bits. 75 */ 76#define TIMEOUT 0x01 77#define nFAULT 0x08 78#define SELECT 0x10 79#define ERROR 0x20 80#define nACK 0x40 --- 9 unchanged lines hidden (view full) --- 90 unsigned int error:1; 91 unsigned int select:1; 92 unsigned int paper_end:1; 93 unsigned int ack:1; 94 unsigned int busy:1; 95}; 96 97/* |
98 * How tsleep() is called in ppb_request_bus(). |
99 */ 100#define PPB_DONTWAIT 0 101#define PPB_NOINTR 0 102#define PPB_WAIT 0x1 103#define PPB_INTR 0x2 104 |
105/* 106 * Microsequence stuff. 107 */ 108#define PPB_MS_MAXLEN 64 /* XXX according to MS_INS_MASK */ 109#define PPB_MS_MAXARGS 3 /* according to MS_ARG_MASK */ |
110 |
111/* maximum number of mode dependent 112 * submicrosequences for in/out operations 113 */ 114#define PPB_MAX_XFER 6 115 116union ppb_insarg { 117 int i; 118 char c; 119 void *p; 120 int (* f)(void *, char *); 121}; 122 123struct ppb_microseq { 124 int opcode; /* microins. opcode */ 125 union ppb_insarg arg[PPB_MS_MAXARGS]; /* arguments */ 126}; 127 128/* microseqences used for GET/PUT operations */ 129struct ppb_xfer { 130 struct ppb_microseq *loop; /* the loop microsequence */ 131}; 132 |
133/* 134 * Parallel Port Bus Device structure. 135 */ |
136struct ppb_data; /* see below */ 137 138struct ppb_context { 139 int valid; /* 1 if the struct is valid */ 140 int mode; /* XXX chipset operating mode */ 141 142 struct microseq *curpc; /* pc in curmsq */ 143 struct microseq *curmsq; /* currently executed microseqence */ 144}; 145 146 |
147struct ppb_device { 148 149 int id_unit; /* unit of the device */ |
150 char *name; /* name of the device */ |
151 |
152 ushort mode; /* current mode of the device */ 153 ushort avm; /* available modes of the device */ 154 155 struct ppb_context ctx; /* context of the device */ 156 157 /* mode dependent get msq. If NULL, 158 * IEEE1284 code is used */ 159 struct ppb_xfer 160 get_xfer[PPB_MAX_XFER]; 161 162 /* mode dependent put msq. If NULL, 163 * IEEE1284 code is used */ 164 struct ppb_xfer 165 put_xfer[PPB_MAX_XFER]; 166 |
167 void (*intr)(int); /* interrupt handler */ 168 169 struct ppb_data *ppb; /* link to the ppbus */ 170 171 LIST_ENTRY(ppb_device) chain; /* list of devices on the bus */ 172}; 173 174/* 175 * Parallel Port Bus Adapter structure. 176 */ 177struct ppb_adapter { 178 179 void (*intr_handler)(int); 180 void (*reset_epp_timeout)(int); 181 void (*ecp_sync)(int); 182 |
183 int (*exec_microseq)(int, struct ppb_microseq *, int *); 184 185 int (*setmode)(int, int); 186 |
187 void (*outsb_epp)(int, char *, int); 188 void (*outsw_epp)(int, char *, int); 189 void (*outsl_epp)(int, char *, int); 190 void (*insb_epp)(int, char *, int); 191 void (*insw_epp)(int, char *, int); 192 void (*insl_epp)(int, char *, int); 193 194 char (*r_dtr)(int); --- 12 unchanged lines hidden (view full) --- 207}; 208 209/* 210 * ppb_link structure. 211 */ 212struct ppb_link { 213 214 int adapter_unit; /* unit of the adapter */ |
215 int base; /* base address of the port */ 216 int id_irq; /* != 0 if irq enabled */ |
217 218#define EPP_1_9 0x0 /* default */ 219#define EPP_1_7 0x1 220 221 int epp_protocol; /* EPP protocol: 0=1.9, 1=1.7 */ 222 223 struct ppb_adapter *adapter; /* link to the ppc adapter */ 224 struct ppb_data *ppbus; /* link to the ppbus */ 225}; 226 227/* 228 * Maximum size of the PnP info string 229 */ |
230#define PPB_PnP_STRING_SIZE 128 /* XXX */ |
231 232/* 233 * Parallel Port Bus structure. 234 */ 235struct ppb_data { 236 237#define PPB_PnP_PRINTER 0 238#define PPB_PnP_MODEM 1 239#define PPB_PnP_NET 2 240#define PPB_PnP_HDC 3 241#define PPB_PnP_PCMCIA 4 242#define PPB_PnP_MEDIA 5 243#define PPB_PnP_FDC 6 244#define PPB_PnP_PORTS 7 245#define PPB_PnP_SCANNER 8 246#define PPB_PnP_DIGICAM 9 247#define PPB_PnP_UNKNOWN 10 248 int class_id; /* not a PnP device if class_id < 0 */ 249 |
250 ushort mode; /* IEEE 1284-1994 mode 251 * NIBBLE, PS2, EPP or ECP */ 252 ushort avm; /* IEEE 1284-1994 available 253 * modes */ 254 |
255 struct ppb_link *ppb_link; /* link to the adapter */ 256 struct ppb_device *ppb_owner; /* device which owns the bus */ 257 LIST_HEAD(, ppb_device) ppb_devs; /* list of devices on the bus */ 258 LIST_ENTRY(ppb_data) ppb_chain; /* list of busses */ 259}; 260 261/* 262 * Parallel Port Bus driver structure. --- 5 unchanged lines hidden (view full) --- 268 char *name; 269}; 270 271extern struct linker_set ppbdriver_set; 272 273extern struct ppb_data *ppb_alloc_bus(void); 274extern struct ppb_data *ppb_next_bus(struct ppb_data *); 275extern struct ppb_data *ppb_lookup_bus(int); |
276extern struct ppb_data *ppb_lookup_link(int); |
277 278extern int ppb_attach_device(struct ppb_device *); 279extern void ppb_remove_device(struct ppb_device *); 280extern int ppb_attachdevs(struct ppb_data *); 281 282extern int ppb_request_bus(struct ppb_device *, int); 283extern int ppb_release_bus(struct ppb_device *); 284 285extern void ppb_intr(struct ppb_link *); 286 287extern int ppb_poll_device(struct ppb_device *, int, char, char, int); 288 289extern int ppb_reset_epp_timeout(struct ppb_device *); 290extern int ppb_ecp_sync(struct ppb_device *); 291extern int ppb_get_status(struct ppb_device *, struct ppb_status *); |
292 |
293extern int ppb_set_mode(struct ppb_device *, int); 294 |
295/* 296 * These are defined as macros for speedup. 297 */ |
298#define ppb_get_base_addr(dev) ((dev)->ppb->ppb_link->base) 299#define ppb_get_epp_protocol(dev) ((dev)->ppb->ppb_link->epp_protocol) 300#define ppb_get_irq(dev) ((dev)->ppb->ppb_link->id_irq) 301 302#define ppb_get_mode(dev) ((dev)->mode) 303 304#define ppb_outsb_epp(dev,buf,cnt) \ 305 (*(dev)->ppb->ppb_link->adapter->outsb_epp) \ |
306 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt) |
307#define ppb_outsw_epp(dev,buf,cnt) \ 308 (*(dev)->ppb->ppb_link->adapter->outsw_epp) \ |
309 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt) |
310#define ppb_outsl_epp(dev,buf,cnt) \ 311 (*(dev)->ppb->ppb_link->adapter->outsl_epp) \ |
312 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt) |
313#define ppb_insb_epp(dev,buf,cnt) \ 314 (*(dev)->ppb->ppb_link->adapter->insb_epp) \ |
315 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt) |
316#define ppb_insw_epp(dev,buf,cnt) \ 317 (*(dev)->ppb->ppb_link->adapter->insw_epp) \ |
318 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt) |
319#define ppb_insl_epp(dev,buf,cnt) \ 320 (*(dev)->ppb->ppb_link->adapter->insl_epp) \ |
321 ((dev)->ppb->ppb_link->adapter_unit, buf, cnt) 322 |
323#define ppb_repp(dev) (*(dev)->ppb->ppb_link->adapter->r_epp) \ |
324 ((dev)->ppb->ppb_link->adapter_unit) |
325#define ppb_recr(dev) (*(dev)->ppb->ppb_link->adapter->r_ecr) \ |
326 ((dev)->ppb->ppb_link->adapter_unit) |
327#define ppb_rfifo(dev) (*(dev)->ppb->ppb_link->adapter->r_fifo) \ |
328 ((dev)->ppb->ppb_link->adapter_unit) |
329#define ppb_wepp(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_epp) \ 330 ((dev)->ppb->ppb_link->adapter_unit, byte) 331#define ppb_wecr(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_ecr) \ 332 ((dev)->ppb->ppb_link->adapter_unit, byte) 333#define ppb_wfifo(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_fifo) \ 334 ((dev)->ppb->ppb_link->adapter_unit, byte) 335 336#define ppb_rdtr(dev) (*(dev)->ppb->ppb_link->adapter->r_dtr) \ |
337 ((dev)->ppb->ppb_link->adapter_unit) |
338#define ppb_rstr(dev) (*(dev)->ppb->ppb_link->adapter->r_str) \ |
339 ((dev)->ppb->ppb_link->adapter_unit) |
340#define ppb_rctr(dev) (*(dev)->ppb->ppb_link->adapter->r_ctr) \ |
341 ((dev)->ppb->ppb_link->adapter_unit) |
342#define ppb_wdtr(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_dtr) \ |
343 ((dev)->ppb->ppb_link->adapter_unit, byte) |
344#define ppb_wstr(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_str) \ |
345 ((dev)->ppb->ppb_link->adapter_unit, byte) |
346#define ppb_wctr(dev,byte) (*(dev)->ppb->ppb_link->adapter->w_ctr) \ |
347 ((dev)->ppb->ppb_link->adapter_unit, byte) |
348 349#endif |