feeea7cff032d08c92a4fb18a8aef4a80722730b
[firefly-linux-kernel-4.4.55.git] / drivers / staging / dgap / dgap.h
1 /*
2  * Copyright 2003 Digi International (www.digi.com)
3  *      Scott H Kilau <Scott_Kilau at digi dot com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the
12  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13  * PURPOSE.  See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  *
19  *      NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
20  *
21  *************************************************************************
22  *
23  * Driver includes
24  *
25  *************************************************************************/
26
27 #ifndef __DGAP_DRIVER_H
28 #define __DGAP_DRIVER_H
29
30 #include <linux/types.h>        /* To pick up the varions Linux types */
31 #include <linux/tty.h>          /* To pick up the various tty structs/defines */
32 #include <linux/interrupt.h>    /* For irqreturn_t type */
33
34 #ifndef TRUE
35 # define TRUE 1
36 #endif
37
38 #ifndef FALSE
39 # define FALSE 0
40 #endif
41
42 /* Required for our shared headers! */
43 typedef unsigned char           uchar;
44
45 #if !defined(TTY_FLIPBUF_SIZE)
46 # define TTY_FLIPBUF_SIZE 512
47 #endif
48
49 /*************************************************************************
50  *
51  * Driver defines
52  *
53  *************************************************************************/
54
55 /*
56  * Driver identification
57  */
58 #define DG_NAME         "dgap-1.3-16"
59 #define DG_PART         "40002347_C"
60 #define DRVSTR          "dgap"
61
62 /*
63  * defines from dgap_pci.h
64  */ 
65 #define PCIMAX 32                       /* maximum number of PCI boards */
66
67 #define DIGI_VID                0x114F
68
69 #define PCI_DEV_EPC_DID         0x0002
70 #define PCI_DEV_XEM_DID         0x0004
71 #define PCI_DEV_XR_DID          0x0005
72 #define PCI_DEV_CX_DID          0x0006
73 #define PCI_DEV_XRJ_DID         0x0009  /* PLX-based Xr adapter */
74 #define PCI_DEV_XR_IBM_DID      0x0011  /* IBM 8-port Async Adapter */
75 #define PCI_DEV_XR_BULL_DID     0x0013  /* BULL 8-port Async Adapter */
76 #define PCI_DEV_XR_SAIP_DID     0x001c  /* SAIP card - Xr adapter */
77 #define PCI_DEV_XR_422_DID      0x0012  /* Xr-422 */
78 #define PCI_DEV_920_2_DID       0x0034  /* XR-Plus 920 K, 2 port */
79 #define PCI_DEV_920_4_DID       0x0026  /* XR-Plus 920 K, 4 port */
80 #define PCI_DEV_920_8_DID       0x0027  /* XR-Plus 920 K, 8 port */
81 #define PCI_DEV_EPCJ_DID        0x000a  /* PLX 9060 chip for PCI  */
82 #define PCI_DEV_CX_IBM_DID      0x001b  /* IBM 128-port Async Adapter */
83 #define PCI_DEV_920_8_HP_DID    0x0058  /* HP XR-Plus 920 K, 8 port */
84 #define PCI_DEV_XEM_HP_DID      0x0059  /* HP Xem PCI */
85
86 #define PCI_DEV_XEM_NAME        "AccelePort XEM"
87 #define PCI_DEV_CX_NAME         "AccelePort CX"
88 #define PCI_DEV_XR_NAME         "AccelePort Xr"
89 #define PCI_DEV_XRJ_NAME        "AccelePort Xr (PLX)"
90 #define PCI_DEV_XR_SAIP_NAME    "AccelePort Xr (SAIP)"
91 #define PCI_DEV_920_2_NAME      "AccelePort Xr920 2 port"
92 #define PCI_DEV_920_4_NAME      "AccelePort Xr920 4 port"
93 #define PCI_DEV_920_8_NAME      "AccelePort Xr920 8 port"
94 #define PCI_DEV_XR_422_NAME     "AccelePort Xr 422"
95 #define PCI_DEV_EPCJ_NAME       "AccelePort EPC (PLX)"
96 #define PCI_DEV_XR_BULL_NAME    "AccelePort Xr (BULL)"
97 #define PCI_DEV_XR_IBM_NAME     "AccelePort Xr (IBM)"
98 #define PCI_DEV_CX_IBM_NAME     "AccelePort CX (IBM)"
99 #define PCI_DEV_920_8_HP_NAME   "AccelePort Xr920 8 port (HP)"
100 #define PCI_DEV_XEM_HP_NAME     "AccelePort XEM (HP)"
101
102 /*
103  * On the PCI boards, there is no IO space allocated
104  * The I/O registers will be in the first 3 bytes of the
105  * upper 2MB of the 4MB memory space.  The board memory
106  * will be mapped into the low 2MB of the 4MB memory space
107  */
108
109 /* Potential location of PCI Bios from E0000 to FFFFF*/
110 #define PCI_BIOS_SIZE           0x00020000
111
112 /* Size of Memory and I/O for PCI (4MB) */
113 #define PCI_RAM_SIZE            0x00400000
114
115 /* Size of Memory (2MB) */
116 #define PCI_MEM_SIZE            0x00200000
117
118 /* Max PCI Window Size (2MB) */
119 #define PCI_WIN_SIZE            0x00200000
120
121 #define PCI_WIN_SHIFT           21 /* 21 bits max */
122
123 /* Offset of I/0 in Memory (2MB) */
124 #define PCI_IO_OFFSET           0x00200000
125
126 /* Size of IO (2MB) */
127 #define PCI_IO_SIZE             0x00200000
128
129 /* Number of boards we support at once. */
130 #define MAXBOARDS       32
131 #define MAXPORTS        224
132 #define MAXTTYNAMELEN   200
133
134 /* Our 3 magic numbers for our board, channel and unit structs */
135 #define DGAP_BOARD_MAGIC        0x5c6df104
136 #define DGAP_CHANNEL_MAGIC      0x6c6df104
137 #define DGAP_UNIT_MAGIC         0x7c6df104
138
139 /* Serial port types */
140 #define DGAP_SERIAL             0
141 #define DGAP_PRINT              1
142
143 #define SERIAL_TYPE_NORMAL      1
144
145 /* 4 extra for alignment play space */
146 #define WRITEBUFLEN             ((4096) + 4)
147 #define MYFLIPLEN               N_TTY_BUF_SIZE
148
149 #define SBREAK_TIME 0x25
150 #define U2BSIZE 0x400
151
152 #define dgap_jiffies_from_ms(a) (((a) * HZ) / 1000)
153
154 /*
155  * Our major for the mgmt devices.
156  *
157  * We can use 22, because Digi was allocated 22 and 23 for the epca driver.
158  * 22 has now become obsolete now that the "cu" devices have
159  * been removed from 2.6.
160  * Also, this *IS* the epca driver, just PCI only now.
161  */
162 #ifndef DIGI_DGAP_MAJOR
163 # define DIGI_DGAP_MAJOR         22
164 #endif
165
166 /*
167  * The parameters we use to define the periods of the moving averages.
168  */
169 #define         MA_PERIOD       (HZ / 10)
170 #define         SMA_DUR         (1 * HZ)
171 #define         EMA_DUR         (1 * HZ)
172 #define         SMA_NPERIODS    (SMA_DUR / MA_PERIOD)
173 #define         EMA_NPERIODS    (EMA_DUR / MA_PERIOD)
174
175 /*
176  * Define a local default termios struct. All ports will be created
177  * with this termios initially.  This is the same structure that is defined
178  * as the default in tty_io.c with the same settings overriden as in serial.c
179  *
180  * In short, this should match the internal serial ports' defaults.
181  */
182 #define DEFAULT_IFLAGS  (ICRNL | IXON)
183 #define DEFAULT_OFLAGS  (OPOST | ONLCR)
184 #define DEFAULT_CFLAGS  (B9600 | CS8 | CREAD | HUPCL | CLOCAL)
185 #define DEFAULT_LFLAGS  (ISIG | ICANON | ECHO | ECHOE | ECHOK | \
186                         ECHOCTL | ECHOKE | IEXTEN)
187
188 #ifndef _POSIX_VDISABLE
189 #define   _POSIX_VDISABLE '\0'
190 #endif
191
192 #define SNIFF_MAX       65536           /* Sniff buffer size (2^n) */
193 #define SNIFF_MASK      (SNIFF_MAX - 1) /* Sniff wrap mask */
194
195 #define VPDSIZE (512)
196
197 /*
198  * Lock function/defines.
199  * Makes spotting lock/unlock locations easier.
200  */
201 # define DGAP_SPINLOCK_INIT(x)          spin_lock_init(&(x))
202 # define DGAP_LOCK(x,y)                 spin_lock_irqsave(&(x), y)
203 # define DGAP_UNLOCK(x,y)               spin_unlock_irqrestore(&(x), y)
204
205 /************************************************************************
206  *      FEP memory offsets
207  ************************************************************************/
208 #define START           0x0004L         /* Execution start address      */
209
210 #define CMDBUF          0x0d10L         /* Command (cm_t) structure offset */
211 #define CMDSTART        0x0400L         /* Start of command buffer      */
212 #define CMDMAX          0x0800L         /* End of command buffer        */
213
214 #define EVBUF           0x0d18L         /* Event (ev_t) structure       */
215 #define EVSTART         0x0800L         /* Start of event buffer        */
216 #define EVMAX           0x0c00L         /* End of event buffer          */
217 #define FEP5_PLUS       0x0E40          /* ASCII '5' and ASCII 'A' is here  */
218 #define ECS_SEG         0x0E44          /* Segment of the extended channel structure */
219 #define LINE_SPEED      0x10            /* Offset into ECS_SEG for line speed   */
220                                         /* if the fep has extended capabilities */
221
222 /* BIOS MAGIC SPOTS */
223 #define ERROR           0x0C14L         /* BIOS error code              */
224 #define SEQUENCE        0x0C12L         /* BIOS sequence indicator      */
225 #define POSTAREA        0x0C00L         /* POST complete message area   */
226
227 /* FEP MAGIC SPOTS */
228 #define FEPSTAT         POSTAREA        /* OS here when FEP comes up    */
229 #define NCHAN           0x0C02L         /* number of ports FEP sees     */
230 #define PANIC           0x0C10L         /* PANIC area for FEP           */
231 #define KMEMEM          0x0C30L         /* Memory for KME use           */
232 #define CONFIG          0x0CD0L         /* Concentrator configuration info */
233 #define CONFIGSIZE      0x0030          /* configuration info size      */
234 #define DOWNREQ         0x0D00          /* Download request buffer pointer */
235
236 #define CHANBUF         0x1000L         /* Async channel (bs_t) structs */
237 #define FEPOSSIZE       0x1FFF          /* 8K FEPOS                     */
238
239 #define XEMPORTS    0xC02       /*
240                                  * Offset in board memory where FEP5 stores
241                                  * how many ports it has detected.
242                                  * NOTE: FEP5 reports 64 ports when the user
243                                  * has the cable in EBI OUT instead of EBI IN.
244                                  */
245
246 #define FEPCLR      0x00
247 #define FEPMEM      0x02
248 #define FEPRST      0x04
249 #define FEPINT      0x08
250 #define FEPMASK     0x0e
251 #define FEPWIN      0x80
252
253 #define LOWMEM      0x0100
254 #define HIGHMEM     0x7f00
255
256 #define FEPTIMEOUT 200000
257
258 #define ENABLE_INTR             0x0e04          /* Enable interrupts flag */
259 #define FEPPOLL_MIN             1               /* minimum of 1 millisecond */
260 #define FEPPOLL_MAX             20              /* maximum of 20 milliseconds */
261 #define FEPPOLL                 0x0c26          /* Fep event poll interval */
262
263 #define IALTPIN                 0x0080          /* Input flag to swap DSR <-> DCD */
264
265 /************************************************************************
266  * FEP supported functions
267  ************************************************************************/
268 #define SRLOW           0xe0            /* Set receive low water        */
269 #define SRHIGH          0xe1            /* Set receive high water       */
270 #define FLUSHTX         0xe2            /* Flush transmit buffer        */
271 #define PAUSETX         0xe3            /* Pause data transmission      */
272 #define RESUMETX        0xe4            /* Resume data transmission     */
273 #define SMINT           0xe5            /* Set Modem Interrupt          */
274 #define SAFLOWC         0xe6            /* Set Aux. flow control chars  */
275 #define SBREAK          0xe8            /* Send break                   */
276 #define SMODEM          0xe9            /* Set 8530 modem control lines */
277 #define SIFLAG          0xea            /* Set UNIX iflags              */
278 #define SFLOWC          0xeb            /* Set flow control characters  */
279 #define STLOW           0xec            /* Set transmit low water mark  */
280 #define RPAUSE          0xee            /* Pause receive                */
281 #define RRESUME         0xef            /* Resume receive               */
282 #define CHRESET         0xf0            /* Reset Channel                */
283 #define BUFSETALL       0xf2            /* Set Tx & Rx buffer size avail*/
284 #define SOFLAG          0xf3            /* Set UNIX oflags              */
285 #define SHFLOW          0xf4            /* Set hardware handshake       */
286 #define SCFLAG          0xf5            /* Set UNIX cflags              */
287 #define SVNEXT          0xf6            /* Set VNEXT character          */
288 #define SPINTFC         0xfc            /* Reserved                     */
289 #define SCOMMODE        0xfd            /* Set RS232/422 mode           */
290
291
292 /************************************************************************
293  *      Modes for SCOMMODE
294  ************************************************************************/
295 #define MODE_232        0x00
296 #define MODE_422        0x01
297
298
299 /************************************************************************
300  *      Event flags.
301  ************************************************************************/
302 #define IFBREAK         0x01            /* Break received               */
303 #define IFTLW           0x02            /* Transmit low water           */
304 #define IFTEM           0x04            /* Transmitter empty            */
305 #define IFDATA          0x08            /* Receive data present         */
306 #define IFMODEM         0x20            /* Modem status change          */
307
308 /************************************************************************
309  *      Modem flags
310  ************************************************************************/
311 #       define  DM_RTS          0x02    /* Request to send              */
312 #       define  DM_CD           0x80    /* Carrier detect               */
313 #       define  DM_DSR          0x20    /* Data set ready               */
314 #       define  DM_CTS          0x10    /* Clear to send                */
315 #       define  DM_RI           0x40    /* Ring indicator               */
316 #       define  DM_DTR          0x01    /* Data terminal ready          */
317
318 /*
319  * defines from dgap_conf.h
320  */
321 #define NULLNODE 0              /* header node, not used */
322 #define BNODE 1                 /* Board node */
323 #define LNODE 2                 /* Line node */
324 #define CNODE 3                 /* Concentrator node */
325 #define MNODE 4                 /* EBI Module node */
326 #define TNODE 5                 /* tty name prefix node */
327 #define CUNODE 6                /* cu name prefix (non-SCO) */
328 #define PNODE 7                 /* trans. print prefix node */
329 #define JNODE 8                 /* maJor number node */
330 #define ANODE 9                 /* altpin */
331 #define TSNODE 10               /* tty structure size */
332 #define CSNODE 11               /* channel structure size */
333 #define BSNODE 12               /* board structure size */
334 #define USNODE 13               /* unit schedule structure size */
335 #define FSNODE 14               /* f2200 structure size */
336 #define VSNODE 15               /* size of VPIX structures */
337 #define INTRNODE 16             /* enable interrupt */
338
339 /* Enumeration of tokens */
340 #define BEGIN   1
341 #define END     2
342 #define BOARD   10
343
344 #define EPCFS   11 /* start of EPC family definitions */
345 #define ICX             11
346 #define MCX             13
347 #define PCX     14
348 #define IEPC    15
349 #define EEPC    16
350 #define MEPC    17
351 #define IPCM    18
352 #define EPCM    19
353 #define MPCM    20
354 #define PEPC    21
355 #define PPCM    22
356 #ifdef CP
357 #define ICP     23
358 #define ECP     24
359 #define MCP     25
360 #endif
361 #define EPCFE   25 /* end of EPC family definitions */
362 #define PC2E    26
363 #define PC4E    27
364 #define PC4E8K  28
365 #define PC8E    29
366 #define PC8E8K  30
367 #define PC16E   31
368 #define MC2E8K  34
369 #define MC4E8K  35
370 #define MC8E8K  36
371
372 #define AVANFS  42      /* start of Avanstar family definitions */
373 #define A8P     42
374 #define A16P    43
375 #define AVANFE  43      /* end of Avanstar family definitions */
376
377 #define DA2000FS        44      /* start of AccelePort 2000 family definitions */
378 #define DA22            44 /* AccelePort 2002 */
379 #define DA24            45 /* AccelePort 2004 */
380 #define DA28            46 /* AccelePort 2008 */
381 #define DA216           47 /* AccelePort 2016 */
382 #define DAR4            48 /* AccelePort RAS 4 port */
383 #define DAR8            49 /* AccelePort RAS 8 port */
384 #define DDR24           50 /* DataFire RAS 24 port */
385 #define DDR30           51 /* DataFire RAS 30 port */
386 #define DDR48           52 /* DataFire RAS 48 port */
387 #define DDR60           53 /* DataFire RAS 60 port */
388 #define DA2000FE        53 /* end of AccelePort 2000/RAS family definitions */
389
390 #define PCXRFS  106     /* start of PCXR family definitions */
391 #define APORT4  106
392 #define APORT8  107
393 #define PAPORT4 108
394 #define PAPORT8 109
395 #define APORT4_920I     110
396 #define APORT8_920I     111
397 #define APORT4_920P     112
398 #define APORT8_920P     113
399 #define APORT2_920P 114
400 #define PCXRFE  117     /* end of PCXR family definitions */
401
402 #define LINE    82
403 #ifdef T1
404 #define T1M     83
405 #define E1M     84
406 #endif
407 #define CONC    64
408 #define CX      65
409 #define EPC     66
410 #define MOD     67
411 #define PORTS   68
412 #define METHOD  69
413 #define CUSTOM  70
414 #define BASIC   71
415 #define STATUS  72
416 #define MODEM   73
417 /* The following tokens can appear in multiple places */
418 #define SPEED   74
419 #define NPORTS  75
420 #define ID      76
421 #define CABLE   77
422 #define CONNECT 78
423 #define IO      79
424 #define MEM     80
425 #define DPSZ    81
426
427 #define TTYN    90
428 #define CU      91
429 #define PRINT   92
430 #define XPRINT  93
431 #define CMAJOR   94
432 #define ALTPIN  95
433 #define STARTO 96
434 #define USEINTR  97
435 #define PCIINFO  98
436
437 #define TTSIZ   100
438 #define CHSIZ   101
439 #define BSSIZ   102
440 #define UNTSIZ  103
441 #define F2SIZ   104
442 #define VPSIZ   105
443
444 #define TOTAL_BOARD     2
445 #define CURRENT_BRD     4
446 #define BOARD_TYPE      6
447 #define IO_ADDRESS      8
448 #define MEM_ADDRESS     10
449
450 #define FIELDS_PER_PAGE 18
451
452 #define TB_FIELD        1
453 #define CB_FIELD        3
454 #define BT_FIELD        5
455 #define IO_FIELD        7
456 #define ID_FIELD        8
457 #define ME_FIELD        9
458 #define TTY_FIELD       11
459 #define CU_FIELD        13
460 #define PR_FIELD        15
461 #define MPR_FIELD       17
462
463 #define MAX_FIELD       512
464
465 #define INIT            0
466 #define NITEMS          128
467 #define MAX_ITEM        512
468
469 #define DSCRINST        1
470 #define DSCRNUM         3
471 #define ALTPINQ         5
472 #define SSAVE           7
473
474 #define DSCR            "32"
475 #define ONETONINE       "123456789"
476 #define ALL             "1234567890"
477
478 /*
479  * All the possible states the driver can be while being loaded.
480  */
481 enum {
482         DRIVER_INITIALIZED = 0,
483         DRIVER_NEED_CONFIG_LOAD,
484         DRIVER_REQUESTED_CONFIG,
485         DRIVER_READY
486 };
487
488 /*
489  * All the possible states the board can be while booting up.
490  */
491 enum {
492         BOARD_FAILED = 0,
493         CONFIG_NOT_FOUND,
494         BOARD_FOUND,
495         NEED_RESET,
496         FINISHED_RESET,
497         NEED_CONFIG,
498         FINISHED_CONFIG,
499         NEED_DEVICE_CREATION,
500         REQUESTED_DEVICE_CREATION,
501         FINISHED_DEVICE_CREATION,
502         NEED_BIOS_LOAD,
503         REQUESTED_BIOS,
504         WAIT_BIOS_LOAD,
505         FINISHED_BIOS_LOAD,
506         NEED_FEP_LOAD,
507         REQUESTED_FEP,
508         WAIT_FEP_LOAD,
509         FINISHED_FEP_LOAD,
510         NEED_PROC_CREATION,
511         FINISHED_PROC_CREATION,
512         BOARD_READY
513 };
514
515 /*
516  * All the possible states that a requested concentrator image can be in.
517  */
518 enum {
519         NO_PENDING_CONCENTRATOR_REQUESTS = 0,
520         NEED_CONCENTRATOR,
521         REQUESTED_CONCENTRATOR
522 };
523
524
525
526 /*
527  * Modem line constants are defined as macros because DSR and
528  * DCD are swapable using the ditty altpin option.
529  */
530 #define D_CD(ch)        ch->ch_cd       /* Carrier detect       */
531 #define D_DSR(ch)       ch->ch_dsr      /* Data set ready       */
532 #define D_RTS(ch)       DM_RTS          /* Request to send      */
533 #define D_CTS(ch)       DM_CTS          /* Clear to send        */
534 #define D_RI(ch)        DM_RI           /* Ring indicator       */
535 #define D_DTR(ch)       DM_DTR          /* Data terminal ready  */
536
537
538 /*************************************************************************
539  *
540  * Structures and closely related defines.
541  *
542  *************************************************************************/
543
544
545 /*
546  * A structure to hold a statistics counter.  We also
547  * compute moving averages for this counter.
548  */
549 struct macounter {
550         u32             cnt;    /* Total count */
551         ulong           accum;  /* Acuumulator per period */
552         ulong           sma;    /* Simple moving average */
553         ulong           ema;    /* Exponential moving average */
554 };
555
556
557 /************************************************************************
558  * Device flag definitions for bd_flags.
559  ************************************************************************/
560 #define BD_FEP5PLUS     0x0001          /* Supports FEP5 Plus commands */
561 #define BD_HAS_VPD      0x0002          /* Board has VPD info available */
562
563 /*
564  *      Per-board information
565  */
566 struct board_t {
567         int             magic;          /* Board Magic number.  */
568         int             boardnum;       /* Board number: 0-3 */
569         int             firstminor;     /* First minor, e.g. 0, 30, 60 */
570
571         int             type;           /* Type of board */
572         char            *name;          /* Product Name */
573         struct pci_dev  *pdev;          /* Pointer to the pci_dev struct */
574         u16             vendor;         /* PCI vendor ID */
575         u16             device;         /* PCI device ID */
576         u16             subvendor;      /* PCI subsystem vendor ID */
577         u16             subdevice;      /* PCI subsystem device ID */
578         uchar           rev;            /* PCI revision ID */
579         uint            pci_bus;        /* PCI bus value */
580         uint            pci_slot;       /* PCI slot value */
581         u16             maxports;       /* MAX ports this board can handle */
582         uchar           vpd[VPDSIZE];   /* VPD of board, if found */
583         u32             bd_flags;       /* Board flags */
584
585         spinlock_t      bd_lock;        /* Used to protect board */
586
587         u32             state;          /* State of card. */
588         wait_queue_head_t state_wait;   /* Place to sleep on for state change */
589
590         struct          tasklet_struct helper_tasklet; /* Poll helper tasklet */
591
592         u32             wait_for_bios;
593         u32             wait_for_fep;
594
595         struct cnode    *bd_config;     /* Config of board */
596
597         u16             nasync;         /* Number of ports on card */
598
599         u32             use_interrupts; /* Should we be interrupt driven? */
600         ulong           irq;            /* Interrupt request number */
601         ulong           intr_count;     /* Count of interrupts */
602         u32             intr_used;      /* Non-zero if using interrupts */
603         u32             intr_running;   /* Non-zero if FEP knows its doing interrupts */
604
605         ulong           port;           /* Start of base io port of the card */
606         ulong           port_end;       /* End of base io port of the card */
607         ulong           membase;        /* Start of base memory of the card */
608         ulong           membase_end;    /* End of base memory of the card */
609
610         uchar           *re_map_port;   /* Remapped io port of the card */
611         uchar           *re_map_membase;/* Remapped memory of the card */
612
613         uchar           runwait;        /* # Processes waiting for FEP  */
614         uchar           inhibit_poller; /* Tells  the poller to leave us alone */
615
616         struct channel_t *channels[MAXPORTS]; /* array of pointers to our channels. */
617
618         struct tty_driver       *SerialDriver;
619         struct tty_port *SerialPorts;
620         char            SerialName[200];
621         struct tty_driver       *PrintDriver;
622         struct tty_port *PrinterPorts;
623         char            PrintName[200];
624
625         u32             dgap_Major_Serial_Registered;
626         u32             dgap_Major_TransparentPrint_Registered;
627
628         u32             dgap_Serial_Major;
629         u32             dgap_TransparentPrint_Major;
630
631         struct bs_t     *bd_bs;                 /* Base structure pointer       */
632
633         char    *flipbuf;               /* Our flip buffer, alloced if board is found */
634         char    *flipflagbuf;           /* Our flip flag buffer, alloced if board is found */
635
636         u16             dpatype;        /* The board "type", as defined by DPA */
637         u16             dpastatus;      /* The board "status", as defined by DPA */
638         wait_queue_head_t kme_wait;     /* Needed for DPA support */
639
640         u32             conc_dl_status; /* Status of any pending conc download */
641 };
642
643
644
645 /************************************************************************
646  * Unit flag definitions for un_flags.
647  ************************************************************************/
648 #define UN_ISOPEN       0x0001          /* Device is open               */
649 #define UN_CLOSING      0x0002          /* Line is being closed         */
650 #define UN_IMM          0x0004          /* Service immediately          */
651 #define UN_BUSY         0x0008          /* Some work this channel       */
652 #define UN_BREAKI       0x0010          /* Input break received         */
653 #define UN_PWAIT        0x0020          /* Printer waiting for terminal */
654 #define UN_TIME         0x0040          /* Waiting on time              */
655 #define UN_EMPTY        0x0080          /* Waiting output queue empty   */
656 #define UN_LOW          0x0100          /* Waiting output low water mark*/
657 #define UN_EXCL_OPEN    0x0200          /* Open for exclusive use       */
658 #define UN_WOPEN        0x0400          /* Device waiting for open      */
659 #define UN_WIOCTL       0x0800          /* Device waiting for open      */
660 #define UN_HANGUP       0x8000          /* Carrier lost                 */
661
662 struct device;
663
664 /************************************************************************
665  * Structure for terminal or printer unit.
666  ************************************************************************/
667 struct un_t {
668         int     magic;          /* Unit Magic Number.                   */
669         struct  channel_t *un_ch;
670         u32     un_time;
671         u32     un_type;
672         u32     un_open_count;  /* Counter of opens to port             */
673         struct tty_struct *un_tty;/* Pointer to unit tty structure      */
674         u32     un_flags;       /* Unit flags                           */
675         wait_queue_head_t un_flags_wait; /* Place to sleep to wait on unit */
676         u32     un_dev;         /* Minor device number                  */
677         tcflag_t un_oflag;      /* oflags being done on board           */
678         tcflag_t un_lflag;      /* lflags being done on board           */
679         struct device *un_sysfs;
680 };
681
682
683 /************************************************************************
684  * Device flag definitions for ch_flags.
685  ************************************************************************/
686 #define CH_PRON         0x0001          /* Printer on string                */
687 #define CH_OUT          0x0002          /* Dial-out device open             */
688 #define CH_STOP         0x0004          /* Output is stopped                */
689 #define CH_STOPI        0x0008          /* Input is stopped                 */
690 #define CH_CD           0x0010          /* Carrier is present               */
691 #define CH_FCAR         0x0020          /* Carrier forced on                */
692
693 #define CH_RXBLOCK      0x0080          /* Enable rx blocked flag           */
694 #define CH_WLOW         0x0100          /* Term waiting low event           */
695 #define CH_WEMPTY       0x0200          /* Term waiting empty event         */
696 #define CH_RENABLE      0x0400          /* Buffer just emptied          */
697 #define CH_RACTIVE      0x0800          /* Process active in xxread()   */
698 #define CH_RWAIT        0x1000          /* Process waiting in xxread()  */
699 #define CH_BAUD0        0x2000          /* Used for checking B0 transitions */
700 #define CH_HANGUP       0x8000          /* Hangup received                  */
701
702 /*
703  * Definitions for ch_sniff_flags
704  */
705 #define SNIFF_OPEN      0x1
706 #define SNIFF_WAIT_DATA 0x2
707 #define SNIFF_WAIT_SPACE 0x4
708
709
710 /************************************************************************
711  ***    Definitions for Digi ditty(1) command.
712  ************************************************************************/
713
714 /************************************************************************
715  * This module provides application access to special Digi
716  * serial line enhancements which are not standard UNIX(tm) features.
717  ************************************************************************/
718
719 #if !defined(TIOCMODG)
720
721 #define TIOCMODG        (('d'<<8) | 250)                /* get modem ctrl state */
722 #define TIOCMODS        (('d'<<8) | 251)                /* set modem ctrl state */
723
724 #ifndef TIOCM_LE
725 #define         TIOCM_LE        0x01            /* line enable          */
726 #define         TIOCM_DTR       0x02            /* data terminal ready  */
727 #define         TIOCM_RTS       0x04            /* request to send      */
728 #define         TIOCM_ST        0x08            /* secondary transmit   */
729 #define         TIOCM_SR        0x10            /* secondary receive    */
730 #define         TIOCM_CTS       0x20            /* clear to send        */
731 #define         TIOCM_CAR       0x40            /* carrier detect       */
732 #define         TIOCM_RNG       0x80            /* ring indicator       */
733 #define         TIOCM_DSR       0x100           /* data set ready       */
734 #define         TIOCM_RI        TIOCM_RNG       /* ring (alternate)     */
735 #define         TIOCM_CD        TIOCM_CAR       /* carrier detect (alt) */
736 #endif
737
738 #endif
739
740 #if !defined(TIOCMSET)
741 #define TIOCMSET        (('d'<<8) | 252)                /* set modem ctrl state */
742 #define TIOCMGET        (('d'<<8) | 253)                /* set modem ctrl state */
743 #endif
744
745 #if !defined(TIOCMBIC)
746 #define TIOCMBIC        (('d'<<8) | 254)                /* set modem ctrl state */
747 #define TIOCMBIS        (('d'<<8) | 255)                /* set modem ctrl state */
748 #endif
749
750
751 #if !defined(TIOCSDTR)
752 #define TIOCSDTR        (('e'<<8) | 0)          /* set DTR              */
753 #define TIOCCDTR        (('e'<<8) | 1)          /* clear DTR            */
754 #endif
755
756 /************************************************************************
757  * Ioctl command arguments for DIGI parameters.
758  ************************************************************************/
759 #define DIGI_GETA       (('e'<<8) | 94)         /* Read params          */
760
761 #define DIGI_SETA       (('e'<<8) | 95)         /* Set params           */
762 #define DIGI_SETAW      (('e'<<8) | 96)         /* Drain & set params   */
763 #define DIGI_SETAF      (('e'<<8) | 97)         /* Drain, flush & set params */
764
765 #define DIGI_KME        (('e'<<8) | 98)         /* Read/Write Host      */
766                                                 /* Adapter Memory       */
767
768 #define DIGI_GETFLOW    (('e'<<8) | 99)         /* Get startc/stopc flow */
769                                                 /* control characters    */
770 #define DIGI_SETFLOW    (('e'<<8) | 100)                /* Set startc/stopc flow */
771                                                 /* control characters    */
772 #define DIGI_GETAFLOW   (('e'<<8) | 101)                /* Get Aux. startc/stopc */
773                                                 /* flow control chars    */
774 #define DIGI_SETAFLOW   (('e'<<8) | 102)                /* Set Aux. startc/stopc */
775                                                 /* flow control chars    */
776
777 #define DIGI_GEDELAY    (('d'<<8) | 246)                /* Get edelay */
778 #define DIGI_SEDELAY    (('d'<<8) | 247)                /* Set edelay */
779
780 struct  digiflow_t {
781         unsigned char   startc;                         /* flow cntl start char */
782         unsigned char   stopc;                          /* flow cntl stop char  */
783 };
784
785
786 #ifdef  FLOW_2200
787 #define F2200_GETA      (('e'<<8) | 104)                /* Get 2x36 flow cntl flags */
788 #define F2200_SETAW     (('e'<<8) | 105)                /* Set 2x36 flow cntl flags */
789 #define         F2200_MASK      0x03            /* 2200 flow cntl bit mask  */
790 #define         FCNTL_2200      0x01            /* 2x36 terminal flow cntl  */
791 #define         PCNTL_2200      0x02            /* 2x36 printer flow cntl   */
792 #define F2200_XON       0xf8
793 #define P2200_XON       0xf9
794 #define F2200_XOFF      0xfa
795 #define P2200_XOFF      0xfb
796
797 #define FXOFF_MASK      0x03                    /* 2200 flow status mask    */
798 #define RCVD_FXOFF      0x01                    /* 2x36 Terminal XOFF rcvd  */
799 #define RCVD_PXOFF      0x02                    /* 2x36 Printer XOFF rcvd   */
800 #endif
801
802 /************************************************************************
803  * Values for digi_flags
804  ************************************************************************/
805 #define DIGI_IXON       0x0001          /* Handle IXON in the FEP       */
806 #define DIGI_FAST       0x0002          /* Fast baud rates              */
807 #define RTSPACE         0x0004          /* RTS input flow control       */
808 #define CTSPACE         0x0008          /* CTS output flow control      */
809 #define DSRPACE         0x0010          /* DSR output flow control      */
810 #define DCDPACE         0x0020          /* DCD output flow control      */
811 #define DTRPACE         0x0040          /* DTR input flow control       */
812 #define DIGI_COOK       0x0080          /* Cooked processing done in FEP */
813 #define DIGI_FORCEDCD   0x0100          /* Force carrier                */
814 #define DIGI_ALTPIN     0x0200          /* Alternate RJ-45 pin config   */
815 #define DIGI_AIXON      0x0400          /* Aux flow control in fep      */
816 #define DIGI_PRINTER    0x0800          /* Hold port open for flow cntrl*/
817 #define DIGI_PP_INPUT   0x1000          /* Change parallel port to input*/
818 #define DIGI_DTR_TOGGLE 0x2000          /* Support DTR Toggle           */
819 #define DIGI_422        0x4000          /* for 422/232 selectable panel */
820 #define DIGI_RTS_TOGGLE 0x8000          /* Support RTS Toggle           */
821
822 /************************************************************************
823  * These options are not supported on the comxi.
824  ************************************************************************/
825 #define DIGI_COMXI      (DIGI_FAST|DIGI_COOK|DSRPACE|DCDPACE|DTRPACE)
826
827 #define DIGI_PLEN       28              /* String length                */
828 #define DIGI_TSIZ       10              /* Terminal string len          */
829
830 /************************************************************************
831  * Structure used with ioctl commands for DIGI parameters.
832  ************************************************************************/
833 struct digi_t {
834         unsigned short  digi_flags;             /* Flags (see above)    */
835         unsigned short  digi_maxcps;            /* Max printer CPS      */
836         unsigned short  digi_maxchar;           /* Max chars in print queue */
837         unsigned short  digi_bufsize;           /* Buffer size          */
838         unsigned char   digi_onlen;             /* Length of ON string  */
839         unsigned char   digi_offlen;            /* Length of OFF string */
840         char            digi_onstr[DIGI_PLEN];  /* Printer on string    */
841         char            digi_offstr[DIGI_PLEN]; /* Printer off string   */
842         char            digi_term[DIGI_TSIZ];   /* terminal string      */
843 };
844
845 /************************************************************************
846  * KME definitions and structures.
847  ************************************************************************/
848 #define RW_IDLE         0       /* Operation complete                   */
849 #define RW_READ         1       /* Read Concentrator Memory             */
850 #define RW_WRITE        2       /* Write Concentrator Memory            */
851
852 struct rw_t {
853         unsigned char   rw_req;         /* Request type                 */
854         unsigned char   rw_board;       /* Host Adapter board number    */
855         unsigned char   rw_conc;        /* Concentrator number          */
856         unsigned char   rw_reserved;    /* Reserved for expansion       */
857         unsigned long   rw_addr;        /* Address in concentrator      */
858         unsigned short  rw_size;        /* Read/write request length    */
859         unsigned char   rw_data[128];   /* Data to read/write           */
860 };
861
862 /***********************************************************************
863  * Shrink Buffer and Board Information definitions and structures.
864
865  ************************************************************************/
866                         /* Board type return codes */
867 #define PCXI_TYPE 1     /* Board type at the designated port is a PC/Xi */
868 #define PCXM_TYPE 2     /* Board type at the designated port is a PC/Xm */
869 #define PCXE_TYPE 3     /* Board type at the designated port is a PC/Xe */
870 #define MCXI_TYPE 4     /* Board type at the designated port is a MC/Xi */
871 #define COMXI_TYPE 5     /* Board type at the designated port is a COM/Xi */
872
873                          /* Non-Zero Result codes. */
874 #define RESULT_NOBDFND 1 /* A Digi product at that port is not config installed */
875 #define RESULT_NODESCT 2 /* A memory descriptor was not obtainable */
876 #define RESULT_NOOSSIG 3 /* FEP/OS signature was not detected on the board */
877 #define RESULT_TOOSML  4 /* Too small an area to shrink.  */
878 #define RESULT_NOCHAN  5 /* Channel structure for the board was not found */
879
880 struct shrink_buf_struct {
881         unsigned long   shrink_buf_vaddr;       /* Virtual address of board */
882         unsigned long   shrink_buf_phys;        /* Physical address of board */
883         unsigned long   shrink_buf_bseg;        /* Amount of board memory */
884         unsigned long   shrink_buf_hseg;        /* '186 Beginning of Dual-Port */
885
886         unsigned long   shrink_buf_lseg;        /* '186 Beginning of freed memory                                               */
887         unsigned long   shrink_buf_mseg;        /* Linear address from start of
888                                                    dual-port were freed memory
889                                                    begins, host viewpoint. */
890
891         unsigned long   shrink_buf_bdparam;     /* Parameter for xxmemon and
892                                                    xxmemoff */
893
894         unsigned long   shrink_buf_reserva;     /* Reserved */
895         unsigned long   shrink_buf_reservb;     /* Reserved */
896         unsigned long   shrink_buf_reservc;     /* Reserved */
897         unsigned long   shrink_buf_reservd;     /* Reserved */
898
899         unsigned char   shrink_buf_result;      /* Reason for call failing
900                                                    Zero is Good return */
901         unsigned char   shrink_buf_init;        /* Non-Zero if it caused an
902                                                    xxinit call. */
903
904         unsigned char   shrink_buf_anports;     /* Number of async ports  */
905         unsigned char   shrink_buf_snports;     /* Number of sync  ports */
906         unsigned char   shrink_buf_type;        /* Board type 1 = PC/Xi,
907                                                               2 = PC/Xm,
908                                                               3 = PC/Xe
909                                                               4 = MC/Xi
910                                                               5 = COMX/i */
911         unsigned char   shrink_buf_card;        /* Card number */
912
913 };
914
915 /************************************************************************
916  * Structure to get driver status information
917  ************************************************************************/
918 struct digi_dinfo {
919         unsigned long   dinfo_nboards;          /* # boards configured  */
920         char            dinfo_reserved[12];     /* for future expansion */
921         char            dinfo_version[16];      /* driver version       */
922 };
923
924 #define DIGI_GETDD      (('d'<<8) | 248)                /* get driver info      */
925
926 /************************************************************************
927  * Structure used with ioctl commands for per-board information
928  *
929  * physsize and memsize differ when board has "windowed" memory
930  ************************************************************************/
931 struct digi_info {
932         unsigned long   info_bdnum;             /* Board number (0 based)  */
933         unsigned long   info_ioport;            /* io port address         */
934         unsigned long   info_physaddr;          /* memory address          */
935         unsigned long   info_physsize;          /* Size of host mem window */
936         unsigned long   info_memsize;           /* Amount of dual-port mem */
937                                                 /* on board                */
938         unsigned short  info_bdtype;            /* Board type              */
939         unsigned short  info_nports;            /* number of ports         */
940         char            info_bdstate;           /* board state             */
941         char            info_reserved[7];       /* for future expansion    */
942 };
943
944 #define DIGI_GETBD      (('d'<<8) | 249)                /* get board info          */
945
946 struct digi_stat {
947         unsigned int    info_chan;              /* Channel number (0 based)  */
948         unsigned int    info_brd;               /* Board number (0 based)  */
949         unsigned long   info_cflag;             /* cflag for channel       */
950         unsigned long   info_iflag;             /* iflag for channel       */
951         unsigned long   info_oflag;             /* oflag for channel       */
952         unsigned long   info_mstat;             /* mstat for channel       */
953         unsigned long   info_tx_data;           /* tx_data for channel       */
954         unsigned long   info_rx_data;           /* rx_data for channel       */
955         unsigned long   info_hflow;             /* hflow for channel       */
956         unsigned long   info_reserved[8];       /* for future expansion    */
957 };
958
959 #define DIGI_GETSTAT    (('d'<<8) | 244)                /* get board info          */
960 /************************************************************************
961  *
962  * Structure used with ioctl commands for per-channel information
963  *
964  ************************************************************************/
965 struct digi_ch {
966         unsigned long   info_bdnum;             /* Board number (0 based)  */
967         unsigned long   info_channel;           /* Channel index number    */
968         unsigned long   info_ch_cflag;          /* Channel cflag           */
969         unsigned long   info_ch_iflag;          /* Channel iflag           */
970         unsigned long   info_ch_oflag;          /* Channel oflag           */
971         unsigned long   info_chsize;            /* Channel structure size  */
972         unsigned long   info_sleep_stat;        /* sleep status            */
973         dev_t           info_dev;               /* device number           */
974         unsigned char   info_initstate;         /* Channel init state      */
975         unsigned char   info_running;           /* Channel running state   */
976         long            reserved[8];            /* reserved for future use */
977 };
978
979 /*
980 * This structure is used with the DIGI_FEPCMD ioctl to
981 * tell the driver which port to send the command for.
982 */
983 struct digi_cmd {
984         int     cmd;
985         int     word;
986         int     ncmds;
987         int     chan; /* channel index (zero based) */
988         int     bdid; /* board index (zero based) */
989 };
990
991 /*
992 *  info_sleep_stat defines
993 */
994 #define INFO_RUNWAIT    0x0001
995 #define INFO_WOPEN      0x0002
996 #define INFO_TTIOW      0x0004
997 #define INFO_CH_RWAIT   0x0008
998 #define INFO_CH_WEMPTY  0x0010
999 #define INFO_CH_WLOW    0x0020
1000 #define INFO_XXBUF_BUSY 0x0040
1001
1002 #define DIGI_GETCH      (('d'<<8) | 245)                /* get board info          */
1003
1004 /* Board type definitions */
1005
1006 #define SUBTYPE         0007
1007 #define T_PCXI          0000
1008 #define T_PCXM          0001
1009 #define T_PCXE          0002
1010 #define T_PCXR          0003
1011 #define T_SP            0004
1012 #define T_SP_PLUS       0005
1013 #       define T_HERC   0000
1014 #       define T_HOU    0001
1015 #       define T_LON    0002
1016 #       define T_CHA    0003
1017 #define FAMILY          0070
1018 #define T_COMXI         0000
1019 #define T_PCXX          0010
1020 #define T_CX            0020
1021 #define T_EPC           0030
1022 #define T_PCLITE        0040
1023 #define T_SPXX          0050
1024 #define T_AVXX          0060
1025 #define T_DXB           0070
1026 #define T_A2K_4_8       0070
1027 #define BUSTYPE         0700
1028 #define T_ISABUS        0000
1029 #define T_MCBUS         0100
1030 #define T_EISABUS       0200
1031 #define T_PCIBUS        0400
1032
1033 /* Board State Definitions */
1034
1035 #define BD_RUNNING      0x0
1036 #define BD_REASON       0x7f
1037 #define BD_NOTFOUND     0x1
1038 #define BD_NOIOPORT     0x2
1039 #define BD_NOMEM        0x3
1040 #define BD_NOBIOS       0x4
1041 #define BD_NOFEP        0x5
1042 #define BD_FAILED       0x6
1043 #define BD_ALLOCATED    0x7
1044 #define BD_TRIBOOT      0x8
1045 #define BD_BADKME       0x80
1046
1047 #define DIGI_LOOPBACK         (('d'<<8) | 252)          /* Enable/disable UART internal loopback */
1048 #define DIGI_SPOLL            (('d'<<8) | 254)          /* change poller rate   */
1049
1050 #define DIGI_SETCUSTOMBAUD      _IOW('e', 106, int)     /* Set integer baud rate */
1051 #define DIGI_GETCUSTOMBAUD      _IOR('e', 107, int)     /* Get integer baud rate */
1052 #define DIGI_RESET_PORT         (('e'<<8) | 93)         /* Reset port           */
1053
1054 /************************************************************************
1055  * Channel information structure.
1056  ************************************************************************/
1057 struct channel_t {
1058         int magic;                      /* Channel Magic Number         */
1059         struct bs_t     *ch_bs;         /* Base structure pointer       */
1060         struct cm_t     *ch_cm;         /* Command queue pointer        */
1061         struct board_t *ch_bd;          /* Board structure pointer      */
1062         unsigned char *ch_vaddr;        /* FEP memory origin            */
1063         unsigned char *ch_taddr;        /* Write buffer origin          */
1064         unsigned char *ch_raddr;        /* Read buffer origin           */
1065         struct digi_t  ch_digi;         /* Transparent Print structure  */
1066         struct un_t ch_tun;             /* Terminal unit info           */
1067         struct un_t ch_pun;             /* Printer unit info            */
1068
1069         spinlock_t      ch_lock;        /* provide for serialization */
1070         wait_queue_head_t ch_flags_wait;
1071
1072         u32     pscan_state;
1073         uchar   pscan_savechar;
1074
1075         u32 ch_portnum;                 /* Port number, 0 offset.       */
1076         u32 ch_open_count;              /* open count                   */
1077         u32     ch_flags;               /* Channel flags                */
1078
1079
1080         u32     ch_close_delay;         /* How long we should drop RTS/DTR for */
1081
1082         u32     ch_cpstime;             /* Time for CPS calculations    */
1083
1084         tcflag_t ch_c_iflag;            /* channel iflags               */
1085         tcflag_t ch_c_cflag;            /* channel cflags               */
1086         tcflag_t ch_c_oflag;            /* channel oflags               */
1087         tcflag_t ch_c_lflag;            /* channel lflags               */
1088
1089         u16  ch_fepiflag;            /* FEP tty iflags               */
1090         u16  ch_fepcflag;               /* FEP tty cflags               */
1091         u16  ch_fepoflag;               /* FEP tty oflags               */
1092         u16  ch_wopen;                  /* Waiting for open process cnt */
1093         u16  ch_tstart;                 /* Transmit buffer start        */
1094         u16  ch_tsize;                  /* Transmit buffer size         */
1095         u16  ch_rstart;                 /* Receive buffer start         */
1096         u16  ch_rsize;                  /* Receive buffer size          */
1097         u16  ch_rdelay;                 /* Receive delay time           */
1098
1099         u16     ch_tlw;                 /* Our currently set low water mark */
1100
1101         u16  ch_cook;                   /* Output character mask        */
1102
1103         uchar   ch_card;                /* Card channel is on           */
1104         uchar   ch_stopc;               /* Stop character               */
1105         uchar   ch_startc;              /* Start character              */
1106
1107         uchar   ch_mostat;              /* FEP output modem status      */
1108         uchar   ch_mistat;              /* FEP input modem status       */
1109         uchar   ch_mforce;              /* Modem values to be forced    */
1110         uchar   ch_mval;                /* Force values                 */
1111         uchar   ch_fepstopc;            /* FEP stop character           */
1112         uchar   ch_fepstartc;           /* FEP start character          */
1113
1114         uchar   ch_astopc;              /* Auxiliary Stop character     */
1115         uchar   ch_astartc;             /* Auxiliary Start character    */
1116         uchar   ch_fepastopc;           /* Auxiliary FEP stop char      */
1117         uchar   ch_fepastartc;          /* Auxiliary FEP start char     */
1118
1119         uchar   ch_hflow;               /* FEP hardware handshake       */
1120         uchar   ch_dsr;                 /* stores real dsr value        */
1121         uchar   ch_cd;                  /* stores real cd value         */
1122         uchar   ch_tx_win;              /* channel tx buffer window     */
1123         uchar   ch_rx_win;              /* channel rx buffer window     */
1124         uint    ch_custom_speed;        /* Custom baud, if set          */
1125         uint    ch_baud_info;           /* Current baud info for /proc output   */
1126         ulong   ch_rxcount;             /* total of data received so far        */
1127         ulong   ch_txcount;             /* total of data transmitted so far     */
1128         ulong   ch_err_parity;          /* Count of parity errors on channel    */
1129         ulong   ch_err_frame;           /* Count of framing errors on channel   */
1130         ulong   ch_err_break;           /* Count of breaks on channel   */
1131         ulong   ch_err_overrun;         /* Count of overruns on channel */
1132
1133         uint ch_sniff_in;
1134         uint ch_sniff_out;
1135         char *ch_sniff_buf;             /* Sniff buffer for proc */
1136         ulong ch_sniff_flags;           /* Channel flags                */
1137         wait_queue_head_t ch_sniff_wait;
1138 };
1139
1140 /************************************************************************
1141  * Command structure definition.
1142  ************************************************************************/
1143 struct cm_t {
1144         volatile unsigned short cm_head;        /* Command buffer head offset   */
1145         volatile unsigned short cm_tail;        /* Command buffer tail offset   */
1146         volatile unsigned short cm_start;       /* start offset of buffer       */
1147         volatile unsigned short cm_max;         /* last offset of buffer        */
1148 };
1149
1150 /************************************************************************
1151  * Event structure definition.
1152  ************************************************************************/
1153 struct ev_t {
1154         volatile unsigned short ev_head;        /* Command buffer head offset   */
1155         volatile unsigned short ev_tail;        /* Command buffer tail offset   */
1156         volatile unsigned short ev_start;       /* start offset of buffer       */
1157         volatile unsigned short ev_max;         /* last offset of buffer        */
1158 };
1159
1160 /************************************************************************
1161  * Download buffer structure.
1162  ************************************************************************/
1163 struct downld_t {
1164         uchar   dl_type;                /* Header                       */
1165         uchar   dl_seq;                 /* Download sequence            */
1166         ushort  dl_srev;                /* Software revision number     */
1167         ushort  dl_lrev;                /* Low revision number          */
1168         ushort  dl_hrev;                /* High revision number         */
1169         ushort  dl_seg;                 /* Start segment address        */
1170         ushort  dl_size;                /* Number of bytes to download  */
1171         uchar   dl_data[1024];          /* Download data                */
1172 };
1173
1174 /************************************************************************
1175  * Per channel buffer structure
1176  ************************************************************************
1177  *              Base Structure Entries Usage Meanings to Host           *
1178  *                                                                      *
1179  *        W = read write        R = read only                           *
1180  *        C = changed by commands only                                  *
1181  *        U = unknown (may be changed w/o notice)                       *
1182  ************************************************************************/
1183 struct bs_t {
1184         volatile unsigned short  tp_jmp;        /* Transmit poll jump            */
1185         volatile unsigned short  tc_jmp;        /* Cooked procedure jump         */
1186         volatile unsigned short  ri_jmp;        /* Not currently used            */
1187         volatile unsigned short  rp_jmp;        /* Receive poll jump             */
1188
1189         volatile unsigned short  tx_seg;        /* W  Tx segment         */
1190         volatile unsigned short  tx_head;       /* W  Tx buffer head offset     */
1191         volatile unsigned short  tx_tail;       /* R  Tx buffer tail offset     */
1192         volatile unsigned short  tx_max;        /* W  Tx buffer size - 1         */
1193
1194         volatile unsigned short  rx_seg;        /* W  Rx segment                */
1195         volatile unsigned short  rx_head;       /* W  Rx buffer head offset     */
1196         volatile unsigned short  rx_tail;       /* R  Rx buffer tail offset     */
1197         volatile unsigned short  rx_max;        /* W  Rx buffer size - 1         */
1198
1199         volatile unsigned short  tx_lw;         /* W  Tx buffer low water mark  */
1200         volatile unsigned short  rx_lw;         /* W  Rx buffer low water mark  */
1201         volatile unsigned short  rx_hw;         /* W  Rx buffer high water mark */
1202         volatile unsigned short  incr;          /* W  Increment to next channel */
1203
1204         volatile unsigned short  fepdev;        /* U  SCC device base address    */
1205         volatile unsigned short  edelay;        /* W  Exception delay            */
1206         volatile unsigned short  blen;          /* W  Break length              */
1207         volatile unsigned short  btime;         /* U  Break complete time       */
1208
1209         volatile unsigned short  iflag;         /* C  UNIX input flags          */
1210         volatile unsigned short  oflag;         /* C  UNIX output flags         */
1211         volatile unsigned short  cflag;         /* C  UNIX control flags        */
1212         volatile unsigned short  wfill[13];     /* U  Reserved for expansion    */
1213
1214         volatile unsigned char   num;           /* U  Channel number            */
1215         volatile unsigned char   ract;          /* U  Receiver active counter   */
1216         volatile unsigned char   bstat;         /* U  Break status bits         */
1217         volatile unsigned char   tbusy;         /* W  Transmit busy             */
1218         volatile unsigned char   iempty;        /* W  Transmit empty event enable */
1219         volatile unsigned char   ilow;          /* W  Transmit low-water event enable */
1220         volatile unsigned char   idata;         /* W  Receive data interrupt enable */
1221         volatile unsigned char   eflag;         /* U  Host event flags          */
1222
1223         volatile unsigned char   tflag;         /* U  Transmit flags            */
1224         volatile unsigned char   rflag;         /* U  Receive flags             */
1225         volatile unsigned char   xmask;         /* U  Transmit ready flags      */
1226         volatile unsigned char   xval;          /* U  Transmit ready value      */
1227         volatile unsigned char   m_stat;        /* RC Modem status bits          */
1228         volatile unsigned char   m_change;      /* U  Modem bits which changed  */
1229         volatile unsigned char   m_int;         /* W  Modem interrupt enable bits */
1230         volatile unsigned char   m_last;        /* U  Last modem status         */
1231
1232         volatile unsigned char   mtran;         /* C   Unreported modem trans   */
1233         volatile unsigned char   orun;          /* C   Buffer overrun occurred  */
1234         volatile unsigned char   astartc;       /* W   Auxiliary Xon char       */
1235         volatile unsigned char   astopc;        /* W   Auxiliary Xoff char      */
1236         volatile unsigned char   startc;        /* W   Xon character             */
1237         volatile unsigned char   stopc;         /* W   Xoff character           */
1238         volatile unsigned char   vnextc;        /* W   Vnext character           */
1239         volatile unsigned char   hflow;         /* C   Software flow control    */
1240         
1241         volatile unsigned char   fillc;         /* U   Delay Fill character     */
1242         volatile unsigned char   ochar;         /* U   Saved output character   */
1243         volatile unsigned char   omask;         /* U   Output character mask    */
1244
1245         volatile unsigned char   bfill[13];     /* U   Reserved for expansion   */
1246
1247         volatile unsigned char   scc[16];       /* U   SCC registers            */
1248 };
1249
1250 struct cnode {
1251         struct cnode *next;
1252         int type;
1253         int numbrd;
1254
1255         union {
1256                 struct {
1257                         char  type;     /* Board Type           */
1258                         short port;     /* I/O Address          */
1259                         char  *portstr; /* I/O Address in string */
1260                         long  addr;     /* Memory Address       */
1261                         char  *addrstr; /* Memory Address in string */
1262                         long  pcibus;   /* PCI BUS              */
1263                         char  *pcibusstr; /* PCI BUS in string */
1264                         long  pcislot;  /* PCI SLOT             */
1265                         char  *pcislotstr; /* PCI SLOT in string */
1266                         char  nport;    /* Number of Ports      */
1267                         char  *id;      /* tty id               */
1268                         int   start;    /* start of tty counting */
1269                         char  *method;  /* Install method       */
1270                         char  v_type;
1271                         char  v_port;
1272                         char  v_addr;
1273                         char  v_pcibus;
1274                         char  v_pcislot;
1275                         char  v_nport;
1276                         char  v_id;
1277                         char  v_start;
1278                         char  v_method;
1279                         char  line1;
1280                         char  line2;
1281                         char  conc1;   /* total concs in line1 */
1282                         char  conc2;   /* total concs in line2 */
1283                         char  module1; /* total modules for line1 */
1284                         char  module2; /* total modules for line2 */
1285                         char  *status; /* config status */
1286                         char  *dimstatus;        /* Y/N */
1287                         int   status_index; /* field pointer */
1288                 } board;
1289
1290                 struct {
1291                         char  *cable;
1292                         char  v_cable;
1293                         char  speed;
1294                         char  v_speed;
1295                 } line;
1296
1297                 struct {
1298                         char  type;
1299                         char  *connect;
1300                         char  speed;
1301                         char  nport;
1302                         char  *id;
1303                         char  *idstr;
1304                         int   start;
1305                         char  v_type;
1306                         char  v_connect;
1307                         char  v_speed;
1308                         char  v_nport;
1309                         char  v_id;
1310                         char  v_start;
1311                 } conc;
1312
1313                 struct {
1314                         char type;
1315                         char nport;
1316                         char *id;
1317                         char *idstr;
1318                         int  start;
1319                         char v_type;
1320                         char v_nport;
1321                         char v_id;
1322                         char v_start;
1323                 } module;
1324
1325                 char *ttyname;
1326
1327                 char *cuname;
1328
1329                 char *printname;
1330
1331                 int  majornumber;
1332
1333                 int  altpin;
1334
1335                 int  ttysize;
1336
1337                 int  chsize;
1338
1339                 int  bssize;
1340
1341                 int  unsize;
1342
1343                 int  f2size;
1344
1345                 int  vpixsize;
1346
1347                 int  useintr;
1348         } u;
1349 };
1350
1351 #endif