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 int init_card(struct IsdnCardState
*cs
)
805 int irq_cnt
, cnt
= 3, ret
;
808 ret
= cs
->cardmsg(cs
, CARD_INIT
, NULL
);
811 irq_cnt
= kstat_irqs(cs
->irq
);
812 printk(KERN_INFO
"%s: IRQ %d count %d\n", CardType
[cs
->typ
],
814 if (request_irq(cs
->irq
, cs
->irq_func
, cs
->irq_flags
, "HiSax", cs
)) {
815 printk(KERN_WARNING
"HiSax: couldn't get interrupt %d\n",
820 cs
->cardmsg(cs
, CARD_INIT
, NULL
);
823 printk(KERN_INFO
"%s: IRQ %d count %d\n",
824 CardType
[cs
->typ
], cs
->irq
, kstat_irqs(cs
->irq
));
825 if (kstat_irqs(cs
->irq
) == irq_cnt
) {
827 "%s: IRQ(%d) getting no interrupts during init %d\n",
828 CardType
[cs
->typ
], cs
->irq
, 4 - cnt
);
830 free_irq(cs
->irq
, cs
);
833 cs
->cardmsg(cs
, CARD_RESET
, NULL
);
837 cs
->cardmsg(cs
, CARD_TEST
, NULL
);
844 static int __devinit
hisax_cs_setup_card(struct IsdnCard
*card
)
850 case ISDN_CTYPE_16_0
:
852 ret
= setup_teles0(card
);
856 case ISDN_CTYPE_16_3
:
858 case ISDN_CTYPE_TELESPCMCIA
:
859 case ISDN_CTYPE_COMPAQ_ISA
:
860 ret
= setup_teles3(card
);
864 case ISDN_CTYPE_S0BOX
:
865 ret
= setup_s0box(card
);
869 case ISDN_CTYPE_TELESPCI
:
870 ret
= setup_telespci(card
);
875 ret
= setup_avm_a1(card
);
878 #if CARD_AVM_A1_PCMCIA
879 case ISDN_CTYPE_A1_PCMCIA
:
880 ret
= setup_avm_a1_pcmcia(card
);
884 case ISDN_CTYPE_FRITZPCI
:
885 ret
= setup_avm_pcipnp(card
);
889 case ISDN_CTYPE_ELSA
:
890 case ISDN_CTYPE_ELSA_PNP
:
891 case ISDN_CTYPE_ELSA_PCMCIA
:
892 case ISDN_CTYPE_ELSA_PCI
:
893 ret
= setup_elsa(card
);
897 case ISDN_CTYPE_IX1MICROR2
:
898 ret
= setup_ix1micro(card
);
902 case ISDN_CTYPE_DIEHLDIVA
:
903 ret
= setup_diva(card
);
907 case ISDN_CTYPE_ASUSCOM
:
908 ret
= setup_asuscom(card
);
912 case ISDN_CTYPE_TELEINT
:
913 ret
= setup_TeleInt(card
);
917 case ISDN_CTYPE_SEDLBAUER
:
918 case ISDN_CTYPE_SEDLBAUER_PCMCIA
:
919 case ISDN_CTYPE_SEDLBAUER_FAX
:
920 ret
= setup_sedlbauer(card
);
924 case ISDN_CTYPE_SPORTSTER
:
925 ret
= setup_sportster(card
);
930 ret
= setup_mic(card
);
934 case ISDN_CTYPE_NETJET_S
:
935 ret
= setup_netjet_s(card
);
939 case ISDN_CTYPE_TELES3C
:
940 case ISDN_CTYPE_ACERP10
:
941 ret
= setup_hfcs(card
);
945 case ISDN_CTYPE_HFC_PCI
:
946 ret
= setup_hfcpci(card
);
950 case ISDN_CTYPE_HFC_SX
:
951 ret
= setup_hfcsx(card
);
955 case ISDN_CTYPE_NICCY
:
956 ret
= setup_niccy(card
);
960 case ISDN_CTYPE_ISURF
:
961 ret
= setup_isurf(card
);
965 case ISDN_CTYPE_HSTSAPHIR
:
966 ret
= setup_saphir(card
);
970 case ISDN_CTYPE_BKM_A4T
:
971 ret
= setup_bkm_a4t(card
);
975 case ISDN_CTYPE_SCT_QUADRO
:
976 ret
= setup_sct_quadro(card
);
980 case ISDN_CTYPE_GAZEL
:
981 ret
= setup_gazel(card
);
985 case ISDN_CTYPE_W6692
:
986 ret
= setup_w6692(card
);
990 case ISDN_CTYPE_NETJET_U
:
991 ret
= setup_netjet_u(card
);
994 #if CARD_FN_ENTERNOW_PCI
995 case ISDN_CTYPE_ENTERNOW
:
996 ret
= setup_enternow_pci(card
);
999 case ISDN_CTYPE_DYNAMIC
:
1004 "HiSax: Support for %s Card not selected\n",
1005 CardType
[card
->typ
]);
1013 static int hisax_cs_new(int cardnr
, char *id
, struct IsdnCard
*card
,
1014 struct IsdnCardState
**cs_out
, int *busy_flag
,
1015 struct module
*lockowner
)
1017 struct IsdnCardState
*cs
;
1021 cs
= kzalloc(sizeof(struct IsdnCardState
), GFP_ATOMIC
);
1024 "HiSax: No memory for IsdnCardState(card %d)\n",
1029 spin_lock_init(&cs
->statlock
);
1030 spin_lock_init(&cs
->lock
);
1031 cs
->chanlimit
= 2; /* maximum B-channel number */
1032 cs
->logecho
= 0; /* No echo logging */
1033 cs
->cardnr
= cardnr
;
1034 cs
->debug
= L1_DEB_WARN
;
1036 cs
->busy_flag
= busy_flag
;
1037 cs
->irq_flags
= I4L_IRQ_FLAG
;
1039 if (card
->protocol
== ISDN_PTYPE_NI1
)
1040 test_and_set_bit(FLG_TWO_DCHAN
, &cs
->HW_Flags
);
1042 test_and_set_bit(FLG_TWO_DCHAN
, &cs
->HW_Flags
);
1044 cs
->protocol
= card
->protocol
;
1046 if (card
->typ
<= 0 || card
->typ
> ISDN_CTYPE_COUNT
) {
1048 "HiSax: Card Type %d out of range\n", card
->typ
);
1051 if (!(cs
->dlog
= kmalloc(MAX_DLOG_SPACE
, GFP_ATOMIC
))) {
1053 "HiSax: No memory for dlog(card %d)\n", cardnr
+ 1);
1056 if (!(cs
->status_buf
= kmalloc(HISAX_STATUS_BUFSIZE
, GFP_ATOMIC
))) {
1058 "HiSax: No memory for status_buf(card %d)\n",
1063 cs
->status_read
= cs
->status_buf
;
1064 cs
->status_write
= cs
->status_buf
;
1065 cs
->status_end
= cs
->status_buf
+ HISAX_STATUS_BUFSIZE
- 1;
1066 cs
->typ
= card
->typ
;
1068 cs
->iif
.owner
= lockowner
;
1070 strcpy(cs
->iif
.id
, id
);
1071 cs
->iif
.channels
= 2;
1072 cs
->iif
.maxbufsize
= MAX_DATA_SIZE
;
1073 cs
->iif
.hl_hdrlen
= MAX_HEADER_LEN
;
1075 ISDN_FEATURE_L2_X75I
|
1076 ISDN_FEATURE_L2_HDLC
|
1077 ISDN_FEATURE_L2_HDLC_56K
|
1078 ISDN_FEATURE_L2_TRANS
|
1079 ISDN_FEATURE_L3_TRANS
|
1080 #ifdef CONFIG_HISAX_1TR6
1081 ISDN_FEATURE_P_1TR6
|
1083 #ifdef CONFIG_HISAX_EURO
1084 ISDN_FEATURE_P_EURO
|
1086 #ifdef CONFIG_HISAX_NI1
1087 ISDN_FEATURE_P_NI1
|
1091 cs
->iif
.command
= HiSax_command
;
1092 cs
->iif
.writecmd
= NULL
;
1093 cs
->iif
.writebuf_skb
= HiSax_writebuf_skb
;
1094 cs
->iif
.readstat
= HiSax_readstatus
;
1095 register_isdn(&cs
->iif
);
1096 cs
->myid
= cs
->iif
.channels
;
1099 return 1; /* success */
1107 return 0; /* error */
1110 static int hisax_cs_setup(int cardnr
, struct IsdnCard
*card
,
1111 struct IsdnCardState
*cs
)
1115 if (!(cs
->rcvbuf
= kmalloc(MAX_DFRAME_LEN_L1
, GFP_ATOMIC
))) {
1116 printk(KERN_WARNING
"HiSax: No memory for isac rcvbuf\n");
1125 skb_queue_head_init(&cs
->rq
);
1126 skb_queue_head_init(&cs
->sq
);
1128 init_bcstate(cs
, 0);
1129 init_bcstate(cs
, 1);
1131 /* init_card only handles interrupts which are not */
1132 /* used here for the loadable driver */
1133 switch (card
->typ
) {
1134 case ISDN_CTYPE_DYNAMIC
:
1138 ret
= init_card(cs
);
1145 init_tei(cs
, cs
->protocol
);
1146 ret
= CallcNewChan(cs
);
1151 /* ISAR needs firmware download first */
1152 if (!test_bit(HW_ISAR
, &cs
->HW_Flags
))
1163 /* Used from an exported function but calls __devinit functions.
1164 * Tell modpost not to warn (__ref)
1166 static int __ref
checkcard(int cardnr
, char *id
, int *busy_flag
,
1167 struct module
*lockowner
,
1168 hisax_setup_func_t card_setup
)
1171 struct IsdnCard
*card
= cards
+ cardnr
;
1172 struct IsdnCardState
*cs
;
1174 ret
= hisax_cs_new(cardnr
, id
, card
, &cs
, busy_flag
, lockowner
);
1179 "HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr
+ 1,
1180 (card
->protocol
== ISDN_PTYPE_1TR6
) ? "1TR6" :
1181 (card
->protocol
== ISDN_PTYPE_EURO
) ? "EDSS1" :
1182 (card
->protocol
== ISDN_PTYPE_LEASED
) ? "LEASED" :
1183 (card
->protocol
== ISDN_PTYPE_NI1
) ? "NI1" :
1184 "NONE", cs
->iif
.id
, cs
->myid
);
1186 ret
= card_setup(card
);
1192 ret
= hisax_cs_setup(cardnr
, card
, cs
);
1202 static void HiSax_shiftcards(int idx
)
1206 for (i
= idx
; i
< (HISAX_MAX_CARDS
- 1); i
++)
1207 memcpy(&cards
[i
], &cards
[i
+ 1], sizeof(cards
[i
]));
1210 static int __init
HiSax_inithardware(int *busy_flag
)
1217 char *next_id
= HiSax_id
;
1220 if (strchr(HiSax_id
, ','))
1222 else if (strchr(HiSax_id
, '%'))
1225 while (i
< nrcards
) {
1226 if (cards
[i
].typ
< 1)
1229 if ((next_id
= strchr(id
, t
))) {
1238 sprintf(ids
, "%s%d", id
, i
);
1240 if (checkcard(i
, ids
, busy_flag
, THIS_MODULE
,
1241 hisax_cs_setup_card
)) {
1245 /* make sure we don't oops the module */
1246 if (cards
[i
].typ
> 0 && cards
[i
].typ
<= ISDN_CTYPE_COUNT
) {
1248 "HiSax: Card %s not installed !\n",
1249 CardType
[cards
[i
].typ
]);
1251 HiSax_shiftcards(i
);
1258 void HiSax_closecard(int cardnr
)
1260 int i
, last
= nrcards
- 1;
1262 if (cardnr
> last
|| cardnr
< 0)
1264 if (cards
[cardnr
].cs
) {
1265 ll_stop(cards
[cardnr
].cs
);
1266 release_tei(cards
[cardnr
].cs
);
1267 CallcFreeChan(cards
[cardnr
].cs
);
1270 if (cards
[cardnr
].cs
->irq
)
1271 free_irq(cards
[cardnr
].cs
->irq
, cards
[cardnr
].cs
);
1272 kfree((void *) cards
[cardnr
].cs
);
1273 cards
[cardnr
].cs
= NULL
;
1277 cards
[i
] = cards
[i
+ 1];
1283 void HiSax_reportcard(int cardnr
, int sel
)
1285 struct IsdnCardState
*cs
= cards
[cardnr
].cs
;
1287 printk(KERN_DEBUG
"HiSax: reportcard No %d\n", cardnr
+ 1);
1288 printk(KERN_DEBUG
"HiSax: Type %s\n", CardType
[cs
->typ
]);
1289 printk(KERN_DEBUG
"HiSax: debuglevel %x\n", cs
->debug
);
1290 printk(KERN_DEBUG
"HiSax: HiSax_reportcard address 0x%lX\n",
1291 (ulong
) & HiSax_reportcard
);
1292 printk(KERN_DEBUG
"HiSax: cs 0x%lX\n", (ulong
) cs
);
1293 printk(KERN_DEBUG
"HiSax: HW_Flags %lx bc0 flg %lx bc1 flg %lx\n",
1294 cs
->HW_Flags
, cs
->bcs
[0].Flag
, cs
->bcs
[1].Flag
);
1295 printk(KERN_DEBUG
"HiSax: bcs 0 mode %d ch%d\n",
1296 cs
->bcs
[0].mode
, cs
->bcs
[0].channel
);
1297 printk(KERN_DEBUG
"HiSax: bcs 1 mode %d ch%d\n",
1298 cs
->bcs
[1].mode
, cs
->bcs
[1].channel
);
1299 #ifdef ERROR_STATISTIC
1300 printk(KERN_DEBUG
"HiSax: dc errors(rx,crc,tx) %d,%d,%d\n",
1301 cs
->err_rx
, cs
->err_crc
, cs
->err_tx
);
1303 "HiSax: bc0 errors(inv,rdo,crc,tx) %d,%d,%d,%d\n",
1304 cs
->bcs
[0].err_inv
, cs
->bcs
[0].err_rdo
, cs
->bcs
[0].err_crc
,
1307 "HiSax: bc1 errors(inv,rdo,crc,tx) %d,%d,%d,%d\n",
1308 cs
->bcs
[1].err_inv
, cs
->bcs
[1].err_rdo
, cs
->bcs
[1].err_crc
,
1314 cs
->bcs
[0].err_inv
= 0;
1315 cs
->bcs
[0].err_rdo
= 0;
1316 cs
->bcs
[0].err_crc
= 0;
1317 cs
->bcs
[0].err_tx
= 0;
1318 cs
->bcs
[1].err_inv
= 0;
1319 cs
->bcs
[1].err_rdo
= 0;
1320 cs
->bcs
[1].err_crc
= 0;
1321 cs
->bcs
[1].err_tx
= 0;
1326 static int __init
HiSax_init(void)
1335 retval
= CallcNew();
1338 retval
= Isdnl3New();
1341 retval
= Isdnl2New();
1347 retval
= Isdnl1New();
1353 /* We 'll register drivers later, but init basic functions */
1354 for (i
= 0; i
< HISAX_MAX_CARDS
; i
++)
1358 #ifdef CONFIG_HISAX_ELSA
1359 if (type
[0] == ISDN_CTYPE_ELSA_PCMCIA
) {
1360 /* we have exported and return in this case */
1364 #ifdef CONFIG_HISAX_SEDLBAUER
1365 if (type
[0] == ISDN_CTYPE_SEDLBAUER_PCMCIA
) {
1366 /* we have to export and return in this case */
1370 #ifdef CONFIG_HISAX_AVM_A1_PCMCIA
1371 if (type
[0] == ISDN_CTYPE_A1_PCMCIA
) {
1372 /* we have to export and return in this case */
1376 #ifdef CONFIG_HISAX_HFC_SX
1377 if (type
[0] == ISDN_CTYPE_HFC_SP_PCMCIA
) {
1378 /* we have to export and return in this case */
1385 if (id
) /* If id= string used */
1387 for (i
= j
= 0; j
< HISAX_MAX_CARDS
; i
++) {
1388 cards
[j
].typ
= type
[i
];
1390 cards
[j
].protocol
= protocol
[i
];
1393 cards
[j
].protocol
= DEFAULT_PROTO
;
1396 case ISDN_CTYPE_16_0
:
1397 cards
[j
].para
[0] = irq
[i
];
1398 cards
[j
].para
[1] = mem
[i
];
1399 cards
[j
].para
[2] = io
[i
];
1402 case ISDN_CTYPE_8_0
:
1403 cards
[j
].para
[0] = irq
[i
];
1404 cards
[j
].para
[1] = mem
[i
];
1408 case ISDN_CTYPE_PNP
:
1409 case ISDN_CTYPE_NICCY
:
1410 cards
[j
].para
[0] = irq
[i
];
1411 cards
[j
].para
[1] = io0
[i
];
1412 cards
[j
].para
[2] = io1
[i
];
1414 case ISDN_CTYPE_COMPAQ_ISA
:
1415 cards
[j
].para
[0] = irq
[i
];
1416 cards
[j
].para
[1] = io0
[i
];
1417 cards
[j
].para
[2] = io1
[i
];
1418 cards
[j
].para
[3] = io
[i
];
1421 case ISDN_CTYPE_ELSA
:
1422 case ISDN_CTYPE_HFC_PCI
:
1423 cards
[j
].para
[0] = io
[i
];
1425 case ISDN_CTYPE_16_3
:
1426 case ISDN_CTYPE_TELESPCMCIA
:
1428 case ISDN_CTYPE_A1_PCMCIA
:
1429 case ISDN_CTYPE_ELSA_PNP
:
1430 case ISDN_CTYPE_ELSA_PCMCIA
:
1431 case ISDN_CTYPE_IX1MICROR2
:
1432 case ISDN_CTYPE_DIEHLDIVA
:
1433 case ISDN_CTYPE_ASUSCOM
:
1434 case ISDN_CTYPE_TELEINT
:
1435 case ISDN_CTYPE_SEDLBAUER
:
1436 case ISDN_CTYPE_SEDLBAUER_PCMCIA
:
1437 case ISDN_CTYPE_SEDLBAUER_FAX
:
1438 case ISDN_CTYPE_SPORTSTER
:
1439 case ISDN_CTYPE_MIC
:
1440 case ISDN_CTYPE_TELES3C
:
1441 case ISDN_CTYPE_ACERP10
:
1442 case ISDN_CTYPE_S0BOX
:
1443 case ISDN_CTYPE_FRITZPCI
:
1444 case ISDN_CTYPE_HSTSAPHIR
:
1445 case ISDN_CTYPE_GAZEL
:
1446 case ISDN_CTYPE_HFC_SX
:
1447 case ISDN_CTYPE_HFC_SP_PCMCIA
:
1448 cards
[j
].para
[0] = irq
[i
];
1449 cards
[j
].para
[1] = io
[i
];
1451 case ISDN_CTYPE_ISURF
:
1452 cards
[j
].para
[0] = irq
[i
];
1453 cards
[j
].para
[1] = io
[i
];
1454 cards
[j
].para
[2] = mem
[i
];
1456 case ISDN_CTYPE_ELSA_PCI
:
1457 case ISDN_CTYPE_NETJET_S
:
1458 case ISDN_CTYPE_TELESPCI
:
1459 case ISDN_CTYPE_W6692
:
1460 case ISDN_CTYPE_NETJET_U
:
1462 case ISDN_CTYPE_BKM_A4T
:
1464 case ISDN_CTYPE_SCT_QUADRO
:
1466 cards
[j
].para
[0] = irq
[i
];
1468 /* QUADRO is a 4 BRI card */
1469 cards
[j
++].para
[0] = 1;
1470 /* we need to check if further cards can be added */
1471 if (j
< HISAX_MAX_CARDS
) {
1472 cards
[j
].typ
= ISDN_CTYPE_SCT_QUADRO
;
1473 cards
[j
].protocol
= protocol
[i
];
1474 cards
[j
++].para
[0] = 2;
1476 if (j
< HISAX_MAX_CARDS
) {
1477 cards
[j
].typ
= ISDN_CTYPE_SCT_QUADRO
;
1478 cards
[j
].protocol
= protocol
[i
];
1479 cards
[j
++].para
[0] = 3;
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] = 4;
1493 "HiSax: Warning - no protocol specified\n");
1494 printk(KERN_WARNING
"HiSax: using protocol %s\n",
1495 DEFAULT_PROTO_NAME
);
1501 strcpy(HiSaxID
, "HiSax");
1502 for (i
= 0; i
< HISAX_MAX_CARDS
; i
++)
1503 if (cards
[i
].typ
> 0)
1505 printk(KERN_DEBUG
"HiSax: Total %d card%s defined\n",
1506 nrcards
, (nrcards
> 1) ? "s" : "");
1508 /* Install only, if at least one card found */
1509 if (!HiSax_inithardware(NULL
))
1525 static void __exit
HiSax_exit(void)
1527 int cardnr
= nrcards
- 1;
1530 HiSax_closecard(cardnr
--);
1536 printk(KERN_INFO
"HiSax module removed\n");
1539 #ifdef CONFIG_HOTPLUG
1541 int __devinit
hisax_init_pcmcia(void *pcm_iob
, int *busy_flag
, struct IsdnCard
*card
)
1546 cards
[nrcards
] = *card
;
1548 sprintf(ids
, "HiSax%d", nrcards
);
1550 sprintf(ids
, "HiSax");
1551 if (!checkcard(nrcards
, ids
, busy_flag
, THIS_MODULE
,
1552 hisax_cs_setup_card
))
1561 EXPORT_SYMBOL(hisax_init_pcmcia
);
1564 EXPORT_SYMBOL(HiSax_closecard
);
1566 #include "hisax_if.h"
1568 EXPORT_SYMBOL(hisax_register
);
1569 EXPORT_SYMBOL(hisax_unregister
);
1571 static void hisax_d_l1l2(struct hisax_if
*ifc
, int pr
, void *arg
);
1572 static void hisax_b_l1l2(struct hisax_if
*ifc
, int pr
, void *arg
);
1573 static void hisax_d_l2l1(struct PStack
*st
, int pr
, void *arg
);
1574 static void hisax_b_l2l1(struct PStack
*st
, int pr
, void *arg
);
1575 static int hisax_cardmsg(struct IsdnCardState
*cs
, int mt
, void *arg
);
1576 static int hisax_bc_setstack(struct PStack
*st
, struct BCState
*bcs
);
1577 static void hisax_bc_close(struct BCState
*bcs
);
1578 static void hisax_bh(struct work_struct
*work
);
1579 static void EChannel_proc_rcv(struct hisax_d_if
*d_if
);
1581 static int hisax_setup_card_dynamic(struct IsdnCard
*card
)
1586 int hisax_register(struct hisax_d_if
*hisax_d_if
, struct hisax_b_if
*b_if
[],
1587 char *name
, int protocol
)
1591 struct IsdnCardState
*cs
;
1593 for (i
= 0; i
< HISAX_MAX_CARDS
; i
++) {
1598 if (i
>= HISAX_MAX_CARDS
)
1601 cards
[i
].typ
= ISDN_CTYPE_DYNAMIC
;
1602 cards
[i
].protocol
= protocol
;
1603 sprintf(id
, "%s%d", name
, i
);
1605 retval
= checkcard(i
, id
, NULL
, hisax_d_if
->owner
,
1606 hisax_setup_card_dynamic
);
1607 if (retval
== 0) { // yuck
1613 hisax_d_if
->cs
= cs
;
1614 cs
->hw
.hisax_d_if
= hisax_d_if
;
1615 cs
->cardmsg
= hisax_cardmsg
;
1616 INIT_WORK(&cs
->tqueue
, hisax_bh
);
1617 cs
->channel
[0].d_st
->l2
.l2l1
= hisax_d_l2l1
;
1618 for (i
= 0; i
< 2; i
++) {
1619 cs
->bcs
[i
].BC_SetStack
= hisax_bc_setstack
;
1620 cs
->bcs
[i
].BC_Close
= hisax_bc_close
;
1622 b_if
[i
]->ifc
.l1l2
= hisax_b_l1l2
;
1624 hisax_d_if
->b_if
[i
] = b_if
[i
];
1626 hisax_d_if
->ifc
.l1l2
= hisax_d_l1l2
;
1627 skb_queue_head_init(&hisax_d_if
->erq
);
1628 clear_bit(0, &hisax_d_if
->ph_state
);
1633 void hisax_unregister(struct hisax_d_if
*hisax_d_if
)
1635 cards
[hisax_d_if
->cs
->cardnr
].typ
= 0;
1636 HiSax_closecard(hisax_d_if
->cs
->cardnr
);
1637 skb_queue_purge(&hisax_d_if
->erq
);
1642 static void hisax_sched_event(struct IsdnCardState
*cs
, int event
)
1644 test_and_set_bit(event
, &cs
->event
);
1645 schedule_work(&cs
->tqueue
);
1648 static void hisax_bh(struct work_struct
*work
)
1650 struct IsdnCardState
*cs
=
1651 container_of(work
, struct IsdnCardState
, tqueue
);
1655 if (test_and_clear_bit(D_RCVBUFREADY
, &cs
->event
))
1656 DChannel_proc_rcv(cs
);
1657 if (test_and_clear_bit(E_RCVBUFREADY
, &cs
->event
))
1658 EChannel_proc_rcv(cs
->hw
.hisax_d_if
);
1659 if (test_and_clear_bit(D_L1STATECHANGE
, &cs
->event
)) {
1660 if (test_bit(0, &cs
->hw
.hisax_d_if
->ph_state
))
1661 pr
= PH_ACTIVATE
| INDICATION
;
1663 pr
= PH_DEACTIVATE
| INDICATION
;
1664 for (st
= cs
->stlist
; st
; st
= st
->next
)
1665 st
->l1
.l1l2(st
, pr
, NULL
);
1670 static void hisax_b_sched_event(struct BCState
*bcs
, int event
)
1672 test_and_set_bit(event
, &bcs
->event
);
1673 schedule_work(&bcs
->tqueue
);
1676 static inline void D_L2L1(struct hisax_d_if
*d_if
, int pr
, void *arg
)
1678 struct hisax_if
*ifc
= (struct hisax_if
*) d_if
;
1679 ifc
->l2l1(ifc
, pr
, arg
);
1682 static inline void B_L2L1(struct hisax_b_if
*b_if
, int pr
, void *arg
)
1684 struct hisax_if
*ifc
= (struct hisax_if
*) b_if
;
1685 ifc
->l2l1(ifc
, pr
, arg
);
1688 static void hisax_d_l1l2(struct hisax_if
*ifc
, int pr
, void *arg
)
1690 struct hisax_d_if
*d_if
= (struct hisax_d_if
*) ifc
;
1691 struct IsdnCardState
*cs
= d_if
->cs
;
1693 struct sk_buff
*skb
;
1696 case PH_ACTIVATE
| INDICATION
:
1697 set_bit(0, &d_if
->ph_state
);
1698 hisax_sched_event(cs
, D_L1STATECHANGE
);
1700 case PH_DEACTIVATE
| INDICATION
:
1701 clear_bit(0, &d_if
->ph_state
);
1702 hisax_sched_event(cs
, D_L1STATECHANGE
);
1704 case PH_DATA
| INDICATION
:
1705 skb_queue_tail(&cs
->rq
, arg
);
1706 hisax_sched_event(cs
, D_RCVBUFREADY
);
1708 case PH_DATA
| CONFIRM
:
1709 skb
= skb_dequeue(&cs
->sq
);
1711 D_L2L1(d_if
, PH_DATA
| REQUEST
, skb
);
1714 clear_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
);
1715 for (st
= cs
->stlist
; st
; st
= st
->next
) {
1716 if (test_and_clear_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
)) {
1717 st
->l1
.l1l2(st
, PH_PULL
| CONFIRM
, NULL
);
1722 case PH_DATA_E
| INDICATION
:
1723 skb_queue_tail(&d_if
->erq
, arg
);
1724 hisax_sched_event(cs
, E_RCVBUFREADY
);
1727 printk("pr %#x\n", pr
);
1732 static void hisax_b_l1l2(struct hisax_if
*ifc
, int pr
, void *arg
)
1734 struct hisax_b_if
*b_if
= (struct hisax_b_if
*) ifc
;
1735 struct BCState
*bcs
= b_if
->bcs
;
1736 struct PStack
*st
= bcs
->st
;
1737 struct sk_buff
*skb
;
1739 // FIXME use isdnl1?
1741 case PH_ACTIVATE
| INDICATION
:
1742 st
->l1
.l1l2(st
, pr
, NULL
);
1744 case PH_DEACTIVATE
| INDICATION
:
1745 st
->l1
.l1l2(st
, pr
, NULL
);
1746 clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1747 skb_queue_purge(&bcs
->squeue
);
1748 bcs
->hw
.b_if
= NULL
;
1750 case PH_DATA
| INDICATION
:
1751 skb_queue_tail(&bcs
->rqueue
, arg
);
1752 hisax_b_sched_event(bcs
, B_RCVBUFREADY
);
1754 case PH_DATA
| CONFIRM
:
1755 bcs
->tx_cnt
-= (long)arg
;
1756 if (test_bit(FLG_LLI_L1WAKEUP
,&bcs
->st
->lli
.flag
)) {
1758 spin_lock_irqsave(&bcs
->aclock
, flags
);
1759 bcs
->ackcnt
+= (long)arg
;
1760 spin_unlock_irqrestore(&bcs
->aclock
, flags
);
1761 schedule_event(bcs
, B_ACKPENDING
);
1763 skb
= skb_dequeue(&bcs
->squeue
);
1765 B_L2L1(b_if
, PH_DATA
| REQUEST
, skb
);
1768 clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1769 if (test_and_clear_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
)) {
1770 st
->l1
.l1l2(st
, PH_PULL
| CONFIRM
, NULL
);
1774 printk("hisax_b_l1l2 pr %#x\n", pr
);
1779 static void hisax_d_l2l1(struct PStack
*st
, int pr
, void *arg
)
1781 struct IsdnCardState
*cs
= st
->l1
.hardware
;
1782 struct hisax_d_if
*hisax_d_if
= cs
->hw
.hisax_d_if
;
1783 struct sk_buff
*skb
= arg
;
1786 case PH_DATA
| REQUEST
:
1787 case PH_PULL
| INDICATION
:
1788 if (cs
->debug
& DEB_DLOG_HEX
)
1789 LogFrame(cs
, skb
->data
, skb
->len
);
1790 if (cs
->debug
& DEB_DLOG_VERBOSE
)
1791 dlogframe(cs
, skb
, 0);
1792 Logl2Frame(cs
, skb
, "PH_DATA_REQ", 0);
1794 if (!test_and_set_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
))
1795 D_L2L1(hisax_d_if
, PH_DATA
| REQUEST
, skb
);
1797 skb_queue_tail(&cs
->sq
, skb
);
1799 case PH_PULL
| REQUEST
:
1800 if (!test_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
))
1801 st
->l1
.l1l2(st
, PH_PULL
| CONFIRM
, NULL
);
1803 set_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
);
1806 D_L2L1(hisax_d_if
, pr
, arg
);
1811 static int hisax_cardmsg(struct IsdnCardState
*cs
, int mt
, void *arg
)
1816 static void hisax_b_l2l1(struct PStack
*st
, int pr
, void *arg
)
1818 struct BCState
*bcs
= st
->l1
.bcs
;
1819 struct hisax_b_if
*b_if
= bcs
->hw
.b_if
;
1822 case PH_ACTIVATE
| REQUEST
:
1823 B_L2L1(b_if
, pr
, (void *)(unsigned long)st
->l1
.mode
);
1825 case PH_DATA
| REQUEST
:
1826 case PH_PULL
| INDICATION
:
1828 if (!test_and_set_bit(BC_FLG_BUSY
, &bcs
->Flag
)) {
1829 B_L2L1(b_if
, PH_DATA
| REQUEST
, arg
);
1831 skb_queue_tail(&bcs
->squeue
, arg
);
1834 case PH_PULL
| REQUEST
:
1835 if (!test_bit(BC_FLG_BUSY
, &bcs
->Flag
))
1836 st
->l1
.l1l2(st
, PH_PULL
| CONFIRM
, NULL
);
1838 set_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
);
1840 case PH_DEACTIVATE
| REQUEST
:
1841 test_and_clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
1842 skb_queue_purge(&bcs
->squeue
);
1844 B_L2L1(b_if
, pr
, arg
);
1849 static int hisax_bc_setstack(struct PStack
*st
, struct BCState
*bcs
)
1851 struct IsdnCardState
*cs
= st
->l1
.hardware
;
1852 struct hisax_d_if
*hisax_d_if
= cs
->hw
.hisax_d_if
;
1854 bcs
->channel
= st
->l1
.bc
;
1856 bcs
->hw
.b_if
= hisax_d_if
->b_if
[st
->l1
.bc
];
1857 hisax_d_if
->b_if
[st
->l1
.bc
]->bcs
= bcs
;
1860 st
->l2
.l2l1
= hisax_b_l2l1
;
1861 setstack_manager(st
);
1864 skb_queue_head_init(&bcs
->rqueue
);
1865 skb_queue_head_init(&bcs
->squeue
);
1869 static void hisax_bc_close(struct BCState
*bcs
)
1871 struct hisax_b_if
*b_if
= bcs
->hw
.b_if
;
1874 B_L2L1(b_if
, PH_DEACTIVATE
| REQUEST
, NULL
);
1877 static void EChannel_proc_rcv(struct hisax_d_if
*d_if
)
1879 struct IsdnCardState
*cs
= d_if
->cs
;
1881 struct sk_buff
*skb
;
1883 while ((skb
= skb_dequeue(&d_if
->erq
)) != NULL
) {
1884 if (cs
->debug
& DEB_DLOG_HEX
) {
1886 if ((skb
->len
) < MAX_DLOG_SPACE
/ 3 - 10) {
1892 ptr
+= QuickHex(ptr
, skb
->data
, skb
->len
);
1896 HiSax_putstatus(cs
, NULL
, cs
->dlog
);
1898 HiSax_putstatus(cs
, "LogEcho: ",
1899 "warning Frame too big (%d)",
1902 dev_kfree_skb_any(skb
);
1907 #include <linux/pci.h>
1909 static struct pci_device_id hisax_pci_tbl
[] __devinitdata
= {
1910 #ifdef CONFIG_HISAX_FRITZPCI
1911 {PCI_VENDOR_ID_AVM
, PCI_DEVICE_ID_AVM_A1
, PCI_ANY_ID
, PCI_ANY_ID
},
1913 #ifdef CONFIG_HISAX_DIEHLDIVA
1914 {PCI_VENDOR_ID_EICON
, PCI_DEVICE_ID_EICON_DIVA20
, PCI_ANY_ID
, PCI_ANY_ID
},
1915 {PCI_VENDOR_ID_EICON
, PCI_DEVICE_ID_EICON_DIVA20_U
, PCI_ANY_ID
, PCI_ANY_ID
},
1916 {PCI_VENDOR_ID_EICON
, PCI_DEVICE_ID_EICON_DIVA201
, PCI_ANY_ID
, PCI_ANY_ID
},
1917 //#########################################################################################
1918 {PCI_VENDOR_ID_EICON
, PCI_DEVICE_ID_EICON_DIVA202
, PCI_ANY_ID
, PCI_ANY_ID
},
1919 //#########################################################################################
1921 #ifdef CONFIG_HISAX_ELSA
1922 {PCI_VENDOR_ID_ELSA
, PCI_DEVICE_ID_ELSA_MICROLINK
, PCI_ANY_ID
, PCI_ANY_ID
},
1923 {PCI_VENDOR_ID_ELSA
, PCI_DEVICE_ID_ELSA_QS3000
, PCI_ANY_ID
, PCI_ANY_ID
},
1925 #ifdef CONFIG_HISAX_GAZEL
1926 {PCI_VENDOR_ID_PLX
, PCI_DEVICE_ID_PLX_R685
, PCI_ANY_ID
, PCI_ANY_ID
},
1927 {PCI_VENDOR_ID_PLX
, PCI_DEVICE_ID_PLX_R753
, PCI_ANY_ID
, PCI_ANY_ID
},
1928 {PCI_VENDOR_ID_PLX
, PCI_DEVICE_ID_PLX_DJINN_ITOO
, PCI_ANY_ID
, PCI_ANY_ID
},
1929 {PCI_VENDOR_ID_PLX
, PCI_DEVICE_ID_PLX_OLITEC
, PCI_ANY_ID
, PCI_ANY_ID
},
1931 #ifdef CONFIG_HISAX_SCT_QUADRO
1932 {PCI_VENDOR_ID_PLX
, PCI_DEVICE_ID_PLX_9050
, PCI_ANY_ID
, PCI_ANY_ID
},
1934 #ifdef CONFIG_HISAX_NICCY
1935 {PCI_VENDOR_ID_SATSAGEM
, PCI_DEVICE_ID_SATSAGEM_NICCY
, PCI_ANY_ID
,PCI_ANY_ID
},
1937 #ifdef CONFIG_HISAX_SEDLBAUER
1938 {PCI_VENDOR_ID_TIGERJET
, PCI_DEVICE_ID_TIGERJET_100
, PCI_ANY_ID
,PCI_ANY_ID
},
1940 #if defined(CONFIG_HISAX_NETJET) || defined(CONFIG_HISAX_NETJET_U)
1941 {PCI_VENDOR_ID_TIGERJET
, PCI_DEVICE_ID_TIGERJET_300
, PCI_ANY_ID
,PCI_ANY_ID
},
1943 #if defined(CONFIG_HISAX_TELESPCI) || defined(CONFIG_HISAX_SCT_QUADRO)
1944 {PCI_VENDOR_ID_ZORAN
, PCI_DEVICE_ID_ZORAN_36120
, PCI_ANY_ID
,PCI_ANY_ID
},
1946 #ifdef CONFIG_HISAX_W6692
1947 {PCI_VENDOR_ID_DYNALINK
, PCI_DEVICE_ID_DYNALINK_IS64PH
, PCI_ANY_ID
,PCI_ANY_ID
},
1948 {PCI_VENDOR_ID_WINBOND2
, PCI_DEVICE_ID_WINBOND2_6692
, PCI_ANY_ID
,PCI_ANY_ID
},
1950 #ifdef CONFIG_HISAX_HFC_PCI
1951 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_2BD0
, PCI_ANY_ID
, PCI_ANY_ID
},
1952 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B000
, PCI_ANY_ID
, PCI_ANY_ID
},
1953 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B006
, PCI_ANY_ID
, PCI_ANY_ID
},
1954 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B007
, PCI_ANY_ID
, PCI_ANY_ID
},
1955 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B008
, PCI_ANY_ID
, PCI_ANY_ID
},
1956 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B009
, PCI_ANY_ID
, PCI_ANY_ID
},
1957 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B00A
, PCI_ANY_ID
, PCI_ANY_ID
},
1958 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B00B
, PCI_ANY_ID
, PCI_ANY_ID
},
1959 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B00C
, PCI_ANY_ID
, PCI_ANY_ID
},
1960 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B100
, PCI_ANY_ID
, PCI_ANY_ID
},
1961 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B700
, PCI_ANY_ID
, PCI_ANY_ID
},
1962 {PCI_VENDOR_ID_CCD
, PCI_DEVICE_ID_CCD_B701
, PCI_ANY_ID
, PCI_ANY_ID
},
1963 {PCI_VENDOR_ID_ABOCOM
, PCI_DEVICE_ID_ABOCOM_2BD1
, PCI_ANY_ID
, PCI_ANY_ID
},
1964 {PCI_VENDOR_ID_ASUSTEK
, PCI_DEVICE_ID_ASUSTEK_0675
, PCI_ANY_ID
, PCI_ANY_ID
},
1965 {PCI_VENDOR_ID_BERKOM
, PCI_DEVICE_ID_BERKOM_T_CONCEPT
, PCI_ANY_ID
, PCI_ANY_ID
},
1966 {PCI_VENDOR_ID_BERKOM
, PCI_DEVICE_ID_BERKOM_A1T
, PCI_ANY_ID
, PCI_ANY_ID
},
1967 {PCI_VENDOR_ID_ANIGMA
, PCI_DEVICE_ID_ANIGMA_MC145575
, PCI_ANY_ID
, PCI_ANY_ID
},
1968 {PCI_VENDOR_ID_ZOLTRIX
, PCI_DEVICE_ID_ZOLTRIX_2BD0
, PCI_ANY_ID
, PCI_ANY_ID
},
1969 {PCI_VENDOR_ID_DIGI
, PCI_DEVICE_ID_DIGI_DF_M_IOM2_E
, PCI_ANY_ID
, PCI_ANY_ID
},
1970 {PCI_VENDOR_ID_DIGI
, PCI_DEVICE_ID_DIGI_DF_M_E
, PCI_ANY_ID
, PCI_ANY_ID
},
1971 {PCI_VENDOR_ID_DIGI
, PCI_DEVICE_ID_DIGI_DF_M_IOM2_A
, PCI_ANY_ID
, PCI_ANY_ID
},
1972 {PCI_VENDOR_ID_DIGI
, PCI_DEVICE_ID_DIGI_DF_M_A
, PCI_ANY_ID
, PCI_ANY_ID
},
1974 { } /* Terminating entry */
1977 MODULE_DEVICE_TABLE(pci
, hisax_pci_tbl
);
1978 #endif /* CONFIG_PCI */
1980 module_init(HiSax_init
);
1981 module_exit(HiSax_exit
);
1983 EXPORT_SYMBOL(FsmNew
);
1984 EXPORT_SYMBOL(FsmFree
);
1985 EXPORT_SYMBOL(FsmEvent
);
1986 EXPORT_SYMBOL(FsmChangeState
);
1987 EXPORT_SYMBOL(FsmInitTimer
);
1988 EXPORT_SYMBOL(FsmDelTimer
);
1989 EXPORT_SYMBOL(FsmRestartTimer
);