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