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 #include <linux/slab.h>
27 #define HISAX_STATUS_BUFSIZE 4096
30 * This structure array contains one entry per card. An entry looks
33 * { type, protocol, p0, p1, p2, NULL }
36 * 1 Teles 16.0 p0=irq p1=membase p2=iobase
37 * 2 Teles 8.0 p0=irq p1=membase
38 * 3 Teles 16.3 p0=irq p1=iobase
39 * 4 Creatix PNP p0=irq p1=IO0 (ISAC) p2=IO1 (HSCX)
40 * 5 AVM A1 (Fritz) p0=irq p1=iobase
41 * 6 ELSA PC [p0=iobase] or nothing (autodetect)
42 * 7 ELSA Quickstep p0=irq p1=iobase
43 * 8 Teles PCMCIA p0=irq p1=iobase
44 * 9 ITK ix1-micro p0=irq p1=iobase
45 * 10 ELSA PCMCIA p0=irq p1=iobase
46 * 11 Eicon.Diehl Diva p0=irq p1=iobase
47 * 12 Asuscom ISDNLink p0=irq p1=iobase
48 * 13 Teleint p0=irq p1=iobase
49 * 14 Teles 16.3c p0=irq p1=iobase
50 * 15 Sedlbauer speed p0=irq p1=iobase
51 * 15 Sedlbauer PC/104 p0=irq p1=iobase
52 * 15 Sedlbauer speed pci no parameter
53 * 16 USR Sportster internal p0=irq p1=iobase
54 * 17 MIC card p0=irq p1=iobase
55 * 18 ELSA Quickstep 1000PCI no parameter
56 * 19 Compaq ISDN S0 ISA card p0=irq p1=IO0 (HSCX) p2=IO1 (ISAC) p3=IO2
57 * 20 Travers Technologies NETjet-S PCI card
58 * 21 TELES PCI no parameter
59 * 22 Sedlbauer Speed Star p0=irq p1=iobase
61 * 24 Dr Neuhaus Niccy PnP/PCI card p0=irq p1=IO0 p2=IO1 (PnP only)
62 * 25 Teles S0Box p0=irq p1=iobase (from isapnp setup)
63 * 26 AVM A1 PCMCIA (Fritz) p0=irq p1=iobase
64 * 27 AVM PnP/PCI p0=irq p1=iobase (PCI no parameter)
65 * 28 Sedlbauer Speed Fax+ p0=irq p1=iobase (from isapnp setup)
66 * 29 Siemens I-Surf p0=irq p1=iobase p2=memory (from isapnp setup)
67 * 30 ACER P10 p0=irq p1=iobase (from isapnp setup)
68 * 31 HST Saphir p0=irq p1=iobase
70 * 33 Scitel Quadro p0=subcontroller (4*S0, subctrl 1...4)
72 * 35 HFC 2BDS0 PCI none
73 * 36 Winbond 6692 PCI none
74 * 37 HFC 2BDS0 S+/SP p0=irq p1=iobase
75 * 38 Travers Technologies NETspider-U PCI card
76 * 39 HFC 2BDS0-SP PCMCIA p0=irq p1=iobase
77 * 40 hotplug interface
78 * 41 Formula-n enter:now ISDN PCI a/b none
80 * protocol can be either ISDN_PTYPE_EURO or ISDN_PTYPE_1TR6 or ISDN_PTYPE_NI1
85 const char *CardType
[] = {
86 "No Card", "Teles 16.0", "Teles 8.0", "Teles 16.3",
87 "Creatix/Teles PnP", "AVM A1", "Elsa ML", "Elsa Quickstep",
88 "Teles PCMCIA", "ITK ix1-micro Rev.2", "Elsa PCMCIA",
89 "Eicon.Diehl Diva", "ISDNLink", "TeleInt", "Teles 16.3c",
90 "Sedlbauer Speed Card", "USR Sportster", "ith mic Linux",
91 "Elsa PCI", "Compaq ISA", "NETjet-S", "Teles PCI",
92 "Sedlbauer Speed Star (PCMCIA)", "AMD 7930", "NICCY", "S0Box",
93 "AVM A1 (PCMCIA)", "AVM Fritz PnP/PCI", "Sedlbauer Speed Fax +",
94 "Siemens I-Surf", "Acer P10", "HST Saphir", "Telekom A4T",
95 "Scitel Quadro", "Gazel", "HFC 2BDS0 PCI", "Winbond 6692",
96 "HFC 2BDS0 SX", "NETspider-U", "HFC-2BDS0-SP PCMCIA",
97 "Hotplug", "Formula-n enter:now PCI a/b",
100 #ifdef CONFIG_HISAX_ELSA
101 #define DEFAULT_CARD ISDN_CTYPE_ELSA
102 #define DEFAULT_CFG {0, 0, 0, 0}
105 #ifdef CONFIG_HISAX_AVM_A1
108 #define DEFAULT_CARD ISDN_CTYPE_A1
109 #define DEFAULT_CFG {10, 0x340, 0, 0}
112 #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
115 #define DEFAULT_CARD ISDN_CTYPE_A1_PCMCIA
116 #define DEFAULT_CFG {11, 0x170, 0, 0}
119 #ifdef CONFIG_HISAX_FRITZPCI
122 #define DEFAULT_CARD ISDN_CTYPE_FRITZPCI
123 #define DEFAULT_CFG {0, 0, 0, 0}
126 #ifdef CONFIG_HISAX_16_3
129 #define DEFAULT_CARD ISDN_CTYPE_16_3
130 #define DEFAULT_CFG {15, 0x180, 0, 0}
133 #ifdef CONFIG_HISAX_S0BOX
136 #define DEFAULT_CARD ISDN_CTYPE_S0BOX
137 #define DEFAULT_CFG {7, 0x378, 0, 0}
140 #ifdef CONFIG_HISAX_16_0
143 #define DEFAULT_CARD ISDN_CTYPE_16_0
144 #define DEFAULT_CFG {15, 0xd0000, 0xd80, 0}
147 #ifdef CONFIG_HISAX_TELESPCI
150 #define DEFAULT_CARD ISDN_CTYPE_TELESPCI
151 #define DEFAULT_CFG {0, 0, 0, 0}
154 #ifdef CONFIG_HISAX_IX1MICROR2
157 #define DEFAULT_CARD ISDN_CTYPE_IX1MICROR2
158 #define DEFAULT_CFG {5, 0x390, 0, 0}
161 #ifdef CONFIG_HISAX_DIEHLDIVA
164 #define DEFAULT_CARD ISDN_CTYPE_DIEHLDIVA
165 #define DEFAULT_CFG {0, 0x0, 0, 0}
168 #ifdef CONFIG_HISAX_ASUSCOM
171 #define DEFAULT_CARD ISDN_CTYPE_ASUSCOM
172 #define DEFAULT_CFG {5, 0x200, 0, 0}
175 #ifdef CONFIG_HISAX_TELEINT
178 #define DEFAULT_CARD ISDN_CTYPE_TELEINT
179 #define DEFAULT_CFG {5, 0x300, 0, 0}
182 #ifdef CONFIG_HISAX_SEDLBAUER
185 #define DEFAULT_CARD ISDN_CTYPE_SEDLBAUER
186 #define DEFAULT_CFG {11, 0x270, 0, 0}
189 #ifdef CONFIG_HISAX_SPORTSTER
192 #define DEFAULT_CARD ISDN_CTYPE_SPORTSTER
193 #define DEFAULT_CFG {7, 0x268, 0, 0}
196 #ifdef CONFIG_HISAX_MIC
199 #define DEFAULT_CARD ISDN_CTYPE_MIC
200 #define DEFAULT_CFG {12, 0x3e0, 0, 0}
203 #ifdef CONFIG_HISAX_NETJET
206 #define DEFAULT_CARD ISDN_CTYPE_NETJET_S
207 #define DEFAULT_CFG {0, 0, 0, 0}
210 #ifdef CONFIG_HISAX_HFCS
213 #define DEFAULT_CARD ISDN_CTYPE_TELES3C
214 #define DEFAULT_CFG {5, 0x500, 0, 0}
217 #ifdef CONFIG_HISAX_HFC_PCI
220 #define DEFAULT_CARD ISDN_CTYPE_HFC_PCI
221 #define DEFAULT_CFG {0, 0, 0, 0}
224 #ifdef CONFIG_HISAX_HFC_SX
227 #define DEFAULT_CARD ISDN_CTYPE_HFC_SX
228 #define DEFAULT_CFG {5, 0x2E0, 0, 0}
231 #ifdef CONFIG_HISAX_NICCY
234 #define DEFAULT_CARD ISDN_CTYPE_NICCY
235 #define DEFAULT_CFG {0, 0x0, 0, 0}
238 #ifdef CONFIG_HISAX_ISURF
241 #define DEFAULT_CARD ISDN_CTYPE_ISURF
242 #define DEFAULT_CFG {5, 0x100, 0xc8000, 0}
245 #ifdef CONFIG_HISAX_HSTSAPHIR
248 #define DEFAULT_CARD ISDN_CTYPE_HSTSAPHIR
249 #define DEFAULT_CFG {5, 0x250, 0, 0}
252 #ifdef CONFIG_HISAX_BKM_A4T
255 #define DEFAULT_CARD ISDN_CTYPE_BKM_A4T
256 #define DEFAULT_CFG {0, 0x0, 0, 0}
259 #ifdef CONFIG_HISAX_SCT_QUADRO
262 #define DEFAULT_CARD ISDN_CTYPE_SCT_QUADRO
263 #define DEFAULT_CFG {1, 0x0, 0, 0}
266 #ifdef CONFIG_HISAX_GAZEL
269 #define DEFAULT_CARD ISDN_CTYPE_GAZEL
270 #define DEFAULT_CFG {15, 0x180, 0, 0}
273 #ifdef CONFIG_HISAX_W6692
276 #define DEFAULT_CARD ISDN_CTYPE_W6692
277 #define DEFAULT_CFG {0, 0, 0, 0}
280 #ifdef CONFIG_HISAX_NETJET_U
283 #define DEFAULT_CARD ISDN_CTYPE_NETJET_U
284 #define DEFAULT_CFG {0, 0, 0, 0}
287 #ifdef CONFIG_HISAX_1TR6
288 #define DEFAULT_PROTO ISDN_PTYPE_1TR6
289 #define DEFAULT_PROTO_NAME "1TR6"
291 #ifdef CONFIG_HISAX_NI1
293 #define DEFAULT_PROTO ISDN_PTYPE_NI1
294 #undef DEFAULT_PROTO_NAME
295 #define DEFAULT_PROTO_NAME "NI1"
297 #ifdef CONFIG_HISAX_EURO
299 #define DEFAULT_PROTO ISDN_PTYPE_EURO
300 #undef DEFAULT_PROTO_NAME
301 #define DEFAULT_PROTO_NAME "EURO"
303 #ifndef DEFAULT_PROTO
304 #define DEFAULT_PROTO ISDN_PTYPE_UNKNOWN
305 #define DEFAULT_PROTO_NAME "UNKNOWN"
308 #define DEFAULT_CARD 0
309 #define DEFAULT_CFG {0, 0, 0, 0}
312 #define FIRST_CARD { \
319 struct IsdnCard cards
[HISAX_MAX_CARDS
] = {
323 #define HISAX_IDSIZE (HISAX_MAX_CARDS * 8)
324 static char HiSaxID
[HISAX_IDSIZE
] = { 0, };
326 static char *HiSax_id
= HiSaxID
;
328 /* Variables for insmod */
329 static int type
[HISAX_MAX_CARDS
] = { 0, };
330 static int protocol
[HISAX_MAX_CARDS
] = { 0, };
331 static int io
[HISAX_MAX_CARDS
] = { 0, };
333 #ifdef CONFIG_HISAX_16_3
336 #ifdef CONFIG_HISAX_NICCY
341 static int io0
[HISAX_MAX_CARDS
] = { 0, };
342 static int io1
[HISAX_MAX_CARDS
] = { 0, };
344 static int irq
[HISAX_MAX_CARDS
] = { 0, };
345 static int mem
[HISAX_MAX_CARDS
] = { 0, };
346 static char *id
= HiSaxID
;
348 MODULE_DESCRIPTION("ISDN4Linux: Driver for passive ISDN cards");
349 MODULE_AUTHOR("Karsten Keil");
350 MODULE_LICENSE("GPL");
351 module_param_array(type
, int, NULL
, 0);
352 module_param_array(protocol
, int, NULL
, 0);
353 module_param_array(io
, int, NULL
, 0);
354 module_param_array(irq
, int, NULL
, 0);
355 module_param_array(mem
, int, NULL
, 0);
356 module_param(id
, charp
, 0);
358 module_param_array(io0
, int, NULL
, 0);
359 module_param_array(io1
, int, NULL
, 0);
365 char *HiSax_getrev(const char *revision
)
370 if ((p
= strchr(revision
, ':'))) {
372 p
= strchr(rev
, '$');
379 static void __init
HiSaxVersion(void)
383 printk(KERN_INFO
"HiSax: Linux Driver for passive ISDN cards\n");
385 printk(KERN_INFO
"HiSax: Version 3.5 (module)\n");
387 printk(KERN_INFO
"HiSax: Version 3.5 (kernel)\n");
389 strcpy(tmp
, l1_revision
);
390 printk(KERN_INFO
"HiSax: Layer1 Revision %s\n", HiSax_getrev(tmp
));
391 strcpy(tmp
, l2_revision
);
392 printk(KERN_INFO
"HiSax: Layer2 Revision %s\n", HiSax_getrev(tmp
));
393 strcpy(tmp
, tei_revision
);
394 printk(KERN_INFO
"HiSax: TeiMgr Revision %s\n", HiSax_getrev(tmp
));
395 strcpy(tmp
, l3_revision
);
396 printk(KERN_INFO
"HiSax: Layer3 Revision %s\n", HiSax_getrev(tmp
));
397 strcpy(tmp
, lli_revision
);
398 printk(KERN_INFO
"HiSax: LinkLayer Revision %s\n",
403 #define MAX_ARG (HISAX_MAX_CARDS * 5)
404 static int __init
HiSax_setup(char *line
)
407 int ints
[MAX_ARG
+ 1];
410 str
= get_options(line
, MAX_ARG
, ints
);
412 printk(KERN_DEBUG
"HiSax_setup: argc(%d) str(%s)\n", argc
, str
);
415 while (argc
&& (i
< HISAX_MAX_CARDS
)) {
416 cards
[i
].protocol
= DEFAULT_PROTO
;
418 cards
[i
].typ
= ints
[j
];
423 cards
[i
].protocol
= ints
[j
];
428 cards
[i
].para
[0] = ints
[j
];
433 cards
[i
].para
[1] = ints
[j
];
438 cards
[i
].para
[2] = ints
[j
];
445 if (strlen(str
) < HISAX_IDSIZE
)
446 strcpy(HiSaxID
, str
);
448 printk(KERN_WARNING
"HiSax: ID too long!");
450 strcpy(HiSaxID
, "HiSax");
456 __setup("hisax=", HiSax_setup
);
460 extern int setup_teles0(struct IsdnCard
*card
);
464 extern int setup_teles3(struct IsdnCard
*card
);
468 extern int setup_s0box(struct IsdnCard
*card
);
472 extern int setup_telespci(struct IsdnCard
*card
);
476 extern int setup_avm_a1(struct IsdnCard
*card
);
479 #if CARD_AVM_A1_PCMCIA
480 extern int setup_avm_a1_pcmcia(struct IsdnCard
*card
);
484 extern int setup_avm_pcipnp(struct IsdnCard
*card
);
488 extern int setup_elsa(struct IsdnCard
*card
);
492 extern int setup_ix1micro(struct IsdnCard
*card
);
496 extern int setup_diva(struct IsdnCard
*card
);
500 extern int setup_asuscom(struct IsdnCard
*card
);
504 extern int setup_TeleInt(struct IsdnCard
*card
);
508 extern int setup_sedlbauer(struct IsdnCard
*card
);
512 extern int setup_sportster(struct IsdnCard
*card
);
516 extern int setup_mic(struct IsdnCard
*card
);
520 extern int setup_netjet_s(struct IsdnCard
*card
);
524 extern int setup_hfcs(struct IsdnCard
*card
);
528 extern int setup_hfcpci(struct IsdnCard
*card
);
532 extern int setup_hfcsx(struct IsdnCard
*card
);
536 extern int setup_niccy(struct IsdnCard
*card
);
540 extern int setup_isurf(struct IsdnCard
*card
);
544 extern int setup_saphir(struct IsdnCard
*card
);
548 extern int setup_bkm_a4t(struct IsdnCard
*card
);
552 extern int setup_sct_quadro(struct IsdnCard
*card
);
556 extern int setup_gazel(struct IsdnCard
*card
);
560 extern int setup_w6692(struct IsdnCard
*card
);
564 extern int setup_netjet_u(struct IsdnCard
*card
);
567 #if CARD_FN_ENTERNOW_PCI
568 extern int setup_enternow_pci(struct IsdnCard
*card
);
572 * Find card with given driverId
574 static inline struct IsdnCardState
*hisax_findcard(int driverid
)
578 for (i
= 0; i
< nrcards
; i
++)
580 if (cards
[i
].cs
->myid
== driverid
)
586 * Find card with given card number
589 struct IsdnCardState
*hisax_get_card(int cardnr
)
591 if ((cardnr
<= nrcards
) && (cardnr
> 0))
592 if (cards
[cardnr
- 1].cs
)
593 return cards
[cardnr
- 1].cs
;
598 static int HiSax_readstatus(u_char __user
*buf
, int len
, int id
, int channel
)
601 u_char __user
*p
= buf
;
602 struct IsdnCardState
*cs
= hisax_findcard(id
);
605 if (len
> HISAX_STATUS_BUFSIZE
) {
607 "HiSax: status overflow readstat %d/%d\n",
608 len
, HISAX_STATUS_BUFSIZE
);
610 count
= cs
->status_end
- cs
->status_read
+ 1;
613 if (copy_to_user(p
, cs
->status_read
, count
))
615 cs
->status_read
+= count
;
616 if (cs
->status_read
> cs
->status_end
)
617 cs
->status_read
= cs
->status_buf
;
621 if (count
> HISAX_STATUS_BUFSIZE
)
622 cnt
= HISAX_STATUS_BUFSIZE
;
625 if (copy_to_user(p
, cs
->status_read
, cnt
))
628 cs
->status_read
+= cnt
% HISAX_STATUS_BUFSIZE
;
634 "HiSax: if_readstatus called with invalid driverId!\n");
639 int jiftime(char *s
, long mark
)
644 *s
-- = mark
% 10 + '0';
646 *s
-- = mark
% 10 + '0';
649 *s
-- = mark
% 10 + '0';
651 *s
-- = mark
% 6 + '0';
654 *s
-- = mark
% 10 + '0';
656 *s
-- = mark
% 10 + '0';
660 static u_char tmpbuf
[HISAX_STATUS_BUFSIZE
];
662 void VHiSax_putstatus(struct IsdnCardState
*cs
, char *head
, char *fmt
,
665 /* if head == NULL the fmt contains the full info */
674 printk(KERN_WARNING
"HiSax: No CardStatus for message");
677 spin_lock_irqsave(&cs
->statlock
, flags
);
680 p
+= jiftime(p
, jiffies
);
681 p
+= sprintf(p
, " %s", head
);
682 p
+= vsprintf(p
, fmt
, args
);
691 if (len
> HISAX_STATUS_BUFSIZE
) {
692 spin_unlock_irqrestore(&cs
->statlock
, flags
);
693 printk(KERN_WARNING
"HiSax: status overflow %d/%d\n",
694 len
, HISAX_STATUS_BUFSIZE
);
698 i
= cs
->status_end
- cs
->status_write
+ 1;
702 memcpy(cs
->status_write
, p
, i
);
703 cs
->status_write
+= i
;
704 if (cs
->status_write
> cs
->status_end
)
705 cs
->status_write
= cs
->status_buf
;
708 memcpy(cs
->status_write
, p
, len
);
709 cs
->status_write
+= len
;
711 #ifdef KERNELSTACK_DEBUG
712 i
= (ulong
) & len
- current
->kernel_stack_page
;
713 sprintf(tmpbuf
, "kstack %s %lx use %ld\n", current
->comm
,
714 current
->kernel_stack_page
, i
);
715 len
= strlen(tmpbuf
);
716 for (p
= tmpbuf
, i
= len
; i
> 0; i
--, p
++) {
717 *cs
->status_write
++ = *p
;
718 if (cs
->status_write
> cs
->status_end
)
719 cs
->status_write
= cs
->status_buf
;
723 spin_unlock_irqrestore(&cs
->statlock
, flags
);
725 ic
.command
= ISDN_STAT_STAVAIL
;
726 ic
.driver
= cs
->myid
;
728 cs
->iif
.statcallb(&ic
);
732 void HiSax_putstatus(struct IsdnCardState
*cs
, char *head
, char *fmt
, ...)
737 VHiSax_putstatus(cs
, head
, fmt
, args
);
741 int ll_run(struct IsdnCardState
*cs
, int addfeatures
)
745 ic
.driver
= cs
->myid
;
746 ic
.command
= ISDN_STAT_RUN
;
747 cs
->iif
.features
|= addfeatures
;
748 cs
->iif
.statcallb(&ic
);
752 static void ll_stop(struct IsdnCardState
*cs
)
756 ic
.command
= ISDN_STAT_STOP
;
757 ic
.driver
= cs
->myid
;
758 cs
->iif
.statcallb(&ic
);
759 // CallcFreeChan(cs);
762 static void ll_unload(struct IsdnCardState
*cs
)
766 ic
.command
= ISDN_STAT_UNLOAD
;
767 ic
.driver
= cs
->myid
;
768 cs
->iif
.statcallb(&ic
);
769 kfree(cs
->status_buf
);
770 cs
->status_read
= NULL
;
771 cs
->status_write
= NULL
;
772 cs
->status_end
= NULL
;
777 static void closecard(int cardnr
)
779 struct IsdnCardState
*csta
= cards
[cardnr
].cs
;
781 if (csta
->bcs
->BC_Close
!= NULL
) {
782 csta
->bcs
->BC_Close(csta
->bcs
+ 1);
783 csta
->bcs
->BC_Close(csta
->bcs
);
786 skb_queue_purge(&csta
->rq
);
787 skb_queue_purge(&csta
->sq
);
791 dev_kfree_skb(csta
->tx_skb
);
794 if (csta
->DC_Close
!= NULL
) {
795 csta
->DC_Close(csta
);
798 csta
->cardmsg(csta
, CARD_RELEASE
, NULL
);
799 if (csta
->dbusytimer
.function
!= NULL
) // FIXME?
800 del_timer(&csta
->dbusytimer
);
804 static irqreturn_t
card_irq(int intno
, void *dev_id
)
806 struct IsdnCardState
*cs
= dev_id
;
807 irqreturn_t ret
= cs
->irq_func(intno
, cs
);
809 if (ret
== IRQ_HANDLED
)
814 static int init_card(struct IsdnCardState
*cs
)
816 int irq_cnt
, cnt
= 3, ret
;
819 ret
= cs
->cardmsg(cs
, CARD_INIT
, NULL
);
822 irq_cnt
= cs
->irq_cnt
= 0;
823 printk(KERN_INFO
"%s: IRQ %d count %d\n", CardType
[cs
->typ
],
825 if (request_irq(cs
->irq
, card_irq
, cs
->irq_flags
, "HiSax", cs
)) {
826 printk(KERN_WARNING
"HiSax: couldn't get interrupt %d\n",
831 cs
->cardmsg(cs
, CARD_INIT
, NULL
);
834 printk(KERN_INFO
"%s: IRQ %d count %d\n",
835 CardType
[cs
->typ
], cs
->irq
, cs
->irq_cnt
);
836 if (cs
->irq_cnt
== irq_cnt
) {
838 "%s: IRQ(%d) getting no interrupts during init %d\n",
839 CardType
[cs
->typ
], cs
->irq
, 4 - cnt
);
841 free_irq(cs
->irq
, cs
);
844 cs
->cardmsg(cs
, CARD_RESET
, NULL
);
848 cs
->cardmsg(cs
, CARD_TEST
, NULL
);
855 static int hisax_cs_setup_card(struct IsdnCard
*card
)
861 case ISDN_CTYPE_16_0
:
863 ret
= setup_teles0(card
);
867 case ISDN_CTYPE_16_3
:
869 case ISDN_CTYPE_TELESPCMCIA
:
870 case ISDN_CTYPE_COMPAQ_ISA
:
871 ret
= setup_teles3(card
);
875 case ISDN_CTYPE_S0BOX
:
876 ret
= setup_s0box(card
);
880 case ISDN_CTYPE_TELESPCI
:
881 ret
= setup_telespci(card
);
886 ret
= setup_avm_a1(card
);
889 #if CARD_AVM_A1_PCMCIA
890 case ISDN_CTYPE_A1_PCMCIA
:
891 ret
= setup_avm_a1_pcmcia(card
);
895 case ISDN_CTYPE_FRITZPCI
:
896 ret
= setup_avm_pcipnp(card
);
900 case ISDN_CTYPE_ELSA
:
901 case ISDN_CTYPE_ELSA_PNP
:
902 case ISDN_CTYPE_ELSA_PCMCIA
:
903 case ISDN_CTYPE_ELSA_PCI
:
904 ret
= setup_elsa(card
);
908 case ISDN_CTYPE_IX1MICROR2
:
909 ret
= setup_ix1micro(card
);
913 case ISDN_CTYPE_DIEHLDIVA
:
914 ret
= setup_diva(card
);
918 case ISDN_CTYPE_ASUSCOM
:
919 ret
= setup_asuscom(card
);
923 case ISDN_CTYPE_TELEINT
:
924 ret
= setup_TeleInt(card
);
928 case ISDN_CTYPE_SEDLBAUER
:
929 case ISDN_CTYPE_SEDLBAUER_PCMCIA
:
930 case ISDN_CTYPE_SEDLBAUER_FAX
:
931 ret
= setup_sedlbauer(card
);
935 case ISDN_CTYPE_SPORTSTER
:
936 ret
= setup_sportster(card
);
941 ret
= setup_mic(card
);
945 case ISDN_CTYPE_NETJET_S
:
946 ret
= setup_netjet_s(card
);
950 case ISDN_CTYPE_TELES3C
:
951 case ISDN_CTYPE_ACERP10
:
952 ret
= setup_hfcs(card
);
956 case ISDN_CTYPE_HFC_PCI
:
957 ret
= setup_hfcpci(card
);
961 case ISDN_CTYPE_HFC_SX
:
962 ret
= setup_hfcsx(card
);
966 case ISDN_CTYPE_NICCY
:
967 ret
= setup_niccy(card
);
971 case ISDN_CTYPE_ISURF
:
972 ret
= setup_isurf(card
);
976 case ISDN_CTYPE_HSTSAPHIR
:
977 ret
= setup_saphir(card
);
981 case ISDN_CTYPE_BKM_A4T
:
982 ret
= setup_bkm_a4t(card
);
986 case ISDN_CTYPE_SCT_QUADRO
:
987 ret
= setup_sct_quadro(card
);
991 case ISDN_CTYPE_GAZEL
:
992 ret
= setup_gazel(card
);
996 case ISDN_CTYPE_W6692
:
997 ret
= setup_w6692(card
);
1001 case ISDN_CTYPE_NETJET_U
:
1002 ret
= setup_netjet_u(card
);
1005 #if CARD_FN_ENTERNOW_PCI
1006 case ISDN_CTYPE_ENTERNOW
:
1007 ret
= setup_enternow_pci(card
);
1010 case ISDN_CTYPE_DYNAMIC
:
1015 "HiSax: Support for %s Card not selected\n",
1016 CardType
[card
->typ
]);
1024 static int hisax_cs_new(int cardnr
, char *id
, struct IsdnCard
*card
,
1025 struct IsdnCardState
**cs_out
, int *busy_flag
,
1026 struct module
*lockowner
)
1028 struct IsdnCardState
*cs
;
1032 cs
= kzalloc(sizeof(struct IsdnCardState
), GFP_ATOMIC
);
1035 "HiSax: No memory for IsdnCardState(card %d)\n",
1040 spin_lock_init(&cs
->statlock
);
1041 spin_lock_init(&cs
->lock
);
1042 cs
->chanlimit
= 2; /* maximum B-channel number */
1043 cs
->logecho
= 0; /* No echo logging */
1044 cs
->cardnr
= cardnr
;
1045 cs
->debug
= L1_DEB_WARN
;
1047 cs
->busy_flag
= busy_flag
;
1048 cs
->irq_flags
= I4L_IRQ_FLAG
;
1050 if (card
->protocol
== ISDN_PTYPE_NI1
)
1051 test_and_set_bit(FLG_TWO_DCHAN
, &cs
->HW_Flags
);
1053 test_and_set_bit(FLG_TWO_DCHAN
, &cs
->HW_Flags
);
1055 cs
->protocol
= card
->protocol
;
1057 if (card
->typ
<= 0 || card
->typ
> ISDN_CTYPE_COUNT
) {
1059 "HiSax: Card Type %d out of range\n", card
->typ
);
1062 if (!(cs
->dlog
= kmalloc(MAX_DLOG_SPACE
, GFP_ATOMIC
))) {
1064 "HiSax: No memory for dlog(card %d)\n", cardnr
+ 1);
1067 if (!(cs
->status_buf
= kmalloc(HISAX_STATUS_BUFSIZE
, GFP_ATOMIC
))) {
1069 "HiSax: No memory for status_buf(card %d)\n",
1074 cs
->status_read
= cs
->status_buf
;
1075 cs
->status_write
= cs
->status_buf
;
1076 cs
->status_end
= cs
->status_buf
+ HISAX_STATUS_BUFSIZE
- 1;
1077 cs
->typ
= card
->typ
;
1079 cs
->iif
.owner
= lockowner
;
1081 strcpy(cs
->iif
.id
, id
);
1082 cs
->iif
.channels
= 2;
1083 cs
->iif
.maxbufsize
= MAX_DATA_SIZE
;
1084 cs
->iif
.hl_hdrlen
= MAX_HEADER_LEN
;
1086 ISDN_FEATURE_L2_X75I
|
1087 ISDN_FEATURE_L2_HDLC
|
1088 ISDN_FEATURE_L2_HDLC_56K
|
1089 ISDN_FEATURE_L2_TRANS
|
1090 ISDN_FEATURE_L3_TRANS
|
1091 #ifdef CONFIG_HISAX_1TR6
1092 ISDN_FEATURE_P_1TR6
|
1094 #ifdef CONFIG_HISAX_EURO
1095 ISDN_FEATURE_P_EURO
|
1097 #ifdef CONFIG_HISAX_NI1
1098 ISDN_FEATURE_P_NI1
|
1102 cs
->iif
.command
= HiSax_command
;
1103 cs
->iif
.writecmd
= NULL
;
1104 cs
->iif
.writebuf_skb
= HiSax_writebuf_skb
;
1105 cs
->iif
.readstat
= HiSax_readstatus
;
1106 register_isdn(&cs
->iif
);
1107 cs
->myid
= cs
->iif
.channels
;
1110 return 1; /* success */
1118 return 0; /* error */
1121 static int hisax_cs_setup(int cardnr
, struct IsdnCard
*card
,
1122 struct IsdnCardState
*cs
)
1126 if (!(cs
->rcvbuf
= kmalloc(MAX_DFRAME_LEN_L1
, GFP_ATOMIC
))) {
1127 printk(KERN_WARNING
"HiSax: No memory for isac rcvbuf\n");
1136 skb_queue_head_init(&cs
->rq
);
1137 skb_queue_head_init(&cs
->sq
);
1139 init_bcstate(cs
, 0);
1140 init_bcstate(cs
, 1);
1142 /* init_card only handles interrupts which are not */
1143 /* used here for the loadable driver */
1144 switch (card
->typ
) {
1145 case ISDN_CTYPE_DYNAMIC
:
1149 ret
= init_card(cs
);
1156 init_tei(cs
, cs
->protocol
);
1157 ret
= CallcNewChan(cs
);
1162 /* ISAR needs firmware download first */
1163 if (!test_bit(HW_ISAR
, &cs
->HW_Flags
))
1174 static int checkcard(int cardnr
, char *id
, int *busy_flag
,
1175 struct module
*lockowner
, hisax_setup_func_t card_setup
)
1178 struct IsdnCard
*card
= cards
+ cardnr
;
1179 struct IsdnCardState
*cs
;
1181 ret
= hisax_cs_new(cardnr
, id
, card
, &cs
, busy_flag
, lockowner
);
1186 "HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr
+ 1,
1187 (card
->protocol
== ISDN_PTYPE_1TR6
) ? "1TR6" :
1188 (card
->protocol
== ISDN_PTYPE_EURO
) ? "EDSS1" :
1189 (card
->protocol
== ISDN_PTYPE_LEASED
) ? "LEASED" :
1190 (card
->protocol
== ISDN_PTYPE_NI1
) ? "NI1" :
1191 "NONE", cs
->iif
.id
, cs
->myid
);
1193 ret
= card_setup(card
);
1199 ret
= hisax_cs_setup(cardnr
, card
, cs
);
1209 static void HiSax_shiftcards(int idx
)
1213 for (i
= idx
; i
< (HISAX_MAX_CARDS
- 1); i
++)
1214 memcpy(&cards
[i
], &cards
[i
+ 1], sizeof(cards
[i
]));
1217 static int __init
HiSax_inithardware(int *busy_flag
)
1224 char *next_id
= HiSax_id
;
1227 if (strchr(HiSax_id
, ','))
1229 else if (strchr(HiSax_id
, '%'))
1232 while (i
< nrcards
) {
1233 if (cards
[i
].typ
< 1)
1236 if ((next_id
= strchr(id
, t
))) {
1245 sprintf(ids
, "%s%d", id
, i
);
1247 if (checkcard(i
, ids
, busy_flag
, THIS_MODULE
,
1248 hisax_cs_setup_card
)) {
1252 /* make sure we don't oops the module */
1253 if (cards
[i
].typ
> 0 && cards
[i
].typ
<= ISDN_CTYPE_COUNT
) {
1255 "HiSax: Card %s not installed !\n",
1256 CardType
[cards
[i
].typ
]);
1258 HiSax_shiftcards(i
);
1265 void HiSax_closecard(int cardnr
)
1267 int i
, last
= nrcards
- 1;
1269 if (cardnr
> last
|| cardnr
< 0)
1271 if (cards
[cardnr
].cs
) {
1272 ll_stop(cards
[cardnr
].cs
);
1273 release_tei(cards
[cardnr
].cs
);
1274 CallcFreeChan(cards
[cardnr
].cs
);
1277 if (cards
[cardnr
].cs
->irq
)
1278 free_irq(cards
[cardnr
].cs
->irq
, cards
[cardnr
].cs
);
1279 kfree((void *) cards
[cardnr
].cs
);
1280 cards
[cardnr
].cs
= NULL
;
1284 cards
[i
] = cards
[i
+ 1];
1290 void HiSax_reportcard(int cardnr
, int sel
)
1292 struct IsdnCardState
*cs
= cards
[cardnr
].cs
;
1294 printk(KERN_DEBUG
"HiSax: reportcard No %d\n", cardnr
+ 1);
1295 printk(KERN_DEBUG
"HiSax: Type %s\n", CardType
[cs
->typ
]);
1296 printk(KERN_DEBUG
"HiSax: debuglevel %x\n", cs
->debug
);
1297 printk(KERN_DEBUG
"HiSax: HiSax_reportcard address 0x%lX\n",
1298 (ulong
) & HiSax_reportcard
);
1299 printk(KERN_DEBUG
"HiSax: cs 0x%lX\n", (ulong
) cs
);
1300 printk(KERN_DEBUG
"HiSax: HW_Flags %lx bc0 flg %lx bc1 flg %lx\n",
1301 cs
->HW_Flags
, cs
->bcs
[0].Flag
, cs
->bcs
[1].Flag
);
1302 printk(KERN_DEBUG
"HiSax: bcs 0 mode %d ch%d\n",
1303 cs
->bcs
[0].mode
, cs
->bcs
[0].channel
);
1304 printk(KERN_DEBUG
"HiSax: bcs 1 mode %d ch%d\n",
1305 cs
->bcs
[1].mode
, cs
->bcs
[1].channel
);
1306 #ifdef ERROR_STATISTIC
1307 printk(KERN_DEBUG
"HiSax: dc errors(rx,crc,tx) %d,%d,%d\n",
1308 cs
->err_rx
, cs
->err_crc
, cs
->err_tx
);
1310 "HiSax: bc0 errors(inv,rdo,crc,tx) %d,%d,%d,%d\n",
1311 cs
->bcs
[0].err_inv
, cs
->bcs
[0].err_rdo
, cs
->bcs
[0].err_crc
,
1314 "HiSax: bc1 errors(inv,rdo,crc,tx) %d,%d,%d,%d\n",
1315 cs
->bcs
[1].err_inv
, cs
->bcs
[1].err_rdo
, cs
->bcs
[1].err_crc
,
1321 cs
->bcs
[0].err_inv
= 0;
1322 cs
->bcs
[0].err_rdo
= 0;
1323 cs
->bcs
[0].err_crc
= 0;
1324 cs
->bcs
[0].err_tx
= 0;
1325 cs
->bcs
[1].err_inv
= 0;
1326 cs
->bcs
[1].err_rdo
= 0;
1327 cs
->bcs
[1].err_crc
= 0;
1328 cs
->bcs
[1].err_tx
= 0;
1333 static int __init
HiSax_init(void)
1342 retval
= CallcNew();
1345 retval
= Isdnl3New();
1348 retval
= Isdnl2New();
1354 retval
= Isdnl1New();
1360 /* We 'll register drivers later, but init basic functions */
1361 for (i
= 0; i
< HISAX_MAX_CARDS
; i
++)
1365 #ifdef CONFIG_HISAX_ELSA
1366 if (type
[0] == ISDN_CTYPE_ELSA_PCMCIA
) {
1367 /* we have exported and return in this case */
1371 #ifdef CONFIG_HISAX_SEDLBAUER
1372 if (type
[0] == ISDN_CTYPE_SEDLBAUER_PCMCIA
) {
1373 /* we have to export and return in this case */
1377 #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
1378 if (type
[0] == ISDN_CTYPE_A1_PCMCIA
) {
1379 /* we have to export and return in this case */
1383 #ifdef CONFIG_HISAX_HFC_SX
1384 if (type
[0] == ISDN_CTYPE_HFC_SP_PCMCIA
) {
1385 /* we have to export and return in this case */
1392 if (id
) /* If id= string used */
1394 for (i
= j
= 0; j
< HISAX_MAX_CARDS
; i
++) {
1395 cards
[j
].typ
= type
[i
];
1397 cards
[j
].protocol
= protocol
[i
];
1400 cards
[j
].protocol
= DEFAULT_PROTO
;
1403 case ISDN_CTYPE_16_0
:
1404 cards
[j
].para
[0] = irq
[i
];
1405 cards
[j
].para
[1] = mem
[i
];
1406 cards
[j
].para
[2] = io
[i
];
1409 case ISDN_CTYPE_8_0
:
1410 cards
[j
].para
[0] = irq
[i
];
1411 cards
[j
].para
[1] = mem
[i
];
1415 case ISDN_CTYPE_PNP
:
1416 case ISDN_CTYPE_NICCY
:
1417 cards
[j
].para
[0] = irq
[i
];
1418 cards
[j
].para
[1] = io0
[i
];
1419 cards
[j
].para
[2] = io1
[i
];
1421 case ISDN_CTYPE_COMPAQ_ISA
:
1422 cards
[j
].para
[0] = irq
[i
];
1423 cards
[j
].para
[1] = io0
[i
];
1424 cards
[j
].para
[2] = io1
[i
];
1425 cards
[j
].para
[3] = io
[i
];
1428 case ISDN_CTYPE_ELSA
:
1429 case ISDN_CTYPE_HFC_PCI
:
1430 cards
[j
].para
[0] = io
[i
];
1432 case ISDN_CTYPE_16_3
:
1433 case ISDN_CTYPE_TELESPCMCIA
:
1435 case ISDN_CTYPE_A1_PCMCIA
:
1436 case ISDN_CTYPE_ELSA_PNP
:
1437 case ISDN_CTYPE_ELSA_PCMCIA
:
1438 case ISDN_CTYPE_IX1MICROR2
:
1439 case ISDN_CTYPE_DIEHLDIVA
:
1440 case ISDN_CTYPE_ASUSCOM
:
1441 case ISDN_CTYPE_TELEINT
:
1442 case ISDN_CTYPE_SEDLBAUER
:
1443 case ISDN_CTYPE_SEDLBAUER_PCMCIA
:
1444 case ISDN_CTYPE_SEDLBAUER_FAX
:
1445 case ISDN_CTYPE_SPORTSTER
:
1446 case ISDN_CTYPE_MIC
:
1447 case ISDN_CTYPE_TELES3C
:
1448 case ISDN_CTYPE_ACERP10
:
1449 case ISDN_CTYPE_S0BOX
:
1450 case ISDN_CTYPE_FRITZPCI
:
1451 case ISDN_CTYPE_HSTSAPHIR
:
1452 case ISDN_CTYPE_GAZEL
:
1453 case ISDN_CTYPE_HFC_SX
:
1454 case ISDN_CTYPE_HFC_SP_PCMCIA
:
1455 cards
[j
].para
[0] = irq
[i
];
1456 cards
[j
].para
[1] = io
[i
];
1458 case ISDN_CTYPE_ISURF
:
1459 cards
[j
].para
[0] = irq
[i
];
1460 cards
[j
].para
[1] = io
[i
];
1461 cards
[j
].para
[2] = mem
[i
];
1463 case ISDN_CTYPE_ELSA_PCI
:
1464 case ISDN_CTYPE_NETJET_S
:
1465 case ISDN_CTYPE_TELESPCI
:
1466 case ISDN_CTYPE_W6692
:
1467 case ISDN_CTYPE_NETJET_U
:
1469 case ISDN_CTYPE_BKM_A4T
:
1471 case ISDN_CTYPE_SCT_QUADRO
:
1473 cards
[j
].para
[0] = irq
[i
];
1475 /* QUADRO is a 4 BRI card */
1476 cards
[j
++].para
[0] = 1;
1477 /* we need to check if further cards can be added */
1478 if (j
< HISAX_MAX_CARDS
) {
1479 cards
[j
].typ
= ISDN_CTYPE_SCT_QUADRO
;
1480 cards
[j
].protocol
= protocol
[i
];
1481 cards
[j
++].para
[0] = 2;
1483 if (j
< HISAX_MAX_CARDS
) {
1484 cards
[j
].typ
= ISDN_CTYPE_SCT_QUADRO
;
1485 cards
[j
].protocol
= protocol
[i
];
1486 cards
[j
++].para
[0] = 3;
1488 if (j
< HISAX_MAX_CARDS
) {
1489 cards
[j
].typ
= ISDN_CTYPE_SCT_QUADRO
;
1490 cards
[j
].protocol
= protocol
[i
];
1491 cards
[j
].para
[0] = 4;
1500 "HiSax: Warning - no protocol specified\n");
1501 printk(KERN_WARNING
"HiSax: using protocol %s\n",
1502 DEFAULT_PROTO_NAME
);
1508 strcpy(HiSaxID
, "HiSax");
1509 for (i
= 0; i
< HISAX_MAX_CARDS
; i
++)
1510 if (cards
[i
].typ
> 0)
1512 printk(KERN_DEBUG
"HiSax: Total %d card%s defined\n",
1513 nrcards
, (nrcards
> 1) ? "s" : "");
1515 /* Install only, if at least one card found */
1516 if (!HiSax_inithardware(NULL
))
1532 static void __exit
HiSax_exit(void)
1534 int cardnr
= nrcards
- 1;
1537 HiSax_closecard(cardnr
--);
1543 printk(KERN_INFO
"HiSax module removed\n");
1546 int hisax_init_pcmcia(void *pcm_iob
, int *busy_flag
, struct IsdnCard
*card
)
1551 cards
[nrcards
] = *card
;
1553 sprintf(ids
, "HiSax%d", nrcards
);
1555 sprintf(ids
, "HiSax");
1556 if (!checkcard(nrcards
, ids
, busy_flag
, THIS_MODULE
,
1557 hisax_cs_setup_card
))
1565 EXPORT_SYMBOL(hisax_init_pcmcia
);
1567 EXPORT_SYMBOL(HiSax_closecard
);
1569 #include "hisax_if.h"
1571 EXPORT_SYMBOL(hisax_register
);
1572 EXPORT_SYMBOL(hisax_unregister
);
1574 static void hisax_d_l1l2(struct hisax_if
*ifc
, int pr
, void *arg
);
1575 static void hisax_b_l1l2(struct hisax_if
*ifc
, int pr
, void *arg
);
1576 static void hisax_d_l2l1(struct PStack
*st
, int pr
, void *arg
);
1577 static void hisax_b_l2l1(struct PStack
*st
, int pr
, void *arg
);
1578 static int hisax_cardmsg(struct IsdnCardState
*cs
, int mt
, void *arg
);
1579 static int hisax_bc_setstack(struct PStack
*st
, struct BCState
*bcs
);
1580 static void hisax_bc_close(struct BCState
*bcs
);
1581 static void hisax_bh(struct work_struct
*work
);
1582 static void EChannel_proc_rcv(struct hisax_d_if
*d_if
);
1584 static int hisax_setup_card_dynamic(struct IsdnCard
*card
)
1589 int hisax_register(struct hisax_d_if
*hisax_d_if
, struct hisax_b_if
*b_if
[],
1590 char *name
, int protocol
)
1594 struct IsdnCardState
*cs
;
1596 for (i
= 0; i
< HISAX_MAX_CARDS
; i
++) {
1601 if (i
>= HISAX_MAX_CARDS
)
1604 cards
[i
].typ
= ISDN_CTYPE_DYNAMIC
;
1605 cards
[i
].protocol
= protocol
;
1606 sprintf(id
, "%s%d", name
, i
);
1608 retval
= checkcard(i
, id
, NULL
, hisax_d_if
->owner
,
1609 hisax_setup_card_dynamic
);
1610 if (retval
== 0) { // yuck
1616 hisax_d_if
->cs
= cs
;
1617 cs
->hw
.hisax_d_if
= hisax_d_if
;
1618 cs
->cardmsg
= hisax_cardmsg
;
1619 INIT_WORK(&cs
->tqueue
, hisax_bh
);
1620 cs
->channel
[0].d_st
->l2
.l2l1
= hisax_d_l2l1
;
1621 for (i
= 0; i
< 2; i
++) {
1622 cs
->bcs
[i
].BC_SetStack
= hisax_bc_setstack
;
1623 cs
->bcs
[i
].BC_Close
= hisax_bc_close
;
1625 b_if
[i
]->ifc
.l1l2
= hisax_b_l1l2
;
1627 hisax_d_if
->b_if
[i
] = b_if
[i
];
1629 hisax_d_if
->ifc
.l1l2
= hisax_d_l1l2
;
1630 skb_queue_head_init(&hisax_d_if
->erq
);
1631 clear_bit(0, &hisax_d_if
->ph_state
);
1636 void hisax_unregister(struct hisax_d_if
*hisax_d_if
)
1638 cards
[hisax_d_if
->cs
->cardnr
].typ
= 0;
1639 HiSax_closecard(hisax_d_if
->cs
->cardnr
);
1640 skb_queue_purge(&hisax_d_if
->erq
);
1645 static void hisax_sched_event(struct IsdnCardState
*cs
, int event
)
1647 test_and_set_bit(event
, &cs
->event
);
1648 schedule_work(&cs
->tqueue
);
1651 static void hisax_bh(struct work_struct
*work
)
1653 struct IsdnCardState
*cs
=
1654 container_of(work
, struct IsdnCardState
, tqueue
);
1658 if (test_and_clear_bit(D_RCVBUFREADY
, &cs
->event
))
1659 DChannel_proc_rcv(cs
);
1660 if (test_and_clear_bit(E_RCVBUFREADY
, &cs
->event
))
1661 EChannel_proc_rcv(cs
->hw
.hisax_d_if
);
1662 if (test_and_clear_bit(D_L1STATECHANGE
, &cs
->event
)) {
1663 if (test_bit(0, &cs
->hw
.hisax_d_if
->ph_state
))
1664 pr
= PH_ACTIVATE
| INDICATION
;
1666 pr
= PH_DEACTIVATE
| INDICATION
;
1667 for (st
= cs
->stlist
; st
; st
= st
->next
)
1668 st
->l1
.l1l2(st
, pr
, NULL
);
1673 static void hisax_b_sched_event(struct BCState
*bcs
, int event
)
1675 test_and_set_bit(event
, &bcs
->event
);
1676 schedule_work(&bcs
->tqueue
);
1679 static inline void D_L2L1(struct hisax_d_if
*d_if
, int pr
, void *arg
)
1681 struct hisax_if
*ifc
= (struct hisax_if
*) d_if
;
1682 ifc
->l2l1(ifc
, pr
, arg
);
1685 static inline void B_L2L1(struct hisax_b_if
*b_if
, int pr
, void *arg
)
1687 struct hisax_if
*ifc
= (struct hisax_if
*) b_if
;
1688 ifc
->l2l1(ifc
, pr
, arg
);
1691 static void hisax_d_l1l2(struct hisax_if
*ifc
, int pr
, void *arg
)
1693 struct hisax_d_if
*d_if
= (struct hisax_d_if
*) ifc
;
1694 struct IsdnCardState
*cs
= d_if
->cs
;
1696 struct sk_buff
*skb
;
1699 case PH_ACTIVATE
| INDICATION
:
1700 set_bit(0, &d_if
->ph_state
);
1701 hisax_sched_event(cs
, D_L1STATECHANGE
);
1703 case PH_DEACTIVATE
| INDICATION
:
1704 clear_bit(0, &d_if
->ph_state
);
1705 hisax_sched_event(cs
, D_L1STATECHANGE
);
1707 case PH_DATA
| INDICATION
:
1708 skb_queue_tail(&cs
->rq
, arg
);
1709 hisax_sched_event(cs
, D_RCVBUFREADY
);
1711 case PH_DATA
| CONFIRM
:
1712 skb
= skb_dequeue(&cs
->sq
);
1714 D_L2L1(d_if
, PH_DATA
| REQUEST
, skb
);
1717 clear_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
);
1718 for (st
= cs
->stlist
; st
; st
= st
->next
) {
1719 if (test_and_clear_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
)) {
1720 st
->l1
.l1l2(st
, PH_PULL
| CONFIRM
, NULL
);
1725 case PH_DATA_E
| INDICATION
:
1726 skb_queue_tail(&d_if
->erq
, arg
);
1727 hisax_sched_event(cs
, E_RCVBUFREADY
);
1730 printk("pr %#x\n", pr
);
1735 static void hisax_b_l1l2(struct hisax_if
*ifc
, int pr
, void *arg
)
1737 struct hisax_b_if
*b_if
= (struct hisax_b_if
*) ifc
;
1738 struct BCState
*bcs
= b_if
->bcs
;
1739 struct PStack
*st
= bcs
->st
;
1740 struct sk_buff
*skb
;
1742 // FIXME use isdnl1?
1744 case PH_ACTIVATE
| INDICATION
:
1745 st
->l1
.l1l2(st
, pr
, NULL
);
1747 case PH_DEACTIVATE
| INDICATION
:
1748 st
->l1
.l1l2(st
, pr
, NULL
);
1749 clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1750 skb_queue_purge(&bcs
->squeue
);
1751 bcs
->hw
.b_if
= NULL
;
1753 case PH_DATA
| INDICATION
:
1754 skb_queue_tail(&bcs
->rqueue
, arg
);
1755 hisax_b_sched_event(bcs
, B_RCVBUFREADY
);
1757 case PH_DATA
| CONFIRM
:
1758 bcs
->tx_cnt
-= (long)arg
;
1759 if (test_bit(FLG_LLI_L1WAKEUP
, &bcs
->st
->lli
.flag
)) {
1761 spin_lock_irqsave(&bcs
->aclock
, flags
);
1762 bcs
->ackcnt
+= (long)arg
;
1763 spin_unlock_irqrestore(&bcs
->aclock
, flags
);
1764 schedule_event(bcs
, B_ACKPENDING
);
1766 skb
= skb_dequeue(&bcs
->squeue
);
1768 B_L2L1(b_if
, PH_DATA
| REQUEST
, skb
);
1771 clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1772 if (test_and_clear_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
)) {
1773 st
->l1
.l1l2(st
, PH_PULL
| CONFIRM
, NULL
);
1777 printk("hisax_b_l1l2 pr %#x\n", pr
);
1782 static void hisax_d_l2l1(struct PStack
*st
, int pr
, void *arg
)
1784 struct IsdnCardState
*cs
= st
->l1
.hardware
;
1785 struct hisax_d_if
*hisax_d_if
= cs
->hw
.hisax_d_if
;
1786 struct sk_buff
*skb
= arg
;
1789 case PH_DATA
| REQUEST
:
1790 case PH_PULL
| INDICATION
:
1791 if (cs
->debug
& DEB_DLOG_HEX
)
1792 LogFrame(cs
, skb
->data
, skb
->len
);
1793 if (cs
->debug
& DEB_DLOG_VERBOSE
)
1794 dlogframe(cs
, skb
, 0);
1795 Logl2Frame(cs
, skb
, "PH_DATA_REQ", 0);
1797 if (!test_and_set_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
))
1798 D_L2L1(hisax_d_if
, PH_DATA
| REQUEST
, skb
);
1800 skb_queue_tail(&cs
->sq
, skb
);
1802 case PH_PULL
| REQUEST
:
1803 if (!test_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
))
1804 st
->l1
.l1l2(st
, PH_PULL
| CONFIRM
, NULL
);
1806 set_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
);
1809 D_L2L1(hisax_d_if
, pr
, arg
);
1814 static int hisax_cardmsg(struct IsdnCardState
*cs
, int mt
, void *arg
)
1819 static void hisax_b_l2l1(struct PStack
*st
, int pr
, void *arg
)
1821 struct BCState
*bcs
= st
->l1
.bcs
;
1822 struct hisax_b_if
*b_if
= bcs
->hw
.b_if
;
1825 case PH_ACTIVATE
| REQUEST
:
1826 B_L2L1(b_if
, pr
, (void *)(unsigned long)st
->l1
.mode
);
1828 case PH_DATA
| REQUEST
:
1829 case PH_PULL
| INDICATION
:
1831 if (!test_and_set_bit(BC_FLG_BUSY
, &bcs
->Flag
)) {
1832 B_L2L1(b_if
, PH_DATA
| REQUEST
, arg
);
1834 skb_queue_tail(&bcs
->squeue
, arg
);
1837 case PH_PULL
| REQUEST
:
1838 if (!test_bit(BC_FLG_BUSY
, &bcs
->Flag
))
1839 st
->l1
.l1l2(st
, PH_PULL
| CONFIRM
, NULL
);
1841 set_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
);
1843 case PH_DEACTIVATE
| REQUEST
:
1844 test_and_clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1845 skb_queue_purge(&bcs
->squeue
);
1847 B_L2L1(b_if
, pr
, arg
);
1852 static int hisax_bc_setstack(struct PStack
*st
, struct BCState
*bcs
)
1854 struct IsdnCardState
*cs
= st
->l1
.hardware
;
1855 struct hisax_d_if
*hisax_d_if
= cs
->hw
.hisax_d_if
;
1857 bcs
->channel
= st
->l1
.bc
;
1859 bcs
->hw
.b_if
= hisax_d_if
->b_if
[st
->l1
.bc
];
1860 hisax_d_if
->b_if
[st
->l1
.bc
]->bcs
= bcs
;
1863 st
->l2
.l2l1
= hisax_b_l2l1
;
1864 setstack_manager(st
);
1867 skb_queue_head_init(&bcs
->rqueue
);
1868 skb_queue_head_init(&bcs
->squeue
);
1872 static void hisax_bc_close(struct BCState
*bcs
)
1874 struct hisax_b_if
*b_if
= bcs
->hw
.b_if
;
1877 B_L2L1(b_if
, PH_DEACTIVATE
| REQUEST
, NULL
);
1880 static void EChannel_proc_rcv(struct hisax_d_if
*d_if
)
1882 struct IsdnCardState
*cs
= d_if
->cs
;
1884 struct sk_buff
*skb
;
1886 while ((skb
= skb_dequeue(&d_if
->erq
)) != NULL
) {
1887 if (cs
->debug
& DEB_DLOG_HEX
) {
1889 if ((skb
->len
) < MAX_DLOG_SPACE
/ 3 - 10) {
1895 ptr
+= QuickHex(ptr
, skb
->data
, skb
->len
);
1899 HiSax_putstatus(cs
, NULL
, cs
->dlog
);
1901 HiSax_putstatus(cs
, "LogEcho: ",
1902 "warning Frame too big (%d)",
1905 dev_kfree_skb_any(skb
);
1910 #include <linux/pci.h>
1912 static struct pci_device_id hisax_pci_tbl
[] __used
= {
1913 #ifdef CONFIG_HISAX_FRITZPCI
1914 {PCI_VDEVICE(AVM
, PCI_DEVICE_ID_AVM_A1
) },
1916 #ifdef CONFIG_HISAX_DIEHLDIVA
1917 {PCI_VDEVICE(EICON
, PCI_DEVICE_ID_EICON_DIVA20
) },
1918 {PCI_VDEVICE(EICON
, PCI_DEVICE_ID_EICON_DIVA20_U
) },
1919 {PCI_VDEVICE(EICON
, PCI_DEVICE_ID_EICON_DIVA201
) },
1920 /*##########################################################################*/
1921 {PCI_VDEVICE(EICON
, PCI_DEVICE_ID_EICON_DIVA202
) },
1922 /*##########################################################################*/
1924 #ifdef CONFIG_HISAX_ELSA
1925 {PCI_VDEVICE(ELSA
, PCI_DEVICE_ID_ELSA_MICROLINK
) },
1926 {PCI_VDEVICE(ELSA
, PCI_DEVICE_ID_ELSA_QS3000
) },
1928 #ifdef CONFIG_HISAX_GAZEL
1929 {PCI_VDEVICE(PLX
, PCI_DEVICE_ID_PLX_R685
) },
1930 {PCI_VDEVICE(PLX
, PCI_DEVICE_ID_PLX_R753
) },
1931 {PCI_VDEVICE(PLX
, PCI_DEVICE_ID_PLX_DJINN_ITOO
) },
1932 {PCI_VDEVICE(PLX
, PCI_DEVICE_ID_PLX_OLITEC
) },
1934 #ifdef CONFIG_HISAX_SCT_QUADRO
1935 {PCI_VDEVICE(PLX
, PCI_DEVICE_ID_PLX_9050
) },
1937 #ifdef CONFIG_HISAX_NICCY
1938 {PCI_VDEVICE(SATSAGEM
, PCI_DEVICE_ID_SATSAGEM_NICCY
) },
1940 #ifdef CONFIG_HISAX_SEDLBAUER
1941 {PCI_VDEVICE(TIGERJET
, PCI_DEVICE_ID_TIGERJET_100
) },
1943 #if defined(CONFIG_HISAX_NETJET) || defined(CONFIG_HISAX_NETJET_U)
1944 {PCI_VDEVICE(TIGERJET
, PCI_DEVICE_ID_TIGERJET_300
) },
1946 #if defined(CONFIG_HISAX_TELESPCI) || defined(CONFIG_HISAX_SCT_QUADRO)
1947 {PCI_VDEVICE(ZORAN
, PCI_DEVICE_ID_ZORAN_36120
) },
1949 #ifdef CONFIG_HISAX_W6692
1950 {PCI_VDEVICE(DYNALINK
, PCI_DEVICE_ID_DYNALINK_IS64PH
) },
1951 {PCI_VDEVICE(WINBOND2
, PCI_DEVICE_ID_WINBOND2_6692
) },
1953 #ifdef CONFIG_HISAX_HFC_PCI
1954 {PCI_VDEVICE(CCD
, PCI_DEVICE_ID_CCD_2BD0
) },
1955 {PCI_VDEVICE(CCD
, PCI_DEVICE_ID_CCD_B000
) },
1956 {PCI_VDEVICE(CCD
, PCI_DEVICE_ID_CCD_B006
) },
1957 {PCI_VDEVICE(CCD
, PCI_DEVICE_ID_CCD_B007
) },
1958 {PCI_VDEVICE(CCD
, PCI_DEVICE_ID_CCD_B008
) },
1959 {PCI_VDEVICE(CCD
, PCI_DEVICE_ID_CCD_B009
) },
1960 {PCI_VDEVICE(CCD
, PCI_DEVICE_ID_CCD_B00A
) },
1961 {PCI_VDEVICE(CCD
, PCI_DEVICE_ID_CCD_B00B
) },
1962 {PCI_VDEVICE(CCD
, PCI_DEVICE_ID_CCD_B00C
) },
1963 {PCI_VDEVICE(CCD
, PCI_DEVICE_ID_CCD_B100
) },
1964 {PCI_VDEVICE(CCD
, PCI_DEVICE_ID_CCD_B700
) },
1965 {PCI_VDEVICE(CCD
, PCI_DEVICE_ID_CCD_B701
) },
1966 {PCI_VDEVICE(ABOCOM
, PCI_DEVICE_ID_ABOCOM_2BD1
) },
1967 {PCI_VDEVICE(ASUSTEK
, PCI_DEVICE_ID_ASUSTEK_0675
) },
1968 {PCI_VDEVICE(BERKOM
, PCI_DEVICE_ID_BERKOM_T_CONCEPT
) },
1969 {PCI_VDEVICE(BERKOM
, PCI_DEVICE_ID_BERKOM_A1T
) },
1970 {PCI_VDEVICE(ANIGMA
, PCI_DEVICE_ID_ANIGMA_MC145575
) },
1971 {PCI_VDEVICE(ZOLTRIX
, PCI_DEVICE_ID_ZOLTRIX_2BD0
) },
1972 {PCI_VDEVICE(DIGI
, PCI_DEVICE_ID_DIGI_DF_M_IOM2_E
) },
1973 {PCI_VDEVICE(DIGI
, PCI_DEVICE_ID_DIGI_DF_M_E
) },
1974 {PCI_VDEVICE(DIGI
, PCI_DEVICE_ID_DIGI_DF_M_IOM2_A
) },
1975 {PCI_VDEVICE(DIGI
, PCI_DEVICE_ID_DIGI_DF_M_A
) },
1977 { } /* Terminating entry */
1980 MODULE_DEVICE_TABLE(pci
, hisax_pci_tbl
);
1981 #endif /* CONFIG_PCI */
1983 module_init(HiSax_init
);
1984 module_exit(HiSax_exit
);
1986 EXPORT_SYMBOL(FsmNew
);
1987 EXPORT_SYMBOL(FsmFree
);
1988 EXPORT_SYMBOL(FsmEvent
);
1989 EXPORT_SYMBOL(FsmChangeState
);
1990 EXPORT_SYMBOL(FsmInitTimer
);
1991 EXPORT_SYMBOL(FsmDelTimer
);
1992 EXPORT_SYMBOL(FsmRestartTimer
);