1 #include <linux/serial.h>
2 #include <linux/serial_reg.h>
4 #define MAX_MODEM_BUF 256
5 #define WAKEUP_CHARS (MAX_MODEM_BUF/2)
6 #define RS_ISR_PASS_LIMIT 256
7 #define BASE_BAUD ( 1843200 / 16 )
10 #define MIN(a,b) ((a) < (b) ? (a) : (b))
13 //#define SERIAL_DEBUG_OPEN 1
14 //#define SERIAL_DEBUG_INTR 1
15 //#define SERIAL_DEBUG_FLOW 1
16 #undef SERIAL_DEBUG_OPEN
17 #undef SERIAL_DEBUG_INTR
18 #undef SERIAL_DEBUG_FLOW
19 #undef SERIAL_DEBUG_REG
20 //#define SERIAL_DEBUG_REG 1
22 #ifdef SERIAL_DEBUG_REG
23 static u_char deb
[32];
24 const char *ModemIn
[] = {"RBR","IER","IIR","LCR","MCR","LSR","MSR","SCR"};
25 const char *ModemOut
[] = {"THR","IER","FCR","LCR","MCR","LSR","MSR","SCR"};
28 static char *MInit_1
= "AT&F&C1E0&D2\r\0";
29 static char *MInit_2
= "ATL2M1S64=13\r\0";
30 static char *MInit_3
= "AT+FCLASS=0\r\0";
31 static char *MInit_4
= "ATV1S2=128X1\r\0";
32 static char *MInit_5
= "AT\\V8\\N3\r\0";
33 static char *MInit_6
= "ATL0M0&G0%E1\r\0";
34 static char *MInit_7
= "AT%L1%M0%C3\r\0";
36 static char *MInit_speed28800
= "AT%G0%B28800\r\0";
38 static char *MInit_dialout
= "ATs7=60 x1 d\r\0";
39 static char *MInit_dialin
= "ATs7=60 x1 a\r\0";
42 static inline unsigned int serial_in(struct IsdnCardState
*cs
, int offset
)
44 #ifdef SERIAL_DEBUG_REG
45 u_int val
= inb(cs
->hw
.elsa
.base
+ 8 + offset
);
46 debugl1(cs
,"in %s %02x",ModemIn
[offset
], val
);
49 return inb(cs
->hw
.elsa
.base
+ 8 + offset
);
53 static inline unsigned int serial_inp(struct IsdnCardState
*cs
, int offset
)
55 #ifdef SERIAL_DEBUG_REG
56 #ifdef CONFIG_SERIAL_NOPAUSE_IO
57 u_int val
= inb(cs
->hw
.elsa
.base
+ 8 + offset
);
58 debugl1(cs
,"inp %s %02x",ModemIn
[offset
], val
);
60 u_int val
= inb_p(cs
->hw
.elsa
.base
+ 8 + offset
);
61 debugl1(cs
,"inP %s %02x",ModemIn
[offset
], val
);
65 #ifdef CONFIG_SERIAL_NOPAUSE_IO
66 return inb(cs
->hw
.elsa
.base
+ 8 + offset
);
68 return inb_p(cs
->hw
.elsa
.base
+ 8 + offset
);
73 static inline void serial_out(struct IsdnCardState
*cs
, int offset
, int value
)
75 #ifdef SERIAL_DEBUG_REG
76 debugl1(cs
,"out %s %02x",ModemOut
[offset
], value
);
78 outb(value
, cs
->hw
.elsa
.base
+ 8 + offset
);
81 static inline void serial_outp(struct IsdnCardState
*cs
, int offset
,
84 #ifdef SERIAL_DEBUG_REG
85 #ifdef CONFIG_SERIAL_NOPAUSE_IO
86 debugl1(cs
,"outp %s %02x",ModemOut
[offset
], value
);
88 debugl1(cs
,"outP %s %02x",ModemOut
[offset
], value
);
91 #ifdef CONFIG_SERIAL_NOPAUSE_IO
92 outb(value
, cs
->hw
.elsa
.base
+ 8 + offset
);
94 outb_p(value
, cs
->hw
.elsa
.base
+ 8 + offset
);
99 * This routine is called to set the UART divisor registers to match
100 * the specified baud rate for a serial port.
102 static void change_speed(struct IsdnCardState
*cs
, int baud
)
104 int quot
= 0, baud_base
;
105 unsigned cval
, fcr
= 0;
110 /* byte size and parity */
111 cval
= 0x03; bits
= 10;
112 /* Determine divisor based on baud rate */
113 baud_base
= BASE_BAUD
;
114 quot
= baud_base
/ baud
;
115 /* If the quotient is ever zero, default to 9600 bps */
117 quot
= baud_base
/ 9600;
120 if ((baud_base
/ quot
) < 2400)
121 fcr
= UART_FCR_ENABLE_FIFO
| UART_FCR_TRIGGER_1
;
123 fcr
= UART_FCR_ENABLE_FIFO
| UART_FCR_TRIGGER_8
;
124 serial_outp(cs
, UART_FCR
, fcr
);
125 /* CTS flow control flag and modem status interrupts */
126 cs
->hw
.elsa
.IER
&= ~UART_IER_MSI
;
127 cs
->hw
.elsa
.IER
|= UART_IER_MSI
;
128 serial_outp(cs
, UART_IER
, cs
->hw
.elsa
.IER
);
130 debugl1(cs
,"modem quot=0x%x", quot
);
133 serial_outp(cs
, UART_LCR
, cval
| UART_LCR_DLAB
);/* set DLAB */
134 serial_outp(cs
, UART_DLL
, quot
& 0xff); /* LS of divisor */
135 serial_outp(cs
, UART_DLM
, quot
>> 8); /* MS of divisor */
136 serial_outp(cs
, UART_LCR
, cval
); /* reset DLAB */
137 serial_inp(cs
, UART_RX
);
138 restore_flags(flags
);
141 static int mstartup(struct IsdnCardState
*cs
)
147 save_flags(flags
); cli();
150 * Clear the FIFO buffers and disable them
151 * (they will be reenabled in change_speed())
153 serial_outp(cs
, UART_FCR
, (UART_FCR_CLEAR_RCVR
| UART_FCR_CLEAR_XMIT
));
156 * At this point there's no way the LSR could still be 0xFF;
157 * if it is, then bail out, because there's likely no UART
160 if (serial_inp(cs
, UART_LSR
) == 0xff) {
166 * Clear the interrupt registers.
168 (void) serial_inp(cs
, UART_RX
);
169 (void) serial_inp(cs
, UART_IIR
);
170 (void) serial_inp(cs
, UART_MSR
);
173 * Now, initialize the UART
175 serial_outp(cs
, UART_LCR
, UART_LCR_WLEN8
); /* reset DLAB */
178 cs
->hw
.elsa
.MCR
= UART_MCR_DTR
| UART_MCR_RTS
| UART_MCR_OUT2
;
179 serial_outp(cs
, UART_MCR
, cs
->hw
.elsa
.MCR
);
182 * Finally, enable interrupts
184 cs
->hw
.elsa
.IER
= UART_IER_MSI
| UART_IER_RLSI
| UART_IER_RDI
;
185 serial_outp(cs
, UART_IER
, cs
->hw
.elsa
.IER
); /* enable interrupts */
188 * And clear the interrupt registers again for luck.
190 (void)serial_inp(cs
, UART_LSR
);
191 (void)serial_inp(cs
, UART_RX
);
192 (void)serial_inp(cs
, UART_IIR
);
193 (void)serial_inp(cs
, UART_MSR
);
195 cs
->hw
.elsa
.transcnt
= cs
->hw
.elsa
.transp
= 0;
196 cs
->hw
.elsa
.rcvcnt
= cs
->hw
.elsa
.rcvp
=0;
199 * and set the speed of the serial port
201 change_speed(cs
, BASE_BAUD
);
202 cs
->hw
.elsa
.MFlag
= 1;
204 restore_flags(flags
);
209 * This routine will shutdown a serial port; interrupts are disabled, and
210 * DTR is dropped if the hangup on close termio flag is on.
212 static void mshutdown(struct IsdnCardState
*cs
)
217 #ifdef SERIAL_DEBUG_OPEN
218 printk(KERN_DEBUG
"Shutting down serial ....");
221 save_flags(flags
); cli(); /* Disable interrupts */
224 * clear delta_msr_wait queue to avoid mem leaks: we may free the irq
225 * here so the queue might never be waken up
229 serial_outp(cs
, UART_IER
, 0x00); /* disable all intrs */
230 cs
->hw
.elsa
.MCR
&= ~UART_MCR_OUT2
;
232 /* disable break condition */
233 serial_outp(cs
, UART_LCR
, serial_inp(cs
, UART_LCR
) & ~UART_LCR_SBC
);
235 cs
->hw
.elsa
.MCR
&= ~(UART_MCR_DTR
|UART_MCR_RTS
);
236 serial_outp(cs
, UART_MCR
, cs
->hw
.elsa
.MCR
);
239 serial_outp(cs
, UART_FCR
, (UART_FCR_CLEAR_RCVR
| UART_FCR_CLEAR_XMIT
));
240 serial_inp(cs
, UART_RX
); /* read data port to reset things */
242 restore_flags(flags
);
243 #ifdef SERIAL_DEBUG_OPEN
249 write_modem(struct BCState
*bcs
) {
251 struct IsdnCardState
*cs
= bcs
->cs
;
252 int count
, len
, fp
, buflen
;
257 if (bcs
->tx_skb
->len
<= 0)
261 buflen
= MAX_MODEM_BUF
- cs
->hw
.elsa
.transcnt
;
262 len
= MIN(buflen
, bcs
->tx_skb
->len
);
263 fp
= cs
->hw
.elsa
.transcnt
+ cs
->hw
.elsa
.transp
;
264 fp
&= (MAX_MODEM_BUF
-1);
265 count
= MIN(len
, MAX_MODEM_BUF
- fp
);
267 memcpy(cs
->hw
.elsa
.transbuf
+ fp
, bcs
->tx_skb
->data
, count
);
268 skb_pull(bcs
->tx_skb
, count
);
269 cs
->hw
.elsa
.transcnt
+= count
;
274 memcpy((cs
->hw
.elsa
.transbuf
+ fp
), bcs
->tx_skb
->data
, count
);
275 skb_pull(bcs
->tx_skb
, count
);
276 cs
->hw
.elsa
.transcnt
+= count
;
279 if (cs
->hw
.elsa
.transcnt
&&
280 !(cs
->hw
.elsa
.IER
& UART_IER_THRI
)) {
281 cs
->hw
.elsa
.IER
|= UART_IER_THRI
;
282 serial_outp(cs
, UART_IER
, cs
->hw
.elsa
.IER
);
284 restore_flags(flags
);
289 modem_fill(struct BCState
*bcs
) {
292 if (bcs
->tx_skb
->len
) {
296 if (bcs
->st
->lli
.l1writewakeup
&&
297 (PACKET_NOACK
!= bcs
->tx_skb
->pkt_type
))
298 bcs
->st
->lli
.l1writewakeup(bcs
->st
,
300 dev_kfree_skb(bcs
->tx_skb
);
304 if ((bcs
->tx_skb
= skb_dequeue(&bcs
->squeue
))) {
305 bcs
->hw
.hscx
.count
= 0;
306 test_and_set_bit(BC_FLG_BUSY
, &bcs
->Flag
);
309 test_and_clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
310 hscx_sched_event(bcs
, B_XMTBUFREADY
);
314 static inline void receive_chars(struct IsdnCardState
*cs
,
321 ch
= serial_in(cs
, UART_RX
);
322 if (cs
->hw
.elsa
.rcvcnt
>= MAX_MODEM_BUF
)
324 cs
->hw
.elsa
.rcvbuf
[cs
->hw
.elsa
.rcvcnt
++] = ch
;
325 #ifdef SERIAL_DEBUG_INTR
326 printk("DR%02x:%02x...", ch
, *status
);
328 if (*status
& (UART_LSR_BI
| UART_LSR_PE
|
329 UART_LSR_FE
| UART_LSR_OE
)) {
331 #ifdef SERIAL_DEBUG_INTR
332 printk("handling exept....");
335 *status
= serial_inp(cs
, UART_LSR
);
336 } while (*status
& UART_LSR_DR
);
337 if (cs
->hw
.elsa
.MFlag
== 2) {
338 if (!(skb
= dev_alloc_skb(cs
->hw
.elsa
.rcvcnt
)))
339 printk(KERN_WARNING
"ElsaSER: receive out of memory\n");
341 memcpy(skb_put(skb
, cs
->hw
.elsa
.rcvcnt
), cs
->hw
.elsa
.rcvbuf
,
343 skb_queue_tail(& cs
->hw
.elsa
.bcs
->rqueue
, skb
);
345 hscx_sched_event(cs
->hw
.elsa
.bcs
, B_RCVBUFREADY
);
350 t
+= sprintf(t
, "modem read cnt %d", cs
->hw
.elsa
.rcvcnt
);
351 QuickHex(t
, cs
->hw
.elsa
.rcvbuf
, cs
->hw
.elsa
.rcvcnt
);
354 cs
->hw
.elsa
.rcvcnt
= 0;
357 static inline void transmit_chars(struct IsdnCardState
*cs
, int *intr_done
)
361 debugl1(cs
, "transmit_chars: p(%x) cnt(%x)", cs
->hw
.elsa
.transp
,
362 cs
->hw
.elsa
.transcnt
);
364 if (cs
->hw
.elsa
.transcnt
<= 0) {
365 cs
->hw
.elsa
.IER
&= ~UART_IER_THRI
;
366 serial_out(cs
, UART_IER
, cs
->hw
.elsa
.IER
);
371 serial_outp(cs
, UART_TX
, cs
->hw
.elsa
.transbuf
[cs
->hw
.elsa
.transp
++]);
372 if (cs
->hw
.elsa
.transp
>= MAX_MODEM_BUF
)
373 cs
->hw
.elsa
.transp
=0;
374 if (--cs
->hw
.elsa
.transcnt
<= 0)
376 } while (--count
> 0);
377 if ((cs
->hw
.elsa
.transcnt
< WAKEUP_CHARS
) && (cs
->hw
.elsa
.MFlag
==2))
378 modem_fill(cs
->hw
.elsa
.bcs
);
380 #ifdef SERIAL_DEBUG_INTR
385 if (cs
->hw
.elsa
.transcnt
<= 0) {
386 cs
->hw
.elsa
.IER
&= ~UART_IER_THRI
;
387 serial_outp(cs
, UART_IER
, cs
->hw
.elsa
.IER
);
392 static inline void check_modem_status(struct IsdnCardState
*cs
)
395 struct async_struct
*info
= cs
->hw
.elsa
.info
;
396 struct async_icount
*icount
;
398 status
= serial_inp(info
, UART_MSR
);
400 if (status
& UART_MSR_ANY_DELTA
) {
401 icount
= &info
->state
->icount
;
402 /* update input line counters */
403 if (status
& UART_MSR_TERI
)
405 if (status
& UART_MSR_DDSR
)
407 if (status
& UART_MSR_DDCD
) {
410 if (status
& UART_MSR_DCTS
)
412 // wake_up_interruptible(&info->delta_msr_wait);
415 if ((info
->flags
& ASYNC_CHECK_CD
) && (status
& UART_MSR_DDCD
)) {
416 #if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
417 printk("ttys%d CD now %s...", info
->line
,
418 (status
& UART_MSR_DCD
) ? "on" : "off");
420 if (status
& UART_MSR_DCD
)
421 // wake_up_interruptible(&info->open_wait);
423 else if (!((info
->flags
& ASYNC_CALLOUT_ACTIVE
) &&
424 (info
->flags
& ASYNC_CALLOUT_NOHUP
))) {
425 #ifdef SERIAL_DEBUG_OPEN
426 printk("doing serial hangup...");
429 tty_hangup(info
->tty
);
433 if (info
->flags
& ASYNC_CTS_FLOW
) {
434 if (info
->tty
->hw_stopped
) {
435 if (status
& UART_MSR_CTS
) {
436 #if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
437 printk("CTS tx start...");
439 info
->tty
->hw_stopped
= 0;
440 info
->IER
|= UART_IER_THRI
;
441 serial_outp(info
, UART_IER
, info
->IER
);
442 // rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
446 if (!(status
& UART_MSR_CTS
)) {
447 #if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
448 printk("CTS tx stop...");
450 info
->tty
->hw_stopped
= 1;
451 info
->IER
&= ~UART_IER_THRI
;
452 serial_outp(info
, UART_IER
, info
->IER
);
460 static void rs_interrupt_elsa(int irq
, struct IsdnCardState
*cs
)
462 int status
, iir
, msr
;
463 int pass_counter
= 0;
465 #ifdef SERIAL_DEBUG_INTR
466 printk("rs_interrupt_single(%d)...", irq
);
470 status
= serial_inp(cs
, UART_LSR
);
471 debugl1(cs
,"rs LSR %02x", status
);
472 #ifdef SERIAL_DEBUG_INTR
473 printk("status = %x...", status
);
475 if (status
& UART_LSR_DR
)
476 receive_chars(cs
, &status
);
477 if (status
& UART_LSR_THRE
)
478 transmit_chars(cs
, 0);
479 if (pass_counter
++ > RS_ISR_PASS_LIMIT
) {
480 printk("rs_single loop break.\n");
483 iir
= serial_inp(cs
, UART_IIR
);
484 debugl1(cs
,"rs IIR %02x", iir
);
485 if ((iir
& 0xf) == 0) {
486 msr
= serial_inp(cs
, UART_MSR
);
487 debugl1(cs
,"rs MSR %02x", msr
);
489 } while (!(iir
& UART_IIR_NO_INT
));
490 #ifdef SERIAL_DEBUG_INTR
495 extern int open_hscxstate(struct IsdnCardState
*cs
, struct BCState
*bcs
);
496 extern void modehscx(struct BCState
*bcs
, int mode
, int bc
);
497 extern void hscx_l2l1(struct PStack
*st
, int pr
, void *arg
);
500 close_elsastate(struct BCState
*bcs
)
504 modehscx(bcs
, 0, bcs
->channel
);
505 if (test_and_clear_bit(BC_FLG_INIT
, &bcs
->Flag
)) {
506 if (bcs
->hw
.hscx
.rcvbuf
) {
507 if (bcs
->mode
!= L1_MODE_MODEM
)
508 kfree(bcs
->hw
.hscx
.rcvbuf
);
509 bcs
->hw
.hscx
.rcvbuf
= NULL
;
511 while ((skb
= skb_dequeue(&bcs
->rqueue
))) {
514 while ((skb
= skb_dequeue(&bcs
->squeue
))) {
518 dev_kfree_skb(bcs
->tx_skb
);
520 test_and_clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
526 modem_write_cmd(struct IsdnCardState
*cs
, u_char
*buf
, int len
) {
535 if (len
> (MAX_MODEM_BUF
- cs
->hw
.elsa
.transcnt
)) {
536 restore_flags(flags
);
539 fp
= cs
->hw
.elsa
.transcnt
+ cs
->hw
.elsa
.transp
;
540 fp
&= (MAX_MODEM_BUF
-1);
541 count
= MIN(len
, MAX_MODEM_BUF
- fp
);
543 memcpy(cs
->hw
.elsa
.transbuf
+ fp
, msg
, count
);
544 cs
->hw
.elsa
.transcnt
+= count
;
549 memcpy(cs
->hw
.elsa
.transbuf
+ fp
, msg
, count
);
550 cs
->hw
.elsa
.transcnt
+= count
;
551 if (cs
->hw
.elsa
.transcnt
&&
552 !(cs
->hw
.elsa
.IER
& UART_IER_THRI
)) {
553 cs
->hw
.elsa
.IER
|= UART_IER_THRI
;
554 serial_outp(cs
, UART_IER
, cs
->hw
.elsa
.IER
);
556 restore_flags(flags
);
560 modem_set_init(struct IsdnCardState
*cs
) {
564 #define RCV_DELAY 20000
567 modem_write_cmd(cs
, MInit_1
, strlen(MInit_1
));
569 while(timeout
-- && cs
->hw
.elsa
.transcnt
)
571 debugl1(cs
, "msi tout=%d", timeout
);
573 modem_write_cmd(cs
, MInit_2
, strlen(MInit_2
));
575 while(timeout
-- && cs
->hw
.elsa
.transcnt
)
577 debugl1(cs
, "msi tout=%d", timeout
);
579 modem_write_cmd(cs
, MInit_3
, strlen(MInit_3
));
581 while(timeout
-- && cs
->hw
.elsa
.transcnt
)
583 debugl1(cs
, "msi tout=%d", timeout
);
585 modem_write_cmd(cs
, MInit_4
, strlen(MInit_4
));
587 while(timeout
-- && cs
->hw
.elsa
.transcnt
)
589 debugl1(cs
, "msi tout=%d", timeout
);
591 modem_write_cmd(cs
, MInit_5
, strlen(MInit_5
));
593 while(timeout
-- && cs
->hw
.elsa
.transcnt
)
595 debugl1(cs
, "msi tout=%d", timeout
);
597 modem_write_cmd(cs
, MInit_6
, strlen(MInit_6
));
599 while(timeout
-- && cs
->hw
.elsa
.transcnt
)
601 debugl1(cs
, "msi tout=%d", timeout
);
603 modem_write_cmd(cs
, MInit_7
, strlen(MInit_7
));
605 while(timeout
-- && cs
->hw
.elsa
.transcnt
)
607 debugl1(cs
, "msi tout=%d", timeout
);
609 restore_flags(flags
);
613 modem_set_dial(struct IsdnCardState
*cs
, int outgoing
) {
616 #define RCV_DELAY 20000
620 modem_write_cmd(cs
, MInit_speed28800
, strlen(MInit_speed28800
));
622 while(timeout
-- && cs
->hw
.elsa
.transcnt
)
624 debugl1(cs
, "msi tout=%d", timeout
);
627 modem_write_cmd(cs
, MInit_dialout
, strlen(MInit_dialout
));
629 modem_write_cmd(cs
, MInit_dialin
, strlen(MInit_dialin
));
631 while(timeout
-- && cs
->hw
.elsa
.transcnt
)
633 debugl1(cs
, "msi tout=%d", timeout
);
635 restore_flags(flags
);
639 modem_l2l1(struct PStack
*st
, int pr
, void *arg
)
641 struct sk_buff
*skb
= arg
;
644 if (pr
== (PH_DATA
| REQUEST
)) {
647 if (st
->l1
.bcs
->tx_skb
) {
648 skb_queue_tail(&st
->l1
.bcs
->squeue
, skb
);
649 restore_flags(flags
);
651 st
->l1
.bcs
->tx_skb
= skb
;
652 test_and_set_bit(BC_FLG_BUSY
, &st
->l1
.bcs
->Flag
);
653 st
->l1
.bcs
->hw
.hscx
.count
= 0;
654 restore_flags(flags
);
655 write_modem(st
->l1
.bcs
);
657 } else if (pr
== (PH_ACTIVATE
| REQUEST
)) {
658 test_and_set_bit(BC_FLG_ACTIV
, &st
->l1
.bcs
->Flag
);
659 st
->l1
.l1l2(st
, PH_ACTIVATE
| CONFIRM
, NULL
);
660 set_arcofi(st
->l1
.bcs
->cs
, st
->l1
.bc
);
661 mstartup(st
->l1
.bcs
->cs
);
662 modem_set_dial(st
->l1
.bcs
->cs
, test_bit(FLG_ORIG
, &st
->l2
.flag
));
663 st
->l1
.bcs
->cs
->hw
.elsa
.MFlag
=2;
664 } else if (pr
== (PH_DEACTIVATE
| REQUEST
)) {
665 test_and_clear_bit(BC_FLG_ACTIV
, &st
->l1
.bcs
->Flag
);
666 send_arcofi(st
->l1
.bcs
->cs
, ARCOFI_XOP_0
, st
->l1
.bc
, 0);
667 st
->l1
.bcs
->cs
->hw
.elsa
.MFlag
=1;
669 printk(KERN_WARNING
"ElsaSer: unknown pr %x\n", pr
);
674 setstack_elsa(struct PStack
*st
, struct BCState
*bcs
)
677 bcs
->channel
= st
->l1
.bc
;
678 switch (st
->l1
.mode
) {
681 if (open_hscxstate(st
->l1
.hardware
, bcs
))
683 st
->l2
.l2l1
= hscx_l2l1
;
686 bcs
->mode
= L1_MODE_MODEM
;
687 if (!test_and_set_bit(BC_FLG_INIT
, &bcs
->Flag
)) {
688 bcs
->hw
.hscx
.rcvbuf
= bcs
->cs
->hw
.elsa
.rcvbuf
;
689 skb_queue_head_init(&bcs
->rqueue
);
690 skb_queue_head_init(&bcs
->squeue
);
693 test_and_clear_bit(BC_FLG_BUSY
, &bcs
->Flag
);
695 bcs
->hw
.hscx
.rcvidx
= 0;
697 bcs
->cs
->hw
.elsa
.bcs
= bcs
;
698 st
->l2
.l2l1
= modem_l2l1
;
702 setstack_manager(st
);
709 init_modem(struct IsdnCardState
*cs
) {
711 cs
->bcs
[0].BC_SetStack
= setstack_elsa
;
712 cs
->bcs
[1].BC_SetStack
= setstack_elsa
;
713 cs
->bcs
[0].BC_Close
= close_elsastate
;
714 cs
->bcs
[1].BC_Close
= close_elsastate
;
715 if (!(cs
->hw
.elsa
.rcvbuf
= kmalloc(MAX_MODEM_BUF
,
718 "Elsa: No modem mem hw.elsa.rcvbuf\n");
721 if (!(cs
->hw
.elsa
.transbuf
= kmalloc(MAX_MODEM_BUF
,
724 "Elsa: No modem mem hw.elsa.transbuf\n");
725 kfree(cs
->hw
.elsa
.rcvbuf
);
726 cs
->hw
.elsa
.rcvbuf
= NULL
;
730 printk(KERN_WARNING
"Elsa: problem startup modem\n");
736 release_modem(struct IsdnCardState
*cs
) {
738 cs
->hw
.elsa
.MFlag
= 0;
739 if (cs
->hw
.elsa
.transbuf
) {
740 if (cs
->hw
.elsa
.rcvbuf
) {
742 kfree(cs
->hw
.elsa
.rcvbuf
);
743 cs
->hw
.elsa
.rcvbuf
= NULL
;
745 kfree(cs
->hw
.elsa
.transbuf
);
746 cs
->hw
.elsa
.transbuf
= NULL
;