File: /usr/src/linux/drivers/isdn/hisax/hisax.h
1 /* $Id: hisax.h,v 2.52.6.8 2001/08/23 19:44:23 kai Exp $
2 *
3 * Basic declarations, defines and prototypes
4 *
5 * This file is (c) under GNU General Public License
6 *
7 */
8 #include <linux/config.h>
9 #include <linux/module.h>
10 #include <linux/version.h>
11 #include <linux/errno.h>
12 #include <linux/fs.h>
13 #include <linux/major.h>
14 #include <asm/segment.h>
15 #include <asm/io.h>
16 #include <linux/delay.h>
17 #include <linux/kernel.h>
18 #include <linux/signal.h>
19 #include <linux/slab.h>
20 #include <linux/mm.h>
21 #include <linux/mman.h>
22 #include <linux/ioport.h>
23 #include <linux/timer.h>
24 #include <linux/wait.h>
25 #include <linux/isdnif.h>
26 #include <linux/tty.h>
27 #include <linux/serial_reg.h>
28 #include <linux/netdevice.h>
29
30 #define ERROR_STATISTIC
31
32 #define REQUEST 0
33 #define CONFIRM 1
34 #define INDICATION 2
35 #define RESPONSE 3
36
37 #define HW_ENABLE 0x0000
38 #define HW_RESET 0x0004
39 #define HW_POWERUP 0x0008
40 #define HW_ACTIVATE 0x0010
41 #define HW_DEACTIVATE 0x0018
42
43 #define HW_INFO1 0x0010
44 #define HW_INFO2 0x0020
45 #define HW_INFO3 0x0030
46 #define HW_INFO4 0x0040
47 #define HW_INFO4_P8 0x0040
48 #define HW_INFO4_P10 0x0048
49 #define HW_RSYNC 0x0060
50 #define HW_TESTLOOP 0x0070
51 #define CARD_RESET 0x00F0
52 #define CARD_INIT 0x00F2
53 #define CARD_RELEASE 0x00F3
54 #define CARD_TEST 0x00F4
55 #define CARD_AUX_IND 0x00F5
56
57 #define PH_ACTIVATE 0x0100
58 #define PH_DEACTIVATE 0x0110
59 #define PH_DATA 0x0120
60 #define PH_PULL 0x0130
61 #define PH_TESTLOOP 0x0140
62 #define PH_PAUSE 0x0150
63 #define MPH_ACTIVATE 0x0180
64 #define MPH_DEACTIVATE 0x0190
65 #define MPH_INFORMATION 0x01A0
66
67 #define DL_ESTABLISH 0x0200
68 #define DL_RELEASE 0x0210
69 #define DL_DATA 0x0220
70 #define DL_FLUSH 0x0224
71 #define DL_UNIT_DATA 0x0230
72 #define MDL_ASSIGN 0x0280
73 #define MDL_REMOVE 0x0284
74 #define MDL_ERROR 0x0288
75 #define MDL_INFO_SETUP 0x02E0
76 #define MDL_INFO_CONN 0x02E4
77 #define MDL_INFO_REL 0x02E8
78
79 #define CC_SETUP 0x0300
80 #define CC_RESUME 0x0304
81 #define CC_MORE_INFO 0x0310
82 #define CC_IGNORE 0x0320
83 #define CC_REJECT 0x0324
84 #define CC_SETUP_COMPL 0x0330
85 #define CC_PROCEEDING 0x0340
86 #define CC_ALERTING 0x0344
87 #define CC_PROGRESS 0x0348
88 #define CC_CONNECT 0x0350
89 #define CC_CHARGE 0x0354
90 #define CC_NOTIFY 0x0358
91 #define CC_DISCONNECT 0x0360
92 #define CC_RELEASE 0x0368
93 #define CC_SUSPEND 0x0370
94 #define CC_PROCEED_SEND 0x0374
95 #define CC_REDIR 0x0378
96 #define CC_T302 0x0382
97 #define CC_T303 0x0383
98 #define CC_T304 0x0384
99 #define CC_T305 0x0385
100 #define CC_T308_1 0x0388
101 #define CC_T308_2 0x038A
102 #define CC_T309 0x0309
103 #define CC_T310 0x0390
104 #define CC_T313 0x0393
105 #define CC_T318 0x0398
106 #define CC_T319 0x0399
107 #define CC_TSPID 0x03A0
108 #define CC_NOSETUP_RSP 0x03E0
109 #define CC_SETUP_ERR 0x03E1
110 #define CC_SUSPEND_ERR 0x03E2
111 #define CC_RESUME_ERR 0x03E3
112 #define CC_CONNECT_ERR 0x03E4
113 #define CC_RELEASE_ERR 0x03E5
114 #define CC_RESTART 0x03F4
115 #define CC_TDSS1_IO 0x13F4 /* DSS1 IO user timer */
116 #define CC_TNI1_IO 0x13F5 /* NI1 IO user timer */
117
118 /* define maximum number of possible waiting incoming calls */
119 #define MAX_WAITING_CALLS 2
120
121
122 #ifdef __KERNEL__
123
124 /* include l3dss1 & ni1 specific process structures, but no other defines */
125 #ifdef CONFIG_HISAX_EURO
126 #define l3dss1_process
127 #include "l3dss1.h"
128 #undef l3dss1_process
129 #endif /* CONFIG_HISAX_EURO */
130
131 #ifdef CONFIG_HISAX_NI1
132 #define l3ni1_process
133 #include "l3ni1.h"
134 #undef l3ni1_process
135 #endif /* CONFIG_HISAX_NI1 */
136
137 #define MAX_DFRAME_LEN 260
138 #define MAX_DFRAME_LEN_L1 300
139 #define HSCX_BUFMAX 4096
140 #define MAX_DATA_SIZE (HSCX_BUFMAX - 4)
141 #define MAX_DATA_MEM (HSCX_BUFMAX + 64)
142 #define RAW_BUFMAX (((HSCX_BUFMAX*6)/5) + 5)
143 #define MAX_HEADER_LEN 4
144 #define MAX_WINDOW 8
145 #define MAX_MON_FRAME 32
146 #define MAX_DLOG_SPACE 2048
147 #define MAX_BLOG_SPACE 256
148
149 /* #define I4L_IRQ_FLAG SA_INTERRUPT */
150 #define I4L_IRQ_FLAG 0
151
152 /*
153 * Statemachine
154 */
155
156 struct FsmInst;
157
158 typedef void (* FSMFNPTR)(struct FsmInst *, int, void *);
159
160 struct Fsm {
161 FSMFNPTR *jumpmatrix;
162 int state_count, event_count;
163 char **strEvent, **strState;
164 };
165
166 struct FsmInst {
167 struct Fsm *fsm;
168 int state;
169 int debug;
170 void *userdata;
171 int userint;
172 void (*printdebug) (struct FsmInst *, char *, ...);
173 };
174
175 struct FsmNode {
176 int state, event;
177 void (*routine) (struct FsmInst *, int, void *);
178 };
179
180 struct FsmTimer {
181 struct FsmInst *fi;
182 struct timer_list tl;
183 int event;
184 void *arg;
185 };
186
187 struct L3Timer {
188 struct l3_process *pc;
189 struct timer_list tl;
190 int event;
191 };
192
193 #define FLG_L1_ACTIVATING 1
194 #define FLG_L1_ACTIVATED 2
195 #define FLG_L1_DEACTTIMER 3
196 #define FLG_L1_ACTTIMER 4
197 #define FLG_L1_T3RUN 5
198 #define FLG_L1_PULL_REQ 6
199 #define FLG_L1_UINT 7
200
201 struct Layer1 {
202 void *hardware;
203 struct BCState *bcs;
204 struct PStack **stlistp;
205 long Flags;
206 struct FsmInst l1m;
207 struct FsmTimer timer;
208 void (*l1l2) (struct PStack *, int, void *);
209 void (*l1hw) (struct PStack *, int, void *);
210 void (*l1tei) (struct PStack *, int, void *);
211 int mode, bc;
212 int delay;
213 };
214
215 #define GROUP_TEI 127
216 #define TEI_SAPI 63
217 #define CTRL_SAPI 0
218 #define PACKET_NOACK 250
219
220 /* Layer2 Flags */
221
222 #define FLG_LAPB 0
223 #define FLG_LAPD 1
224 #define FLG_ORIG 2
225 #define FLG_MOD128 3
226 #define FLG_PEND_REL 4
227 #define FLG_L3_INIT 5
228 #define FLG_T200_RUN 6
229 #define FLG_ACK_PEND 7
230 #define FLG_REJEXC 8
231 #define FLG_OWN_BUSY 9
232 #define FLG_PEER_BUSY 10
233 #define FLG_DCHAN_BUSY 11
234 #define FLG_L1_ACTIV 12
235 #define FLG_ESTAB_PEND 13
236 #define FLG_PTP 14
237 #define FLG_FIXED_TEI 15
238 #define FLG_L2BLOCK 16
239
240 struct Layer2 {
241 int tei;
242 int sap;
243 int maxlen;
244 unsigned long flag;
245 unsigned int vs, va, vr;
246 int rc;
247 unsigned int window;
248 unsigned int sow;
249 struct sk_buff *windowar[MAX_WINDOW];
250 struct sk_buff_head i_queue;
251 struct sk_buff_head ui_queue;
252 void (*l2l1) (struct PStack *, int, void *);
253 void (*l2l3) (struct PStack *, int, void *);
254 void (*l2tei) (struct PStack *, int, void *);
255 struct FsmInst l2m;
256 struct FsmTimer t200, t203;
257 int T200, N200, T203;
258 int debug;
259 char debug_id[16];
260 };
261
262 struct Layer3 {
263 void (*l3l4) (struct PStack *, int, void *);
264 void (*l3ml3) (struct PStack *, int, void *);
265 void (*l3l2) (struct PStack *, int, void *);
266 struct FsmInst l3m;
267 struct FsmTimer l3m_timer;
268 struct sk_buff_head squeue;
269 struct l3_process *proc;
270 struct l3_process *global;
271 int N303;
272 int debug;
273 char debug_id[8];
274 };
275
276 struct LLInterface {
277 void (*l4l3) (struct PStack *, int, void *);
278 int (*l4l3_proto) (struct PStack *, isdn_ctrl *);
279 void *userdata;
280 void (*l1writewakeup) (struct PStack *, int);
281 void (*l2writewakeup) (struct PStack *, int);
282 };
283
284
285 struct Management {
286 int ri;
287 struct FsmInst tei_m;
288 struct FsmTimer t202;
289 int T202, N202, debug;
290 void (*layer) (struct PStack *, int, void *);
291 };
292
293 #define NO_CAUSE 254
294
295 struct Param {
296 u_char cause;
297 u_char loc;
298 u_char diag[6];
299 int bchannel;
300 int chargeinfo;
301 int spv; /* SPV Flag */
302 setup_parm setup; /* from isdnif.h numbers and Serviceindicator */
303 u_char moderate; /* transfer mode and rate (bearer octet 4) */
304 };
305
306
307 struct PStack {
308 struct PStack *next;
309 struct Layer1 l1;
310 struct Layer2 l2;
311 struct Layer3 l3;
312 struct LLInterface lli;
313 struct Management ma;
314 int protocol; /* EDSS1, 1TR6 or NI1 */
315
316 /* protocol specific data fields */
317 union
318 { u_char uuuu; /* only as dummy */
319 #ifdef CONFIG_HISAX_EURO
320 dss1_stk_priv dss1; /* private dss1 data */
321 #endif /* CONFIG_HISAX_EURO */
322 #ifdef CONFIG_HISAX_NI1
323 ni1_stk_priv ni1; /* private ni1 data */
324 #endif /* CONFIG_HISAX_NI1 */
325 } prot;
326 };
327
328 struct l3_process {
329 int callref;
330 int state;
331 struct L3Timer timer;
332 int N303;
333 int debug;
334 struct Param para;
335 struct Channel *chan;
336 struct PStack *st;
337 struct l3_process *next;
338 ulong redir_result;
339
340 /* protocol specific data fields */
341 union
342 { u_char uuuu; /* only when euro not defined, avoiding empty union */
343 #ifdef CONFIG_HISAX_EURO
344 dss1_proc_priv dss1; /* private dss1 data */
345 #endif /* CONFIG_HISAX_EURO */
346 #ifdef CONFIG_HISAX_NI1
347 ni1_proc_priv ni1; /* private ni1 data */
348 #endif /* CONFIG_HISAX_NI1 */
349 } prot;
350 };
351
352 struct hscx_hw {
353 int hscx;
354 int rcvidx;
355 int count; /* Current skb sent count */
356 u_char *rcvbuf; /* B-Channel receive Buffer */
357 u_char tsaxr0;
358 u_char tsaxr1;
359 };
360
361 struct w6692B_hw {
362 int bchan;
363 int rcvidx;
364 int count; /* Current skb sent count */
365 u_char *rcvbuf; /* B-Channel receive Buffer */
366 };
367
368 struct isar_reg {
369 unsigned long Flags;
370 volatile u_char bstat;
371 volatile u_char iis;
372 volatile u_char cmsb;
373 volatile u_char clsb;
374 volatile u_char par[8];
375 };
376
377 struct isar_hw {
378 int dpath;
379 int rcvidx;
380 int txcnt;
381 int mml;
382 u_char state;
383 u_char cmd;
384 u_char mod;
385 u_char newcmd;
386 u_char newmod;
387 char try_mod;
388 struct timer_list ftimer;
389 u_char *rcvbuf; /* B-Channel receive Buffer */
390 u_char conmsg[16];
391 struct isar_reg *reg;
392 };
393
394 struct hdlc_stat_reg {
395 #ifdef __BIG_ENDIAN
396 u_char fill __attribute__((packed));
397 u_char mode __attribute__((packed));
398 u_char xml __attribute__((packed));
399 u_char cmd __attribute__((packed));
400 #else
401 u_char cmd __attribute__((packed));
402 u_char xml __attribute__((packed));
403 u_char mode __attribute__((packed));
404 u_char fill __attribute__((packed));
405 #endif
406 };
407
408 struct hdlc_hw {
409 union {
410 u_int ctrl;
411 struct hdlc_stat_reg sr;
412 } ctrl;
413 u_int stat;
414 int rcvidx;
415 int count; /* Current skb sent count */
416 u_char *rcvbuf; /* B-Channel receive Buffer */
417 };
418
419 struct hfcB_hw {
420 unsigned int *send;
421 int f1;
422 int f2;
423 };
424
425 struct tiger_hw {
426 u_int *send;
427 u_int *s_irq;
428 u_int *s_end;
429 u_int *sendp;
430 u_int *rec;
431 int free;
432 u_char *rcvbuf;
433 u_char *sendbuf;
434 u_char *sp;
435 int sendcnt;
436 u_int s_tot;
437 u_int r_bitcnt;
438 u_int r_tot;
439 u_int r_err;
440 u_int r_fcs;
441 u_char r_state;
442 u_char r_one;
443 u_char r_val;
444 u_char s_state;
445 };
446
447 struct amd7930_hw {
448 u_char *tx_buff;
449 u_char *rv_buff;
450 int rv_buff_in;
451 int rv_buff_out;
452 struct sk_buff *rv_skb;
453 struct hdlc_state *hdlc_state;
454 struct tq_struct tq_rcv;
455 struct tq_struct tq_xmt;
456 };
457
458 #define BC_FLG_INIT 1
459 #define BC_FLG_ACTIV 2
460 #define BC_FLG_BUSY 3
461 #define BC_FLG_NOFRAME 4
462 #define BC_FLG_HALF 5
463 #define BC_FLG_EMPTY 6
464 #define BC_FLG_ORIG 7
465 #define BC_FLG_DLEETX 8
466 #define BC_FLG_LASTDLE 9
467 #define BC_FLG_FIRST 10
468 #define BC_FLG_LASTDATA 11
469 #define BC_FLG_NMD_DATA 12
470 #define BC_FLG_FTI_RUN 13
471 #define BC_FLG_LL_OK 14
472 #define BC_FLG_LL_CONN 15
473
474 #define L1_MODE_NULL 0
475 #define L1_MODE_TRANS 1
476 #define L1_MODE_HDLC 2
477 #define L1_MODE_EXTRN 3
478 #define L1_MODE_HDLC_56K 4
479 #define L1_MODE_MODEM 7
480 #define L1_MODE_V32 8
481 #define L1_MODE_FAX 9
482
483 struct BCState {
484 int channel;
485 int mode;
486 long Flag; /* long req'd for set_bit --RR */
487 struct IsdnCardState *cs;
488 int tx_cnt; /* B-Channel transmit counter */
489 struct sk_buff *tx_skb; /* B-Channel transmit Buffer */
490 struct sk_buff_head rqueue; /* B-Channel receive Queue */
491 struct sk_buff_head squeue; /* B-Channel send Queue */
492 struct PStack *st;
493 u_char *blog;
494 u_char *conmsg;
495 struct timer_list transbusy;
496 struct tq_struct tqueue;
497 int event;
498 int (*BC_SetStack) (struct PStack *, struct BCState *);
499 void (*BC_Close) (struct BCState *);
500 #ifdef ERROR_STATISTIC
501 int err_crc;
502 int err_tx;
503 int err_rdo;
504 int err_inv;
505 #endif
506 union {
507 struct hscx_hw hscx;
508 struct hdlc_hw hdlc;
509 struct isar_hw isar;
510 struct hfcB_hw hfc;
511 struct tiger_hw tiger;
512 struct amd7930_hw amd7930;
513 struct w6692B_hw w6692;
514 struct hisax_b_if *b_if;
515 } hw;
516 };
517
518 struct Channel {
519 struct PStack *b_st, *d_st;
520 struct IsdnCardState *cs;
521 struct BCState *bcs;
522 int chan;
523 int incoming;
524 struct FsmInst fi;
525 struct FsmTimer drel_timer, dial_timer;
526 int debug;
527 int l2_protocol, l2_active_protocol;
528 int l3_protocol;
529 int data_open;
530 struct l3_process *proc;
531 setup_parm setup; /* from isdnif.h numbers and Serviceindicator */
532 long Flags; /* for remembering action done in l4 */
533 /* long req'd for set_bit --RR */
534 int leased;
535 };
536
537 struct elsa_hw {
538 unsigned long base;
539 unsigned int cfg;
540 unsigned int ctrl;
541 unsigned int ale;
542 unsigned int isac;
543 unsigned int itac;
544 unsigned int hscx;
545 unsigned int trig;
546 unsigned int timer;
547 unsigned int counter;
548 unsigned int status;
549 struct timer_list tl;
550 unsigned int MFlag;
551 struct BCState *bcs;
552 u_char *transbuf;
553 u_char *rcvbuf;
554 unsigned int transp;
555 unsigned int rcvp;
556 unsigned int transcnt;
557 unsigned int rcvcnt;
558 u_char IER;
559 u_char FCR;
560 u_char LCR;
561 u_char MCR;
562 u_char ctrl_reg;
563 };
564
565 struct teles3_hw {
566 unsigned int cfg_reg;
567 signed int isac;
568 signed int hscx[2];
569 signed int isacfifo;
570 signed int hscxfifo[2];
571 };
572
573 struct teles0_hw {
574 unsigned int cfg_reg;
575 unsigned long membase;
576 unsigned long phymem;
577 };
578
579 struct avm_hw {
580 unsigned int cfg_reg;
581 unsigned int isac;
582 unsigned int hscx[2];
583 unsigned int isacfifo;
584 unsigned int hscxfifo[2];
585 unsigned int counter;
586 };
587
588 struct ix1_hw {
589 unsigned int cfg_reg;
590 unsigned int isac_ale;
591 unsigned int isac;
592 unsigned int hscx_ale;
593 unsigned int hscx;
594 };
595
596 struct diva_hw {
597 unsigned long cfg_reg;
598 unsigned long pci_cfg;
599 unsigned int ctrl;
600 unsigned long isac_adr;
601 unsigned int isac;
602 unsigned long hscx_adr;
603 unsigned int hscx;
604 unsigned int status;
605 struct timer_list tl;
606 u_char ctrl_reg;
607 };
608
609 struct asus_hw {
610 unsigned int cfg_reg;
611 unsigned int adr;
612 unsigned int isac;
613 unsigned int hscx;
614 unsigned int u7;
615 unsigned int pots;
616 };
617
618
619 struct hfc_hw {
620 unsigned int addr;
621 unsigned int fifosize;
622 unsigned char cirm;
623 unsigned char ctmt;
624 unsigned char cip;
625 u_char isac_spcr;
626 struct timer_list timer;
627 };
628
629 struct sedl_hw {
630 unsigned int cfg_reg;
631 unsigned int adr;
632 unsigned int isac;
633 unsigned int hscx;
634 unsigned int reset_on;
635 unsigned int reset_off;
636 struct isar_reg isar;
637 unsigned int chip;
638 unsigned int bus;
639 };
640
641 struct spt_hw {
642 unsigned int cfg_reg;
643 unsigned int isac;
644 unsigned int hscx[2];
645 unsigned char res_irq;
646 };
647
648 struct mic_hw {
649 unsigned int cfg_reg;
650 unsigned int adr;
651 unsigned int isac;
652 unsigned int hscx;
653 };
654
655 struct njet_hw {
656 unsigned long base;
657 unsigned int isac;
658 unsigned int auxa;
659 unsigned char auxd;
660 unsigned char dmactrl;
661 unsigned char ctrl_reg;
662 unsigned char irqmask0;
663 unsigned char irqstat0;
664 unsigned char last_is0;
665 };
666
667 struct hfcPCI_hw {
668 unsigned char cirm;
669 unsigned char ctmt;
670 unsigned char conn;
671 unsigned char mst_m;
672 unsigned char int_m1;
673 unsigned char int_m2;
674 unsigned char int_s1;
675 unsigned char sctrl;
676 unsigned char sctrl_r;
677 unsigned char sctrl_e;
678 unsigned char trm;
679 unsigned char stat;
680 unsigned char fifo;
681 unsigned char fifo_en;
682 unsigned char bswapped;
683 unsigned char nt_mode;
684 int nt_timer;
685 unsigned char pci_bus;
686 unsigned char pci_device_fn;
687 unsigned char *pci_io; /* start of PCI IO memory */
688 void *share_start; /* shared memory for Fifos start */
689 void *fifos; /* FIFO memory */
690 int last_bfifo_cnt[2]; /* marker saving last b-fifo frame count */
691 struct timer_list timer;
692 };
693
694 struct hfcSX_hw {
695 unsigned long base;
696 unsigned char cirm;
697 unsigned char ctmt;
698 unsigned char conn;
699 unsigned char mst_m;
700 unsigned char int_m1;
701 unsigned char int_m2;
702 unsigned char int_s1;
703 unsigned char sctrl;
704 unsigned char sctrl_r;
705 unsigned char sctrl_e;
706 unsigned char trm;
707 unsigned char stat;
708 unsigned char fifo;
709 unsigned char bswapped;
710 unsigned char nt_mode;
711 unsigned char chip;
712 int b_fifo_size;
713 unsigned char last_fifo;
714 void *extra;
715 int nt_timer;
716 struct timer_list timer;
717 };
718
719 struct hfcD_hw {
720 unsigned int addr;
721 unsigned int bfifosize;
722 unsigned int dfifosize;
723 unsigned char cirm;
724 unsigned char ctmt;
725 unsigned char cip;
726 unsigned char conn;
727 unsigned char mst_m;
728 unsigned char int_m1;
729 unsigned char int_m2;
730 unsigned char int_s1;
731 unsigned char sctrl;
732 unsigned char stat;
733 unsigned char fifo;
734 unsigned char f1;
735 unsigned char f2;
736 unsigned int *send;
737 struct timer_list timer;
738 };
739
740 struct isurf_hw {
741 unsigned int reset;
742 unsigned long phymem;
743 unsigned long isac;
744 unsigned long isar;
745 struct isar_reg isar_r;
746 };
747
748 struct saphir_hw {
749 unsigned int cfg_reg;
750 unsigned int ale;
751 unsigned int isac;
752 unsigned int hscx;
753 struct timer_list timer;
754 };
755
756 struct bkm_hw {
757 unsigned long base;
758 /* A4T stuff */
759 unsigned long isac_adr;
760 unsigned int isac_ale;
761 unsigned long jade_adr;
762 unsigned int jade_ale;
763 /* Scitel Quadro stuff */
764 unsigned long plx_adr;
765 unsigned long data_adr;
766 };
767
768 struct gazel_hw {
769 unsigned int cfg_reg;
770 unsigned int pciaddr[2];
771 signed int ipac;
772 signed int isac;
773 signed int hscx[2];
774 signed int isacfifo;
775 signed int hscxfifo[2];
776 unsigned char timeslot;
777 unsigned char iom2;
778 };
779
780 struct w6692_hw {
781 unsigned int iobase;
782 struct timer_list timer;
783 };
784
785 #ifdef CONFIG_HISAX_TESTEMU
786 struct te_hw {
787 unsigned char *sfifo;
788 unsigned char *sfifo_w;
789 unsigned char *sfifo_r;
790 unsigned char *sfifo_e;
791 int sfifo_cnt;
792 unsigned int stat;
793 wait_queue_head_t rwaitq;
794 wait_queue_head_t swaitq;
795 };
796 #endif
797
798 struct arcofi_msg {
799 struct arcofi_msg *next;
800 u_char receive;
801 u_char len;
802 u_char msg[10];
803 };
804
805 struct isac_chip {
806 int ph_state;
807 u_char *mon_tx;
808 u_char *mon_rx;
809 int mon_txp;
810 int mon_txc;
811 int mon_rxp;
812 struct arcofi_msg *arcofi_list;
813 struct timer_list arcofitimer;
814 wait_queue_head_t arcofi_wait;
815 u_char arcofi_bc;
816 u_char arcofi_state;
817 u_char mocr;
818 u_char adf2;
819 };
820
821 struct hfcd_chip {
822 int ph_state;
823 };
824
825 struct hfcpci_chip {
826 int ph_state;
827 };
828
829 struct hfcsx_chip {
830 int ph_state;
831 };
832
833 struct w6692_chip {
834 int ph_state;
835 };
836
837 struct icc_chip {
838 int ph_state;
839 u_char *mon_tx;
840 u_char *mon_rx;
841 int mon_txp;
842 int mon_txc;
843 int mon_rxp;
844 struct arcofi_msg *arcofi_list;
845 struct timer_list arcofitimer;
846 wait_queue_head_t arcofi_wait;
847 u_char arcofi_bc;
848 u_char arcofi_state;
849 u_char mocr;
850 u_char adf2;
851 };
852
853 #define HW_IOM1 0
854 #define HW_IPAC 1
855 #define HW_ISAR 2
856 #define HW_ARCOFI 3
857 #define FLG_TWO_DCHAN 4
858 #define FLG_L1_DBUSY 5
859 #define FLG_DBUSY_TIMER 6
860 #define FLG_LOCK_ATOMIC 7
861 #define FLG_ARCOFI_TIMER 8
862 #define FLG_ARCOFI_ERROR 9
863 #define FLG_HW_L1_UINT 10
864
865 struct IsdnCardState {
866 unsigned char typ;
867 unsigned char subtyp;
868 int protocol;
869 unsigned int irq;
870 unsigned long irq_flags;
871 long HW_Flags;
872 int *busy_flag;
873 int chanlimit; /* limited number of B-chans to use */
874 int logecho; /* log echo if supported by card */
875 union {
876 struct elsa_hw elsa;
877 struct teles0_hw teles0;
878 struct teles3_hw teles3;
879 struct avm_hw avm;
880 struct ix1_hw ix1;
881 struct diva_hw diva;
882 struct asus_hw asus;
883 struct hfc_hw hfc;
884 struct sedl_hw sedl;
885 struct spt_hw spt;
886 struct mic_hw mic;
887 struct njet_hw njet;
888 struct hfcD_hw hfcD;
889 struct hfcPCI_hw hfcpci;
890 struct hfcSX_hw hfcsx;
891 struct ix1_hw niccy;
892 struct isurf_hw isurf;
893 struct saphir_hw saphir;
894 #ifdef CONFIG_HISAX_TESTEMU
895 struct te_hw te;
896 #endif
897 struct bkm_hw ax;
898 struct gazel_hw gazel;
899 struct w6692_hw w6692;
900 struct hisax_d_if *hisax_d_if;
901 } hw;
902 int myid;
903 isdn_if iif;
904 u_char *status_buf;
905 u_char *status_read;
906 u_char *status_write;
907 u_char *status_end;
908 u_char (*readisac) (struct IsdnCardState *, u_char);
909 void (*writeisac) (struct IsdnCardState *, u_char, u_char);
910 void (*readisacfifo) (struct IsdnCardState *, u_char *, int);
911 void (*writeisacfifo) (struct IsdnCardState *, u_char *, int);
912 u_char (*BC_Read_Reg) (struct IsdnCardState *, int, u_char);
913 void (*BC_Write_Reg) (struct IsdnCardState *, int, u_char, u_char);
914 void (*BC_Send_Data) (struct BCState *);
915 int (*cardmsg) (struct IsdnCardState *, int, void *);
916 void (*setstack_d) (struct PStack *, struct IsdnCardState *);
917 void (*DC_Close) (struct IsdnCardState *);
918 void (*irq_func) (int, void *, struct pt_regs *);
919 int (*auxcmd) (struct IsdnCardState *, isdn_ctrl *);
920 struct Channel channel[2+MAX_WAITING_CALLS];
921 struct BCState bcs[2+MAX_WAITING_CALLS];
922 struct PStack *stlist;
923 struct sk_buff_head rq, sq; /* D-channel queues */
924 int cardnr;
925 char *dlog;
926 int debug;
927 union {
928 struct isac_chip isac;
929 struct hfcd_chip hfcd;
930 struct hfcpci_chip hfcpci;
931 struct hfcsx_chip hfcsx;
932 struct w6692_chip w6692;
933 struct icc_chip icc;
934 } dc;
935 u_char *rcvbuf;
936 int rcvidx;
937 struct sk_buff *tx_skb;
938 int tx_cnt;
939 long event;
940 struct tq_struct tqueue;
941 struct timer_list dbusytimer;
942 #ifdef ERROR_STATISTIC
943 int err_crc;
944 int err_tx;
945 int err_rx;
946 #endif
947 };
948
949 #define MON0_RX 1
950 #define MON1_RX 2
951 #define MON0_TX 4
952 #define MON1_TX 8
953
954 #define HISAX_MAX_CARDS 8
955
956 #define ISDN_CTYPE_16_0 1
957 #define ISDN_CTYPE_8_0 2
958 #define ISDN_CTYPE_16_3 3
959 #define ISDN_CTYPE_PNP 4
960 #define ISDN_CTYPE_A1 5
961 #define ISDN_CTYPE_ELSA 6
962 #define ISDN_CTYPE_ELSA_PNP 7
963 #define ISDN_CTYPE_TELESPCMCIA 8
964 #define ISDN_CTYPE_IX1MICROR2 9
965 #define ISDN_CTYPE_ELSA_PCMCIA 10
966 #define ISDN_CTYPE_DIEHLDIVA 11
967 #define ISDN_CTYPE_ASUSCOM 12
968 #define ISDN_CTYPE_TELEINT 13
969 #define ISDN_CTYPE_TELES3C 14
970 #define ISDN_CTYPE_SEDLBAUER 15
971 #define ISDN_CTYPE_SPORTSTER 16
972 #define ISDN_CTYPE_MIC 17
973 #define ISDN_CTYPE_ELSA_PCI 18
974 #define ISDN_CTYPE_COMPAQ_ISA 19
975 #define ISDN_CTYPE_NETJET_S 20
976 #define ISDN_CTYPE_TELESPCI 21
977 #define ISDN_CTYPE_SEDLBAUER_PCMCIA 22
978 #define ISDN_CTYPE_AMD7930 23
979 #define ISDN_CTYPE_NICCY 24
980 #define ISDN_CTYPE_S0BOX 25
981 #define ISDN_CTYPE_A1_PCMCIA 26
982 #define ISDN_CTYPE_FRITZPCI 27
983 #define ISDN_CTYPE_SEDLBAUER_FAX 28
984 #define ISDN_CTYPE_ISURF 29
985 #define ISDN_CTYPE_ACERP10 30
986 #define ISDN_CTYPE_HSTSAPHIR 31
987 #define ISDN_CTYPE_BKM_A4T 32
988 #define ISDN_CTYPE_SCT_QUADRO 33
989 #define ISDN_CTYPE_GAZEL 34
990 #define ISDN_CTYPE_HFC_PCI 35
991 #define ISDN_CTYPE_W6692 36
992 #define ISDN_CTYPE_HFC_SX 37
993 #define ISDN_CTYPE_NETJET_U 38
994 #define ISDN_CTYPE_HFC_SP_PCMCIA 39
995 #define ISDN_CTYPE_DYNAMIC 40
996 #define ISDN_CTYPE_COUNT 40
997
998
999 #ifdef ISDN_CHIP_ISAC
1000 #undef ISDN_CHIP_ISAC
1001 #endif
1002
1003 #ifdef CONFIG_HISAX_16_0
1004 #define CARD_TELES0 1
1005 #ifndef ISDN_CHIP_ISAC
1006 #define ISDN_CHIP_ISAC 1
1007 #endif
1008 #else
1009 #define CARD_TELES0 0
1010 #endif
1011
1012 #ifdef CONFIG_HISAX_16_3
1013 #define CARD_TELES3 1
1014 #ifndef ISDN_CHIP_ISAC
1015 #define ISDN_CHIP_ISAC 1
1016 #endif
1017 #else
1018 #define CARD_TELES3 0
1019 #endif
1020
1021 #ifdef CONFIG_HISAX_TELESPCI
1022 #define CARD_TELESPCI 1
1023 #ifndef ISDN_CHIP_ISAC
1024 #define ISDN_CHIP_ISAC 1
1025 #endif
1026 #else
1027 #define CARD_TELESPCI 0
1028 #endif
1029
1030 #ifdef CONFIG_HISAX_AVM_A1
1031 #define CARD_AVM_A1 1
1032 #ifndef ISDN_CHIP_ISAC
1033 #define ISDN_CHIP_ISAC 1
1034 #endif
1035 #else
1036 #define CARD_AVM_A1 0
1037 #endif
1038
1039 #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
1040 #define CARD_AVM_A1_PCMCIA 1
1041 #ifndef ISDN_CHIP_ISAC
1042 #define ISDN_CHIP_ISAC 1
1043 #endif
1044 #else
1045 #define CARD_AVM_A1_PCMCIA 0
1046 #endif
1047
1048 #ifdef CONFIG_HISAX_FRITZPCI
1049 #define CARD_FRITZPCI 1
1050 #ifndef ISDN_CHIP_ISAC
1051 #define ISDN_CHIP_ISAC 1
1052 #endif
1053 #else
1054 #define CARD_FRITZPCI 0
1055 #endif
1056
1057 #ifdef CONFIG_HISAX_ELSA
1058 #define CARD_ELSA 1
1059 #ifndef ISDN_CHIP_ISAC
1060 #define ISDN_CHIP_ISAC 1
1061 #endif
1062 #else
1063 #define CARD_ELSA 0
1064 #endif
1065
1066 #ifdef CONFIG_HISAX_IX1MICROR2
1067 #define CARD_IX1MICROR2 1
1068 #ifndef ISDN_CHIP_ISAC
1069 #define ISDN_CHIP_ISAC 1
1070 #endif
1071 #else
1072 #define CARD_IX1MICROR2 0
1073 #endif
1074
1075 #ifdef CONFIG_HISAX_DIEHLDIVA
1076 #define CARD_DIEHLDIVA 1
1077 #ifndef ISDN_CHIP_ISAC
1078 #define ISDN_CHIP_ISAC 1
1079 #endif
1080 #else
1081 #define CARD_DIEHLDIVA 0
1082 #endif
1083
1084 #ifdef CONFIG_HISAX_ASUSCOM
1085 #define CARD_ASUSCOM 1
1086 #ifndef ISDN_CHIP_ISAC
1087 #define ISDN_CHIP_ISAC 1
1088 #endif
1089 #else
1090 #define CARD_ASUSCOM 0
1091 #endif
1092
1093 #ifdef CONFIG_HISAX_TELEINT
1094 #define CARD_TELEINT 1
1095 #ifndef ISDN_CHIP_ISAC
1096 #define ISDN_CHIP_ISAC 1
1097 #endif
1098 #else
1099 #define CARD_TELEINT 0
1100 #endif
1101
1102 #ifdef CONFIG_HISAX_SEDLBAUER
1103 #define CARD_SEDLBAUER 1
1104 #ifndef ISDN_CHIP_ISAC
1105 #define ISDN_CHIP_ISAC 1
1106 #endif
1107 #else
1108 #define CARD_SEDLBAUER 0
1109 #endif
1110
1111 #ifdef CONFIG_HISAX_SPORTSTER
1112 #define CARD_SPORTSTER 1
1113 #ifndef ISDN_CHIP_ISAC
1114 #define ISDN_CHIP_ISAC 1
1115 #endif
1116 #else
1117 #define CARD_SPORTSTER 0
1118 #endif
1119
1120 #ifdef CONFIG_HISAX_MIC
1121 #define CARD_MIC 1
1122 #ifndef ISDN_CHIP_ISAC
1123 #define ISDN_CHIP_ISAC 1
1124 #endif
1125 #else
1126 #define CARD_MIC 0
1127 #endif
1128
1129 #ifdef CONFIG_HISAX_NETJET
1130 #define CARD_NETJET_S 1
1131 #ifndef ISDN_CHIP_ISAC
1132 #define ISDN_CHIP_ISAC 1
1133 #endif
1134 #else
1135 #define CARD_NETJET_S 0
1136 #endif
1137
1138 #ifdef CONFIG_HISAX_HFCS
1139 #define CARD_HFCS 1
1140 #else
1141 #define CARD_HFCS 0
1142 #endif
1143
1144 #ifdef CONFIG_HISAX_HFC_PCI
1145 #define CARD_HFC_PCI 1
1146 #else
1147 #define CARD_HFC_PCI 0
1148 #endif
1149
1150 #ifdef CONFIG_HISAX_HFC_SX
1151 #define CARD_HFC_SX 1
1152 #else
1153 #define CARD_HFC_SX 0
1154 #endif
1155
1156 #ifdef CONFIG_HISAX_AMD7930
1157 #define CARD_AMD7930 1
1158 #else
1159 #define CARD_AMD7930 0
1160 #endif
1161
1162 #ifdef CONFIG_HISAX_NICCY
1163 #define CARD_NICCY 1
1164 #ifndef ISDN_CHIP_ISAC
1165 #define ISDN_CHIP_ISAC 1
1166 #endif
1167 #else
1168 #define CARD_NICCY 0
1169 #endif
1170
1171 #ifdef CONFIG_HISAX_ISURF
1172 #define CARD_ISURF 1
1173 #ifndef ISDN_CHIP_ISAC
1174 #define ISDN_CHIP_ISAC 1
1175 #endif
1176 #else
1177 #define CARD_ISURF 0
1178 #endif
1179
1180 #ifdef CONFIG_HISAX_S0BOX
1181 #define CARD_S0BOX 1
1182 #ifndef ISDN_CHIP_ISAC
1183 #define ISDN_CHIP_ISAC 1
1184 #endif
1185 #else
1186 #define CARD_S0BOX 0
1187 #endif
1188
1189 #ifdef CONFIG_HISAX_HSTSAPHIR
1190 #define CARD_HSTSAPHIR 1
1191 #ifndef ISDN_CHIP_ISAC
1192 #define ISDN_CHIP_ISAC 1
1193 #endif
1194 #else
1195 #define CARD_HSTSAPHIR 0
1196 #endif
1197
1198 #ifdef CONFIG_HISAX_TESTEMU
1199 #define CARD_TESTEMU 1
1200 #define ISDN_CTYPE_TESTEMU 99
1201 #undef ISDN_CTYPE_COUNT
1202 #define ISDN_CTYPE_COUNT ISDN_CTYPE_TESTEMU
1203 #else
1204 #define CARD_TESTEMU 0
1205 #endif
1206
1207 #ifdef CONFIG_HISAX_BKM_A4T
1208 #define CARD_BKM_A4T 1
1209 #ifndef ISDN_CHIP_ISAC
1210 #define ISDN_CHIP_ISAC 1
1211 #endif
1212 #else
1213 #define CARD_BKM_A4T 0
1214 #endif
1215
1216 #ifdef CONFIG_HISAX_SCT_QUADRO
1217 #define CARD_SCT_QUADRO 1
1218 #ifndef ISDN_CHIP_ISAC
1219 #define ISDN_CHIP_ISAC 1
1220 #endif
1221 #else
1222 #define CARD_SCT_QUADRO 0
1223 #endif
1224
1225 #ifdef CONFIG_HISAX_GAZEL
1226 #define CARD_GAZEL 1
1227 #ifndef ISDN_CHIP_ISAC
1228 #define ISDN_CHIP_ISAC 1
1229 #endif
1230 #else
1231 #define CARD_GAZEL 0
1232 #endif
1233
1234 #ifdef CONFIG_HISAX_W6692
1235 #define CARD_W6692 1
1236 #ifndef ISDN_CHIP_W6692
1237 #define ISDN_CHIP_W6692 1
1238 #endif
1239 #else
1240 #define CARD_W6692 0
1241 #endif
1242
1243 #ifdef CONFIG_HISAX_NETJET_U
1244 #define CARD_NETJET_U 1
1245 #ifndef ISDN_CHIP_ICC
1246 #define ISDN_CHIP_ICC 1
1247 #endif
1248 #ifndef HISAX_UINTERFACE
1249 #define HISAX_UINTERFACE 1
1250 #endif
1251 #else
1252 #define CARD_NETJET_U 0
1253 #endif
1254
1255 #define TEI_PER_CARD 1
1256
1257 /* L1 Debug */
1258 #define L1_DEB_WARN 0x01
1259 #define L1_DEB_INTSTAT 0x02
1260 #define L1_DEB_ISAC 0x04
1261 #define L1_DEB_ISAC_FIFO 0x08
1262 #define L1_DEB_HSCX 0x10
1263 #define L1_DEB_HSCX_FIFO 0x20
1264 #define L1_DEB_LAPD 0x40
1265 #define L1_DEB_IPAC 0x80
1266 #define L1_DEB_RECEIVE_FRAME 0x100
1267 #define L1_DEB_MONITOR 0x200
1268 #define DEB_DLOG_HEX 0x400
1269 #define DEB_DLOG_VERBOSE 0x800
1270
1271 #define L2FRAME_DEBUG
1272
1273 #ifdef L2FRAME_DEBUG
1274 extern void Logl2Frame(struct IsdnCardState *cs, struct sk_buff *skb, char *buf, int dir);
1275 #endif
1276
1277 struct IsdnCard {
1278 int typ;
1279 int protocol; /* EDSS1, 1TR6 or NI1 */
1280 unsigned long para[4];
1281 struct IsdnCardState *cs;
1282 };
1283
1284 void init_bcstate(struct IsdnCardState *cs, int bc);
1285
1286 void setstack_HiSax(struct PStack *st, struct IsdnCardState *cs);
1287 unsigned int random_ri(void);
1288 void HiSax_addlist(struct IsdnCardState *sp, struct PStack *st);
1289 void HiSax_rmlist(struct IsdnCardState *sp, struct PStack *st);
1290
1291 void setstack_l1_B(struct PStack *st);
1292
1293 void setstack_tei(struct PStack *st);
1294 void setstack_manager(struct PStack *st);
1295
1296 void setstack_isdnl2(struct PStack *st, char *debug_id);
1297 void releasestack_isdnl2(struct PStack *st);
1298 void setstack_transl2(struct PStack *st);
1299 void releasestack_transl2(struct PStack *st);
1300
1301 void setstack_l3dc(struct PStack *st, struct Channel *chanp);
1302 void setstack_l3bc(struct PStack *st, struct Channel *chanp);
1303 void releasestack_isdnl3(struct PStack *st);
1304
1305 u_char *findie(u_char * p, int size, u_char ie, int wanted_set);
1306 int getcallref(u_char * p);
1307 int newcallref(void);
1308
1309 int FsmNew(struct Fsm *fsm, struct FsmNode *fnlist, int fncount);
1310 void FsmFree(struct Fsm *fsm);
1311 int FsmEvent(struct FsmInst *fi, int event, void *arg);
1312 void FsmChangeState(struct FsmInst *fi, int newstate);
1313 void FsmInitTimer(struct FsmInst *fi, struct FsmTimer *ft);
1314 int FsmAddTimer(struct FsmTimer *ft, int millisec, int event,
1315 void *arg, int where);
1316 void FsmRestartTimer(struct FsmTimer *ft, int millisec, int event,
1317 void *arg, int where);
1318 void FsmDelTimer(struct FsmTimer *ft, int where);
1319 int jiftime(char *s, long mark);
1320
1321 int HiSax_command(isdn_ctrl * ic);
1322 int HiSax_writebuf_skb(int id, int chan, int ack, struct sk_buff *skb);
1323 void HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...);
1324 void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, va_list args);
1325 void HiSax_reportcard(int cardnr, int sel);
1326 int QuickHex(char *txt, u_char * p, int cnt);
1327 void LogFrame(struct IsdnCardState *cs, u_char * p, int size);
1328 void dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir);
1329 void iecpy(u_char * dest, u_char * iestart, int ieoffset);
1330 #ifdef ISDN_CHIP_ISAC
1331 void setstack_isac(struct PStack *st, struct IsdnCardState *cs);
1332 #endif /* ISDN_CHIP_ISAC */
1333 #endif /* __KERNEL__ */
1334
1335 #define HZDELAY(jiffs) {int tout = jiffs; while (tout--) udelay(1000000/HZ);}
1336
1337 int ll_run(struct IsdnCardState *cs, int addfeatures);
1338 void ll_stop(struct IsdnCardState *cs);
1339 int CallcNew(void);
1340 void CallcFree(void);
1341 int CallcNewChan(struct IsdnCardState *cs);
1342 void CallcFreeChan(struct IsdnCardState *cs);
1343 int Isdnl1New(void);
1344 void Isdnl1Free(void);
1345 int Isdnl2New(void);
1346 void Isdnl2Free(void);
1347 int Isdnl3New(void);
1348 void Isdnl3Free(void);
1349 void init_tei(struct IsdnCardState *cs, int protocol);
1350 void release_tei(struct IsdnCardState *cs);
1351 char *HiSax_getrev(const char *revision);
1352 int TeiNew(void);
1353 void TeiFree(void);
1354 int certification_check(int output);
1355