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