Merge branch 'upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/vitb/linux...
[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/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                 copy_to_user(p, cs->status_read, count);
635                 cs->status_read += count;
636                 if (cs->status_read > cs->status_end)
637                         cs->status_read = cs->status_buf;
638                 p += count;
639                 count = len - count;
640                 while (count) {
641                         if (count > HISAX_STATUS_BUFSIZE)
642                                 cnt = HISAX_STATUS_BUFSIZE;
643                         else
644                                 cnt = count;
645                         copy_to_user(p, cs->status_read, cnt);
646                         p += cnt;
647                         cs->status_read += cnt % HISAX_STATUS_BUFSIZE;
648                         count -= cnt;
649                 }
650                 return len;
651         } else {
652                 printk(KERN_ERR
653                        "HiSax: if_readstatus called with invalid driverId!\n");
654                 return -ENODEV;
655         }
656 }
657
658 int jiftime(char *s, long mark)
659 {
660         s += 8;
661
662         *s-- = '\0';
663         *s-- = mark % 10 + '0';
664         mark /= 10;
665         *s-- = mark % 10 + '0';
666         mark /= 10;
667         *s-- = '.';
668         *s-- = mark % 10 + '0';
669         mark /= 10;
670         *s-- = mark % 6 + '0';
671         mark /= 6;
672         *s-- = ':';
673         *s-- = mark % 10 + '0';
674         mark /= 10;
675         *s-- = mark % 10 + '0';
676         return 8;
677 }
678
679 static u_char tmpbuf[HISAX_STATUS_BUFSIZE];
680
681 void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt,
682                       va_list args)
683 {
684         /* if head == NULL the fmt contains the full info */
685
686         u_long          flags;
687         int             count, i;
688         u_char          *p;
689         isdn_ctrl       ic;
690         int             len;
691
692         if (!cs) {
693                 printk(KERN_WARNING "HiSax: No CardStatus for message");
694                 return;
695         }
696         spin_lock_irqsave(&cs->statlock, flags);
697         p = tmpbuf;
698         if (head) {
699                 p += jiftime(p, jiffies);
700                 p += sprintf(p, " %s", head);
701                 p += vsprintf(p, fmt, args);
702                 *p++ = '\n';
703                 *p = 0;
704                 len = p - tmpbuf;
705                 p = tmpbuf;
706         } else {
707                 p = fmt;
708                 len = strlen(fmt);
709         }
710         if (len > HISAX_STATUS_BUFSIZE) {
711                 spin_unlock_irqrestore(&cs->statlock, flags);
712                 printk(KERN_WARNING "HiSax: status overflow %d/%d\n",
713                        len, HISAX_STATUS_BUFSIZE);
714                 return;
715         }
716         count = len;
717         i = cs->status_end - cs->status_write + 1;
718         if (i >= len)
719                 i = len;
720         len -= i;
721         memcpy(cs->status_write, p, i);
722         cs->status_write += i;
723         if (cs->status_write > cs->status_end)
724                 cs->status_write = cs->status_buf;
725         p += i;
726         if (len) {
727                 memcpy(cs->status_write, p, len);
728                 cs->status_write += len;
729         }
730 #ifdef KERNELSTACK_DEBUG
731         i = (ulong) & len - current->kernel_stack_page;
732         sprintf(tmpbuf, "kstack %s %lx use %ld\n", current->comm,
733                 current->kernel_stack_page, i);
734         len = strlen(tmpbuf);
735         for (p = tmpbuf, i = len; i > 0; i--, p++) {
736                 *cs->status_write++ = *p;
737                 if (cs->status_write > cs->status_end)
738                         cs->status_write = cs->status_buf;
739                 count++;
740         }
741 #endif
742         spin_unlock_irqrestore(&cs->statlock, flags);
743         if (count) {
744                 ic.command = ISDN_STAT_STAVAIL;
745                 ic.driver = cs->myid;
746                 ic.arg = count;
747                 cs->iif.statcallb(&ic);
748         }
749 }
750
751 void HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...)
752 {
753         va_list args;
754
755         va_start(args, fmt);
756         VHiSax_putstatus(cs, head, fmt, args);
757         va_end(args);
758 }
759
760 int ll_run(struct IsdnCardState *cs, int addfeatures)
761 {
762         isdn_ctrl ic;
763
764         ic.driver = cs->myid;
765         ic.command = ISDN_STAT_RUN;
766         cs->iif.features |= addfeatures;
767         cs->iif.statcallb(&ic);
768         return 0;
769 }
770
771 static void ll_stop(struct IsdnCardState *cs)
772 {
773         isdn_ctrl ic;
774
775         ic.command = ISDN_STAT_STOP;
776         ic.driver = cs->myid;
777         cs->iif.statcallb(&ic);
778         //      CallcFreeChan(cs);
779 }
780
781 static void ll_unload(struct IsdnCardState *cs)
782 {
783         isdn_ctrl ic;
784
785         ic.command = ISDN_STAT_UNLOAD;
786         ic.driver = cs->myid;
787         cs->iif.statcallb(&ic);
788         kfree(cs->status_buf);
789         cs->status_read = NULL;
790         cs->status_write = NULL;
791         cs->status_end = NULL;
792         kfree(cs->dlog);
793         cs->dlog = NULL;
794 }
795
796 static void closecard(int cardnr)
797 {
798         struct IsdnCardState *csta = cards[cardnr].cs;
799
800         if (csta->bcs->BC_Close != NULL) {
801                 csta->bcs->BC_Close(csta->bcs + 1);
802                 csta->bcs->BC_Close(csta->bcs);
803         }
804
805         skb_queue_purge(&csta->rq);
806         skb_queue_purge(&csta->sq);
807         kfree(csta->rcvbuf);
808         csta->rcvbuf = NULL;
809         if (csta->tx_skb) {
810                 dev_kfree_skb(csta->tx_skb);
811                 csta->tx_skb = NULL;
812         }
813         if (csta->DC_Close != NULL) {
814                 csta->DC_Close(csta);
815         }
816         if (csta->cardmsg)
817                 csta->cardmsg(csta, CARD_RELEASE, NULL);
818         if (csta->dbusytimer.function != NULL) // FIXME?
819                 del_timer(&csta->dbusytimer);
820         ll_unload(csta);
821 }
822
823 static int init_card(struct IsdnCardState *cs)
824 {
825         int     irq_cnt, cnt = 3, ret;
826
827         if (!cs->irq) {
828                 ret = cs->cardmsg(cs, CARD_INIT, NULL);
829                 return(ret);
830         }
831         irq_cnt = kstat_irqs(cs->irq);
832         printk(KERN_INFO "%s: IRQ %d count %d\n", CardType[cs->typ],
833                cs->irq, irq_cnt);
834         if (request_irq(cs->irq, cs->irq_func, cs->irq_flags, "HiSax", cs)) {
835                 printk(KERN_WARNING "HiSax: couldn't get interrupt %d\n",
836                        cs->irq);
837                 return 1;
838         }
839         while (cnt) {
840                 cs->cardmsg(cs, CARD_INIT, NULL);
841                 /* Timeout 10ms */
842                 msleep(10);
843                 printk(KERN_INFO "%s: IRQ %d count %d\n",
844                        CardType[cs->typ], cs->irq, kstat_irqs(cs->irq));
845                 if (kstat_irqs(cs->irq) == irq_cnt) {
846                         printk(KERN_WARNING
847                                "%s: IRQ(%d) getting no interrupts during init %d\n",
848                                CardType[cs->typ], cs->irq, 4 - cnt);
849                         if (cnt == 1) {
850                                 free_irq(cs->irq, cs);
851                                 return 2;
852                         } else {
853                                 cs->cardmsg(cs, CARD_RESET, NULL);
854                                 cnt--;
855                         }
856                 } else {
857                         cs->cardmsg(cs, CARD_TEST, NULL);
858                         return 0;
859                 }
860         }
861         return 3;
862 }
863
864 static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockowner)
865 {
866         int ret = 0;
867         struct IsdnCard *card = cards + cardnr;
868         struct IsdnCardState *cs;
869
870         cs = kmalloc(sizeof(struct IsdnCardState), GFP_ATOMIC);
871         if (!cs) {
872                 printk(KERN_WARNING
873                        "HiSax: No memory for IsdnCardState(card %d)\n",
874                        cardnr + 1);
875                 goto out;
876         }
877         memset(cs, 0, sizeof(struct IsdnCardState));
878         card->cs = cs;
879         spin_lock_init(&cs->statlock);
880         spin_lock_init(&cs->lock);
881         cs->chanlimit = 2;      /* maximum B-channel number */
882         cs->logecho = 0;        /* No echo logging */
883         cs->cardnr = cardnr;
884         cs->debug = L1_DEB_WARN;
885         cs->HW_Flags = 0;
886         cs->busy_flag = busy_flag;
887         cs->irq_flags = I4L_IRQ_FLAG;
888 #if TEI_PER_CARD
889         if (card->protocol == ISDN_PTYPE_NI1)
890                 test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);
891 #else
892         test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);
893 #endif
894         cs->protocol = card->protocol;
895
896         if (card->typ <= 0 || card->typ > ISDN_CTYPE_COUNT) {
897                 printk(KERN_WARNING
898                        "HiSax: Card Type %d out of range\n", card->typ);
899                 goto outf_cs;
900         }
901         if (!(cs->dlog = kmalloc(MAX_DLOG_SPACE, GFP_ATOMIC))) {
902                 printk(KERN_WARNING
903                        "HiSax: No memory for dlog(card %d)\n", cardnr + 1);
904                 goto outf_cs;
905         }
906         if (!(cs->status_buf = kmalloc(HISAX_STATUS_BUFSIZE, GFP_ATOMIC))) {
907                 printk(KERN_WARNING
908                        "HiSax: No memory for status_buf(card %d)\n",
909                        cardnr + 1);
910                 goto outf_dlog;
911         }
912         cs->stlist = NULL;
913         cs->status_read = cs->status_buf;
914         cs->status_write = cs->status_buf;
915         cs->status_end = cs->status_buf + HISAX_STATUS_BUFSIZE - 1;
916         cs->typ = card->typ;
917 #ifdef MODULE
918         cs->iif.owner = lockowner;
919 #endif
920         strcpy(cs->iif.id, id);
921         cs->iif.channels = 2;
922         cs->iif.maxbufsize = MAX_DATA_SIZE;
923         cs->iif.hl_hdrlen = MAX_HEADER_LEN;
924         cs->iif.features =
925                 ISDN_FEATURE_L2_X75I |
926                 ISDN_FEATURE_L2_HDLC |
927                 ISDN_FEATURE_L2_HDLC_56K |
928                 ISDN_FEATURE_L2_TRANS |
929                 ISDN_FEATURE_L3_TRANS |
930 #ifdef  CONFIG_HISAX_1TR6
931                 ISDN_FEATURE_P_1TR6 |
932 #endif
933 #ifdef  CONFIG_HISAX_EURO
934                 ISDN_FEATURE_P_EURO |
935 #endif
936 #ifdef  CONFIG_HISAX_NI1
937                 ISDN_FEATURE_P_NI1 |
938 #endif
939                 0;
940
941         cs->iif.command = HiSax_command;
942         cs->iif.writecmd = NULL;
943         cs->iif.writebuf_skb = HiSax_writebuf_skb;
944         cs->iif.readstat = HiSax_readstatus;
945         register_isdn(&cs->iif);
946         cs->myid = cs->iif.channels;
947         printk(KERN_INFO
948                "HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr + 1,
949                (card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" :
950                (card->protocol == ISDN_PTYPE_EURO) ? "EDSS1" :
951                (card->protocol == ISDN_PTYPE_LEASED) ? "LEASED" :
952                (card->protocol == ISDN_PTYPE_NI1) ? "NI1" :
953                "NONE", cs->iif.id, cs->myid);
954         switch (card->typ) {
955 #if CARD_TELES0
956         case ISDN_CTYPE_16_0:
957         case ISDN_CTYPE_8_0:
958                 ret = setup_teles0(card);
959                 break;
960 #endif
961 #if CARD_TELES3
962         case ISDN_CTYPE_16_3:
963         case ISDN_CTYPE_PNP:
964         case ISDN_CTYPE_TELESPCMCIA:
965         case ISDN_CTYPE_COMPAQ_ISA:
966                 ret = setup_teles3(card);
967                 break;
968 #endif
969 #if CARD_S0BOX
970         case ISDN_CTYPE_S0BOX:
971                 ret = setup_s0box(card);
972                 break;
973 #endif
974 #if CARD_TELESPCI
975         case ISDN_CTYPE_TELESPCI:
976                 ret = setup_telespci(card);
977                 break;
978 #endif
979 #if CARD_AVM_A1
980         case ISDN_CTYPE_A1:
981                 ret = setup_avm_a1(card);
982                 break;
983 #endif
984 #if CARD_AVM_A1_PCMCIA
985         case ISDN_CTYPE_A1_PCMCIA:
986                 ret = setup_avm_a1_pcmcia(card);
987                 break;
988 #endif
989 #if CARD_FRITZPCI
990         case ISDN_CTYPE_FRITZPCI:
991                 ret = setup_avm_pcipnp(card);
992                 break;
993 #endif
994 #if CARD_ELSA
995         case ISDN_CTYPE_ELSA:
996         case ISDN_CTYPE_ELSA_PNP:
997         case ISDN_CTYPE_ELSA_PCMCIA:
998         case ISDN_CTYPE_ELSA_PCI:
999                 ret = setup_elsa(card);
1000                 break;
1001 #endif
1002 #if CARD_IX1MICROR2
1003         case ISDN_CTYPE_IX1MICROR2:
1004                 ret = setup_ix1micro(card);
1005                 break;
1006 #endif
1007 #if CARD_DIEHLDIVA
1008         case ISDN_CTYPE_DIEHLDIVA:
1009                 ret = setup_diva(card);
1010                 break;
1011 #endif
1012 #if CARD_ASUSCOM
1013         case ISDN_CTYPE_ASUSCOM:
1014                 ret = setup_asuscom(card);
1015                 break;
1016 #endif
1017 #if CARD_TELEINT
1018         case ISDN_CTYPE_TELEINT:
1019                 ret = setup_TeleInt(card);
1020                 break;
1021 #endif
1022 #if CARD_SEDLBAUER
1023         case ISDN_CTYPE_SEDLBAUER:
1024         case ISDN_CTYPE_SEDLBAUER_PCMCIA:
1025         case ISDN_CTYPE_SEDLBAUER_FAX:
1026                 ret = setup_sedlbauer(card);
1027                 break;
1028 #endif
1029 #if CARD_SPORTSTER
1030         case ISDN_CTYPE_SPORTSTER:
1031                 ret = setup_sportster(card);
1032                 break;
1033 #endif
1034 #if CARD_MIC
1035         case ISDN_CTYPE_MIC:
1036                 ret = setup_mic(card);
1037                 break;
1038 #endif
1039 #if CARD_NETJET_S
1040         case ISDN_CTYPE_NETJET_S:
1041                 ret = setup_netjet_s(card);
1042                 break;
1043 #endif
1044 #if CARD_HFCS
1045         case ISDN_CTYPE_TELES3C:
1046         case ISDN_CTYPE_ACERP10:
1047                 ret = setup_hfcs(card);
1048                 break;
1049 #endif
1050 #if CARD_HFC_PCI
1051         case ISDN_CTYPE_HFC_PCI:
1052                 ret = setup_hfcpci(card);
1053                 break;
1054 #endif
1055 #if CARD_HFC_SX
1056         case ISDN_CTYPE_HFC_SX:
1057                 ret = setup_hfcsx(card);
1058                 break;
1059 #endif
1060 #if CARD_NICCY
1061         case ISDN_CTYPE_NICCY:
1062                 ret = setup_niccy(card);
1063                 break;
1064 #endif
1065 #if CARD_AMD7930
1066         case ISDN_CTYPE_AMD7930:
1067                 ret = setup_amd7930(card);
1068                 break;
1069 #endif
1070 #if CARD_ISURF
1071         case ISDN_CTYPE_ISURF:
1072                 ret = setup_isurf(card);
1073                 break;
1074 #endif
1075 #if CARD_HSTSAPHIR
1076         case ISDN_CTYPE_HSTSAPHIR:
1077                 ret = setup_saphir(card);
1078                 break;
1079 #endif
1080 #if CARD_TESTEMU
1081         case ISDN_CTYPE_TESTEMU:
1082                 ret = setup_testemu(card);
1083                 break;
1084 #endif
1085 #if     CARD_BKM_A4T
1086         case ISDN_CTYPE_BKM_A4T:
1087                 ret = setup_bkm_a4t(card);
1088                 break;
1089 #endif
1090 #if     CARD_SCT_QUADRO
1091         case ISDN_CTYPE_SCT_QUADRO:
1092                 ret = setup_sct_quadro(card);
1093                 break;
1094 #endif
1095 #if CARD_GAZEL
1096         case ISDN_CTYPE_GAZEL:
1097                 ret = setup_gazel(card);
1098                 break;
1099 #endif
1100 #if CARD_W6692
1101         case ISDN_CTYPE_W6692:
1102                 ret = setup_w6692(card);
1103                 break;
1104 #endif
1105 #if CARD_NETJET_U
1106         case ISDN_CTYPE_NETJET_U:
1107                 ret = setup_netjet_u(card);
1108                 break;
1109 #endif
1110 #if CARD_FN_ENTERNOW_PCI
1111         case ISDN_CTYPE_ENTERNOW:
1112                 ret = setup_enternow_pci(card);
1113                 break;
1114 #endif
1115         case ISDN_CTYPE_DYNAMIC:
1116                 ret = 2;
1117                 break;
1118         default:
1119                 printk(KERN_WARNING
1120                        "HiSax: Support for %s Card not selected\n",
1121                        CardType[card->typ]);
1122                 ll_unload(cs);
1123                 goto outf_cs;
1124         }
1125         if (!ret) {
1126                 ll_unload(cs);
1127                 goto outf_cs;
1128         }
1129         if (!(cs->rcvbuf = kmalloc(MAX_DFRAME_LEN_L1, GFP_ATOMIC))) {
1130                 printk(KERN_WARNING "HiSax: No memory for isac rcvbuf\n");
1131                 ll_unload(cs);
1132                 goto outf_cs;
1133         }
1134         cs->rcvidx = 0;
1135         cs->tx_skb = NULL;
1136         cs->tx_cnt = 0;
1137         cs->event = 0;
1138         cs->tqueue.data = cs;
1139
1140         skb_queue_head_init(&cs->rq);
1141         skb_queue_head_init(&cs->sq);
1142
1143         init_bcstate(cs, 0);
1144         init_bcstate(cs, 1);
1145
1146         /* init_card only handles interrupts which are not */
1147         /* used here for the loadable driver */
1148         switch (card->typ) {
1149                 case ISDN_CTYPE_DYNAMIC:
1150                         ret = 0;
1151                         break;
1152                 default:
1153                         ret = init_card(cs);
1154                         break;
1155         }
1156         if (ret) {
1157                 closecard(cardnr);
1158                 ret = 0;
1159                 goto outf_cs;
1160         }
1161         init_tei(cs, cs->protocol);
1162         ret = CallcNewChan(cs);
1163         if (ret) {
1164                 closecard(cardnr);
1165                 ret = 0;
1166                 goto outf_cs;
1167         }
1168         /* ISAR needs firmware download first */
1169         if (!test_bit(HW_ISAR, &cs->HW_Flags))
1170                 ll_run(cs, 0);
1171
1172         ret = 1;
1173         goto out;
1174
1175  outf_dlog:
1176         kfree(cs->dlog);
1177  outf_cs:
1178         kfree(cs);
1179         card->cs = NULL;
1180  out:
1181         return ret;
1182 }
1183
1184 static void HiSax_shiftcards(int idx)
1185 {
1186         int i;
1187
1188         for (i = idx; i < (HISAX_MAX_CARDS - 1); i++)
1189                 memcpy(&cards[i], &cards[i + 1], sizeof(cards[i]));
1190 }
1191
1192 static int HiSax_inithardware(int *busy_flag)
1193 {
1194         int foundcards = 0;
1195         int i = 0;
1196         int t = ',';
1197         int flg = 0;
1198         char *id;
1199         char *next_id = HiSax_id;
1200         char ids[20];
1201
1202         if (strchr(HiSax_id, ','))
1203                 t = ',';
1204         else if (strchr(HiSax_id, '%'))
1205                 t = '%';
1206
1207         while (i < nrcards) {
1208                 if (cards[i].typ < 1)
1209                         break;
1210                 id = next_id;
1211                 if ((next_id = strchr(id, t))) {
1212                         *next_id++ = 0;
1213                         strcpy(ids, id);
1214                         flg = i + 1;
1215                 } else {
1216                         next_id = id;
1217                         if (flg >= i)
1218                                 strcpy(ids, id);
1219                         else
1220                                 sprintf(ids, "%s%d", id, i);
1221                 }
1222                 if (checkcard(i, ids, busy_flag, THIS_MODULE)) {
1223                         foundcards++;
1224                         i++;
1225                 } else {
1226                         /* make sure we don't oops the module */
1227                         if (cards[i].typ > 0 && cards[i].typ <= ISDN_CTYPE_COUNT) {
1228                                 printk(KERN_WARNING
1229                                         "HiSax: Card %s not installed !\n",
1230                                         CardType[cards[i].typ]);
1231                         }
1232                         HiSax_shiftcards(i);
1233                         nrcards--;
1234                 }
1235         }
1236         return foundcards;
1237 }
1238
1239 void HiSax_closecard(int cardnr)
1240 {
1241         int i, last = nrcards - 1;
1242
1243         if (cardnr > last || cardnr < 0)
1244                 return;
1245         if (cards[cardnr].cs) {
1246                 ll_stop(cards[cardnr].cs);
1247                 release_tei(cards[cardnr].cs);
1248                 CallcFreeChan(cards[cardnr].cs);
1249
1250                 closecard(cardnr);
1251                 if (cards[cardnr].cs->irq)
1252                         free_irq(cards[cardnr].cs->irq, cards[cardnr].cs);
1253                 kfree((void *) cards[cardnr].cs);
1254                 cards[cardnr].cs = NULL;
1255         }
1256         i = cardnr;
1257         while (i <= last) {
1258                 cards[i] = cards[i + 1];
1259                 i++;
1260         }
1261         nrcards--;
1262 }
1263
1264 void HiSax_reportcard(int cardnr, int sel)
1265 {
1266         struct IsdnCardState *cs = cards[cardnr].cs;
1267
1268         printk(KERN_DEBUG "HiSax: reportcard No %d\n", cardnr + 1);
1269         printk(KERN_DEBUG "HiSax: Type %s\n", CardType[cs->typ]);
1270         printk(KERN_DEBUG "HiSax: debuglevel %x\n", cs->debug);
1271         printk(KERN_DEBUG "HiSax: HiSax_reportcard address 0x%lX\n",
1272                (ulong) & HiSax_reportcard);
1273         printk(KERN_DEBUG "HiSax: cs 0x%lX\n", (ulong) cs);
1274         printk(KERN_DEBUG "HiSax: HW_Flags %lx bc0 flg %lx bc1 flg %lx\n",
1275                cs->HW_Flags, cs->bcs[0].Flag, cs->bcs[1].Flag);
1276         printk(KERN_DEBUG "HiSax: bcs 0 mode %d ch%d\n",
1277                cs->bcs[0].mode, cs->bcs[0].channel);
1278         printk(KERN_DEBUG "HiSax: bcs 1 mode %d ch%d\n",
1279                cs->bcs[1].mode, cs->bcs[1].channel);
1280 #ifdef ERROR_STATISTIC
1281         printk(KERN_DEBUG "HiSax: dc errors(rx,crc,tx) %d,%d,%d\n",
1282                cs->err_rx, cs->err_crc, cs->err_tx);
1283         printk(KERN_DEBUG
1284                "HiSax: bc0 errors(inv,rdo,crc,tx) %d,%d,%d,%d\n",
1285                cs->bcs[0].err_inv, cs->bcs[0].err_rdo, cs->bcs[0].err_crc,
1286                cs->bcs[0].err_tx);
1287         printk(KERN_DEBUG
1288                "HiSax: bc1 errors(inv,rdo,crc,tx) %d,%d,%d,%d\n",
1289                cs->bcs[1].err_inv, cs->bcs[1].err_rdo, cs->bcs[1].err_crc,
1290                cs->bcs[1].err_tx);
1291         if (sel == 99) {
1292                 cs->err_rx  = 0;
1293                 cs->err_crc = 0;
1294                 cs->err_tx  = 0;
1295                 cs->bcs[0].err_inv = 0;
1296                 cs->bcs[0].err_rdo = 0;
1297                 cs->bcs[0].err_crc = 0;
1298                 cs->bcs[0].err_tx  = 0;
1299                 cs->bcs[1].err_inv = 0;
1300                 cs->bcs[1].err_rdo = 0;
1301                 cs->bcs[1].err_crc = 0;
1302                 cs->bcs[1].err_tx  = 0;
1303         }
1304 #endif
1305 }
1306
1307 static int __init HiSax_init(void)
1308 {
1309         int i, retval;
1310 #ifdef MODULE
1311         int j;
1312         int nzproto = 0;
1313 #endif
1314
1315         HiSaxVersion();
1316         retval = CallcNew();
1317         if (retval)
1318                 goto out;
1319         retval = Isdnl3New();
1320         if (retval)
1321                 goto out_callc;
1322         retval = Isdnl2New();
1323         if (retval)
1324                 goto out_isdnl3;
1325         retval = TeiNew();
1326         if (retval)
1327                 goto out_isdnl2;
1328         retval = Isdnl1New();
1329         if (retval)
1330                 goto out_tei;
1331
1332 #ifdef MODULE
1333         if (!type[0]) {
1334                 /* We 'll register drivers later, but init basic functions */
1335                 for (i = 0; i < HISAX_MAX_CARDS; i++)
1336                         cards[i].typ = 0;
1337                 return 0;
1338         }
1339 #ifdef CONFIG_HISAX_ELSA
1340         if (type[0] == ISDN_CTYPE_ELSA_PCMCIA) {
1341                 /* we have exported  and return in this case */
1342                 return 0;
1343         }
1344 #endif
1345 #ifdef CONFIG_HISAX_SEDLBAUER
1346         if (type[0] == ISDN_CTYPE_SEDLBAUER_PCMCIA) {
1347                 /* we have to export  and return in this case */
1348                 return 0;
1349         }
1350 #endif
1351 #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
1352         if (type[0] == ISDN_CTYPE_A1_PCMCIA) {
1353                 /* we have to export  and return in this case */
1354                 return 0;
1355         }
1356 #endif
1357 #ifdef CONFIG_HISAX_HFC_SX
1358         if (type[0] == ISDN_CTYPE_HFC_SP_PCMCIA) {
1359                 /* we have to export  and return in this case */
1360                 return 0;
1361         }
1362 #endif
1363 #endif
1364         nrcards = 0;
1365 #ifdef MODULE
1366         if (id)                 /* If id= string used */
1367                 HiSax_id = id;
1368         for (i = j = 0; j < HISAX_MAX_CARDS; i++) {
1369                 cards[j].typ = type[i];
1370                 if (protocol[i]) {
1371                         cards[j].protocol = protocol[i];
1372                         nzproto++;
1373                 } else {
1374                         cards[j].protocol = DEFAULT_PROTO;
1375                 }
1376                 switch (type[i]) {
1377                 case ISDN_CTYPE_16_0:
1378                         cards[j].para[0] = irq[i];
1379                         cards[j].para[1] = mem[i];
1380                         cards[j].para[2] = io[i];
1381                         break;
1382
1383                 case ISDN_CTYPE_8_0:
1384                         cards[j].para[0] = irq[i];
1385                         cards[j].para[1] = mem[i];
1386                         break;
1387
1388 #ifdef IO0_IO1
1389                 case ISDN_CTYPE_PNP:
1390                 case ISDN_CTYPE_NICCY:
1391                         cards[j].para[0] = irq[i];
1392                         cards[j].para[1] = io0[i];
1393                         cards[j].para[2] = io1[i];
1394                         break;
1395                 case ISDN_CTYPE_COMPAQ_ISA:
1396                         cards[j].para[0] = irq[i];
1397                         cards[j].para[1] = io0[i];
1398                         cards[j].para[2] = io1[i];
1399                         cards[j].para[3] = io[i];
1400                         break;
1401 #endif
1402                 case ISDN_CTYPE_ELSA:
1403                 case ISDN_CTYPE_HFC_PCI:
1404                         cards[j].para[0] = io[i];
1405                         break;
1406                 case ISDN_CTYPE_16_3:
1407                 case ISDN_CTYPE_TELESPCMCIA:
1408                 case ISDN_CTYPE_A1:
1409                 case ISDN_CTYPE_A1_PCMCIA:
1410                 case ISDN_CTYPE_ELSA_PNP:
1411                 case ISDN_CTYPE_ELSA_PCMCIA:
1412                 case ISDN_CTYPE_IX1MICROR2:
1413                 case ISDN_CTYPE_DIEHLDIVA:
1414                 case ISDN_CTYPE_ASUSCOM:
1415                 case ISDN_CTYPE_TELEINT:
1416                 case ISDN_CTYPE_SEDLBAUER:
1417                 case ISDN_CTYPE_SEDLBAUER_PCMCIA:
1418                 case ISDN_CTYPE_SEDLBAUER_FAX:
1419                 case ISDN_CTYPE_SPORTSTER:
1420                 case ISDN_CTYPE_MIC:
1421                 case ISDN_CTYPE_TELES3C:
1422                 case ISDN_CTYPE_ACERP10:
1423                 case ISDN_CTYPE_S0BOX:
1424                 case ISDN_CTYPE_FRITZPCI:
1425                 case ISDN_CTYPE_HSTSAPHIR:
1426                 case ISDN_CTYPE_GAZEL:
1427                 case ISDN_CTYPE_HFC_SX:
1428                 case ISDN_CTYPE_HFC_SP_PCMCIA:
1429                         cards[j].para[0] = irq[i];
1430                         cards[j].para[1] = io[i];
1431                         break;
1432                 case ISDN_CTYPE_ISURF:
1433                         cards[j].para[0] = irq[i];
1434                         cards[j].para[1] = io[i];
1435                         cards[j].para[2] = mem[i];
1436                         break;
1437                 case ISDN_CTYPE_ELSA_PCI:
1438                 case ISDN_CTYPE_NETJET_S:
1439                 case ISDN_CTYPE_AMD7930:
1440                 case ISDN_CTYPE_TELESPCI:
1441                 case ISDN_CTYPE_W6692:
1442                 case ISDN_CTYPE_NETJET_U:
1443                         break;
1444                 case ISDN_CTYPE_BKM_A4T:
1445                         break;
1446                 case ISDN_CTYPE_SCT_QUADRO:
1447                         if (irq[i]) {
1448                                 cards[j].para[0] = irq[i];
1449                         } else {
1450                                 /* QUADRO is a 4 BRI card */
1451                                 cards[j++].para[0] = 1;
1452                                 /* we need to check if further cards can be added */
1453                                 if (j < HISAX_MAX_CARDS) {
1454                                         cards[j].typ = ISDN_CTYPE_SCT_QUADRO;
1455                                         cards[j].protocol = protocol[i];
1456                                         cards[j++].para[0] = 2;
1457                                 }
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] = 3;
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] = 4;
1467                                 }
1468                         }
1469                         break;
1470                 }
1471                 j++;
1472         }
1473         if (!nzproto) {
1474                 printk(KERN_WARNING
1475                        "HiSax: Warning - no protocol specified\n");
1476                 printk(KERN_WARNING "HiSax: using protocol %s\n",
1477                        DEFAULT_PROTO_NAME);
1478         }
1479 #endif
1480         if (!HiSax_id)
1481                 HiSax_id = HiSaxID;
1482         if (!HiSaxID[0])
1483                 strcpy(HiSaxID, "HiSax");
1484         for (i = 0; i < HISAX_MAX_CARDS; i++)
1485                 if (cards[i].typ > 0)
1486                         nrcards++;
1487         printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
1488                nrcards, (nrcards > 1) ? "s" : "");
1489
1490         /* Install only, if at least one card found */
1491         if (!HiSax_inithardware(NULL))
1492                 return -ENODEV;
1493         return 0;
1494
1495  out_tei:
1496         TeiFree();
1497  out_isdnl2:
1498         Isdnl2Free();
1499  out_isdnl3:
1500         Isdnl3Free();
1501  out_callc:
1502         CallcFree();
1503  out:
1504         return retval;
1505 }
1506
1507 static void __exit HiSax_exit(void)
1508 {
1509         int cardnr = nrcards - 1;
1510
1511         while (cardnr >= 0)
1512                 HiSax_closecard(cardnr--);
1513         Isdnl1Free();
1514         TeiFree();
1515         Isdnl2Free();
1516         Isdnl3Free();
1517         CallcFree();
1518         printk(KERN_INFO "HiSax module removed\n");
1519 }
1520
1521 int hisax_init_pcmcia(void *pcm_iob, int *busy_flag, struct IsdnCard *card)
1522 {
1523         u_char ids[16];
1524         int ret = -1;
1525
1526         cards[nrcards] = *card;
1527         if (nrcards)
1528                 sprintf(ids, "HiSax%d", nrcards);
1529         else
1530                 sprintf(ids, "HiSax");
1531         if (!checkcard(nrcards, ids, busy_flag, THIS_MODULE))
1532                 goto error;
1533
1534         ret = nrcards;
1535         nrcards++;
1536 error:
1537         return ret;
1538 }
1539
1540 EXPORT_SYMBOL(hisax_init_pcmcia);
1541 EXPORT_SYMBOL(HiSax_closecard);
1542
1543 #include "hisax_if.h"
1544
1545 EXPORT_SYMBOL(hisax_register);
1546 EXPORT_SYMBOL(hisax_unregister);
1547
1548 static void hisax_d_l1l2(struct hisax_if *ifc, int pr, void *arg);
1549 static void hisax_b_l1l2(struct hisax_if *ifc, int pr, void *arg);
1550 static void hisax_d_l2l1(struct PStack *st, int pr, void *arg);
1551 static void hisax_b_l2l1(struct PStack *st, int pr, void *arg);
1552 static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg);
1553 static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs);
1554 static void hisax_bc_close(struct BCState *bcs);
1555 static void hisax_bh(struct IsdnCardState *cs);
1556 static void EChannel_proc_rcv(struct hisax_d_if *d_if);
1557
1558 int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
1559                    char *name, int protocol)
1560 {
1561         int i, retval;
1562         char id[20];
1563         struct IsdnCardState *cs;
1564
1565         for (i = 0; i < HISAX_MAX_CARDS; i++) {
1566                 if (!cards[i].typ)
1567                         break;
1568         }
1569
1570         if (i >= HISAX_MAX_CARDS)
1571                 return -EBUSY;
1572
1573         cards[i].typ = ISDN_CTYPE_DYNAMIC;
1574         cards[i].protocol = protocol;
1575         sprintf(id, "%s%d", name, i);
1576         nrcards++;
1577         retval = checkcard(i, id, NULL, hisax_d_if->owner);
1578         if (retval == 0) { // yuck
1579                 cards[i].typ = 0;
1580                 nrcards--;
1581                 return retval;
1582         }
1583         cs = cards[i].cs;
1584         hisax_d_if->cs = cs;
1585         cs->hw.hisax_d_if = hisax_d_if;
1586         cs->cardmsg = hisax_cardmsg;
1587         INIT_WORK(&cs->tqueue, (void *)(void *)hisax_bh, cs);
1588         cs->channel[0].d_st->l2.l2l1 = hisax_d_l2l1;
1589         for (i = 0; i < 2; i++) {
1590                 cs->bcs[i].BC_SetStack = hisax_bc_setstack;
1591                 cs->bcs[i].BC_Close = hisax_bc_close;
1592
1593                 b_if[i]->ifc.l1l2 = hisax_b_l1l2;
1594
1595                 hisax_d_if->b_if[i] = b_if[i];
1596         }
1597         hisax_d_if->ifc.l1l2 = hisax_d_l1l2;
1598         skb_queue_head_init(&hisax_d_if->erq);
1599         clear_bit(0, &hisax_d_if->ph_state);
1600         
1601         return 0;
1602 }
1603
1604 void hisax_unregister(struct hisax_d_if *hisax_d_if)
1605 {
1606         cards[hisax_d_if->cs->cardnr].typ = 0;
1607         HiSax_closecard(hisax_d_if->cs->cardnr);
1608         skb_queue_purge(&hisax_d_if->erq);
1609 }
1610
1611 #include "isdnl1.h"
1612
1613 static void hisax_sched_event(struct IsdnCardState *cs, int event)
1614 {
1615         test_and_set_bit(event, &cs->event);
1616         schedule_work(&cs->tqueue);
1617 }
1618
1619 static void hisax_bh(struct IsdnCardState *cs)
1620 {
1621         struct PStack *st;
1622         int pr;
1623
1624         if (test_and_clear_bit(D_RCVBUFREADY, &cs->event))
1625                 DChannel_proc_rcv(cs);
1626         if (test_and_clear_bit(E_RCVBUFREADY, &cs->event))
1627                 EChannel_proc_rcv(cs->hw.hisax_d_if);
1628         if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) {
1629                 if (test_bit(0, &cs->hw.hisax_d_if->ph_state))
1630                         pr = PH_ACTIVATE | INDICATION;
1631                 else
1632                         pr = PH_DEACTIVATE | INDICATION;
1633                 for (st = cs->stlist; st; st = st->next)
1634                         st->l1.l1l2(st, pr, NULL);
1635                 
1636         }
1637 }
1638
1639 static void hisax_b_sched_event(struct BCState *bcs, int event)
1640 {
1641         test_and_set_bit(event, &bcs->event);
1642         schedule_work(&bcs->tqueue);
1643 }
1644
1645 static inline void D_L2L1(struct hisax_d_if *d_if, int pr, void *arg)
1646 {
1647         struct hisax_if *ifc = (struct hisax_if *) d_if;
1648         ifc->l2l1(ifc, pr, arg);
1649 }
1650
1651 static inline void B_L2L1(struct hisax_b_if *b_if, int pr, void *arg)
1652 {
1653         struct hisax_if *ifc = (struct hisax_if *) b_if;
1654         ifc->l2l1(ifc, pr, arg);
1655 }
1656
1657 static void hisax_d_l1l2(struct hisax_if *ifc, int pr, void *arg)
1658 {
1659         struct hisax_d_if *d_if = (struct hisax_d_if *) ifc;
1660         struct IsdnCardState *cs = d_if->cs;
1661         struct PStack *st;
1662         struct sk_buff *skb;
1663
1664         switch (pr) {
1665         case PH_ACTIVATE | INDICATION:
1666                 set_bit(0, &d_if->ph_state);
1667                 hisax_sched_event(cs, D_L1STATECHANGE);
1668                 break;
1669         case PH_DEACTIVATE | INDICATION:
1670                 clear_bit(0, &d_if->ph_state);
1671                 hisax_sched_event(cs, D_L1STATECHANGE);
1672                 break;
1673         case PH_DATA | INDICATION:
1674                 skb_queue_tail(&cs->rq, arg);
1675                 hisax_sched_event(cs, D_RCVBUFREADY);
1676                 break;
1677         case PH_DATA | CONFIRM:
1678                 skb = skb_dequeue(&cs->sq);
1679                 if (skb) {
1680                         D_L2L1(d_if, PH_DATA | REQUEST, skb);
1681                         break;
1682                 }
1683                 clear_bit(FLG_L1_DBUSY, &cs->HW_Flags);
1684                 for (st = cs->stlist; st; st = st->next) {
1685                         if (test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags)) {
1686                                 st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
1687                                 break;
1688                         }
1689                 }
1690                 break;
1691         case PH_DATA_E | INDICATION:
1692                 skb_queue_tail(&d_if->erq, arg);
1693                 hisax_sched_event(cs, E_RCVBUFREADY);
1694                 break;
1695         default:
1696                 printk("pr %#x\n", pr);
1697                 break;
1698         }
1699 }
1700
1701 static void hisax_b_l1l2(struct hisax_if *ifc, int pr, void *arg)
1702 {
1703         struct hisax_b_if *b_if = (struct hisax_b_if *) ifc;
1704         struct BCState *bcs = b_if->bcs;
1705         struct PStack *st = bcs->st;
1706         struct sk_buff *skb;
1707
1708         // FIXME use isdnl1?
1709         switch (pr) {
1710         case PH_ACTIVATE | INDICATION:
1711                 st->l1.l1l2(st, pr, NULL);
1712                 break;
1713         case PH_DEACTIVATE | INDICATION:
1714                 st->l1.l1l2(st, pr, NULL);
1715                 clear_bit(BC_FLG_BUSY, &bcs->Flag);
1716                 skb_queue_purge(&bcs->squeue);
1717                 bcs->hw.b_if = NULL;
1718                 break;
1719         case PH_DATA | INDICATION:
1720                 skb_queue_tail(&bcs->rqueue, arg);
1721                 hisax_b_sched_event(bcs, B_RCVBUFREADY);
1722                 break;
1723         case PH_DATA | CONFIRM:
1724                 bcs->tx_cnt -= (long)arg;
1725                 if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag)) {
1726                         u_long  flags;
1727                         spin_lock_irqsave(&bcs->aclock, flags);
1728                         bcs->ackcnt += (long)arg;
1729                         spin_unlock_irqrestore(&bcs->aclock, flags);
1730                         schedule_event(bcs, B_ACKPENDING);
1731                 }
1732                 skb = skb_dequeue(&bcs->squeue);
1733                 if (skb) {
1734                         B_L2L1(b_if, PH_DATA | REQUEST, skb);
1735                         break;
1736                 }
1737                 clear_bit(BC_FLG_BUSY, &bcs->Flag);
1738                 if (test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags)) {
1739                         st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
1740                 }
1741                 break;
1742         default:
1743                 printk("hisax_b_l1l2 pr %#x\n", pr);
1744                 break;
1745         }
1746 }
1747
1748 static void hisax_d_l2l1(struct PStack *st, int pr, void *arg)
1749 {
1750         struct IsdnCardState *cs = st->l1.hardware;
1751         struct hisax_d_if *hisax_d_if = cs->hw.hisax_d_if;
1752         struct sk_buff *skb = arg;
1753
1754         switch (pr) {
1755         case PH_DATA | REQUEST:
1756         case PH_PULL | INDICATION:
1757                 if (cs->debug & DEB_DLOG_HEX)
1758                         LogFrame(cs, skb->data, skb->len);
1759                 if (cs->debug & DEB_DLOG_VERBOSE)
1760                         dlogframe(cs, skb, 0);
1761                 Logl2Frame(cs, skb, "PH_DATA_REQ", 0);
1762                 // FIXME lock?
1763                 if (!test_and_set_bit(FLG_L1_DBUSY, &cs->HW_Flags))
1764                         D_L2L1(hisax_d_if, PH_DATA | REQUEST, skb);
1765                 else
1766                         skb_queue_tail(&cs->sq, skb);
1767                 break;
1768         case PH_PULL | REQUEST:
1769                 if (!test_bit(FLG_L1_DBUSY, &cs->HW_Flags))
1770                         st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
1771                 else
1772                         set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
1773                 break;
1774         default:
1775                 D_L2L1(hisax_d_if, pr, arg);
1776                 break;
1777         }
1778 }
1779
1780 static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg)
1781 {
1782         return 0;
1783 }
1784
1785 static void hisax_b_l2l1(struct PStack *st, int pr, void *arg)
1786 {
1787         struct BCState *bcs = st->l1.bcs;
1788         struct hisax_b_if *b_if = bcs->hw.b_if;
1789
1790         switch (pr) {
1791         case PH_ACTIVATE | REQUEST:
1792                 B_L2L1(b_if, pr, (void *)(unsigned long)st->l1.mode);
1793                 break;
1794         case PH_DATA | REQUEST:
1795         case PH_PULL | INDICATION:
1796                 // FIXME lock?
1797                 if (!test_and_set_bit(BC_FLG_BUSY, &bcs->Flag)) {
1798                         B_L2L1(b_if, PH_DATA | REQUEST, arg);
1799                 } else {
1800                         skb_queue_tail(&bcs->squeue, arg);
1801                 }
1802                 break;
1803         case PH_PULL | REQUEST:
1804                 if (!test_bit(BC_FLG_BUSY, &bcs->Flag))
1805                         st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
1806                 else
1807                         set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
1808                 break;
1809         case PH_DEACTIVATE | REQUEST:
1810                 test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
1811                 skb_queue_purge(&bcs->squeue);
1812         default:
1813                 B_L2L1(b_if, pr, arg);
1814                 break;
1815         }
1816 }
1817
1818 static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs)
1819 {
1820         struct IsdnCardState *cs = st->l1.hardware;
1821         struct hisax_d_if *hisax_d_if = cs->hw.hisax_d_if;
1822
1823         bcs->channel = st->l1.bc;
1824
1825         bcs->hw.b_if = hisax_d_if->b_if[st->l1.bc];
1826         hisax_d_if->b_if[st->l1.bc]->bcs = bcs;
1827
1828         st->l1.bcs = bcs;
1829         st->l2.l2l1 = hisax_b_l2l1;
1830         setstack_manager(st);
1831         bcs->st = st;
1832         setstack_l1_B(st);
1833         skb_queue_head_init(&bcs->rqueue);
1834         skb_queue_head_init(&bcs->squeue);
1835         return 0;
1836 }
1837
1838 static void hisax_bc_close(struct BCState *bcs)
1839 {
1840         struct hisax_b_if *b_if = bcs->hw.b_if;
1841
1842         if (b_if)
1843                 B_L2L1(b_if, PH_DEACTIVATE | REQUEST, NULL);
1844 }
1845
1846 static void EChannel_proc_rcv(struct hisax_d_if *d_if)
1847 {
1848         struct IsdnCardState *cs = d_if->cs;
1849         u_char *ptr;
1850         struct sk_buff *skb;
1851
1852         while ((skb = skb_dequeue(&d_if->erq)) != NULL) {
1853                 if (cs->debug & DEB_DLOG_HEX) {
1854                         ptr = cs->dlog;
1855                         if ((skb->len) < MAX_DLOG_SPACE / 3 - 10) {
1856                                 *ptr++ = 'E';
1857                                 *ptr++ = 'C';
1858                                 *ptr++ = 'H';
1859                                 *ptr++ = 'O';
1860                                 *ptr++ = ':';
1861                                 ptr += QuickHex(ptr, skb->data, skb->len);
1862                                 ptr--;
1863                                 *ptr++ = '\n';
1864                                 *ptr = 0;
1865                                 HiSax_putstatus(cs, NULL, cs->dlog);
1866                         } else
1867                                 HiSax_putstatus(cs, "LogEcho: ",
1868                                                 "warning Frame too big (%d)",
1869                                                 skb->len);
1870                 }
1871                 dev_kfree_skb_any(skb);
1872         }
1873 }
1874
1875 #ifdef CONFIG_PCI
1876 #include <linux/pci.h>
1877
1878 static struct pci_device_id hisax_pci_tbl[] __devinitdata = {
1879 #ifdef CONFIG_HISAX_FRITZPCI
1880         {PCI_VENDOR_ID_AVM,      PCI_DEVICE_ID_AVM_A1,           PCI_ANY_ID, PCI_ANY_ID},
1881 #endif
1882 #ifdef CONFIG_HISAX_DIEHLDIVA
1883         {PCI_VENDOR_ID_EICON,    PCI_DEVICE_ID_EICON_DIVA20,     PCI_ANY_ID, PCI_ANY_ID},
1884         {PCI_VENDOR_ID_EICON,    PCI_DEVICE_ID_EICON_DIVA20_U,   PCI_ANY_ID, PCI_ANY_ID},
1885         {PCI_VENDOR_ID_EICON,    PCI_DEVICE_ID_EICON_DIVA201,    PCI_ANY_ID, PCI_ANY_ID},
1886 //#########################################################################################     
1887         {PCI_VENDOR_ID_EICON,    PCI_DEVICE_ID_EICON_DIVA202,    PCI_ANY_ID, PCI_ANY_ID},
1888 //#########################################################################################     
1889 #endif
1890 #ifdef CONFIG_HISAX_ELSA
1891         {PCI_VENDOR_ID_ELSA,     PCI_DEVICE_ID_ELSA_MICROLINK,   PCI_ANY_ID, PCI_ANY_ID},
1892         {PCI_VENDOR_ID_ELSA,     PCI_DEVICE_ID_ELSA_QS3000,      PCI_ANY_ID, PCI_ANY_ID},
1893 #endif
1894 #ifdef CONFIG_HISAX_GAZEL
1895         {PCI_VENDOR_ID_PLX,      PCI_DEVICE_ID_PLX_R685,         PCI_ANY_ID, PCI_ANY_ID},
1896         {PCI_VENDOR_ID_PLX,      PCI_DEVICE_ID_PLX_R753,         PCI_ANY_ID, PCI_ANY_ID},
1897         {PCI_VENDOR_ID_PLX,      PCI_DEVICE_ID_PLX_DJINN_ITOO,   PCI_ANY_ID, PCI_ANY_ID},
1898         {PCI_VENDOR_ID_PLX,      PCI_DEVICE_ID_PLX_OLITEC,       PCI_ANY_ID, PCI_ANY_ID},
1899 #endif
1900 #ifdef CONFIG_HISAX_QUADRO
1901         {PCI_VENDOR_ID_PLX,      PCI_DEVICE_ID_PLX_9050,         PCI_ANY_ID, PCI_ANY_ID},
1902 #endif
1903 #ifdef CONFIG_HISAX_NICCY
1904         {PCI_VENDOR_ID_SATSAGEM, PCI_DEVICE_ID_SATSAGEM_NICCY,   PCI_ANY_ID,PCI_ANY_ID},
1905 #endif
1906 #ifdef CONFIG_HISAX_SEDLBAUER
1907         {PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_100,     PCI_ANY_ID,PCI_ANY_ID},
1908 #endif
1909 #if defined(CONFIG_HISAX_NETJET) || defined(CONFIG_HISAX_NETJET_U)
1910         {PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_300,     PCI_ANY_ID,PCI_ANY_ID},
1911 #endif
1912 #if defined(CONFIG_HISAX_TELESPCI) || defined(CONFIG_HISAX_SCT_QUADRO)
1913         {PCI_VENDOR_ID_ZORAN,    PCI_DEVICE_ID_ZORAN_36120,      PCI_ANY_ID,PCI_ANY_ID},
1914 #endif
1915 #ifdef CONFIG_HISAX_W6692
1916         {PCI_VENDOR_ID_DYNALINK, PCI_DEVICE_ID_DYNALINK_IS64PH,  PCI_ANY_ID,PCI_ANY_ID},
1917         {PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_6692,    PCI_ANY_ID,PCI_ANY_ID},
1918 #endif
1919 #ifdef CONFIG_HISAX_HFC_PCI
1920         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_2BD0,         PCI_ANY_ID, PCI_ANY_ID},
1921         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B000,         PCI_ANY_ID, PCI_ANY_ID},
1922         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B006,         PCI_ANY_ID, PCI_ANY_ID},
1923         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B007,         PCI_ANY_ID, PCI_ANY_ID},
1924         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B008,         PCI_ANY_ID, PCI_ANY_ID},
1925         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B009,         PCI_ANY_ID, PCI_ANY_ID},
1926         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B00A,         PCI_ANY_ID, PCI_ANY_ID},
1927         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B00B,         PCI_ANY_ID, PCI_ANY_ID},
1928         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B00C,         PCI_ANY_ID, PCI_ANY_ID},
1929         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B100,         PCI_ANY_ID, PCI_ANY_ID},
1930         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B700,         PCI_ANY_ID, PCI_ANY_ID},
1931         {PCI_VENDOR_ID_CCD,      PCI_DEVICE_ID_CCD_B701,         PCI_ANY_ID, PCI_ANY_ID},
1932         {PCI_VENDOR_ID_ABOCOM,   PCI_DEVICE_ID_ABOCOM_2BD1,      PCI_ANY_ID, PCI_ANY_ID},
1933         {PCI_VENDOR_ID_ASUSTEK,  PCI_DEVICE_ID_ASUSTEK_0675,     PCI_ANY_ID, PCI_ANY_ID},
1934         {PCI_VENDOR_ID_BERKOM,   PCI_DEVICE_ID_BERKOM_T_CONCEPT, PCI_ANY_ID, PCI_ANY_ID},
1935         {PCI_VENDOR_ID_BERKOM,   PCI_DEVICE_ID_BERKOM_A1T,       PCI_ANY_ID, PCI_ANY_ID},
1936         {PCI_VENDOR_ID_ANIGMA,   PCI_DEVICE_ID_ANIGMA_MC145575,  PCI_ANY_ID, PCI_ANY_ID},
1937         {PCI_VENDOR_ID_ZOLTRIX,  PCI_DEVICE_ID_ZOLTRIX_2BD0,     PCI_ANY_ID, PCI_ANY_ID},
1938         {PCI_VENDOR_ID_DIGI,     PCI_DEVICE_ID_DIGI_DF_M_IOM2_E, PCI_ANY_ID, PCI_ANY_ID},
1939         {PCI_VENDOR_ID_DIGI,     PCI_DEVICE_ID_DIGI_DF_M_E,      PCI_ANY_ID, PCI_ANY_ID},
1940         {PCI_VENDOR_ID_DIGI,     PCI_DEVICE_ID_DIGI_DF_M_IOM2_A, PCI_ANY_ID, PCI_ANY_ID},
1941         {PCI_VENDOR_ID_DIGI,     PCI_DEVICE_ID_DIGI_DF_M_A,      PCI_ANY_ID, PCI_ANY_ID},
1942 #endif
1943         { }                             /* Terminating entry */
1944 };
1945
1946 MODULE_DEVICE_TABLE(pci, hisax_pci_tbl);
1947 #endif /* CONFIG_PCI */
1948
1949 module_init(HiSax_init);
1950 module_exit(HiSax_exit);
1951
1952 EXPORT_SYMBOL(FsmNew);
1953 EXPORT_SYMBOL(FsmFree);
1954 EXPORT_SYMBOL(FsmEvent);
1955 EXPORT_SYMBOL(FsmChangeState);
1956 EXPORT_SYMBOL(FsmInitTimer);
1957 EXPORT_SYMBOL(FsmDelTimer);
1958 EXPORT_SYMBOL(FsmRestartTimer);