Import 2.3.10pre5
[davej-history.git] / drivers / isdn / hisax / config.c
blobd3bf31d90aea23c04ea400b819980c3026ce1eb3
1 /* $Id: config.c,v 2.23 1999/02/17 10:53:02 cpetig Exp $
3 * Author Karsten Keil (keil@isdn4linux.de)
4 * based on the teles driver from Jan den Ouden
7 * $Log: config.c,v $
8 * Revision 2.23 1999/02/17 10:53:02 cpetig
9 * Added Hisax_closecard to exported symbols.
10 * As indicated by Oliver Schoett <os@sdm.de>.
12 * If anyone is annoyed by exporting symbols deep inside the code, please
13 * contact me.
15 * Revision 2.22 1999/02/04 21:41:53 keil
16 * Fix printk msg
18 * Revision 2.21 1999/02/04 10:48:52 keil
19 * Fix readstat bug
21 * Revision 2.20 1998/11/15 23:54:28 keil
22 * changes from 2.0
24 * Revision 2.19 1998/08/13 23:36:18 keil
25 * HiSax 3.1 - don't work stable with current LinkLevel
27 * Revision 2.18 1998/07/30 21:01:37 niemann
28 * Fixed Sedlbauer Speed Fax PCMCIA missing isdnl3new
30 * Revision 2.17 1998/07/15 15:01:26 calle
31 * Support for AVM passive PCMCIA cards:
32 * A1 PCMCIA, FRITZ!Card PCMCIA and FRITZ!Card PCMCIA 2.0
34 * Revision 2.16 1998/05/25 14:10:03 keil
35 * HiSax 3.0
36 * X.75 and leased are working again.
38 * Revision 2.15 1998/05/25 12:57:43 keil
39 * HiSax golden code from certification, Don't use !!!
40 * No leased lines, no X75, but many changes.
42 * Revision 2.14 1998/04/15 16:38:25 keil
43 * Add S0Box and Teles PCI support
45 * Revision 2.13 1998/03/09 23:19:23 keil
46 * Changes for PCMCIA
48 * Revision 2.12 1998/02/11 17:28:02 keil
49 * Niccy PnP/PCI support
51 * Revision 2.11 1998/02/09 21:26:13 keil
52 * fix export module for 2.1
54 * Revision 2.10 1998/02/09 18:46:05 keil
55 * Support for Sedlbauer PCMCIA (Marcus Niemann)
57 * Revision 2.9 1998/02/03 23:31:28 keil
58 * add AMD7930 support
60 * Revision 2.8 1998/02/02 13:32:59 keil
61 * New card support
63 * Revision 2.7 1998/01/31 21:41:44 keil
64 * changes for newer 2.1 kernels
66 * Revision 2.6 1997/11/08 21:35:43 keil
67 * new l1 init
69 * Revision 2.5 1997/11/06 17:15:08 keil
70 * New 2.1 init; PCMCIA wrapper changes
72 * Revision 2.4 1997/10/29 19:07:52 keil
73 * changes for 2.1
75 * Revision 2.3 1997/10/01 09:21:33 fritz
76 * Removed old compatibility stuff for 2.0.X kernels.
77 * From now on, this code is for 2.1.X ONLY!
78 * Old stuff is still in the separate branch.
80 * Revision 2.2 1997/09/11 17:24:46 keil
81 * Add new cards
83 * Revision 2.1 1997/07/27 21:41:35 keil
84 * version change
86 * Revision 2.0 1997/06/26 11:06:28 keil
87 * New card and L1 interface.
88 * Eicon.Diehl Diva and Dynalink IS64PH support
90 * old changes removed /KKe
93 #include <linux/types.h>
94 #include <linux/stddef.h>
95 #include <linux/timer.h>
96 #include <linux/config.h>
97 #include "hisax.h"
98 #include <linux/module.h>
99 #include <linux/kernel_stat.h>
100 #include <linux/tqueue.h>
101 #include <linux/interrupt.h>
102 #define HISAX_STATUS_BUFSIZE 4096
103 #define INCLUDE_INLINE_FUNCS
106 * This structure array contains one entry per card. An entry looks
107 * like this:
109 * { type, protocol, p0, p1, p2, NULL }
111 * type
112 * 1 Teles 16.0 p0=irq p1=membase p2=iobase
113 * 2 Teles 8.0 p0=irq p1=membase
114 * 3 Teles 16.3 p0=irq p1=iobase
115 * 4 Creatix PNP p0=irq p1=IO0 (ISAC) p2=IO1 (HSCX)
116 * 5 AVM A1 (Fritz) p0=irq p1=iobase
117 * 6 ELSA PC [p0=iobase] or nothing (autodetect)
118 * 7 ELSA Quickstep p0=irq p1=iobase
119 * 8 Teles PCMCIA p0=irq p1=iobase
120 * 9 ITK ix1-micro p0=irq p1=iobase
121 * 10 ELSA PCMCIA p0=irq p1=iobase
122 * 11 Eicon.Diehl Diva p0=irq p1=iobase
123 * 12 Asuscom ISDNLink p0=irq p1=iobase
124 * 13 Teleint p0=irq p1=iobase
125 * 14 Teles 16.3c p0=irq p1=iobase
126 * 15 Sedlbauer speed p0=irq p1=iobase
127 * 15 Sedlbauer PC/104 p0=irq p1=iobase
128 * 15 Sedlbauer speed pci no parameter
129 * 16 USR Sportster internal p0=irq p1=iobase
130 * 17 MIC card p0=irq p1=iobase
131 * 18 ELSA Quickstep 1000PCI no parameter
132 * 19 Compaq ISDN S0 ISA card p0=irq p1=IO0 (HSCX) p2=IO1 (ISAC) p3=IO2
133 * 20 Travers Technologies NETjet PCI card
134 * 21 TELES PCI no parameter
135 * 22 Sedlbauer Speed Star p0=irq p1=iobase
136 * 23 reserved
137 * 24 Dr Neuhaus Niccy PnP/PCI card p0=irq p1=IO0 p2=IO1 (PnP only)
138 * 25 Teles S0Box p0=irq p1=iobase (from isapnp setup)
139 * 26 AVM A1 PCMCIA (Fritz) p0=irq p1=iobase
140 * 27 AVM PnP/PCI p0=irq p1=iobase (PCI no parameter)
141 * 28 Sedlbauer Speed Fax+ p0=irq p1=iobase (from isapnp setup)
143 * protocol can be either ISDN_PTYPE_EURO or ISDN_PTYPE_1TR6 or ISDN_PTYPE_NI1
148 const char *CardType[] =
149 {"No Card", "Teles 16.0", "Teles 8.0", "Teles 16.3", "Creatix/Teles PnP",
150 "AVM A1", "Elsa ML", "Elsa Quickstep", "Teles PCMCIA", "ITK ix1-micro Rev.2",
151 "Elsa PCMCIA", "Eicon.Diehl Diva", "ISDNLink", "TeleInt", "Teles 16.3c",
152 "Sedlbauer Speed Card", "USR Sportster", "ith mic Linux", "Elsa PCI",
153 "Compaq ISA", "NETjet", "Teles PCI", "Sedlbauer Speed Star (PCMCIA)",
154 "AMD 7930", "NICCY", "S0Box", "AVM A1 (PCMCIA)", "AVM Fritz PnP/PCI",
155 "Sedlbauer Speed Fax +"
158 #ifdef CONFIG_HISAX_ELSA
159 #define DEFAULT_CARD ISDN_CTYPE_ELSA
160 #define DEFAULT_CFG {0,0,0,0}
161 int elsa_init_pcmcia(void*, int, int*, int);
162 EXPORT_SYMBOL(elsa_init_pcmcia);
163 #endif
164 #ifdef CONFIG_HISAX_AVM_A1
165 #undef DEFAULT_CARD
166 #undef DEFAULT_CFG
167 #define DEFAULT_CARD ISDN_CTYPE_A1
168 #define DEFAULT_CFG {10,0x340,0,0}
169 #endif
171 #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
172 #undef DEFAULT_CARD
173 #undef DEFAULT_CFG
174 #define DEFAULT_CARD ISDN_CTYPE_A1_PCMCIA
175 #define DEFAULT_CFG {11,0x170,0,0}
176 int avm_a1_init_pcmcia(void*, int, int*, int);
177 EXPORT_SYMBOL(avm_a1_init_pcmcia);
178 #endif
180 #ifdef CONFIG_HISAX_FRITZPCI
181 #undef DEFAULT_CARD
182 #undef DEFAULT_CFG
183 #define DEFAULT_CARD ISDN_CTYPE_FRITZPCI
184 #define DEFAULT_CFG {0,0,0,0}
185 #endif
187 #ifdef CONFIG_HISAX_16_3
188 #undef DEFAULT_CARD
189 #undef DEFAULT_CFG
190 #define DEFAULT_CARD ISDN_CTYPE_16_3
191 #define DEFAULT_CFG {15,0x180,0,0}
192 #endif
193 #ifdef CONFIG_HISAX_S0BOX
194 #undef DEFAULT_CARD
195 #undef DEFAULT_CFG
196 #define DEFAULT_CARD ISDN_CTYPE_S0BOX
197 #define DEFAULT_CFG {7,0x378,0,0}
198 #endif
199 #ifdef CONFIG_HISAX_16_0
200 #undef DEFAULT_CARD
201 #undef DEFAULT_CFG
202 #define DEFAULT_CARD ISDN_CTYPE_16_0
203 #define DEFAULT_CFG {15,0xd0000,0xd80,0}
204 #endif
206 #ifdef CONFIG_HISAX_TELESPCI
207 #undef DEFAULT_CARD
208 #undef DEFAULT_CFG
209 #define DEFAULT_CARD ISDN_CTYPE_TELESPCI
210 #define DEFAULT_CFG {0,0,0,0}
211 #endif
213 #ifdef CONFIG_HISAX_IX1MICROR2
214 #undef DEFAULT_CARD
215 #undef DEFAULT_CFG
216 #define DEFAULT_CARD ISDN_CTYPE_IX1MICROR2
217 #define DEFAULT_CFG {5,0x390,0,0}
218 #endif
220 #ifdef CONFIG_HISAX_DIEHLDIVA
221 #undef DEFAULT_CARD
222 #undef DEFAULT_CFG
223 #define DEFAULT_CARD ISDN_CTYPE_DIEHLDIVA
224 #define DEFAULT_CFG {0,0x0,0,0}
225 #endif
227 #ifdef CONFIG_HISAX_ASUSCOM
228 #undef DEFAULT_CARD
229 #undef DEFAULT_CFG
230 #define DEFAULT_CARD ISDN_CTYPE_ASUSCOM
231 #define DEFAULT_CFG {5,0x200,0,0}
232 #endif
234 #ifdef CONFIG_HISAX_TELEINT
235 #undef DEFAULT_CARD
236 #undef DEFAULT_CFG
237 #define DEFAULT_CARD ISDN_CTYPE_TELEINT
238 #define DEFAULT_CFG {5,0x300,0,0}
239 #endif
241 #ifdef CONFIG_HISAX_SEDLBAUER
242 #undef DEFAULT_CARD
243 #undef DEFAULT_CFG
244 #define DEFAULT_CARD ISDN_CTYPE_SEDLBAUER
245 #define DEFAULT_CFG {11,0x270,0,0}
246 int sedl_init_pcmcia(void*, int, int*, int);
247 EXPORT_SYMBOL(sedl_init_pcmcia);
248 #endif
250 #ifdef CONFIG_HISAX_SPORTSTER
251 #undef DEFAULT_CARD
252 #undef DEFAULT_CFG
253 #define DEFAULT_CARD ISDN_CTYPE_SPORTSTER
254 #define DEFAULT_CFG {7,0x268,0,0}
255 #endif
257 #ifdef CONFIG_HISAX_MIC
258 #undef DEFAULT_CARD
259 #undef DEFAULT_CFG
260 #define DEFAULT_CARD ISDN_CTYPE_MIC
261 #define DEFAULT_CFG {12,0x3e0,0,0}
262 #endif
264 #ifdef CONFIG_HISAX_NETJET
265 #undef DEFAULT_CARD
266 #undef DEFAULT_CFG
267 #define DEFAULT_CARD ISDN_CTYPE_NETJET
268 #define DEFAULT_CFG {0,0,0,0}
269 #endif
271 #ifdef CONFIG_HISAX_TELES3C
272 #undef DEFAULT_CARD
273 #undef DEFAULT_CFG
274 #define DEFAULT_CARD ISDN_CTYPE_TELES3C
275 #define DEFAULT_CFG {5,0x500,0,0}
276 #endif
278 #ifdef CONFIG_HISAX_AMD7930
279 #undef DEFAULT_CARD
280 #undef DEFAULT_CFG
281 #define DEFAULT_CARD ISDN_CTYPE_AMD7930
282 #define DEFAULT_CFG {12,0x3e0,0,0}
283 #endif
285 #ifdef CONFIG_HISAX_NICCY
286 #undef DEFAULT_CARD
287 #undef DEFAULT_CFG
288 #define DEFAULT_CARD ISDN_CTYPE_NICCY
289 #define DEFAULT_CFG {0,0x0,0,0}
290 #endif
292 #ifdef CONFIG_HISAX_1TR6
293 #define DEFAULT_PROTO ISDN_PTYPE_1TR6
294 #define DEFAULT_PROTO_NAME "1TR6"
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 #ifdef CONFIG_HISAX_NI1
303 #undef DEFAULT_PROTO
304 #define DEFAULT_PROTO ISDN_PTYPE_NI1
305 #undef DEFAULT_PROTO_NAME
306 #define DEFAULT_PROTO_NAME "NI1"
307 #endif
308 #ifndef DEFAULT_PROTO
309 #define DEFAULT_PROTO ISDN_PTYPE_UNKNOWN
310 #define DEFAULT_PROTO_NAME "UNKNOWN"
311 #endif
312 #ifndef DEFAULT_CARD
313 #error "HiSax: No cards configured"
314 #endif
316 #define FIRST_CARD { \
317 DEFAULT_CARD, \
318 DEFAULT_PROTO, \
319 DEFAULT_CFG, \
320 NULL, \
323 #define EMPTY_CARD {0, DEFAULT_PROTO, {0, 0, 0, 0}, NULL}
325 struct IsdnCard cards[] =
327 FIRST_CARD,
328 EMPTY_CARD,
329 EMPTY_CARD,
330 EMPTY_CARD,
331 EMPTY_CARD,
332 EMPTY_CARD,
333 EMPTY_CARD,
334 EMPTY_CARD,
337 static char HiSaxID[64] HISAX_INITDATA = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" \
338 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" \
339 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
340 char *HiSax_id HISAX_INITDATA = HiSaxID;
341 #ifdef MODULE
342 /* Variables for insmod */
343 static int type[] HISAX_INITDATA =
344 {0, 0, 0, 0, 0, 0, 0, 0};
345 static int protocol[] HISAX_INITDATA =
346 {0, 0, 0, 0, 0, 0, 0, 0};
347 static int io[] HISAX_INITDATA =
348 {0, 0, 0, 0, 0, 0, 0, 0};
349 #undef IO0_IO1
350 #ifdef CONFIG_HISAX_16_3
351 #define IO0_IO1
352 #endif
353 #ifdef CONFIG_HISAX_NICCY
354 #undef IO0_IO1
355 #define IO0_IO1
356 #endif
357 #ifdef IO0_IO1
358 static int io0[] HISAX_INITDATA =
359 {0, 0, 0, 0, 0, 0, 0, 0};
360 static int io1[] HISAX_INITDATA =
361 {0, 0, 0, 0, 0, 0, 0, 0};
362 #endif
363 static int irq[] HISAX_INITDATA =
364 {0, 0, 0, 0, 0, 0, 0, 0};
365 static int mem[] HISAX_INITDATA =
366 {0, 0, 0, 0, 0, 0, 0, 0};
367 static char *id HISAX_INITDATA = HiSaxID;
369 MODULE_AUTHOR("Karsten Keil");
370 MODULE_PARM(type, "1-8i");
371 MODULE_PARM(protocol, "1-8i");
372 MODULE_PARM(io, "1-8i");
373 MODULE_PARM(irq, "1-8i");
374 MODULE_PARM(mem, "1-8i");
375 MODULE_PARM(id, "s");
376 #ifdef CONFIG_HISAX_16_3 /* For Creatix/Teles PnP */
377 MODULE_PARM(io0, "1-8i");
378 MODULE_PARM(io1, "1-8i");
379 #endif /* CONFIG_HISAX_16_3 */
381 #endif /* MODULE */
383 int nrcards;
385 extern char *l1_revision;
386 extern char *l2_revision;
387 extern char *l3_revision;
388 extern char *lli_revision;
389 extern char *tei_revision;
391 HISAX_INITFUNC(char *
392 HiSax_getrev(const char *revision))
394 char *rev;
395 char *p;
397 if ((p = strchr(revision, ':'))) {
398 rev = p + 2;
399 p = strchr(rev, '$');
400 *--p = 0;
401 } else
402 rev = "???";
403 return rev;
406 HISAX_INITFUNC(void
407 HiSaxVersion(void))
409 char tmp[64];
411 printk(KERN_INFO "HiSax: Linux Driver for passive ISDN cards\n");
412 #ifdef MODULE
413 printk(KERN_INFO "HiSax: Version 3.1a (module)\n");
414 #else
415 printk(KERN_INFO "HiSax: Version 3.1a (kernel)\n");
416 #endif
417 strcpy(tmp, l1_revision);
418 printk(KERN_INFO "HiSax: Layer1 Revision %s\n", HiSax_getrev(tmp));
419 strcpy(tmp, l2_revision);
420 printk(KERN_INFO "HiSax: Layer2 Revision %s\n", HiSax_getrev(tmp));
421 strcpy(tmp, tei_revision);
422 printk(KERN_INFO "HiSax: TeiMgr Revision %s\n", HiSax_getrev(tmp));
423 strcpy(tmp, l3_revision);
424 printk(KERN_INFO "HiSax: Layer3 Revision %s\n", HiSax_getrev(tmp));
425 strcpy(tmp, lli_revision);
426 printk(KERN_INFO "HiSax: LinkLayer Revision %s\n", HiSax_getrev(tmp));
427 certification_check(1);
430 void
431 HiSax_mod_dec_use_count(void)
433 MOD_DEC_USE_COUNT;
436 void
437 HiSax_mod_inc_use_count(void)
439 MOD_INC_USE_COUNT;
442 #ifdef MODULE
443 #define HiSax_init init_module
444 #else
445 void __init
446 HiSax_setup(char *str, int *ints)
448 int i, j, argc;
450 argc = ints[0];
451 i = 0;
452 j = 1;
453 while (argc && (i < HISAX_MAX_CARDS)) {
454 if (argc) {
455 cards[i].typ = ints[j];
456 j++;
457 argc--;
459 if (argc) {
460 cards[i].protocol = ints[j];
461 j++;
462 argc--;
464 if (argc) {
465 cards[i].para[0] = ints[j];
466 j++;
467 argc--;
469 if (argc) {
470 cards[i].para[1] = ints[j];
471 j++;
472 argc--;
474 if (argc) {
475 cards[i].para[2] = ints[j];
476 j++;
477 argc--;
479 i++;
481 if (strlen(str)) {
482 strcpy(HiSaxID, str);
483 HiSax_id = HiSaxID;
484 } else {
485 strcpy(HiSaxID, "HiSax");
486 HiSax_id = HiSaxID;
489 #endif
491 #if CARD_TELES0
492 extern int setup_teles0(struct IsdnCard *card);
493 #endif
495 #if CARD_TELES3
496 extern int setup_teles3(struct IsdnCard *card);
497 #endif
499 #if CARD_S0BOX
500 extern int setup_s0box(struct IsdnCard *card);
501 #endif
503 #if CARD_TELESPCI
504 extern int setup_telespci(struct IsdnCard *card);
505 #endif
507 #if CARD_AVM_A1
508 extern int setup_avm_a1(struct IsdnCard *card);
509 #endif
511 #if CARD_AVM_A1_PCMCIA
512 extern int setup_avm_a1_pcmcia(struct IsdnCard *card);
513 #endif
515 #if CARD_FRITZPCI
516 extern int setup_avm_pcipnp(struct IsdnCard *card);
517 #endif
519 #if CARD_ELSA
520 extern int setup_elsa(struct IsdnCard *card);
521 #endif
523 #if CARD_IX1MICROR2
524 extern int setup_ix1micro(struct IsdnCard *card);
525 #endif
527 #if CARD_DIEHLDIVA
528 extern int setup_diva(struct IsdnCard *card);
529 #endif
531 #if CARD_ASUSCOM
532 extern int setup_asuscom(struct IsdnCard *card);
533 #endif
535 #if CARD_TELEINT
536 extern int setup_TeleInt(struct IsdnCard *card);
537 #endif
539 #if CARD_SEDLBAUER
540 extern int setup_sedlbauer(struct IsdnCard *card);
541 #endif
543 #if CARD_SPORTSTER
544 extern int setup_sportster(struct IsdnCard *card);
545 #endif
547 #if CARD_MIC
548 extern int setup_mic(struct IsdnCard *card);
549 #endif
551 #if CARD_NETJET
552 extern int setup_netjet(struct IsdnCard *card);
553 #endif
555 #if CARD_TELES3C
556 extern int setup_t163c(struct IsdnCard *card);
557 #endif
559 #if CARD_AMD7930
560 extern int setup_amd7930(struct IsdnCard *card);
561 #endif
563 #if CARD_NICCY
564 extern int setup_niccy(struct IsdnCard *card);
565 #endif
568 * Find card with given driverId
570 static inline struct IsdnCardState
571 *hisax_findcard(int driverid)
573 int i;
575 for (i = 0; i < nrcards; i++)
576 if (cards[i].cs)
577 if (cards[i].cs->myid == driverid)
578 return (cards[i].cs);
579 return (NULL);
583 HiSax_readstatus(u_char * buf, int len, int user, int id, int channel)
585 int count,cnt;
586 u_char *p = buf;
587 struct IsdnCardState *cs = hisax_findcard(id);
589 if (cs) {
590 if (len > HISAX_STATUS_BUFSIZE) {
591 printk(KERN_WARNING "HiSax: status overflow readstat %d/%d\n",
592 len, HISAX_STATUS_BUFSIZE);
594 count = cs->status_end - cs->status_read +1;
595 if (count >= len)
596 count = len;
597 if (user)
598 copy_to_user(p, cs->status_read, count);
599 else
600 memcpy(p, cs->status_read, count);
601 cs->status_read += count;
602 if (cs->status_read > cs->status_end)
603 cs->status_read = cs->status_buf;
604 p += count;
605 count = len - count;
606 while (count) {
607 if (count > HISAX_STATUS_BUFSIZE)
608 cnt = HISAX_STATUS_BUFSIZE;
609 else
610 cnt = count;
611 if (user)
612 copy_to_user(p, cs->status_read, cnt);
613 else
614 memcpy(p, cs->status_read, cnt);
615 p += cnt;
616 cs->status_read += cnt % HISAX_STATUS_BUFSIZE;
617 count -= cnt;
619 return len;
620 } else {
621 printk(KERN_ERR
622 "HiSax: if_readstatus called with invalid driverId!\n");
623 return -ENODEV;
627 inline int
628 jiftime(char *s, long mark)
630 s += 8;
632 *s-- = '\0';
633 *s-- = mark % 10 + '0';
634 mark /= 10;
635 *s-- = mark % 10 + '0';
636 mark /= 10;
637 *s-- = '.';
638 *s-- = mark % 10 + '0';
639 mark /= 10;
640 *s-- = mark % 6 + '0';
641 mark /= 6;
642 *s-- = ':';
643 *s-- = mark % 10 + '0';
644 mark /= 10;
645 *s-- = mark % 10 + '0';
646 return(8);
649 static u_char tmpbuf[HISAX_STATUS_BUFSIZE];
651 void
652 VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, va_list args)
654 /* if head == NULL the fmt contains the full info */
656 long flags;
657 int count, i;
658 u_char *p;
659 isdn_ctrl ic;
660 int len;
662 save_flags(flags);
663 cli();
664 p = tmpbuf;
665 if (head) {
666 p += jiftime(p, jiffies);
667 p += sprintf(p, " %s", head);
668 p += vsprintf(p, fmt, args);
669 *p++ = '\n';
670 *p = 0;
671 len = p - tmpbuf;
672 p = tmpbuf;
673 } else {
674 p = fmt;
675 len = strlen(fmt);
677 if (!cs) {
678 printk(KERN_WARNING "HiSax: No CardStatus for message %s", p);
679 restore_flags(flags);
680 return;
682 if (len > HISAX_STATUS_BUFSIZE) {
683 printk(KERN_WARNING "HiSax: status overflow %d/%d\n",
684 len, HISAX_STATUS_BUFSIZE);
685 restore_flags(flags);
686 return;
688 count = len;
689 i = cs->status_end - cs->status_write +1;
690 if (i >= len)
691 i = len;
692 len -= i;
693 memcpy(cs->status_write, p, i);
694 cs->status_write += i;
695 if (cs->status_write > cs->status_end)
696 cs->status_write = cs->status_buf;
697 p += i;
698 if (len) {
699 memcpy(cs->status_write, p, len);
700 cs->status_write += len;
702 #ifdef KERNELSTACK_DEBUG
703 i = (ulong)&len - current->kernel_stack_page;
704 sprintf(tmpbuf, "kstack %s %lx use %ld\n", current->comm,
705 current->kernel_stack_page, i);
706 len = strlen(tmpbuf);
707 for (p = tmpbuf, i = len; i > 0; i--, p++) {
708 *cs->status_write++ = *p;
709 if (cs->status_write > cs->status_end)
710 cs->status_write = cs->status_buf;
711 count++;
713 #endif
714 restore_flags(flags);
715 if (count) {
716 ic.command = ISDN_STAT_STAVAIL;
717 ic.driver = cs->myid;
718 ic.arg = count;
719 cs->iif.statcallb(&ic);
723 void
724 HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...)
726 va_list args;
728 va_start(args, fmt);
729 VHiSax_putstatus(cs, head, fmt, args);
730 va_end(args);
734 ll_run(struct IsdnCardState *cs)
736 long flags;
737 isdn_ctrl ic;
739 save_flags(flags);
740 cli();
741 ic.driver = cs->myid;
742 ic.command = ISDN_STAT_RUN;
743 cs->iif.statcallb(&ic);
744 restore_flags(flags);
745 return 0;
748 void
749 ll_stop(struct IsdnCardState *cs)
751 isdn_ctrl ic;
753 ic.command = ISDN_STAT_STOP;
754 ic.driver = cs->myid;
755 cs->iif.statcallb(&ic);
756 CallcFreeChan(cs);
759 static void
760 ll_unload(struct IsdnCardState *cs)
762 isdn_ctrl ic;
764 ic.command = ISDN_STAT_UNLOAD;
765 ic.driver = cs->myid;
766 cs->iif.statcallb(&ic);
767 if (cs->status_buf)
768 kfree(cs->status_buf);
769 cs->status_read = NULL;
770 cs->status_write = NULL;
771 cs->status_end = NULL;
772 kfree(cs->dlog);
775 static void
776 closecard(int cardnr)
778 struct IsdnCardState *csta = cards[cardnr].cs;
780 if (csta->bcs->BC_Close != NULL) {
781 csta->bcs->BC_Close(csta->bcs + 1);
782 csta->bcs->BC_Close(csta->bcs);
785 if (csta->rcvbuf) {
786 kfree(csta->rcvbuf);
787 csta->rcvbuf = NULL;
789 discard_queue(&csta->rq);
790 discard_queue(&csta->sq);
791 if (csta->tx_skb) {
792 dev_kfree_skb(csta->tx_skb);
793 csta->tx_skb = NULL;
795 if (csta->mon_rx) {
796 kfree(csta->mon_rx);
797 csta->mon_rx = NULL;
799 if (csta->mon_tx) {
800 kfree(csta->mon_tx);
801 csta->mon_tx = NULL;
803 csta->cardmsg(csta, CARD_RELEASE, NULL);
804 if (csta->dbusytimer.function != NULL)
805 del_timer(&csta->dbusytimer);
806 ll_unload(csta);
809 HISAX_INITFUNC(static int init_card(struct IsdnCardState *cs))
811 int irq_cnt, cnt = 3;
812 long flags;
814 save_flags(flags);
815 cli();
816 irq_cnt = kstat_irqs(cs->irq);
817 printk(KERN_INFO "%s: IRQ %d count %d\n", CardType[cs->typ], cs->irq,
818 irq_cnt);
819 if (cs->cardmsg(cs, CARD_SETIRQ, NULL)) {
820 printk(KERN_WARNING "HiSax: couldn't get interrupt %d\n",
821 cs->irq);
822 restore_flags(flags);
823 return(1);
825 while (cnt) {
826 cs->cardmsg(cs, CARD_INIT, NULL);
827 sti();
828 current->state = TASK_INTERRUPTIBLE;
829 /* Timeout 10ms */
830 schedule_timeout((10 * HZ) / 1000);
831 restore_flags(flags);
832 printk(KERN_INFO "%s: IRQ %d count %d\n", CardType[cs->typ],
833 cs->irq, kstat_irqs(cs->irq));
834 if (kstat_irqs(cs->irq) == irq_cnt) {
835 printk(KERN_WARNING
836 "%s: IRQ(%d) getting no interrupts during init %d\n",
837 CardType[cs->typ], cs->irq, 4 - cnt);
838 if (cnt == 1) {
839 free_irq(cs->irq, cs);
840 return (2);
841 } else {
842 cs->cardmsg(cs, CARD_RESET, NULL);
843 cnt--;
845 } else {
846 cs->cardmsg(cs, CARD_TEST, NULL);
847 return(0);
850 restore_flags(flags);
851 return(3);
854 HISAX_INITFUNC(static int
855 checkcard(int cardnr, char *id, int *busy_flag))
857 long flags;
858 int ret = 0;
859 struct IsdnCard *card = cards + cardnr;
860 struct IsdnCardState *cs;
862 save_flags(flags);
863 cli();
864 if (!(cs = (struct IsdnCardState *)
865 kmalloc(sizeof(struct IsdnCardState), GFP_ATOMIC))) {
866 printk(KERN_WARNING
867 "HiSax: No memory for IsdnCardState(card %d)\n",
868 cardnr + 1);
869 restore_flags(flags);
870 return (0);
872 memset(cs, 0, sizeof(struct IsdnCardState));
873 card->cs = cs;
874 cs->cardnr = cardnr;
875 cs->debug = L1_DEB_WARN;
876 cs->HW_Flags = 0;
877 cs->busy_flag = busy_flag;
878 #if TEI_PER_CARD
879 #else
880 test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);
881 #endif
882 cs->protocol = card->protocol;
884 if ((card->typ > 0) && (card->typ < 31)) {
885 if (!((1 << card->typ) & SUPORTED_CARDS)) {
886 printk(KERN_WARNING
887 "HiSax: Support for %s Card not selected\n",
888 CardType[card->typ]);
889 restore_flags(flags);
890 return (0);
892 } else {
893 printk(KERN_WARNING
894 "HiSax: Card Type %d out of range\n",
895 card->typ);
896 restore_flags(flags);
897 return (0);
899 if (!(cs->dlog = kmalloc(MAX_DLOG_SPACE, GFP_ATOMIC))) {
900 printk(KERN_WARNING
901 "HiSax: No memory for dlog(card %d)\n",
902 cardnr + 1);
903 restore_flags(flags);
904 return (0);
906 if (!(cs->status_buf = kmalloc(HISAX_STATUS_BUFSIZE, GFP_ATOMIC))) {
907 printk(KERN_WARNING
908 "HiSax: No memory for status_buf(card %d)\n",
909 cardnr + 1);
910 kfree(cs->dlog);
911 restore_flags(flags);
912 return (0);
914 cs->stlist = NULL;
915 cs->mon_tx = NULL;
916 cs->mon_rx = NULL;
917 cs->status_read = cs->status_buf;
918 cs->status_write = cs->status_buf;
919 cs->status_end = cs->status_buf + HISAX_STATUS_BUFSIZE - 1;
920 cs->typ = card->typ;
921 strcpy(cs->iif.id, id);
922 cs->iif.channels = 2;
923 cs->iif.maxbufsize = MAX_DATA_SIZE;
924 cs->iif.hl_hdrlen = MAX_HEADER_LEN;
925 cs->iif.features =
926 ISDN_FEATURE_L2_X75I |
927 ISDN_FEATURE_L2_HDLC |
928 ISDN_FEATURE_L2_MODEM |
929 ISDN_FEATURE_L2_TRANS |
930 ISDN_FEATURE_L3_TRANS |
931 #ifdef CONFIG_HISAX_1TR6
932 ISDN_FEATURE_P_1TR6 |
933 #endif
934 #ifdef CONFIG_HISAX_EURO
935 ISDN_FEATURE_P_EURO |
936 #endif
937 #ifdef CONFIG_HISAX_NI1
938 ISDN_FEATURE_P_NI1 |
939 #endif
942 cs->iif.command = HiSax_command;
943 cs->iif.writecmd = NULL;
944 cs->iif.writebuf_skb = HiSax_writebuf_skb;
945 cs->iif.readstat = HiSax_readstatus;
946 register_isdn(&cs->iif);
947 cs->myid = cs->iif.channels;
948 printk(KERN_INFO
949 "HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr + 1,
950 (card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" :
951 (card->protocol == ISDN_PTYPE_EURO) ? "EDSS1" :
952 (card->protocol == ISDN_PTYPE_LEASED) ? "LEASED" :
953 (card->protocol == ISDN_PTYPE_NI1) ? "NI1" :
954 "NONE", cs->iif.id, cs->myid);
955 switch (card->typ) {
956 #if CARD_TELES0
957 case ISDN_CTYPE_16_0:
958 case ISDN_CTYPE_8_0:
959 ret = setup_teles0(card);
960 break;
961 #endif
962 #if CARD_TELES3
963 case ISDN_CTYPE_16_3:
964 case ISDN_CTYPE_PNP:
965 case ISDN_CTYPE_TELESPCMCIA:
966 case ISDN_CTYPE_COMPAQ_ISA:
967 ret = setup_teles3(card);
968 break;
969 #endif
970 #if CARD_S0BOX
971 case ISDN_CTYPE_S0BOX:
972 ret = setup_s0box(card);
973 break;
974 #endif
975 #if CARD_TELESPCI
976 case ISDN_CTYPE_TELESPCI:
977 ret = setup_telespci(card);
978 break;
979 #endif
980 #if CARD_AVM_A1
981 case ISDN_CTYPE_A1:
982 ret = setup_avm_a1(card);
983 break;
984 #endif
985 #if CARD_AVM_A1_PCMCIA
986 case ISDN_CTYPE_A1_PCMCIA:
987 ret = setup_avm_a1_pcmcia(card);
988 break;
989 #endif
990 #if CARD_FRITZPCI
991 case ISDN_CTYPE_FRITZPCI:
992 ret = setup_avm_pcipnp(card);
993 break;
994 #endif
995 #if CARD_ELSA
996 case ISDN_CTYPE_ELSA:
997 case ISDN_CTYPE_ELSA_PNP:
998 case ISDN_CTYPE_ELSA_PCMCIA:
999 case ISDN_CTYPE_ELSA_PCI:
1000 ret = setup_elsa(card);
1001 break;
1002 #endif
1003 #if CARD_IX1MICROR2
1004 case ISDN_CTYPE_IX1MICROR2:
1005 ret = setup_ix1micro(card);
1006 break;
1007 #endif
1008 #if CARD_DIEHLDIVA
1009 case ISDN_CTYPE_DIEHLDIVA:
1010 ret = setup_diva(card);
1011 break;
1012 #endif
1013 #if CARD_ASUSCOM
1014 case ISDN_CTYPE_ASUSCOM:
1015 ret = setup_asuscom(card);
1016 break;
1017 #endif
1018 #if CARD_TELEINT
1019 case ISDN_CTYPE_TELEINT:
1020 ret = setup_TeleInt(card);
1021 break;
1022 #endif
1023 #if CARD_SEDLBAUER
1024 case ISDN_CTYPE_SEDLBAUER:
1025 case ISDN_CTYPE_SEDLBAUER_PCMCIA:
1026 case ISDN_CTYPE_SEDLBAUER_FAX:
1027 ret = setup_sedlbauer(card);
1028 break;
1029 #endif
1030 #if CARD_SPORTSTER
1031 case ISDN_CTYPE_SPORTSTER:
1032 ret = setup_sportster(card);
1033 break;
1034 #endif
1035 #if CARD_MIC
1036 case ISDN_CTYPE_MIC:
1037 ret = setup_mic(card);
1038 break;
1039 #endif
1040 #if CARD_NETJET
1041 case ISDN_CTYPE_NETJET:
1042 ret = setup_netjet(card);
1043 break;
1044 #endif
1045 #if CARD_TELES3C
1046 case ISDN_CTYPE_TELES3C:
1047 ret = setup_t163c(card);
1048 break;
1049 #endif
1050 #if CARD_NICCY
1051 case ISDN_CTYPE_NICCY:
1052 ret = setup_niccy(card);
1053 break;
1054 #endif
1055 #if CARD_AMD7930
1056 case ISDN_CTYPE_AMD7930:
1057 ret = setup_amd7930(card);
1058 break;
1059 #endif
1060 default:
1061 printk(KERN_WARNING "HiSax: Unknown Card Typ %d\n",
1062 card->typ);
1063 ll_unload(cs);
1064 restore_flags(flags);
1065 return (0);
1067 if (!ret) {
1068 ll_unload(cs);
1069 restore_flags(flags);
1070 return (0);
1072 if (!(cs->rcvbuf = kmalloc(MAX_DFRAME_LEN_L1, GFP_ATOMIC))) {
1073 printk(KERN_WARNING
1074 "HiSax: No memory for isac rcvbuf\n");
1075 return (1);
1077 cs->rcvidx = 0;
1078 cs->tx_skb = NULL;
1079 cs->tx_cnt = 0;
1080 cs->event = 0;
1081 cs->tqueue.next = 0;
1082 cs->tqueue.sync = 0;
1083 cs->tqueue.data = cs;
1085 skb_queue_head_init(&cs->rq);
1086 skb_queue_head_init(&cs->sq);
1088 init_bcstate(cs, 0);
1089 init_bcstate(cs, 1);
1090 ret = init_card(cs);
1091 if (ret) {
1092 closecard(cardnr);
1093 restore_flags(flags);
1094 return (0);
1096 init_tei(cs, cs->protocol);
1097 CallcNewChan(cs);
1098 /* ISAR needs firmware download first */
1099 if (!test_bit(HW_ISAR, &cs->HW_Flags))
1100 ll_run(cs);
1101 restore_flags(flags);
1102 return (1);
1105 HISAX_INITFUNC(void
1106 HiSax_shiftcards(int idx))
1108 int i;
1110 for (i = idx; i < (HISAX_MAX_CARDS - 1); i++)
1111 memcpy(&cards[i], &cards[i + 1], sizeof(cards[i]));
1114 HISAX_INITFUNC(int
1115 HiSax_inithardware(int *busy_flag))
1117 int foundcards = 0;
1118 int i = 0;
1119 int t = ',';
1120 int flg = 0;
1121 char *id;
1122 char *next_id = HiSax_id;
1123 char ids[20];
1125 if (strchr(HiSax_id, ','))
1126 t = ',';
1127 else if (strchr(HiSax_id, '%'))
1128 t = '%';
1130 while (i < nrcards) {
1131 if (cards[i].typ < 1)
1132 break;
1133 id = next_id;
1134 if ((next_id = strchr(id, t))) {
1135 *next_id++ = 0;
1136 strcpy(ids, id);
1137 flg = i + 1;
1138 } else {
1139 next_id = id;
1140 if (flg >= i)
1141 strcpy(ids, id);
1142 else
1143 sprintf(ids, "%s%d", id, i);
1145 if (checkcard(i, ids, busy_flag)) {
1146 foundcards++;
1147 i++;
1148 } else {
1149 printk(KERN_WARNING "HiSax: Card %s not installed !\n",
1150 CardType[cards[i].typ]);
1151 if (cards[i].cs)
1152 kfree((void *) cards[i].cs);
1153 cards[i].cs = NULL;
1154 HiSax_shiftcards(i);
1157 return foundcards;
1160 void
1161 HiSax_closecard(int cardnr)
1163 int i,last=nrcards - 1;
1165 if (cardnr>last)
1166 return;
1167 if (cards[cardnr].cs) {
1168 ll_stop(cards[cardnr].cs);
1169 release_tei(cards[cardnr].cs);
1170 closecard(cardnr);
1171 free_irq(cards[cardnr].cs->irq, cards[cardnr].cs);
1172 kfree((void *) cards[cardnr].cs);
1173 cards[cardnr].cs = NULL;
1175 i = cardnr;
1176 while (i!=last) {
1177 cards[i] = cards[i+1];
1178 i++;
1180 nrcards--;
1183 EXPORT_SYMBOL(HiSax_closecard);
1185 void
1186 HiSax_reportcard(int cardnr)
1188 struct IsdnCardState *cs = cards[cardnr].cs;
1189 struct PStack *stptr;
1190 struct l3_process *pc;
1191 int j, i = 1;
1193 printk(KERN_DEBUG "HiSax: reportcard No %d\n", cardnr + 1);
1194 printk(KERN_DEBUG "HiSax: Type %s\n", CardType[cs->typ]);
1195 printk(KERN_DEBUG "HiSax: debuglevel %x\n", cs->debug);
1196 printk(KERN_DEBUG "HiSax: HiSax_reportcard address 0x%lX\n",
1197 (ulong) & HiSax_reportcard);
1198 printk(KERN_DEBUG "HiSax: cs 0x%lX\n", (ulong) cs);
1199 printk(KERN_DEBUG "HiSax: HW_Flags %x bc0 flg %x bc0 flg %x\n",
1200 cs->HW_Flags, cs->bcs[0].Flag, cs->bcs[1].Flag);
1201 printk(KERN_DEBUG "HiSax: bcs 0 mode %d ch%d\n",
1202 cs->bcs[0].mode, cs->bcs[0].channel);
1203 printk(KERN_DEBUG "HiSax: bcs 1 mode %d ch%d\n",
1204 cs->bcs[1].mode, cs->bcs[1].channel);
1205 printk(KERN_DEBUG "HiSax: cs stl 0x%lX\n", (ulong) & (cs->stlist));
1206 stptr = cs->stlist;
1207 while (stptr != NULL) {
1208 printk(KERN_DEBUG "HiSax: dst%d 0x%lX\n", i, (ulong) stptr);
1209 printk(KERN_DEBUG "HiSax: dst%d stp 0x%lX\n", i, (ulong) stptr->l1.stlistp);
1210 printk(KERN_DEBUG "HiSax: tei %d sapi %d\n",
1211 stptr->l2.tei, stptr->l2.sap);
1212 printk(KERN_DEBUG "HiSax: man 0x%lX\n", (ulong) stptr->ma.layer);
1213 pc = stptr->l3.proc;
1214 while (pc) {
1215 printk(KERN_DEBUG "HiSax: l3proc %x 0x%lX\n", pc->callref,
1216 (ulong) pc);
1217 printk(KERN_DEBUG "HiSax: state %d st 0x%lX chan 0x%lX\n",
1218 pc->state, (ulong) pc->st, (ulong) pc->chan);
1219 pc = pc->next;
1221 stptr = stptr->next;
1222 i++;
1224 for (j = 0; j < 2; j++) {
1225 printk(KERN_DEBUG "HiSax: ch%d 0x%lX\n", j,
1226 (ulong) & cs->channel[j]);
1227 stptr = cs->channel[j].b_st;
1228 i = 1;
1229 while (stptr != NULL) {
1230 printk(KERN_DEBUG "HiSax: b_st%d 0x%lX\n", i, (ulong) stptr);
1231 printk(KERN_DEBUG "HiSax: man 0x%lX\n", (ulong) stptr->ma.layer);
1232 stptr = stptr->next;
1233 i++;
1239 int __init
1240 HiSax_init(void)
1242 int i;
1244 #ifdef MODULE
1245 int nzproto = 0;
1246 #ifdef CONFIG_HISAX_ELSA
1247 if (type[0] == ISDN_CTYPE_ELSA_PCMCIA) {
1248 /* we have exported and return in this case */
1249 return 0;
1251 #endif
1252 #ifdef CONFIG_HISAX_SEDLBAUER
1253 if (type[0] == ISDN_CTYPE_SEDLBAUER_PCMCIA) {
1254 /* we have to export and return in this case */
1255 return 0;
1257 #endif
1258 #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
1259 if (type[0] == ISDN_CTYPE_A1_PCMCIA) {
1260 /* we have to export and return in this case */
1261 return 0;
1263 #endif
1264 #endif
1265 nrcards = 0;
1266 HiSaxVersion();
1267 #ifdef MODULE
1268 if (id) /* If id= string used */
1269 HiSax_id = id;
1270 for (i = 0; i < HISAX_MAX_CARDS; i++) {
1271 cards[i].typ = type[i];
1272 if (protocol[i]) {
1273 cards[i].protocol = protocol[i];
1274 nzproto++;
1276 switch (type[i]) {
1277 case ISDN_CTYPE_16_0:
1278 cards[i].para[0] = irq[i];
1279 cards[i].para[1] = mem[i];
1280 cards[i].para[2] = io[i];
1281 break;
1283 case ISDN_CTYPE_8_0:
1284 cards[i].para[0] = irq[i];
1285 cards[i].para[1] = mem[i];
1286 break;
1288 #ifdef IO0_IO1
1289 case ISDN_CTYPE_PNP:
1290 case ISDN_CTYPE_NICCY:
1291 cards[i].para[0] = irq[i];
1292 cards[i].para[1] = io0[i];
1293 cards[i].para[2] = io1[i];
1294 break;
1295 case ISDN_CTYPE_COMPAQ_ISA:
1296 cards[i].para[0] = irq[i];
1297 cards[i].para[1] = io0[i];
1298 cards[i].para[2] = io1[i];
1299 cards[i].para[3] = io[i];
1300 break;
1301 #endif
1302 case ISDN_CTYPE_ELSA:
1303 cards[i].para[0] = io[i];
1304 break;
1305 case ISDN_CTYPE_16_3:
1306 case ISDN_CTYPE_TELESPCMCIA:
1307 case ISDN_CTYPE_A1:
1308 case ISDN_CTYPE_A1_PCMCIA:
1309 case ISDN_CTYPE_ELSA_PNP:
1310 case ISDN_CTYPE_ELSA_PCMCIA:
1311 case ISDN_CTYPE_IX1MICROR2:
1312 case ISDN_CTYPE_DIEHLDIVA:
1313 case ISDN_CTYPE_ASUSCOM:
1314 case ISDN_CTYPE_TELEINT:
1315 case ISDN_CTYPE_SEDLBAUER:
1316 case ISDN_CTYPE_SEDLBAUER_PCMCIA:
1317 case ISDN_CTYPE_SEDLBAUER_FAX:
1318 case ISDN_CTYPE_SPORTSTER:
1319 case ISDN_CTYPE_MIC:
1320 case ISDN_CTYPE_TELES3C:
1321 case ISDN_CTYPE_S0BOX:
1322 case ISDN_CTYPE_FRITZPCI:
1323 cards[i].para[0] = irq[i];
1324 cards[i].para[1] = io[i];
1325 break;
1326 case ISDN_CTYPE_ELSA_PCI:
1327 case ISDN_CTYPE_NETJET:
1328 case ISDN_CTYPE_AMD7930:
1329 case ISDN_CTYPE_TELESPCI:
1330 break;
1333 if (!nzproto) {
1334 printk(KERN_WARNING "HiSax: Warning - no protocol specified\n");
1335 printk(KERN_WARNING "HiSax: Note! module load syntax has changed.\n");
1336 printk(KERN_WARNING "HiSax: using protocol %s\n", DEFAULT_PROTO_NAME);
1338 #endif
1339 if (!HiSax_id)
1340 HiSax_id = HiSaxID;
1341 if (!HiSaxID[0])
1342 strcpy(HiSaxID, "HiSax");
1343 for (i = 0; i < HISAX_MAX_CARDS; i++)
1344 if (cards[i].typ > 0)
1345 nrcards++;
1346 printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
1347 nrcards, (nrcards > 1) ? "s" : "");
1349 CallcNew();
1350 Isdnl3New();
1351 Isdnl2New();
1352 TeiNew();
1353 Isdnl1New();
1354 if (HiSax_inithardware(NULL)) {
1355 /* Install only, if at least one card found */
1356 /* No symbols to export, hide all symbols */
1358 #ifdef MODULE
1359 printk(KERN_INFO "HiSax: module installed\n");
1360 #endif
1361 return (0);
1362 } else {
1363 Isdnl1Free();
1364 TeiFree();
1365 Isdnl2Free();
1366 Isdnl3Free();
1367 CallcFree();
1368 return -EIO;
1372 #ifdef MODULE
1373 void
1374 cleanup_module(void)
1376 int cardnr = nrcards -1;
1377 long flags;
1379 save_flags(flags);
1380 cli();
1381 while(cardnr>=0)
1382 HiSax_closecard(cardnr--);
1383 Isdnl1Free();
1384 TeiFree();
1385 Isdnl2Free();
1386 Isdnl3Free();
1387 CallcFree();
1388 restore_flags(flags);
1389 printk(KERN_INFO "HiSax module removed\n");
1391 #endif
1393 #ifdef CONFIG_HISAX_ELSA
1394 int elsa_init_pcmcia(void *pcm_iob, int pcm_irq, int *busy_flag, int prot)
1396 #ifdef MODULE
1397 int i;
1398 int nzproto = 0;
1400 nrcards = 0;
1401 HiSaxVersion();
1402 if (id) /* If id= string used */
1403 HiSax_id = id;
1404 /* Initialize all 8 structs, even though we only accept
1405 two pcmcia cards
1407 for (i = 0; i < HISAX_MAX_CARDS; i++) {
1408 cards[i].para[0] = irq[i];
1409 cards[i].para[1] = io[i];
1410 cards[i].typ = type[i];
1411 if (protocol[i]) {
1412 cards[i].protocol = protocol[i];
1413 nzproto++;
1416 cards[0].para[0] = pcm_irq;
1417 cards[0].para[1] = (int)pcm_iob;
1418 cards[0].protocol = prot;
1419 cards[0].typ = 10;
1420 nzproto = 1;
1422 if (!HiSax_id)
1423 HiSax_id = HiSaxID;
1424 if (!HiSaxID[0])
1425 strcpy(HiSaxID, "HiSax");
1426 for (i = 0; i < HISAX_MAX_CARDS; i++)
1427 if (cards[i].typ > 0)
1428 nrcards++;
1429 printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
1430 nrcards, (nrcards > 1) ? "s" : "");
1432 Isdnl1New();
1433 CallcNew();
1434 Isdnl3New();
1435 Isdnl2New();
1436 TeiNew();
1437 HiSax_inithardware(busy_flag);
1438 printk(KERN_NOTICE "HiSax: module installed\n");
1439 #endif
1440 return (0);
1442 #endif
1444 #ifdef CONFIG_HISAX_SEDLBAUER
1445 int sedl_init_pcmcia(void *pcm_iob, int pcm_irq, int *busy_flag, int prot)
1447 #ifdef MODULE
1448 int i;
1449 int nzproto = 0;
1451 nrcards = 0;
1452 HiSaxVersion();
1453 if (id) /* If id= string used */
1454 HiSax_id = id;
1455 /* Initialize all 8 structs, even though we only accept
1456 two pcmcia cards
1458 for (i = 0; i < HISAX_MAX_CARDS; i++) {
1459 cards[i].para[0] = irq[i];
1460 cards[i].para[1] = io[i];
1461 cards[i].typ = type[i];
1462 if (protocol[i]) {
1463 cards[i].protocol = protocol[i];
1464 nzproto++;
1467 cards[0].para[0] = pcm_irq;
1468 cards[0].para[1] = (int)pcm_iob;
1469 cards[0].protocol = prot;
1470 cards[0].typ = ISDN_CTYPE_SEDLBAUER_PCMCIA;
1471 nzproto = 1;
1473 if (!HiSax_id)
1474 HiSax_id = HiSaxID;
1475 if (!HiSaxID[0])
1476 strcpy(HiSaxID, "HiSax");
1477 for (i = 0; i < HISAX_MAX_CARDS; i++)
1478 if (cards[i].typ > 0)
1479 nrcards++;
1480 printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
1481 nrcards, (nrcards > 1) ? "s" : "");
1483 CallcNew();
1484 Isdnl3New();
1485 Isdnl2New();
1486 Isdnl1New();
1487 TeiNew();
1488 HiSax_inithardware(busy_flag);
1489 printk(KERN_NOTICE "HiSax: module installed\n");
1490 #endif
1491 return (0);
1493 #endif
1495 #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
1496 int avm_a1_init_pcmcia(void *pcm_iob, int pcm_irq, int *busy_flag, int prot)
1498 #ifdef MODULE
1499 int i;
1500 int nzproto = 0;
1502 nrcards = 0;
1503 HiSaxVersion();
1504 if (id) /* If id= string used */
1505 HiSax_id = id;
1506 /* Initialize all 16 structs, even though we only accept
1507 two pcmcia cards
1509 for (i = 0; i < 16; i++) {
1510 cards[i].para[0] = irq[i];
1511 cards[i].para[1] = io[i];
1512 cards[i].typ = type[i];
1513 if (protocol[i]) {
1514 cards[i].protocol = protocol[i];
1515 nzproto++;
1518 cards[0].para[0] = pcm_irq;
1519 cards[0].para[1] = (int)pcm_iob;
1520 cards[0].protocol = prot;
1521 cards[0].typ = ISDN_CTYPE_A1_PCMCIA;
1522 nzproto = 1;
1524 if (!HiSax_id)
1525 HiSax_id = HiSaxID;
1526 if (!HiSaxID[0])
1527 strcpy(HiSaxID, "HiSax");
1528 for (i = 0; i < HISAX_MAX_CARDS; i++)
1529 if (cards[i].typ > 0)
1530 nrcards++;
1531 printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
1532 nrcards, (nrcards > 1) ? "s" : "");
1534 Isdnl1New();
1535 CallcNew();
1536 Isdnl3New();
1537 Isdnl2New();
1538 TeiNew();
1539 HiSax_inithardware(busy_flag);
1540 printk(KERN_NOTICE "HiSax: module installed\n");
1541 #endif
1542 return (0);
1544 #endif