aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/hisax/elsa.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/isdn/hisax/elsa.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/isdn/hisax/elsa.c')
-rw-r--r--drivers/isdn/hisax/elsa.c1190
1 files changed, 1190 insertions, 0 deletions
diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
new file mode 100644
index 000000000000..4d7a0250d7e2
--- /dev/null
+++ b/drivers/isdn/hisax/elsa.c
@@ -0,0 +1,1190 @@
1/* $Id: elsa.c,v 2.32.2.4 2004/01/24 20:47:21 keil Exp $
2 *
3 * low level stuff for Elsa isdn cards
4 *
5 * Author Karsten Keil
6 * Copyright by Karsten Keil <keil@isdn4linux.de>
7 *
8 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference.
10 *
11 * For changes and modifications please read
12 * Documentation/isdn/HiSax.cert
13 *
14 * Thanks to Elsa GmbH for documents and information
15 *
16 * Klaus Lichtenwalder (Klaus.Lichtenwalder@WebForum.DE)
17 * for ELSA PCMCIA support
18 *
19 */
20
21#include <linux/init.h>
22#include <linux/config.h>
23#include "hisax.h"
24#include "arcofi.h"
25#include "isac.h"
26#include "ipac.h"
27#include "hscx.h"
28#include "isdnl1.h"
29#include <linux/pci.h>
30#include <linux/isapnp.h>
31#include <linux/serial.h>
32#include <linux/serial_reg.h>
33
34extern const char *CardType[];
35
36const char *Elsa_revision = "$Revision: 2.32.2.4 $";
37const char *Elsa_Types[] =
38{"None", "PC", "PCC-8", "PCC-16", "PCF", "PCF-Pro",
39 "PCMCIA", "QS 1000", "QS 3000", "Microlink PCI", "QS 3000 PCI",
40 "PCMCIA-IPAC" };
41
42const char *ITACVer[] =
43{"?0?", "?1?", "?2?", "?3?", "?4?", "V2.2",
44 "B1", "A1"};
45
46#define byteout(addr,val) outb(val,addr)
47#define bytein(addr) inb(addr)
48
49#define ELSA_ISAC 0
50#define ELSA_ISAC_PCM 1
51#define ELSA_ITAC 1
52#define ELSA_HSCX 2
53#define ELSA_ALE 3
54#define ELSA_ALE_PCM 4
55#define ELSA_CONTROL 4
56#define ELSA_CONFIG 5
57#define ELSA_START_TIMER 6
58#define ELSA_TRIG_IRQ 7
59
60#define ELSA_PC 1
61#define ELSA_PCC8 2
62#define ELSA_PCC16 3
63#define ELSA_PCF 4
64#define ELSA_PCFPRO 5
65#define ELSA_PCMCIA 6
66#define ELSA_QS1000 7
67#define ELSA_QS3000 8
68#define ELSA_QS1000PCI 9
69#define ELSA_QS3000PCI 10
70#define ELSA_PCMCIA_IPAC 11
71
72/* PCI stuff */
73#define ELSA_PCI_IRQ_MASK 0x04
74
75/* ITAC Registeradressen (only Microlink PC) */
76#define ITAC_SYS 0x34
77#define ITAC_ISEN 0x48
78#define ITAC_RFIE 0x4A
79#define ITAC_XFIE 0x4C
80#define ITAC_SCIE 0x4E
81#define ITAC_STIE 0x46
82
83/*** ***
84 *** Makros als Befehle fuer die Kartenregister ***
85 *** (mehrere Befehle werden durch Bit-Oderung kombiniert) ***
86 *** ***/
87
88/* Config-Register (Read) */
89#define ELSA_TIMER_RUN 0x02 /* Bit 1 des Config-Reg */
90#define ELSA_TIMER_RUN_PCC8 0x01 /* Bit 0 des Config-Reg bei PCC */
91#define ELSA_IRQ_IDX 0x38 /* Bit 3,4,5 des Config-Reg */
92#define ELSA_IRQ_IDX_PCC8 0x30 /* Bit 4,5 des Config-Reg */
93#define ELSA_IRQ_IDX_PC 0x0c /* Bit 2,3 des Config-Reg */
94
95/* Control-Register (Write) */
96#define ELSA_LINE_LED 0x02 /* Bit 1 Gelbe LED */
97#define ELSA_STAT_LED 0x08 /* Bit 3 Gruene LED */
98#define ELSA_ISDN_RESET 0x20 /* Bit 5 Reset-Leitung */
99#define ELSA_ENA_TIMER_INT 0x80 /* Bit 7 Freigabe Timer Interrupt */
100
101/* ALE-Register (Read) */
102#define ELSA_HW_RELEASE 0x07 /* Bit 0-2 Hardwarerkennung */
103#define ELSA_S0_POWER_BAD 0x08 /* Bit 3 S0-Bus Spannung fehlt */
104
105/* Status Flags */
106#define ELSA_TIMER_AKTIV 1
107#define ELSA_BAD_PWR 2
108#define ELSA_ASSIGN 4
109
110#define RS_ISR_PASS_LIMIT 256
111#define _INLINE_ inline
112#define FLG_MODEM_ACTIVE 1
113/* IPAC AUX */
114#define ELSA_IPAC_LINE_LED 0x40 /* Bit 6 Gelbe LED */
115#define ELSA_IPAC_STAT_LED 0x80 /* Bit 7 Gruene LED */
116
117#if ARCOFI_USE
118static struct arcofi_msg ARCOFI_XOP_F =
119 {NULL,0,2,{0xa1,0x3f,0,0,0,0,0,0,0,0}}; /* Normal OP */
120static struct arcofi_msg ARCOFI_XOP_1 =
121 {&ARCOFI_XOP_F,0,2,{0xa1,0x31,0,0,0,0,0,0,0,0}}; /* PWR UP */
122static struct arcofi_msg ARCOFI_SOP_F =
123 {&ARCOFI_XOP_1,0,10,{0xa1,0x1f,0x00,0x50,0x10,0x00,0x00,0x80,0x02,0x12}};
124static struct arcofi_msg ARCOFI_COP_9 =
125 {&ARCOFI_SOP_F,0,10,{0xa1,0x29,0x80,0xcb,0xe9,0x88,0x00,0xc8,0xd8,0x80}}; /* RX */
126static struct arcofi_msg ARCOFI_COP_8 =
127 {&ARCOFI_COP_9,0,10,{0xa1,0x28,0x49,0x31,0x8,0x13,0x6e,0x88,0x2a,0x61}}; /* TX */
128static struct arcofi_msg ARCOFI_COP_7 =
129 {&ARCOFI_COP_8,0,4,{0xa1,0x27,0x80,0x80,0,0,0,0,0,0}}; /* GZ */
130static struct arcofi_msg ARCOFI_COP_6 =
131 {&ARCOFI_COP_7,0,6,{0xa1,0x26,0,0,0x82,0x7c,0,0,0,0}}; /* GRL GRH */
132static struct arcofi_msg ARCOFI_COP_5 =
133 {&ARCOFI_COP_6,0,4,{0xa1,0x25,0xbb,0x4a,0,0,0,0,0,0}}; /* GTX */
134static struct arcofi_msg ARCOFI_VERSION =
135 {NULL,1,2,{0xa0,0,0,0,0,0,0,0,0,0}};
136static struct arcofi_msg ARCOFI_XOP_0 =
137 {NULL,0,2,{0xa1,0x30,0,0,0,0,0,0,0,0}}; /* PWR Down */
138
139static void set_arcofi(struct IsdnCardState *cs, int bc);
140
141#include "elsa_ser.c"
142#endif /* ARCOFI_USE */
143
144static inline u_char
145readreg(unsigned int ale, unsigned int adr, u_char off)
146{
147 register u_char ret;
148
149 byteout(ale, off);
150 ret = bytein(adr);
151 return (ret);
152}
153
154static inline void
155readfifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
156{
157 byteout(ale, off);
158 insb(adr, data, size);
159}
160
161
162static inline void
163writereg(unsigned int ale, unsigned int adr, u_char off, u_char data)
164{
165 byteout(ale, off);
166 byteout(adr, data);
167}
168
169static inline void
170writefifo(unsigned int ale, unsigned int adr, u_char off, u_char * data, int size)
171{
172 byteout(ale, off);
173 outsb(adr, data, size);
174}
175
176/* Interface functions */
177
178static u_char
179ReadISAC(struct IsdnCardState *cs, u_char offset)
180{
181 return (readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, offset));
182}
183
184static void
185WriteISAC(struct IsdnCardState *cs, u_char offset, u_char value)
186{
187 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, offset, value);
188}
189
190static void
191ReadISACfifo(struct IsdnCardState *cs, u_char * data, int size)
192{
193 readfifo(cs->hw.elsa.ale, cs->hw.elsa.isac, 0, data, size);
194}
195
196static void
197WriteISACfifo(struct IsdnCardState *cs, u_char * data, int size)
198{
199 writefifo(cs->hw.elsa.ale, cs->hw.elsa.isac, 0, data, size);
200}
201
202static u_char
203ReadISAC_IPAC(struct IsdnCardState *cs, u_char offset)
204{
205 return (readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, offset+0x80));
206}
207
208static void
209WriteISAC_IPAC(struct IsdnCardState *cs, u_char offset, u_char value)
210{
211 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, offset|0x80, value);
212}
213
214static void
215ReadISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size)
216{
217 readfifo(cs->hw.elsa.ale, cs->hw.elsa.isac, 0x80, data, size);
218}
219
220static void
221WriteISACfifo_IPAC(struct IsdnCardState *cs, u_char * data, int size)
222{
223 writefifo(cs->hw.elsa.ale, cs->hw.elsa.isac, 0x80, data, size);
224}
225
226static u_char
227ReadHSCX(struct IsdnCardState *cs, int hscx, u_char offset)
228{
229 return (readreg(cs->hw.elsa.ale,
230 cs->hw.elsa.hscx, offset + (hscx ? 0x40 : 0)));
231}
232
233static void
234WriteHSCX(struct IsdnCardState *cs, int hscx, u_char offset, u_char value)
235{
236 writereg(cs->hw.elsa.ale,
237 cs->hw.elsa.hscx, offset + (hscx ? 0x40 : 0), value);
238}
239
240static inline u_char
241readitac(struct IsdnCardState *cs, u_char off)
242{
243 register u_char ret;
244
245 byteout(cs->hw.elsa.ale, off);
246 ret = bytein(cs->hw.elsa.itac);
247 return (ret);
248}
249
250static inline void
251writeitac(struct IsdnCardState *cs, u_char off, u_char data)
252{
253 byteout(cs->hw.elsa.ale, off);
254 byteout(cs->hw.elsa.itac, data);
255}
256
257static inline int
258TimerRun(struct IsdnCardState *cs)
259{
260 register u_char v;
261
262 v = bytein(cs->hw.elsa.cfg);
263 if ((cs->subtyp == ELSA_QS1000) || (cs->subtyp == ELSA_QS3000))
264 return (0 == (v & ELSA_TIMER_RUN));
265 else if (cs->subtyp == ELSA_PCC8)
266 return (v & ELSA_TIMER_RUN_PCC8);
267 return (v & ELSA_TIMER_RUN);
268}
269/*
270 * fast interrupt HSCX stuff goes here
271 */
272
273#define READHSCX(cs, nr, reg) readreg(cs->hw.elsa.ale, \
274 cs->hw.elsa.hscx, reg + (nr ? 0x40 : 0))
275#define WRITEHSCX(cs, nr, reg, data) writereg(cs->hw.elsa.ale, \
276 cs->hw.elsa.hscx, reg + (nr ? 0x40 : 0), data)
277
278#define READHSCXFIFO(cs, nr, ptr, cnt) readfifo(cs->hw.elsa.ale, \
279 cs->hw.elsa.hscx, (nr ? 0x40 : 0), ptr, cnt)
280
281#define WRITEHSCXFIFO(cs, nr, ptr, cnt) writefifo(cs->hw.elsa.ale, \
282 cs->hw.elsa.hscx, (nr ? 0x40 : 0), ptr, cnt)
283
284#include "hscx_irq.c"
285
286static irqreturn_t
287elsa_interrupt(int intno, void *dev_id, struct pt_regs *regs)
288{
289 struct IsdnCardState *cs = dev_id;
290 u_long flags;
291 u_char val;
292 int icnt=5;
293
294 if ((cs->typ == ISDN_CTYPE_ELSA_PCMCIA) && (*cs->busy_flag == 1)) {
295 /* The card tends to generate interrupts while being removed
296 causing us to just crash the kernel. bad. */
297 printk(KERN_WARNING "Elsa: card not available!\n");
298 return IRQ_NONE;
299 }
300 spin_lock_irqsave(&cs->lock, flags);
301#if ARCOFI_USE
302 if (cs->hw.elsa.MFlag) {
303 val = serial_inp(cs, UART_IIR);
304 if (!(val & UART_IIR_NO_INT)) {
305 debugl1(cs,"IIR %02x", val);
306 rs_interrupt_elsa(intno, cs);
307 }
308 }
309#endif
310 val = readreg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_ISTA + 0x40);
311 Start_HSCX:
312 if (val) {
313 hscx_int_main(cs, val);
314 }
315 val = readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_ISTA);
316 Start_ISAC:
317 if (val) {
318 isac_interrupt(cs, val);
319 }
320 val = readreg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_ISTA + 0x40);
321 if (val && icnt) {
322 if (cs->debug & L1_DEB_HSCX)
323 debugl1(cs, "HSCX IntStat after IntRoutine");
324 icnt--;
325 goto Start_HSCX;
326 }
327 val = readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_ISTA);
328 if (val && icnt) {
329 if (cs->debug & L1_DEB_ISAC)
330 debugl1(cs, "ISAC IntStat after IntRoutine");
331 icnt--;
332 goto Start_ISAC;
333 }
334 if (!icnt)
335 printk(KERN_WARNING"ELSA IRQ LOOP\n");
336 writereg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_MASK, 0xFF);
337 writereg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_MASK + 0x40, 0xFF);
338 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_MASK, 0xFF);
339 if (cs->hw.elsa.status & ELSA_TIMER_AKTIV) {
340 if (!TimerRun(cs)) {
341 /* Timer Restart */
342 byteout(cs->hw.elsa.timer, 0);
343 cs->hw.elsa.counter++;
344 }
345 }
346#if ARCOFI_USE
347 if (cs->hw.elsa.MFlag) {
348 val = serial_inp(cs, UART_MCR);
349 val ^= 0x8;
350 serial_outp(cs, UART_MCR, val);
351 val = serial_inp(cs, UART_MCR);
352 val ^= 0x8;
353 serial_outp(cs, UART_MCR, val);
354 }
355#endif
356 if (cs->hw.elsa.trig)
357 byteout(cs->hw.elsa.trig, 0x00);
358 writereg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_MASK, 0x0);
359 writereg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_MASK + 0x40, 0x0);
360 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_MASK, 0x0);
361 spin_unlock_irqrestore(&cs->lock, flags);
362 return IRQ_HANDLED;
363}
364
365static irqreturn_t
366elsa_interrupt_ipac(int intno, void *dev_id, struct pt_regs *regs)
367{
368 struct IsdnCardState *cs = dev_id;
369 u_long flags;
370 u_char ista,val;
371 int icnt=5;
372
373 spin_lock_irqsave(&cs->lock, flags);
374 if (cs->subtyp == ELSA_QS1000PCI || cs->subtyp == ELSA_QS3000PCI) {
375 val = bytein(cs->hw.elsa.cfg + 0x4c); /* PCI IRQ */
376 if (!(val & ELSA_PCI_IRQ_MASK)) {
377 spin_unlock_irqrestore(&cs->lock, flags);
378 return IRQ_NONE;
379 }
380 }
381#if ARCOFI_USE
382 if (cs->hw.elsa.MFlag) {
383 val = serial_inp(cs, UART_IIR);
384 if (!(val & UART_IIR_NO_INT)) {
385 debugl1(cs,"IIR %02x", val);
386 rs_interrupt_elsa(intno, cs);
387 }
388 }
389#endif
390 ista = readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ISTA);
391Start_IPAC:
392 if (cs->debug & L1_DEB_IPAC)
393 debugl1(cs, "IPAC ISTA %02X", ista);
394 if (ista & 0x0f) {
395 val = readreg(cs->hw.elsa.ale, cs->hw.elsa.hscx, HSCX_ISTA + 0x40);
396 if (ista & 0x01)
397 val |= 0x01;
398 if (ista & 0x04)
399 val |= 0x02;
400 if (ista & 0x08)
401 val |= 0x04;
402 if (val)
403 hscx_int_main(cs, val);
404 }
405 if (ista & 0x20) {
406 val = 0xfe & readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, ISAC_ISTA + 0x80);
407 if (val) {
408 isac_interrupt(cs, val);
409 }
410 }
411 if (ista & 0x10) {
412 val = 0x01;
413 isac_interrupt(cs, val);
414 }
415 ista = readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ISTA);
416 if ((ista & 0x3f) && icnt) {
417 icnt--;
418 goto Start_IPAC;
419 }
420 if (!icnt)
421 printk(KERN_WARNING "ELSA IRQ LOOP\n");
422 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_MASK, 0xFF);
423 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_MASK, 0xC0);
424 spin_unlock_irqrestore(&cs->lock, flags);
425 return IRQ_HANDLED;
426}
427
428void
429release_io_elsa(struct IsdnCardState *cs)
430{
431 int bytecnt = 8;
432
433 del_timer(&cs->hw.elsa.tl);
434#if ARCOFI_USE
435 clear_arcofi(cs);
436#endif
437 if (cs->hw.elsa.ctrl)
438 byteout(cs->hw.elsa.ctrl, 0); /* LEDs Out */
439 if (cs->subtyp == ELSA_QS1000PCI) {
440 byteout(cs->hw.elsa.cfg + 0x4c, 0x01); /* disable IRQ */
441 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ATX, 0xff);
442 bytecnt = 2;
443 release_region(cs->hw.elsa.cfg, 0x80);
444 }
445 if (cs->subtyp == ELSA_QS3000PCI) {
446 byteout(cs->hw.elsa.cfg + 0x4c, 0x03); /* disable ELSA PCI IRQ */
447 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ATX, 0xff);
448 release_region(cs->hw.elsa.cfg, 0x80);
449 }
450 if (cs->subtyp == ELSA_PCMCIA_IPAC) {
451 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ATX, 0xff);
452 }
453 if ((cs->subtyp == ELSA_PCFPRO) ||
454 (cs->subtyp == ELSA_QS3000) ||
455 (cs->subtyp == ELSA_PCF) ||
456 (cs->subtyp == ELSA_QS3000PCI)) {
457 bytecnt = 16;
458#if ARCOFI_USE
459 release_modem(cs);
460#endif
461 }
462 if (cs->hw.elsa.base)
463 release_region(cs->hw.elsa.base, bytecnt);
464}
465
466static void
467reset_elsa(struct IsdnCardState *cs)
468{
469 if (cs->hw.elsa.timer) {
470 /* Wait 1 Timer */
471 byteout(cs->hw.elsa.timer, 0);
472 while (TimerRun(cs));
473 cs->hw.elsa.ctrl_reg |= 0x50;
474 cs->hw.elsa.ctrl_reg &= ~ELSA_ISDN_RESET; /* Reset On */
475 byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg);
476 /* Wait 1 Timer */
477 byteout(cs->hw.elsa.timer, 0);
478 while (TimerRun(cs));
479 cs->hw.elsa.ctrl_reg |= ELSA_ISDN_RESET; /* Reset Off */
480 byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg);
481 /* Wait 1 Timer */
482 byteout(cs->hw.elsa.timer, 0);
483 while (TimerRun(cs));
484 if (cs->hw.elsa.trig)
485 byteout(cs->hw.elsa.trig, 0xff);
486 }
487 if ((cs->subtyp == ELSA_QS1000PCI) || (cs->subtyp == ELSA_QS3000PCI) || (cs->subtyp == ELSA_PCMCIA_IPAC)) {
488 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_POTA2, 0x20);
489 mdelay(10);
490 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_POTA2, 0x00);
491 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_MASK, 0xc0);
492 mdelay(10);
493 if (cs->subtyp != ELSA_PCMCIA_IPAC) {
494 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ACFG, 0x0);
495 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_AOE, 0x3c);
496 } else {
497 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_PCFG, 0x10);
498 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ACFG, 0x4);
499 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_AOE, 0xf8);
500 }
501 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ATX, 0xff);
502 if (cs->subtyp == ELSA_QS1000PCI)
503 byteout(cs->hw.elsa.cfg + 0x4c, 0x41); /* enable ELSA PCI IRQ */
504 else if (cs->subtyp == ELSA_QS3000PCI)
505 byteout(cs->hw.elsa.cfg + 0x4c, 0x43); /* enable ELSA PCI IRQ */
506 }
507}
508
509#if ARCOFI_USE
510
511static void
512set_arcofi(struct IsdnCardState *cs, int bc) {
513 cs->dc.isac.arcofi_bc = bc;
514 arcofi_fsm(cs, ARCOFI_START, &ARCOFI_COP_5);
515 interruptible_sleep_on(&cs->dc.isac.arcofi_wait);
516}
517
518static int
519check_arcofi(struct IsdnCardState *cs)
520{
521 int arcofi_present = 0;
522 char tmp[40];
523 char *t;
524 u_char *p;
525
526 if (!cs->dc.isac.mon_tx)
527 if (!(cs->dc.isac.mon_tx=kmalloc(MAX_MON_FRAME, GFP_ATOMIC))) {
528 if (cs->debug & L1_DEB_WARN)
529 debugl1(cs, "ISAC MON TX out of buffers!");
530 return(0);
531 }
532 cs->dc.isac.arcofi_bc = 0;
533 arcofi_fsm(cs, ARCOFI_START, &ARCOFI_VERSION);
534 interruptible_sleep_on(&cs->dc.isac.arcofi_wait);
535 if (!test_and_clear_bit(FLG_ARCOFI_ERROR, &cs->HW_Flags)) {
536 debugl1(cs, "Arcofi response received %d bytes", cs->dc.isac.mon_rxp);
537 p = cs->dc.isac.mon_rx;
538 t = tmp;
539 t += sprintf(tmp, "Arcofi data");
540 QuickHex(t, p, cs->dc.isac.mon_rxp);
541 debugl1(cs, tmp);
542 if ((cs->dc.isac.mon_rxp == 2) && (cs->dc.isac.mon_rx[0] == 0xa0)) {
543 switch(cs->dc.isac.mon_rx[1]) {
544 case 0x80:
545 debugl1(cs, "Arcofi 2160 detected");
546 arcofi_present = 1;
547 break;
548 case 0x82:
549 debugl1(cs, "Arcofi 2165 detected");
550 arcofi_present = 2;
551 break;
552 case 0x84:
553 debugl1(cs, "Arcofi 2163 detected");
554 arcofi_present = 3;
555 break;
556 default:
557 debugl1(cs, "unknown Arcofi response");
558 break;
559 }
560 } else
561 debugl1(cs, "undefined Monitor response");
562 cs->dc.isac.mon_rxp = 0;
563 } else if (cs->dc.isac.mon_tx) {
564 debugl1(cs, "Arcofi not detected");
565 }
566 if (arcofi_present) {
567 if (cs->subtyp==ELSA_QS1000) {
568 cs->subtyp = ELSA_QS3000;
569 printk(KERN_INFO
570 "Elsa: %s detected modem at 0x%lx\n",
571 Elsa_Types[cs->subtyp],
572 cs->hw.elsa.base+8);
573 release_region(cs->hw.elsa.base, 8);
574 if (!request_region(cs->hw.elsa.base, 16, "elsa isdn modem")) {
575 printk(KERN_WARNING
576 "HiSax: %s config port %lx-%lx already in use\n",
577 Elsa_Types[cs->subtyp],
578 cs->hw.elsa.base + 8,
579 cs->hw.elsa.base + 16);
580 }
581 } else if (cs->subtyp==ELSA_PCC16) {
582 cs->subtyp = ELSA_PCF;
583 printk(KERN_INFO
584 "Elsa: %s detected modem at 0x%lx\n",
585 Elsa_Types[cs->subtyp],
586 cs->hw.elsa.base+8);
587 release_region(cs->hw.elsa.base, 8);
588 if (!request_region(cs->hw.elsa.base, 16, "elsa isdn modem")) {
589 printk(KERN_WARNING
590 "HiSax: %s config port %lx-%lx already in use\n",
591 Elsa_Types[cs->subtyp],
592 cs->hw.elsa.base + 8,
593 cs->hw.elsa.base + 16);
594 }
595 } else
596 printk(KERN_INFO
597 "Elsa: %s detected modem at 0x%lx\n",
598 Elsa_Types[cs->subtyp],
599 cs->hw.elsa.base+8);
600 arcofi_fsm(cs, ARCOFI_START, &ARCOFI_XOP_0);
601 interruptible_sleep_on(&cs->dc.isac.arcofi_wait);
602 return(1);
603 }
604 return(0);
605}
606#endif /* ARCOFI_USE */
607
608static void
609elsa_led_handler(struct IsdnCardState *cs)
610{
611 int blink = 0;
612
613 if (cs->subtyp == ELSA_PCMCIA || cs->subtyp == ELSA_PCMCIA_IPAC)
614 return;
615 del_timer(&cs->hw.elsa.tl);
616 if (cs->hw.elsa.status & ELSA_ASSIGN)
617 cs->hw.elsa.ctrl_reg |= ELSA_STAT_LED;
618 else if (cs->hw.elsa.status & ELSA_BAD_PWR)
619 cs->hw.elsa.ctrl_reg &= ~ELSA_STAT_LED;
620 else {
621 cs->hw.elsa.ctrl_reg ^= ELSA_STAT_LED;
622 blink = 250;
623 }
624 if (cs->hw.elsa.status & 0xf000)
625 cs->hw.elsa.ctrl_reg |= ELSA_LINE_LED;
626 else if (cs->hw.elsa.status & 0x0f00) {
627 cs->hw.elsa.ctrl_reg ^= ELSA_LINE_LED;
628 blink = 500;
629 } else
630 cs->hw.elsa.ctrl_reg &= ~ELSA_LINE_LED;
631
632 if ((cs->subtyp == ELSA_QS1000PCI) ||
633 (cs->subtyp == ELSA_QS3000PCI)) {
634 u_char led = 0xff;
635 if (cs->hw.elsa.ctrl_reg & ELSA_LINE_LED)
636 led ^= ELSA_IPAC_LINE_LED;
637 if (cs->hw.elsa.ctrl_reg & ELSA_STAT_LED)
638 led ^= ELSA_IPAC_STAT_LED;
639 writereg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ATX, led);
640 } else
641 byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg);
642 if (blink) {
643 init_timer(&cs->hw.elsa.tl);
644 cs->hw.elsa.tl.expires = jiffies + ((blink * HZ) / 1000);
645 add_timer(&cs->hw.elsa.tl);
646 }
647}
648
649static int
650Elsa_card_msg(struct IsdnCardState *cs, int mt, void *arg)
651{
652 int ret = 0;
653 u_long flags;
654
655 switch (mt) {
656 case CARD_RESET:
657 spin_lock_irqsave(&cs->lock, flags);
658 reset_elsa(cs);
659 spin_unlock_irqrestore(&cs->lock, flags);
660 return(0);
661 case CARD_RELEASE:
662 release_io_elsa(cs);
663 return(0);
664 case CARD_INIT:
665 spin_lock_irqsave(&cs->lock, flags);
666 cs->debug |= L1_DEB_IPAC;
667 reset_elsa(cs);
668 inithscxisac(cs, 1);
669 if ((cs->subtyp == ELSA_QS1000) ||
670 (cs->subtyp == ELSA_QS3000))
671 {
672 byteout(cs->hw.elsa.timer, 0);
673 }
674 if (cs->hw.elsa.trig)
675 byteout(cs->hw.elsa.trig, 0xff);
676 inithscxisac(cs, 2);
677 spin_unlock_irqrestore(&cs->lock, flags);
678 return(0);
679 case CARD_TEST:
680 if ((cs->subtyp == ELSA_PCMCIA) ||
681 (cs->subtyp == ELSA_PCMCIA_IPAC) ||
682 (cs->subtyp == ELSA_QS1000PCI)) {
683 return(0);
684 } else if (cs->subtyp == ELSA_QS3000PCI) {
685 ret = 0;
686 } else {
687 spin_lock_irqsave(&cs->lock, flags);
688 cs->hw.elsa.counter = 0;
689 cs->hw.elsa.ctrl_reg |= ELSA_ENA_TIMER_INT;
690 cs->hw.elsa.status |= ELSA_TIMER_AKTIV;
691 byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg);
692 byteout(cs->hw.elsa.timer, 0);
693 spin_unlock_irqrestore(&cs->lock, flags);
694 msleep(110);
695 spin_lock_irqsave(&cs->lock, flags);
696 cs->hw.elsa.ctrl_reg &= ~ELSA_ENA_TIMER_INT;
697 byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg);
698 cs->hw.elsa.status &= ~ELSA_TIMER_AKTIV;
699 spin_unlock_irqrestore(&cs->lock, flags);
700 printk(KERN_INFO "Elsa: %d timer tics in 110 msek\n",
701 cs->hw.elsa.counter);
702 if ((cs->hw.elsa.counter > 10) &&
703 (cs->hw.elsa.counter < 16)) {
704 printk(KERN_INFO "Elsa: timer and irq OK\n");
705 ret = 0;
706 } else {
707 printk(KERN_WARNING
708 "Elsa: timer tic problem (%d/12) maybe an IRQ(%d) conflict\n",
709 cs->hw.elsa.counter, cs->irq);
710 ret = 1;
711 }
712 }
713#if ARCOFI_USE
714 if (check_arcofi(cs)) {
715 init_modem(cs);
716 }
717#endif
718 elsa_led_handler(cs);
719 return(ret);
720 case (MDL_REMOVE | REQUEST):
721 cs->hw.elsa.status &= 0;
722 break;
723 case (MDL_ASSIGN | REQUEST):
724 cs->hw.elsa.status |= ELSA_ASSIGN;
725 break;
726 case MDL_INFO_SETUP:
727 if ((long) arg)
728 cs->hw.elsa.status |= 0x0200;
729 else
730 cs->hw.elsa.status |= 0x0100;
731 break;
732 case MDL_INFO_CONN:
733 if ((long) arg)
734 cs->hw.elsa.status |= 0x2000;
735 else
736 cs->hw.elsa.status |= 0x1000;
737 break;
738 case MDL_INFO_REL:
739 if ((long) arg) {
740 cs->hw.elsa.status &= ~0x2000;
741 cs->hw.elsa.status &= ~0x0200;
742 } else {
743 cs->hw.elsa.status &= ~0x1000;
744 cs->hw.elsa.status &= ~0x0100;
745 }
746 break;
747#if ARCOFI_USE
748 case CARD_AUX_IND:
749 if (cs->hw.elsa.MFlag) {
750 int len;
751 u_char *msg;
752
753 if (!arg)
754 return(0);
755 msg = arg;
756 len = *msg;
757 msg++;
758 modem_write_cmd(cs, msg, len);
759 }
760 break;
761#endif
762 }
763 if (cs->typ == ISDN_CTYPE_ELSA) {
764 int pwr = bytein(cs->hw.elsa.ale);
765 if (pwr & 0x08)
766 cs->hw.elsa.status |= ELSA_BAD_PWR;
767 else
768 cs->hw.elsa.status &= ~ELSA_BAD_PWR;
769 }
770 elsa_led_handler(cs);
771 return(ret);
772}
773
774static unsigned char
775probe_elsa_adr(unsigned int adr, int typ)
776{
777 int i, in1, in2, p16_1 = 0, p16_2 = 0, p8_1 = 0, p8_2 = 0, pc_1 = 0,
778 pc_2 = 0, pfp_1 = 0, pfp_2 = 0;
779
780 /* In case of the elsa pcmcia card, this region is in use,
781 reserved for us by the card manager. So we do not check it
782 here, it would fail. */
783 if (typ != ISDN_CTYPE_ELSA_PCMCIA) {
784 if (request_region(adr, 8, "elsa card")) {
785 release_region(adr, 8);
786 } else {
787 printk(KERN_WARNING
788 "Elsa: Probing Port 0x%x: already in use\n", adr);
789 return (0);
790 }
791 }
792 for (i = 0; i < 16; i++) {
793 in1 = inb(adr + ELSA_CONFIG); /* 'toggelt' bei */
794 in2 = inb(adr + ELSA_CONFIG); /* jedem Zugriff */
795 p16_1 += 0x04 & in1;
796 p16_2 += 0x04 & in2;
797 p8_1 += 0x02 & in1;
798 p8_2 += 0x02 & in2;
799 pc_1 += 0x01 & in1;
800 pc_2 += 0x01 & in2;
801 pfp_1 += 0x40 & in1;
802 pfp_2 += 0x40 & in2;
803 }
804 printk(KERN_INFO "Elsa: Probing IO 0x%x", adr);
805 if (65 == ++p16_1 * ++p16_2) {
806 printk(" PCC-16/PCF found\n");
807 return (ELSA_PCC16);
808 } else if (1025 == ++pfp_1 * ++pfp_2) {
809 printk(" PCF-Pro found\n");
810 return (ELSA_PCFPRO);
811 } else if (33 == ++p8_1 * ++p8_2) {
812 printk(" PCC8 found\n");
813 return (ELSA_PCC8);
814 } else if (17 == ++pc_1 * ++pc_2) {
815 printk(" PC found\n");
816 return (ELSA_PC);
817 } else {
818 printk(" failed\n");
819 return (0);
820 }
821}
822
823static unsigned int
824probe_elsa(struct IsdnCardState *cs)
825{
826 int i;
827 unsigned int CARD_portlist[] =
828 {0x160, 0x170, 0x260, 0x360, 0};
829
830 for (i = 0; CARD_portlist[i]; i++) {
831 if ((cs->subtyp = probe_elsa_adr(CARD_portlist[i], cs->typ)))
832 break;
833 }
834 return (CARD_portlist[i]);
835}
836
837static struct pci_dev *dev_qs1000 __devinitdata = NULL;
838static struct pci_dev *dev_qs3000 __devinitdata = NULL;
839
840#ifdef __ISAPNP__
841static struct isapnp_device_id elsa_ids[] __devinitdata = {
842 { ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0133),
843 ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0133),
844 (unsigned long) "Elsa QS1000" },
845 { ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0134),
846 ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0134),
847 (unsigned long) "Elsa QS3000" },
848 { 0, }
849};
850
851static struct isapnp_device_id *ipid __devinitdata = &elsa_ids[0];
852static struct pnp_card *pnp_c __devinitdata = NULL;
853#endif
854
855int __devinit
856setup_elsa(struct IsdnCard *card)
857{
858 int bytecnt;
859 u_char val;
860 struct IsdnCardState *cs = card->cs;
861 char tmp[64];
862
863 strcpy(tmp, Elsa_revision);
864 printk(KERN_INFO "HiSax: Elsa driver Rev. %s\n", HiSax_getrev(tmp));
865 cs->hw.elsa.ctrl_reg = 0;
866 cs->hw.elsa.status = 0;
867 cs->hw.elsa.MFlag = 0;
868 cs->subtyp = 0;
869 if (cs->typ == ISDN_CTYPE_ELSA) {
870 cs->hw.elsa.base = card->para[0];
871 printk(KERN_INFO "Elsa: Microlink IO probing\n");
872 if (cs->hw.elsa.base) {
873 if (!(cs->subtyp = probe_elsa_adr(cs->hw.elsa.base,
874 cs->typ))) {
875 printk(KERN_WARNING
876 "Elsa: no Elsa Microlink at %#lx\n",
877 cs->hw.elsa.base);
878 return (0);
879 }
880 } else
881 cs->hw.elsa.base = probe_elsa(cs);
882 if (cs->hw.elsa.base) {
883 cs->hw.elsa.cfg = cs->hw.elsa.base + ELSA_CONFIG;
884 cs->hw.elsa.ctrl = cs->hw.elsa.base + ELSA_CONTROL;
885 cs->hw.elsa.ale = cs->hw.elsa.base + ELSA_ALE;
886 cs->hw.elsa.isac = cs->hw.elsa.base + ELSA_ISAC;
887 cs->hw.elsa.itac = cs->hw.elsa.base + ELSA_ITAC;
888 cs->hw.elsa.hscx = cs->hw.elsa.base + ELSA_HSCX;
889 cs->hw.elsa.trig = cs->hw.elsa.base + ELSA_TRIG_IRQ;
890 cs->hw.elsa.timer = cs->hw.elsa.base + ELSA_START_TIMER;
891 val = bytein(cs->hw.elsa.cfg);
892 if (cs->subtyp == ELSA_PC) {
893 const u_char CARD_IrqTab[8] =
894 {7, 3, 5, 9, 0, 0, 0, 0};
895 cs->irq = CARD_IrqTab[(val & ELSA_IRQ_IDX_PC) >> 2];
896 } else if (cs->subtyp == ELSA_PCC8) {
897 const u_char CARD_IrqTab[8] =
898 {7, 3, 5, 9, 0, 0, 0, 0};
899 cs->irq = CARD_IrqTab[(val & ELSA_IRQ_IDX_PCC8) >> 4];
900 } else {
901 const u_char CARD_IrqTab[8] =
902 {15, 10, 15, 3, 11, 5, 11, 9};
903 cs->irq = CARD_IrqTab[(val & ELSA_IRQ_IDX) >> 3];
904 }
905 val = bytein(cs->hw.elsa.ale) & ELSA_HW_RELEASE;
906 if (val < 3)
907 val |= 8;
908 val += 'A' - 3;
909 if (val == 'B' || val == 'C')
910 val ^= 1;
911 if ((cs->subtyp == ELSA_PCFPRO) && (val = 'G'))
912 val = 'C';
913 printk(KERN_INFO
914 "Elsa: %s found at %#lx Rev.:%c IRQ %d\n",
915 Elsa_Types[cs->subtyp],
916 cs->hw.elsa.base,
917 val, cs->irq);
918 val = bytein(cs->hw.elsa.ale) & ELSA_S0_POWER_BAD;
919 if (val) {
920 printk(KERN_WARNING
921 "Elsa: Microlink S0 bus power bad\n");
922 cs->hw.elsa.status |= ELSA_BAD_PWR;
923 }
924 } else {
925 printk(KERN_WARNING
926 "No Elsa Microlink found\n");
927 return (0);
928 }
929 } else if (cs->typ == ISDN_CTYPE_ELSA_PNP) {
930#ifdef __ISAPNP__
931 if (!card->para[1] && isapnp_present()) {
932 struct pnp_dev *pnp_d;
933 while(ipid->card_vendor) {
934 if ((pnp_c = pnp_find_card(ipid->card_vendor,
935 ipid->card_device, pnp_c))) {
936 pnp_d = NULL;
937 if ((pnp_d = pnp_find_dev(pnp_c,
938 ipid->vendor, ipid->function, pnp_d))) {
939 int err;
940
941 printk(KERN_INFO "HiSax: %s detected\n",
942 (char *)ipid->driver_data);
943 pnp_disable_dev(pnp_d);
944 err = pnp_activate_dev(pnp_d);
945 if (err<0) {
946 printk(KERN_WARNING "%s: pnp_activate_dev ret(%d)\n",
947 __FUNCTION__, err);
948 return(0);
949 }
950 card->para[1] = pnp_port_start(pnp_d, 0);
951 card->para[0] = pnp_irq(pnp_d, 0);
952
953 if (!card->para[0] || !card->para[1]) {
954 printk(KERN_ERR "Elsa PnP:some resources are missing %ld/%lx\n",
955 card->para[0], card->para[1]);
956 pnp_disable_dev(pnp_d);
957 return(0);
958 }
959 if (ipid->function == ISAPNP_FUNCTION(0x133))
960 cs->subtyp = ELSA_QS1000;
961 else
962 cs->subtyp = ELSA_QS3000;
963 break;
964 } else {
965 printk(KERN_ERR "Elsa PnP: PnP error card found, no device\n");
966 return(0);
967 }
968 }
969 ipid++;
970 pnp_c=NULL;
971 }
972 if (!ipid->card_vendor) {
973 printk(KERN_INFO "Elsa PnP: no ISAPnP card found\n");
974 return(0);
975 }
976 }
977#endif
978 if (card->para[1] && card->para[0]) {
979 cs->hw.elsa.base = card->para[1];
980 cs->irq = card->para[0];
981 if (!cs->subtyp)
982 cs->subtyp = ELSA_QS1000;
983 } else {
984 printk(KERN_ERR "Elsa PnP: no parameter\n");
985 }
986 cs->hw.elsa.cfg = cs->hw.elsa.base + ELSA_CONFIG;
987 cs->hw.elsa.ale = cs->hw.elsa.base + ELSA_ALE;
988 cs->hw.elsa.isac = cs->hw.elsa.base + ELSA_ISAC;
989 cs->hw.elsa.hscx = cs->hw.elsa.base + ELSA_HSCX;
990 cs->hw.elsa.trig = cs->hw.elsa.base + ELSA_TRIG_IRQ;
991 cs->hw.elsa.timer = cs->hw.elsa.base + ELSA_START_TIMER;
992 cs->hw.elsa.ctrl = cs->hw.elsa.base + ELSA_CONTROL;
993 printk(KERN_INFO
994 "Elsa: %s defined at %#lx IRQ %d\n",
995 Elsa_Types[cs->subtyp],
996 cs->hw.elsa.base,
997 cs->irq);
998 } else if (cs->typ == ISDN_CTYPE_ELSA_PCMCIA) {
999 cs->hw.elsa.base = card->para[1];
1000 cs->irq = card->para[0];
1001 val = readreg(cs->hw.elsa.base + 0, cs->hw.elsa.base + 2, IPAC_ID);
1002 if ((val == 1) || (val == 2)) { /* IPAC version 1.1/1.2 */
1003 cs->subtyp = ELSA_PCMCIA_IPAC;
1004 cs->hw.elsa.ale = cs->hw.elsa.base + 0;
1005 cs->hw.elsa.isac = cs->hw.elsa.base + 2;
1006 cs->hw.elsa.hscx = cs->hw.elsa.base + 2;
1007 test_and_set_bit(HW_IPAC, &cs->HW_Flags);
1008 } else {
1009 cs->subtyp = ELSA_PCMCIA;
1010 cs->hw.elsa.ale = cs->hw.elsa.base + ELSA_ALE_PCM;
1011 cs->hw.elsa.isac = cs->hw.elsa.base + ELSA_ISAC_PCM;
1012 cs->hw.elsa.hscx = cs->hw.elsa.base + ELSA_HSCX;
1013 }
1014 cs->hw.elsa.timer = 0;
1015 cs->hw.elsa.trig = 0;
1016 cs->hw.elsa.ctrl = 0;
1017 cs->irq_flags |= SA_SHIRQ;
1018 printk(KERN_INFO
1019 "Elsa: %s defined at %#lx IRQ %d\n",
1020 Elsa_Types[cs->subtyp],
1021 cs->hw.elsa.base,
1022 cs->irq);
1023 } else if (cs->typ == ISDN_CTYPE_ELSA_PCI) {
1024#ifdef CONFIG_PCI
1025 cs->subtyp = 0;
1026 if ((dev_qs1000 = pci_find_device(PCI_VENDOR_ID_ELSA,
1027 PCI_DEVICE_ID_ELSA_MICROLINK, dev_qs1000))) {
1028 if (pci_enable_device(dev_qs1000))
1029 return(0);
1030 cs->subtyp = ELSA_QS1000PCI;
1031 cs->irq = dev_qs1000->irq;
1032 cs->hw.elsa.cfg = pci_resource_start(dev_qs1000, 1);
1033 cs->hw.elsa.base = pci_resource_start(dev_qs1000, 3);
1034 } else if ((dev_qs3000 = pci_find_device(PCI_VENDOR_ID_ELSA,
1035 PCI_DEVICE_ID_ELSA_QS3000, dev_qs3000))) {
1036 if (pci_enable_device(dev_qs3000))
1037 return(0);
1038 cs->subtyp = ELSA_QS3000PCI;
1039 cs->irq = dev_qs3000->irq;
1040 cs->hw.elsa.cfg = pci_resource_start(dev_qs3000, 1);
1041 cs->hw.elsa.base = pci_resource_start(dev_qs3000, 3);
1042 } else {
1043 printk(KERN_WARNING "Elsa: No PCI card found\n");
1044 return(0);
1045 }
1046 if (!cs->irq) {
1047 printk(KERN_WARNING "Elsa: No IRQ for PCI card found\n");
1048 return(0);
1049 }
1050
1051 if (!(cs->hw.elsa.base && cs->hw.elsa.cfg)) {
1052 printk(KERN_WARNING "Elsa: No IO-Adr for PCI card found\n");
1053 return(0);
1054 }
1055 if ((cs->hw.elsa.cfg & 0xff) || (cs->hw.elsa.base & 0xf)) {
1056 printk(KERN_WARNING "Elsa: You may have a wrong PCI bios\n");
1057 printk(KERN_WARNING "Elsa: If your system hangs now, read\n");
1058 printk(KERN_WARNING "Elsa: Documentation/isdn/README.HiSax\n");
1059 }
1060 cs->hw.elsa.ale = cs->hw.elsa.base;
1061 cs->hw.elsa.isac = cs->hw.elsa.base +1;
1062 cs->hw.elsa.hscx = cs->hw.elsa.base +1;
1063 test_and_set_bit(HW_IPAC, &cs->HW_Flags);
1064 cs->hw.elsa.timer = 0;
1065 cs->hw.elsa.trig = 0;
1066 cs->irq_flags |= SA_SHIRQ;
1067 printk(KERN_INFO
1068 "Elsa: %s defined at %#lx/0x%x IRQ %d\n",
1069 Elsa_Types[cs->subtyp],
1070 cs->hw.elsa.base,
1071 cs->hw.elsa.cfg,
1072 cs->irq);
1073#else
1074 printk(KERN_WARNING "Elsa: Elsa PCI and NO_PCI_BIOS\n");
1075 printk(KERN_WARNING "Elsa: unable to config Elsa PCI\n");
1076 return (0);
1077#endif /* CONFIG_PCI */
1078 } else
1079 return (0);
1080
1081 switch (cs->subtyp) {
1082 case ELSA_PC:
1083 case ELSA_PCC8:
1084 case ELSA_PCC16:
1085 case ELSA_QS1000:
1086 case ELSA_PCMCIA:
1087 case ELSA_PCMCIA_IPAC:
1088 bytecnt = 8;
1089 break;
1090 case ELSA_PCFPRO:
1091 case ELSA_PCF:
1092 case ELSA_QS3000:
1093 case ELSA_QS3000PCI:
1094 bytecnt = 16;
1095 break;
1096 case ELSA_QS1000PCI:
1097 bytecnt = 2;
1098 break;
1099 default:
1100 printk(KERN_WARNING
1101 "Unknown ELSA subtype %d\n", cs->subtyp);
1102 return (0);
1103 }
1104 /* In case of the elsa pcmcia card, this region is in use,
1105 reserved for us by the card manager. So we do not check it
1106 here, it would fail. */
1107 if (cs->typ != ISDN_CTYPE_ELSA_PCMCIA && !request_region(cs->hw.elsa.base, bytecnt, "elsa isdn")) {
1108 printk(KERN_WARNING
1109 "HiSax: %s config port %#lx-%#lx already in use\n",
1110 CardType[card->typ],
1111 cs->hw.elsa.base,
1112 cs->hw.elsa.base + bytecnt);
1113 return (0);
1114 }
1115 if ((cs->subtyp == ELSA_QS1000PCI) || (cs->subtyp == ELSA_QS3000PCI)) {
1116 if (!request_region(cs->hw.elsa.cfg, 0x80, "elsa isdn pci")) {
1117 printk(KERN_WARNING
1118 "HiSax: %s pci port %x-%x already in use\n",
1119 CardType[card->typ],
1120 cs->hw.elsa.cfg,
1121 cs->hw.elsa.cfg + 0x80);
1122 release_region(cs->hw.elsa.base, bytecnt);
1123 return (0);
1124 }
1125 }
1126#if ARCOFI_USE
1127 init_arcofi(cs);
1128#endif
1129 setup_isac(cs);
1130 cs->hw.elsa.tl.function = (void *) elsa_led_handler;
1131 cs->hw.elsa.tl.data = (long) cs;
1132 init_timer(&cs->hw.elsa.tl);
1133 /* Teste Timer */
1134 if (cs->hw.elsa.timer) {
1135 byteout(cs->hw.elsa.trig, 0xff);
1136 byteout(cs->hw.elsa.timer, 0);
1137 if (!TimerRun(cs)) {
1138 byteout(cs->hw.elsa.timer, 0); /* 2. Versuch */
1139 if (!TimerRun(cs)) {
1140 printk(KERN_WARNING
1141 "Elsa: timer do not start\n");
1142 release_io_elsa(cs);
1143 return (0);
1144 }
1145 }
1146 HZDELAY((HZ/100) + 1); /* wait >=10 ms */
1147 if (TimerRun(cs)) {
1148 printk(KERN_WARNING "Elsa: timer do not run down\n");
1149 release_io_elsa(cs);
1150 return (0);
1151 }
1152 printk(KERN_INFO "Elsa: timer OK; resetting card\n");
1153 }
1154 cs->BC_Read_Reg = &ReadHSCX;
1155 cs->BC_Write_Reg = &WriteHSCX;
1156 cs->BC_Send_Data = &hscx_fill_fifo;
1157 cs->cardmsg = &Elsa_card_msg;
1158 if ((cs->subtyp == ELSA_QS1000PCI) || (cs->subtyp == ELSA_QS3000PCI) || (cs->subtyp == ELSA_PCMCIA_IPAC)) {
1159 cs->readisac = &ReadISAC_IPAC;
1160 cs->writeisac = &WriteISAC_IPAC;
1161 cs->readisacfifo = &ReadISACfifo_IPAC;
1162 cs->writeisacfifo = &WriteISACfifo_IPAC;
1163 cs->irq_func = &elsa_interrupt_ipac;
1164 val = readreg(cs->hw.elsa.ale, cs->hw.elsa.isac, IPAC_ID);
1165 printk(KERN_INFO "Elsa: IPAC version %x\n", val);
1166 } else {
1167 cs->readisac = &ReadISAC;
1168 cs->writeisac = &WriteISAC;
1169 cs->readisacfifo = &ReadISACfifo;
1170 cs->writeisacfifo = &WriteISACfifo;
1171 cs->irq_func = &elsa_interrupt;
1172 ISACVersion(cs, "Elsa:");
1173 if (HscxVersion(cs, "Elsa:")) {
1174 printk(KERN_WARNING
1175 "Elsa: wrong HSCX versions check IO address\n");
1176 release_io_elsa(cs);
1177 return (0);
1178 }
1179 }
1180 if (cs->subtyp == ELSA_PC) {
1181 val = readitac(cs, ITAC_SYS);
1182 printk(KERN_INFO "Elsa: ITAC version %s\n", ITACVer[val & 7]);
1183 writeitac(cs, ITAC_ISEN, 0);
1184 writeitac(cs, ITAC_RFIE, 0);
1185 writeitac(cs, ITAC_XFIE, 0);
1186 writeitac(cs, ITAC_SCIE, 0);
1187 writeitac(cs, ITAC_STIE, 0);
1188 }
1189 return (1);
1190}