OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [drivers/] [isdn/] [hisax/] [config.c] - Blame information for rev 1777

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1626 jcastillo
/* $Id: config.c,v 1.1 2005-12-20 10:17:01 jcastillo Exp $
2
 
3
 * Author       Karsten Keil (keil@isdn4linux.de)
4
 *              based on the teles driver from Jan den Ouden
5
 *
6
 *
7
 * $Log: not supported by cvs2svn $
8
 * Revision 1.1.1.1  2001/09/10 07:44:18  simons
9
 * Initial import
10
 *
11
 * Revision 1.1.1.1  2001/07/02 17:58:32  simons
12
 * Initial revision
13
 *
14
 * Revision 1.15.2.24  1998/11/11 13:37:53  keil
15
 * fix typo
16
 *
17
 * Revision 1.15.2.23  1998/11/11 11:04:36  keil
18
 * update version
19
 *
20
 * Revision 1.15.2.22  1998/11/08 13:00:56  niemann
21
 * Added doc for Sedlbauer ISDN cards,
22
 * added info for downloading firmware (Sedlbauer speed fax+)
23
 *
24
 * Revision 1.15.2.21  1998/11/05 21:13:46  keil
25
 * minor fixes
26
 *
27
 * Revision 1.15.2.20  1998/11/04 11:50:32  fritz
28
 * Make compile with modversions enabled.
29
 *
30
 * Revision 1.15.2.19  1998/11/03 00:06:05  keil
31
 * certification related changes
32
 * fixed logging for smaller stack use
33
 *
34
 * Revision 1.15.2.18  1998/10/13 10:27:26  keil
35
 * New cards, minor fixes
36
 *
37
 * Revision 1.15.2.17  1998/10/11 19:31:31  niemann
38
 * Fixed problems with CONFIG_MODVERSIONS for sedlbauer cards
39
 *
40
 * Revision 1.15.2.16  1998/09/27 13:05:48  keil
41
 * Apply most changes from 2.1.X (HiSax 3.1)
42
 *
43
 * Revision 1.15.2.15  1998/09/12 18:43:56  niemann
44
 * Added new card: Sedlbauer ISDN-Controller PC/104
45
 *
46
 * Revision 1.15.2.14  1998/08/25 14:01:27  calle
47
 * Ported driver for AVM Fritz!Card PCI from the 2.1 tree.
48
 * I could not test it.
49
 *
50
 * Revision 1.15.2.13  1998/07/30 20:51:24  niemann
51
 * Fixed Sedlbauer Speed Card PCMCIA missing isdnl3new
52
 *
53
 * Revision 1.15.2.12  1998/07/15 14:43:29  calle
54
 * Support for AVM passive PCMCIA cards:
55
 *    A1 PCMCIA, FRITZ!Card PCMCIA and FRITZ!Card PCMCIA 2.0
56
 *
57
 * Revision 1.15.2.11  1998/05/27 18:05:07  keil
58
 * HiSax 3.0
59
 *
60
 * Revision 1.15.2.10  1998/04/11 18:43:13  keil
61
 * New cards
62
 *
63
 * Revision 1.15.2.9  1998/03/07 23:15:12  tsbogend
64
 * made HiSax working on Linux/Alpha
65
 *
66
 * Revision 1.15.2.8  1998/02/11 19:21:37  keil
67
 * fix typo
68
 *
69
 * Revision 1.15.2.7  1998/02/11 14:23:08  keil
70
 * support for Dr Neuhaus Niccy PnP and PCI
71
 *
72
 * Revision 1.15.2.6  1998/02/09 11:21:19  keil
73
 * Sedlbauer PCMCIA support from Marcus Niemann
74
 *
75
 * Revision 1.15.2.5  1998/01/27 23:28:48  keil
76
 * v2.8
77
 *
78
 * Revision 1.15.2.4  1998/01/27 22:33:53  keil
79
 * dynalink ----> asuscom
80
 *
81
 * Revision 1.15.2.3  1998/01/11 22:55:15  keil
82
 * 16.3c support
83
 *
84
 * Revision 1.15.2.2  1997/11/15 18:55:46  keil
85
 * New init, new cards
86
 *
87
 * Revision 1.15.2.1  1997/10/17 22:13:40  keil
88
 * update to last hisax version
89
 *
90
 * Revision 2.2  1997/09/11 17:24:46  keil
91
 * Add new cards
92
 *
93
 * Revision 2.1  1997/07/27 21:41:35  keil
94
 * version change
95
 *
96
 * Revision 2.0  1997/06/26 11:06:28  keil
97
 * New card and L1 interface.
98
 * Eicon.Diehl Diva and Dynalink IS64PH support
99
 *
100
 * old changes removed /KKe
101
 *
102
 */
103
#include <linux/types.h>
104
#include <linux/stddef.h>
105
#include <linux/timer.h>
106
#include <linux/config.h>
107
#include "hisax.h"
108
#include <linux/module.h>
109
#include <linux/kernel_stat.h>
110
#define kstat_irqs( PAR ) kstat.interrupts[PAR]
111
#include <linux/tqueue.h>
112
#include <linux/interrupt.h>
113
#define HISAX_STATUS_BUFSIZE 4096
114
#define INCLUDE_INLINE_FUNCS
115
 
116
/*
117
 * This structure array contains one entry per card. An entry looks
118
 * like this:
119
 *
120
 * { type, protocol, p0, p1, p2, NULL }
121
 *
122
 * type
123
 *    1 Teles 16.0       p0=irq p1=membase p2=iobase
124
 *    2 Teles  8.0       p0=irq p1=membase
125
 *    3 Teles 16.3       p0=irq p1=iobase
126
 *    4 Creatix PNP      p0=irq p1=IO0 (ISAC)  p2=IO1 (HSCX)
127
 *    5 AVM A1 (Fritz)   p0=irq p1=iobase
128
 *    6 ELSA PC          [p0=iobase] or nothing (autodetect)
129
 *    7 ELSA Quickstep   p0=irq p1=iobase
130
 *    8 Teles PCMCIA     p0=irq p1=iobase
131
 *    9 ITK ix1-micro    p0=irq p1=iobase
132
 *   10 ELSA PCMCIA      p0=irq p1=iobase
133
 *   11 Eicon.Diehl Diva p0=irq p1=iobase
134
 *   12 Asuscom ISDNLink p0=irq p1=iobase
135
 *   13 Teleint          p0=irq p1=iobase
136
 *   14 Teles 16.3c      p0=irq p1=iobase
137
 *   15 Sedlbauer speed  p0=irq p1=iobase
138
 *   15 Sedlbauer PC/104        p0=irq p1=iobase
139
 *   15 Sedlbauer speed pci     no parameter
140
 *   16 USR Sportster internal  p0=irq  p1=iobase
141
 *   17 MIC card                p0=irq  p1=iobase
142
 *   18 ELSA Quickstep 1000PCI  no parameter
143
 *   19 Compaq ISDN S0 ISA card p0=irq  p1=IO0 (HSCX)  p2=IO1 (ISAC) p3=IO2
144
 *   20 Travers Technologies NETjet PCI card
145
 *   21 TELES PCI               no parameter
146
 *   22 Sedlbauer Speed Star    p0=irq p1=iobase
147
 *   23 reserved
148
 *   24 Dr Neuhaus Niccy PnP/PCI card p0=irq p1=IO0 p2=IO1 (PnP only)
149
 *   25 Teles S0Box             p0=irq p1=iobase (from isapnp setup)
150
 *   26 AVM A1 PCMCIA (Fritz)   p0=irq p1=iobase
151
 *   27 AVM PnP/PCI             p0=irq p1=iobase (PCI no parameter)
152
 *   28 Sedlbauer Speed Fax+    p0=irq p1=iobase (from isapnp setup)
153
 *
154
 * protocol can be either ISDN_PTYPE_EURO or ISDN_PTYPE_1TR6 or ISDN_PTYPE_NI1
155
 *
156
 *
157
 */
158
 
159
const char *CardType[] =
160
{"No Card", "Teles 16.0", "Teles 8.0", "Teles 16.3", "Creatix/Teles PnP",
161
 "AVM A1", "Elsa ML", "Elsa Quickstep", "Teles PCMCIA", "ITK ix1-micro Rev.2",
162
 "Elsa PCMCIA", "Eicon.Diehl Diva", "ISDNLink", "TeleInt", "Teles 16.3c",
163
 "Sedlbauer Speed Card", "USR Sportster", "ith mic Linux", "Elsa PCI",
164
 "Compaq ISA", "NETjet", "Teles PCI", "Sedlbauer Speed Star (PCMCIA)",
165
 "AMD 7930", "NICCY", "S0Box", "AVM A1 (PCMCIA)", "AVM Fritz PnP/PCI",
166
 "Sedlbauer Speed Fax +"
167
};
168
 
169
#ifdef CONFIG_HISAX_ELSA
170
#define DEFAULT_CARD ISDN_CTYPE_ELSA
171
#define DEFAULT_CFG {0,0,0,0}
172
int elsa_init_pcmcia(void*, int, int*, int);
173
static struct symbol_table hisax_syms_elsa = {
174
#include <linux/symtab_begin.h>
175
        X(elsa_init_pcmcia),
176
#include <linux/symtab_end.h>
177
};
178
void register_elsa_symbols(void) {
179
        register_symtab(&hisax_syms_elsa);
180
}
181
#endif
182
#ifdef CONFIG_HISAX_AVM_A1
183
#undef DEFAULT_CARD
184
#undef DEFAULT_CFG
185
#define DEFAULT_CARD ISDN_CTYPE_A1
186
#define DEFAULT_CFG {10,0x340,0,0}
187
#endif
188
 
189
#ifdef CONFIG_HISAX_AVM_A1_PCMCIA
190
#undef DEFAULT_CARD
191
#undef DEFAULT_CFG
192
#define DEFAULT_CARD ISDN_CTYPE_A1_PCMCIA
193
#define DEFAULT_CFG {11,0x170,0,0}
194
int avm_a1_init_pcmcia(void*, int, int*, int);
195
void HiSax_closecard(int cardnr);
196
static struct symbol_table hisax_syms_avm_a1= {
197
#include <linux/symtab_begin.h>
198
        X(avm_a1_init_pcmcia),
199
        X(HiSax_closecard),
200
#include <linux/symtab_end.h>
201
};
202
void register_avm_a1_symbols(void) {
203
        register_symtab(&hisax_syms_avm_a1);
204
}
205
#endif
206
#ifdef CONFIG_HISAX_FRITZPCI
207
#undef DEFAULT_CARD
208
#undef DEFAULT_CFG
209
#define DEFAULT_CARD ISDN_CTYPE_FRITZPCI
210
#define DEFAULT_CFG {0,0,0,0}
211
#endif
212
#ifdef CONFIG_HISAX_16_3
213
#undef DEFAULT_CARD
214
#undef DEFAULT_CFG
215
#define DEFAULT_CARD ISDN_CTYPE_16_3
216
#define DEFAULT_CFG {15,0x180,0,0}
217
#endif
218
#ifdef CONFIG_HISAX_S0BOX
219
#undef DEFAULT_CARD
220
#undef DEFAULT_CFG
221
#define DEFAULT_CARD ISDN_CTYPE_S0BOX
222
#define DEFAULT_CFG {7,0x378,0,0}
223
#endif
224
#ifdef CONFIG_HISAX_16_0
225
#undef DEFAULT_CARD
226
#undef DEFAULT_CFG
227
#define DEFAULT_CARD ISDN_CTYPE_16_0
228
#define DEFAULT_CFG {15,0xd0000,0xd80,0}
229
#endif
230
 
231
#ifdef CONFIG_HISAX_TELESPCI
232
#undef DEFAULT_CARD
233
#undef DEFAULT_CFG
234
#define DEFAULT_CARD ISDN_CTYPE_TELESPCI
235
#define DEFAULT_CFG {0,0,0,0}
236
#endif
237
 
238
#ifdef CONFIG_HISAX_IX1MICROR2
239
#undef DEFAULT_CARD
240
#undef DEFAULT_CFG
241
#define DEFAULT_CARD ISDN_CTYPE_IX1MICROR2
242
#define DEFAULT_CFG {5,0x390,0,0}
243
#endif
244
 
245
#ifdef CONFIG_HISAX_DIEHLDIVA
246
#undef DEFAULT_CARD
247
#undef DEFAULT_CFG
248
#define DEFAULT_CARD ISDN_CTYPE_DIEHLDIVA
249
#define DEFAULT_CFG {0,0x0,0,0}
250
#endif
251
 
252
#ifdef CONFIG_HISAX_ASUSCOM
253
#undef DEFAULT_CARD
254
#undef DEFAULT_CFG
255
#define DEFAULT_CARD ISDN_CTYPE_ASUSCOM
256
#define DEFAULT_CFG {5,0x200,0,0}
257
#endif
258
 
259
#ifdef CONFIG_HISAX_TELEINT
260
#undef DEFAULT_CARD
261
#undef DEFAULT_CFG
262
#define DEFAULT_CARD ISDN_CTYPE_TELEINT
263
#define DEFAULT_CFG {5,0x300,0,0}
264
#endif
265
 
266
#ifdef CONFIG_HISAX_SEDLBAUER
267
#undef DEFAULT_CARD
268
#undef DEFAULT_CFG
269
#define DEFAULT_CARD ISDN_CTYPE_SEDLBAUER
270
#define DEFAULT_CFG {11,0x270,0,0}
271
int sedl_init_pcmcia(void*, int, int*, int);
272
static struct symbol_table hisax_syms_sedl= {
273
#include <linux/symtab_begin.h>
274
        X(sedl_init_pcmcia),
275
#include <linux/symtab_end.h>
276
};
277
#endif
278
 
279
#ifdef CONFIG_HISAX_SPORTSTER
280
#undef DEFAULT_CARD
281
#undef DEFAULT_CFG
282
#define DEFAULT_CARD ISDN_CTYPE_SPORTSTER
283
#define DEFAULT_CFG {7,0x268,0,0}
284
#endif
285
 
286
#ifdef CONFIG_HISAX_MIC
287
#undef DEFAULT_CARD
288
#undef DEFAULT_CFG
289
#define DEFAULT_CARD ISDN_CTYPE_MIC
290
#define DEFAULT_CFG {12,0x3e0,0,0}
291
#endif
292
 
293
#ifdef CONFIG_HISAX_NETJET
294
#undef DEFAULT_CARD
295
#undef DEFAULT_CFG
296
#define DEFAULT_CARD ISDN_CTYPE_NETJET
297
#define DEFAULT_CFG {0,0,0,0}
298
#endif
299
 
300
#ifdef CONFIG_HISAX_TELES3C
301
#undef DEFAULT_CARD
302
#undef DEFAULT_CFG
303
#define DEFAULT_CARD ISDN_CTYPE_TELES3C
304
#define DEFAULT_CFG {5,0x500,0,0}
305
#endif
306
 
307
#ifdef CONFIG_HISAX_AMD7930
308
#undef DEFAULT_CARD
309
#undef DEFAULT_CFG
310
#define DEFAULT_CARD ISDN_CTYPE_AMD7930
311
#define DEFAULT_CFG {12,0x3e0,0,0}
312
#endif
313
 
314
#ifdef CONFIG_HISAX_NICCY
315
#undef DEFAULT_CARD
316
#undef DEFAULT_CFG
317
#define DEFAULT_CARD ISDN_CTYPE_NICCY
318
#define DEFAULT_CFG {0,0x0,0,0}
319
#endif
320
 
321
#ifdef CONFIG_HISAX_1TR6
322
#define DEFAULT_PROTO ISDN_PTYPE_1TR6
323
#define DEFAULT_PROTO_NAME "1TR6"
324
#endif
325
#ifdef CONFIG_HISAX_EURO
326
#undef DEFAULT_PROTO
327
#define DEFAULT_PROTO ISDN_PTYPE_EURO
328
#undef DEFAULT_PROTO_NAME
329
#define DEFAULT_PROTO_NAME "EURO"
330
#endif
331
#ifdef CONFIG_HISAX_NI1
332
#undef DEFAULT_PROTO
333
#define DEFAULT_PROTO ISDN_PTYPE_NI1
334
#undef DEFAULT_PROTO_NAME
335
#define DEFAULT_PROTO_NAME "NI1"
336
#endif
337
#ifndef DEFAULT_PROTO
338
#define DEFAULT_PROTO ISDN_PTYPE_UNKNOWN
339
#define DEFAULT_PROTO_NAME "UNKNOWN"
340
#endif
341
#ifndef DEFAULT_CARD
342
#error "HiSax: No cards configured"
343
#endif
344
 
345
#define FIRST_CARD { \
346
        DEFAULT_CARD, \
347
        DEFAULT_PROTO, \
348
        DEFAULT_CFG, \
349
        NULL, \
350
}
351
 
352
#define EMPTY_CARD      {0, DEFAULT_PROTO, {0, 0, 0, 0}, NULL}
353
 
354
struct IsdnCard cards[] =
355
{
356
        FIRST_CARD,
357
        EMPTY_CARD,
358
        EMPTY_CARD,
359
        EMPTY_CARD,
360
        EMPTY_CARD,
361
        EMPTY_CARD,
362
        EMPTY_CARD,
363
        EMPTY_CARD,
364
};
365
 
366
static char HiSaxID[64] HISAX_INITDATA = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" \
367
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" \
368
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
369
char *HiSax_id HISAX_INITDATA = HiSaxID;
370
#ifdef MODULE
371
/* Variables for insmod */
372
static int type[] HISAX_INITDATA =
373
{0, 0, 0, 0, 0, 0, 0, 0};
374
static int protocol[] HISAX_INITDATA =
375
{0, 0, 0, 0, 0, 0, 0, 0};
376
static int io[] HISAX_INITDATA =
377
{0, 0, 0, 0, 0, 0, 0, 0};
378
#undef IO0_IO1
379
#ifdef CONFIG_HISAX_16_3
380
#define IO0_IO1
381
#endif
382
#ifdef CONFIG_HISAX_NICCY
383
#undef IO0_IO1
384
#define IO0_IO1
385
#endif
386
#ifdef IO0_IO1
387
static int io0[] HISAX_INITDATA =
388
{0, 0, 0, 0, 0, 0, 0, 0};
389
static int io1[] HISAX_INITDATA =
390
{0, 0, 0, 0, 0, 0, 0, 0};
391
#endif
392
static int irq[] HISAX_INITDATA =
393
{0, 0, 0, 0, 0, 0, 0, 0};
394
static int mem[] HISAX_INITDATA =
395
{0, 0, 0, 0, 0, 0, 0, 0};
396
static char *id HISAX_INITDATA = HiSaxID;
397
 
398
#if (LINUX_VERSION_CODE > 0x020111)
399
MODULE_AUTHOR("Karsten Keil");
400
MODULE_PARM(type, "1-8i");
401
MODULE_PARM(protocol, "1-8i");
402
MODULE_PARM(io, "1-8i");
403
MODULE_PARM(irq, "1-8i");
404
MODULE_PARM(mem, "1-8i");
405
MODULE_PARM(id, "s");
406
#ifdef CONFIG_HISAX_16_3        /* For Creatix/Teles PnP */
407
MODULE_PARM(io0, "1-8i");
408
MODULE_PARM(io1, "1-8i");
409
#endif /* CONFIG_HISAX_16_3 */
410
#endif /* (LINUX_VERSION_CODE > 0x020111) */
411
#endif /* MODULE */
412
 
413
int nrcards;
414
 
415
extern char *l1_revision;
416
extern char *l2_revision;
417
extern char *l3_revision;
418
extern char *lli_revision;
419
extern char *tei_revision;
420
 
421
HISAX_INITFUNC(char *
422
HiSax_getrev(const char *revision))
423
{
424
        char *rev;
425
        char *p;
426
 
427
        if ((p = strchr(revision, ':'))) {
428
                rev = p + 2;
429
                p = strchr(rev, '$');
430
                *--p = 0;
431
        } else
432
                rev = "???";
433
        return rev;
434
}
435
 
436
HISAX_INITFUNC(void
437
HiSaxVersion(void))
438
{
439
        char tmp[64];
440
 
441
        printk(KERN_INFO "HiSax: Linux Driver for passive ISDN cards\n");
442
#ifdef MODULE
443
        printk(KERN_INFO "HiSax: Version 3.1 (module)\n");
444
#else
445
        printk(KERN_INFO "HiSax: Version 3.1 (kernel)\n");
446
#endif
447
        strcpy(tmp, l1_revision);
448
        printk(KERN_INFO "HiSax: Layer1 Revision %s\n", HiSax_getrev(tmp));
449
        strcpy(tmp, l2_revision);
450
        printk(KERN_INFO "HiSax: Layer2 Revision %s\n", HiSax_getrev(tmp));
451
        strcpy(tmp, tei_revision);
452
        printk(KERN_INFO "HiSax: TeiMgr Revision %s\n", HiSax_getrev(tmp));
453
        strcpy(tmp, l3_revision);
454
        printk(KERN_INFO "HiSax: Layer3 Revision %s\n", HiSax_getrev(tmp));
455
        strcpy(tmp, lli_revision);
456
        printk(KERN_INFO "HiSax: LinkLayer Revision %s\n", HiSax_getrev(tmp));
457
        certification_check(1);
458
}
459
 
460
void
461
HiSax_mod_dec_use_count(void)
462
{
463
        MOD_DEC_USE_COUNT;
464
}
465
 
466
void
467
HiSax_mod_inc_use_count(void)
468
{
469
        MOD_INC_USE_COUNT;
470
}
471
 
472
#ifdef MODULE
473
#define HiSax_init init_module
474
#else
475
__initfunc(void
476
HiSax_setup(char *str, int *ints))
477
{
478
        int i, j, argc;
479
 
480
        argc = ints[0];
481
        i = 0;
482
        j = 1;
483
        while (argc && (i < HISAX_MAX_CARDS)) {
484
                if (argc) {
485
                        cards[i].typ = ints[j];
486
                        j++;
487
                        argc--;
488
                }
489
                if (argc) {
490
                        cards[i].protocol = ints[j];
491
                        j++;
492
                        argc--;
493
                }
494
                if (argc) {
495
                        cards[i].para[0] = ints[j];
496
                        j++;
497
                        argc--;
498
                }
499
                if (argc) {
500
                        cards[i].para[1] = ints[j];
501
                        j++;
502
                        argc--;
503
                }
504
                if (argc) {
505
                        cards[i].para[2] = ints[j];
506
                        j++;
507
                        argc--;
508
                }
509
                i++;
510
        }
511
        if (strlen(str)) {
512
                strcpy(HiSaxID, str);
513
                HiSax_id = HiSaxID;
514
        } else {
515
                strcpy(HiSaxID, "HiSax");
516
                HiSax_id = HiSaxID;
517
        }
518
}
519
#endif
520
 
521
#if CARD_TELES0
522
extern int setup_teles0(struct IsdnCard *card);
523
#endif
524
 
525
#if CARD_TELES3
526
extern int setup_teles3(struct IsdnCard *card);
527
#endif
528
 
529
#if CARD_S0BOX
530
extern int setup_s0box(struct IsdnCard *card);
531
#endif
532
 
533
#if CARD_TELESPCI
534
extern int setup_telespci(struct IsdnCard *card);
535
#endif
536
 
537
#if CARD_AVM_A1
538
extern int setup_avm_a1(struct IsdnCard *card);
539
#endif
540
 
541
#if CARD_AVM_A1_PCMCIA
542
extern int setup_avm_a1_pcmcia(struct IsdnCard *card);
543
#endif
544
 
545
#if CARD_FRITZPCI
546
extern int setup_avm_pcipnp(struct IsdnCard *card);
547
#endif
548
 
549
#if CARD_ELSA
550
extern int setup_elsa(struct IsdnCard *card);
551
#endif
552
 
553
#if CARD_IX1MICROR2
554
extern int setup_ix1micro(struct IsdnCard *card);
555
#endif
556
 
557
#if CARD_DIEHLDIVA
558
extern  int  setup_diva(struct IsdnCard *card);
559
#endif
560
 
561
#if CARD_ASUSCOM
562
extern int setup_asuscom(struct IsdnCard *card);
563
#endif
564
 
565
#if CARD_TELEINT
566
extern int setup_TeleInt(struct IsdnCard *card);
567
#endif
568
 
569
#if CARD_SEDLBAUER
570
extern int setup_sedlbauer(struct IsdnCard *card);
571
#endif
572
 
573
#if CARD_SPORTSTER
574
extern int setup_sportster(struct IsdnCard *card);
575
#endif
576
 
577
#if CARD_MIC
578
extern int setup_mic(struct IsdnCard *card);
579
#endif
580
 
581
#if CARD_NETJET
582
extern int setup_netjet(struct IsdnCard *card);
583
#endif
584
 
585
#if CARD_TELES3C
586
extern int setup_t163c(struct IsdnCard *card);
587
#endif
588
 
589
#if CARD_AMD7930
590
extern int setup_amd7930(struct IsdnCard *card);
591
#endif
592
 
593
#if CARD_NICCY
594
extern int setup_niccy(struct IsdnCard *card);
595
#endif
596
 
597
/*
598
 * Find card with given driverId
599
 */
600
static inline struct IsdnCardState
601
*hisax_findcard(int driverid)
602
{
603
        int i;
604
 
605
        for (i = 0; i < nrcards; i++)
606
                if (cards[i].cs)
607
                        if (cards[i].cs->myid == driverid)
608
                                return (cards[i].cs);
609
        return (NULL);
610
}
611
 
612
int
613
HiSax_readstatus(u_char * buf, int len, int user, int id, int channel)
614
{
615
        int count;
616
        u_char *p = buf;
617
        struct IsdnCardState *cs = hisax_findcard(id);
618
 
619
        if (cs) {
620
                if (len > HISAX_STATUS_BUFSIZE) {
621
                        printk(KERN_WARNING "HiSax: status overflow readstat %d/%d",
622
                                len, HISAX_STATUS_BUFSIZE);
623
                        return -ENODEV;
624
                }
625
                count = cs->status_end - cs->status_read +1;
626
                if (count >= len)
627
                        count = len;
628
                if (user)
629
                        copy_to_user(p, cs->status_read, count);
630
                else
631
                        memcpy(p, cs->status_read, count);
632
                cs->status_read += count;
633
                if (cs->status_read > cs->status_end)
634
                        cs->status_read = cs->status_buf;
635
                p += count;
636
                count = len - count;
637
                if (count) {
638
                        if (user)
639
                                copy_to_user(p, cs->status_read, count);
640
                        else
641
                                memcpy(p, cs->status_read, count);
642
                        cs->status_read += count;
643
                }
644
                return len;
645
        } else {
646
                printk(KERN_ERR
647
                 "HiSax: if_readstatus called with invalid driverId!\n");
648
                return -ENODEV;
649
        }
650
}
651
 
652
inline int
653
jiftime(char *s, long mark)
654
{
655
        s += 8;
656
 
657
        *s-- = '\0';
658
        *s-- = mark % 10 + '0';
659
        mark /= 10;
660
        *s-- = mark % 10 + '0';
661
        mark /= 10;
662
        *s-- = '.';
663
        *s-- = mark % 10 + '0';
664
        mark /= 10;
665
        *s-- = mark % 6 + '0';
666
        mark /= 6;
667
        *s-- = ':';
668
        *s-- = mark % 10 + '0';
669
        mark /= 10;
670
        *s-- = mark % 10 + '0';
671
        return(8);
672
}
673
 
674
static u_char tmpbuf[HISAX_STATUS_BUFSIZE];
675
 
676
void
677
VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, va_list args)
678
{
679
/* if head == NULL the fmt contains the full info */
680
 
681
        long flags;
682
        int count, i;
683
        u_char *p;
684
        isdn_ctrl ic;
685
        int len;
686
 
687
        save_flags(flags);
688
        cli();
689
        p = tmpbuf;
690
        if (head) {
691
                p += jiftime(p, jiffies);
692
                p += sprintf(p, " %s", head);
693
                p += vsprintf(p, fmt, args);
694
                *p++ = '\n';
695
                *p = 0;
696
                len = p - tmpbuf;
697
                p = tmpbuf;
698
        } else {
699
                p = fmt;
700
                len = strlen(fmt);
701
        }
702
        if (!cs) {
703
                printk(KERN_WARNING "HiSax: No CardStatus for message %s", p);
704
                restore_flags(flags);
705
                return;
706
        }
707
        if (len > HISAX_STATUS_BUFSIZE) {
708
                printk(KERN_WARNING "HiSax: status overflow %d/%d",
709
                        len, HISAX_STATUS_BUFSIZE);
710
                restore_flags(flags);
711
                return;
712
        }
713
        count = len;
714
        i = cs->status_end - cs->status_write +1;
715
        if (i >= len)
716
                i = len;
717
        len -= i;
718
        memcpy(cs->status_write, p, i);
719
        cs->status_write += i;
720
        if (cs->status_write > cs->status_end)
721
                cs->status_write = cs->status_buf;
722
        p += i;
723
        if (len) {
724
                memcpy(cs->status_write, p, len);
725
                cs->status_write += len;
726
        }
727
#ifdef KERNELSTACK_DEBUG
728
        i = (ulong)&len - current->kernel_stack_page;
729
        sprintf(tmpbuf, "kstack %s %lx use %ld\n", current->comm,
730
                current->kernel_stack_page, i);
731
        len = strlen(tmpbuf);
732
        for (p = tmpbuf, i = len; i > 0; i--, p++) {
733
                *cs->status_write++ = *p;
734
                if (cs->status_write > cs->status_end)
735
                        cs->status_write = cs->status_buf;
736
                count++;
737
        }
738
#endif
739
        restore_flags(flags);
740
        if (count) {
741
                ic.command = ISDN_STAT_STAVAIL;
742
                ic.driver = cs->myid;
743
                ic.arg = count;
744
                cs->iif.statcallb(&ic);
745
        }
746
}
747
 
748
void
749
HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...)
750
{
751
        va_list args;
752
 
753
        va_start(args, fmt);
754
        VHiSax_putstatus(cs, head, fmt, args);
755
        va_end(args);
756
}
757
 
758
int
759
ll_run(struct IsdnCardState *cs)
760
{
761
        long flags;
762
        isdn_ctrl ic;
763
 
764
        save_flags(flags);
765
        cli();
766
        ic.driver = cs->myid;
767
        ic.command = ISDN_STAT_RUN;
768
        cs->iif.statcallb(&ic);
769
        restore_flags(flags);
770
        return 0;
771
}
772
 
773
void
774
ll_stop(struct IsdnCardState *cs)
775
{
776
        isdn_ctrl ic;
777
 
778
        ic.command = ISDN_STAT_STOP;
779
        ic.driver = cs->myid;
780
        cs->iif.statcallb(&ic);
781
        CallcFreeChan(cs);
782
}
783
 
784
static void
785
ll_unload(struct IsdnCardState *cs)
786
{
787
        isdn_ctrl ic;
788
 
789
        ic.command = ISDN_STAT_UNLOAD;
790
        ic.driver = cs->myid;
791
        cs->iif.statcallb(&ic);
792
        if (cs->status_buf)
793
                kfree(cs->status_buf);
794
        cs->status_read = NULL;
795
        cs->status_write = NULL;
796
        cs->status_end = NULL;
797
        kfree(cs->dlog);
798
}
799
 
800
static void
801
closecard(int cardnr)
802
{
803
        struct IsdnCardState *csta = cards[cardnr].cs;
804
 
805
        if (csta->bcs->BC_Close != NULL) {
806
                csta->bcs->BC_Close(csta->bcs + 1);
807
                csta->bcs->BC_Close(csta->bcs);
808
        }
809
 
810
        if (csta->rcvbuf) {
811
                kfree(csta->rcvbuf);
812
                csta->rcvbuf = NULL;
813
        }
814
        discard_queue(&csta->rq);
815
        discard_queue(&csta->sq);
816
        if (csta->tx_skb) {
817
                dev_kfree_skb(csta->tx_skb, FREE_WRITE);
818
                csta->tx_skb = NULL;
819
        }
820
        if (csta->mon_rx) {
821
                kfree(csta->mon_rx);
822
                csta->mon_rx = NULL;
823
        }
824
        if (csta->mon_tx) {
825
                kfree(csta->mon_tx);
826
                csta->mon_tx = NULL;
827
        }
828
        csta->cardmsg(csta, CARD_RELEASE, NULL);
829
        if (csta->dbusytimer.function != NULL)
830
                del_timer(&csta->dbusytimer);
831
        ll_unload(csta);
832
}
833
 
834
HISAX_INITFUNC(static int init_card(struct IsdnCardState *cs))
835
{
836
        int irq_cnt, cnt = 3;
837
        long flags;
838
 
839
        save_flags(flags);
840
        cli();
841
        irq_cnt = kstat_irqs(cs->irq);
842
        printk(KERN_INFO "%s: IRQ %d count %d\n", CardType[cs->typ], cs->irq,
843
                irq_cnt);
844
        if (cs->cardmsg(cs, CARD_SETIRQ, NULL)) {
845
                printk(KERN_WARNING "HiSax: couldn't get interrupt %d\n",
846
                        cs->irq);
847
                restore_flags(flags);
848
                return(1);
849
        }
850
        while (cnt) {
851
                cs->cardmsg(cs, CARD_INIT, NULL);
852
                sti();
853
                current->state = TASK_INTERRUPTIBLE;
854
                /* Timeout 10ms */
855
                current->timeout = jiffies + (10 * HZ) / 1000;
856
                schedule();
857
                restore_flags(flags);
858
                printk(KERN_INFO "%s: IRQ %d count %d\n", CardType[cs->typ],
859
                        cs->irq, kstat_irqs(cs->irq));
860
                if (kstat_irqs(cs->irq) == irq_cnt) {
861
                        printk(KERN_WARNING
862
                               "%s: IRQ(%d) getting no interrupts during init %d\n",
863
                               CardType[cs->typ], cs->irq, 4 - cnt);
864
                        if (cnt == 1) {
865
                                free_irq(cs->irq, cs);
866
                                return (2);
867
                        } else {
868
                                cs->cardmsg(cs, CARD_RESET, NULL);
869
                                cnt--;
870
                        }
871
                } else {
872
                        cs->cardmsg(cs, CARD_TEST, NULL);
873
                        return(0);
874
                }
875
        }
876
        restore_flags(flags);
877
        return(3);
878
}
879
 
880
HISAX_INITFUNC(static int
881
checkcard(int cardnr, char *id, int *busy_flag))
882
{
883
        long flags;
884
        int ret = 0;
885
        struct IsdnCard *card = cards + cardnr;
886
        struct IsdnCardState *cs;
887
 
888
        save_flags(flags);
889
        cli();
890
        if (!(cs = (struct IsdnCardState *)
891
                kmalloc(sizeof(struct IsdnCardState), GFP_ATOMIC))) {
892
                printk(KERN_WARNING
893
                       "HiSax: No memory for IsdnCardState(card %d)\n",
894
                       cardnr + 1);
895
                restore_flags(flags);
896
                return (0);
897
        }
898
        memset(cs, 0, sizeof(struct IsdnCardState));
899
        card->cs = cs;
900
        cs->cardnr = cardnr;
901
        cs->debug = L1_DEB_WARN;
902
        cs->HW_Flags = 0;
903
        cs->busy_flag = busy_flag;
904
#if TEI_PER_CARD
905
#else
906
        test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);
907
#endif
908
        cs->protocol = card->protocol;
909
 
910
        if ((card->typ > 0) && (card->typ < 31)) {
911
                if (!((1 << card->typ) & SUPORTED_CARDS)) {
912
                        printk(KERN_WARNING
913
                             "HiSax: Support for %s Card not selected\n",
914
                               CardType[card->typ]);
915
                        restore_flags(flags);
916
                        return (0);
917
                }
918
        } else {
919
                printk(KERN_WARNING
920
                       "HiSax: Card Type %d out of range\n",
921
                       card->typ);
922
                restore_flags(flags);
923
                return (0);
924
        }
925
        if (!(cs->dlog = kmalloc(MAX_DLOG_SPACE, GFP_ATOMIC))) {
926
                printk(KERN_WARNING
927
                       "HiSax: No memory for dlog(card %d)\n",
928
                       cardnr + 1);
929
                restore_flags(flags);
930
                return (0);
931
        }
932
        if (!(cs->status_buf = kmalloc(HISAX_STATUS_BUFSIZE, GFP_ATOMIC))) {
933
                printk(KERN_WARNING
934
                       "HiSax: No memory for status_buf(card %d)\n",
935
                       cardnr + 1);
936
                kfree(cs->dlog);
937
                restore_flags(flags);
938
                return (0);
939
        }
940
        cs->stlist = NULL;
941
        cs->mon_tx = NULL;
942
        cs->mon_rx = NULL;
943
        cs->status_read = cs->status_buf;
944
        cs->status_write = cs->status_buf;
945
        cs->status_end = cs->status_buf + HISAX_STATUS_BUFSIZE - 1;
946
        cs->typ = card->typ;
947
        strcpy(cs->iif.id, id);
948
        cs->iif.channels = 2;
949
        cs->iif.maxbufsize = MAX_DATA_SIZE;
950
        cs->iif.hl_hdrlen = MAX_HEADER_LEN;
951
        cs->iif.features =
952
            ISDN_FEATURE_L2_X75I |
953
            ISDN_FEATURE_L2_HDLC |
954
//          ISDN_FEATURE_L2_MODEM |
955
            ISDN_FEATURE_L2_TRANS |
956
            ISDN_FEATURE_L3_TRANS |
957
#ifdef  CONFIG_HISAX_1TR6
958
            ISDN_FEATURE_P_1TR6 |
959
#endif
960
#ifdef  CONFIG_HISAX_EURO
961
            ISDN_FEATURE_P_EURO |
962
#endif
963
#ifdef        CONFIG_HISAX_NI1
964
            ISDN_FEATURE_P_NI1 |
965
#endif
966
            0;
967
 
968
        cs->iif.command = HiSax_command;
969
        cs->iif.writecmd = NULL;
970
        cs->iif.writebuf_skb = HiSax_writebuf_skb;
971
        cs->iif.readstat = HiSax_readstatus;
972
        register_isdn(&cs->iif);
973
        cs->myid = cs->iif.channels;
974
        printk(KERN_INFO
975
               "HiSax: Card %d Protocol %s Id=%s (%d)\n", cardnr + 1,
976
               (card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" :
977
               (card->protocol == ISDN_PTYPE_EURO) ? "EDSS1" :
978
               (card->protocol == ISDN_PTYPE_LEASED) ? "LEASED" :
979
               (card->protocol == ISDN_PTYPE_NI1) ? "NI1" :
980
               "NONE", cs->iif.id, cs->myid);
981
        switch (card->typ) {
982
#if CARD_TELES0
983
                case ISDN_CTYPE_16_0:
984
                case ISDN_CTYPE_8_0:
985
                        ret = setup_teles0(card);
986
                        break;
987
#endif
988
#if CARD_TELES3
989
                case ISDN_CTYPE_16_3:
990
                case ISDN_CTYPE_PNP:
991
                case ISDN_CTYPE_TELESPCMCIA:
992
                case ISDN_CTYPE_COMPAQ_ISA:
993
                        ret = setup_teles3(card);
994
                        break;
995
#endif
996
#if CARD_S0BOX
997
                case ISDN_CTYPE_S0BOX:
998
                        ret = setup_s0box(card);
999
                        break;
1000
#endif
1001
#if CARD_TELESPCI
1002
                case ISDN_CTYPE_TELESPCI:
1003
                        ret = setup_telespci(card);
1004
                        break;
1005
#endif
1006
#if CARD_AVM_A1
1007
                case ISDN_CTYPE_A1:
1008
                        ret = setup_avm_a1(card);
1009
                        break;
1010
#endif
1011
#if CARD_AVM_A1_PCMCIA
1012
                case ISDN_CTYPE_A1_PCMCIA:
1013
                        ret = setup_avm_a1_pcmcia(card);
1014
                        break;
1015
#endif
1016
#if CARD_FRITZPCI
1017
                case ISDN_CTYPE_FRITZPCI:
1018
                        ret = setup_avm_pcipnp(card);
1019
                        break;
1020
#endif
1021
#if CARD_ELSA
1022
                case ISDN_CTYPE_ELSA:
1023
                case ISDN_CTYPE_ELSA_PNP:
1024
                case ISDN_CTYPE_ELSA_PCMCIA:
1025
                case ISDN_CTYPE_ELSA_PCI:
1026
                        ret = setup_elsa(card);
1027
                        break;
1028
#endif
1029
#if CARD_IX1MICROR2
1030
                case ISDN_CTYPE_IX1MICROR2:
1031
                        ret = setup_ix1micro(card);
1032
                        break;
1033
#endif
1034
#if CARD_DIEHLDIVA
1035
                case ISDN_CTYPE_DIEHLDIVA:
1036
                        ret = setup_diva(card);
1037
                        break;
1038
#endif
1039
#if CARD_ASUSCOM
1040
                case ISDN_CTYPE_ASUSCOM:
1041
                        ret = setup_asuscom(card);
1042
                        break;
1043
#endif
1044
#if CARD_TELEINT
1045
                case ISDN_CTYPE_TELEINT:
1046
                        ret = setup_TeleInt(card);
1047
                        break;
1048
#endif
1049
#if CARD_SEDLBAUER
1050
                case ISDN_CTYPE_SEDLBAUER:
1051
                case ISDN_CTYPE_SEDLBAUER_PCMCIA:
1052
                case ISDN_CTYPE_SEDLBAUER_FAX:
1053
                        ret = setup_sedlbauer(card);
1054
                        break;
1055
#endif
1056
#if CARD_SPORTSTER
1057
                case ISDN_CTYPE_SPORTSTER:
1058
                        ret = setup_sportster(card);
1059
                        break;
1060
#endif
1061
#if CARD_MIC
1062
                case ISDN_CTYPE_MIC:
1063
                        ret = setup_mic(card);
1064
                        break;
1065
#endif
1066
#if CARD_NETJET
1067
                case ISDN_CTYPE_NETJET:
1068
                        ret = setup_netjet(card);
1069
                        break;
1070
#endif
1071
#if CARD_TELES3C
1072
                case ISDN_CTYPE_TELES3C:
1073
                        ret = setup_t163c(card);
1074
                        break;
1075
#endif
1076
#if CARD_NICCY
1077
                case ISDN_CTYPE_NICCY:
1078
                        ret = setup_niccy(card);
1079
                        break;
1080
#endif
1081
#if CARD_AMD7930
1082
                case ISDN_CTYPE_AMD7930:
1083
                        ret = setup_amd7930(card);
1084
                        break;
1085
#endif
1086
                default:
1087
                        printk(KERN_WARNING "HiSax: Unknown Card Typ %d\n",
1088
                               card->typ);
1089
                        ll_unload(cs);
1090
                        restore_flags(flags);
1091
                        return (0);
1092
        }
1093
        if (!ret) {
1094
                ll_unload(cs);
1095
                restore_flags(flags);
1096
                return (0);
1097
        }
1098
        if (!(cs->rcvbuf = kmalloc(MAX_DFRAME_LEN_L1, GFP_ATOMIC))) {
1099
                printk(KERN_WARNING
1100
                       "HiSax: No memory for isac rcvbuf\n");
1101
                return (1);
1102
        }
1103
        cs->rcvidx = 0;
1104
        cs->tx_skb = NULL;
1105
        cs->tx_cnt = 0;
1106
        cs->event = 0;
1107
        cs->tqueue.next = 0;
1108
        cs->tqueue.sync = 0;
1109
        cs->tqueue.data = cs;
1110
 
1111
        skb_queue_head_init(&cs->rq);
1112
        skb_queue_head_init(&cs->sq);
1113
 
1114
        init_bcstate(cs, 0);
1115
        init_bcstate(cs, 1);
1116
        ret = init_card(cs);
1117
        if (ret) {
1118
                closecard(cardnr);
1119
                restore_flags(flags);
1120
                return (0);
1121
        }
1122
        init_tei(cs, cs->protocol);
1123
        CallcNewChan(cs);
1124
        /* ISAR needs firmware download first */
1125
        if (!test_bit(HW_ISAR, &cs->HW_Flags))
1126
                ll_run(cs);
1127
        restore_flags(flags);
1128
        return (1);
1129
}
1130
 
1131
HISAX_INITFUNC(void
1132
HiSax_shiftcards(int idx))
1133
{
1134
        int i;
1135
 
1136
        for (i = idx; i < (HISAX_MAX_CARDS - 1); i++)
1137
                memcpy(&cards[i], &cards[i + 1], sizeof(cards[i]));
1138
}
1139
 
1140
HISAX_INITFUNC(int
1141
HiSax_inithardware(int *busy_flag))
1142
{
1143
        int foundcards = 0;
1144
        int i = 0;
1145
        int t = ',';
1146
        int flg = 0;
1147
        char *id;
1148
        char *next_id = HiSax_id;
1149
        char ids[20];
1150
 
1151
        if (strchr(HiSax_id, ','))
1152
                t = ',';
1153
        else if (strchr(HiSax_id, '%'))
1154
                t = '%';
1155
 
1156
        while (i < nrcards) {
1157
                if (cards[i].typ < 1)
1158
                        break;
1159
                id = next_id;
1160
                if ((next_id = strchr(id, t))) {
1161
                        *next_id++ = 0;
1162
                        strcpy(ids, id);
1163
                        flg = i + 1;
1164
                } else {
1165
                        next_id = id;
1166
                        if (flg >= i)
1167
                                strcpy(ids, id);
1168
                        else
1169
                                sprintf(ids, "%s%d", id, i);
1170
                }
1171
                if (checkcard(i, ids, busy_flag)) {
1172
                        foundcards++;
1173
                        i++;
1174
                } else {
1175
                        printk(KERN_WARNING "HiSax: Card %s not installed !\n",
1176
                               CardType[cards[i].typ]);
1177
                        if (cards[i].cs)
1178
                                kfree((void *) cards[i].cs);
1179
                        cards[i].cs = NULL;
1180
                        HiSax_shiftcards(i);
1181
                }
1182
        }
1183
        return foundcards;
1184
}
1185
 
1186
void
1187
HiSax_closecard(int cardnr)
1188
{
1189
        int     i,last=nrcards - 1;
1190
 
1191
        if (cardnr>last)
1192
                return;
1193
        if (cards[cardnr].cs) {
1194
                ll_stop(cards[cardnr].cs);
1195
                release_tei(cards[cardnr].cs);
1196
                closecard(cardnr);
1197
                free_irq(cards[cardnr].cs->irq, cards[cardnr].cs);
1198
                kfree((void *) cards[cardnr].cs);
1199
                cards[cardnr].cs = NULL;
1200
        }
1201
        i = cardnr;
1202
        while (i!=last) {
1203
                cards[i] = cards[i+1];
1204
                i++;
1205
        }
1206
        nrcards--;
1207
}
1208
 
1209
void
1210
HiSax_reportcard(int cardnr)
1211
{
1212
        struct IsdnCardState *cs = cards[cardnr].cs;
1213
        struct PStack *stptr;
1214
        struct l3_process *pc;
1215
        int j, i = 1;
1216
 
1217
        printk(KERN_DEBUG "HiSax: reportcard No %d\n", cardnr + 1);
1218
        printk(KERN_DEBUG "HiSax: Type %s\n", CardType[cs->typ]);
1219
        printk(KERN_DEBUG "HiSax: debuglevel %x\n", cs->debug);
1220
        printk(KERN_DEBUG "HiSax: HiSax_reportcard address 0x%lX\n",
1221
                (ulong) & HiSax_reportcard);
1222
        printk(KERN_DEBUG "HiSax: cs 0x%lX\n", (ulong) cs);
1223
        printk(KERN_DEBUG "HiSax: HW_Flags %x bc0 flg %x bc0 flg %x\n",
1224
                cs->HW_Flags, cs->bcs[0].Flag, cs->bcs[1].Flag);
1225
        printk(KERN_DEBUG "HiSax: bcs 0 mode %d ch%d\n",
1226
                cs->bcs[0].mode, cs->bcs[0].channel);
1227
        printk(KERN_DEBUG "HiSax: bcs 1 mode %d ch%d\n",
1228
                cs->bcs[1].mode, cs->bcs[1].channel);
1229
        printk(KERN_DEBUG "HiSax: cs stl 0x%lX\n", (ulong) & (cs->stlist));
1230
        stptr = cs->stlist;
1231
        while (stptr != NULL) {
1232
                printk(KERN_DEBUG "HiSax: dst%d 0x%lX\n", i, (ulong) stptr);
1233
                printk(KERN_DEBUG "HiSax: dst%d stp 0x%lX\n", i, (ulong) stptr->l1.stlistp);
1234
                printk(KERN_DEBUG "HiSax:   tei %d sapi %d\n",
1235
                       stptr->l2.tei, stptr->l2.sap);
1236
                printk(KERN_DEBUG "HiSax:      man 0x%lX\n", (ulong) stptr->ma.layer);
1237
                pc = stptr->l3.proc;
1238
                while (pc) {
1239
                        printk(KERN_DEBUG "HiSax: l3proc %x 0x%lX\n", pc->callref,
1240
                               (ulong) pc);
1241
                        printk(KERN_DEBUG "HiSax:    state %d  st 0x%lX chan 0x%lX\n",
1242
                            pc->state, (ulong) pc->st, (ulong) pc->chan);
1243
                        pc = pc->next;
1244
                }
1245
                stptr = stptr->next;
1246
                i++;
1247
        }
1248
        for (j = 0; j < 2; j++) {
1249
                printk(KERN_DEBUG "HiSax: ch%d 0x%lX\n", j,
1250
                       (ulong) & cs->channel[j]);
1251
                stptr = cs->channel[j].b_st;
1252
                i = 1;
1253
                while (stptr != NULL) {
1254
                        printk(KERN_DEBUG "HiSax:  b_st%d 0x%lX\n", i, (ulong) stptr);
1255
                        printk(KERN_DEBUG "HiSax:    man 0x%lX\n", (ulong) stptr->ma.layer);
1256
                        stptr = stptr->next;
1257
                        i++;
1258
                }
1259
        }
1260
}
1261
 
1262
 
1263
__initfunc(int
1264
HiSax_init(void))
1265
{
1266
        int i;
1267
 
1268
#ifdef MODULE
1269
        int nzproto = 0;
1270
#ifdef CONFIG_HISAX_ELSA
1271
        if (type[0] == ISDN_CTYPE_ELSA_PCMCIA) {
1272
                /* we have exported  and return in this case */
1273
                register_elsa_symbols();
1274
                return 0;
1275
        }
1276
#endif
1277
#ifdef CONFIG_HISAX_SEDLBAUER
1278
        if (type[0] == ISDN_CTYPE_SEDLBAUER_PCMCIA) {
1279
                /* we have to export  and return in this case */
1280
                register_symtab(&hisax_syms_sedl);
1281
                return 0;
1282
        }
1283
#endif
1284
#ifdef CONFIG_HISAX_AVM_A1_PCMCIA
1285
        if (type[0] == ISDN_CTYPE_A1_PCMCIA) {
1286
                /* we have to export  and return in this case */
1287
                register_avm_a1_symbols();
1288
                return 0;
1289
        }
1290
#endif
1291
#endif
1292
        nrcards = 0;
1293
        HiSaxVersion();
1294
#ifdef MODULE
1295
        if (id)                 /* If id= string used */
1296
                HiSax_id = id;
1297
        for (i = 0; i < HISAX_MAX_CARDS; i++) {
1298
                cards[i].typ = type[i];
1299
                if (protocol[i]) {
1300
                        cards[i].protocol = protocol[i];
1301
                        nzproto++;
1302
                }
1303
                switch (type[i]) {
1304
                        case ISDN_CTYPE_16_0:
1305
                                cards[i].para[0] = irq[i];
1306
                                cards[i].para[1] = mem[i];
1307
                                cards[i].para[2] = io[i];
1308
                                break;
1309
 
1310
                        case ISDN_CTYPE_8_0:
1311
                                cards[i].para[0] = irq[i];
1312
                                cards[i].para[1] = mem[i];
1313
                                break;
1314
 
1315
#ifdef IO0_IO1
1316
                        case ISDN_CTYPE_PNP:
1317
                        case ISDN_CTYPE_NICCY:
1318
                                cards[i].para[0] = irq[i];
1319
                                cards[i].para[1] = io0[i];
1320
                                cards[i].para[2] = io1[i];
1321
                                break;
1322
                        case ISDN_CTYPE_COMPAQ_ISA:
1323
                                cards[i].para[0] = irq[i];
1324
                                cards[i].para[1] = io0[i];
1325
                                cards[i].para[2] = io1[i];
1326
                                cards[i].para[3] = io[i];
1327
                                break;
1328
#endif
1329
                        case ISDN_CTYPE_ELSA:
1330
                                cards[i].para[0] = io[i];
1331
                                break;
1332
                        case ISDN_CTYPE_16_3:
1333
                        case ISDN_CTYPE_TELESPCMCIA:
1334
                        case ISDN_CTYPE_A1:
1335
                        case ISDN_CTYPE_A1_PCMCIA:
1336
                        case ISDN_CTYPE_ELSA_PNP:
1337
                        case ISDN_CTYPE_ELSA_PCMCIA:
1338
                        case ISDN_CTYPE_IX1MICROR2:
1339
                        case ISDN_CTYPE_DIEHLDIVA:
1340
                        case ISDN_CTYPE_ASUSCOM:
1341
                        case ISDN_CTYPE_TELEINT:
1342
                        case ISDN_CTYPE_SEDLBAUER:
1343
                        case ISDN_CTYPE_SEDLBAUER_PCMCIA:
1344
                        case ISDN_CTYPE_SEDLBAUER_FAX:
1345
                        case ISDN_CTYPE_SPORTSTER:
1346
                        case ISDN_CTYPE_MIC:
1347
                        case ISDN_CTYPE_TELES3C:
1348
                        case ISDN_CTYPE_S0BOX:
1349
                        case ISDN_CTYPE_FRITZPCI:
1350
                                cards[i].para[0] = irq[i];
1351
                                cards[i].para[1] = io[i];
1352
                                break;
1353
                        case ISDN_CTYPE_ELSA_PCI:
1354
                        case ISDN_CTYPE_NETJET:
1355
                        case ISDN_CTYPE_AMD7930:
1356
                        case ISDN_CTYPE_TELESPCI:
1357
                                break;
1358
                }
1359
        }
1360
        if (!nzproto) {
1361
                printk(KERN_WARNING "HiSax: Warning - no protocol specified\n");
1362
                printk(KERN_WARNING "HiSax: Note! module load syntax has changed.\n");
1363
                printk(KERN_WARNING "HiSax: using protocol %s\n", DEFAULT_PROTO_NAME);
1364
        }
1365
#endif
1366
        if (!HiSax_id)
1367
                HiSax_id = HiSaxID;
1368
        if (!HiSaxID[0])
1369
                strcpy(HiSaxID, "HiSax");
1370
        for (i = 0; i < HISAX_MAX_CARDS; i++)
1371
                if (cards[i].typ > 0)
1372
                        nrcards++;
1373
        printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
1374
               nrcards, (nrcards > 1) ? "s" : "");
1375
 
1376
        CallcNew();
1377
        Isdnl3New();
1378
        Isdnl2New();
1379
        TeiNew();
1380
        Isdnl1New();
1381
        if (HiSax_inithardware(NULL)) {
1382
                /* Install only, if at least one card found */
1383
                /* No symbols to export, hide all symbols */
1384
 
1385
#ifdef MODULE
1386
                register_symtab(NULL);
1387
                printk(KERN_INFO "HiSax: module installed\n");
1388
#endif
1389
                return (0);
1390
        } else {
1391
                Isdnl1Free();
1392
                TeiFree();
1393
                Isdnl2Free();
1394
                Isdnl3Free();
1395
                CallcFree();
1396
                return -EIO;
1397
        }
1398
}
1399
 
1400
#ifdef MODULE
1401
void
1402
cleanup_module(void)
1403
{
1404
        int cardnr = nrcards -1;
1405
        long flags;
1406
 
1407
        save_flags(flags);
1408
        cli();
1409
        while(cardnr>=0)
1410
                HiSax_closecard(cardnr--);
1411
        Isdnl1Free();
1412
        TeiFree();
1413
        Isdnl2Free();
1414
        Isdnl3Free();
1415
        CallcFree();
1416
        restore_flags(flags);
1417
        printk(KERN_INFO "HiSax module removed\n");
1418
}
1419
#endif
1420
 
1421
#ifdef CONFIG_HISAX_ELSA
1422
int elsa_init_pcmcia(void *pcm_iob, int pcm_irq, int *busy_flag, int prot)
1423
{
1424
#ifdef MODULE
1425
        int i;
1426
        int nzproto = 0;
1427
 
1428
        nrcards = 0;
1429
        HiSaxVersion();
1430
        if (id)                 /* If id= string used */
1431
                HiSax_id = id;
1432
        /* Initialize all 8 structs, even though we only accept
1433
           two pcmcia cards
1434
           */
1435
        for (i = 0; i < HISAX_MAX_CARDS; i++) {
1436
                cards[i].para[0] = irq[i];
1437
                cards[i].para[1] = io[i];
1438
                cards[i].typ = type[i];
1439
                if (protocol[i]) {
1440
                        cards[i].protocol = protocol[i];
1441
                        nzproto++;
1442
                }
1443
        }
1444
        cards[0].para[0] = pcm_irq;
1445
        cards[0].para[1] = (int)pcm_iob;
1446
        cards[0].protocol = prot;
1447
        cards[0].typ = 10;
1448
        nzproto = 1;
1449
 
1450
        if (!HiSax_id)
1451
                HiSax_id = HiSaxID;
1452
        if (!HiSaxID[0])
1453
                strcpy(HiSaxID, "HiSax");
1454
        for (i = 0; i < HISAX_MAX_CARDS; i++)
1455
                if (cards[i].typ > 0)
1456
                        nrcards++;
1457
        printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
1458
               nrcards, (nrcards > 1) ? "s" : "");
1459
 
1460
        Isdnl1New();
1461
        CallcNew();
1462
        Isdnl3New();
1463
        Isdnl2New();
1464
        TeiNew();
1465
        HiSax_inithardware(busy_flag);
1466
        printk(KERN_NOTICE "HiSax: module installed\n");
1467
#endif
1468
        return (0);
1469
}
1470
#endif
1471
 
1472
#ifdef CONFIG_HISAX_SEDLBAUER
1473
int sedl_init_pcmcia(void *pcm_iob, int pcm_irq, int *busy_flag, int prot)
1474
{
1475
#ifdef MODULE
1476
        int i;
1477
        int nzproto = 0;
1478
 
1479
        nrcards = 0;
1480
        HiSaxVersion();
1481
        if (id)                 /* If id= string used */
1482
                HiSax_id = id;
1483
        /* Initialize all 8 structs, even though we only accept
1484
           two pcmcia cards
1485
           */
1486
        for (i = 0; i < HISAX_MAX_CARDS; i++) {
1487
                cards[i].para[0] = irq[i];
1488
                cards[i].para[1] = io[i];
1489
                cards[i].typ = type[i];
1490
                if (protocol[i]) {
1491
                        cards[i].protocol = protocol[i];
1492
                        nzproto++;
1493
                }
1494
        }
1495
        cards[0].para[0] = pcm_irq;
1496
        cards[0].para[1] = (int)pcm_iob;
1497
        cards[0].protocol = prot;
1498
        cards[0].typ = ISDN_CTYPE_SEDLBAUER_PCMCIA;
1499
        nzproto = 1;
1500
 
1501
        if (!HiSax_id)
1502
                HiSax_id = HiSaxID;
1503
        if (!HiSaxID[0])
1504
                strcpy(HiSaxID, "HiSax");
1505
        for (i = 0; i < HISAX_MAX_CARDS; i++)
1506
                if (cards[i].typ > 0)
1507
                        nrcards++;
1508
        printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
1509
               nrcards, (nrcards > 1) ? "s" : "");
1510
 
1511
        CallcNew();
1512
        Isdnl3New();
1513
        Isdnl2New();
1514
        Isdnl1New();
1515
        TeiNew();
1516
        HiSax_inithardware(busy_flag);
1517
        printk(KERN_NOTICE "HiSax: module installed\n");
1518
#endif
1519
        return (0);
1520
}
1521
#endif
1522
 
1523
#ifdef CONFIG_HISAX_AVM_A1_PCMCIA
1524
int avm_a1_init_pcmcia(void *pcm_iob, int pcm_irq, int *busy_flag, int prot)
1525
{
1526
#ifdef MODULE
1527
        int i;
1528
        int nzproto = 0;
1529
 
1530
        nrcards = 0;
1531
        HiSaxVersion();
1532
        if (id)                 /* If id= string used */
1533
                HiSax_id = id;
1534
        /* Initialize all 16 structs, even though we only accept
1535
           two pcmcia cards
1536
           */
1537
        for (i = 0; i < 16; i++) {
1538
                cards[i].para[0] = irq[i];
1539
                cards[i].para[1] = io[i];
1540
                cards[i].typ = type[i];
1541
                if (protocol[i]) {
1542
                        cards[i].protocol = protocol[i];
1543
                        nzproto++;
1544
                }
1545
        }
1546
        cards[0].para[0] = pcm_irq;
1547
        cards[0].para[1] = (int)pcm_iob;
1548
        cards[0].protocol = prot;
1549
        cards[0].typ = ISDN_CTYPE_A1_PCMCIA;
1550
        nzproto = 1;
1551
 
1552
        if (!HiSax_id)
1553
                HiSax_id = HiSaxID;
1554
        if (!HiSaxID[0])
1555
                strcpy(HiSaxID, "HiSax");
1556
        for (i = 0; i < HISAX_MAX_CARDS; i++)
1557
                if (cards[i].typ > 0)
1558
                        nrcards++;
1559
        printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
1560
               nrcards, (nrcards > 1) ? "s" : "");
1561
 
1562
        Isdnl1New();
1563
        CallcNew();
1564
        Isdnl3New();
1565
        Isdnl2New();
1566
        TeiNew();
1567
        HiSax_inithardware(busy_flag);
1568
        printk(KERN_NOTICE "HiSax: module installed\n");
1569
#endif
1570
        return (0);
1571
}
1572
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.