1 /* $Id: config.c,v 1.1.1.1 2005/04/11 02:50:23 jack Exp $
4 * Copyright by Karsten Keil <keil@isdn4linux.de>
5 * by Kai Germaschewski <kai.germaschewski@gmx.de>
7 * This software may be used and distributed according to the terms
8 * of the GNU General Public License, incorporated herein by reference.
10 * For changes and modifications please read
11 * ../../../Documentation/isdn/HiSax.cert
13 * based on the teles driver from Jan den Ouden
17 #include <linux/types.h>
18 #include <linux/stddef.h>
19 #include <linux/timer.h>
20 #include <linux/config.h>
21 #include <linux/init.h>
23 #include <linux/module.h>
24 #include <linux/kernel_stat.h>
25 #include <linux/tqueue.h>
26 #include <linux/interrupt.h>
27 #define HISAX_STATUS_BUFSIZE 4096
28 #define INCLUDE_INLINE_FUNCS
31 * This structure array contains one entry per card. An entry looks
34 * { type, protocol, p0, p1, p2, NULL }
37 * 1 Teles 16.0 p0=irq p1=membase p2=iobase
38 * 2 Teles 8.0 p0=irq p1=membase
39 * 3 Teles 16.3 p0=irq p1=iobase
40 * 4 Creatix PNP p0=irq p1=IO0 (ISAC) p2=IO1 (HSCX)
41 * 5 AVM A1 (Fritz) p0=irq p1=iobase
42 * 6 ELSA PC [p0=iobase] or nothing (autodetect)
43 * 7 ELSA Quickstep p0=irq p1=iobase
44 * 8 Teles PCMCIA p0=irq p1=iobase
45 * 9 ITK ix1-micro p0=irq p1=iobase
46 * 10 ELSA PCMCIA p0=irq p1=iobase
47 * 11 Eicon.Diehl Diva p0=irq p1=iobase
48 * 12 Asuscom ISDNLink p0=irq p1=iobase
49 * 13 Teleint p0=irq p1=iobase
50 * 14 Teles 16.3c p0=irq p1=iobase
51 * 15 Sedlbauer speed p0=irq p1=iobase
52 * 15 Sedlbauer PC/104 p0=irq p1=iobase
53 * 15 Sedlbauer speed pci no parameter
54 * 16 USR Sportster internal p0=irq p1=iobase
55 * 17 MIC card p0=irq p1=iobase
56 * 18 ELSA Quickstep 1000PCI no parameter
57 * 19 Compaq ISDN S0 ISA card p0=irq p1=IO0 (HSCX) p2=IO1 (ISAC) p3=IO2
58 * 20 Travers Technologies NETjet-S PCI card
59 * 21 TELES PCI no parameter
60 * 22 Sedlbauer Speed Star p0=irq p1=iobase
62 * 24 Dr Neuhaus Niccy PnP/PCI card p0=irq p1=IO0 p2=IO1 (PnP only)
63 * 25 Teles S0Box p0=irq p1=iobase (from isapnp setup)
64 * 26 AVM A1 PCMCIA (Fritz) p0=irq p1=iobase
65 * 27 AVM PnP/PCI p0=irq p1=iobase (PCI no parameter)
66 * 28 Sedlbauer Speed Fax+ p0=irq p1=iobase (from isapnp setup)
67 * 29 Siemens I-Surf p0=irq p1=iobase p2=memory (from isapnp setup)
68 * 30 ACER P10 p0=irq p1=iobase (from isapnp setup)
69 * 31 HST Saphir p0=irq p1=iobase
71 * 33 Scitel Quadro p0=subcontroller (4*S0, subctrl 1...4)
73 * 35 HFC 2BDS0 PCI none
74 * 36 Winbond 6692 PCI none
75 * 37 HFC 2BDS0 S+/SP p0=irq p1=iobase
76 * 38 Travers Technologies NETspider-U PCI card
77 * 39 HFC 2BDS0-SP PCMCIA p0=irq p1=iobase
78 * 40 hotplug interface
79 * 41 Formula-n enter:now ISDN PCI a/b none
81 * protocol can be either ISDN_PTYPE_EURO or ISDN_PTYPE_1TR6 or ISDN_PTYPE_NI1
86 const char *CardType[] = {
87 "No Card", "Teles 16.0", "Teles 8.0", "Teles 16.3",
88 "Creatix/Teles PnP", "AVM A1", "Elsa ML", "Elsa Quickstep",
89 "Teles PCMCIA", "ITK ix1-micro Rev.2", "Elsa PCMCIA",
90 "Eicon.Diehl Diva", "ISDNLink", "TeleInt", "Teles 16.3c",
91 "Sedlbauer Speed Card", "USR Sportster", "ith mic Linux",
92 "Elsa PCI", "Compaq ISA", "NETjet-S", "Teles PCI",
93 "Sedlbauer Speed Star (PCMCIA)", "AMD 7930", "NICCY", "S0Box",
94 "AVM A1 (PCMCIA)", "AVM Fritz PnP/PCI", "Sedlbauer Speed Fax +",
95 "Siemens I-Surf", "Acer P10", "HST Saphir", "Telekom A4T",
96 "Scitel Quadro", "Gazel", "HFC 2BDS0 PCI", "Winbond 6692",
97 "HFC 2BDS0 SX", "NETspider-U", "HFC-2BDS0-SP PCMCIA",
98 "Hotplug", "Formula-n enter:now PCI a/b",
101 void HiSax_closecard(int cardnr);
103 #ifdef CONFIG_HISAX_ELSA
104 #define DEFAULT_CARD ISDN_CTYPE_ELSA
105 #define DEFAULT_CFG {0,0,0,0}
106 int elsa_init_pcmcia(void *, int, int *, int);
107 EXPORT_SYMBOL(elsa_init_pcmcia);
110 #ifdef CONFIG_HISAX_AVM_A1
113 #define DEFAULT_CARD ISDN_CTYPE_A1
114 #define DEFAULT_CFG {10,0x340,0,0}
117 #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
120 #define DEFAULT_CARD ISDN_CTYPE_A1_PCMCIA
121 #define DEFAULT_CFG {11,0x170,0,0}
122 int avm_a1_init_pcmcia(void *, int, int *, int);
123 EXPORT_SYMBOL(avm_a1_init_pcmcia);
126 #ifdef CONFIG_HISAX_FRITZPCI
129 #define DEFAULT_CARD ISDN_CTYPE_FRITZPCI
130 #define DEFAULT_CFG {0,0,0,0}
133 #ifdef CONFIG_HISAX_16_3
136 #define DEFAULT_CARD ISDN_CTYPE_16_3
137 #define DEFAULT_CFG {15,0x180,0,0}
140 #ifdef CONFIG_HISAX_S0BOX
143 #define DEFAULT_CARD ISDN_CTYPE_S0BOX
144 #define DEFAULT_CFG {7,0x378,0,0}
147 #ifdef CONFIG_HISAX_16_0
150 #define DEFAULT_CARD ISDN_CTYPE_16_0
151 #define DEFAULT_CFG {15,0xd0000,0xd80,0}
154 #ifdef CONFIG_HISAX_TELESPCI
157 #define DEFAULT_CARD ISDN_CTYPE_TELESPCI
158 #define DEFAULT_CFG {0,0,0,0}
161 #ifdef CONFIG_HISAX_IX1MICROR2
164 #define DEFAULT_CARD ISDN_CTYPE_IX1MICROR2
165 #define DEFAULT_CFG {5,0x390,0,0}
168 #ifdef CONFIG_HISAX_DIEHLDIVA
171 #define DEFAULT_CARD ISDN_CTYPE_DIEHLDIVA
172 #define DEFAULT_CFG {0,0x0,0,0}
175 #ifdef CONFIG_HISAX_ASUSCOM
178 #define DEFAULT_CARD ISDN_CTYPE_ASUSCOM
179 #define DEFAULT_CFG {5,0x200,0,0}
182 #ifdef CONFIG_HISAX_TELEINT
185 #define DEFAULT_CARD ISDN_CTYPE_TELEINT
186 #define DEFAULT_CFG {5,0x300,0,0}
189 #ifdef CONFIG_HISAX_SEDLBAUER
192 #define DEFAULT_CARD ISDN_CTYPE_SEDLBAUER
193 #define DEFAULT_CFG {11,0x270,0,0}
194 int sedl_init_pcmcia(void *, int, int *, int);
195 EXPORT_SYMBOL(sedl_init_pcmcia);
198 #ifdef CONFIG_HISAX_SPORTSTER
201 #define DEFAULT_CARD ISDN_CTYPE_SPORTSTER
202 #define DEFAULT_CFG {7,0x268,0,0}
205 #ifdef CONFIG_HISAX_MIC
208 #define DEFAULT_CARD ISDN_CTYPE_MIC
209 #define DEFAULT_CFG {12,0x3e0,0,0}
212 #ifdef CONFIG_HISAX_NETJET
215 #define DEFAULT_CARD ISDN_CTYPE_NETJET_S
216 #define DEFAULT_CFG {0,0,0,0}
219 #ifdef CONFIG_HISAX_HFCS
222 #define DEFAULT_CARD ISDN_CTYPE_TELES3C
223 #define DEFAULT_CFG {5,0x500,0,0}
226 #ifdef CONFIG_HISAX_HFC_PCI
229 #define DEFAULT_CARD ISDN_CTYPE_HFC_PCI
230 #define DEFAULT_CFG {0,0,0,0}
233 #ifdef CONFIG_HISAX_HFC_SX
236 #define DEFAULT_CARD ISDN_CTYPE_HFC_SX
237 #define DEFAULT_CFG {5,0x2E0,0,0}
238 int hfc_init_pcmcia(void *, int, int *, int);
239 EXPORT_SYMBOL(hfc_init_pcmcia);
243 #ifdef CONFIG_HISAX_AMD7930
246 #define DEFAULT_CARD ISDN_CTYPE_AMD7930
247 #define DEFAULT_CFG {12,0x3e0,0,0}
250 #ifdef CONFIG_HISAX_NICCY
253 #define DEFAULT_CARD ISDN_CTYPE_NICCY
254 #define DEFAULT_CFG {0,0x0,0,0}
257 #ifdef CONFIG_HISAX_ISURF
260 #define DEFAULT_CARD ISDN_CTYPE_ISURF
261 #define DEFAULT_CFG {5,0x100,0xc8000,0}
264 #ifdef CONFIG_HISAX_HSTSAPHIR
267 #define DEFAULT_CARD ISDN_CTYPE_HSTSAPHIR
268 #define DEFAULT_CFG {5,0x250,0,0}
271 #ifdef CONFIG_HISAX_BKM_A4T
274 #define DEFAULT_CARD ISDN_CTYPE_BKM_A4T
275 #define DEFAULT_CFG {0,0x0,0,0}
278 #ifdef CONFIG_HISAX_SCT_QUADRO
281 #define DEFAULT_CARD ISDN_CTYPE_SCT_QUADRO
282 #define DEFAULT_CFG {1,0x0,0,0}
285 #ifdef CONFIG_HISAX_GAZEL
288 #define DEFAULT_CARD ISDN_CTYPE_GAZEL
289 #define DEFAULT_CFG {15,0x180,0,0}
292 #ifdef CONFIG_HISAX_W6692
295 #define DEFAULT_CARD ISDN_CTYPE_W6692
296 #define DEFAULT_CFG {0,0,0,0}
299 #ifdef CONFIG_HISAX_NETJET_U
302 #define DEFAULT_CARD ISDN_CTYPE_NETJET_U
303 #define DEFAULT_CFG {0,0,0,0}
306 #ifdef CONFIG_HISAX_1TR6
307 #define DEFAULT_PROTO ISDN_PTYPE_1TR6
308 #define DEFAULT_PROTO_NAME "1TR6"
310 #ifdef CONFIG_HISAX_NI1
312 #define DEFAULT_PROTO ISDN_PTYPE_NI1
313 #undef DEFAULT_PROTO_NAME
314 #define DEFAULT_PROTO_NAME "NI1"
316 #ifdef CONFIG_HISAX_EURO
318 #define DEFAULT_PROTO ISDN_PTYPE_EURO
319 #undef DEFAULT_PROTO_NAME
320 #define DEFAULT_PROTO_NAME "EURO"
322 #ifndef DEFAULT_PROTO
323 #define DEFAULT_PROTO ISDN_PTYPE_UNKNOWN
324 #define DEFAULT_PROTO_NAME "UNKNOWN"
327 #define DEFAULT_CARD 0
328 #define DEFAULT_CFG {0,0,0,0}
331 int hisax_init_pcmcia(void *, int *, struct IsdnCard *);
332 EXPORT_SYMBOL(hisax_init_pcmcia);
333 EXPORT_SYMBOL(HiSax_closecard);
335 #define FIRST_CARD { \
342 struct IsdnCard cards[HISAX_MAX_CARDS] = {
346 #define HISAX_IDSIZE (HISAX_MAX_CARDS*8)
347 static char HiSaxID[HISAX_IDSIZE] __devinitdata = { 0, };
349 char *HiSax_id __devinitdata = HiSaxID;
351 /* Variables for insmod */
352 static int type[HISAX_MAX_CARDS] __devinitdata = { 0, };
353 static int protocol[HISAX_MAX_CARDS] __devinitdata = { 0, };
354 static int io[HISAX_MAX_CARDS] __devinitdata = { 0, };
356 #ifdef CONFIG_HISAX_16_3
359 #ifdef CONFIG_HISAX_NICCY
364 static int io0[HISAX_MAX_CARDS] __devinitdata = { 0, };
365 static int io1[HISAX_MAX_CARDS] __devinitdata = { 0, };
367 static int irq[HISAX_MAX_CARDS] __devinitdata = { 0, };
368 static int mem[HISAX_MAX_CARDS] __devinitdata = { 0, };
369 static char *id __devinitdata = HiSaxID;
371 #define PARM_PARA "1-" __MODULE_STRING(HISAX_MAX_CARDS) "i"
373 MODULE_DESCRIPTION("ISDN4Linux: Driver for passive ISDN cards");
374 MODULE_AUTHOR("Karsten Keil");
375 MODULE_LICENSE("GPL");
376 MODULE_PARM(type, PARM_PARA);
377 MODULE_PARM(protocol, PARM_PARA);
378 MODULE_PARM(io, PARM_PARA);
379 MODULE_PARM(irq, PARM_PARA);
380 MODULE_PARM(mem, PARM_PARA);
381 MODULE_PARM(id, "s");
383 MODULE_PARM(io0, PARM_PARA);
384 MODULE_PARM(io1, PARM_PARA);
390 extern char *l1_revision;
391 extern char *l2_revision;
392 extern char *l3_revision;
393 extern char *lli_revision;
394 extern char *tei_revision;
396 char *HiSax_getrev(const char *revision)
401 if ((p = strchr(revision, ':'))) {
403 p = strchr(rev, '$');
410 void __init HiSaxVersion(void)
414 printk(KERN_INFO "HiSax: Linux Driver for passive ISDN cards\n");
416 printk(KERN_INFO "HiSax: Version 3.5 (module)\n");
418 printk(KERN_INFO "HiSax: Version 3.5 (kernel)\n");
420 strcpy(tmp, l1_revision);
421 printk(KERN_INFO "HiSax: Layer1 Revision %s\n", HiSax_getrev(tmp));
422 strcpy(tmp, l2_revision);
423 printk(KERN_INFO "HiSax: Layer2 Revision %s\n", HiSax_getrev(tmp));
424 strcpy(tmp, tei_revision);
425 printk(KERN_INFO "HiSax: TeiMgr Revision %s\n", HiSax_getrev(tmp));
426 strcpy(tmp, l3_revision);
427 printk(KERN_INFO "HiSax: Layer3 Revision %s\n", HiSax_getrev(tmp));
428 strcpy(tmp, lli_revision);
429 printk(KERN_INFO "HiSax: LinkLayer Revision %s\n",
431 certification_check(1);
435 #define MAX_ARG (HISAX_MAX_CARDS*5)
436 static int __init HiSax_setup(char *line)
439 int ints[MAX_ARG + 1];
442 str = get_options(line, MAX_ARG, ints);
444 printk(KERN_DEBUG "HiSax_setup: argc(%d) str(%s)\n", argc, str);
447 while (argc && (i < HISAX_MAX_CARDS)) {
448 cards[i].protocol = DEFAULT_PROTO;
450 cards[i].typ = ints[j];
455 cards[i].protocol = ints[j];
460 cards[i].para[0] = ints[j];
465 cards[i].para[1] = ints[j];
470 cards[i].para[2] = ints[j];
477 if (strlen(str) < HISAX_IDSIZE)
478 strcpy(HiSaxID, str);
480 printk(KERN_WARNING "HiSax: ID too long!");
482 strcpy(HiSaxID, "HiSax");
488 __setup("hisax=", HiSax_setup);
492 extern int setup_teles0(struct IsdnCard *card);
496 extern int setup_teles3(struct IsdnCard *card);
500 extern int setup_s0box(struct IsdnCard *card);
504 extern int setup_telespci(struct IsdnCard *card);
508 extern int setup_avm_a1(struct IsdnCard *card);
511 #if CARD_AVM_A1_PCMCIA
512 extern int setup_avm_a1_pcmcia(struct IsdnCard *card);
516 extern int setup_avm_pcipnp(struct IsdnCard *card);
520 extern int setup_elsa(struct IsdnCard *card);
524 extern int setup_ix1micro(struct IsdnCard *card);
528 extern int setup_diva(struct IsdnCard *card);
532 extern int setup_asuscom(struct IsdnCard *card);
536 extern int setup_TeleInt(struct IsdnCard *card);
540 extern int setup_sedlbauer(struct IsdnCard *card);
544 extern int setup_sportster(struct IsdnCard *card);
548 extern int setup_mic(struct IsdnCard *card);
552 extern int setup_netjet_s(struct IsdnCard *card);
556 extern int setup_hfcs(struct IsdnCard *card);
560 extern int setup_hfcpci(struct IsdnCard *card);
564 extern int setup_hfcsx(struct IsdnCard *card);
568 extern int setup_amd7930(struct IsdnCard *card);
572 extern int setup_niccy(struct IsdnCard *card);
576 extern int setup_isurf(struct IsdnCard *card);
580 extern int setup_saphir(struct IsdnCard *card);
584 extern int setup_testemu(struct IsdnCard *card);
588 extern int setup_bkm_a4t(struct IsdnCard *card);
592 extern int setup_sct_quadro(struct IsdnCard *card);
596 extern int setup_gazel(struct IsdnCard *card);
600 extern int setup_w6692(struct IsdnCard *card);
604 extern int setup_netjet_u(struct IsdnCard *card);
607 #if CARD_FN_ENTERNOW_PCI
608 extern int setup_enternow_pci(struct IsdnCard *card);
612 * Find card with given driverId
614 static inline struct IsdnCardState *hisax_findcard(int driverid)
618 for (i = 0; i < nrcards; i++)
620 if (cards[i].cs->myid == driverid)
626 * Find card with given card number
628 struct IsdnCardState *hisax_get_card(int cardnr)
630 if ((cardnr <= nrcards) && (cardnr > 0))
631 if (cards[cardnr - 1].cs)
632 return cards[cardnr - 1].cs;
636 int HiSax_readstatus(u_char * buf, int len, int user, int id, int channel)
640 struct IsdnCardState *cs = hisax_findcard(id);
643 if (len > HISAX_STATUS_BUFSIZE) {
645 "HiSax: status overflow readstat %d/%d\n",
646 len, HISAX_STATUS_BUFSIZE);
648 count = cs->status_end - cs->status_read + 1;
652 copy_to_user(p, cs->status_read, count);
654 memcpy(p, cs->status_read, count);
655 cs->status_read += count;
656 if (cs->status_read > cs->status_end)
657 cs->status_read = cs->status_buf;
661 if (count > HISAX_STATUS_BUFSIZE)
662 cnt = HISAX_STATUS_BUFSIZE;
666 copy_to_user(p, cs->status_read, cnt);
668 memcpy(p, cs->status_read, cnt);
670 cs->status_read += cnt % HISAX_STATUS_BUFSIZE;
676 "HiSax: if_readstatus called with invalid driverId!\n");
681 int jiftime(char *s, long mark)
686 *s-- = mark % 10 + '0';
688 *s-- = mark % 10 + '0';
691 *s-- = mark % 10 + '0';
693 *s-- = mark % 6 + '0';
696 *s-- = mark % 10 + '0';
698 *s-- = mark % 10 + '0';
702 static u_char tmpbuf[HISAX_STATUS_BUFSIZE];
704 void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt,
707 /* if head == NULL the fmt contains the full info */
719 p += jiftime(p, jiffies);
720 p += sprintf(p, " %s", head);
721 p += vsprintf(p, fmt, args);
731 printk(KERN_WARNING "HiSax: No CardStatus for message %s",
733 restore_flags(flags);
736 if (len > HISAX_STATUS_BUFSIZE) {
737 printk(KERN_WARNING "HiSax: status overflow %d/%d\n",
738 len, HISAX_STATUS_BUFSIZE);
739 restore_flags(flags);
743 i = cs->status_end - cs->status_write + 1;
747 memcpy(cs->status_write, p, i);
748 cs->status_write += i;
749 if (cs->status_write > cs->status_end)
750 cs->status_write = cs->status_buf;
753 memcpy(cs->status_write, p, len);
754 cs->status_write += len;
756 #ifdef KERNELSTACK_DEBUG
757 i = (ulong) & len - current->kernel_stack_page;
758 sprintf(tmpbuf, "kstack %s %lx use %ld\n", current->comm,
759 current->kernel_stack_page, i);
760 len = strlen(tmpbuf);
761 for (p = tmpbuf, i = len; i > 0; i--, p++) {
762 *cs->status_write++ = *p;
763 if (cs->status_write > cs->status_end)
764 cs->status_write = cs->status_buf;
768 restore_flags(flags);
770 ic.command = ISDN_STAT_STAVAIL;
771 ic.driver = cs->myid;
773 cs->iif.statcallb(&ic);
777 void HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...)
782 VHiSax_putstatus(cs, head, fmt, args);
786 int ll_run(struct IsdnCardState *cs, int addfeatures)
793 ic.driver = cs->myid;
794 ic.command = ISDN_STAT_RUN;
795 cs->iif.features |= addfeatures;
796 cs->iif.statcallb(&ic);
797 restore_flags(flags);
801 void ll_stop(struct IsdnCardState *cs)
805 ic.command = ISDN_STAT_STOP;
806 ic.driver = cs->myid;
807 cs->iif.statcallb(&ic);
808 // CallcFreeChan(cs);
811 static void ll_unload(struct IsdnCardState *cs)
815 ic.command = ISDN_STAT_UNLOAD;
816 ic.driver = cs->myid;
817 cs->iif.statcallb(&ic);
819 kfree(cs->status_buf);
820 cs->status_read = NULL;
821 cs->status_write = NULL;
822 cs->status_end = NULL;
826 static void closecard(int cardnr)
828 struct IsdnCardState *csta = cards[cardnr].cs;
830 if (csta->bcs->BC_Close != NULL) {
831 csta->bcs->BC_Close(csta->bcs + 1);
832 csta->bcs->BC_Close(csta->bcs);
835 skb_queue_purge(&csta->rq);
836 skb_queue_purge(&csta->sq);
842 dev_kfree_skb(csta->tx_skb);
845 if (csta->DC_Close != NULL) {
846 csta->DC_Close(csta);
849 csta->cardmsg(csta, CARD_RELEASE, NULL);
850 if (csta->dbusytimer.function != NULL) // FIXME?
851 del_timer(&csta->dbusytimer);
855 static int __devinit init_card(struct IsdnCardState *cs)
857 int irq_cnt, cnt = 3;
861 return cs->cardmsg(cs, CARD_INIT, NULL);
864 irq_cnt = kstat_irqs(cs->irq);
865 printk(KERN_INFO "%s: IRQ %d count %d\n", CardType[cs->typ],
867 if (request_irq(cs->irq, cs->irq_func, cs->irq_flags, "HiSax", cs)) {
868 printk(KERN_WARNING "HiSax: couldn't get interrupt %d\n",
870 restore_flags(flags);
874 cs->cardmsg(cs, CARD_INIT, NULL);
876 set_current_state(TASK_UNINTERRUPTIBLE);
878 schedule_timeout((10 * HZ) / 1000);
879 restore_flags(flags);
880 printk(KERN_INFO "%s: IRQ %d count %d\n",
881 CardType[cs->typ], cs->irq, kstat_irqs(cs->irq));
882 if (kstat_irqs(cs->irq) == irq_cnt) {
884 "%s: IRQ(%d) getting no interrupts during init %d\n",
885 CardType[cs->typ], cs->irq, 4 - cnt);
887 free_irq(cs->irq, cs);
890 cs->cardmsg(cs, CARD_RESET, NULL);
894 cs->cardmsg(cs, CARD_TEST, NULL);
898 restore_flags(flags);
902 static int __devinit checkcard(int cardnr, char *id, int *busy_flag)
906 struct IsdnCard *card = cards + cardnr;
907 struct IsdnCardState *cs;
911 cs = kmalloc(sizeof(struct IsdnCardState), GFP_ATOMIC);
914 "HiSax: No memory for IsdnCardState(card %d)\n",
918 memset(cs, 0, sizeof(struct IsdnCardState));
920 cs->chanlimit = 2; /* maximum B-channel number */
921 cs->logecho = 0; /* No echo logging */
923 cs->debug = L1_DEB_WARN;
925 cs->busy_flag = busy_flag;
926 cs->irq_flags = I4L_IRQ_FLAG;
928 if (card->protocol == ISDN_PTYPE_NI1)
929 test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);
931 test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);
933 cs->protocol = card->protocol;
935 if (card->typ <= 0 || card->typ > ISDN_CTYPE_COUNT) {
937 "HiSax: Card Type %d out of range\n", card->typ);
940 if (!(cs->dlog = kmalloc(MAX_DLOG_SPACE, GFP_ATOMIC))) {
942 "HiSax: No memory for dlog(card %d)\n", cardnr + 1);
945 if (!(cs->status_buf = kmalloc(HISAX_STATUS_BUFSIZE, GFP_ATOMIC))) {
947 "HiSax: No memory for status_buf(card %d)\n",
952 cs->status_read = cs->status_buf;
953 cs->status_write = cs->status_buf;
954 cs->status_end = cs->status_buf + HISAX_STATUS_BUFSIZE - 1;
956 strcpy(cs->iif.id, id);
957 cs->iif.channels = 2;
958 cs->iif.maxbufsize = MAX_DATA_SIZE;
959 cs->iif.hl_hdrlen = MAX_HEADER_LEN;
961 ISDN_FEATURE_L2_X75I |
962 ISDN_FEATURE_L2_HDLC |
963 ISDN_FEATURE_L2_HDLC_56K |
964 ISDN_FEATURE_L2_TRANS |
965 ISDN_FEATURE_L3_TRANS |
966 #ifdef CONFIG_HISAX_1TR6
967 ISDN_FEATURE_P_1TR6 |
969 #ifdef CONFIG_HISAX_EURO
970 ISDN_FEATURE_P_EURO |
972 #ifdef CONFIG_HISAX_NI1
977 cs->iif.command = HiSax_command;
978 cs->iif.writecmd = NULL;
979 cs->iif.writebuf_skb = HiSax_writebuf_skb;
980 cs->iif.readstat = HiSax_readstatus;
981 register_isdn(&cs->iif);
982 cs->myid = cs->iif.channels;
984 "HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr + 1,
985 (card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" :
986 (card->protocol == ISDN_PTYPE_EURO) ? "EDSS1" :
987 (card->protocol == ISDN_PTYPE_LEASED) ? "LEASED" :
988 (card->protocol == ISDN_PTYPE_NI1) ? "NI1" :
989 "NONE", cs->iif.id, cs->myid);
992 case ISDN_CTYPE_16_0:
994 ret = setup_teles0(card);
998 case ISDN_CTYPE_16_3:
1000 case ISDN_CTYPE_TELESPCMCIA:
1001 case ISDN_CTYPE_COMPAQ_ISA:
1002 ret = setup_teles3(card);
1006 case ISDN_CTYPE_S0BOX:
1007 ret = setup_s0box(card);
1011 case ISDN_CTYPE_TELESPCI:
1012 ret = setup_telespci(card);
1017 ret = setup_avm_a1(card);
1020 #if CARD_AVM_A1_PCMCIA
1021 case ISDN_CTYPE_A1_PCMCIA:
1022 ret = setup_avm_a1_pcmcia(card);
1026 case ISDN_CTYPE_FRITZPCI:
1027 ret = setup_avm_pcipnp(card);
1031 case ISDN_CTYPE_ELSA:
1032 case ISDN_CTYPE_ELSA_PNP:
1033 case ISDN_CTYPE_ELSA_PCMCIA:
1034 case ISDN_CTYPE_ELSA_PCI:
1035 ret = setup_elsa(card);
1039 case ISDN_CTYPE_IX1MICROR2:
1040 ret = setup_ix1micro(card);
1044 case ISDN_CTYPE_DIEHLDIVA:
1045 ret = setup_diva(card);
1049 case ISDN_CTYPE_ASUSCOM:
1050 ret = setup_asuscom(card);
1054 case ISDN_CTYPE_TELEINT:
1055 ret = setup_TeleInt(card);
1059 case ISDN_CTYPE_SEDLBAUER:
1060 case ISDN_CTYPE_SEDLBAUER_PCMCIA:
1061 case ISDN_CTYPE_SEDLBAUER_FAX:
1062 ret = setup_sedlbauer(card);
1066 case ISDN_CTYPE_SPORTSTER:
1067 ret = setup_sportster(card);
1071 case ISDN_CTYPE_MIC:
1072 ret = setup_mic(card);
1076 case ISDN_CTYPE_NETJET_S:
1077 ret = setup_netjet_s(card);
1081 case ISDN_CTYPE_TELES3C:
1082 case ISDN_CTYPE_ACERP10:
1083 ret = setup_hfcs(card);
1087 case ISDN_CTYPE_HFC_PCI:
1088 ret = setup_hfcpci(card);
1092 case ISDN_CTYPE_HFC_SX:
1093 ret = setup_hfcsx(card);
1097 case ISDN_CTYPE_NICCY:
1098 ret = setup_niccy(card);
1102 case ISDN_CTYPE_AMD7930:
1103 ret = setup_amd7930(card);
1107 case ISDN_CTYPE_ISURF:
1108 ret = setup_isurf(card);
1112 case ISDN_CTYPE_HSTSAPHIR:
1113 ret = setup_saphir(card);
1117 case ISDN_CTYPE_TESTEMU:
1118 ret = setup_testemu(card);
1122 case ISDN_CTYPE_BKM_A4T:
1123 ret = setup_bkm_a4t(card);
1127 case ISDN_CTYPE_SCT_QUADRO:
1128 ret = setup_sct_quadro(card);
1132 case ISDN_CTYPE_GAZEL:
1133 ret = setup_gazel(card);
1137 case ISDN_CTYPE_W6692:
1138 ret = setup_w6692(card);
1142 case ISDN_CTYPE_NETJET_U:
1143 ret = setup_netjet_u(card);
1146 #if CARD_FN_ENTERNOW_PCI
1147 case ISDN_CTYPE_ENTERNOW:
1148 ret = setup_enternow_pci(card);
1151 case ISDN_CTYPE_DYNAMIC:
1156 "HiSax: Support for %s Card not selected\n",
1157 CardType[card->typ]);
1165 if (!(cs->rcvbuf = kmalloc(MAX_DFRAME_LEN_L1, GFP_ATOMIC))) {
1166 printk(KERN_WARNING "HiSax: No memory for isac rcvbuf\n");
1174 cs->tqueue.sync = 0;
1175 cs->tqueue.data = cs;
1177 skb_queue_head_init(&cs->rq);
1178 skb_queue_head_init(&cs->sq);
1180 init_bcstate(cs, 0);
1181 init_bcstate(cs, 1);
1183 /* init_card only handles interrupts which are not */
1184 /* used here for the loadable driver */
1185 switch (card->typ) {
1186 case ISDN_CTYPE_DYNAMIC:
1190 ret = init_card(cs);
1198 init_tei(cs, cs->protocol);
1199 ret = CallcNewChan(cs);
1205 /* ISAR needs firmware download first */
1206 if (!test_bit(HW_ISAR, &cs->HW_Flags))
1218 restore_flags(flags);
1222 void __devinit HiSax_shiftcards(int idx)
1226 for (i = idx; i < (HISAX_MAX_CARDS - 1); i++)
1227 memcpy(&cards[i], &cards[i + 1], sizeof(cards[i]));
1230 int __devinit HiSax_inithardware(int *busy_flag)
1237 char *next_id = HiSax_id;
1240 if (strchr(HiSax_id, ','))
1242 else if (strchr(HiSax_id, '%'))
1245 while (i < nrcards) {
1246 if (cards[i].typ < 1)
1249 if ((next_id = strchr(id, t))) {
1258 sprintf(ids, "%s%d", id, i);
1260 if (checkcard(i, ids, busy_flag)) {
1264 /* make sure we don't oops the module */
1265 if (cards[i].typ > 0 && cards[i].typ <= ISDN_CTYPE_COUNT) {
1267 "HiSax: Card %s not installed !\n",
1268 CardType[cards[i].typ]);
1270 HiSax_shiftcards(i);
1277 void HiSax_closecard(int cardnr)
1279 int i, last = nrcards - 1;
1283 if (cards[cardnr].cs) {
1284 ll_stop(cards[cardnr].cs);
1285 release_tei(cards[cardnr].cs);
1286 CallcFreeChan(cards[cardnr].cs);
1289 if (cards[cardnr].cs->irq)
1290 free_irq(cards[cardnr].cs->irq, cards[cardnr].cs);
1291 kfree((void *) cards[cardnr].cs);
1292 cards[cardnr].cs = NULL;
1296 cards[i] = cards[i + 1];
1302 void HiSax_reportcard(int cardnr, int sel)
1304 struct IsdnCardState *cs = cards[cardnr].cs;
1306 printk(KERN_DEBUG "HiSax: reportcard No %d\n", cardnr + 1);
1307 printk(KERN_DEBUG "HiSax: Type %s\n", CardType[cs->typ]);
1308 printk(KERN_DEBUG "HiSax: debuglevel %x\n", cs->debug);
1309 printk(KERN_DEBUG "HiSax: HiSax_reportcard address 0x%lX\n",
1310 (ulong) & HiSax_reportcard);
1311 printk(KERN_DEBUG "HiSax: cs 0x%lX\n", (ulong) cs);
1312 printk(KERN_DEBUG "HiSax: HW_Flags %lx bc0 flg %lx bc1 flg %lx\n",
1313 cs->HW_Flags, cs->bcs[0].Flag, cs->bcs[1].Flag);
1314 printk(KERN_DEBUG "HiSax: bcs 0 mode %d ch%d\n",
1315 cs->bcs[0].mode, cs->bcs[0].channel);
1316 printk(KERN_DEBUG "HiSax: bcs 1 mode %d ch%d\n",
1317 cs->bcs[1].mode, cs->bcs[1].channel);
1318 #ifdef ERROR_STATISTIC
1319 printk(KERN_DEBUG "HiSax: dc errors(rx,crc,tx) %d,%d,%d\n",
1320 cs->err_rx, cs->err_crc, cs->err_tx);
1322 "HiSax: bc0 errors(inv,rdo,crc,tx) %d,%d,%d,%d\n",
1323 cs->bcs[0].err_inv, cs->bcs[0].err_rdo, cs->bcs[0].err_crc,
1326 "HiSax: bc1 errors(inv,rdo,crc,tx) %d,%d,%d,%d\n",
1327 cs->bcs[1].err_inv, cs->bcs[1].err_rdo, cs->bcs[1].err_crc,
1333 cs->bcs[0].err_inv = 0;
1334 cs->bcs[0].err_rdo = 0;
1335 cs->bcs[0].err_crc = 0;
1336 cs->bcs[0].err_tx = 0;
1337 cs->bcs[1].err_inv = 0;
1338 cs->bcs[1].err_rdo = 0;
1339 cs->bcs[1].err_crc = 0;
1340 cs->bcs[1].err_tx = 0;
1345 static int __init HiSax_init(void)
1354 retval = CallcNew();
1357 retval = Isdnl3New();
1360 retval = Isdnl2New();
1366 retval = Isdnl1New();
1372 /* We 'll register drivers later, but init basic functions */
1373 for (i = 0; i < HISAX_MAX_CARDS; i++)
1377 #ifdef CONFIG_HISAX_ELSA
1378 if (type[0] == ISDN_CTYPE_ELSA_PCMCIA) {
1379 /* we have exported and return in this case */
1383 #ifdef CONFIG_HISAX_SEDLBAUER
1384 if (type[0] == ISDN_CTYPE_SEDLBAUER_PCMCIA) {
1385 /* we have to export and return in this case */
1389 #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
1390 if (type[0] == ISDN_CTYPE_A1_PCMCIA) {
1391 /* we have to export and return in this case */
1395 #ifdef CONFIG_HISAX_HFC_SX
1396 if (type[0] == ISDN_CTYPE_HFC_SP_PCMCIA) {
1397 /* we have to export and return in this case */
1404 if (id) /* If id= string used */
1406 for (i = j = 0; j < HISAX_MAX_CARDS; i++) {
1407 cards[j].typ = type[i];
1409 cards[j].protocol = protocol[i];
1412 cards[j].protocol = DEFAULT_PROTO;
1415 case ISDN_CTYPE_16_0:
1416 cards[j].para[0] = irq[i];
1417 cards[j].para[1] = mem[i];
1418 cards[j].para[2] = io[i];
1421 case ISDN_CTYPE_8_0:
1422 cards[j].para[0] = irq[i];
1423 cards[j].para[1] = mem[i];
1427 case ISDN_CTYPE_PNP:
1428 case ISDN_CTYPE_NICCY:
1429 cards[j].para[0] = irq[i];
1430 cards[j].para[1] = io0[i];
1431 cards[j].para[2] = io1[i];
1433 case ISDN_CTYPE_COMPAQ_ISA:
1434 cards[j].para[0] = irq[i];
1435 cards[j].para[1] = io0[i];
1436 cards[j].para[2] = io1[i];
1437 cards[j].para[3] = io[i];
1440 case ISDN_CTYPE_ELSA:
1441 case ISDN_CTYPE_HFC_PCI:
1442 cards[j].para[0] = io[i];
1444 case ISDN_CTYPE_16_3:
1445 case ISDN_CTYPE_TELESPCMCIA:
1447 case ISDN_CTYPE_A1_PCMCIA:
1448 case ISDN_CTYPE_ELSA_PNP:
1449 case ISDN_CTYPE_ELSA_PCMCIA:
1450 case ISDN_CTYPE_IX1MICROR2:
1451 case ISDN_CTYPE_DIEHLDIVA:
1452 case ISDN_CTYPE_ASUSCOM:
1453 case ISDN_CTYPE_TELEINT:
1454 case ISDN_CTYPE_SEDLBAUER:
1455 case ISDN_CTYPE_SEDLBAUER_PCMCIA:
1456 case ISDN_CTYPE_SEDLBAUER_FAX:
1457 case ISDN_CTYPE_SPORTSTER:
1458 case ISDN_CTYPE_MIC:
1459 case ISDN_CTYPE_TELES3C:
1460 case ISDN_CTYPE_ACERP10:
1461 case ISDN_CTYPE_S0BOX:
1462 case ISDN_CTYPE_FRITZPCI:
1463 case ISDN_CTYPE_HSTSAPHIR:
1464 case ISDN_CTYPE_GAZEL:
1465 case ISDN_CTYPE_HFC_SX:
1466 case ISDN_CTYPE_HFC_SP_PCMCIA:
1467 cards[j].para[0] = irq[i];
1468 cards[j].para[1] = io[i];
1470 case ISDN_CTYPE_ISURF:
1471 cards[j].para[0] = irq[i];
1472 cards[j].para[1] = io[i];
1473 cards[j].para[2] = mem[i];
1475 case ISDN_CTYPE_ELSA_PCI:
1476 case ISDN_CTYPE_NETJET_S:
1477 case ISDN_CTYPE_AMD7930:
1478 case ISDN_CTYPE_TELESPCI:
1479 case ISDN_CTYPE_W6692:
1480 case ISDN_CTYPE_NETJET_U:
1482 case ISDN_CTYPE_BKM_A4T:
1484 case ISDN_CTYPE_SCT_QUADRO:
1486 cards[j].para[0] = irq[i];
1488 /* QUADRO is a 4 BRI card */
1489 cards[j++].para[0] = 1;
1490 /* we need to check if further cards can be added */
1491 if (j < HISAX_MAX_CARDS) {
1492 cards[j].typ = ISDN_CTYPE_SCT_QUADRO;
1493 cards[j].protocol = protocol[i];
1494 cards[j++].para[0] = 2;
1496 if (j < HISAX_MAX_CARDS) {
1497 cards[j].typ = ISDN_CTYPE_SCT_QUADRO;
1498 cards[j].protocol = protocol[i];
1499 cards[j++].para[0] = 3;
1501 if (j < HISAX_MAX_CARDS) {
1502 cards[j].typ = ISDN_CTYPE_SCT_QUADRO;
1503 cards[j].protocol = protocol[i];
1504 cards[j].para[0] = 4;
1513 "HiSax: Warning - no protocol specified\n");
1514 printk(KERN_WARNING "HiSax: using protocol %s\n",
1515 DEFAULT_PROTO_NAME);
1521 strcpy(HiSaxID, "HiSax");
1522 for (i = 0; i < HISAX_MAX_CARDS; i++)
1523 if (cards[i].typ > 0)
1525 printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
1526 nrcards, (nrcards > 1) ? "s" : "");
1528 /* Install only, if at least one card found */
1529 if (!HiSax_inithardware(NULL))
1545 static void __exit HiSax_exit(void)
1547 int cardnr = nrcards - 1;
1553 HiSax_closecard(cardnr--);
1559 restore_flags(flags);
1560 printk(KERN_INFO "HiSax module removed\n");
1563 #ifdef CONFIG_HISAX_ELSA
1564 int elsa_init_pcmcia(void *pcm_iob, int pcm_irq, int *busy_flag, int prot)
1570 /* Initialize all structs, even though we only accept
1573 for (i = 0; i < HISAX_MAX_CARDS; i++) {
1574 cards[i].para[0] = irq[i];
1575 cards[i].para[1] = io[i];
1576 cards[i].typ = type[i];
1578 cards[i].protocol = protocol[i];
1580 cards[i].protocol = DEFAULT_PROTO;
1583 cards[0].para[0] = pcm_irq;
1584 cards[0].para[1] = (int) pcm_iob;
1585 cards[0].protocol = prot;
1586 cards[0].typ = ISDN_CTYPE_ELSA_PCMCIA;
1591 strcpy(HiSaxID, "HiSax");
1592 for (i = 0; i < HISAX_MAX_CARDS; i++)
1593 if (cards[i].typ > 0)
1595 printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
1596 nrcards, (nrcards > 1) ? "s" : "");
1598 if (!HiSax_inithardware(busy_flag))
1600 printk(KERN_NOTICE "HiSax: module installed\n");
1606 #ifdef CONFIG_HISAX_HFC_SX
1607 int hfc_init_pcmcia(void *pcm_iob, int pcm_irq, int *busy_flag, int prot)
1613 /* Initialize all structs, even though we only accept
1616 for (i = 0; i < HISAX_MAX_CARDS; i++) {
1617 cards[i].para[0] = irq[i];
1618 cards[i].para[1] = io[i];
1619 cards[i].typ = type[i];
1621 cards[i].protocol = protocol[i];
1623 cards[i].protocol = DEFAULT_PROTO;
1626 cards[0].para[0] = pcm_irq;
1627 cards[0].para[1] = (int) pcm_iob;
1628 cards[0].protocol = prot;
1629 cards[0].typ = ISDN_CTYPE_HFC_SP_PCMCIA;
1634 strcpy(HiSaxID, "HiSax");
1635 for (i = 0; i < HISAX_MAX_CARDS; i++)
1636 if (cards[i].typ > 0)
1638 printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
1639 nrcards, (nrcards > 1) ? "s" : "");
1641 if (!HiSax_inithardware(busy_flag))
1643 printk(KERN_NOTICE "HiSax: module installed\n");
1649 #ifdef CONFIG_HISAX_SEDLBAUER
1650 int sedl_init_pcmcia(void *pcm_iob, int pcm_irq, int *busy_flag, int prot)
1656 /* Initialize all structs, even though we only accept
1659 for (i = 0; i < HISAX_MAX_CARDS; i++) {
1660 cards[i].para[0] = irq[i];
1661 cards[i].para[1] = io[i];
1662 cards[i].typ = type[i];
1664 cards[i].protocol = protocol[i];
1666 cards[i].protocol = DEFAULT_PROTO;
1669 cards[0].para[0] = pcm_irq;
1670 cards[0].para[1] = (int) pcm_iob;
1671 cards[0].protocol = prot;
1672 cards[0].typ = ISDN_CTYPE_SEDLBAUER_PCMCIA;
1677 strcpy(HiSaxID, "HiSax");
1678 for (i = 0; i < HISAX_MAX_CARDS; i++)
1679 if (cards[i].typ > 0)
1681 printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
1682 nrcards, (nrcards > 1) ? "s" : "");
1684 if (!HiSax_inithardware(busy_flag))
1686 printk(KERN_NOTICE "HiSax: module installed\n");
1692 #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
1693 int avm_a1_init_pcmcia(void *pcm_iob, int pcm_irq, int *busy_flag, int prot)
1699 /* Initialize all structs, even though we only accept
1702 for (i = 0; i < HISAX_MAX_CARDS; i++) {
1703 cards[i].para[0] = irq[i];
1704 cards[i].para[1] = io[i];
1705 cards[i].typ = type[i];
1707 cards[i].protocol = protocol[i];
1709 cards[i].protocol = DEFAULT_PROTO;
1712 cards[0].para[0] = pcm_irq;
1713 cards[0].para[1] = (int) pcm_iob;
1714 cards[0].protocol = prot;
1715 cards[0].typ = ISDN_CTYPE_A1_PCMCIA;
1720 strcpy(HiSaxID, "HiSax");
1721 for (i = 0; i < HISAX_MAX_CARDS; i++)
1722 if (cards[i].typ > 0)
1724 printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
1725 nrcards, (nrcards > 1) ? "s" : "");
1727 if (!HiSax_inithardware(busy_flag))
1729 printk(KERN_NOTICE "HiSax: module installed\n");
1735 int __devinit hisax_init_pcmcia(void *pcm_iob, int *busy_flag,
1736 struct IsdnCard *card)
1741 cards[nrcards] = *card;
1743 sprintf(ids, "HiSax%d", nrcards);
1745 sprintf(ids, "HiSax");
1746 if (!checkcard(nrcards, ids, busy_flag)) {
1754 #include "hisax_if.h"
1756 EXPORT_SYMBOL(hisax_register);
1757 EXPORT_SYMBOL(hisax_unregister);
1759 static void hisax_d_l1l2(struct hisax_if *ifc, int pr, void *arg);
1760 static void hisax_b_l1l2(struct hisax_if *ifc, int pr, void *arg);
1761 static void hisax_d_l2l1(struct PStack *st, int pr, void *arg);
1762 static void hisax_b_l2l1(struct PStack *st, int pr, void *arg);
1763 static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg);
1764 static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs);
1765 static void hisax_bc_close(struct BCState *bcs);
1766 static void hisax_bh(struct IsdnCardState *cs);
1767 static void EChannel_proc_rcv(struct hisax_d_if *d_if);
1769 int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
1770 char *name, int protocol)
1774 struct IsdnCardState *cs;
1776 for (i = 0; i < HISAX_MAX_CARDS; i++) {
1781 if (i >= HISAX_MAX_CARDS)
1784 cards[i].typ = ISDN_CTYPE_DYNAMIC;
1785 cards[i].protocol = protocol;
1786 sprintf(id, "%s%d", name, i);
1788 retval = checkcard(i, id, 0);
1789 if (retval == 0) { // yuck
1795 hisax_d_if->cs = cs;
1796 cs->hw.hisax_d_if = hisax_d_if;
1797 cs->cardmsg = hisax_cardmsg;
1798 cs->tqueue.routine = (void *) (void *) hisax_bh;
1799 cs->channel[0].d_st->l2.l2l1 = hisax_d_l2l1;
1800 for (i = 0; i < 2; i++) {
1801 cs->bcs[i].BC_SetStack = hisax_bc_setstack;
1802 cs->bcs[i].BC_Close = hisax_bc_close;
1804 b_if[i]->ifc.l1l2 = hisax_b_l1l2;
1806 hisax_d_if->b_if[i] = b_if[i];
1808 hisax_d_if->ifc.l1l2 = hisax_d_l1l2;
1809 skb_queue_head_init(&hisax_d_if->erq);
1810 clear_bit(0, &hisax_d_if->ph_state);
1815 void hisax_unregister(struct hisax_d_if *hisax_d_if)
1817 cards[hisax_d_if->cs->cardnr].typ = 0;
1818 HiSax_closecard(hisax_d_if->cs->cardnr);
1819 skb_queue_purge(&hisax_d_if->erq);
1824 static void hisax_sched_event(struct IsdnCardState *cs, int event)
1826 cs->event |= 1 << event;
1827 queue_task(&cs->tqueue, &tq_immediate);
1828 mark_bh(IMMEDIATE_BH);
1831 static void hisax_bh(struct IsdnCardState *cs)
1836 if (test_and_clear_bit(D_RCVBUFREADY, &cs->event))
1837 DChannel_proc_rcv(cs);
1838 if (test_and_clear_bit(E_RCVBUFREADY, &cs->event))
1839 EChannel_proc_rcv(cs->hw.hisax_d_if);
1840 if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) {
1841 if (test_bit(0, &cs->hw.hisax_d_if->ph_state))
1842 pr = PH_ACTIVATE | INDICATION;
1844 pr = PH_DEACTIVATE | INDICATION;
1845 for (st = cs->stlist; st; st = st->next)
1846 st->l1.l1l2(st, pr, NULL);
1851 static void hisax_b_sched_event(struct BCState *bcs, int event)
1853 bcs->event |= 1 << event;
1854 queue_task(&bcs->tqueue, &tq_immediate);
1855 mark_bh(IMMEDIATE_BH);
1858 static inline void D_L2L1(struct hisax_d_if *d_if, int pr, void *arg)
1860 struct hisax_if *ifc = (struct hisax_if *) d_if;
1861 ifc->l2l1(ifc, pr, arg);
1864 static inline void B_L2L1(struct hisax_b_if *b_if, int pr, void *arg)
1866 struct hisax_if *ifc = (struct hisax_if *) b_if;
1867 ifc->l2l1(ifc, pr, arg);
1870 static void hisax_d_l1l2(struct hisax_if *ifc, int pr, void *arg)
1872 struct hisax_d_if *d_if = (struct hisax_d_if *) ifc;
1873 struct IsdnCardState *cs = d_if->cs;
1875 struct sk_buff *skb;
1878 case PH_ACTIVATE | INDICATION:
1879 set_bit(0, &d_if->ph_state);
1880 hisax_sched_event(cs, D_L1STATECHANGE);
1882 case PH_DEACTIVATE | INDICATION:
1883 clear_bit(0, &d_if->ph_state);
1884 hisax_sched_event(cs, D_L1STATECHANGE);
1886 case PH_DATA | INDICATION:
1887 skb_queue_tail(&cs->rq, arg);
1888 hisax_sched_event(cs, D_RCVBUFREADY);
1890 case PH_DATA | CONFIRM:
1891 skb = skb_dequeue(&cs->sq);
1893 D_L2L1(d_if, PH_DATA | REQUEST, skb);
1896 clear_bit(FLG_L1_DBUSY, &cs->HW_Flags);
1897 for (st = cs->stlist; st; st = st->next) {
1898 if (test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags)) {
1899 st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
1904 case PH_DATA_E | INDICATION:
1905 skb_queue_tail(&d_if->erq, arg);
1906 hisax_sched_event(cs, E_RCVBUFREADY);
1909 printk("pr %#x\n", pr);
1914 static void hisax_b_l1l2(struct hisax_if *ifc, int pr, void *arg)
1916 struct hisax_b_if *b_if = (struct hisax_b_if *) ifc;
1917 struct BCState *bcs = b_if->bcs;
1918 struct PStack *st = bcs->st;
1919 struct sk_buff *skb;
1921 // FIXME use isdnl1?
1923 case PH_ACTIVATE | INDICATION:
1924 st->l1.l1l2(st, pr, NULL);
1926 case PH_DEACTIVATE | INDICATION:
1927 st->l1.l1l2(st, pr, NULL);
1928 bcs->hw.b_if = NULL;
1930 case PH_DATA | INDICATION:
1931 skb_queue_tail(&bcs->rqueue, arg);
1932 hisax_b_sched_event(bcs, B_RCVBUFREADY);
1934 case PH_DATA | CONFIRM:
1935 bcs->tx_cnt -= (int) arg;
1936 if (bcs->st->lli.l1writewakeup)
1937 bcs->st->lli.l1writewakeup(bcs->st, (int) arg);
1938 skb = skb_dequeue(&bcs->squeue);
1940 B_L2L1(b_if, PH_DATA | REQUEST, skb);
1943 clear_bit(BC_FLG_BUSY, &bcs->Flag);
1944 if (test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags)) {
1945 st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
1949 printk("hisax_b_l1l2 pr %#x\n", pr);
1954 static void hisax_d_l2l1(struct PStack *st, int pr, void *arg)
1956 struct IsdnCardState *cs = st->l1.hardware;
1957 struct hisax_d_if *hisax_d_if = cs->hw.hisax_d_if;
1958 struct sk_buff *skb = arg;
1961 case PH_DATA | REQUEST:
1962 case PH_PULL | INDICATION:
1963 if (cs->debug & DEB_DLOG_HEX)
1964 LogFrame(cs, skb->data, skb->len);
1965 if (cs->debug & DEB_DLOG_VERBOSE)
1966 dlogframe(cs, skb, 0);
1967 Logl2Frame(cs, skb, "PH_DATA_REQ", 0);
1969 if (!test_and_set_bit(FLG_L1_DBUSY, &cs->HW_Flags))
1970 D_L2L1(hisax_d_if, PH_DATA | REQUEST, skb);
1972 skb_queue_tail(&cs->sq, skb);
1974 case PH_PULL | REQUEST:
1975 if (!test_bit(FLG_L1_DBUSY, &cs->HW_Flags))
1976 st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
1978 set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
1981 D_L2L1(hisax_d_if, pr, arg);
1986 static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg)
1991 static void hisax_b_l2l1(struct PStack *st, int pr, void *arg)
1993 struct BCState *bcs = st->l1.bcs;
1994 struct hisax_b_if *b_if = bcs->hw.b_if;
1997 case PH_ACTIVATE | REQUEST:
1998 B_L2L1(b_if, pr, (void *) st->l1.mode);
2000 case PH_DATA | REQUEST:
2001 case PH_PULL | INDICATION:
2003 if (!test_and_set_bit(BC_FLG_BUSY, &bcs->Flag)) {
2004 B_L2L1(b_if, PH_DATA | REQUEST, arg);
2006 skb_queue_tail(&bcs->squeue, arg);
2009 case PH_PULL | REQUEST:
2010 if (!test_bit(BC_FLG_BUSY, &bcs->Flag))
2011 st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
2013 set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
2016 B_L2L1(b_if, pr, arg);
2021 static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs)
2023 struct IsdnCardState *cs = st->l1.hardware;
2024 struct hisax_d_if *hisax_d_if = cs->hw.hisax_d_if;
2026 bcs->channel = st->l1.bc;
2028 bcs->hw.b_if = hisax_d_if->b_if[st->l1.bc];
2029 hisax_d_if->b_if[st->l1.bc]->bcs = bcs;
2032 st->l2.l2l1 = hisax_b_l2l1;
2033 setstack_manager(st);
2036 skb_queue_head_init(&bcs->rqueue);
2037 skb_queue_head_init(&bcs->squeue);
2041 static void hisax_bc_close(struct BCState *bcs)
2043 struct hisax_b_if *b_if = bcs->hw.b_if;
2046 B_L2L1(b_if, PH_DEACTIVATE | REQUEST, NULL);
2049 static void EChannel_proc_rcv(struct hisax_d_if *d_if)
2051 struct IsdnCardState *cs = d_if->cs;
2053 struct sk_buff *skb;
2055 while ((skb = skb_dequeue(&d_if->erq)) != NULL) {
2056 if (cs->debug & DEB_DLOG_HEX) {
2058 if ((skb->len) < MAX_DLOG_SPACE / 3 - 10) {
2064 ptr += QuickHex(ptr, skb->data, skb->len);
2068 HiSax_putstatus(cs, NULL, cs->dlog);
2070 HiSax_putstatus(cs, "LogEcho: ",
2071 "warning Frame too big (%d)",
2074 dev_kfree_skb_any(skb);
2078 void HiSax_mod_dec_use_count(struct IsdnCardState *cs)
2082 if (cs && cs->cardmsg == hisax_cardmsg) {
2083 mod = cs->hw.hisax_d_if->owner;
2085 __MOD_DEC_USE_COUNT(mod);
2091 void HiSax_mod_inc_use_count(struct IsdnCardState *cs)
2095 if (cs && cs->cardmsg == hisax_cardmsg) {
2096 mod = cs->hw.hisax_d_if->owner;
2098 // hope we do win the race...
2099 try_inc_mod_count(mod);
2105 #include <linux/pci.h>
2107 static struct pci_device_id hisax_pci_tbl[] __initdata = {
2108 #ifdef CONFIG_HISAX_FRITZPCI
2109 {PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_A1, PCI_ANY_ID, PCI_ANY_ID},
2111 #ifdef CONFIG_HISAX_DIEHLDIVA
2112 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA20, PCI_ANY_ID, PCI_ANY_ID},
2113 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA20_U, PCI_ANY_ID, PCI_ANY_ID},
2114 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA201, PCI_ANY_ID, PCI_ANY_ID},
2115 //#########################################################################################
2116 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA202, PCI_ANY_ID, PCI_ANY_ID},
2117 //#########################################################################################
2119 #ifdef CONFIG_HISAX_ELSA
2120 {PCI_VENDOR_ID_ELSA, PCI_DEVICE_ID_ELSA_MICROLINK, PCI_ANY_ID, PCI_ANY_ID},
2121 {PCI_VENDOR_ID_ELSA, PCI_DEVICE_ID_ELSA_QS3000, PCI_ANY_ID, PCI_ANY_ID},
2123 #ifdef CONFIG_HISAX_GAZEL
2124 {PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_R685, PCI_ANY_ID, PCI_ANY_ID},
2125 {PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_R753, PCI_ANY_ID, PCI_ANY_ID},
2126 {PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_DJINN_ITOO, PCI_ANY_ID, PCI_ANY_ID},
2128 #ifdef CONFIG_HISAX_QUADRO
2129 {PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, PCI_ANY_ID, PCI_ANY_ID},
2131 #ifdef CONFIG_HISAX_NICCY
2132 {PCI_VENDOR_ID_SATSAGEM, PCI_DEVICE_ID_SATSAGEM_NICCY, PCI_ANY_ID,PCI_ANY_ID},
2134 #ifdef CONFIG_HISAX_SEDLBAUER
2135 {PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_100, PCI_ANY_ID,PCI_ANY_ID},
2137 #if defined(CONFIG_HISAX_NETJET) || defined(CONFIG_HISAX_NETJET_U)
2138 {PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_300, PCI_ANY_ID,PCI_ANY_ID},
2140 #if defined(CONFIG_HISAX_TELESPCI) || defined(CONFIG_HISAX_SCT_QUADRO)
2141 {PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36120, PCI_ANY_ID,PCI_ANY_ID},
2143 #ifdef CONFIG_HISAX_W6692
2144 {PCI_VENDOR_ID_DYNALINK, PCI_DEVICE_ID_DYNALINK_IS64PH, PCI_ANY_ID,PCI_ANY_ID},
2145 {PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_6692, PCI_ANY_ID,PCI_ANY_ID},
2147 #ifdef CONFIG_HISAX_HFC_PCI
2148 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_2BD0, PCI_ANY_ID, PCI_ANY_ID},
2149 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B000, PCI_ANY_ID, PCI_ANY_ID},
2150 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B006, PCI_ANY_ID, PCI_ANY_ID},
2151 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B007, PCI_ANY_ID, PCI_ANY_ID},
2152 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B008, PCI_ANY_ID, PCI_ANY_ID},
2153 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B009, PCI_ANY_ID, PCI_ANY_ID},
2154 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00A, PCI_ANY_ID, PCI_ANY_ID},
2155 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00B, PCI_ANY_ID, PCI_ANY_ID},
2156 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00C, PCI_ANY_ID, PCI_ANY_ID},
2157 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B100, PCI_ANY_ID, PCI_ANY_ID},
2158 {PCI_VENDOR_ID_ABOCOM, PCI_DEVICE_ID_ABOCOM_2BD1, PCI_ANY_ID, PCI_ANY_ID},
2159 {PCI_VENDOR_ID_ASUSTEK, PCI_DEVICE_ID_ASUSTEK_0675, PCI_ANY_ID, PCI_ANY_ID},
2160 {PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_T_CONCEPT, PCI_ANY_ID, PCI_ANY_ID},
2161 {PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_A1T, PCI_ANY_ID, PCI_ANY_ID},
2162 {PCI_VENDOR_ID_ANIGMA, PCI_DEVICE_ID_ANIGMA_MC145575, PCI_ANY_ID, PCI_ANY_ID},
2163 {PCI_VENDOR_ID_ZOLTRIX, PCI_DEVICE_ID_ZOLTRIX_2BD0, PCI_ANY_ID, PCI_ANY_ID},
2164 {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_IOM2_E, PCI_ANY_ID, PCI_ANY_ID},
2165 {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_E, PCI_ANY_ID, PCI_ANY_ID},
2166 {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_IOM2_A, PCI_ANY_ID, PCI_ANY_ID},
2167 {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_A, PCI_ANY_ID, PCI_ANY_ID},
2169 { } /* Terminating entry */
2172 MODULE_DEVICE_TABLE(pci, hisax_pci_tbl);
2174 module_init(HiSax_init);
2175 module_exit(HiSax_exit);
2177 EXPORT_SYMBOL(FsmNew);
2178 EXPORT_SYMBOL(FsmFree);
2179 EXPORT_SYMBOL(FsmEvent);
2180 EXPORT_SYMBOL(FsmChangeState);
2181 EXPORT_SYMBOL(FsmInitTimer);
2182 EXPORT_SYMBOL(FsmDelTimer);
2183 EXPORT_SYMBOL(FsmRestartTimer);