1 /* $Id: isac.c,v 1.31.2.3 2004/01/13 14:31:25 keil Exp $
3 * ISAC specific routines
6 * Copyright by Karsten Keil <keil@isdn4linux.de>
8 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference.
11 * For changes and modifications please read
12 * Documentation/isdn/HiSax.cert
20 #include <linux/interrupt.h>
21 #include <linux/init.h>
23 #define DBUSY_TIMER_VALUE 80
26 static char *ISACVer
[] __devinitdata
=
27 {"2086/2186 V1.1", "2085 B1", "2085 B2",
30 void __devinit
ISACVersion(struct IsdnCardState
*cs
, char *s
)
34 val
= cs
->readisac(cs
, ISAC_RBCH
);
35 printk(KERN_INFO
"%s ISAC version (%x): %s\n", s
, val
, ISACVer
[(val
>> 5) & 3]);
39 ph_command(struct IsdnCardState
*cs
, unsigned int command
)
41 if (cs
->debug
& L1_DEB_ISAC
)
42 debugl1(cs
, "ph_command %x", command
);
43 cs
->writeisac(cs
, ISAC_CIX0
, (command
<< 2) | 3);
48 isac_new_ph(struct IsdnCardState
*cs
)
50 switch (cs
->dc
.isac
.ph_state
) {
53 ph_command(cs
, ISAC_CMD_DUI
);
54 l1_msg(cs
, HW_RESET
| INDICATION
, NULL
);
57 l1_msg(cs
, HW_DEACTIVATE
| CONFIRM
, NULL
);
60 l1_msg(cs
, HW_DEACTIVATE
| INDICATION
, NULL
);
63 l1_msg(cs
, HW_POWERUP
| CONFIRM
, NULL
);
66 l1_msg(cs
, HW_RSYNC
| INDICATION
, NULL
);
69 l1_msg(cs
, HW_INFO2
| INDICATION
, NULL
);
72 l1_msg(cs
, HW_INFO4_P8
| INDICATION
, NULL
);
75 l1_msg(cs
, HW_INFO4_P10
| INDICATION
, NULL
);
83 isac_bh(struct work_struct
*work
)
85 struct IsdnCardState
*cs
=
86 container_of(work
, struct IsdnCardState
, tqueue
);
91 if (test_and_clear_bit(D_CLEARBUSY
, &cs
->event
)) {
93 debugl1(cs
, "D-Channel Busy cleared");
95 while (stptr
!= NULL
) {
96 stptr
->l1
.l1l2(stptr
, PH_PAUSE
| CONFIRM
, NULL
);
100 if (test_and_clear_bit(D_L1STATECHANGE
, &cs
->event
))
102 if (test_and_clear_bit(D_RCVBUFREADY
, &cs
->event
))
103 DChannel_proc_rcv(cs
);
104 if (test_and_clear_bit(D_XMTBUFREADY
, &cs
->event
))
105 DChannel_proc_xmt(cs
);
107 if (!test_bit(HW_ARCOFI
, &cs
->HW_Flags
))
109 if (test_and_clear_bit(D_RX_MON1
, &cs
->event
))
110 arcofi_fsm(cs
, ARCOFI_RX_END
, NULL
);
111 if (test_and_clear_bit(D_TX_MON1
, &cs
->event
))
112 arcofi_fsm(cs
, ARCOFI_TX_END
, NULL
);
117 isac_empty_fifo(struct IsdnCardState
*cs
, int count
)
121 if ((cs
->debug
& L1_DEB_ISAC
) && !(cs
->debug
& L1_DEB_ISAC_FIFO
))
122 debugl1(cs
, "isac_empty_fifo");
124 if ((cs
->rcvidx
+ count
) >= MAX_DFRAME_LEN_L1
) {
125 if (cs
->debug
& L1_DEB_WARN
)
126 debugl1(cs
, "isac_empty_fifo overrun %d",
128 cs
->writeisac(cs
, ISAC_CMDR
, 0x80);
132 ptr
= cs
->rcvbuf
+ cs
->rcvidx
;
134 cs
->readisacfifo(cs
, ptr
, count
);
135 cs
->writeisac(cs
, ISAC_CMDR
, 0x80);
136 if (cs
->debug
& L1_DEB_ISAC_FIFO
) {
139 t
+= sprintf(t
, "isac_empty_fifo cnt %d", count
);
140 QuickHex(t
, ptr
, count
);
141 debugl1(cs
, cs
->dlog
);
146 isac_fill_fifo(struct IsdnCardState
*cs
)
151 if ((cs
->debug
& L1_DEB_ISAC
) && !(cs
->debug
& L1_DEB_ISAC_FIFO
))
152 debugl1(cs
, "isac_fill_fifo");
157 count
= cs
->tx_skb
->len
;
166 ptr
= cs
->tx_skb
->data
;
167 skb_pull(cs
->tx_skb
, count
);
169 cs
->writeisacfifo(cs
, ptr
, count
);
170 cs
->writeisac(cs
, ISAC_CMDR
, more
? 0x8 : 0xa);
171 if (test_and_set_bit(FLG_DBUSY_TIMER
, &cs
->HW_Flags
)) {
172 debugl1(cs
, "isac_fill_fifo dbusytimer running");
173 del_timer(&cs
->dbusytimer
);
175 init_timer(&cs
->dbusytimer
);
176 cs
->dbusytimer
.expires
= jiffies
+ ((DBUSY_TIMER_VALUE
* HZ
)/1000);
177 add_timer(&cs
->dbusytimer
);
178 if (cs
->debug
& L1_DEB_ISAC_FIFO
) {
181 t
+= sprintf(t
, "isac_fill_fifo cnt %d", count
);
182 QuickHex(t
, ptr
, count
);
183 debugl1(cs
, cs
->dlog
);
188 isac_interrupt(struct IsdnCardState
*cs
, u_char val
)
194 if (cs
->debug
& L1_DEB_ISAC
)
195 debugl1(cs
, "ISAC interrupt %x", val
);
196 if (val
& 0x80) { /* RME */
197 exval
= cs
->readisac(cs
, ISAC_RSTA
);
198 if ((exval
& 0x70) != 0x20) {
200 if (cs
->debug
& L1_DEB_WARN
)
201 debugl1(cs
, "ISAC RDO");
202 #ifdef ERROR_STATISTIC
206 if (!(exval
& 0x20)) {
207 if (cs
->debug
& L1_DEB_WARN
)
208 debugl1(cs
, "ISAC CRC error");
209 #ifdef ERROR_STATISTIC
213 cs
->writeisac(cs
, ISAC_CMDR
, 0x80);
215 count
= cs
->readisac(cs
, ISAC_RBCL
) & 0x1f;
218 isac_empty_fifo(cs
, count
);
219 if ((count
= cs
->rcvidx
) > 0) {
221 if (!(skb
= alloc_skb(count
, GFP_ATOMIC
)))
222 printk(KERN_WARNING
"HiSax: D receive out of memory\n");
224 memcpy(skb_put(skb
, count
), cs
->rcvbuf
, count
);
225 skb_queue_tail(&cs
->rq
, skb
);
230 schedule_event(cs
, D_RCVBUFREADY
);
232 if (val
& 0x40) { /* RPF */
233 isac_empty_fifo(cs
, 32);
235 if (val
& 0x20) { /* RSC */
237 if (cs
->debug
& L1_DEB_WARN
)
238 debugl1(cs
, "ISAC RSC interrupt");
240 if (val
& 0x10) { /* XPR */
241 if (test_and_clear_bit(FLG_DBUSY_TIMER
, &cs
->HW_Flags
))
242 del_timer(&cs
->dbusytimer
);
243 if (test_and_clear_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
))
244 schedule_event(cs
, D_CLEARBUSY
);
246 if (cs
->tx_skb
->len
) {
250 dev_kfree_skb_irq(cs
->tx_skb
);
255 if ((cs
->tx_skb
= skb_dequeue(&cs
->sq
))) {
259 schedule_event(cs
, D_XMTBUFREADY
);
262 if (val
& 0x04) { /* CISQ */
263 exval
= cs
->readisac(cs
, ISAC_CIR0
);
264 if (cs
->debug
& L1_DEB_ISAC
)
265 debugl1(cs
, "ISAC CIR0 %02X", exval
);
267 cs
->dc
.isac
.ph_state
= (exval
>> 2) & 0xf;
268 if (cs
->debug
& L1_DEB_ISAC
)
269 debugl1(cs
, "ph_state change %x", cs
->dc
.isac
.ph_state
);
270 schedule_event(cs
, D_L1STATECHANGE
);
273 exval
= cs
->readisac(cs
, ISAC_CIR1
);
274 if (cs
->debug
& L1_DEB_ISAC
)
275 debugl1(cs
, "ISAC CIR1 %02X", exval
);
278 if (val
& 0x02) { /* SIN */
280 if (cs
->debug
& L1_DEB_WARN
)
281 debugl1(cs
, "ISAC SIN interrupt");
283 if (val
& 0x01) { /* EXI */
284 exval
= cs
->readisac(cs
, ISAC_EXIR
);
285 if (cs
->debug
& L1_DEB_WARN
)
286 debugl1(cs
, "ISAC EXIR %02x", exval
);
287 if (exval
& 0x80) { /* XMR */
288 debugl1(cs
, "ISAC XMR");
289 printk(KERN_WARNING
"HiSax: ISAC XMR\n");
291 if (exval
& 0x40) { /* XDU */
292 debugl1(cs
, "ISAC XDU");
293 printk(KERN_WARNING
"HiSax: ISAC XDU\n");
294 #ifdef ERROR_STATISTIC
297 if (test_and_clear_bit(FLG_DBUSY_TIMER
, &cs
->HW_Flags
))
298 del_timer(&cs
->dbusytimer
);
299 if (test_and_clear_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
))
300 schedule_event(cs
, D_CLEARBUSY
);
301 if (cs
->tx_skb
) { /* Restart frame */
302 skb_push(cs
->tx_skb
, cs
->tx_cnt
);
306 printk(KERN_WARNING
"HiSax: ISAC XDU no skb\n");
307 debugl1(cs
, "ISAC XDU no skb");
310 if (exval
& 0x04) { /* MOS */
311 v1
= cs
->readisac(cs
, ISAC_MOSR
);
312 if (cs
->debug
& L1_DEB_MONITOR
)
313 debugl1(cs
, "ISAC MOSR %02x", v1
);
316 if (!cs
->dc
.isac
.mon_rx
) {
317 if (!(cs
->dc
.isac
.mon_rx
= kmalloc(MAX_MON_FRAME
, GFP_ATOMIC
))) {
318 if (cs
->debug
& L1_DEB_WARN
)
319 debugl1(cs
, "ISAC MON RX out of memory!");
320 cs
->dc
.isac
.mocr
&= 0xf0;
321 cs
->dc
.isac
.mocr
|= 0x0a;
322 cs
->writeisac(cs
, ISAC_MOCR
, cs
->dc
.isac
.mocr
);
325 cs
->dc
.isac
.mon_rxp
= 0;
327 if (cs
->dc
.isac
.mon_rxp
>= MAX_MON_FRAME
) {
328 cs
->dc
.isac
.mocr
&= 0xf0;
329 cs
->dc
.isac
.mocr
|= 0x0a;
330 cs
->writeisac(cs
, ISAC_MOCR
, cs
->dc
.isac
.mocr
);
331 cs
->dc
.isac
.mon_rxp
= 0;
332 if (cs
->debug
& L1_DEB_WARN
)
333 debugl1(cs
, "ISAC MON RX overflow!");
336 cs
->dc
.isac
.mon_rx
[cs
->dc
.isac
.mon_rxp
++] = cs
->readisac(cs
, ISAC_MOR0
);
337 if (cs
->debug
& L1_DEB_MONITOR
)
338 debugl1(cs
, "ISAC MOR0 %02x", cs
->dc
.isac
.mon_rx
[cs
->dc
.isac
.mon_rxp
-1]);
339 if (cs
->dc
.isac
.mon_rxp
== 1) {
340 cs
->dc
.isac
.mocr
|= 0x04;
341 cs
->writeisac(cs
, ISAC_MOCR
, cs
->dc
.isac
.mocr
);
346 if (!cs
->dc
.isac
.mon_rx
) {
347 if (!(cs
->dc
.isac
.mon_rx
= kmalloc(MAX_MON_FRAME
, GFP_ATOMIC
))) {
348 if (cs
->debug
& L1_DEB_WARN
)
349 debugl1(cs
, "ISAC MON RX out of memory!");
350 cs
->dc
.isac
.mocr
&= 0x0f;
351 cs
->dc
.isac
.mocr
|= 0xa0;
352 cs
->writeisac(cs
, ISAC_MOCR
, cs
->dc
.isac
.mocr
);
355 cs
->dc
.isac
.mon_rxp
= 0;
357 if (cs
->dc
.isac
.mon_rxp
>= MAX_MON_FRAME
) {
358 cs
->dc
.isac
.mocr
&= 0x0f;
359 cs
->dc
.isac
.mocr
|= 0xa0;
360 cs
->writeisac(cs
, ISAC_MOCR
, cs
->dc
.isac
.mocr
);
361 cs
->dc
.isac
.mon_rxp
= 0;
362 if (cs
->debug
& L1_DEB_WARN
)
363 debugl1(cs
, "ISAC MON RX overflow!");
366 cs
->dc
.isac
.mon_rx
[cs
->dc
.isac
.mon_rxp
++] = cs
->readisac(cs
, ISAC_MOR1
);
367 if (cs
->debug
& L1_DEB_MONITOR
)
368 debugl1(cs
, "ISAC MOR1 %02x", cs
->dc
.isac
.mon_rx
[cs
->dc
.isac
.mon_rxp
-1]);
369 cs
->dc
.isac
.mocr
|= 0x40;
370 cs
->writeisac(cs
, ISAC_MOCR
, cs
->dc
.isac
.mocr
);
374 cs
->dc
.isac
.mocr
&= 0xf0;
375 cs
->writeisac(cs
, ISAC_MOCR
, cs
->dc
.isac
.mocr
);
376 cs
->dc
.isac
.mocr
|= 0x0a;
377 cs
->writeisac(cs
, ISAC_MOCR
, cs
->dc
.isac
.mocr
);
378 schedule_event(cs
, D_RX_MON0
);
381 cs
->dc
.isac
.mocr
&= 0x0f;
382 cs
->writeisac(cs
, ISAC_MOCR
, cs
->dc
.isac
.mocr
);
383 cs
->dc
.isac
.mocr
|= 0xa0;
384 cs
->writeisac(cs
, ISAC_MOCR
, cs
->dc
.isac
.mocr
);
385 schedule_event(cs
, D_RX_MON1
);
388 if ((!cs
->dc
.isac
.mon_tx
) || (cs
->dc
.isac
.mon_txc
&&
389 (cs
->dc
.isac
.mon_txp
>= cs
->dc
.isac
.mon_txc
) &&
391 cs
->dc
.isac
.mocr
&= 0xf0;
392 cs
->writeisac(cs
, ISAC_MOCR
, cs
->dc
.isac
.mocr
);
393 cs
->dc
.isac
.mocr
|= 0x0a;
394 cs
->writeisac(cs
, ISAC_MOCR
, cs
->dc
.isac
.mocr
);
395 if (cs
->dc
.isac
.mon_txc
&&
396 (cs
->dc
.isac
.mon_txp
>= cs
->dc
.isac
.mon_txc
))
397 schedule_event(cs
, D_TX_MON0
);
400 if (cs
->dc
.isac
.mon_txc
&& (cs
->dc
.isac
.mon_txp
>= cs
->dc
.isac
.mon_txc
)) {
401 schedule_event(cs
, D_TX_MON0
);
404 cs
->writeisac(cs
, ISAC_MOX0
,
405 cs
->dc
.isac
.mon_tx
[cs
->dc
.isac
.mon_txp
++]);
406 if (cs
->debug
& L1_DEB_MONITOR
)
407 debugl1(cs
, "ISAC %02x -> MOX0", cs
->dc
.isac
.mon_tx
[cs
->dc
.isac
.mon_txp
-1]);
411 if ((!cs
->dc
.isac
.mon_tx
) || (cs
->dc
.isac
.mon_txc
&&
412 (cs
->dc
.isac
.mon_txp
>= cs
->dc
.isac
.mon_txc
) &&
414 cs
->dc
.isac
.mocr
&= 0x0f;
415 cs
->writeisac(cs
, ISAC_MOCR
, cs
->dc
.isac
.mocr
);
416 cs
->dc
.isac
.mocr
|= 0xa0;
417 cs
->writeisac(cs
, ISAC_MOCR
, cs
->dc
.isac
.mocr
);
418 if (cs
->dc
.isac
.mon_txc
&&
419 (cs
->dc
.isac
.mon_txp
>= cs
->dc
.isac
.mon_txc
))
420 schedule_event(cs
, D_TX_MON1
);
423 if (cs
->dc
.isac
.mon_txc
&& (cs
->dc
.isac
.mon_txp
>= cs
->dc
.isac
.mon_txc
)) {
424 schedule_event(cs
, D_TX_MON1
);
427 cs
->writeisac(cs
, ISAC_MOX1
,
428 cs
->dc
.isac
.mon_tx
[cs
->dc
.isac
.mon_txp
++]);
429 if (cs
->debug
& L1_DEB_MONITOR
)
430 debugl1(cs
, "ISAC %02x -> MOX1", cs
->dc
.isac
.mon_tx
[cs
->dc
.isac
.mon_txp
-1]);
439 ISAC_l1hw(struct PStack
*st
, int pr
, void *arg
)
441 struct IsdnCardState
*cs
= (struct IsdnCardState
*) st
->l1
.hardware
;
442 struct sk_buff
*skb
= arg
;
447 case (PH_DATA
|REQUEST
):
448 if (cs
->debug
& DEB_DLOG_HEX
)
449 LogFrame(cs
, skb
->data
, skb
->len
);
450 if (cs
->debug
& DEB_DLOG_VERBOSE
)
451 dlogframe(cs
, skb
, 0);
452 spin_lock_irqsave(&cs
->lock
, flags
);
454 skb_queue_tail(&cs
->sq
, skb
);
455 #ifdef L2FRAME_DEBUG /* psa */
456 if (cs
->debug
& L1_DEB_LAPD
)
457 Logl2Frame(cs
, skb
, "PH_DATA Queued", 0);
462 #ifdef L2FRAME_DEBUG /* psa */
463 if (cs
->debug
& L1_DEB_LAPD
)
464 Logl2Frame(cs
, skb
, "PH_DATA", 0);
468 spin_unlock_irqrestore(&cs
->lock
, flags
);
470 case (PH_PULL
|INDICATION
):
471 spin_lock_irqsave(&cs
->lock
, flags
);
473 if (cs
->debug
& L1_DEB_WARN
)
474 debugl1(cs
, " l2l1 tx_skb exist this shouldn't happen");
475 skb_queue_tail(&cs
->sq
, skb
);
477 if (cs
->debug
& DEB_DLOG_HEX
)
478 LogFrame(cs
, skb
->data
, skb
->len
);
479 if (cs
->debug
& DEB_DLOG_VERBOSE
)
480 dlogframe(cs
, skb
, 0);
483 #ifdef L2FRAME_DEBUG /* psa */
484 if (cs
->debug
& L1_DEB_LAPD
)
485 Logl2Frame(cs
, skb
, "PH_DATA_PULLED", 0);
489 spin_unlock_irqrestore(&cs
->lock
, flags
);
491 case (PH_PULL
| REQUEST
):
492 #ifdef L2FRAME_DEBUG /* psa */
493 if (cs
->debug
& L1_DEB_LAPD
)
494 debugl1(cs
, "-> PH_REQUEST_PULL");
497 test_and_clear_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
);
498 st
->l1
.l1l2(st
, PH_PULL
| CONFIRM
, NULL
);
500 test_and_set_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
);
502 case (HW_RESET
| REQUEST
):
503 spin_lock_irqsave(&cs
->lock
, flags
);
504 if ((cs
->dc
.isac
.ph_state
== ISAC_IND_EI
) ||
505 (cs
->dc
.isac
.ph_state
== ISAC_IND_DR
) ||
506 (cs
->dc
.isac
.ph_state
== ISAC_IND_RS
))
507 ph_command(cs
, ISAC_CMD_TIM
);
509 ph_command(cs
, ISAC_CMD_RS
);
510 spin_unlock_irqrestore(&cs
->lock
, flags
);
512 case (HW_ENABLE
| REQUEST
):
513 spin_lock_irqsave(&cs
->lock
, flags
);
514 ph_command(cs
, ISAC_CMD_TIM
);
515 spin_unlock_irqrestore(&cs
->lock
, flags
);
517 case (HW_INFO3
| REQUEST
):
518 spin_lock_irqsave(&cs
->lock
, flags
);
519 ph_command(cs
, ISAC_CMD_AR8
);
520 spin_unlock_irqrestore(&cs
->lock
, flags
);
522 case (HW_TESTLOOP
| REQUEST
):
523 spin_lock_irqsave(&cs
->lock
, flags
);
529 if (test_bit(HW_IOM1
, &cs
->HW_Flags
)) {
532 cs
->writeisac(cs
, ISAC_SPCR
, 0xa);
533 cs
->writeisac(cs
, ISAC_ADF1
, 0x2);
535 cs
->writeisac(cs
, ISAC_SPCR
, val
);
536 cs
->writeisac(cs
, ISAC_ADF1
, 0xa);
540 cs
->writeisac(cs
, ISAC_SPCR
, val
);
542 cs
->writeisac(cs
, ISAC_ADF1
, 0x8);
544 cs
->writeisac(cs
, ISAC_ADF1
, 0x0);
546 spin_unlock_irqrestore(&cs
->lock
, flags
);
548 case (HW_DEACTIVATE
| RESPONSE
):
549 skb_queue_purge(&cs
->rq
);
550 skb_queue_purge(&cs
->sq
);
552 dev_kfree_skb_any(cs
->tx_skb
);
555 if (test_and_clear_bit(FLG_DBUSY_TIMER
, &cs
->HW_Flags
))
556 del_timer(&cs
->dbusytimer
);
557 if (test_and_clear_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
))
558 schedule_event(cs
, D_CLEARBUSY
);
561 if (cs
->debug
& L1_DEB_WARN
)
562 debugl1(cs
, "isac_l1hw unknown %04x", pr
);
568 setstack_isac(struct PStack
*st
, struct IsdnCardState
*cs
)
570 st
->l1
.l1hw
= ISAC_l1hw
;
574 DC_Close_isac(struct IsdnCardState
*cs
)
576 kfree(cs
->dc
.isac
.mon_rx
);
577 cs
->dc
.isac
.mon_rx
= NULL
;
578 kfree(cs
->dc
.isac
.mon_tx
);
579 cs
->dc
.isac
.mon_tx
= NULL
;
583 dbusy_timer_handler(struct IsdnCardState
*cs
)
585 struct PStack
*stptr
;
588 if (test_bit(FLG_DBUSY_TIMER
, &cs
->HW_Flags
)) {
589 rbch
= cs
->readisac(cs
, ISAC_RBCH
);
590 star
= cs
->readisac(cs
, ISAC_STAR
);
592 debugl1(cs
, "D-Channel Busy RBCH %02x STAR %02x",
594 if (rbch
& ISAC_RBCH_XAC
) { /* D-Channel Busy */
595 test_and_set_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
);
597 while (stptr
!= NULL
) {
598 stptr
->l1
.l1l2(stptr
, PH_PAUSE
| INDICATION
, NULL
);
602 /* discard frame; reset transceiver */
603 test_and_clear_bit(FLG_DBUSY_TIMER
, &cs
->HW_Flags
);
605 dev_kfree_skb_any(cs
->tx_skb
);
609 printk(KERN_WARNING
"HiSax: ISAC D-Channel Busy no skb\n");
610 debugl1(cs
, "D-Channel Busy no skb");
612 cs
->writeisac(cs
, ISAC_CMDR
, 0x01); /* Transmitter reset */
613 cs
->irq_func(cs
->irq
, cs
);
618 void initisac(struct IsdnCardState
*cs
)
620 cs
->setstack_d
= setstack_isac
;
621 cs
->DC_Close
= DC_Close_isac
;
622 cs
->dc
.isac
.mon_tx
= NULL
;
623 cs
->dc
.isac
.mon_rx
= NULL
;
624 cs
->writeisac(cs
, ISAC_MASK
, 0xff);
625 cs
->dc
.isac
.mocr
= 0xaa;
626 if (test_bit(HW_IOM1
, &cs
->HW_Flags
)) {
628 cs
->writeisac(cs
, ISAC_ADF2
, 0x0);
629 cs
->writeisac(cs
, ISAC_SPCR
, 0xa);
630 cs
->writeisac(cs
, ISAC_ADF1
, 0x2);
631 cs
->writeisac(cs
, ISAC_STCR
, 0x70);
632 cs
->writeisac(cs
, ISAC_MODE
, 0xc9);
635 if (!cs
->dc
.isac
.adf2
)
636 cs
->dc
.isac
.adf2
= 0x80;
637 cs
->writeisac(cs
, ISAC_ADF2
, cs
->dc
.isac
.adf2
);
638 cs
->writeisac(cs
, ISAC_SQXR
, 0x2f);
639 cs
->writeisac(cs
, ISAC_SPCR
, 0x00);
640 cs
->writeisac(cs
, ISAC_STCR
, 0x70);
641 cs
->writeisac(cs
, ISAC_MODE
, 0xc9);
642 cs
->writeisac(cs
, ISAC_TIMR
, 0x00);
643 cs
->writeisac(cs
, ISAC_ADF1
, 0x00);
645 ph_command(cs
, ISAC_CMD_RS
);
646 cs
->writeisac(cs
, ISAC_MASK
, 0x0);
649 void clear_pending_isac_ints(struct IsdnCardState
*cs
)
653 val
= cs
->readisac(cs
, ISAC_STAR
);
654 debugl1(cs
, "ISAC STAR %x", val
);
655 val
= cs
->readisac(cs
, ISAC_MODE
);
656 debugl1(cs
, "ISAC MODE %x", val
);
657 val
= cs
->readisac(cs
, ISAC_ADF2
);
658 debugl1(cs
, "ISAC ADF2 %x", val
);
659 val
= cs
->readisac(cs
, ISAC_ISTA
);
660 debugl1(cs
, "ISAC ISTA %x", val
);
662 eval
= cs
->readisac(cs
, ISAC_EXIR
);
663 debugl1(cs
, "ISAC EXIR %x", eval
);
665 val
= cs
->readisac(cs
, ISAC_CIR0
);
666 debugl1(cs
, "ISAC CIR0 %x", val
);
667 cs
->dc
.isac
.ph_state
= (val
>> 2) & 0xf;
668 schedule_event(cs
, D_L1STATECHANGE
);
669 /* Disable all IRQ */
670 cs
->writeisac(cs
, ISAC_MASK
, 0xFF);
674 setup_isac(struct IsdnCardState
*cs
)
676 INIT_WORK(&cs
->tqueue
, isac_bh
);
677 cs
->dbusytimer
.function
= (void *) dbusy_timer_handler
;
678 cs
->dbusytimer
.data
= (long) cs
;
679 init_timer(&cs
->dbusytimer
);