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 extern const char *l1_revision
;
365 extern const char *l2_revision
;
366 extern const char *l3_revision
;
367 extern const char *lli_revision
;
368 extern const char *tei_revision
;
370 char *HiSax_getrev(const char *revision
)
375 if ((p
= strchr(revision
, ':'))) {
377 p
= strchr(rev
, '$');
384 static void __init
HiSaxVersion(void)
388 printk(KERN_INFO
"HiSax: Linux Driver for passive ISDN cards\n");
390 printk(KERN_INFO
"HiSax: Version 3.5 (module)\n");
392 printk(KERN_INFO
"HiSax: Version 3.5 (kernel)\n");
394 strcpy(tmp
, l1_revision
);
395 printk(KERN_INFO
"HiSax: Layer1 Revision %s\n", HiSax_getrev(tmp
));
396 strcpy(tmp
, l2_revision
);
397 printk(KERN_INFO
"HiSax: Layer2 Revision %s\n", HiSax_getrev(tmp
));
398 strcpy(tmp
, tei_revision
);
399 printk(KERN_INFO
"HiSax: TeiMgr Revision %s\n", HiSax_getrev(tmp
));
400 strcpy(tmp
, l3_revision
);
401 printk(KERN_INFO
"HiSax: Layer3 Revision %s\n", HiSax_getrev(tmp
));
402 strcpy(tmp
, lli_revision
);
403 printk(KERN_INFO
"HiSax: LinkLayer Revision %s\n",
408 #define MAX_ARG (HISAX_MAX_CARDS*5)
409 static int __init
HiSax_setup(char *line
)
412 int ints
[MAX_ARG
+ 1];
415 str
= get_options(line
, MAX_ARG
, ints
);
417 printk(KERN_DEBUG
"HiSax_setup: argc(%d) str(%s)\n", argc
, str
);
420 while (argc
&& (i
< HISAX_MAX_CARDS
)) {
421 cards
[i
].protocol
= DEFAULT_PROTO
;
423 cards
[i
].typ
= ints
[j
];
428 cards
[i
].protocol
= ints
[j
];
433 cards
[i
].para
[0] = ints
[j
];
438 cards
[i
].para
[1] = ints
[j
];
443 cards
[i
].para
[2] = ints
[j
];
450 if (strlen(str
) < HISAX_IDSIZE
)
451 strcpy(HiSaxID
, str
);
453 printk(KERN_WARNING
"HiSax: ID too long!");
455 strcpy(HiSaxID
, "HiSax");
461 __setup("hisax=", HiSax_setup
);
465 extern int setup_teles0(struct IsdnCard
*card
);
469 extern int setup_teles3(struct IsdnCard
*card
);
473 extern int setup_s0box(struct IsdnCard
*card
);
477 extern int setup_telespci(struct IsdnCard
*card
);
481 extern int setup_avm_a1(struct IsdnCard
*card
);
484 #if CARD_AVM_A1_PCMCIA
485 extern int setup_avm_a1_pcmcia(struct IsdnCard
*card
);
489 extern int setup_avm_pcipnp(struct IsdnCard
*card
);
493 extern int setup_elsa(struct IsdnCard
*card
);
497 extern int setup_ix1micro(struct IsdnCard
*card
);
501 extern int setup_diva(struct IsdnCard
*card
);
505 extern int setup_asuscom(struct IsdnCard
*card
);
509 extern int setup_TeleInt(struct IsdnCard
*card
);
513 extern int setup_sedlbauer(struct IsdnCard
*card
);
517 extern int setup_sportster(struct IsdnCard
*card
);
521 extern int setup_mic(struct IsdnCard
*card
);
525 extern int setup_netjet_s(struct IsdnCard
*card
);
529 extern int setup_hfcs(struct IsdnCard
*card
);
533 extern int setup_hfcpci(struct IsdnCard
*card
);
537 extern int setup_hfcsx(struct IsdnCard
*card
);
541 extern int setup_niccy(struct IsdnCard
*card
);
545 extern int setup_isurf(struct IsdnCard
*card
);
549 extern int setup_saphir(struct IsdnCard
*card
);
553 extern int setup_bkm_a4t(struct IsdnCard
*card
);
557 extern int setup_sct_quadro(struct IsdnCard
*card
);
561 extern int setup_gazel(struct IsdnCard
*card
);
565 extern int setup_w6692(struct IsdnCard
*card
);
569 extern int setup_netjet_u(struct IsdnCard
*card
);
572 #if CARD_FN_ENTERNOW_PCI
573 extern int setup_enternow_pci(struct IsdnCard
*card
);
577 * Find card with given driverId
579 static inline struct IsdnCardState
*hisax_findcard(int driverid
)
583 for (i
= 0; i
< nrcards
; i
++)
585 if (cards
[i
].cs
->myid
== driverid
)
591 * Find card with given card number
594 struct IsdnCardState
*hisax_get_card(int cardnr
)
596 if ((cardnr
<= nrcards
) && (cardnr
> 0))
597 if (cards
[cardnr
- 1].cs
)
598 return cards
[cardnr
- 1].cs
;
603 static int HiSax_readstatus(u_char __user
*buf
, int len
, int id
, int channel
)
606 u_char __user
*p
= buf
;
607 struct IsdnCardState
*cs
= hisax_findcard(id
);
610 if (len
> HISAX_STATUS_BUFSIZE
) {
612 "HiSax: status overflow readstat %d/%d\n",
613 len
, HISAX_STATUS_BUFSIZE
);
615 count
= cs
->status_end
- cs
->status_read
+ 1;
618 if (copy_to_user(p
, cs
->status_read
, count
))
620 cs
->status_read
+= count
;
621 if (cs
->status_read
> cs
->status_end
)
622 cs
->status_read
= cs
->status_buf
;
626 if (count
> HISAX_STATUS_BUFSIZE
)
627 cnt
= HISAX_STATUS_BUFSIZE
;
630 if (copy_to_user(p
, cs
->status_read
, cnt
))
633 cs
->status_read
+= cnt
% HISAX_STATUS_BUFSIZE
;
639 "HiSax: if_readstatus called with invalid driverId!\n");
644 int jiftime(char *s
, long mark
)
649 *s
-- = mark
% 10 + '0';
651 *s
-- = mark
% 10 + '0';
654 *s
-- = mark
% 10 + '0';
656 *s
-- = mark
% 6 + '0';
659 *s
-- = mark
% 10 + '0';
661 *s
-- = mark
% 10 + '0';
665 static u_char tmpbuf
[HISAX_STATUS_BUFSIZE
];
667 void VHiSax_putstatus(struct IsdnCardState
*cs
, char *head
, char *fmt
,
670 /* if head == NULL the fmt contains the full info */
679 printk(KERN_WARNING
"HiSax: No CardStatus for message");
682 spin_lock_irqsave(&cs
->statlock
, flags
);
685 p
+= jiftime(p
, jiffies
);
686 p
+= sprintf(p
, " %s", head
);
687 p
+= vsprintf(p
, fmt
, args
);
696 if (len
> HISAX_STATUS_BUFSIZE
) {
697 spin_unlock_irqrestore(&cs
->statlock
, flags
);
698 printk(KERN_WARNING
"HiSax: status overflow %d/%d\n",
699 len
, HISAX_STATUS_BUFSIZE
);
703 i
= cs
->status_end
- cs
->status_write
+ 1;
707 memcpy(cs
->status_write
, p
, i
);
708 cs
->status_write
+= i
;
709 if (cs
->status_write
> cs
->status_end
)
710 cs
->status_write
= cs
->status_buf
;
713 memcpy(cs
->status_write
, p
, len
);
714 cs
->status_write
+= len
;
716 #ifdef KERNELSTACK_DEBUG
717 i
= (ulong
) & len
- current
->kernel_stack_page
;
718 sprintf(tmpbuf
, "kstack %s %lx use %ld\n", current
->comm
,
719 current
->kernel_stack_page
, i
);
720 len
= strlen(tmpbuf
);
721 for (p
= tmpbuf
, i
= len
; i
> 0; i
--, p
++) {
722 *cs
->status_write
++ = *p
;
723 if (cs
->status_write
> cs
->status_end
)
724 cs
->status_write
= cs
->status_buf
;
728 spin_unlock_irqrestore(&cs
->statlock
, flags
);
730 ic
.command
= ISDN_STAT_STAVAIL
;
731 ic
.driver
= cs
->myid
;
733 cs
->iif
.statcallb(&ic
);
737 void HiSax_putstatus(struct IsdnCardState
*cs
, char *head
, char *fmt
, ...)
742 VHiSax_putstatus(cs
, head
, fmt
, args
);
746 int ll_run(struct IsdnCardState
*cs
, int addfeatures
)
750 ic
.driver
= cs
->myid
;
751 ic
.command
= ISDN_STAT_RUN
;
752 cs
->iif
.features
|= addfeatures
;
753 cs
->iif
.statcallb(&ic
);
757 static void ll_stop(struct IsdnCardState
*cs
)
761 ic
.command
= ISDN_STAT_STOP
;
762 ic
.driver
= cs
->myid
;
763 cs
->iif
.statcallb(&ic
);
764 // CallcFreeChan(cs);
767 static void ll_unload(struct IsdnCardState
*cs
)
771 ic
.command
= ISDN_STAT_UNLOAD
;
772 ic
.driver
= cs
->myid
;
773 cs
->iif
.statcallb(&ic
);
774 kfree(cs
->status_buf
);
775 cs
->status_read
= NULL
;
776 cs
->status_write
= NULL
;
777 cs
->status_end
= NULL
;
782 static void closecard(int cardnr
)
784 struct IsdnCardState
*csta
= cards
[cardnr
].cs
;
786 if (csta
->bcs
->BC_Close
!= NULL
) {
787 csta
->bcs
->BC_Close(csta
->bcs
+ 1);
788 csta
->bcs
->BC_Close(csta
->bcs
);
791 skb_queue_purge(&csta
->rq
);
792 skb_queue_purge(&csta
->sq
);
796 dev_kfree_skb(csta
->tx_skb
);
799 if (csta
->DC_Close
!= NULL
) {
800 csta
->DC_Close(csta
);
803 csta
->cardmsg(csta
, CARD_RELEASE
, NULL
);
804 if (csta
->dbusytimer
.function
!= NULL
) // FIXME?
805 del_timer(&csta
->dbusytimer
);
809 static int init_card(struct IsdnCardState
*cs
)
811 int irq_cnt
, cnt
= 3, ret
;
814 ret
= cs
->cardmsg(cs
, CARD_INIT
, NULL
);
817 irq_cnt
= kstat_irqs(cs
->irq
);
818 printk(KERN_INFO
"%s: IRQ %d count %d\n", CardType
[cs
->typ
],
820 if (request_irq(cs
->irq
, cs
->irq_func
, cs
->irq_flags
, "HiSax", cs
)) {
821 printk(KERN_WARNING
"HiSax: couldn't get interrupt %d\n",
826 cs
->cardmsg(cs
, CARD_INIT
, NULL
);
829 printk(KERN_INFO
"%s: IRQ %d count %d\n",
830 CardType
[cs
->typ
], cs
->irq
, kstat_irqs(cs
->irq
));
831 if (kstat_irqs(cs
->irq
) == irq_cnt
) {
833 "%s: IRQ(%d) getting no interrupts during init %d\n",
834 CardType
[cs
->typ
], cs
->irq
, 4 - cnt
);
836 free_irq(cs
->irq
, cs
);
839 cs
->cardmsg(cs
, CARD_RESET
, NULL
);
843 cs
->cardmsg(cs
, CARD_TEST
, NULL
);
850 static int __devinit
hisax_cs_setup_card(struct IsdnCard
*card
)
856 case ISDN_CTYPE_16_0
:
858 ret
= setup_teles0(card
);
862 case ISDN_CTYPE_16_3
:
864 case ISDN_CTYPE_TELESPCMCIA
:
865 case ISDN_CTYPE_COMPAQ_ISA
:
866 ret
= setup_teles3(card
);
870 case ISDN_CTYPE_S0BOX
:
871 ret
= setup_s0box(card
);
875 case ISDN_CTYPE_TELESPCI
:
876 ret
= setup_telespci(card
);
881 ret
= setup_avm_a1(card
);
884 #if CARD_AVM_A1_PCMCIA
885 case ISDN_CTYPE_A1_PCMCIA
:
886 ret
= setup_avm_a1_pcmcia(card
);
890 case ISDN_CTYPE_FRITZPCI
:
891 ret
= setup_avm_pcipnp(card
);
895 case ISDN_CTYPE_ELSA
:
896 case ISDN_CTYPE_ELSA_PNP
:
897 case ISDN_CTYPE_ELSA_PCMCIA
:
898 case ISDN_CTYPE_ELSA_PCI
:
899 ret
= setup_elsa(card
);
903 case ISDN_CTYPE_IX1MICROR2
:
904 ret
= setup_ix1micro(card
);
908 case ISDN_CTYPE_DIEHLDIVA
:
909 ret
= setup_diva(card
);
913 case ISDN_CTYPE_ASUSCOM
:
914 ret
= setup_asuscom(card
);
918 case ISDN_CTYPE_TELEINT
:
919 ret
= setup_TeleInt(card
);
923 case ISDN_CTYPE_SEDLBAUER
:
924 case ISDN_CTYPE_SEDLBAUER_PCMCIA
:
925 case ISDN_CTYPE_SEDLBAUER_FAX
:
926 ret
= setup_sedlbauer(card
);
930 case ISDN_CTYPE_SPORTSTER
:
931 ret
= setup_sportster(card
);
936 ret
= setup_mic(card
);
940 case ISDN_CTYPE_NETJET_S
:
941 ret
= setup_netjet_s(card
);
945 case ISDN_CTYPE_TELES3C
:
946 case ISDN_CTYPE_ACERP10
:
947 ret
= setup_hfcs(card
);
951 case ISDN_CTYPE_HFC_PCI
:
952 ret
= setup_hfcpci(card
);
956 case ISDN_CTYPE_HFC_SX
:
957 ret
= setup_hfcsx(card
);
961 case ISDN_CTYPE_NICCY
:
962 ret
= setup_niccy(card
);
966 case ISDN_CTYPE_ISURF
:
967 ret
= setup_isurf(card
);
971 case ISDN_CTYPE_HSTSAPHIR
:
972 ret
= setup_saphir(card
);
976 case ISDN_CTYPE_BKM_A4T
:
977 ret
= setup_bkm_a4t(card
);
981 case ISDN_CTYPE_SCT_QUADRO
:
982 ret
= setup_sct_quadro(card
);
986 case ISDN_CTYPE_GAZEL
:
987 ret
= setup_gazel(card
);
991 case ISDN_CTYPE_W6692
:
992 ret
= setup_w6692(card
);
996 case ISDN_CTYPE_NETJET_U
:
997 ret
= setup_netjet_u(card
);
1000 #if CARD_FN_ENTERNOW_PCI
1001 case ISDN_CTYPE_ENTERNOW
:
1002 ret
= setup_enternow_pci(card
);
1005 case ISDN_CTYPE_DYNAMIC
:
1010 "HiSax: Support for %s Card not selected\n",
1011 CardType
[card
->typ
]);
1019 static int hisax_cs_new(int cardnr
, char *id
, struct IsdnCard
*card
,
1020 struct IsdnCardState
**cs_out
, int *busy_flag
,
1021 struct module
*lockowner
)
1023 struct IsdnCardState
*cs
;
1027 cs
= kzalloc(sizeof(struct IsdnCardState
), GFP_ATOMIC
);
1030 "HiSax: No memory for IsdnCardState(card %d)\n",
1035 spin_lock_init(&cs
->statlock
);
1036 spin_lock_init(&cs
->lock
);
1037 cs
->chanlimit
= 2; /* maximum B-channel number */
1038 cs
->logecho
= 0; /* No echo logging */
1039 cs
->cardnr
= cardnr
;
1040 cs
->debug
= L1_DEB_WARN
;
1042 cs
->busy_flag
= busy_flag
;
1043 cs
->irq_flags
= I4L_IRQ_FLAG
;
1045 if (card
->protocol
== ISDN_PTYPE_NI1
)
1046 test_and_set_bit(FLG_TWO_DCHAN
, &cs
->HW_Flags
);
1048 test_and_set_bit(FLG_TWO_DCHAN
, &cs
->HW_Flags
);
1050 cs
->protocol
= card
->protocol
;
1052 if (card
->typ
<= 0 || card
->typ
> ISDN_CTYPE_COUNT
) {
1054 "HiSax: Card Type %d out of range\n", card
->typ
);
1057 if (!(cs
->dlog
= kmalloc(MAX_DLOG_SPACE
, GFP_ATOMIC
))) {
1059 "HiSax: No memory for dlog(card %d)\n", cardnr
+ 1);
1062 if (!(cs
->status_buf
= kmalloc(HISAX_STATUS_BUFSIZE
, GFP_ATOMIC
))) {
1064 "HiSax: No memory for status_buf(card %d)\n",
1069 cs
->status_read
= cs
->status_buf
;
1070 cs
->status_write
= cs
->status_buf
;
1071 cs
->status_end
= cs
->status_buf
+ HISAX_STATUS_BUFSIZE
- 1;
1072 cs
->typ
= card
->typ
;
1074 cs
->iif
.owner
= lockowner
;
1076 strcpy(cs
->iif
.id
, id
);
1077 cs
->iif
.channels
= 2;
1078 cs
->iif
.maxbufsize
= MAX_DATA_SIZE
;
1079 cs
->iif
.hl_hdrlen
= MAX_HEADER_LEN
;
1081 ISDN_FEATURE_L2_X75I
|
1082 ISDN_FEATURE_L2_HDLC
|
1083 ISDN_FEATURE_L2_HDLC_56K
|
1084 ISDN_FEATURE_L2_TRANS
|
1085 ISDN_FEATURE_L3_TRANS
|
1086 #ifdef CONFIG_HISAX_1TR6
1087 ISDN_FEATURE_P_1TR6
|
1089 #ifdef CONFIG_HISAX_EURO
1090 ISDN_FEATURE_P_EURO
|
1092 #ifdef CONFIG_HISAX_NI1
1093 ISDN_FEATURE_P_NI1
|
1097 cs
->iif
.command
= HiSax_command
;
1098 cs
->iif
.writecmd
= NULL
;
1099 cs
->iif
.writebuf_skb
= HiSax_writebuf_skb
;
1100 cs
->iif
.readstat
= HiSax_readstatus
;
1101 register_isdn(&cs
->iif
);
1102 cs
->myid
= cs
->iif
.channels
;
1105 return 1; /* success */
1113 return 0; /* error */
1116 static int hisax_cs_setup(int cardnr
, struct IsdnCard
*card
,
1117 struct IsdnCardState
*cs
)
1121 if (!(cs
->rcvbuf
= kmalloc(MAX_DFRAME_LEN_L1
, GFP_ATOMIC
))) {
1122 printk(KERN_WARNING
"HiSax: No memory for isac rcvbuf\n");
1131 skb_queue_head_init(&cs
->rq
);
1132 skb_queue_head_init(&cs
->sq
);
1134 init_bcstate(cs
, 0);
1135 init_bcstate(cs
, 1);
1137 /* init_card only handles interrupts which are not */
1138 /* used here for the loadable driver */
1139 switch (card
->typ
) {
1140 case ISDN_CTYPE_DYNAMIC
:
1144 ret
= init_card(cs
);
1151 init_tei(cs
, cs
->protocol
);
1152 ret
= CallcNewChan(cs
);
1157 /* ISAR needs firmware download first */
1158 if (!test_bit(HW_ISAR
, &cs
->HW_Flags
))
1169 /* Used from an exported function but calls __devinit functions.
1170 * Tell modpost not to warn (__ref)
1172 static int __ref
checkcard(int cardnr
, char *id
, int *busy_flag
, struct module
*lockowner
)
1175 struct IsdnCard
*card
= cards
+ cardnr
;
1176 struct IsdnCardState
*cs
;
1178 ret
= hisax_cs_new(cardnr
, id
, card
, &cs
, busy_flag
, lockowner
);
1183 "HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr
+ 1,
1184 (card
->protocol
== ISDN_PTYPE_1TR6
) ? "1TR6" :
1185 (card
->protocol
== ISDN_PTYPE_EURO
) ? "EDSS1" :
1186 (card
->protocol
== ISDN_PTYPE_LEASED
) ? "LEASED" :
1187 (card
->protocol
== ISDN_PTYPE_NI1
) ? "NI1" :
1188 "NONE", cs
->iif
.id
, cs
->myid
);
1190 ret
= hisax_cs_setup_card(card
);
1196 ret
= hisax_cs_setup(cardnr
, card
, cs
);
1206 static void HiSax_shiftcards(int idx
)
1210 for (i
= idx
; i
< (HISAX_MAX_CARDS
- 1); i
++)
1211 memcpy(&cards
[i
], &cards
[i
+ 1], sizeof(cards
[i
]));
1214 static int HiSax_inithardware(int *busy_flag
)
1221 char *next_id
= HiSax_id
;
1224 if (strchr(HiSax_id
, ','))
1226 else if (strchr(HiSax_id
, '%'))
1229 while (i
< nrcards
) {
1230 if (cards
[i
].typ
< 1)
1233 if ((next_id
= strchr(id
, t
))) {
1242 sprintf(ids
, "%s%d", id
, i
);
1244 if (checkcard(i
, ids
, busy_flag
, THIS_MODULE
)) {
1248 /* make sure we don't oops the module */
1249 if (cards
[i
].typ
> 0 && cards
[i
].typ
<= ISDN_CTYPE_COUNT
) {
1251 "HiSax: Card %s not installed !\n",
1252 CardType
[cards
[i
].typ
]);
1254 HiSax_shiftcards(i
);
1261 void HiSax_closecard(int cardnr
)
1263 int i
, last
= nrcards
- 1;
1265 if (cardnr
> last
|| cardnr
< 0)
1267 if (cards
[cardnr
].cs
) {
1268 ll_stop(cards
[cardnr
].cs
);
1269 release_tei(cards
[cardnr
].cs
);
1270 CallcFreeChan(cards
[cardnr
].cs
);
1273 if (cards
[cardnr
].cs
->irq
)
1274 free_irq(cards
[cardnr
].cs
->irq
, cards
[cardnr
].cs
);
1275 kfree((void *) cards
[cardnr
].cs
);
1276 cards
[cardnr
].cs
= NULL
;
1280 cards
[i
] = cards
[i
+ 1];
1286 void HiSax_reportcard(int cardnr
, int sel
)
1288 struct IsdnCardState
*cs
= cards
[cardnr
].cs
;
1290 printk(KERN_DEBUG
"HiSax: reportcard No %d\n", cardnr
+ 1);
1291 printk(KERN_DEBUG
"HiSax: Type %s\n", CardType
[cs
->typ
]);
1292 printk(KERN_DEBUG
"HiSax: debuglevel %x\n", cs
->debug
);
1293 printk(KERN_DEBUG
"HiSax: HiSax_reportcard address 0x%lX\n",
1294 (ulong
) & HiSax_reportcard
);
1295 printk(KERN_DEBUG
"HiSax: cs 0x%lX\n", (ulong
) cs
);
1296 printk(KERN_DEBUG
"HiSax: HW_Flags %lx bc0 flg %lx bc1 flg %lx\n",
1297 cs
->HW_Flags
, cs
->bcs
[0].Flag
, cs
->bcs
[1].Flag
);
1298 printk(KERN_DEBUG
"HiSax: bcs 0 mode %d ch%d\n",
1299 cs
->bcs
[0].mode
, cs
->bcs
[0].channel
);
1300 printk(KERN_DEBUG
"HiSax: bcs 1 mode %d ch%d\n",
1301 cs
->bcs
[1].mode
, cs
->bcs
[1].channel
);
1302 #ifdef ERROR_STATISTIC
1303 printk(KERN_DEBUG
"HiSax: dc errors(rx,crc,tx) %d,%d,%d\n",
1304 cs
->err_rx
, cs
->err_crc
, cs
->err_tx
);
1306 "HiSax: bc0 errors(inv,rdo,crc,tx) %d,%d,%d,%d\n",
1307 cs
->bcs
[0].err_inv
, cs
->bcs
[0].err_rdo
, cs
->bcs
[0].err_crc
,
1310 "HiSax: bc1 errors(inv,rdo,crc,tx) %d,%d,%d,%d\n",
1311 cs
->bcs
[1].err_inv
, cs
->bcs
[1].err_rdo
, cs
->bcs
[1].err_crc
,
1317 cs
->bcs
[0].err_inv
= 0;
1318 cs
->bcs
[0].err_rdo
= 0;
1319 cs
->bcs
[0].err_crc
= 0;
1320 cs
->bcs
[0].err_tx
= 0;
1321 cs
->bcs
[1].err_inv
= 0;
1322 cs
->bcs
[1].err_rdo
= 0;
1323 cs
->bcs
[1].err_crc
= 0;
1324 cs
->bcs
[1].err_tx
= 0;
1329 static int __init
HiSax_init(void)
1338 retval
= CallcNew();
1341 retval
= Isdnl3New();
1344 retval
= Isdnl2New();
1350 retval
= Isdnl1New();
1356 /* We 'll register drivers later, but init basic functions */
1357 for (i
= 0; i
< HISAX_MAX_CARDS
; i
++)
1361 #ifdef CONFIG_HISAX_ELSA
1362 if (type
[0] == ISDN_CTYPE_ELSA_PCMCIA
) {
1363 /* we have exported and return in this case */
1367 #ifdef CONFIG_HISAX_SEDLBAUER
1368 if (type
[0] == ISDN_CTYPE_SEDLBAUER_PCMCIA
) {
1369 /* we have to export and return in this case */
1373 #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
1374 if (type
[0] == ISDN_CTYPE_A1_PCMCIA
) {
1375 /* we have to export and return in this case */
1379 #ifdef CONFIG_HISAX_HFC_SX
1380 if (type
[0] == ISDN_CTYPE_HFC_SP_PCMCIA
) {
1381 /* we have to export and return in this case */
1388 if (id
) /* If id= string used */
1390 for (i
= j
= 0; j
< HISAX_MAX_CARDS
; i
++) {
1391 cards
[j
].typ
= type
[i
];
1393 cards
[j
].protocol
= protocol
[i
];
1396 cards
[j
].protocol
= DEFAULT_PROTO
;
1399 case ISDN_CTYPE_16_0
:
1400 cards
[j
].para
[0] = irq
[i
];
1401 cards
[j
].para
[1] = mem
[i
];
1402 cards
[j
].para
[2] = io
[i
];
1405 case ISDN_CTYPE_8_0
:
1406 cards
[j
].para
[0] = irq
[i
];
1407 cards
[j
].para
[1] = mem
[i
];
1411 case ISDN_CTYPE_PNP
:
1412 case ISDN_CTYPE_NICCY
:
1413 cards
[j
].para
[0] = irq
[i
];
1414 cards
[j
].para
[1] = io0
[i
];
1415 cards
[j
].para
[2] = io1
[i
];
1417 case ISDN_CTYPE_COMPAQ_ISA
:
1418 cards
[j
].para
[0] = irq
[i
];
1419 cards
[j
].para
[1] = io0
[i
];
1420 cards
[j
].para
[2] = io1
[i
];
1421 cards
[j
].para
[3] = io
[i
];
1424 case ISDN_CTYPE_ELSA
:
1425 case ISDN_CTYPE_HFC_PCI
:
1426 cards
[j
].para
[0] = io
[i
];
1428 case ISDN_CTYPE_16_3
:
1429 case ISDN_CTYPE_TELESPCMCIA
:
1431 case ISDN_CTYPE_A1_PCMCIA
:
1432 case ISDN_CTYPE_ELSA_PNP
:
1433 case ISDN_CTYPE_ELSA_PCMCIA
:
1434 case ISDN_CTYPE_IX1MICROR2
:
1435 case ISDN_CTYPE_DIEHLDIVA
:
1436 case ISDN_CTYPE_ASUSCOM
:
1437 case ISDN_CTYPE_TELEINT
:
1438 case ISDN_CTYPE_SEDLBAUER
:
1439 case ISDN_CTYPE_SEDLBAUER_PCMCIA
:
1440 case ISDN_CTYPE_SEDLBAUER_FAX
:
1441 case ISDN_CTYPE_SPORTSTER
:
1442 case ISDN_CTYPE_MIC
:
1443 case ISDN_CTYPE_TELES3C
:
1444 case ISDN_CTYPE_ACERP10
:
1445 case ISDN_CTYPE_S0BOX
:
1446 case ISDN_CTYPE_FRITZPCI
:
1447 case ISDN_CTYPE_HSTSAPHIR
:
1448 case ISDN_CTYPE_GAZEL
:
1449 case ISDN_CTYPE_HFC_SX
:
1450 case ISDN_CTYPE_HFC_SP_PCMCIA
:
1451 cards
[j
].para
[0] = irq
[i
];
1452 cards
[j
].para
[1] = io
[i
];
1454 case ISDN_CTYPE_ISURF
:
1455 cards
[j
].para
[0] = irq
[i
];
1456 cards
[j
].para
[1] = io
[i
];
1457 cards
[j
].para
[2] = mem
[i
];
1459 case ISDN_CTYPE_ELSA_PCI
:
1460 case ISDN_CTYPE_NETJET_S
:
1461 case ISDN_CTYPE_TELESPCI
:
1462 case ISDN_CTYPE_W6692
:
1463 case ISDN_CTYPE_NETJET_U
:
1465 case ISDN_CTYPE_BKM_A4T
:
1467 case ISDN_CTYPE_SCT_QUADRO
:
1469 cards
[j
].para
[0] = irq
[i
];
1471 /* QUADRO is a 4 BRI card */
1472 cards
[j
++].para
[0] = 1;
1473 /* we need to check if further cards can be added */
1474 if (j
< HISAX_MAX_CARDS
) {
1475 cards
[j
].typ
= ISDN_CTYPE_SCT_QUADRO
;
1476 cards
[j
].protocol
= protocol
[i
];
1477 cards
[j
++].para
[0] = 2;
1479 if (j
< HISAX_MAX_CARDS
) {
1480 cards
[j
].typ
= ISDN_CTYPE_SCT_QUADRO
;
1481 cards
[j
].protocol
= protocol
[i
];
1482 cards
[j
++].para
[0] = 3;
1484 if (j
< HISAX_MAX_CARDS
) {
1485 cards
[j
].typ
= ISDN_CTYPE_SCT_QUADRO
;
1486 cards
[j
].protocol
= protocol
[i
];
1487 cards
[j
].para
[0] = 4;
1496 "HiSax: Warning - no protocol specified\n");
1497 printk(KERN_WARNING
"HiSax: using protocol %s\n",
1498 DEFAULT_PROTO_NAME
);
1504 strcpy(HiSaxID
, "HiSax");
1505 for (i
= 0; i
< HISAX_MAX_CARDS
; i
++)
1506 if (cards
[i
].typ
> 0)
1508 printk(KERN_DEBUG
"HiSax: Total %d card%s defined\n",
1509 nrcards
, (nrcards
> 1) ? "s" : "");
1511 /* Install only, if at least one card found */
1512 if (!HiSax_inithardware(NULL
))
1528 static void __exit
HiSax_exit(void)
1530 int cardnr
= nrcards
- 1;
1533 HiSax_closecard(cardnr
--);
1539 printk(KERN_INFO
"HiSax module removed\n");
1542 int hisax_init_pcmcia(void *pcm_iob
, int *busy_flag
, struct IsdnCard
*card
)
1547 cards
[nrcards
] = *card
;
1549 sprintf(ids
, "HiSax%d", nrcards
);
1551 sprintf(ids
, "HiSax");
1552 if (!checkcard(nrcards
, ids
, busy_flag
, THIS_MODULE
))
1561 EXPORT_SYMBOL(hisax_init_pcmcia
);
1562 EXPORT_SYMBOL(HiSax_closecard
);
1564 #include "hisax_if.h"
1566 EXPORT_SYMBOL(hisax_register
);
1567 EXPORT_SYMBOL(hisax_unregister
);
1569 static void hisax_d_l1l2(struct hisax_if
*ifc
, int pr
, void *arg
);
1570 static void hisax_b_l1l2(struct hisax_if
*ifc
, int pr
, void *arg
);
1571 static void hisax_d_l2l1(struct PStack
*st
, int pr
, void *arg
);
1572 static void hisax_b_l2l1(struct PStack
*st
, int pr
, void *arg
);
1573 static int hisax_cardmsg(struct IsdnCardState
*cs
, int mt
, void *arg
);
1574 static int hisax_bc_setstack(struct PStack
*st
, struct BCState
*bcs
);
1575 static void hisax_bc_close(struct BCState
*bcs
);
1576 static void hisax_bh(struct work_struct
*work
);
1577 static void EChannel_proc_rcv(struct hisax_d_if
*d_if
);
1579 int hisax_register(struct hisax_d_if
*hisax_d_if
, struct hisax_b_if
*b_if
[],
1580 char *name
, int protocol
)
1584 struct IsdnCardState
*cs
;
1586 for (i
= 0; i
< HISAX_MAX_CARDS
; i
++) {
1591 if (i
>= HISAX_MAX_CARDS
)
1594 cards
[i
].typ
= ISDN_CTYPE_DYNAMIC
;
1595 cards
[i
].protocol
= protocol
;
1596 sprintf(id
, "%s%d", name
, i
);
1598 retval
= checkcard(i
, id
, NULL
, hisax_d_if
->owner
);
1599 if (retval
== 0) { // yuck
1605 hisax_d_if
->cs
= cs
;
1606 cs
->hw
.hisax_d_if
= hisax_d_if
;
1607 cs
->cardmsg
= hisax_cardmsg
;
1608 INIT_WORK(&cs
->tqueue
, hisax_bh
);
1609 cs
->channel
[0].d_st
->l2
.l2l1
= hisax_d_l2l1
;
1610 for (i
= 0; i
< 2; i
++) {
1611 cs
->bcs
[i
].BC_SetStack
= hisax_bc_setstack
;
1612 cs
->bcs
[i
].BC_Close
= hisax_bc_close
;
1614 b_if
[i
]->ifc
.l1l2
= hisax_b_l1l2
;
1616 hisax_d_if
->b_if
[i
] = b_if
[i
];
1618 hisax_d_if
->ifc
.l1l2
= hisax_d_l1l2
;
1619 skb_queue_head_init(&hisax_d_if
->erq
);
1620 clear_bit(0, &hisax_d_if
->ph_state
);
1625 void hisax_unregister(struct hisax_d_if
*hisax_d_if
)
1627 cards
[hisax_d_if
->cs
->cardnr
].typ
= 0;
1628 HiSax_closecard(hisax_d_if
->cs
->cardnr
);
1629 skb_queue_purge(&hisax_d_if
->erq
);
1634 static void hisax_sched_event(struct IsdnCardState
*cs
, int event
)
1636 test_and_set_bit(event
, &cs
->event
);
1637 schedule_work(&cs
->tqueue
);
1640 static void hisax_bh(struct work_struct
*work
)
1642 struct IsdnCardState
*cs
=
1643 container_of(work
, struct IsdnCardState
, tqueue
);
1647 if (test_and_clear_bit(D_RCVBUFREADY
, &cs
->event
))
1648 DChannel_proc_rcv(cs
);
1649 if (test_and_clear_bit(E_RCVBUFREADY
, &cs
->event
))
1650 EChannel_proc_rcv(cs
->hw
.hisax_d_if
);
1651 if (test_and_clear_bit(D_L1STATECHANGE
, &cs
->event
)) {
1652 if (test_bit(0, &cs
->hw
.hisax_d_if
->ph_state
))
1653 pr
= PH_ACTIVATE
| INDICATION
;
1655 pr
= PH_DEACTIVATE
| INDICATION
;
1656 for (st
= cs
->stlist
; st
; st
= st
->next
)
1657 st
->l1
.l1l2(st
, pr
, NULL
);
1662 static void hisax_b_sched_event(struct BCState
*bcs
, int event
)
1664 test_and_set_bit(event
, &bcs
->event
);
1665 schedule_work(&bcs
->tqueue
);
1668 static inline void D_L2L1(struct hisax_d_if
*d_if
, int pr
, void *arg
)
1670 struct hisax_if
*ifc
= (struct hisax_if
*) d_if
;
1671 ifc
->l2l1(ifc
, pr
, arg
);
1674 static inline void B_L2L1(struct hisax_b_if
*b_if
, int pr
, void *arg
)
1676 struct hisax_if
*ifc
= (struct hisax_if
*) b_if
;
1677 ifc
->l2l1(ifc
, pr
, arg
);
1680 static void hisax_d_l1l2(struct hisax_if
*ifc
, int pr
, void *arg
)
1682 struct hisax_d_if
*d_if
= (struct hisax_d_if
*) ifc
;
1683 struct IsdnCardState
*cs
= d_if
->cs
;
1685 struct sk_buff
*skb
;
1688 case PH_ACTIVATE
| INDICATION
:
1689 set_bit(0, &d_if
->ph_state
);
1690 hisax_sched_event(cs
, D_L1STATECHANGE
);
1692 case PH_DEACTIVATE
| INDICATION
:
1693 clear_bit(0, &d_if
->ph_state
);
1694 hisax_sched_event(cs
, D_L1STATECHANGE
);
1696 case PH_DATA
| INDICATION
:
1697 skb_queue_tail(&cs
->rq
, arg
);
1698 hisax_sched_event(cs
, D_RCVBUFREADY
);
1700 case PH_DATA
| CONFIRM
:
1701 skb
= skb_dequeue(&cs
->sq
);
1703 D_L2L1(d_if
, PH_DATA
| REQUEST
, skb
);
1706 clear_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
);
1707 for (st
= cs
->stlist
; st
; st
= st
->next
) {
1708 if (test_and_clear_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
)) {
1709 st
->l1
.l1l2(st
, PH_PULL
| CONFIRM
, NULL
);
1714 case PH_DATA_E
| INDICATION
:
1715 skb_queue_tail(&d_if
->erq
, arg
);
1716 hisax_sched_event(cs
, E_RCVBUFREADY
);
1719 printk("pr %#x\n", pr
);
1724 static void hisax_b_l1l2(struct hisax_if
*ifc
, int pr
, void *arg
)
1726 struct hisax_b_if
*b_if
= (struct hisax_b_if
*) ifc
;
1727 struct BCState
*bcs
= b_if
->bcs
;
1728 struct PStack
*st
= bcs
->st
;
1729 struct sk_buff
*skb
;
1731 // FIXME use isdnl1?
1733 case PH_ACTIVATE
| INDICATION
:
1734 st
->l1
.l1l2(st
, pr
, NULL
);
1736 case PH_DEACTIVATE
| INDICATION
:
1737 st
->l1
.l1l2(st
, pr
, NULL
);
1738 clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1739 skb_queue_purge(&bcs
->squeue
);
1740 bcs
->hw
.b_if
= NULL
;
1742 case PH_DATA
| INDICATION
:
1743 skb_queue_tail(&bcs
->rqueue
, arg
);
1744 hisax_b_sched_event(bcs
, B_RCVBUFREADY
);
1746 case PH_DATA
| CONFIRM
:
1747 bcs
->tx_cnt
-= (long)arg
;
1748 if (test_bit(FLG_LLI_L1WAKEUP
,&bcs
->st
->lli
.flag
)) {
1750 spin_lock_irqsave(&bcs
->aclock
, flags
);
1751 bcs
->ackcnt
+= (long)arg
;
1752 spin_unlock_irqrestore(&bcs
->aclock
, flags
);
1753 schedule_event(bcs
, B_ACKPENDING
);
1755 skb
= skb_dequeue(&bcs
->squeue
);
1757 B_L2L1(b_if
, PH_DATA
| REQUEST
, skb
);
1760 clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1761 if (test_and_clear_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
)) {
1762 st
->l1
.l1l2(st
, PH_PULL
| CONFIRM
, NULL
);
1766 printk("hisax_b_l1l2 pr %#x\n", pr
);
1771 static void hisax_d_l2l1(struct PStack
*st
, int pr
, void *arg
)
1773 struct IsdnCardState
*cs
= st
->l1
.hardware
;
1774 struct hisax_d_if
*hisax_d_if
= cs
->hw
.hisax_d_if
;
1775 struct sk_buff
*skb
= arg
;
1778 case PH_DATA
| REQUEST
:
1779 case PH_PULL
| INDICATION
:
1780 if (cs
->debug
& DEB_DLOG_HEX
)
1781 LogFrame(cs
, skb
->data
, skb
->len
);
1782 if (cs
->debug
& DEB_DLOG_VERBOSE
)
1783 dlogframe(cs
, skb
, 0);
1784 Logl2Frame(cs
, skb
, "PH_DATA_REQ", 0);
1786 if (!test_and_set_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
))
1787 D_L2L1(hisax_d_if
, PH_DATA
| REQUEST
, skb
);
1789 skb_queue_tail(&cs
->sq
, skb
);
1791 case PH_PULL
| REQUEST
:
1792 if (!test_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
))
1793 st
->l1
.l1l2(st
, PH_PULL
| CONFIRM
, NULL
);
1795 set_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
);
1798 D_L2L1(hisax_d_if
, pr
, arg
);
1803 static int hisax_cardmsg(struct IsdnCardState
*cs
, int mt
, void *arg
)
1808 static void hisax_b_l2l1(struct PStack
*st
, int pr
, void *arg
)
1810 struct BCState
*bcs
= st
->l1
.bcs
;
1811 struct hisax_b_if
*b_if
= bcs
->hw
.b_if
;
1814 case PH_ACTIVATE
| REQUEST
:
1815 B_L2L1(b_if
, pr
, (void *)(unsigned long)st
->l1
.mode
);
1817 case PH_DATA
| REQUEST
:
1818 case PH_PULL
| INDICATION
:
1820 if (!test_and_set_bit(BC_FLG_BUSY
, &bcs
->Flag
)) {
1821 B_L2L1(b_if
, PH_DATA
| REQUEST
, arg
);
1823 skb_queue_tail(&bcs
->squeue
, arg
);
1826 case PH_PULL
| REQUEST
:
1827 if (!test_bit(BC_FLG_BUSY
, &bcs
->Flag
))
1828 st
->l1
.l1l2(st
, PH_PULL
| CONFIRM
, NULL
);
1830 set_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
);
1832 case PH_DEACTIVATE
| REQUEST
:
1833 test_and_clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1834 skb_queue_purge(&bcs
->squeue
);
1836 B_L2L1(b_if
, pr
, arg
);
1841 static int hisax_bc_setstack(struct PStack
*st
, struct BCState
*bcs
)
1843 struct IsdnCardState
*cs
= st
->l1
.hardware
;
1844 struct hisax_d_if
*hisax_d_if
= cs
->hw
.hisax_d_if
;
1846 bcs
->channel
= st
->l1
.bc
;
1848 bcs
->hw
.b_if
= hisax_d_if
->b_if
[st
->l1
.bc
];
1849 hisax_d_if
->b_if
[st
->l1
.bc
]->bcs
= bcs
;
1852 st
->l2
.l2l1
= hisax_b_l2l1
;
1853 setstack_manager(st
);
1856 skb_queue_head_init(&bcs
->rqueue
);
1857 skb_queue_head_init(&bcs
->squeue
);
1861 static void hisax_bc_close(struct BCState
*bcs
)
1863 struct hisax_b_if
*b_if
= bcs
->hw
.b_if
;
1866 B_L2L1(b_if
, PH_DEACTIVATE
| REQUEST
, NULL
);
1869 static void EChannel_proc_rcv(struct hisax_d_if
*d_if
)
1871 struct IsdnCardState
*cs
= d_if
->cs
;
1873 struct sk_buff
*skb
;
1875 while ((skb
= skb_dequeue(&d_if
->erq
)) != NULL
) {
1876 if (cs
->debug
& DEB_DLOG_HEX
) {
1878 if ((skb
->len
) < MAX_DLOG_SPACE
/ 3 - 10) {
1884 ptr
+= QuickHex(ptr
, skb
->data
, skb
->len
);
1888 HiSax_putstatus(cs
, NULL
, cs
->dlog
);
1890 HiSax_putstatus(cs
, "LogEcho: ",
1891 "warning Frame too big (%d)",
1894 dev_kfree_skb_any(skb
);
1899 #include <linux/pci.h>
1901 static struct pci_device_id hisax_pci_tbl
[] __devinitdata
= {
1902 #ifdef CONFIG_HISAX_FRITZPCI
1903 {PCI_VENDOR_ID_AVM
, PCI_DEVICE_ID_AVM_A1
, PCI_ANY_ID
, PCI_ANY_ID
},
1905 #ifdef CONFIG_HISAX_DIEHLDIVA
1906 {PCI_VENDOR_ID_EICON
, PCI_DEVICE_ID_EICON_DIVA20
, PCI_ANY_ID
, PCI_ANY_ID
},
1907 {PCI_VENDOR_ID_EICON
, PCI_DEVICE_ID_EICON_DIVA20_U
, PCI_ANY_ID
, PCI_ANY_ID
},
1908 {PCI_VENDOR_ID_EICON
, PCI_DEVICE_ID_EICON_DIVA201
, PCI_ANY_ID
, PCI_ANY_ID
},
1909 //#########################################################################################
1910 {PCI_VENDOR_ID_EICON
, PCI_DEVICE_ID_EICON_DIVA202
, PCI_ANY_ID
, PCI_ANY_ID
},
1911 //#########################################################################################
1913 #ifdef CONFIG_HISAX_ELSA
1914 {PCI_VENDOR_ID_ELSA
, PCI_DEVICE_ID_ELSA_MICROLINK
, PCI_ANY_ID
, PCI_ANY_ID
},
1915 {PCI_VENDOR_ID_ELSA
, PCI_DEVICE_ID_ELSA_QS3000
, PCI_ANY_ID
, PCI_ANY_ID
},
1917 #ifdef CONFIG_HISAX_GAZEL
1918 {PCI_VENDOR_ID_PLX
, PCI_DEVICE_ID_PLX_R685
, PCI_ANY_ID
, PCI_ANY_ID
},
1919 {PCI_VENDOR_ID_PLX
, PCI_DEVICE_ID_PLX_R753
, PCI_ANY_ID
, PCI_ANY_ID
},
1920 {PCI_VENDOR_ID_PLX
, PCI_DEVICE_ID_PLX_DJINN_ITOO
, PCI_ANY_ID
, PCI_ANY_ID
},
1921 {PCI_VENDOR_ID_PLX
, PCI_DEVICE_ID_PLX_OLITEC
, PCI_ANY_ID
, PCI_ANY_ID
},
1923 #ifdef CONFIG_HISAX_SCT_QUADRO
1924 {PCI_VENDOR_ID_PLX
, PCI_DEVICE_ID_PLX_9050
, PCI_ANY_ID
, PCI_ANY_ID
},
1926 #ifdef CONFIG_HISAX_NICCY
1927 {PCI_VENDOR_ID_SATSAGEM
, PCI_DEVICE_ID_SATSAGEM_NICCY
, PCI_ANY_ID
,PCI_ANY_ID
},
1929 #ifdef CONFIG_HISAX_SEDLBAUER
1930 {PCI_VENDOR_ID_TIGERJET
, PCI_DEVICE_ID_TIGERJET_100
, PCI_ANY_ID
,PCI_ANY_ID
},
1932 #if defined(CONFIG_HISAX_NETJET) || defined(CONFIG_HISAX_NETJET_U)
1933 {PCI_VENDOR_ID_TIGERJET
, PCI_DEVICE_ID_TIGERJET_300
, PCI_ANY_ID
,PCI_ANY_ID
},
1935 #if defined(CONFIG_HISAX_TELESPCI) || defined(CONFIG_HISAX_SCT_QUADRO)
1936 {PCI_VENDOR_ID_ZORAN
, PCI_DEVICE_ID_ZORAN_36120
, PCI_ANY_ID
,PCI_ANY_ID
},
1938 #ifdef CONFIG_HISAX_W6692
1939 {PCI_VENDOR_ID_DYNALINK
, PCI_DEVICE_ID_DYNALINK_IS64PH
, PCI_ANY_ID
,PCI_ANY_ID
},
1940 {PCI_VENDOR_ID_WINBOND2
, PCI_DEVICE_ID_WINBOND2_6692
, PCI_ANY_ID
,PCI_ANY_ID
},
1942 #ifdef CONFIG_HISAX_HFC_PCI
1943 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_2BD0
, PCI_ANY_ID
, PCI_ANY_ID
},
1944 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B000
, PCI_ANY_ID
, PCI_ANY_ID
},
1945 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B006
, PCI_ANY_ID
, PCI_ANY_ID
},
1946 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B007
, PCI_ANY_ID
, PCI_ANY_ID
},
1947 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B008
, PCI_ANY_ID
, PCI_ANY_ID
},
1948 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B009
, PCI_ANY_ID
, PCI_ANY_ID
},
1949 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B00A
, PCI_ANY_ID
, PCI_ANY_ID
},
1950 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B00B
, PCI_ANY_ID
, PCI_ANY_ID
},
1951 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B00C
, PCI_ANY_ID
, PCI_ANY_ID
},
1952 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B100
, PCI_ANY_ID
, PCI_ANY_ID
},
1953 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B700
, PCI_ANY_ID
, PCI_ANY_ID
},
1954 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B701
, PCI_ANY_ID
, PCI_ANY_ID
},
1955 {PCI_VENDOR_ID_ABOCOM
, PCI_DEVICE_ID_ABOCOM_2BD1
, PCI_ANY_ID
, PCI_ANY_ID
},
1956 {PCI_VENDOR_ID_ASUSTEK
, PCI_DEVICE_ID_ASUSTEK_0675
, PCI_ANY_ID
, PCI_ANY_ID
},
1957 {PCI_VENDOR_ID_BERKOM
, PCI_DEVICE_ID_BERKOM_T_CONCEPT
, PCI_ANY_ID
, PCI_ANY_ID
},
1958 {PCI_VENDOR_ID_BERKOM
, PCI_DEVICE_ID_BERKOM_A1T
, PCI_ANY_ID
, PCI_ANY_ID
},
1959 {PCI_VENDOR_ID_ANIGMA
, PCI_DEVICE_ID_ANIGMA_MC145575
, PCI_ANY_ID
, PCI_ANY_ID
},
1960 {PCI_VENDOR_ID_ZOLTRIX
, PCI_DEVICE_ID_ZOLTRIX_2BD0
, PCI_ANY_ID
, PCI_ANY_ID
},
1961 {PCI_VENDOR_ID_DIGI
, PCI_DEVICE_ID_DIGI_DF_M_IOM2_E
, PCI_ANY_ID
, PCI_ANY_ID
},
1962 {PCI_VENDOR_ID_DIGI
, PCI_DEVICE_ID_DIGI_DF_M_E
, PCI_ANY_ID
, PCI_ANY_ID
},
1963 {PCI_VENDOR_ID_DIGI
, PCI_DEVICE_ID_DIGI_DF_M_IOM2_A
, PCI_ANY_ID
, PCI_ANY_ID
},
1964 {PCI_VENDOR_ID_DIGI
, PCI_DEVICE_ID_DIGI_DF_M_A
, PCI_ANY_ID
, PCI_ANY_ID
},
1966 { } /* Terminating entry */
1969 MODULE_DEVICE_TABLE(pci
, hisax_pci_tbl
);
1970 #endif /* CONFIG_PCI */
1972 module_init(HiSax_init
);
1973 module_exit(HiSax_exit
);
1975 EXPORT_SYMBOL(FsmNew
);
1976 EXPORT_SYMBOL(FsmFree
);
1977 EXPORT_SYMBOL(FsmEvent
);
1978 EXPORT_SYMBOL(FsmChangeState
);
1979 EXPORT_SYMBOL(FsmInitTimer
);
1980 EXPORT_SYMBOL(FsmDelTimer
);
1981 EXPORT_SYMBOL(FsmRestartTimer
);