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