1 /* $Id: config.c,v 2.84.2.5 2004/02/11 13:21:33 keil 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/init.h>
22 #include <linux/module.h>
23 #include <linux/kernel_stat.h>
24 #include <linux/workqueue.h>
25 #include <linux/interrupt.h>
26 #define HISAX_STATUS_BUFSIZE 4096
29 * This structure array contains one entry per card. An entry looks
32 * { type, protocol, p0, p1, p2, NULL }
35 * 1 Teles 16.0 p0=irq p1=membase p2=iobase
36 * 2 Teles 8.0 p0=irq p1=membase
37 * 3 Teles 16.3 p0=irq p1=iobase
38 * 4 Creatix PNP p0=irq p1=IO0 (ISAC) p2=IO1 (HSCX)
39 * 5 AVM A1 (Fritz) p0=irq p1=iobase
40 * 6 ELSA PC [p0=iobase] or nothing (autodetect)
41 * 7 ELSA Quickstep p0=irq p1=iobase
42 * 8 Teles PCMCIA p0=irq p1=iobase
43 * 9 ITK ix1-micro p0=irq p1=iobase
44 * 10 ELSA PCMCIA p0=irq p1=iobase
45 * 11 Eicon.Diehl Diva p0=irq p1=iobase
46 * 12 Asuscom ISDNLink p0=irq p1=iobase
47 * 13 Teleint p0=irq p1=iobase
48 * 14 Teles 16.3c p0=irq p1=iobase
49 * 15 Sedlbauer speed p0=irq p1=iobase
50 * 15 Sedlbauer PC/104 p0=irq p1=iobase
51 * 15 Sedlbauer speed pci no parameter
52 * 16 USR Sportster internal p0=irq p1=iobase
53 * 17 MIC card p0=irq p1=iobase
54 * 18 ELSA Quickstep 1000PCI no parameter
55 * 19 Compaq ISDN S0 ISA card p0=irq p1=IO0 (HSCX) p2=IO1 (ISAC) p3=IO2
56 * 20 Travers Technologies NETjet-S PCI card
57 * 21 TELES PCI no parameter
58 * 22 Sedlbauer Speed Star p0=irq p1=iobase
60 * 24 Dr Neuhaus Niccy PnP/PCI card p0=irq p1=IO0 p2=IO1 (PnP only)
61 * 25 Teles S0Box p0=irq p1=iobase (from isapnp setup)
62 * 26 AVM A1 PCMCIA (Fritz) p0=irq p1=iobase
63 * 27 AVM PnP/PCI p0=irq p1=iobase (PCI no parameter)
64 * 28 Sedlbauer Speed Fax+ p0=irq p1=iobase (from isapnp setup)
65 * 29 Siemens I-Surf p0=irq p1=iobase p2=memory (from isapnp setup)
66 * 30 ACER P10 p0=irq p1=iobase (from isapnp setup)
67 * 31 HST Saphir p0=irq p1=iobase
69 * 33 Scitel Quadro p0=subcontroller (4*S0, subctrl 1...4)
71 * 35 HFC 2BDS0 PCI none
72 * 36 Winbond 6692 PCI none
73 * 37 HFC 2BDS0 S+/SP p0=irq p1=iobase
74 * 38 Travers Technologies NETspider-U PCI card
75 * 39 HFC 2BDS0-SP PCMCIA p0=irq p1=iobase
76 * 40 hotplug interface
77 * 41 Formula-n enter:now ISDN PCI a/b none
79 * protocol can be either ISDN_PTYPE_EURO or ISDN_PTYPE_1TR6 or ISDN_PTYPE_NI1
84 const char *CardType[] = {
85 "No Card", "Teles 16.0", "Teles 8.0", "Teles 16.3",
86 "Creatix/Teles PnP", "AVM A1", "Elsa ML", "Elsa Quickstep",
87 "Teles PCMCIA", "ITK ix1-micro Rev.2", "Elsa PCMCIA",
88 "Eicon.Diehl Diva", "ISDNLink", "TeleInt", "Teles 16.3c",
89 "Sedlbauer Speed Card", "USR Sportster", "ith mic Linux",
90 "Elsa PCI", "Compaq ISA", "NETjet-S", "Teles PCI",
91 "Sedlbauer Speed Star (PCMCIA)", "AMD 7930", "NICCY", "S0Box",
92 "AVM A1 (PCMCIA)", "AVM Fritz PnP/PCI", "Sedlbauer Speed Fax +",
93 "Siemens I-Surf", "Acer P10", "HST Saphir", "Telekom A4T",
94 "Scitel Quadro", "Gazel", "HFC 2BDS0 PCI", "Winbond 6692",
95 "HFC 2BDS0 SX", "NETspider-U", "HFC-2BDS0-SP PCMCIA",
96 "Hotplug", "Formula-n enter:now PCI a/b",
99 #ifdef CONFIG_HISAX_ELSA
100 #define DEFAULT_CARD ISDN_CTYPE_ELSA
101 #define DEFAULT_CFG {0,0,0,0}
104 #ifdef CONFIG_HISAX_AVM_A1
107 #define DEFAULT_CARD ISDN_CTYPE_A1
108 #define DEFAULT_CFG {10,0x340,0,0}
111 #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
114 #define DEFAULT_CARD ISDN_CTYPE_A1_PCMCIA
115 #define DEFAULT_CFG {11,0x170,0,0}
118 #ifdef CONFIG_HISAX_FRITZPCI
121 #define DEFAULT_CARD ISDN_CTYPE_FRITZPCI
122 #define DEFAULT_CFG {0,0,0,0}
125 #ifdef CONFIG_HISAX_16_3
128 #define DEFAULT_CARD ISDN_CTYPE_16_3
129 #define DEFAULT_CFG {15,0x180,0,0}
132 #ifdef CONFIG_HISAX_S0BOX
135 #define DEFAULT_CARD ISDN_CTYPE_S0BOX
136 #define DEFAULT_CFG {7,0x378,0,0}
139 #ifdef CONFIG_HISAX_16_0
142 #define DEFAULT_CARD ISDN_CTYPE_16_0
143 #define DEFAULT_CFG {15,0xd0000,0xd80,0}
146 #ifdef CONFIG_HISAX_TELESPCI
149 #define DEFAULT_CARD ISDN_CTYPE_TELESPCI
150 #define DEFAULT_CFG {0,0,0,0}
153 #ifdef CONFIG_HISAX_IX1MICROR2
156 #define DEFAULT_CARD ISDN_CTYPE_IX1MICROR2
157 #define DEFAULT_CFG {5,0x390,0,0}
160 #ifdef CONFIG_HISAX_DIEHLDIVA
163 #define DEFAULT_CARD ISDN_CTYPE_DIEHLDIVA
164 #define DEFAULT_CFG {0,0x0,0,0}
167 #ifdef CONFIG_HISAX_ASUSCOM
170 #define DEFAULT_CARD ISDN_CTYPE_ASUSCOM
171 #define DEFAULT_CFG {5,0x200,0,0}
174 #ifdef CONFIG_HISAX_TELEINT
177 #define DEFAULT_CARD ISDN_CTYPE_TELEINT
178 #define DEFAULT_CFG {5,0x300,0,0}
181 #ifdef CONFIG_HISAX_SEDLBAUER
184 #define DEFAULT_CARD ISDN_CTYPE_SEDLBAUER
185 #define DEFAULT_CFG {11,0x270,0,0}
188 #ifdef CONFIG_HISAX_SPORTSTER
191 #define DEFAULT_CARD ISDN_CTYPE_SPORTSTER
192 #define DEFAULT_CFG {7,0x268,0,0}
195 #ifdef CONFIG_HISAX_MIC
198 #define DEFAULT_CARD ISDN_CTYPE_MIC
199 #define DEFAULT_CFG {12,0x3e0,0,0}
202 #ifdef CONFIG_HISAX_NETJET
205 #define DEFAULT_CARD ISDN_CTYPE_NETJET_S
206 #define DEFAULT_CFG {0,0,0,0}
209 #ifdef CONFIG_HISAX_HFCS
212 #define DEFAULT_CARD ISDN_CTYPE_TELES3C
213 #define DEFAULT_CFG {5,0x500,0,0}
216 #ifdef CONFIG_HISAX_HFC_PCI
219 #define DEFAULT_CARD ISDN_CTYPE_HFC_PCI
220 #define DEFAULT_CFG {0,0,0,0}
223 #ifdef CONFIG_HISAX_HFC_SX
226 #define DEFAULT_CARD ISDN_CTYPE_HFC_SX
227 #define DEFAULT_CFG {5,0x2E0,0,0}
230 #ifdef CONFIG_HISAX_NICCY
233 #define DEFAULT_CARD ISDN_CTYPE_NICCY
234 #define DEFAULT_CFG {0,0x0,0,0}
237 #ifdef CONFIG_HISAX_ISURF
240 #define DEFAULT_CARD ISDN_CTYPE_ISURF
241 #define DEFAULT_CFG {5,0x100,0xc8000,0}
244 #ifdef CONFIG_HISAX_HSTSAPHIR
247 #define DEFAULT_CARD ISDN_CTYPE_HSTSAPHIR
248 #define DEFAULT_CFG {5,0x250,0,0}
251 #ifdef CONFIG_HISAX_BKM_A4T
254 #define DEFAULT_CARD ISDN_CTYPE_BKM_A4T
255 #define DEFAULT_CFG {0,0x0,0,0}
258 #ifdef CONFIG_HISAX_SCT_QUADRO
261 #define DEFAULT_CARD ISDN_CTYPE_SCT_QUADRO
262 #define DEFAULT_CFG {1,0x0,0,0}
265 #ifdef CONFIG_HISAX_GAZEL
268 #define DEFAULT_CARD ISDN_CTYPE_GAZEL
269 #define DEFAULT_CFG {15,0x180,0,0}
272 #ifdef CONFIG_HISAX_W6692
275 #define DEFAULT_CARD ISDN_CTYPE_W6692
276 #define DEFAULT_CFG {0,0,0,0}
279 #ifdef CONFIG_HISAX_NETJET_U
282 #define DEFAULT_CARD ISDN_CTYPE_NETJET_U
283 #define DEFAULT_CFG {0,0,0,0}
286 #ifdef CONFIG_HISAX_1TR6
287 #define DEFAULT_PROTO ISDN_PTYPE_1TR6
288 #define DEFAULT_PROTO_NAME "1TR6"
290 #ifdef CONFIG_HISAX_NI1
292 #define DEFAULT_PROTO ISDN_PTYPE_NI1
293 #undef DEFAULT_PROTO_NAME
294 #define DEFAULT_PROTO_NAME "NI1"
296 #ifdef CONFIG_HISAX_EURO
298 #define DEFAULT_PROTO ISDN_PTYPE_EURO
299 #undef DEFAULT_PROTO_NAME
300 #define DEFAULT_PROTO_NAME "EURO"
302 #ifndef DEFAULT_PROTO
303 #define DEFAULT_PROTO ISDN_PTYPE_UNKNOWN
304 #define DEFAULT_PROTO_NAME "UNKNOWN"
307 #define DEFAULT_CARD 0
308 #define DEFAULT_CFG {0,0,0,0}
311 #define FIRST_CARD { \
318 struct IsdnCard cards[HISAX_MAX_CARDS] = {
322 #define HISAX_IDSIZE (HISAX_MAX_CARDS*8)
323 static char HiSaxID[HISAX_IDSIZE] = { 0, };
325 static char *HiSax_id = HiSaxID;
327 /* Variables for insmod */
328 static int type[HISAX_MAX_CARDS] = { 0, };
329 static int protocol[HISAX_MAX_CARDS] = { 0, };
330 static int io[HISAX_MAX_CARDS] = { 0, };
332 #ifdef CONFIG_HISAX_16_3
335 #ifdef CONFIG_HISAX_NICCY
340 static int io0[HISAX_MAX_CARDS] __devinitdata = { 0, };
341 static int io1[HISAX_MAX_CARDS] __devinitdata = { 0, };
343 static int irq[HISAX_MAX_CARDS] __devinitdata = { 0, };
344 static int mem[HISAX_MAX_CARDS] __devinitdata = { 0, };
345 static char *id = HiSaxID;
347 MODULE_DESCRIPTION("ISDN4Linux: Driver for passive ISDN cards");
348 MODULE_AUTHOR("Karsten Keil");
349 MODULE_LICENSE("GPL");
350 module_param_array(type, int, NULL, 0);
351 module_param_array(protocol, int, NULL, 0);
352 module_param_array(io, int, NULL, 0);
353 module_param_array(irq, int, NULL, 0);
354 module_param_array(mem, int, NULL, 0);
355 module_param(id, charp, 0);
357 module_param_array(io0, int, NULL, 0);
358 module_param_array(io1, int, NULL, 0);
364 char *HiSax_getrev(const char *revision)
369 if ((p = strchr(revision, ':'))) {
371 p = strchr(rev, '$');
378 static void __init HiSaxVersion(void)
382 printk(KERN_INFO "HiSax: Linux Driver for passive ISDN cards\n");
384 printk(KERN_INFO "HiSax: Version 3.5 (module)\n");
386 printk(KERN_INFO "HiSax: Version 3.5 (kernel)\n");
388 strcpy(tmp, l1_revision);
389 printk(KERN_INFO "HiSax: Layer1 Revision %s\n", HiSax_getrev(tmp));
390 strcpy(tmp, l2_revision);
391 printk(KERN_INFO "HiSax: Layer2 Revision %s\n", HiSax_getrev(tmp));
392 strcpy(tmp, tei_revision);
393 printk(KERN_INFO "HiSax: TeiMgr Revision %s\n", HiSax_getrev(tmp));
394 strcpy(tmp, l3_revision);
395 printk(KERN_INFO "HiSax: Layer3 Revision %s\n", HiSax_getrev(tmp));
396 strcpy(tmp, lli_revision);
397 printk(KERN_INFO "HiSax: LinkLayer Revision %s\n",
402 #define MAX_ARG (HISAX_MAX_CARDS*5)
403 static int __init HiSax_setup(char *line)
406 int ints[MAX_ARG + 1];
409 str = get_options(line, MAX_ARG, ints);
411 printk(KERN_DEBUG "HiSax_setup: argc(%d) str(%s)\n", argc, str);
414 while (argc && (i < HISAX_MAX_CARDS)) {
415 cards[i].protocol = DEFAULT_PROTO;
417 cards[i].typ = ints[j];
422 cards[i].protocol = ints[j];
427 cards[i].para[0] = ints[j];
432 cards[i].para[1] = ints[j];
437 cards[i].para[2] = ints[j];
444 if (strlen(str) < HISAX_IDSIZE)
445 strcpy(HiSaxID, str);
447 printk(KERN_WARNING "HiSax: ID too long!");
449 strcpy(HiSaxID, "HiSax");
455 __setup("hisax=", HiSax_setup);
459 extern int setup_teles0(struct IsdnCard *card);
463 extern int setup_teles3(struct IsdnCard *card);
467 extern int setup_s0box(struct IsdnCard *card);
471 extern int setup_telespci(struct IsdnCard *card);
475 extern int setup_avm_a1(struct IsdnCard *card);
478 #if CARD_AVM_A1_PCMCIA
479 extern int setup_avm_a1_pcmcia(struct IsdnCard *card);
483 extern int setup_avm_pcipnp(struct IsdnCard *card);
487 extern int setup_elsa(struct IsdnCard *card);
491 extern int setup_ix1micro(struct IsdnCard *card);
495 extern int setup_diva(struct IsdnCard *card);
499 extern int setup_asuscom(struct IsdnCard *card);
503 extern int setup_TeleInt(struct IsdnCard *card);
507 extern int setup_sedlbauer(struct IsdnCard *card);
511 extern int setup_sportster(struct IsdnCard *card);
515 extern int setup_mic(struct IsdnCard *card);
519 extern int setup_netjet_s(struct IsdnCard *card);
523 extern int setup_hfcs(struct IsdnCard *card);
527 extern int setup_hfcpci(struct IsdnCard *card);
531 extern int setup_hfcsx(struct IsdnCard *card);
535 extern int setup_niccy(struct IsdnCard *card);
539 extern int setup_isurf(struct IsdnCard *card);
543 extern int setup_saphir(struct IsdnCard *card);
547 extern int setup_bkm_a4t(struct IsdnCard *card);
551 extern int setup_sct_quadro(struct IsdnCard *card);
555 extern int setup_gazel(struct IsdnCard *card);
559 extern int setup_w6692(struct IsdnCard *card);
563 extern int setup_netjet_u(struct IsdnCard *card);
566 #if CARD_FN_ENTERNOW_PCI
567 extern int setup_enternow_pci(struct IsdnCard *card);
571 * Find card with given driverId
573 static inline struct IsdnCardState *hisax_findcard(int driverid)
577 for (i = 0; i < nrcards; i++)
579 if (cards[i].cs->myid == driverid)
585 * Find card with given card number
588 struct IsdnCardState *hisax_get_card(int cardnr)
590 if ((cardnr <= nrcards) && (cardnr > 0))
591 if (cards[cardnr - 1].cs)
592 return cards[cardnr - 1].cs;
597 static int HiSax_readstatus(u_char __user *buf, int len, int id, int channel)
600 u_char __user *p = buf;
601 struct IsdnCardState *cs = hisax_findcard(id);
604 if (len > HISAX_STATUS_BUFSIZE) {
606 "HiSax: status overflow readstat %d/%d\n",
607 len, HISAX_STATUS_BUFSIZE);
609 count = cs->status_end - cs->status_read + 1;
612 if (copy_to_user(p, cs->status_read, count))
614 cs->status_read += count;
615 if (cs->status_read > cs->status_end)
616 cs->status_read = cs->status_buf;
620 if (count > HISAX_STATUS_BUFSIZE)
621 cnt = HISAX_STATUS_BUFSIZE;
624 if (copy_to_user(p, cs->status_read, cnt))
627 cs->status_read += cnt % HISAX_STATUS_BUFSIZE;
633 "HiSax: if_readstatus called with invalid driverId!\n");
638 int jiftime(char *s, long mark)
643 *s-- = mark % 10 + '0';
645 *s-- = mark % 10 + '0';
648 *s-- = mark % 10 + '0';
650 *s-- = mark % 6 + '0';
653 *s-- = mark % 10 + '0';
655 *s-- = mark % 10 + '0';
659 static u_char tmpbuf[HISAX_STATUS_BUFSIZE];
661 void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt,
664 /* if head == NULL the fmt contains the full info */
673 printk(KERN_WARNING "HiSax: No CardStatus for message");
676 spin_lock_irqsave(&cs->statlock, flags);
679 p += jiftime(p, jiffies);
680 p += sprintf(p, " %s", head);
681 p += vsprintf(p, fmt, args);
690 if (len > HISAX_STATUS_BUFSIZE) {
691 spin_unlock_irqrestore(&cs->statlock, flags);
692 printk(KERN_WARNING "HiSax: status overflow %d/%d\n",
693 len, HISAX_STATUS_BUFSIZE);
697 i = cs->status_end - cs->status_write + 1;
701 memcpy(cs->status_write, p, i);
702 cs->status_write += i;
703 if (cs->status_write > cs->status_end)
704 cs->status_write = cs->status_buf;
707 memcpy(cs->status_write, p, len);
708 cs->status_write += len;
710 #ifdef KERNELSTACK_DEBUG
711 i = (ulong) & len - current->kernel_stack_page;
712 sprintf(tmpbuf, "kstack %s %lx use %ld\n", current->comm,
713 current->kernel_stack_page, i);
714 len = strlen(tmpbuf);
715 for (p = tmpbuf, i = len; i > 0; i--, p++) {
716 *cs->status_write++ = *p;
717 if (cs->status_write > cs->status_end)
718 cs->status_write = cs->status_buf;
722 spin_unlock_irqrestore(&cs->statlock, flags);
724 ic.command = ISDN_STAT_STAVAIL;
725 ic.driver = cs->myid;
727 cs->iif.statcallb(&ic);
731 void HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...)
736 VHiSax_putstatus(cs, head, fmt, args);
740 int ll_run(struct IsdnCardState *cs, int addfeatures)
744 ic.driver = cs->myid;
745 ic.command = ISDN_STAT_RUN;
746 cs->iif.features |= addfeatures;
747 cs->iif.statcallb(&ic);
751 static void ll_stop(struct IsdnCardState *cs)
755 ic.command = ISDN_STAT_STOP;
756 ic.driver = cs->myid;
757 cs->iif.statcallb(&ic);
758 // CallcFreeChan(cs);
761 static void ll_unload(struct IsdnCardState *cs)
765 ic.command = ISDN_STAT_UNLOAD;
766 ic.driver = cs->myid;
767 cs->iif.statcallb(&ic);
768 kfree(cs->status_buf);
769 cs->status_read = NULL;
770 cs->status_write = NULL;
771 cs->status_end = NULL;
776 static void 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 skb_queue_purge(&csta->rq);
786 skb_queue_purge(&csta->sq);
790 dev_kfree_skb(csta->tx_skb);
793 if (csta->DC_Close != NULL) {
794 csta->DC_Close(csta);
797 csta->cardmsg(csta, CARD_RELEASE, NULL);
798 if (csta->dbusytimer.function != NULL) // FIXME?
799 del_timer(&csta->dbusytimer);
803 static irqreturn_t card_irq(int intno, void *dev_id)
805 struct IsdnCardState *cs = dev_id;
806 irqreturn_t ret = cs->irq_func(intno, cs);
808 if (ret == IRQ_HANDLED)
813 static int init_card(struct IsdnCardState *cs)
815 int irq_cnt, cnt = 3, ret;
818 ret = cs->cardmsg(cs, CARD_INIT, NULL);
821 irq_cnt = cs->irq_cnt = 0;
822 printk(KERN_INFO "%s: IRQ %d count %d\n", CardType[cs->typ],
824 if (request_irq(cs->irq, card_irq, cs->irq_flags, "HiSax", cs)) {
825 printk(KERN_WARNING "HiSax: couldn't get interrupt %d\n",
830 cs->cardmsg(cs, CARD_INIT, NULL);
833 printk(KERN_INFO "%s: IRQ %d count %d\n",
834 CardType[cs->typ], cs->irq, cs->irq_cnt);
835 if (cs->irq_cnt == irq_cnt) {
837 "%s: IRQ(%d) getting no interrupts during init %d\n",
838 CardType[cs->typ], cs->irq, 4 - cnt);
840 free_irq(cs->irq, cs);
843 cs->cardmsg(cs, CARD_RESET, NULL);
847 cs->cardmsg(cs, CARD_TEST, NULL);
854 static int __devinit hisax_cs_setup_card(struct IsdnCard *card)
860 case ISDN_CTYPE_16_0:
862 ret = setup_teles0(card);
866 case ISDN_CTYPE_16_3:
868 case ISDN_CTYPE_TELESPCMCIA:
869 case ISDN_CTYPE_COMPAQ_ISA:
870 ret = setup_teles3(card);
874 case ISDN_CTYPE_S0BOX:
875 ret = setup_s0box(card);
879 case ISDN_CTYPE_TELESPCI:
880 ret = setup_telespci(card);
885 ret = setup_avm_a1(card);
888 #if CARD_AVM_A1_PCMCIA
889 case ISDN_CTYPE_A1_PCMCIA:
890 ret = setup_avm_a1_pcmcia(card);
894 case ISDN_CTYPE_FRITZPCI:
895 ret = setup_avm_pcipnp(card);
899 case ISDN_CTYPE_ELSA:
900 case ISDN_CTYPE_ELSA_PNP:
901 case ISDN_CTYPE_ELSA_PCMCIA:
902 case ISDN_CTYPE_ELSA_PCI:
903 ret = setup_elsa(card);
907 case ISDN_CTYPE_IX1MICROR2:
908 ret = setup_ix1micro(card);
912 case ISDN_CTYPE_DIEHLDIVA:
913 ret = setup_diva(card);
917 case ISDN_CTYPE_ASUSCOM:
918 ret = setup_asuscom(card);
922 case ISDN_CTYPE_TELEINT:
923 ret = setup_TeleInt(card);
927 case ISDN_CTYPE_SEDLBAUER:
928 case ISDN_CTYPE_SEDLBAUER_PCMCIA:
929 case ISDN_CTYPE_SEDLBAUER_FAX:
930 ret = setup_sedlbauer(card);
934 case ISDN_CTYPE_SPORTSTER:
935 ret = setup_sportster(card);
940 ret = setup_mic(card);
944 case ISDN_CTYPE_NETJET_S:
945 ret = setup_netjet_s(card);
949 case ISDN_CTYPE_TELES3C:
950 case ISDN_CTYPE_ACERP10:
951 ret = setup_hfcs(card);
955 case ISDN_CTYPE_HFC_PCI:
956 ret = setup_hfcpci(card);
960 case ISDN_CTYPE_HFC_SX:
961 ret = setup_hfcsx(card);
965 case ISDN_CTYPE_NICCY:
966 ret = setup_niccy(card);
970 case ISDN_CTYPE_ISURF:
971 ret = setup_isurf(card);
975 case ISDN_CTYPE_HSTSAPHIR:
976 ret = setup_saphir(card);
980 case ISDN_CTYPE_BKM_A4T:
981 ret = setup_bkm_a4t(card);
985 case ISDN_CTYPE_SCT_QUADRO:
986 ret = setup_sct_quadro(card);
990 case ISDN_CTYPE_GAZEL:
991 ret = setup_gazel(card);
995 case ISDN_CTYPE_W6692:
996 ret = setup_w6692(card);
1000 case ISDN_CTYPE_NETJET_U:
1001 ret = setup_netjet_u(card);
1004 #if CARD_FN_ENTERNOW_PCI
1005 case ISDN_CTYPE_ENTERNOW:
1006 ret = setup_enternow_pci(card);
1009 case ISDN_CTYPE_DYNAMIC:
1014 "HiSax: Support for %s Card not selected\n",
1015 CardType[card->typ]);
1023 static int hisax_cs_new(int cardnr, char *id, struct IsdnCard *card,
1024 struct IsdnCardState **cs_out, int *busy_flag,
1025 struct module *lockowner)
1027 struct IsdnCardState *cs;
1031 cs = kzalloc(sizeof(struct IsdnCardState), GFP_ATOMIC);
1034 "HiSax: No memory for IsdnCardState(card %d)\n",
1039 spin_lock_init(&cs->statlock);
1040 spin_lock_init(&cs->lock);
1041 cs->chanlimit = 2; /* maximum B-channel number */
1042 cs->logecho = 0; /* No echo logging */
1043 cs->cardnr = cardnr;
1044 cs->debug = L1_DEB_WARN;
1046 cs->busy_flag = busy_flag;
1047 cs->irq_flags = I4L_IRQ_FLAG;
1049 if (card->protocol == ISDN_PTYPE_NI1)
1050 test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);
1052 test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);
1054 cs->protocol = card->protocol;
1056 if (card->typ <= 0 || card->typ > ISDN_CTYPE_COUNT) {
1058 "HiSax: Card Type %d out of range\n", card->typ);
1061 if (!(cs->dlog = kmalloc(MAX_DLOG_SPACE, GFP_ATOMIC))) {
1063 "HiSax: No memory for dlog(card %d)\n", cardnr + 1);
1066 if (!(cs->status_buf = kmalloc(HISAX_STATUS_BUFSIZE, GFP_ATOMIC))) {
1068 "HiSax: No memory for status_buf(card %d)\n",
1073 cs->status_read = cs->status_buf;
1074 cs->status_write = cs->status_buf;
1075 cs->status_end = cs->status_buf + HISAX_STATUS_BUFSIZE - 1;
1076 cs->typ = card->typ;
1078 cs->iif.owner = lockowner;
1080 strcpy(cs->iif.id, id);
1081 cs->iif.channels = 2;
1082 cs->iif.maxbufsize = MAX_DATA_SIZE;
1083 cs->iif.hl_hdrlen = MAX_HEADER_LEN;
1085 ISDN_FEATURE_L2_X75I |
1086 ISDN_FEATURE_L2_HDLC |
1087 ISDN_FEATURE_L2_HDLC_56K |
1088 ISDN_FEATURE_L2_TRANS |
1089 ISDN_FEATURE_L3_TRANS |
1090 #ifdef CONFIG_HISAX_1TR6
1091 ISDN_FEATURE_P_1TR6 |
1093 #ifdef CONFIG_HISAX_EURO
1094 ISDN_FEATURE_P_EURO |
1096 #ifdef CONFIG_HISAX_NI1
1097 ISDN_FEATURE_P_NI1 |
1101 cs->iif.command = HiSax_command;
1102 cs->iif.writecmd = NULL;
1103 cs->iif.writebuf_skb = HiSax_writebuf_skb;
1104 cs->iif.readstat = HiSax_readstatus;
1105 register_isdn(&cs->iif);
1106 cs->myid = cs->iif.channels;
1109 return 1; /* success */
1117 return 0; /* error */
1120 static int hisax_cs_setup(int cardnr, struct IsdnCard *card,
1121 struct IsdnCardState *cs)
1125 if (!(cs->rcvbuf = kmalloc(MAX_DFRAME_LEN_L1, GFP_ATOMIC))) {
1126 printk(KERN_WARNING "HiSax: No memory for isac rcvbuf\n");
1135 skb_queue_head_init(&cs->rq);
1136 skb_queue_head_init(&cs->sq);
1138 init_bcstate(cs, 0);
1139 init_bcstate(cs, 1);
1141 /* init_card only handles interrupts which are not */
1142 /* used here for the loadable driver */
1143 switch (card->typ) {
1144 case ISDN_CTYPE_DYNAMIC:
1148 ret = init_card(cs);
1155 init_tei(cs, cs->protocol);
1156 ret = CallcNewChan(cs);
1161 /* ISAR needs firmware download first */
1162 if (!test_bit(HW_ISAR, &cs->HW_Flags))
1173 /* Used from an exported function but calls __devinit functions.
1174 * Tell modpost not to warn (__ref)
1176 static int __ref checkcard(int cardnr, char *id, int *busy_flag,
1177 struct module *lockowner,
1178 hisax_setup_func_t card_setup)
1181 struct IsdnCard *card = cards + cardnr;
1182 struct IsdnCardState *cs;
1184 ret = hisax_cs_new(cardnr, id, card, &cs, busy_flag, lockowner);
1189 "HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr + 1,
1190 (card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" :
1191 (card->protocol == ISDN_PTYPE_EURO) ? "EDSS1" :
1192 (card->protocol == ISDN_PTYPE_LEASED) ? "LEASED" :
1193 (card->protocol == ISDN_PTYPE_NI1) ? "NI1" :
1194 "NONE", cs->iif.id, cs->myid);
1196 ret = card_setup(card);
1202 ret = hisax_cs_setup(cardnr, card, cs);
1212 static void HiSax_shiftcards(int idx)
1216 for (i = idx; i < (HISAX_MAX_CARDS - 1); i++)
1217 memcpy(&cards[i], &cards[i + 1], sizeof(cards[i]));
1220 static int __init HiSax_inithardware(int *busy_flag)
1227 char *next_id = HiSax_id;
1230 if (strchr(HiSax_id, ','))
1232 else if (strchr(HiSax_id, '%'))
1235 while (i < nrcards) {
1236 if (cards[i].typ < 1)
1239 if ((next_id = strchr(id, t))) {
1248 sprintf(ids, "%s%d", id, i);
1250 if (checkcard(i, ids, busy_flag, THIS_MODULE,
1251 hisax_cs_setup_card)) {
1255 /* make sure we don't oops the module */
1256 if (cards[i].typ > 0 && cards[i].typ <= ISDN_CTYPE_COUNT) {
1258 "HiSax: Card %s not installed !\n",
1259 CardType[cards[i].typ]);
1261 HiSax_shiftcards(i);
1268 void HiSax_closecard(int cardnr)
1270 int i, last = nrcards - 1;
1272 if (cardnr > last || cardnr < 0)
1274 if (cards[cardnr].cs) {
1275 ll_stop(cards[cardnr].cs);
1276 release_tei(cards[cardnr].cs);
1277 CallcFreeChan(cards[cardnr].cs);
1280 if (cards[cardnr].cs->irq)
1281 free_irq(cards[cardnr].cs->irq, cards[cardnr].cs);
1282 kfree((void *) cards[cardnr].cs);
1283 cards[cardnr].cs = NULL;
1287 cards[i] = cards[i + 1];
1293 void HiSax_reportcard(int cardnr, int sel)
1295 struct IsdnCardState *cs = cards[cardnr].cs;
1297 printk(KERN_DEBUG "HiSax: reportcard No %d\n", cardnr + 1);
1298 printk(KERN_DEBUG "HiSax: Type %s\n", CardType[cs->typ]);
1299 printk(KERN_DEBUG "HiSax: debuglevel %x\n", cs->debug);
1300 printk(KERN_DEBUG "HiSax: HiSax_reportcard address 0x%lX\n",
1301 (ulong) & HiSax_reportcard);
1302 printk(KERN_DEBUG "HiSax: cs 0x%lX\n", (ulong) cs);
1303 printk(KERN_DEBUG "HiSax: HW_Flags %lx bc0 flg %lx bc1 flg %lx\n",
1304 cs->HW_Flags, cs->bcs[0].Flag, cs->bcs[1].Flag);
1305 printk(KERN_DEBUG "HiSax: bcs 0 mode %d ch%d\n",
1306 cs->bcs[0].mode, cs->bcs[0].channel);
1307 printk(KERN_DEBUG "HiSax: bcs 1 mode %d ch%d\n",
1308 cs->bcs[1].mode, cs->bcs[1].channel);
1309 #ifdef ERROR_STATISTIC
1310 printk(KERN_DEBUG "HiSax: dc errors(rx,crc,tx) %d,%d,%d\n",
1311 cs->err_rx, cs->err_crc, cs->err_tx);
1313 "HiSax: bc0 errors(inv,rdo,crc,tx) %d,%d,%d,%d\n",
1314 cs->bcs[0].err_inv, cs->bcs[0].err_rdo, cs->bcs[0].err_crc,
1317 "HiSax: bc1 errors(inv,rdo,crc,tx) %d,%d,%d,%d\n",
1318 cs->bcs[1].err_inv, cs->bcs[1].err_rdo, cs->bcs[1].err_crc,
1324 cs->bcs[0].err_inv = 0;
1325 cs->bcs[0].err_rdo = 0;
1326 cs->bcs[0].err_crc = 0;
1327 cs->bcs[0].err_tx = 0;
1328 cs->bcs[1].err_inv = 0;
1329 cs->bcs[1].err_rdo = 0;
1330 cs->bcs[1].err_crc = 0;
1331 cs->bcs[1].err_tx = 0;
1336 static int __init HiSax_init(void)
1345 retval = CallcNew();
1348 retval = Isdnl3New();
1351 retval = Isdnl2New();
1357 retval = Isdnl1New();
1363 /* We 'll register drivers later, but init basic functions */
1364 for (i = 0; i < HISAX_MAX_CARDS; i++)
1368 #ifdef CONFIG_HISAX_ELSA
1369 if (type[0] == ISDN_CTYPE_ELSA_PCMCIA) {
1370 /* we have exported and return in this case */
1374 #ifdef CONFIG_HISAX_SEDLBAUER
1375 if (type[0] == ISDN_CTYPE_SEDLBAUER_PCMCIA) {
1376 /* we have to export and return in this case */
1380 #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
1381 if (type[0] == ISDN_CTYPE_A1_PCMCIA) {
1382 /* we have to export and return in this case */
1386 #ifdef CONFIG_HISAX_HFC_SX
1387 if (type[0] == ISDN_CTYPE_HFC_SP_PCMCIA) {
1388 /* we have to export and return in this case */
1395 if (id) /* If id= string used */
1397 for (i = j = 0; j < HISAX_MAX_CARDS; i++) {
1398 cards[j].typ = type[i];
1400 cards[j].protocol = protocol[i];
1403 cards[j].protocol = DEFAULT_PROTO;
1406 case ISDN_CTYPE_16_0:
1407 cards[j].para[0] = irq[i];
1408 cards[j].para[1] = mem[i];
1409 cards[j].para[2] = io[i];
1412 case ISDN_CTYPE_8_0:
1413 cards[j].para[0] = irq[i];
1414 cards[j].para[1] = mem[i];
1418 case ISDN_CTYPE_PNP:
1419 case ISDN_CTYPE_NICCY:
1420 cards[j].para[0] = irq[i];
1421 cards[j].para[1] = io0[i];
1422 cards[j].para[2] = io1[i];
1424 case ISDN_CTYPE_COMPAQ_ISA:
1425 cards[j].para[0] = irq[i];
1426 cards[j].para[1] = io0[i];
1427 cards[j].para[2] = io1[i];
1428 cards[j].para[3] = io[i];
1431 case ISDN_CTYPE_ELSA:
1432 case ISDN_CTYPE_HFC_PCI:
1433 cards[j].para[0] = io[i];
1435 case ISDN_CTYPE_16_3:
1436 case ISDN_CTYPE_TELESPCMCIA:
1438 case ISDN_CTYPE_A1_PCMCIA:
1439 case ISDN_CTYPE_ELSA_PNP:
1440 case ISDN_CTYPE_ELSA_PCMCIA:
1441 case ISDN_CTYPE_IX1MICROR2:
1442 case ISDN_CTYPE_DIEHLDIVA:
1443 case ISDN_CTYPE_ASUSCOM:
1444 case ISDN_CTYPE_TELEINT:
1445 case ISDN_CTYPE_SEDLBAUER:
1446 case ISDN_CTYPE_SEDLBAUER_PCMCIA:
1447 case ISDN_CTYPE_SEDLBAUER_FAX:
1448 case ISDN_CTYPE_SPORTSTER:
1449 case ISDN_CTYPE_MIC:
1450 case ISDN_CTYPE_TELES3C:
1451 case ISDN_CTYPE_ACERP10:
1452 case ISDN_CTYPE_S0BOX:
1453 case ISDN_CTYPE_FRITZPCI:
1454 case ISDN_CTYPE_HSTSAPHIR:
1455 case ISDN_CTYPE_GAZEL:
1456 case ISDN_CTYPE_HFC_SX:
1457 case ISDN_CTYPE_HFC_SP_PCMCIA:
1458 cards[j].para[0] = irq[i];
1459 cards[j].para[1] = io[i];
1461 case ISDN_CTYPE_ISURF:
1462 cards[j].para[0] = irq[i];
1463 cards[j].para[1] = io[i];
1464 cards[j].para[2] = mem[i];
1466 case ISDN_CTYPE_ELSA_PCI:
1467 case ISDN_CTYPE_NETJET_S:
1468 case ISDN_CTYPE_TELESPCI:
1469 case ISDN_CTYPE_W6692:
1470 case ISDN_CTYPE_NETJET_U:
1472 case ISDN_CTYPE_BKM_A4T:
1474 case ISDN_CTYPE_SCT_QUADRO:
1476 cards[j].para[0] = irq[i];
1478 /* QUADRO is a 4 BRI card */
1479 cards[j++].para[0] = 1;
1480 /* we need to check if further cards can be added */
1481 if (j < HISAX_MAX_CARDS) {
1482 cards[j].typ = ISDN_CTYPE_SCT_QUADRO;
1483 cards[j].protocol = protocol[i];
1484 cards[j++].para[0] = 2;
1486 if (j < HISAX_MAX_CARDS) {
1487 cards[j].typ = ISDN_CTYPE_SCT_QUADRO;
1488 cards[j].protocol = protocol[i];
1489 cards[j++].para[0] = 3;
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] = 4;
1503 "HiSax: Warning - no protocol specified\n");
1504 printk(KERN_WARNING "HiSax: using protocol %s\n",
1505 DEFAULT_PROTO_NAME);
1511 strcpy(HiSaxID, "HiSax");
1512 for (i = 0; i < HISAX_MAX_CARDS; i++)
1513 if (cards[i].typ > 0)
1515 printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
1516 nrcards, (nrcards > 1) ? "s" : "");
1518 /* Install only, if at least one card found */
1519 if (!HiSax_inithardware(NULL))
1535 static void __exit HiSax_exit(void)
1537 int cardnr = nrcards - 1;
1540 HiSax_closecard(cardnr--);
1546 printk(KERN_INFO "HiSax module removed\n");
1549 #ifdef CONFIG_HOTPLUG
1551 int __devinit hisax_init_pcmcia(void *pcm_iob, int *busy_flag, struct IsdnCard *card)
1556 cards[nrcards] = *card;
1558 sprintf(ids, "HiSax%d", nrcards);
1560 sprintf(ids, "HiSax");
1561 if (!checkcard(nrcards, ids, busy_flag, THIS_MODULE,
1562 hisax_cs_setup_card))
1571 EXPORT_SYMBOL(hisax_init_pcmcia);
1574 EXPORT_SYMBOL(HiSax_closecard);
1576 #include "hisax_if.h"
1578 EXPORT_SYMBOL(hisax_register);
1579 EXPORT_SYMBOL(hisax_unregister);
1581 static void hisax_d_l1l2(struct hisax_if *ifc, int pr, void *arg);
1582 static void hisax_b_l1l2(struct hisax_if *ifc, int pr, void *arg);
1583 static void hisax_d_l2l1(struct PStack *st, int pr, void *arg);
1584 static void hisax_b_l2l1(struct PStack *st, int pr, void *arg);
1585 static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg);
1586 static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs);
1587 static void hisax_bc_close(struct BCState *bcs);
1588 static void hisax_bh(struct work_struct *work);
1589 static void EChannel_proc_rcv(struct hisax_d_if *d_if);
1591 static int hisax_setup_card_dynamic(struct IsdnCard *card)
1596 int hisax_register(struct hisax_d_if *hisax_d_if, struct hisax_b_if *b_if[],
1597 char *name, int protocol)
1601 struct IsdnCardState *cs;
1603 for (i = 0; i < HISAX_MAX_CARDS; i++) {
1608 if (i >= HISAX_MAX_CARDS)
1611 cards[i].typ = ISDN_CTYPE_DYNAMIC;
1612 cards[i].protocol = protocol;
1613 sprintf(id, "%s%d", name, i);
1615 retval = checkcard(i, id, NULL, hisax_d_if->owner,
1616 hisax_setup_card_dynamic);
1617 if (retval == 0) { // yuck
1623 hisax_d_if->cs = cs;
1624 cs->hw.hisax_d_if = hisax_d_if;
1625 cs->cardmsg = hisax_cardmsg;
1626 INIT_WORK(&cs->tqueue, hisax_bh);
1627 cs->channel[0].d_st->l2.l2l1 = hisax_d_l2l1;
1628 for (i = 0; i < 2; i++) {
1629 cs->bcs[i].BC_SetStack = hisax_bc_setstack;
1630 cs->bcs[i].BC_Close = hisax_bc_close;
1632 b_if[i]->ifc.l1l2 = hisax_b_l1l2;
1634 hisax_d_if->b_if[i] = b_if[i];
1636 hisax_d_if->ifc.l1l2 = hisax_d_l1l2;
1637 skb_queue_head_init(&hisax_d_if->erq);
1638 clear_bit(0, &hisax_d_if->ph_state);
1643 void hisax_unregister(struct hisax_d_if *hisax_d_if)
1645 cards[hisax_d_if->cs->cardnr].typ = 0;
1646 HiSax_closecard(hisax_d_if->cs->cardnr);
1647 skb_queue_purge(&hisax_d_if->erq);
1652 static void hisax_sched_event(struct IsdnCardState *cs, int event)
1654 test_and_set_bit(event, &cs->event);
1655 schedule_work(&cs->tqueue);
1658 static void hisax_bh(struct work_struct *work)
1660 struct IsdnCardState *cs =
1661 container_of(work, struct IsdnCardState, tqueue);
1665 if (test_and_clear_bit(D_RCVBUFREADY, &cs->event))
1666 DChannel_proc_rcv(cs);
1667 if (test_and_clear_bit(E_RCVBUFREADY, &cs->event))
1668 EChannel_proc_rcv(cs->hw.hisax_d_if);
1669 if (test_and_clear_bit(D_L1STATECHANGE, &cs->event)) {
1670 if (test_bit(0, &cs->hw.hisax_d_if->ph_state))
1671 pr = PH_ACTIVATE | INDICATION;
1673 pr = PH_DEACTIVATE | INDICATION;
1674 for (st = cs->stlist; st; st = st->next)
1675 st->l1.l1l2(st, pr, NULL);
1680 static void hisax_b_sched_event(struct BCState *bcs, int event)
1682 test_and_set_bit(event, &bcs->event);
1683 schedule_work(&bcs->tqueue);
1686 static inline void D_L2L1(struct hisax_d_if *d_if, int pr, void *arg)
1688 struct hisax_if *ifc = (struct hisax_if *) d_if;
1689 ifc->l2l1(ifc, pr, arg);
1692 static inline void B_L2L1(struct hisax_b_if *b_if, int pr, void *arg)
1694 struct hisax_if *ifc = (struct hisax_if *) b_if;
1695 ifc->l2l1(ifc, pr, arg);
1698 static void hisax_d_l1l2(struct hisax_if *ifc, int pr, void *arg)
1700 struct hisax_d_if *d_if = (struct hisax_d_if *) ifc;
1701 struct IsdnCardState *cs = d_if->cs;
1703 struct sk_buff *skb;
1706 case PH_ACTIVATE | INDICATION:
1707 set_bit(0, &d_if->ph_state);
1708 hisax_sched_event(cs, D_L1STATECHANGE);
1710 case PH_DEACTIVATE | INDICATION:
1711 clear_bit(0, &d_if->ph_state);
1712 hisax_sched_event(cs, D_L1STATECHANGE);
1714 case PH_DATA | INDICATION:
1715 skb_queue_tail(&cs->rq, arg);
1716 hisax_sched_event(cs, D_RCVBUFREADY);
1718 case PH_DATA | CONFIRM:
1719 skb = skb_dequeue(&cs->sq);
1721 D_L2L1(d_if, PH_DATA | REQUEST, skb);
1724 clear_bit(FLG_L1_DBUSY, &cs->HW_Flags);
1725 for (st = cs->stlist; st; st = st->next) {
1726 if (test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags)) {
1727 st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
1732 case PH_DATA_E | INDICATION:
1733 skb_queue_tail(&d_if->erq, arg);
1734 hisax_sched_event(cs, E_RCVBUFREADY);
1737 printk("pr %#x\n", pr);
1742 static void hisax_b_l1l2(struct hisax_if *ifc, int pr, void *arg)
1744 struct hisax_b_if *b_if = (struct hisax_b_if *) ifc;
1745 struct BCState *bcs = b_if->bcs;
1746 struct PStack *st = bcs->st;
1747 struct sk_buff *skb;
1749 // FIXME use isdnl1?
1751 case PH_ACTIVATE | INDICATION:
1752 st->l1.l1l2(st, pr, NULL);
1754 case PH_DEACTIVATE | INDICATION:
1755 st->l1.l1l2(st, pr, NULL);
1756 clear_bit(BC_FLG_BUSY, &bcs->Flag);
1757 skb_queue_purge(&bcs->squeue);
1758 bcs->hw.b_if = NULL;
1760 case PH_DATA | INDICATION:
1761 skb_queue_tail(&bcs->rqueue, arg);
1762 hisax_b_sched_event(bcs, B_RCVBUFREADY);
1764 case PH_DATA | CONFIRM:
1765 bcs->tx_cnt -= (long)arg;
1766 if (test_bit(FLG_LLI_L1WAKEUP,&bcs->st->lli.flag)) {
1768 spin_lock_irqsave(&bcs->aclock, flags);
1769 bcs->ackcnt += (long)arg;
1770 spin_unlock_irqrestore(&bcs->aclock, flags);
1771 schedule_event(bcs, B_ACKPENDING);
1773 skb = skb_dequeue(&bcs->squeue);
1775 B_L2L1(b_if, PH_DATA | REQUEST, skb);
1778 clear_bit(BC_FLG_BUSY, &bcs->Flag);
1779 if (test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags)) {
1780 st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
1784 printk("hisax_b_l1l2 pr %#x\n", pr);
1789 static void hisax_d_l2l1(struct PStack *st, int pr, void *arg)
1791 struct IsdnCardState *cs = st->l1.hardware;
1792 struct hisax_d_if *hisax_d_if = cs->hw.hisax_d_if;
1793 struct sk_buff *skb = arg;
1796 case PH_DATA | REQUEST:
1797 case PH_PULL | INDICATION:
1798 if (cs->debug & DEB_DLOG_HEX)
1799 LogFrame(cs, skb->data, skb->len);
1800 if (cs->debug & DEB_DLOG_VERBOSE)
1801 dlogframe(cs, skb, 0);
1802 Logl2Frame(cs, skb, "PH_DATA_REQ", 0);
1804 if (!test_and_set_bit(FLG_L1_DBUSY, &cs->HW_Flags))
1805 D_L2L1(hisax_d_if, PH_DATA | REQUEST, skb);
1807 skb_queue_tail(&cs->sq, skb);
1809 case PH_PULL | REQUEST:
1810 if (!test_bit(FLG_L1_DBUSY, &cs->HW_Flags))
1811 st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
1813 set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
1816 D_L2L1(hisax_d_if, pr, arg);
1821 static int hisax_cardmsg(struct IsdnCardState *cs, int mt, void *arg)
1826 static void hisax_b_l2l1(struct PStack *st, int pr, void *arg)
1828 struct BCState *bcs = st->l1.bcs;
1829 struct hisax_b_if *b_if = bcs->hw.b_if;
1832 case PH_ACTIVATE | REQUEST:
1833 B_L2L1(b_if, pr, (void *)(unsigned long)st->l1.mode);
1835 case PH_DATA | REQUEST:
1836 case PH_PULL | INDICATION:
1838 if (!test_and_set_bit(BC_FLG_BUSY, &bcs->Flag)) {
1839 B_L2L1(b_if, PH_DATA | REQUEST, arg);
1841 skb_queue_tail(&bcs->squeue, arg);
1844 case PH_PULL | REQUEST:
1845 if (!test_bit(BC_FLG_BUSY, &bcs->Flag))
1846 st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);
1848 set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
1850 case PH_DEACTIVATE | REQUEST:
1851 test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
1852 skb_queue_purge(&bcs->squeue);
1854 B_L2L1(b_if, pr, arg);
1859 static int hisax_bc_setstack(struct PStack *st, struct BCState *bcs)
1861 struct IsdnCardState *cs = st->l1.hardware;
1862 struct hisax_d_if *hisax_d_if = cs->hw.hisax_d_if;
1864 bcs->channel = st->l1.bc;
1866 bcs->hw.b_if = hisax_d_if->b_if[st->l1.bc];
1867 hisax_d_if->b_if[st->l1.bc]->bcs = bcs;
1870 st->l2.l2l1 = hisax_b_l2l1;
1871 setstack_manager(st);
1874 skb_queue_head_init(&bcs->rqueue);
1875 skb_queue_head_init(&bcs->squeue);
1879 static void hisax_bc_close(struct BCState *bcs)
1881 struct hisax_b_if *b_if = bcs->hw.b_if;
1884 B_L2L1(b_if, PH_DEACTIVATE | REQUEST, NULL);
1887 static void EChannel_proc_rcv(struct hisax_d_if *d_if)
1889 struct IsdnCardState *cs = d_if->cs;
1891 struct sk_buff *skb;
1893 while ((skb = skb_dequeue(&d_if->erq)) != NULL) {
1894 if (cs->debug & DEB_DLOG_HEX) {
1896 if ((skb->len) < MAX_DLOG_SPACE / 3 - 10) {
1902 ptr += QuickHex(ptr, skb->data, skb->len);
1906 HiSax_putstatus(cs, NULL, cs->dlog);
1908 HiSax_putstatus(cs, "LogEcho: ",
1909 "warning Frame too big (%d)",
1912 dev_kfree_skb_any(skb);
1917 #include <linux/pci.h>
1919 static struct pci_device_id hisax_pci_tbl[] __devinitdata = {
1920 #ifdef CONFIG_HISAX_FRITZPCI
1921 {PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_A1, PCI_ANY_ID, PCI_ANY_ID},
1923 #ifdef CONFIG_HISAX_DIEHLDIVA
1924 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA20, PCI_ANY_ID, PCI_ANY_ID},
1925 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA20_U, PCI_ANY_ID, PCI_ANY_ID},
1926 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA201, PCI_ANY_ID, PCI_ANY_ID},
1927 //#########################################################################################
1928 {PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA202, PCI_ANY_ID, PCI_ANY_ID},
1929 //#########################################################################################
1931 #ifdef CONFIG_HISAX_ELSA
1932 {PCI_VENDOR_ID_ELSA, PCI_DEVICE_ID_ELSA_MICROLINK, PCI_ANY_ID, PCI_ANY_ID},
1933 {PCI_VENDOR_ID_ELSA, PCI_DEVICE_ID_ELSA_QS3000, PCI_ANY_ID, PCI_ANY_ID},
1935 #ifdef CONFIG_HISAX_GAZEL
1936 {PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_R685, PCI_ANY_ID, PCI_ANY_ID},
1937 {PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_R753, PCI_ANY_ID, PCI_ANY_ID},
1938 {PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_DJINN_ITOO, PCI_ANY_ID, PCI_ANY_ID},
1939 {PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_OLITEC, PCI_ANY_ID, PCI_ANY_ID},
1941 #ifdef CONFIG_HISAX_SCT_QUADRO
1942 {PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, PCI_ANY_ID, PCI_ANY_ID},
1944 #ifdef CONFIG_HISAX_NICCY
1945 {PCI_VENDOR_ID_SATSAGEM, PCI_DEVICE_ID_SATSAGEM_NICCY, PCI_ANY_ID,PCI_ANY_ID},
1947 #ifdef CONFIG_HISAX_SEDLBAUER
1948 {PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_100, PCI_ANY_ID,PCI_ANY_ID},
1950 #if defined(CONFIG_HISAX_NETJET) || defined(CONFIG_HISAX_NETJET_U)
1951 {PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_300, PCI_ANY_ID,PCI_ANY_ID},
1953 #if defined(CONFIG_HISAX_TELESPCI) || defined(CONFIG_HISAX_SCT_QUADRO)
1954 {PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36120, PCI_ANY_ID,PCI_ANY_ID},
1956 #ifdef CONFIG_HISAX_W6692
1957 {PCI_VENDOR_ID_DYNALINK, PCI_DEVICE_ID_DYNALINK_IS64PH, PCI_ANY_ID,PCI_ANY_ID},
1958 {PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_6692, PCI_ANY_ID,PCI_ANY_ID},
1960 #ifdef CONFIG_HISAX_HFC_PCI
1961 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_2BD0, PCI_ANY_ID, PCI_ANY_ID},
1962 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B000, PCI_ANY_ID, PCI_ANY_ID},
1963 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B006, PCI_ANY_ID, PCI_ANY_ID},
1964 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B007, PCI_ANY_ID, PCI_ANY_ID},
1965 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B008, PCI_ANY_ID, PCI_ANY_ID},
1966 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B009, PCI_ANY_ID, PCI_ANY_ID},
1967 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00A, PCI_ANY_ID, PCI_ANY_ID},
1968 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00B, PCI_ANY_ID, PCI_ANY_ID},
1969 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B00C, PCI_ANY_ID, PCI_ANY_ID},
1970 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B100, PCI_ANY_ID, PCI_ANY_ID},
1971 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B700, PCI_ANY_ID, PCI_ANY_ID},
1972 {PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_B701, PCI_ANY_ID, PCI_ANY_ID},
1973 {PCI_VENDOR_ID_ABOCOM, PCI_DEVICE_ID_ABOCOM_2BD1, PCI_ANY_ID, PCI_ANY_ID},
1974 {PCI_VENDOR_ID_ASUSTEK, PCI_DEVICE_ID_ASUSTEK_0675, PCI_ANY_ID, PCI_ANY_ID},
1975 {PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_T_CONCEPT, PCI_ANY_ID, PCI_ANY_ID},
1976 {PCI_VENDOR_ID_BERKOM, PCI_DEVICE_ID_BERKOM_A1T, PCI_ANY_ID, PCI_ANY_ID},
1977 {PCI_VENDOR_ID_ANIGMA, PCI_DEVICE_ID_ANIGMA_MC145575, PCI_ANY_ID, PCI_ANY_ID},
1978 {PCI_VENDOR_ID_ZOLTRIX, PCI_DEVICE_ID_ZOLTRIX_2BD0, PCI_ANY_ID, PCI_ANY_ID},
1979 {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_IOM2_E, PCI_ANY_ID, PCI_ANY_ID},
1980 {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_E, PCI_ANY_ID, PCI_ANY_ID},
1981 {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_IOM2_A, PCI_ANY_ID, PCI_ANY_ID},
1982 {PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_DIGI_DF_M_A, PCI_ANY_ID, PCI_ANY_ID},
1984 { } /* Terminating entry */
1987 MODULE_DEVICE_TABLE(pci, hisax_pci_tbl);
1988 #endif /* CONFIG_PCI */
1990 module_init(HiSax_init);
1991 module_exit(HiSax_exit);
1993 EXPORT_SYMBOL(FsmNew);
1994 EXPORT_SYMBOL(FsmFree);
1995 EXPORT_SYMBOL(FsmEvent);
1996 EXPORT_SYMBOL(FsmChangeState);
1997 EXPORT_SYMBOL(FsmInitTimer);
1998 EXPORT_SYMBOL(FsmDelTimer);
1999 EXPORT_SYMBOL(FsmRestartTimer);