Import 2.1.42pre1
[davej-history.git] / drivers / isdn / hisax / config.c
blob595fb713e56ad7662c0b4fba9ef0992c8c8aa99c
1 /* $Id: config.c,v 1.15 1997/04/06 22:57:24 keil Exp $
3 * Author Karsten Keil (keil@temic-ech.spacenet.de)
4 * based on the teles driver from Jan den Ouden
7 * $Log: config.c,v $
8 * Revision 1.15 1997/04/06 22:57:24 keil
9 * Hisax version 2.1
11 * Revision 1.14 1997/03/25 23:11:22 keil
12 * US NI-1 protocol
14 * Revision 1.13 1997/03/23 21:45:49 keil
15 * Add support for ELSA PCMCIA
17 * Revision 1.12 1997/03/11 21:01:43 keil
18 * nzproto is only used with modules
20 * Revision 1.11 1997/02/14 12:23:12 fritz
21 * Added support for new insmod parameter handling.
23 * Revision 1.10 1997/02/14 09:22:09 keil
24 * Final 2.0 version
26 * Revision 1.9 1997/02/10 11:45:09 fritz
27 * More changes for Kernel 2.1.X compatibility.
29 * Revision 1.8 1997/02/09 00:28:05 keil
30 * new interface handling, one interface per card
31 * default protocol now works again
33 * Revision 1.7 1997/01/27 15:56:57 keil
34 * Teles PCMCIA ITK ix1 micro added
36 * Revision 1.6 1997/01/21 22:17:56 keil
37 * new module load syntax
39 * Revision 1.5 1997/01/09 18:28:20 keil
40 * cosmetic cleanups
42 * Revision 1.4 1996/11/05 19:35:17 keil
43 * using config.h; some spelling fixes
45 * Revision 1.3 1996/10/23 17:23:28 keil
46 * default config changes
48 * Revision 1.2 1996/10/23 11:58:48 fritz
49 * Changed default setup to reflect user's selection of supported
50 * cards/protocols.
52 * Revision 1.1 1996/10/13 20:04:51 keil
53 * Initial revision
58 #include <linux/types.h>
59 #include <linux/stddef.h>
60 #include <linux/timer.h>
61 #include <linux/config.h>
62 #include "hisax.h"
65 * This structure array contains one entry per card. An entry looks
66 * like this:
68 * { type, protocol, p0, p1, p2, NULL }
70 * type
71 * 1 Teles 16.0 p0=irq p1=membase p2=iobase
72 * 2 Teles 8.0 p0=irq p1=membase
73 * 3 Teles 16.3 p0=irq p1=iobase
74 * 4 Creatix PNP p0=irq p1=IO0 (ISAC) p2=IO1 (HSCX)
75 * 5 AVM A1 (Fritz) p0=irq p1=iobase
76 * 6 ELSA PC [p0=iobase] or nothing (autodetect)
77 * 7 ELSA Quickstep p0=irq p1=iobase
78 * ELSA PCMCIA p0=irq p1=iobase
79 * 8 Teles PCMCIA p0=irq p1=iobase
80 * 9 ITK ix1-micro p0=irq p1=iobase
83 * protocol can be either ISDN_PTYPE_EURO or ISDN_PTYPE_1TR6 or ISDN_PTYPE_NI1
88 #ifdef CONFIG_HISAX_ELSA_PCC
89 #define DEFAULT_CARD ISDN_CTYPE_ELSA
90 #define DEFAULT_CFG {0,0,0}
91 #endif
92 #ifdef CONFIG_HISAX_ELSA_PCMCIA
93 #define DEFAULT_CARD ISDN_CTYPE_ELSA_QS1000
94 #define DEFAULT_CFG {3,0x2f8,0}
95 #endif
96 #ifdef CONFIG_HISAX_AVM_A1
97 #undef DEFAULT_CARD
98 #undef DEFAULT_CFG
99 #define DEFAULT_CARD ISDN_CTYPE_A1
100 #define DEFAULT_CFG {10,0x340,0}
101 #endif
102 #ifdef CONFIG_HISAX_16_3
103 #undef DEFAULT_CARD
104 #undef DEFAULT_CFG
105 #define DEFAULT_CARD ISDN_CTYPE_16_3
106 #define DEFAULT_CFG {15,0x180,0}
107 #endif
108 #ifdef CONFIG_HISAX_16_0
109 #undef DEFAULT_CARD
110 #undef DEFAULT_CFG
111 #define DEFAULT_CARD ISDN_CTYPE_16_0
112 #define DEFAULT_CFG {15,0xd0000,0xd80}
113 #endif
115 #ifdef CONFIG_HISAX_IX1MICROR2
116 #undef DEFAULT_CARD
117 #undef DEFAULT_CFG
118 #define DEFAULT_CARD ISDN_CTYPE_IX1MICROR2
119 #define DEFAULT_CFG {5,0x390,0}
120 #endif
122 #ifdef CONFIG_HISAX_1TR6
123 #define DEFAULT_PROTO ISDN_PTYPE_1TR6
124 #define DEFAULT_PROTO_NAME "1TR6"
125 #endif
126 #ifdef CONFIG_HISAX_EURO
127 #undef DEFAULT_PROTO
128 #define DEFAULT_PROTO ISDN_PTYPE_EURO
129 #undef DEFAULT_PROTO_NAME
130 #define DEFAULT_PROTO_NAME "EURO"
131 #endif
132 #ifdef CONFIG_HISAX_NI1
133 #undef DEFAULT_PROTO
134 #define DEFAULT_PROTO ISDN_PTYPE_NI1
135 #undef DEFAULT_PROTO_NAME
136 #define DEFAULT_PROTO_NAME "NI1"
137 #endif
138 #ifndef DEFAULT_PROTO
139 #define DEFAULT_PROTO ISDN_PTYPE_UNKNOWN
140 #define DEFAULT_PROTO_NAME "UNKNOWN"
141 #endif
142 #ifndef DEFAULT_CARD
143 #error "HiSax: No cards configured"
144 #endif
146 #define FIRST_CARD { \
147 DEFAULT_CARD, \
148 DEFAULT_PROTO, \
149 DEFAULT_CFG, \
150 NULL, \
153 #define EMPTY_CARD {0, DEFAULT_PROTO, {0, 0, 0}, NULL}
155 struct IsdnCard cards[] =
157 FIRST_CARD,
158 EMPTY_CARD,
159 EMPTY_CARD,
160 EMPTY_CARD,
161 EMPTY_CARD,
162 EMPTY_CARD,
163 EMPTY_CARD,
164 EMPTY_CARD,
165 EMPTY_CARD,
166 EMPTY_CARD,
167 EMPTY_CARD,
168 EMPTY_CARD,
169 EMPTY_CARD,
170 EMPTY_CARD,
171 EMPTY_CARD,
172 EMPTY_CARD,
175 static char HiSaxID[96] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" \
176 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" \
177 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" \
178 "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
179 char *HiSax_id = HiSaxID;
180 #ifdef MODULE
181 /* Variables for insmod */
182 int type[] =
183 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
184 int protocol[] =
185 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
186 int io[] =
187 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
188 #ifdef CONFIG_HISAX_16_3 /* For Creatix/Teles PnP */
189 int io0[] =
190 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
191 int io1[] =
192 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
193 #endif
194 int irq[] =
195 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
196 int mem[] =
197 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
198 char *id = HiSaxID;
200 #if (LINUX_VERSION_CODE > 0x020111)
201 MODULE_AUTHOR("Karsten Keil");
202 MODULE_PARM(type, "1-16i");
203 MODULE_PARM(protocol, "1-16i");
204 MODULE_PARM(io, "1-16i");
205 MODULE_PARM(irq, "1-16i");
206 MODULE_PARM(mem, "1-16i");
207 MODULE_PARM(id, "s");
208 #ifdef CONFIG_HISAX_16_3 /* For Creatix/Teles PnP */
209 MODULE_PARM(io0, "1-16i");
210 MODULE_PARM(io1, "1-16i");
211 #endif
212 #endif
214 #endif
216 extern char *l1_revision;
217 extern char *l2_revision;
218 extern char *l3_revision;
219 extern char *l4_revision;
220 extern char *tei_revision;
222 char *
223 HiSax_getrev(const char *revision)
225 char *rev;
226 char *p;
228 if ((p = strchr(revision, ':'))) {
229 rev = p + 2;
230 p = strchr(rev, '$');
231 *--p = 0;
232 } else
233 rev = "???";
234 return rev;
237 int nrcards;
239 void
240 HiSax_mod_dec_use_count(void)
242 MOD_DEC_USE_COUNT;
245 void
246 HiSax_mod_inc_use_count(void)
248 MOD_INC_USE_COUNT;
251 #ifdef MODULE
252 #define HiSax_init init_module
253 #else
254 void
255 HiSax_setup(char *str, int *ints)
257 int i, j, argc;
259 argc = ints[0];
260 i = 0;
261 j = 1;
262 while (argc && (i < 16)) {
263 if (argc) {
264 cards[i].typ = ints[j];
265 j++;
266 argc--;
268 if (argc) {
269 cards[i].protocol = ints[j];
270 j++;
271 argc--;
273 if (argc) {
274 cards[i].para[0] = ints[j];
275 j++;
276 argc--;
278 if (argc) {
279 cards[i].para[1] = ints[j];
280 j++;
281 argc--;
283 if (argc) {
284 cards[i].para[2] = ints[j];
285 j++;
286 argc--;
288 i++;
290 if (strlen(str)) {
291 strcpy(HiSaxID, str);
292 HiSax_id = HiSaxID;
293 } else {
294 strcpy(HiSaxID, "HiSax");
295 HiSax_id = HiSaxID;
298 #endif
301 HiSax_init(void)
303 int i;
304 char tmp[64], rev[64];
305 char *r = rev;
306 #ifdef MODULE
307 int nzproto = 0;
308 #endif
309 nrcards = 0;
310 strcpy(tmp, l1_revision);
311 r += sprintf(r, "%s/", HiSax_getrev(tmp));
312 strcpy(tmp, l2_revision);
313 r += sprintf(r, "%s/", HiSax_getrev(tmp));
314 strcpy(tmp, l3_revision);
315 r += sprintf(r, "%s/", HiSax_getrev(tmp));
316 strcpy(tmp, l4_revision);
317 r += sprintf(r, "%s/", HiSax_getrev(tmp));
318 strcpy(tmp, tei_revision);
319 r += sprintf(r, "%s", HiSax_getrev(tmp));
321 printk(KERN_NOTICE "HiSax: Driver for Siemens chip set ISDN cards\n");
322 printk(KERN_NOTICE "HiSax: Version 2.1\n");
323 printk(KERN_NOTICE "HiSax: Revisions %s\n", rev);
325 #ifdef MODULE
326 if (id) /* If id= string used */
327 HiSax_id = id;
328 for (i = 0; i < 16; i++) {
329 cards[i].typ = type[i];
330 if (protocol[i]) {
331 cards[i].protocol = protocol[i];
332 nzproto++;
334 switch (type[i]) {
335 case ISDN_CTYPE_16_0:
336 cards[i].para[0] = irq[i];
337 cards[i].para[1] = mem[i];
338 cards[i].para[2] = io[i];
339 break;
341 case ISDN_CTYPE_8_0:
342 cards[i].para[0] = irq[i];
343 cards[i].para[1] = mem[i];
344 break;
346 case ISDN_CTYPE_16_3:
347 case ISDN_CTYPE_TELESPCMCIA:
348 cards[i].para[0] = irq[i];
349 cards[i].para[1] = io[i];
350 break;
352 #ifdef CONFIG_HISAX_16_3 /* For Creatix/Teles PnP */
353 case ISDN_CTYPE_PNP:
354 cards[i].para[0] = irq[i];
355 cards[i].para[1] = io0[i];
356 cards[i].para[2] = io1[i];
357 break;
358 #endif
359 case ISDN_CTYPE_A1:
360 cards[i].para[0] = irq[i];
361 cards[i].para[1] = io[i];
362 break;
364 case ISDN_CTYPE_ELSA:
365 cards[i].para[0] = io[i];
366 break;
367 case ISDN_CTYPE_ELSA_QS1000:
368 cards[i].para[0] = irq[i];
369 cards[i].para[1] = io[i];
370 break;
372 case ISDN_CTYPE_IX1MICROR2:
373 cards[i].para[0] = irq[i];
374 cards[i].para[1] = io[i];
375 break;
379 if (!nzproto) {
380 printk(KERN_WARNING "HiSax: Warning - no protocol specified\n");
381 printk(KERN_WARNING "HiSax: Note! module load syntax has changed.\n");
382 printk(KERN_WARNING "HiSax: using protocol %s\n", DEFAULT_PROTO_NAME);
384 #endif
385 if (!HiSax_id)
386 HiSax_id = HiSaxID;
387 if (!HiSaxID[0])
388 strcpy(HiSaxID, "HiSax");
389 for (i = 0; i < 16; i++)
390 if (cards[i].typ > 0)
391 nrcards++;
392 printk(KERN_DEBUG "HiSax: Total %d card%s defined\n",
393 nrcards, (nrcards > 1) ? "s" : "");
395 CallcNew();
396 Isdnl2New();
397 if (HiSax_inithardware()) {
398 /* Install only, if at least one card found */
399 /* No symbols to export, hide all symbols */
401 #ifdef MODULE
402 #if (LINUX_VERSION_CODE < 0x020111)
403 register_symtab(NULL);
404 #else
405 EXPORT_NO_SYMBOLS;
406 #endif
407 printk(KERN_NOTICE "HiSax: module installed\n");
408 #endif
409 return (0);
410 } else {
411 Isdnl2Free();
412 CallcFree();
413 return -EIO;
417 #ifdef MODULE
418 void
419 cleanup_module(void)
421 HiSax_closehardware();
422 printk(KERN_NOTICE "HiSax module removed\n");
425 #endif