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