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