Merge ../linux-2.6-watchdog-mm
[linux-drm-fsl-dcu.git] / drivers / isdn / hisax / config.c
1 /* $Id: config.c,v 2.84.2.5 2004/02/11 13:21:33 keil Exp $
2  *
3  * Author       Karsten Keil
4  * Copyright    by Karsten Keil      <keil@isdn4linux.de>
5  *              by Kai Germaschewski <kai.germaschewski@gmx.de>
6  * 
7  * This software may be used and distributed according to the terms
8  * of the GNU General Public License, incorporated herein by reference.
9  *
10  * For changes and modifications please read
11  * Documentation/isdn/HiSax.cert
12  *
13  * based on the teles driver from Jan den Ouden
14  *
15  */
16
17 #include <linux/types.h>
18 #include <linux/stddef.h>
19 #include <linux/timer.h>
20 #include <linux/init.h>
21 #include "hisax.h"
22 #include <linux/module.h>
23 #include <linux/kernel_stat.h>
24 #include <linux/workqueue.h>
25 #include <linux/interrupt.h>
26 #define HISAX_STATUS_BUFSIZE 4096
27
28 /*
29  * This structure array contains one entry per card. An entry looks
30  * like this:
31  *
32  * { type, protocol, p0, p1, p2, NULL }
33  *
34  * type
35  *    1 Teles 16.0       p0=irq p1=membase p2=iobase
36  *    2 Teles  8.0       p0=irq p1=membase
37  *    3 Teles 16.3       p0=irq p1=iobase
38  *    4 Creatix PNP      p0=irq p1=IO0 (ISAC)  p2=IO1 (HSCX)
39  *    5 AVM A1 (Fritz)   p0=irq p1=iobase
40  *    6 ELSA PC          [p0=iobase] or nothing (autodetect)
41  *    7 ELSA Quickstep   p0=irq p1=iobase
42  *    8 Teles PCMCIA     p0=irq p1=iobase
43  *    9 ITK ix1-micro    p0=irq p1=iobase
44  *   10 ELSA PCMCIA      p0=irq p1=iobase
45  *   11 Eicon.Diehl Diva p0=irq p1=iobase
46  *   12 Asuscom ISDNLink p0=irq p1=iobase
47  *   13 Teleint          p0=irq p1=iobase
48  *   14 Teles 16.3c      p0=irq p1=iobase
49  *   15 Sedlbauer speed  p0=irq p1=iobase
50  *   15 Sedlbauer PC/104        p0=irq p1=iobase
51  *   15 Sedlbauer speed pci     no parameter
52  *   16 USR Sportster internal  p0=irq  p1=iobase
53  *   17 MIC card                p0=irq  p1=iobase
54  *   18 ELSA Quickstep 1000PCI  no parameter
55  *   19 Compaq ISDN S0 ISA card p0=irq  p1=IO0 (HSCX)  p2=IO1 (ISAC) p3=IO2
56  *   20 Travers Technologies NETjet-S PCI card
57  *   21 TELES PCI               no parameter
58  *   22 Sedlbauer Speed Star    p0=irq p1=iobase
59  *   23 reserved
60  *   24 Dr Neuhaus Niccy PnP/PCI card p0=irq p1=IO0 p2=IO1 (PnP only)
61  *   25 Teles S0Box             p0=irq p1=iobase (from isapnp setup)
62  *   26 AVM A1 PCMCIA (Fritz)   p0=irq p1=iobase
63  *   27 AVM PnP/PCI             p0=irq p1=iobase (PCI no parameter)
64  *   28 Sedlbauer Speed Fax+    p0=irq p1=iobase (from isapnp setup)
65  *   29 Siemens I-Surf          p0=irq p1=iobase p2=memory (from isapnp setup)
66  *   30 ACER P10                p0=irq p1=iobase (from isapnp setup)
67  *   31 HST Saphir              p0=irq  p1=iobase
68  *   32 Telekom A4T             none
69  *   33 Scitel Quadro           p0=subcontroller (4*S0, subctrl 1...4)
70  *   34 Gazel ISDN cards
71  *   35 HFC 2BDS0 PCI           none
72  *   36 Winbond 6692 PCI        none
73  *   37 HFC 2BDS0 S+/SP         p0=irq p1=iobase
74  *   38 Travers Technologies NETspider-U PCI card
75  *   39 HFC 2BDS0-SP PCMCIA     p0=irq p1=iobase
76  *   40 hotplug interface
77  *   41 Formula-n enter:now ISDN PCI a/b   none
78  *
79  * protocol can be either ISDN_PTYPE_EURO or ISDN_PTYPE_1TR6 or ISDN_PTYPE_NI1
80  *
81  *
82  */
83
84 const char *CardType[] = {
85         "No Card", "Teles 16.0", "Teles 8.0", "Teles 16.3",
86         "Creatix/Teles PnP", "AVM A1", "Elsa ML", "Elsa Quickstep",
87         "Teles PCMCIA", "ITK ix1-micro Rev.2", "Elsa PCMCIA",
88         "Eicon.Diehl Diva", "ISDNLink", "TeleInt", "Teles 16.3c",
89         "Sedlbauer Speed Card", "USR Sportster", "ith mic Linux",
90         "Elsa PCI", "Compaq ISA", "NETjet-S", "Teles PCI", 
91         "Sedlbauer Speed Star (PCMCIA)", "AMD 7930", "NICCY", "S0Box",
92         "AVM A1 (PCMCIA)", "AVM Fritz PnP/PCI", "Sedlbauer Speed Fax +",
93         "Siemens I-Surf", "Acer P10", "HST Saphir", "Telekom A4T",
94         "Scitel Quadro", "Gazel", "HFC 2BDS0 PCI", "Winbond 6692",
95         "HFC 2BDS0 SX", "NETspider-U", "HFC-2BDS0-SP PCMCIA",
96         "Hotplug", "Formula-n enter:now PCI a/b", 
97 };
98
99 #ifdef CONFIG_HISAX_ELSA
100 #define DEFAULT_CARD ISDN_CTYPE_ELSA
101 #define DEFAULT_CFG {0,0,0,0}
102 #endif
103
104 #ifdef CONFIG_HISAX_AVM_A1
105 #undef DEFAULT_CARD
106 #undef DEFAULT_CFG
107 #define DEFAULT_CARD ISDN_CTYPE_A1
108 #define DEFAULT_CFG {10,0x340,0,0}
109 #endif
110
111 #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
112 #undef DEFAULT_CARD
113 #undef DEFAULT_CFG
114 #define DEFAULT_CARD ISDN_CTYPE_A1_PCMCIA
115 #define DEFAULT_CFG {11,0x170,0,0}
116 #endif
117
118 #ifdef CONFIG_HISAX_FRITZPCI
119 #undef DEFAULT_CARD
120 #undef DEFAULT_CFG
121 #define DEFAULT_CARD ISDN_CTYPE_FRITZPCI
122 #define DEFAULT_CFG {0,0,0,0}
123 #endif
124
125 #ifdef CONFIG_HISAX_16_3
126 #undef DEFAULT_CARD
127 #undef DEFAULT_CFG
128 #define DEFAULT_CARD ISDN_CTYPE_16_3
129 #define DEFAULT_CFG {15,0x180,0,0}
130 #endif
131
132 #ifdef CONFIG_HISAX_S0BOX
133 #undef DEFAULT_CARD
134 #undef DEFAULT_CFG
135 #define DEFAULT_CARD ISDN_CTYPE_S0BOX
136 #define DEFAULT_CFG {7,0x378,0,0}
137 #endif
138
139 #ifdef CONFIG_HISAX_16_0
140 #undef DEFAULT_CARD
141 #undef DEFAULT_CFG
142 #define DEFAULT_CARD ISDN_CTYPE_16_0
143 #define DEFAULT_CFG {15,0xd0000,0xd80,0}
144 #endif
145
146 #ifdef CONFIG_HISAX_TELESPCI
147 #undef DEFAULT_CARD
148 #undef DEFAULT_CFG
149 #define DEFAULT_CARD ISDN_CTYPE_TELESPCI
150 #define DEFAULT_CFG {0,0,0,0}
151 #endif
152
153 #ifdef CONFIG_HISAX_IX1MICROR2
154 #undef DEFAULT_CARD
155 #undef DEFAULT_CFG
156 #define DEFAULT_CARD ISDN_CTYPE_IX1MICROR2
157 #define DEFAULT_CFG {5,0x390,0,0}
158 #endif
159
160 #ifdef CONFIG_HISAX_DIEHLDIVA
161 #undef DEFAULT_CARD
162 #undef DEFAULT_CFG
163 #define DEFAULT_CARD ISDN_CTYPE_DIEHLDIVA
164 #define DEFAULT_CFG {0,0x0,0,0}
165 #endif
166
167 #ifdef CONFIG_HISAX_ASUSCOM
168 #undef DEFAULT_CARD
169 #undef DEFAULT_CFG
170 #define DEFAULT_CARD ISDN_CTYPE_ASUSCOM
171 #define DEFAULT_CFG {5,0x200,0,0}
172 #endif
173
174 #ifdef CONFIG_HISAX_TELEINT
175 #undef DEFAULT_CARD
176 #undef DEFAULT_CFG
177 #define DEFAULT_CARD ISDN_CTYPE_TELEINT
178 #define DEFAULT_CFG {5,0x300,0,0}
179 #endif
180
181 #ifdef CONFIG_HISAX_SEDLBAUER
182 #undef DEFAULT_CARD
183 #undef DEFAULT_CFG
184 #define DEFAULT_CARD ISDN_CTYPE_SEDLBAUER
185 #define DEFAULT_CFG {11,0x270,0,0}
186 #endif
187
188 #ifdef CONFIG_HISAX_SPORTSTER
189 #undef DEFAULT_CARD
190 #undef DEFAULT_CFG
191 #define DEFAULT_CARD ISDN_CTYPE_SPORTSTER
192 #define DEFAULT_CFG {7,0x268,0,0}
193 #endif
194
195 #ifdef CONFIG_HISAX_MIC
196 #undef DEFAULT_CARD
197 #undef DEFAULT_CFG
198 #define DEFAULT_CARD ISDN_CTYPE_MIC
199 #define DEFAULT_CFG {12,0x3e0,0,0}
200 #endif
201
202 #ifdef CONFIG_HISAX_NETJET
203 #undef DEFAULT_CARD
204 #undef DEFAULT_CFG
205 #define DEFAULT_CARD ISDN_CTYPE_NETJET_S
206 #define DEFAULT_CFG {0,0,0,0}
207 #endif
208
209 #ifdef CONFIG_HISAX_HFCS
210 #undef DEFAULT_CARD
211 #undef DEFAULT_CFG
212 #define DEFAULT_CARD ISDN_CTYPE_TELES3C
213 #define DEFAULT_CFG {5,0x500,0,0}
214 #endif
215
216 #ifdef CONFIG_HISAX_HFC_PCI
217 #undef DEFAULT_CARD
218 #undef DEFAULT_CFG
219 #define DEFAULT_CARD ISDN_CTYPE_HFC_PCI
220 #define DEFAULT_CFG {0,0,0,0}
221 #endif
222
223 #ifdef CONFIG_HISAX_HFC_SX
224 #undef DEFAULT_CARD
225 #undef DEFAULT_CFG
226 #define DEFAULT_CARD ISDN_CTYPE_HFC_SX
227 #define DEFAULT_CFG {5,0x2E0,0,0}
228 #endif
229
230
231 #ifdef CONFIG_HISAX_AMD7930
232 #undef DEFAULT_CARD
233 #undef DEFAULT_CFG
234 #define DEFAULT_CARD ISDN_CTYPE_AMD7930
235 #define DEFAULT_CFG {12,0x3e0,0,0}
236 #endif
237
238 #ifdef CONFIG_HISAX_NICCY
239 #undef DEFAULT_CARD
240 #undef DEFAULT_CFG
241 #define DEFAULT_CARD ISDN_CTYPE_NICCY
242 #define DEFAULT_CFG {0,0x0,0,0}
243 #endif
244
245 #ifdef CONFIG_HISAX_ISURF
246 #undef DEFAULT_CARD
247 #undef DEFAULT_CFG
248 #define DEFAULT_CARD ISDN_CTYPE_ISURF
249 #define DEFAULT_CFG {5,0x100,0xc8000,0}
250 #endif
251
252 #ifdef CONFIG_HISAX_HSTSAPHIR
253 #undef DEFAULT_CARD
254 #undef DEFAULT_CFG
255 #define DEFAULT_CARD ISDN_CTYPE_HSTSAPHIR
256 #define DEFAULT_CFG {5,0x250,0,0}
257 #endif
258
259 #ifdef CONFIG_HISAX_BKM_A4T
260 #undef DEFAULT_CARD
261 #undef DEFAULT_CFG
262 #define DEFAULT_CARD ISDN_CTYPE_BKM_A4T
263 #define DEFAULT_CFG {0,0x0,0,0}
264 #endif
265
266 #ifdef CONFIG_HISAX_SCT_QUADRO
267 #undef DEFAULT_CARD
268 #undef DEFAULT_CFG
269 #define DEFAULT_CARD ISDN_CTYPE_SCT_QUADRO
270 #define DEFAULT_CFG {1,0x0,0,0}
271 #endif
272
273 #ifdef CONFIG_HISAX_GAZEL
274 #undef DEFAULT_CARD
275 #undef DEFAULT_CFG
276 #define DEFAULT_CARD ISDN_CTYPE_GAZEL
277 #define DEFAULT_CFG {15,0x180,0,0}
278 #endif
279
280 #ifdef CONFIG_HISAX_W6692
281 #undef DEFAULT_CARD
282 #undef DEFAULT_CFG
283 #define DEFAULT_CARD ISDN_CTYPE_W6692
284 #define DEFAULT_CFG {0,0,0,0}
285 #endif
286
287 #ifdef CONFIG_HISAX_NETJET_U
288 #undef DEFAULT_CARD
289 #undef DEFAULT_CFG
290 #define DEFAULT_CARD ISDN_CTYPE_NETJET_U
291 #define DEFAULT_CFG {0,0,0,0}
292 #endif
293
294 #ifdef CONFIG_HISAX_1TR6
295 #define DEFAULT_PROTO ISDN_PTYPE_1TR6
296 #define DEFAULT_PROTO_NAME "1TR6"
297 #endif
298 #ifdef CONFIG_HISAX_NI1
299 #undef DEFAULT_PROTO
300 #define DEFAULT_PROTO ISDN_PTYPE_NI1
301 #undef DEFAULT_PROTO_NAME
302 #define DEFAULT_PROTO_NAME "NI1"
303 #endif
304 #ifdef CONFIG_HISAX_EURO
305 #undef DEFAULT_PROTO
306 #define DEFAULT_PROTO ISDN_PTYPE_EURO
307 #undef DEFAULT_PROTO_NAME
308 #define DEFAULT_PROTO_NAME "EURO"
309 #endif
310 #ifndef DEFAULT_PROTO
311 #define DEFAULT_PROTO ISDN_PTYPE_UNKNOWN
312 #define DEFAULT_PROTO_NAME "UNKNOWN"
313 #endif
314 #ifndef DEFAULT_CARD
315 #define DEFAULT_CARD 0
316 #define DEFAULT_CFG {0,0,0,0}
317 #endif
318
319 #define FIRST_CARD { \
320         DEFAULT_CARD, \
321         DEFAULT_PROTO, \
322         DEFAULT_CFG, \
323         NULL, \
324 }
325
326 struct IsdnCard cards[HISAX_MAX_CARDS] = {
327         FIRST_CARD,
328 };
329
330 #define HISAX_IDSIZE (HISAX_MAX_CARDS*8)
331 static char HiSaxID[HISAX_IDSIZE] = { 0, };
332
333 static char *HiSax_id = HiSaxID;
334 #ifdef MODULE
335 /* Variables for insmod */
336 static int type[HISAX_MAX_CARDS] = { 0, };
337 static int protocol[HISAX_MAX_CARDS] = { 0, };
338 static int io[HISAX_MAX_CARDS] = { 0, };
339 #undef IO0_IO1
340 #ifdef CONFIG_HISAX_16_3
341 #define IO0_IO1
342 #endif
343 #ifdef CONFIG_HISAX_NICCY
344 #undef IO0_IO1
345 #define IO0_IO1
346 #endif
347 #ifdef IO0_IO1
348 static int io0[HISAX_MAX_CARDS] __devinitdata = { 0, };
349 static int io1[HISAX_MAX_CARDS] __devinitdata = { 0, };
350 #endif
351 static int irq[HISAX_MAX_CARDS] __devinitdata = { 0, };
352 static int mem[HISAX_MAX_CARDS] __devinitdata = { 0, };
353 static char *id = HiSaxID;
354
355 MODULE_DESCRIPTION("ISDN4Linux: Driver for passive ISDN cards");
356 MODULE_AUTHOR("Karsten Keil");
357 MODULE_LICENSE("GPL");
358 module_param_array(type, int, NULL, 0);
359 module_param_array(protocol, int, NULL, 0);
360 module_param_array(io, int, NULL, 0);
361 module_param_array(irq, int, NULL, 0);
362 module_param_array(mem, int, NULL, 0);
363 module_param(id, charp, 0);
364 #ifdef IO0_IO1
365 module_param_array(io0, int, NULL, 0);
366 module_param_array(io1, int, NULL, 0);
367 #endif
368 #endif /* MODULE */
369
370 int nrcards;
371
372 extern char *l1_revision;
373 extern char *l2_revision;
374 extern char *l3_revision;
375 extern char *lli_revision;
376 extern char *tei_revision;
377
378 char *HiSax_getrev(const char *revision)
379 {
380         char *rev;
381         char *p;
382
383         if ((p = strchr(revision, ':'))) {
384                 rev = p + 2;
385                 p = strchr(rev, '$');
386                 *--p = 0;
387         } else
388                 rev = "???";
389         return rev;
390 }
391
392 static void __init HiSaxVersion(void)
393 {
394         char tmp[64];
395
396         printk(KERN_INFO "HiSax: Linux Driver for passive ISDN cards\n");
397 #ifdef MODULE
398         printk(KERN_INFO "HiSax: Version 3.5 (module)\n");
399 #else
400         printk(KERN_INFO "HiSax: Version 3.5 (kernel)\n");
401 #endif
402         strcpy(tmp, l1_revision);
403         printk(KERN_INFO "HiSax: Layer1 Revision %s\n", HiSax_getrev(tmp));
404         strcpy(tmp, l2_revision);
405         printk(KERN_INFO "HiSax: Layer2 Revision %s\n", HiSax_getrev(tmp));
406         strcpy(tmp, tei_revision);
407         printk(KERN_INFO "HiSax: TeiMgr Revision %s\n", HiSax_getrev(tmp));
408         strcpy(tmp, l3_revision);
409         printk(KERN_INFO "HiSax: Layer3 Revision %s\n", HiSax_getrev(tmp));
410         strcpy(tmp, lli_revision);
411         printk(KERN_INFO "HiSax: LinkLayer Revision %s\n",
412                HiSax_getrev(tmp));
413 }
414
415 #ifndef MODULE
416 #define MAX_ARG (HISAX_MAX_CARDS*5)
417 static int __init HiSax_setup(char *line)
418 {
419         int i, j, argc;
420         int ints[MAX_ARG + 1];
421         char *str;
422
423         str = get_options(line, MAX_ARG, ints);
424         argc = ints[0];
425         printk(KERN_DEBUG "HiSax_setup: argc(%d) str(%s)\n", argc, str);
426         i = 0;
427         j = 1;
428         while (argc && (i < HISAX_MAX_CARDS)) {
429                 cards[i].protocol = DEFAULT_PROTO;
430                 if (argc) {
431                         cards[i].typ = ints[j];
432                         j++;
433                         argc--;
434                 }
435                 if (argc) {
436                         cards[i].protocol = ints[j];
437                         j++;
438                         argc--;
439                 }
440                 if (argc) {
441                         cards[i].para[0] = ints[j];
442                         j++;
443                         argc--;
444                 }
445                 if (argc) {
446                         cards[i].para[1] = ints[j];
447                         j++;
448                         argc--;
449                 }
450                 if (argc) {
451                         cards[i].para[2] = ints[j];
452                         j++;
453                         argc--;
454                 }
455                 i++;
456         }
457         if (str && *str) {
458                 if (strlen(str) < HISAX_IDSIZE)
459                         strcpy(HiSaxID, str);
460                 else
461                         printk(KERN_WARNING "HiSax: ID too long!");
462         } else
463                 strcpy(HiSaxID, "HiSax");
464
465         HiSax_id = HiSaxID;
466         return 1;
467 }
468
469 __setup("hisax=", HiSax_setup);
470 #endif /* MODULES */
471
472 #if CARD_TELES0
473 extern int setup_teles0(struct IsdnCard *card);
474 #endif
475
476 #if CARD_TELES3
477 extern int setup_teles3(struct IsdnCard *card);
478 #endif
479
480 #if CARD_S0BOX
481 extern int setup_s0box(struct IsdnCard *card);
482 #endif
483
484 #if CARD_TELESPCI
485 extern int setup_telespci(struct IsdnCard *card);
486 #endif
487
488 #if CARD_AVM_A1
489 extern int setup_avm_a1(struct IsdnCard *card);
490 #endif
491
492 #if CARD_AVM_A1_PCMCIA
493 extern int setup_avm_a1_pcmcia(struct IsdnCard *card);
494 #endif
495
496 #if CARD_FRITZPCI
497 extern int setup_avm_pcipnp(struct IsdnCard *card);
498 #endif
499
500 #if CARD_ELSA
501 extern int setup_elsa(struct IsdnCard *card);
502 #endif
503
504 #if CARD_IX1MICROR2
505 extern int setup_ix1micro(struct IsdnCard *card);
506 #endif
507
508 #if CARD_DIEHLDIVA
509 extern int setup_diva(struct IsdnCard *card);
510 #endif
511
512 #if CARD_ASUSCOM
513 extern int setup_asuscom(struct IsdnCard *card);
514 #endif
515
516 #if CARD_TELEINT
517 extern int setup_TeleInt(struct IsdnCard *card);
518 #endif
519
520 #if CARD_SEDLBAUER
521 extern int setup_sedlbauer(struct IsdnCard *card);
522 #endif
523
524 #if CARD_SPORTSTER
525 extern int setup_sportster(struct IsdnCard *card);
526 #endif
527
528 #if CARD_MIC
529 extern int setup_mic(struct IsdnCard *card);
530 #endif
531
532 #if CARD_NETJET_S
533 extern int setup_netjet_s(struct IsdnCard *card);
534 #endif
535
536 #if CARD_HFCS
537 extern int setup_hfcs(struct IsdnCard *card);
538 #endif
539
540 #if CARD_HFC_PCI
541 extern int setup_hfcpci(struct IsdnCard *card);
542 #endif
543
544 #if CARD_HFC_SX
545 extern int setup_hfcsx(struct IsdnCard *card);
546 #endif
547
548 #if CARD_AMD7930
549 extern int setup_amd7930(struct IsdnCard *card);
550 #endif
551
552 #if CARD_NICCY
553 extern int setup_niccy(struct IsdnCard *card);
554 #endif
555
556 #if CARD_ISURF
557 extern int setup_isurf(struct IsdnCard *card);
558 #endif
559
560 #if CARD_HSTSAPHIR
561 extern int setup_saphir(struct IsdnCard *card);
562 #endif
563
564 #if CARD_TESTEMU
565 extern int setup_testemu(struct IsdnCard *card);
566 #endif
567
568 #if CARD_BKM_A4T
569 extern int setup_bkm_a4t(struct IsdnCard *card);
570 #endif
571
572 #if CARD_SCT_QUADRO
573 extern int setup_sct_quadro(struct IsdnCard *card);
574 #endif
575
576 #if CARD_GAZEL
577 extern int setup_gazel(struct IsdnCard *card);
578 #endif
579
580 #if CARD_W6692
581 extern int setup_w6692(struct IsdnCard *card);
582 #endif
583
584 #if CARD_NETJET_U
585 extern int setup_netjet_u(struct IsdnCard *card);
586 #endif
587
588 #if CARD_FN_ENTERNOW_PCI
589 extern int setup_enternow_pci(struct IsdnCard *card);
590 #endif
591
592 /*
593  * Find card with given driverId
594  */
595 static inline struct IsdnCardState *hisax_findcard(int driverid)
596 {
597         int i;
598
599         for (i = 0; i < nrcards; i++)
600                 if (cards[i].cs)
601                         if (cards[i].cs->myid == driverid)
602                                 return cards[i].cs;
603         return NULL;
604 }
605
606 /*
607  * Find card with given card number
608  */
609 #if 0
610 struct IsdnCardState *hisax_get_card(int cardnr)
611 {
612         if ((cardnr <= nrcards) && (cardnr > 0))
613                 if (cards[cardnr - 1].cs)
614                         return cards[cardnr - 1].cs;
615         return NULL;
616 }
617 #endif  /*  0  */
618
619 static int HiSax_readstatus(u_char __user *buf, int len, int id, int channel)
620 {
621         int count, cnt;
622         u_char __user *p = buf;
623         struct IsdnCardState *cs = hisax_findcard(id);
624
625         if (cs) {
626                 if (len > HISAX_STATUS_BUFSIZE) {
627                         printk(KERN_WARNING
628                                "HiSax: status overflow readstat %d/%d\n",
629                                len, HISAX_STATUS_BUFSIZE);
630                 }
631                 count = cs->status_end - cs->status_read + 1;
632                 if (count >= len)
633                         count = len;
634                 if (copy_to_user(p, cs->status_read, count))
635                         return -EFAULT;
636                 cs->status_read += count;
637                 if (cs->status_read > cs->status_end)
638                         cs->status_read = cs->status_buf;
639                 p += count;
640                 count = len - count;
641                 while (count) {
642                         if (count > HISAX_STATUS_BUFSIZE)
643                                 cnt = HISAX_STATUS_BUFSIZE;
644                         else
645                                 cnt = count;
646                         if (copy_to_user(p, cs->status_read, cnt))
647                                 return -EFAULT;
648                         p += cnt;
649                         cs->status_read += cnt % HISAX_STATUS_BUFSIZE;
650                         count -= cnt;
651                 }
652                 return len;
653         } else {
654                 printk(KERN_ERR
655                        "HiSax: if_readstatus called with invalid driverId!\n");
656                 return -ENODEV;
657         }
658 }
659
660 int jiftime(char *s, long mark)
661 {
662         s += 8;
663
664         *s-- = '\0';
665         *s-- = mark % 10 + '0';
666         mark /= 10;
667         *s-- = mark % 10 + '0';
668         mark /= 10;
669         *s-- = '.';
670         *s-- = mark % 10 + '0';
671         mark /= 10;
672         *s-- = mark % 6 + '0';
673         mark /= 6;
674         *s-- = ':';
675         *s-- = mark % 10 + '0';
676         mark /= 10;
677         *s-- = mark % 10 + '0';
678         return 8;
679 }
680
681 static u_char tmpbuf[HISAX_STATUS_BUFSIZE];
682
683 void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt,
684                       va_list args)
685 {
686         /* if head == NULL the fmt contains the full info */
687
688         u_long          flags;
689         int             count, i;
690         u_char          *p;
691         isdn_ctrl       ic;
692         int             len;
693
694         if (!cs) {
695                 printk(KERN_WARNING "HiSax: No CardStatus for message");
696                 return;
697         }
698         spin_lock_irqsave(&cs->statlock, flags);
699         p = tmpbuf;
700         if (head) {
701                 p += jiftime(p, jiffies);
702                 p += sprintf(p, " %s", head);
703                 p += vsprintf(p, fmt, args);
704                 *p++ = '\n';
705                 *p = 0;
706                 len = p - tmpbuf;
707                 p = tmpbuf;
708         } else {
709                 p = fmt;
710                 len = strlen(fmt);
711         }
712         if (len > HISAX_STATUS_BUFSIZE) {
713                 spin_unlock_irqrestore(&cs->statlock, flags);
714                 printk(KERN_WARNING "HiSax: status overflow %d/%d\n",
715                        len, HISAX_STATUS_BUFSIZE);
716                 return;
717         }
718         count = len;
719         i = cs->status_end - cs->status_write + 1;
720         if (i >= len)
721                 i = len;
722         len -= i;
723         memcpy(cs->status_write, p, i);
724         cs->status_write += i;
725         if (cs->status_write > cs->status_end)
726                 cs->status_write = cs->status_buf;
727         p += i;
728         if (len) {
729                 memcpy(cs->status_write, p, len);
730                 cs->status_write += len;
731         }
732 #ifdef KERNELSTACK_DEBUG
733         i = (ulong) & len - current->kernel_stack_page;
734         sprintf(tmpbuf, "kstack %s %lx use %ld\n", current->comm,
735                 current->kernel_stack_page, i);
736         len = strlen(tmpbuf);
737         for (p = tmpbuf, i = len; i > 0; i--, p++) {
738                 *cs->status_write++ = *p;
739                 if (cs->status_write > cs->status_end)
740                         cs->status_write = cs->status_buf;
741                 count++;
742         }
743 #endif
744         spin_unlock_irqrestore(&cs->statlock, flags);
745         if (count) {
746                 ic.command = ISDN_STAT_STAVAIL;
747                 ic.driver = cs->myid;
748                 ic.arg = count;
749                 cs->iif.statcallb(&ic);
750         }
751 }
752
753 void HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...)
754 {
755         va_list args;
756
757         va_start(args, fmt);
758         VHiSax_putstatus(cs, head, fmt, args);
759         va_end(args);
760 }
761
762 int ll_run(struct IsdnCardState *cs, int addfeatures)
763 {
764         isdn_ctrl ic;
765
766         ic.driver = cs->myid;
767         ic.command = ISDN_STAT_RUN;
768         cs->iif.features |= addfeatures;
769         cs->iif.statcallb(&ic);
770         return 0;
771 }
772
773 static void ll_stop(struct IsdnCardState *cs)
774 {
775         isdn_ctrl ic;
776
777         ic.command = ISDN_STAT_STOP;
778         ic.driver = cs->myid;
779         cs->iif.statcallb(&ic);
780         //      CallcFreeChan(cs);
781 }
782
783 static void ll_unload(struct IsdnCardState *cs)
784 {
785         isdn_ctrl ic;
786
787         ic.command = ISDN_STAT_UNLOAD;
788         ic.driver = cs->myid;
789         cs->iif.statcallb(&ic);
790         kfree(cs->status_buf);
791         cs->status_read = NULL;
792         cs->status_write = NULL;
793         cs->status_end = NULL;
794         kfree(cs->dlog);
795         cs->dlog = NULL;
796 }
797
798 static void closecard(int cardnr)
799 {
800         struct IsdnCardState *csta = cards[cardnr].cs;
801
802         if (csta->bcs->BC_Close != NULL) {
803                 csta->bcs->BC_Close(csta->bcs + 1);
804                 csta->bcs->BC_Close(csta->bcs);
805         }
806
807         skb_queue_purge(&csta->rq);
808         skb_queue_purge(&csta->sq);
809         kfree(csta->rcvbuf);
810         csta->rcvbuf = NULL;
811         if (csta->tx_skb) {
812                 dev_kfree_skb(csta->tx_skb);
813                 csta->tx_skb = NULL;
814         }
815         if (csta->DC_Close != NULL) {
816                 csta->DC_Close(csta);
817         }
818         if (csta->cardmsg)
819                 csta->cardmsg(csta, CARD_RELEASE, NULL);
820         if (csta->dbusytimer.function != NULL) // FIXME?
821                 del_timer(&csta->dbusytimer);
822         ll_unload(csta);
823 }
824
825 static int init_card(struct IsdnCardState *cs)
826 {
827         int     irq_cnt, cnt = 3, ret;
828
829         if (!cs->irq) {
830                 ret = cs->cardmsg(cs, CARD_INIT, NULL);
831                 return(ret);
832         }
833         irq_cnt = kstat_irqs(cs->irq);
834         printk(KERN_INFO "%s: IRQ %d count %d\n", CardType[cs->typ],
835                cs->irq, irq_cnt);
836         if (request_irq(cs->irq, cs->irq_func, cs->irq_flags, "HiSax", cs)) {
837                 printk(KERN_WARNING "HiSax: couldn't get interrupt %d\n",
838                        cs->irq);
839                 return 1;
840         }
841         while (cnt) {
842                 cs->cardmsg(cs, CARD_INIT, NULL);
843                 /* Timeout 10ms */
844                 msleep(10);
845                 printk(KERN_INFO "%s: IRQ %d count %d\n",
846                        CardType[cs->typ], cs->irq, kstat_irqs(cs->irq));
847                 if (kstat_irqs(cs->irq) == irq_cnt) {
848                         printk(KERN_WARNING
849                                "%s: IRQ(%d) getting no interrupts during init %d\n",
850                                CardType[cs->typ], cs->irq, 4 - cnt);
851                         if (cnt == 1) {
852                                 free_irq(cs->irq, cs);
853                                 return 2;
854                         } else {
855                                 cs->cardmsg(cs, CARD_RESET, NULL);
856                                 cnt--;
857                         }
858                 } else {
859                         cs->cardmsg(cs, CARD_TEST, NULL);
860                         return 0;
861                 }
862         }
863         return 3;
864 }
865
866 static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockowner)
867 {
868         int ret = 0;
869         struct IsdnCard *card = cards + cardnr;
870         struct IsdnCardState *cs;
871
872         cs = kmalloc(sizeof(struct IsdnCardState), GFP_ATOMIC);
873         if (!cs) {
874                 printk(KERN_WARNING
875                        "HiSax: No memory for IsdnCardState(card %d)\n",
876                        cardnr + 1);
877                 goto out;
878         }
879         memset(cs, 0, sizeof(struct IsdnCardState));
880         card->cs = cs;
881         spin_lock_init(&cs->statlock);
882         spin_lock_init(&cs->lock);
883         cs->chanlimit = 2;      /* maximum B-channel number */
884         cs->logecho = 0;        /* No echo logging */
885         cs->cardnr = cardnr;
886         cs->debug = L1_DEB_WARN;
887         cs->HW_Flags = 0;
888         cs->busy_flag = busy_flag;
889         cs->irq_flags = I4L_IRQ_FLAG;
890 #if TEI_PER_CARD
891         if (card->protocol == ISDN_PTYPE_NI1)
892                 test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);
893 #else
894         test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);
895 #endif
896         cs->protocol = card->protocol;
897
898         if (card->typ <= 0 || card->typ > ISDN_CTYPE_COUNT) {
899                 printk(KERN_WARNING
900                        "HiSax: Card Type %d out of range\n", card->typ);
901                 goto outf_cs;
902         }
903         if (!(cs->dlog = kmalloc(MAX_DLOG_SPACE, GFP_ATOMIC))) {
904                 printk(KERN_WARNING
905                        "HiSax: No memory for dlog(card %d)\n", cardnr + 1);
906                 goto outf_cs;
907         }
908         if (!(cs->status_buf = kmalloc(HISAX_STATUS_BUFSIZE, GFP_ATOMIC))) {
909                 printk(KERN_WARNING
910                        "HiSax: No memory for status_buf(card %d)\n",
911                        cardnr + 1);
912                 goto outf_dlog;
913         }
914         cs->stlist = NULL;
915         cs->status_read = cs->status_buf;
916         cs->status_write = cs->status_buf;
917         cs->status_end = cs->status_buf + HISAX_STATUS_BUFSIZE - 1;
918         cs->typ = card->typ;
919 #ifdef MODULE
920         cs->iif.owner = lockowner;
921 #endif
922         strcpy(cs->iif.id, id);
923         cs->iif.channels = 2;
924         cs->iif.maxbufsize = MAX_DATA_SIZE;
925         cs->iif.hl_hdrlen = MAX_HEADER_LEN;
926         cs->iif.features =
927                 ISDN_FEATURE_L2_X75I |
928                 ISDN_FEATURE_L2_HDLC |
929                 ISDN_FEATURE_L2_HDLC_56K |
930                 ISDN_FEATURE_L2_TRANS |
931                 ISDN_FEATURE_L3_TRANS |
932 #ifdef  CONFIG_HISAX_1TR6
933                 ISDN_FEATURE_P_1TR6 |
934 #endif
935 #ifdef  CONFIG_HISAX_EURO
936                 ISDN_FEATURE_P_EURO |
937 #endif
938 #ifdef  CONFIG_HISAX_NI1
939                 ISDN_FEATURE_P_NI1 |
940 #endif
941                 0;
942
943         cs->iif.command = HiSax_command;
944         cs->iif.writecmd = NULL;
945         cs->iif.writebuf_skb = HiSax_writebuf_skb;
946         cs->iif.readstat = HiSax_readstatus;
947         register_isdn(&cs->iif);
948         cs->myid = cs->iif.channels;
949         printk(KERN_INFO
950                "HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr + 1,
951                (card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" :
952                (card->protocol == ISDN_PTYPE_EURO) ? "EDSS1" :
953                (card->protocol == ISDN_PTYPE_LEASED) ? "LEASED" :
954                (card->protocol == ISDN_PTYPE_NI1) ? "NI1" :
955                "NONE", cs->iif.id, cs->myid);
956         switch (card->typ) {
957 #if CARD_TELES0
958         case ISDN_CTYPE_16_0:
959         case ISDN_CTYPE_8_0:
960                 ret = setup_teles0(card);
961                 break;
962 #endif
963 #if CARD_TELES3
964         case ISDN_CTYPE_16_3:
965         case ISDN_CTYPE_PNP:
966         case ISDN_CTYPE_TELESPCMCIA:
967         case ISDN_CTYPE_COMPAQ_ISA:
968                 ret = setup_teles3(card);
969                 break;
970 #endif
971 #if CARD_S0BOX
972         case ISDN_CTYPE_S0BOX:
973                 ret = setup_s0box(card);
974                 break;
975 #endif
976 #if CARD_TELESPCI
977         case ISDN_CTYPE_TELESPCI:
978                 ret = setup_telespci(card);
979                 break;
980 #endif
981 #if CARD_AVM_A1
982         case ISDN_CTYPE_A1:
983                 ret = setup_avm_a1(card);
984                 break;
985 #endif
986 #if CARD_AVM_A1_PCMCIA
987         case ISDN_CTYPE_A1_PCMCIA:
988                 ret = setup_avm_a1_pcmcia(card);
989                 break;
990 #endif
991 #if CARD_FRITZPCI
992         case ISDN_CTYPE_FRITZPCI:
993                 ret = setup_avm_pcipnp(card);
994                 break;
995 #endif
996 #if CARD_ELSA
997         case ISDN_CTYPE_ELSA:
998         case ISDN_CTYPE_ELSA_PNP:
999         case ISDN_CTYPE_ELSA_PCMCIA:
1000         case ISDN_CTYPE_ELSA_PCI:
1001                 ret = setup_elsa(card);
1002                 break;
1003 #endif
1004 #if CARD_IX1MICROR2
1005         case ISDN_CTYPE_IX1MICROR2:
1006                 ret = setup_ix1micro(card);
1007                 break;
1008 #endif
1009 #if CARD_DIEHLDIVA
1010         case ISDN_CTYPE_DIEHLDIVA:
1011                 ret = setup_diva(card);
1012                 break;
1013 #endif
1014 #if CARD_ASUSCOM
1015         case ISDN_CTYPE_ASUSCOM:
1016                 ret = setup_asuscom(card);
1017                 break;
1018 #endif
1019 #if CARD_TELEINT
1020         case ISDN_CTYPE_TELEINT:
1021                 ret = setup_TeleInt(card);
1022                 break;
1023 #endif
1024 #if CARD_SEDLBAUER
1025         case ISDN_CTYPE_SEDLBAUER:
1026         case ISDN_CTYPE_SEDLBAUER_PCMCIA:
1027         case ISDN_CTYPE_SEDLBAUER_FAX:
1028                 ret = setup_sedlbauer(card);
1029                 break;
1030 #endif
1031 #if CARD_SPORTSTER
1032         case ISDN_CTYPE_SPORTSTER:
1033                 ret = setup_sportster(card);
1034                 break;
1035 #endif
1036 #if CARD_MIC
1037         case ISDN_CTYPE_MIC:
1038                 ret = setup_mic(card);
1039                 break;
1040 #endif
1041 #if CARD_NETJET_S
1042         case ISDN_CTYPE_NETJET_S:
1043                 ret = setup_netjet_s(card);
1044                 break;
1045 #endif
1046 #if CARD_HFCS
1047         case ISDN_CTYPE_TELES3C:
1048         case ISDN_CTYPE_ACERP10:
1049                 ret = setup_hfcs(card);
1050                 break;
1051 #endif
1052 #if CARD_HFC_PCI
1053         case ISDN_CTYPE_HFC_PCI:
1054                 ret = setup_hfcpci(card);
1055                 break;
1056 #endif
1057 #if CARD_HFC_SX
1058         case ISDN_CTYPE_HFC_SX:
1059                 ret = setup_hfcsx(card);
1060                 break;
1061 #endif
1062 #if CARD_NICCY
1063         case ISDN_CTYPE_NICCY:
1064                 ret = setup_niccy(card);
1065                 break;
1066 #endif
1067 #if CARD_AMD7930
1068         case ISDN_CTYPE_AMD7930:
1069                 ret = setup_amd7930(card);
1070                 break;
1071 #endif
1072 #if CARD_ISURF
1073         case ISDN_CTYPE_ISURF:
1074                 ret = setup_isurf(card);
1075                 break;
1076 #endif
1077 #if CARD_HSTSAPHIR
1078         case ISDN_CTYPE_HSTSAPHIR:
1079                 ret = setup_saphir(card);
1080                 break;
1081 #endif
1082 #if CARD_TESTEMU
1083         case ISDN_CTYPE_TESTEMU:
1084                 ret = setup_testemu(card);
1085                 break;
1086 #endif
1087 #if     CARD_BKM_A4T
1088         case ISDN_CTYPE_BKM_A4T:
1089                 ret = setup_bkm_a4t(card);
1090                 break;
1091 #endif
1092 #if     CARD_SCT_QUADRO
1093         case ISDN_CTYPE_SCT_QUADRO:
1094                 ret = setup_sct_quadro(card);
1095                 break;
1096 #endif
1097 #if CARD_GAZEL
1098         case ISDN_CTYPE_GAZEL:
1099                 ret = setup_gazel(card);
1100                 break;
1101 #endif
1102 #if CARD_W6692
1103         case ISDN_CTYPE_W6692:
1104                 ret = setup_w6692(card);
1105                 break;
1106 #endif
1107 #if CARD_NETJET_U
1108         case ISDN_CTYPE_NETJET_U:
1109                 ret = setup_netjet_u(card);
1110                 break;
1111 #endif
1112 #if CARD_FN_ENTERNOW_PCI
1113         case ISDN_CTYPE_ENTERNOW:
1114                 ret = setup_enternow_pci(card);
1115                 break;
1116 #endif
1117         case ISDN_CTYPE_DYNAMIC:
1118                 ret = 2;
1119                 break;
1120         default:
1121                 printk(KERN_WARNING
1122                        "HiSax: Support for %s Card not selected\n",
1123                        CardType[card->typ]);
1124                 ll_unload(cs);
1125                 goto outf_cs;
1126         }
1127         if (!ret) {
1128                 ll_unload(cs);
1129                 goto outf_cs;
1130         }
1131         if (!(cs->rcvbuf = kmalloc(MAX_DFRAME_LEN_L1, GFP_ATOMIC))) {
1132                 printk(KERN_WARNING "HiSax: No memory for isac rcvbuf\n");
1133                 ll_unload(cs);
1134                 goto outf_cs;
1135         }
1136         cs->rcvidx = 0;
1137         cs->tx_skb = NULL;
1138         cs->tx_cnt = 0;
1139         cs->event = 0;
1140         cs->tqueue.data = cs;
1141
1142         skb_queue_head_init(&cs->rq);
1143         skb_queue_head_init(&cs->sq);
1144
1145         init_bcstate(cs, 0);
1146         init_bcstate(cs, 1);
1147
1148         /* init_card only handles interrupts which are not */
1149         /* used here for the loadable driver */
1150         switch (card->typ) {
1151                 case ISDN_CTYPE_DYNAMIC:
1152                         ret = 0;
1153                         break;
1154                 default:
1155                         ret = init_card(cs);
1156                         break;
1157         }
1158         if (ret) {
1159                 closecard(cardnr);
1160                 ret = 0;
1161                 goto outf_cs;
1162         }
1163         init_tei(cs, cs->protocol);
1164         ret = CallcNewChan(cs);
1165         if (ret) {
1166                 closecard(cardnr);
1167                 ret = 0;
1168                 goto outf_cs;
1169         }
1170         /* ISAR needs firmware download first */
1171         if (!test_bit(HW_ISAR, &cs->HW_Flags))
1172                 ll_run(cs, 0);
1173
1174         ret = 1;
1175         goto out;
1176
1177  outf_dlog:
1178         kfree(cs->dlog);
1179  outf_cs:
1180         kfree(cs);
1181         card->cs = NULL;
1182  out:
1183         return ret;
1184 }
1185
1186 static void HiSax_shiftcards(int idx)
1187 {
1188         int i;
1189
1190         for (i = idx; i < (HISAX_MAX_CARDS - 1); i++)
1191                 memcpy(&cards[i], &cards[i + 1], sizeof(cards[i]));
1192 }
1193
1194 static int HiSax_inithardware(int *busy_flag)
1195 {
1196         int foundcards = 0;
1197         int i = 0;
1198         int t = ',';
1199         int flg = 0;
1200         char *id;
1201         char *next_id = HiSax_id;
1202         char ids[20];
1203
1204         if (strchr(HiSax_id, ','))
1205                 t = ',';
1206         else if (strchr(HiSax_id, '%'))
1207                 t = '%';
1208
1209         while (i < nrcards) {
1210                 if (cards[i].typ < 1)
1211                         break;
1212                 id = next_id;
1213                 if ((next_id = strchr(id, t))) {
1214                         *next_id++ = 0;
1215                         strcpy(ids, id);
1216                         flg = i + 1;
1217                 } else {
1218                         next_id = id;
1219                         if (flg >= i)
1220                                 strcpy(ids, id);
1221                         else
1222                                 sprintf(ids, "%s%d", id, i);
1223                 }
1224                 if (checkcard(i, ids, busy_flag, THIS_MODULE)) {
1225                         foundcards++;
1226                         i++;
1227                 } else {
1228                         /* make sure we don't oops the module */
1229                         if (cards[i].typ > 0 && cards[i].typ <= ISDN_CTYPE_COUNT) {
1230                                 printk(KERN_WARNING
1231                                         "HiSax: Card %s not installed !\n",
1232                                         CardType[cards[i].typ]);
1233                         }
1234                         HiSax_shiftcards(i);
1235                         nrcards--;
1236                 }
1237         }
1238         return foundcards;
1239 }
1240
1241 void HiSax_closecard(int cardnr)
1242 {
1243         int i, last = nrcards - 1;
1244
1245         if (cardnr > last || cardnr < 0)
1246                 return;
1247         if (cards[cardnr].cs) {
1248                 ll_stop(cards[cardnr].cs);
1249                 release_tei(cards[cardnr].cs);
1250                 CallcFreeChan(cards[cardnr].cs);
1251
1252                 closecard(cardnr);
1253                 if (cards[cardnr].cs->irq)
1254                         free_irq(cards[cardnr].cs->irq, cards[cardnr].cs);
1255                 kfree((void *) cards[cardnr].cs);
1256                 cards[cardnr].cs = NULL;
1257         }
1258         i = cardnr;
1259         while (i <= last) {
1260                 cards[i] = cards[i + 1];
1261                 i++;
1262         }
1263         nrcards--;
1264 }
1265
1266 void HiSax_reportcard(int cardnr, int sel)
1267 {
1268         struct IsdnCardState *cs = cards[cardnr].cs;
1269
1270         printk(KERN_DEBUG "HiSax: reportcard No %d\n", cardnr + 1);
1271         printk(KERN_DEBUG "HiSax: Type %s\n", CardType[cs->typ]);
1272         printk(KERN_DEBUG "HiSax: debuglevel %x\n", cs->debug);
1273         printk(KERN_DEBUG "HiSax: HiSax_reportcard address 0x%lX\n",
1274                (ulong) & HiSax_reportcard);
1275         printk(KERN_DEBUG "HiSax: cs 0x%lX\n", (ulong) cs);
1276         printk(KERN_DEBUG "HiSax: HW_Flags %lx bc0 flg %lx bc1 flg %lx\n",
1277                cs->HW_Flags, cs->bcs[0].Flag, cs->bcs[1].Flag);
1278         printk(KERN_DEBUG "HiSax: bcs 0 mode %d ch%d\n",
1279                cs->bcs[0].mode, cs->bcs[0].channel);
1280         printk(KERN_DEBUG "HiSax: bcs 1 mode %d ch%d\n",
1281                cs->bcs[1].mode, cs->bcs[1].channel);
1282 #ifdef ERROR_STATISTIC
1283         printk(KERN_DEBUG "HiSax: dc errors(rx,crc,tx) %d,%d,%d\n",
1284                cs->err_rx, cs->err_crc, cs->err_tx);
1285         printk(KERN_DEBUG
1286                "HiSax: bc0 errors(inv,rdo,crc,tx) %d,%d,%d,%d\n",
1287                cs->bcs[0].err_inv, cs->bcs[0].err_rdo, cs->bcs[0].err_crc,
1288                cs->bcs[0].err_tx);
1289         printk(KERN_DEBUG
1290                "HiSax: bc1 errors(inv,rdo,crc,tx) %d,%d,%d,%d\n",
1291                cs->bcs[1].err_inv, cs->bcs[1].err_rdo, cs->bcs[1].err_crc,
1292                cs->bcs[1].err_tx);
1293         if (sel == 99) {
1294                 cs->err_rx  = 0;
1295                 cs->err_crc = 0;
1296                 cs->err_tx  = 0;
1297                 cs->bcs[0].err_inv = 0;
1298                 cs->bcs[0].err_rdo = 0;
1299                 cs->bcs[0].err_crc = 0;
1300                 cs->bcs[0].err_tx  = 0;
1301                 cs->bcs[1].err_inv = 0;
1302                 cs->bcs[1].err_rdo = 0;
1303                 cs->bcs[1].err_crc = 0;
1304                 cs->bcs[1].err_tx  = 0;
1305         }
1306 #endif
1307 }
1308
1309 static int __init HiSax_init(void)
1310 {
1311         int i, retval;
1312 #ifdef MODULE
1313         int j;
1314         int nzproto = 0;
1315 #endif
1316
1317         HiSaxVersion();
1318         retval = CallcNew();
1319         if (retval)
1320                 goto out;
1321         retval = Isdnl3New();
1322         if (retval)
1323                 goto out_callc;
1324         retval = Isdnl2New();
1325         if (retval)
1326                 goto out_isdnl3;
1327         retval = TeiNew();
1328         if (retval)
1329                 goto out_isdnl2;
1330         retval = Isdnl1New();
1331         if (retval)
1332                 goto out_tei;
1333
1334 #ifdef MODULE
1335         if (!type[0]) {
1336                 /* We 'll register drivers later, but init basic functions */
1337                 for (i = 0; i < HISAX_MAX_CARDS; i++)
1338                         cards[i].typ = 0;
1339                 return 0;
1340         }
1341 #ifdef CONFIG_HISAX_ELSA
1342         if (type[0] == ISDN_CTYPE_ELSA_PCMCIA) {
1343                 /* we have exported  and return in this case */
1344                 return 0;
1345         }
1346 #endif
1347 #ifdef CONFIG_HISAX_SEDLBAUER
1348         if (type[0] == ISDN_CTYPE_SEDLBAUER_PCMCIA) {
1349                 /* we have to export  and return in this case */
1350                 return 0;
1351         }
1352 #endif
1353 #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
1354         if (type[0] == ISDN_CTYPE_A1_PCMCIA) {
1355                 /* we have to export  and return in this case */
1356                 return 0;
1357         }
1358 #endif
1359 #ifdef CONFIG_HISAX_HFC_SX
1360         if (type[0] == ISDN_CTYPE_HFC_SP_PCMCIA) {
1361                 /* we have to export  and return in this case */
1362                 return 0;
1363         }
1364 #endif
1365 #endif
1366         nrcards = 0;
1367 #ifdef MODULE
1368         if (id)                 /* If id= string used */
1369                 HiSax_id = id;
1370         for (i = j = 0; j < HISAX_MAX_CARDS; i++) {
1371                 cards[j].typ = type[i];
1372                 if (protocol[i]) {
1373                         cards[j].protocol = protocol[i];
1374                         nzproto++;
1375                 } else {
1376                         cards[j].protocol = DEFAULT_PROTO;
1377                 }
1378                 switch (type[i]) {
1379                 case ISDN_CTYPE_16_0:
1380                         cards[j].para[0] = irq[i];
1381                         cards[j].para[1] = mem[i];
1382                         cards[j].para[2] = io[i];
1383                         break;
1384
1385                 case ISDN_CTYPE_8_0:
1386                         cards[j].para[0] = irq[i];
1387                         cards[j].para[1] = mem[i];
1388                         break;
1389
1390 #ifdef IO0_IO1
1391                 case ISDN_CTYPE_PNP:
1392                 case ISDN_CTYPE_NICCY:
1393                         cards[j].para[0] = irq[i];
1394                         cards[j].para[1] = io0[i];
1395                         cards[j].para[2] = io1[i];
1396                         break;
1397                 case ISDN_CTYPE_COMPAQ_ISA:
1398                         cards[j].para[0] = irq[i];
1399                         cards[j].para[1] = io0[i];
1400                         cards[j].para[2] = io1[i];
1401                         cards[j].para[3] = io[i];
1402                         break;
1403 #endif
1404                 case ISDN_CTYPE_ELSA:
1405                 case ISDN_CTYPE_HFC_PCI:
1406                         cards[j].para[0] = io[i];
1407                         break;
1408                 case ISDN_CTYPE_16_3:
1409                 case ISDN_CTYPE_TELESPCMCIA:
1410                 case ISDN_CTYPE_A1:
1411                 case ISDN_CTYPE_A1_PCMCIA:
1412                 case ISDN_CTYPE_ELSA_PNP:
1413                 case ISDN_CTYPE_ELSA_PCMCIA:
1414                 case ISDN_CTYPE_IX1MICROR2:
1415                 case ISDN_CTYPE_DIEHLDIVA:
1416                 case ISDN_CTYPE_ASUSCOM:
1417                 case ISDN_CTYPE_TELEINT:
1418                 case ISDN_CTYPE_SEDLBAUER:
1419                 case ISDN_CTYPE_SEDLBAUER_PCMCIA:
1420                 case ISDN_CTYPE_SEDLBAUER_FAX:
1421                 case ISDN_CTYPE_SPORTSTER:
1422                 case ISDN_CTYPE_MIC:
1423                 case ISDN_CTYPE_TELES3C:
1424                 case ISDN_CTYPE_ACERP10:
1425                 case ISDN_CTYPE_S0BOX:
1426                 case ISDN_CTYPE_FRITZPCI:
1427                 case ISDN_CTYPE_HSTSAPHIR:
1428                 case ISDN_CTYPE_GAZEL:
1429                 case ISDN_CTYPE_HFC_SX:
1430                 case ISDN_CTYPE_HFC_SP_PCMCIA:
1431                         cards[j].para[0] = irq[i];
1432                         cards[j].para[1] = io[i];
1433                         break;
1434                 case ISDN_CTYPE_ISURF:
1435                         cards[j].para[0] = irq[i];
1436                         cards[j].para[1] = io[i];
1437                         cards[j].para[2] = mem[i];
1438                         break;
1439                 case ISDN_CTYPE_ELSA_PCI:
1440                 case ISDN_CTYPE_NETJET_S:
1441                 case ISDN_CTYPE_AMD7930:
1442                 case ISDN_CTYPE_TELESPCI:
1443                 case ISDN_CTYPE_W6692:
1444                 case ISDN_CTYPE_NETJET_U:
1445                         break;
1446                 case ISDN_CTYPE_BKM_A4T:
1447                         break;
1448                 case ISDN_CTYPE_SCT_QUADRO:
1449                         if (irq[i]) {
1450                                 cards[j].para[0] = irq[i];
1451                         } else {
1452                                 /* QUADRO is a 4 BRI card */
1453                                 cards[j++].para[0] = 1;
1454                                 /* we need to check if further cards can be added */
1455                                 if (j < HISAX_MAX_CARDS) {
1456                                         cards[j].typ = ISDN_CTYPE_SCT_QUADRO;
1457                                         cards[j].protocol = protocol[i];
1458                                         cards[j++].para[0] = 2;
1459                                 }
1460                                 if (j < HISAX_MAX_CARDS) {
1461                                         cards[j].typ = ISDN_CTYPE_SCT_QUADRO;
1462                                         cards[j].protocol = protocol[i];
1463                                         cards[j++].para[0] = 3;
1464                                 }
1465                                 if (j < HISAX_MAX_CARDS) {
1466                                         cards[j].typ = ISDN_CTYPE_SCT_QUADRO;
1467                                         cards[j].protocol = protocol[i];
1468                                         cards[j].para[0] = 4;
1469                                 }
1470                         }
1471                         break;
1472                 }
1473                 j++;
1474         }
1475         if (!nzproto) {
1476                 printk(KERN_WARNING
1477                        "HiSax: Warning - no protocol specified\n");
1478                 printk(KERN_WARNING "HiSax: using protocol %s\n",
1479                        DEFAULT_PROTO_NAME);
1480         }
1481 #endif
1482         if (!HiSax_id)
1483                 HiSax_id = HiSaxID;
1484         if (!HiSaxID[0])
1485                 strcpy(HiSaxID, "HiSax");
1486         for (i = 0; i < HISAX_MAX_CARDS; i++)
1487                 if (cards[i].typ > 0)
1488                         nrcards++;
1489         printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
1490                nrcards, (nrcards > 1) ? "s" : "");
1491
1492         /* Install only, if at least one card found */
1493         if (!HiSax_inithardware(NULL))
1494                 return -ENODEV;
1495         return 0;
1496
1497  out_tei:
1498         TeiFree();
1499  out_isdnl2:
1500         Isdnl2Free();
1501  out_isdnl3:
1502         Isdnl3Free();
1503  out_callc:
1504         CallcFree();
1505  out:
1506         return retval;
1507 }
1508
1509 static void __exit HiSax_exit(void)
1510 {
1511         int cardnr = nrcards - 1;
1512
1513         while (cardnr >= 0)
1514                 HiSax_closecard(cardnr--);
1515         Isdnl1Free();
1516         TeiFree();
1517         Isdnl2Free();
1518         Isdnl3Free();
1519         CallcFree();
1520         printk(KERN_INFO "HiSax module removed\n");
1521 }
1522
1523 int hisax_init_pcmcia(void *pcm_iob, int *busy_flag, struct IsdnCard *card)
1524 {
1525         u_char ids[16];
1526         int ret = -1;
1527
1528         cards[nrcards] = *card;
1529         if (nrcards)
1530                 sprintf(ids, "HiSax%d", nrcards);
1531         else
1532                 sprintf(ids, "HiSax");
1533         if (!checkcard(nrcards, ids, busy_flag, THIS_MODULE))
1534                 goto error;
1535
1536         ret = nrcards;
1537         nrcards++;
1538 error:
1539         return ret;
1540 }
1541
1542 EXPORT_SYMBOL(hisax_init_pcmcia);
1543 EXPORT_SYMBOL(HiSax_closecard);
1544
1545 #include "hisax_if.h"
1546
1547 EXPORT_SYMBOL(hisax_register);
1548 EXPORT_SYMBOL(hisax_unregister);
1549
1550 static void hisax_d_l1l2(struct hisax_if *ifc, int pr, void *arg);
1551 static void hisax_b_l1l2(struct hisax_if *ifc, int pr, void *arg);
1552 static void hisax_d_l2l1(struct PStack *st, int pr, void *arg);
1553 static void hisax_b_l2l1(struct PStack *st, int pr, void *arg);
1554 static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg);
1555 static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs);
1556 static void hisax_bc_close(struct BCState *bcs);
1557 static void hisax_bh(struct IsdnCardState *cs);
1558 static void EChannel_proc_rcv(struct hisax_d_if *d_if);
1559
1560 int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
1561                    char *name, int protocol)
1562 {
1563         int i, retval;
1564         char id[20];
1565         struct IsdnCardState *cs;
1566
1567         for (i = 0; i < HISAX_MAX_CARDS; i++) {
1568                 if (!cards[i].typ)
1569                         break;
1570         }
1571
1572         if (i >= HISAX_MAX_CARDS)
1573                 return -EBUSY;
1574
1575         cards[i].typ = ISDN_CTYPE_DYNAMIC;
1576         cards[i].protocol = protocol;
1577         sprintf(id, "%s%d", name, i);
1578         nrcards++;
1579         retval = checkcard(i, id, NULL, hisax_d_if->owner);
1580         if (retval == 0) { // yuck
1581                 cards[i].typ = 0;
1582                 nrcards--;
1583                 return retval;
1584         }
1585         cs = cards[i].cs;
1586         hisax_d_if->cs = cs;
1587         cs->hw.hisax_d_if = hisax_d_if;
1588         cs->cardmsg = hisax_cardmsg;
1589         INIT_WORK(&cs->tqueue, (void *)(void *)hisax_bh, cs);
1590         cs->channel[0].d_st->l2.l2l1 = hisax_d_l2l1;
1591         for (i = 0; i < 2; i++) {
1592                 cs->bcs[i].BC_SetStack = hisax_bc_setstack;
1593                 cs->bcs[i].BC_Close = hisax_bc_close;
1594
1595                 b_if[i]->ifc.l1l2 = hisax_b_l1l2;
1596
1597                 hisax_d_if->b_if[i] = b_if[i];
1598         }
1599         hisax_d_if->ifc.l1l2 = hisax_d_l1l2;
1600         skb_queue_head_init(&hisax_d_if->erq);
1601         clear_bit(0, &hisax_d_if->ph_state);
1602         
1603         return 0;
1604 }
1605
1606 void hisax_unregister(struct hisax_d_if *hisax_d_if)
1607 {
1608         cards[hisax_d_if->cs->cardnr].typ = 0;
1609         HiSax_closecard(hisax_d_if->cs->cardnr);
1610         skb_queue_purge(&hisax_d_if->erq);
1611 }
1612
1613 #include "isdnl1.h"
1614
1615 static void hisax_sched_event(struct IsdnCardState *cs, int event)
1616 {
1617         test_and_set_bit(event, &cs->event);
1618         schedule_work(&cs->tqueue);
1619 }
1620
1621 static void hisax_bh(struct IsdnCardState *cs)
1622 {
1623         struct PStack *st;
1624         int pr;
1625
1626         if (test_and_clear_bit(D_RCVBUFREADY, &cs->event))
1627                 DChannel_proc_rcv(cs);
1628         if (test_and_clear_bit(E_RCVBUFREADY, &cs->event))
1629                 EChannel_proc_rcv(cs->hw.hisax_d_if);
1630         if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) {
1631                 if (test_bit(0, &cs->hw.hisax_d_if->ph_state))
1632                         pr = PH_ACTIVATE | INDICATION;
1633                 else
1634                         pr = PH_DEACTIVATE | INDICATION;
1635                 for (st = cs->stlist; st; st = st->next)
1636                         st->l1.l1l2(st, pr, NULL);
1637                 
1638         }
1639 }
1640
1641 static void hisax_b_sched_event(struct BCState *bcs, int event)
1642 {
1643         test_and_set_bit(event, &bcs->event);
1644         schedule_work(&bcs->tqueue);
1645 }
1646
1647 static inline void D_L2L1(struct hisax_d_if *d_if, int pr, void *arg)
1648 {
1649         struct hisax_if *ifc = (struct hisax_if *) d_if;
1650         ifc->l2l1(ifc, pr, arg);
1651 }
1652
1653 static inline void B_L2L1(struct hisax_b_if *b_if, int pr, void *arg)
1654 {
1655         struct hisax_if *ifc = (struct hisax_if *) b_if;
1656         ifc->l2l1(ifc, pr, arg);
1657 }
1658
1659 static void hisax_d_l1l2(struct hisax_if *ifc, int pr, void *arg)
1660 {
1661         struct hisax_d_if *d_if = (struct hisax_d_if *) ifc;
1662         struct IsdnCardState *cs = d_if->cs;
1663         struct PStack *st;
1664         struct sk_buff *skb;
1665
1666         switch (pr) {
1667         case PH_ACTIVATE | INDICATION:
1668                 set_bit(0, &d_if->ph_state);
1669                 hisax_sched_event(cs, D_L1STATECHANGE);
1670                 break;
1671         case PH_DEACTIVATE | INDICATION:
1672                 clear_bit(0, &d_if->ph_state);
1673                 hisax_sched_event(cs, D_L1STATECHANGE);
1674                 break;
1675         case PH_DATA | INDICATION:
1676                 skb_queue_tail(&cs->rq, arg);
1677                 hisax_sched_event(cs, D_RCVBUFREADY);
1678                 break;
1679         case PH_DATA | CONFIRM:
1680                 skb = skb_dequeue(&cs->sq);
1681                 if (skb) {
1682                         D_L2L1(d_if, PH_DATA | REQUEST, skb);
1683                         break;
1684                 }
1685                 clear_bit(FLG_L1_DBUSY, &cs->HW_Flags);
1686                 for (st = cs->stlist; st; st = st->next) {
1687                         if (test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags)) {
1688                                 st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
1689                                 break;
1690                         }
1691                 }
1692                 break;
1693         case PH_DATA_E | INDICATION:
1694                 skb_queue_tail(&d_if->erq, arg);
1695                 hisax_sched_event(cs, E_RCVBUFREADY);
1696                 break;
1697         default:
1698                 printk("pr %#x\n", pr);
1699                 break;
1700         }
1701 }
1702
1703 static void hisax_b_l1l2(struct hisax_if *ifc, int pr, void *arg)
1704 {
1705         struct hisax_b_if *b_if = (struct hisax_b_if *) ifc;
1706         struct BCState *bcs = b_if->bcs;
1707         struct PStack *st = bcs->st;
1708         struct sk_buff *skb;
1709
1710         // FIXME use isdnl1?
1711         switch (pr) {
1712         case PH_ACTIVATE | INDICATION:
1713                 st->l1.l1l2(st, pr, NULL);
1714                 break;
1715         case PH_DEACTIVATE | INDICATION:
1716                 st->l1.l1l2(st, pr, NULL);
1717                 clear_bit(BC_FLG_BUSY, &bcs->Flag);
1718                 skb_queue_purge(&bcs->squeue);
1719                 bcs->hw.b_if = NULL;
1720                 break;
1721         case PH_DATA | INDICATION:
1722                 skb_queue_tail(&bcs->rqueue, arg);
1723                 hisax_b_sched_event(bcs, B_RCVBUFREADY);
1724                 break;
1725         case PH_DATA | CONFIRM:
1726                 bcs->tx_cnt -= (long)arg;
1727                 if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag)) {
1728                         u_long  flags;
1729                         spin_lock_irqsave(&bcs->aclock, flags);
1730                         bcs->ackcnt += (long)arg;
1731                         spin_unlock_irqrestore(&bcs->aclock, flags);
1732                         schedule_event(bcs, B_ACKPENDING);
1733                 }
1734                 skb = skb_dequeue(&bcs->squeue);
1735                 if (skb) {
1736                         B_L2L1(b_if, PH_DATA | REQUEST, skb);
1737                         break;
1738                 }
1739                 clear_bit(BC_FLG_BUSY, &bcs->Flag);
1740                 if (test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags)) {
1741                         st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
1742                 }
1743                 break;
1744         default:
1745                 printk("hisax_b_l1l2 pr %#x\n", pr);
1746                 break;
1747         }
1748 }
1749
1750 static void hisax_d_l2l1(struct PStack *st, int pr, void *arg)
1751 {
1752         struct IsdnCardState *cs = st->l1.hardware;
1753         struct hisax_d_if *hisax_d_if = cs->hw.hisax_d_if;
1754         struct sk_buff *skb = arg;
1755
1756         switch (pr) {
1757         case PH_DATA | REQUEST:
1758         case PH_PULL | INDICATION:
1759                 if (cs->debug & DEB_DLOG_HEX)
1760                         LogFrame(cs, skb->data, skb->len);
1761                 if (cs->debug & DEB_DLOG_VERBOSE)
1762                         dlogframe(cs, skb, 0);
1763                 Logl2Frame(cs, skb, "PH_DATA_REQ", 0);
1764                 // FIXME lock?
1765                 if (!test_and_set_bit(FLG_L1_DBUSY, &cs->HW_Flags))
1766                         D_L2L1(hisax_d_if, PH_DATA | REQUEST, skb);
1767                 else
1768                         skb_queue_tail(&cs->sq, skb);
1769                 break;
1770         case PH_PULL | REQUEST:
1771                 if (!test_bit(FLG_L1_DBUSY, &cs->HW_Flags))
1772                         st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
1773                 else
1774                         set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
1775                 break;
1776         default:
1777                 D_L2L1(hisax_d_if, pr, arg);
1778                 break;
1779         }
1780 }
1781
1782 static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg)
1783 {
1784         return 0;
1785 }
1786
1787 static void hisax_b_l2l1(struct PStack *st, int pr, void *arg)
1788 {
1789         struct BCState *bcs = st->l1.bcs;
1790         struct hisax_b_if *b_if = bcs->hw.b_if;
1791
1792         switch (pr) {
1793         case PH_ACTIVATE | REQUEST:
1794                 B_L2L1(b_if, pr, (void *)(unsigned long)st->l1.mode);
1795                 break;
1796         case PH_DATA | REQUEST:
1797         case PH_PULL | INDICATION:
1798                 // FIXME lock?
1799                 if (!test_and_set_bit(BC_FLG_BUSY, &bcs->Flag)) {
1800                         B_L2L1(b_if, PH_DATA | REQUEST, arg);
1801                 } else {
1802                         skb_queue_tail(&bcs->squeue, arg);
1803                 }
1804                 break;
1805         case PH_PULL | REQUEST:
1806                 if (!test_bit(BC_FLG_BUSY, &bcs->Flag))
1807                         st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
1808                 else
1809                         set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
1810                 break;
1811         case PH_DEACTIVATE | REQUEST:
1812                 test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
1813                 skb_queue_purge(&bcs->squeue);
1814         default:
1815                 B_L2L1(b_if, pr, arg);
1816                 break;
1817         }
1818 }
1819
1820 static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs)
1821 {
1822         struct IsdnCardState *cs = st->l1.hardware;
1823         struct hisax_d_if *hisax_d_if = cs->hw.hisax_d_if;
1824
1825         bcs->channel = st->l1.bc;
1826
1827         bcs->hw.b_if = hisax_d_if->b_if[st->l1.bc];
1828         hisax_d_if->b_if[st->l1.bc]->bcs = bcs;
1829
1830         st->l1.bcs = bcs;
1831         st->l2.l2l1 = hisax_b_l2l1;
1832         setstack_manager(st);
1833         bcs->st = st;
1834         setstack_l1_B(st);
1835         skb_queue_head_init(&bcs->rqueue);
1836         skb_queue_head_init(&bcs->squeue);
1837         return 0;
1838 }
1839
1840 static void hisax_bc_close(struct BCState *bcs)
1841 {
1842         struct hisax_b_if *b_if = bcs->hw.b_if;
1843
1844         if (b_if)
1845                 B_L2L1(b_if, PH_DEACTIVATE | REQUEST, NULL);
1846 }
1847
1848 static void EChannel_proc_rcv(struct hisax_d_if *d_if)
1849 {
1850         struct IsdnCardState *cs = d_if->cs;
1851         u_char *ptr;
1852         struct sk_buff *skb;
1853
1854         while ((skb = skb_dequeue(&d_if->erq)) != NULL) {
1855                 if (cs->debug & DEB_DLOG_HEX) {
1856                         ptr = cs->dlog;
1857                         if ((skb->len) < MAX_DLOG_SPACE / 3 - 10) {
1858                                 *ptr++ = 'E';
1859                                 *ptr++ = 'C';
1860                                 *ptr++ = 'H';
1861                                 *ptr++ = 'O';
1862                                 *ptr++ = ':';
1863                                 ptr += QuickHex(ptr, skb->data, skb->len);
1864                                 ptr--;
1865                                 *ptr++ = '\n';
1866                                 *ptr = 0;
1867                                 HiSax_putstatus(cs, NULL, cs->dlog);
1868                         } else
1869                                 HiSax_putstatus(cs, "LogEcho: ",
1870                                                 "warning Frame too big (%d)",
1871                                                 skb->len);
1872                 }
1873                 dev_kfree_skb_any(skb);
1874         }
1875 }
1876
1877 #ifdef CONFIG_PCI
1878 #include <linux/pci.h>
1879
1880 static struct pci_device_id hisax_pci_tbl[] __devinitdata = {
1881 #ifdef CONFIG_HISAX_FRITZPCI
1882         {PCI_VENDOR_ID_AVM,      PCI_DEVICE_ID_AVM_A1,           PCI_ANY_ID, PCI_ANY_ID},
1883 #endif
1884 #ifdef CONFIG_HISAX_DIEHLDIVA
1885         {PCI_VENDOR_ID_EICON,    PCI_DEVICE_ID_EICON_DIVA20,     PCI_ANY_ID, PCI_ANY_ID},
1886         {PCI_VENDOR_ID_EICON,    PCI_DEVICE_ID_EICON_DIVA20_U,   PCI_ANY_ID, PCI_ANY_ID},
1887         {PCI_VENDOR_ID_EICON,    PCI_DEVICE_ID_EICON_DIVA201,    PCI_ANY_ID, PCI_ANY_ID},
1888 //#########################################################################################     
1889         {PCI_VENDOR_ID_EICON,    PCI_DEVICE_ID_EICON_DIVA202,    PCI_ANY_ID, PCI_ANY_ID},
1890 //#########################################################################################     
1891 #endif
1892 #ifdef CONFIG_HISAX_ELSA
1893         {PCI_VENDOR_ID_ELSA,     PCI_DEVICE_ID_ELSA_MICROLINK,   PCI_ANY_ID, PCI_ANY_ID},
1894         {PCI_VENDOR_ID_ELSA,     PCI_DEVICE_ID_ELSA_QS3000,      PCI_ANY_ID, PCI_ANY_ID},
1895 #endif
1896 #ifdef CONFIG_HISAX_GAZEL
1897         {PCI_VENDOR_ID_PLX,      PCI_DEVICE_ID_PLX_R685,         PCI_ANY_ID, PCI_ANY_ID},
1898         {PCI_VENDOR_ID_PLX,      PCI_DEVICE_ID_PLX_R753,         PCI_ANY_ID, PCI_ANY_ID},
1899         {PCI_VENDOR_ID_PLX,      PCI_DEVICE_ID_PLX_DJINN_ITOO,   PCI_ANY_ID, PCI_ANY_ID},
1900         {PCI_VENDOR_ID_PLX,      PCI_DEVICE_ID_PLX_OLITEC,       PCI_ANY_ID, PCI_ANY_ID},
1901 #endif
1902 #ifdef CONFIG_HISAX_QUADRO
1903         {PCI_VENDOR_ID_PLX,      PCI_DEVICE_ID_PLX_9050,         PCI_ANY_ID, PCI_ANY_ID},
1904 #endif
1905 #ifdef CONFIG_HISAX_NICCY
1906         {PCI_VENDOR_ID_SATSAGEM, PCI_DEVICE_ID_SATSAGEM_NICCY,   PCI_ANY_ID,PCI_ANY_ID},
1907 #endif
1908 #ifdef CONFIG_HISAX_SEDLBAUER
1909         {PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_100,     PCI_ANY_ID,PCI_ANY_ID},
1910 #endif
1911 #if defined(CONFIG_HISAX_NETJET) || defined(CONFIG_HISAX_NETJET_U)
1912         {PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_300,     PCI_ANY_ID,PCI_ANY_ID},
1913 #endif
1914 #if defined(CONFIG_HISAX_TELESPCI) || defined(CONFIG_HISAX_SCT_QUADRO)
1915         {PCI_VENDOR_ID_ZORAN,    PCI_DEVICE_ID_ZORAN_36120,      PCI_ANY_ID,PCI_ANY_ID},
1916 #endif
1917 #ifdef CONFIG_HISAX_W6692
1918         {PCI_VENDOR_ID_DYNALINK, PCI_DEVICE_ID_DYNALINK_IS64PH,  PCI_ANY_ID,PCI_ANY_ID},
1919         {PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_6692,    PCI_ANY_ID,PCI_ANY_ID},
1920 #endif
1921 #ifdef CONFIG_HISAX_HFC_PCI
1922         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_2BD0,         PCI_ANY_ID, PCI_ANY_ID},
1923         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B000,         PCI_ANY_ID, PCI_ANY_ID},
1924         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B006,         PCI_ANY_ID, PCI_ANY_ID},
1925         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B007,         PCI_ANY_ID, PCI_ANY_ID},
1926         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B008,         PCI_ANY_ID, PCI_ANY_ID},
1927         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B009,         PCI_ANY_ID, PCI_ANY_ID},
1928         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B00A,         PCI_ANY_ID, PCI_ANY_ID},
1929         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B00B,         PCI_ANY_ID, PCI_ANY_ID},
1930         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B00C,         PCI_ANY_ID, PCI_ANY_ID},
1931         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B100,         PCI_ANY_ID, PCI_ANY_ID},
1932         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B700,         PCI_ANY_ID, PCI_ANY_ID},
1933         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B701,         PCI_ANY_ID, PCI_ANY_ID},
1934         {PCI_VENDOR_ID_ABOCOM,   PCI_DEVICE_ID_ABOCOM_2BD1,      PCI_ANY_ID, PCI_ANY_ID},
1935         {PCI_VENDOR_ID_ASUSTEK,  PCI_DEVICE_ID_ASUSTEK_0675,     PCI_ANY_ID, PCI_ANY_ID},
1936         {PCI_VENDOR_ID_BERKOM,   PCI_DEVICE_ID_BERKOM_T_CONCEPT, PCI_ANY_ID, PCI_ANY_ID},
1937         {PCI_VENDOR_ID_BERKOM,   PCI_DEVICE_ID_BERKOM_A1T,       PCI_ANY_ID, PCI_ANY_ID},
1938         {PCI_VENDOR_ID_ANIGMA,   PCI_DEVICE_ID_ANIGMA_MC145575,  PCI_ANY_ID, PCI_ANY_ID},
1939         {PCI_VENDOR_ID_ZOLTRIX,  PCI_DEVICE_ID_ZOLTRIX_2BD0,     PCI_ANY_ID, PCI_ANY_ID},
1940         {PCI_VENDOR_ID_DIGI,     PCI_DEVICE_ID_DIGI_DF_M_IOM2_E, PCI_ANY_ID, PCI_ANY_ID},
1941         {PCI_VENDOR_ID_DIGI,     PCI_DEVICE_ID_DIGI_DF_M_E,      PCI_ANY_ID, PCI_ANY_ID},
1942         {PCI_VENDOR_ID_DIGI,     PCI_DEVICE_ID_DIGI_DF_M_IOM2_A, PCI_ANY_ID, PCI_ANY_ID},
1943         {PCI_VENDOR_ID_DIGI,     PCI_DEVICE_ID_DIGI_DF_M_A,      PCI_ANY_ID, PCI_ANY_ID},
1944 #endif
1945         { }                             /* Terminating entry */
1946 };
1947
1948 MODULE_DEVICE_TABLE(pci, hisax_pci_tbl);
1949 #endif /* CONFIG_PCI */
1950
1951 module_init(HiSax_init);
1952 module_exit(HiSax_exit);
1953
1954 EXPORT_SYMBOL(FsmNew);
1955 EXPORT_SYMBOL(FsmFree);
1956 EXPORT_SYMBOL(FsmEvent);
1957 EXPORT_SYMBOL(FsmChangeState);
1958 EXPORT_SYMBOL(FsmInitTimer);
1959 EXPORT_SYMBOL(FsmDelTimer);
1960 EXPORT_SYMBOL(FsmRestartTimer);