1 /* $Id: icc.c,v 1.8.2.3 2004/01/13 14:31:25 keil Exp $
3 * ICC specific routines
5 * Author Matt Henderson & Guy Ellis
6 * Copyright by Traverse Technologies Pty Ltd, www.travers.com.au
8 * This software may be used and distributed according to the terms
9 * of the GNU General Public License, incorporated herein by reference.
11 * 1999.6.25 Initial implementation of routines for Siemens ISDN
12 * Communication Controller PEB 2070 based on the ISAC routines
13 * written by Karsten Keil.
17 #include <linux/init.h>
20 // #include "arcofi.h"
22 #include <linux/interrupt.h>
24 #define DBUSY_TIMER_VALUE 80
27 static char *ICCVer
[] =
28 {"2070 A1/A3", "2070 B1", "2070 B2/B3", "2070 V2.4"};
31 ICCVersion(struct IsdnCardState
*cs
, char *s
)
35 val
= cs
->readisac(cs
, ICC_RBCH
);
36 printk(KERN_INFO
"%s ICC version (%x): %s\n", s
, val
, ICCVer
[(val
>> 5) & 3]);
40 ph_command(struct IsdnCardState
*cs
, unsigned int command
)
42 if (cs
->debug
& L1_DEB_ISAC
)
43 debugl1(cs
, "ph_command %x", command
);
44 cs
->writeisac(cs
, ICC_CIX0
, (command
<< 2) | 3);
49 icc_new_ph(struct IsdnCardState
*cs
)
51 switch (cs
->dc
.icc
.ph_state
) {
53 ph_command(cs
, ICC_CMD_DI
);
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
| INDICATION
, NULL
);
80 icc_bh(struct work_struct
*work
)
82 struct IsdnCardState
*cs
=
83 container_of(work
, struct IsdnCardState
, tqueue
);
88 if (test_and_clear_bit(D_CLEARBUSY
, &cs
->event
)) {
90 debugl1(cs
, "D-Channel Busy cleared");
92 while (stptr
!= NULL
) {
93 stptr
->l1
.l1l2(stptr
, PH_PAUSE
| CONFIRM
, NULL
);
97 if (test_and_clear_bit(D_L1STATECHANGE
, &cs
->event
))
99 if (test_and_clear_bit(D_RCVBUFREADY
, &cs
->event
))
100 DChannel_proc_rcv(cs
);
101 if (test_and_clear_bit(D_XMTBUFREADY
, &cs
->event
))
102 DChannel_proc_xmt(cs
);
104 if (!test_bit(HW_ARCOFI
, &cs
->HW_Flags
))
106 if (test_and_clear_bit(D_RX_MON1
, &cs
->event
))
107 arcofi_fsm(cs
, ARCOFI_RX_END
, NULL
);
108 if (test_and_clear_bit(D_TX_MON1
, &cs
->event
))
109 arcofi_fsm(cs
, ARCOFI_TX_END
, NULL
);
114 icc_empty_fifo(struct IsdnCardState
*cs
, int count
)
118 if ((cs
->debug
& L1_DEB_ISAC
) && !(cs
->debug
& L1_DEB_ISAC_FIFO
))
119 debugl1(cs
, "icc_empty_fifo");
121 if ((cs
->rcvidx
+ count
) >= MAX_DFRAME_LEN_L1
) {
122 if (cs
->debug
& L1_DEB_WARN
)
123 debugl1(cs
, "icc_empty_fifo overrun %d",
125 cs
->writeisac(cs
, ICC_CMDR
, 0x80);
129 ptr
= cs
->rcvbuf
+ cs
->rcvidx
;
131 cs
->readisacfifo(cs
, ptr
, count
);
132 cs
->writeisac(cs
, ICC_CMDR
, 0x80);
133 if (cs
->debug
& L1_DEB_ISAC_FIFO
) {
136 t
+= sprintf(t
, "icc_empty_fifo cnt %d", count
);
137 QuickHex(t
, ptr
, count
);
138 debugl1(cs
, cs
->dlog
);
143 icc_fill_fifo(struct IsdnCardState
*cs
)
148 if ((cs
->debug
& L1_DEB_ISAC
) && !(cs
->debug
& L1_DEB_ISAC_FIFO
))
149 debugl1(cs
, "icc_fill_fifo");
154 count
= cs
->tx_skb
->len
;
163 ptr
= cs
->tx_skb
->data
;
164 skb_pull(cs
->tx_skb
, count
);
166 cs
->writeisacfifo(cs
, ptr
, count
);
167 cs
->writeisac(cs
, ICC_CMDR
, more
? 0x8 : 0xa);
168 if (test_and_set_bit(FLG_DBUSY_TIMER
, &cs
->HW_Flags
)) {
169 debugl1(cs
, "icc_fill_fifo dbusytimer running");
170 del_timer(&cs
->dbusytimer
);
172 init_timer(&cs
->dbusytimer
);
173 cs
->dbusytimer
.expires
= jiffies
+ ((DBUSY_TIMER_VALUE
* HZ
)/1000);
174 add_timer(&cs
->dbusytimer
);
175 if (cs
->debug
& L1_DEB_ISAC_FIFO
) {
178 t
+= sprintf(t
, "icc_fill_fifo cnt %d", count
);
179 QuickHex(t
, ptr
, count
);
180 debugl1(cs
, cs
->dlog
);
185 icc_interrupt(struct IsdnCardState
*cs
, u_char val
)
191 if (cs
->debug
& L1_DEB_ISAC
)
192 debugl1(cs
, "ICC interrupt %x", val
);
193 if (val
& 0x80) { /* RME */
194 exval
= cs
->readisac(cs
, ICC_RSTA
);
195 if ((exval
& 0x70) != 0x20) {
197 if (cs
->debug
& L1_DEB_WARN
)
198 debugl1(cs
, "ICC RDO");
199 #ifdef ERROR_STATISTIC
203 if (!(exval
& 0x20)) {
204 if (cs
->debug
& L1_DEB_WARN
)
205 debugl1(cs
, "ICC CRC error");
206 #ifdef ERROR_STATISTIC
210 cs
->writeisac(cs
, ICC_CMDR
, 0x80);
212 count
= cs
->readisac(cs
, ICC_RBCL
) & 0x1f;
215 icc_empty_fifo(cs
, count
);
216 if ((count
= cs
->rcvidx
) > 0) {
218 if (!(skb
= alloc_skb(count
, GFP_ATOMIC
)))
219 printk(KERN_WARNING
"HiSax: D receive out of memory\n");
221 memcpy(skb_put(skb
, count
), cs
->rcvbuf
, count
);
222 skb_queue_tail(&cs
->rq
, skb
);
227 schedule_event(cs
, D_RCVBUFREADY
);
229 if (val
& 0x40) { /* RPF */
230 icc_empty_fifo(cs
, 32);
232 if (val
& 0x20) { /* RSC */
234 if (cs
->debug
& L1_DEB_WARN
)
235 debugl1(cs
, "ICC RSC interrupt");
237 if (val
& 0x10) { /* XPR */
238 if (test_and_clear_bit(FLG_DBUSY_TIMER
, &cs
->HW_Flags
))
239 del_timer(&cs
->dbusytimer
);
240 if (test_and_clear_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
))
241 schedule_event(cs
, D_CLEARBUSY
);
243 if (cs
->tx_skb
->len
) {
247 dev_kfree_skb_irq(cs
->tx_skb
);
252 if ((cs
->tx_skb
= skb_dequeue(&cs
->sq
))) {
256 schedule_event(cs
, D_XMTBUFREADY
);
259 if (val
& 0x04) { /* CISQ */
260 exval
= cs
->readisac(cs
, ICC_CIR0
);
261 if (cs
->debug
& L1_DEB_ISAC
)
262 debugl1(cs
, "ICC CIR0 %02X", exval
);
264 cs
->dc
.icc
.ph_state
= (exval
>> 2) & 0xf;
265 if (cs
->debug
& L1_DEB_ISAC
)
266 debugl1(cs
, "ph_state change %x", cs
->dc
.icc
.ph_state
);
267 schedule_event(cs
, D_L1STATECHANGE
);
270 exval
= cs
->readisac(cs
, ICC_CIR1
);
271 if (cs
->debug
& L1_DEB_ISAC
)
272 debugl1(cs
, "ICC CIR1 %02X", exval
);
275 if (val
& 0x02) { /* SIN */
277 if (cs
->debug
& L1_DEB_WARN
)
278 debugl1(cs
, "ICC SIN interrupt");
280 if (val
& 0x01) { /* EXI */
281 exval
= cs
->readisac(cs
, ICC_EXIR
);
282 if (cs
->debug
& L1_DEB_WARN
)
283 debugl1(cs
, "ICC EXIR %02x", exval
);
284 if (exval
& 0x80) { /* XMR */
285 debugl1(cs
, "ICC XMR");
286 printk(KERN_WARNING
"HiSax: ICC XMR\n");
288 if (exval
& 0x40) { /* XDU */
289 debugl1(cs
, "ICC XDU");
290 printk(KERN_WARNING
"HiSax: ICC XDU\n");
291 #ifdef ERROR_STATISTIC
294 if (test_and_clear_bit(FLG_DBUSY_TIMER
, &cs
->HW_Flags
))
295 del_timer(&cs
->dbusytimer
);
296 if (test_and_clear_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
))
297 schedule_event(cs
, D_CLEARBUSY
);
298 if (cs
->tx_skb
) { /* Restart frame */
299 skb_push(cs
->tx_skb
, cs
->tx_cnt
);
303 printk(KERN_WARNING
"HiSax: ICC XDU no skb\n");
304 debugl1(cs
, "ICC XDU no skb");
307 if (exval
& 0x04) { /* MOS */
308 v1
= cs
->readisac(cs
, ICC_MOSR
);
309 if (cs
->debug
& L1_DEB_MONITOR
)
310 debugl1(cs
, "ICC MOSR %02x", v1
);
313 if (!cs
->dc
.icc
.mon_rx
) {
314 if (!(cs
->dc
.icc
.mon_rx
= kmalloc(MAX_MON_FRAME
, GFP_ATOMIC
))) {
315 if (cs
->debug
& L1_DEB_WARN
)
316 debugl1(cs
, "ICC MON RX out of memory!");
317 cs
->dc
.icc
.mocr
&= 0xf0;
318 cs
->dc
.icc
.mocr
|= 0x0a;
319 cs
->writeisac(cs
, ICC_MOCR
, cs
->dc
.icc
.mocr
);
322 cs
->dc
.icc
.mon_rxp
= 0;
324 if (cs
->dc
.icc
.mon_rxp
>= MAX_MON_FRAME
) {
325 cs
->dc
.icc
.mocr
&= 0xf0;
326 cs
->dc
.icc
.mocr
|= 0x0a;
327 cs
->writeisac(cs
, ICC_MOCR
, cs
->dc
.icc
.mocr
);
328 cs
->dc
.icc
.mon_rxp
= 0;
329 if (cs
->debug
& L1_DEB_WARN
)
330 debugl1(cs
, "ICC MON RX overflow!");
333 cs
->dc
.icc
.mon_rx
[cs
->dc
.icc
.mon_rxp
++] = cs
->readisac(cs
, ICC_MOR0
);
334 if (cs
->debug
& L1_DEB_MONITOR
)
335 debugl1(cs
, "ICC MOR0 %02x", cs
->dc
.icc
.mon_rx
[cs
->dc
.icc
.mon_rxp
-1]);
336 if (cs
->dc
.icc
.mon_rxp
== 1) {
337 cs
->dc
.icc
.mocr
|= 0x04;
338 cs
->writeisac(cs
, ICC_MOCR
, cs
->dc
.icc
.mocr
);
343 if (!cs
->dc
.icc
.mon_rx
) {
344 if (!(cs
->dc
.icc
.mon_rx
= kmalloc(MAX_MON_FRAME
, GFP_ATOMIC
))) {
345 if (cs
->debug
& L1_DEB_WARN
)
346 debugl1(cs
, "ICC MON RX out of memory!");
347 cs
->dc
.icc
.mocr
&= 0x0f;
348 cs
->dc
.icc
.mocr
|= 0xa0;
349 cs
->writeisac(cs
, ICC_MOCR
, cs
->dc
.icc
.mocr
);
352 cs
->dc
.icc
.mon_rxp
= 0;
354 if (cs
->dc
.icc
.mon_rxp
>= MAX_MON_FRAME
) {
355 cs
->dc
.icc
.mocr
&= 0x0f;
356 cs
->dc
.icc
.mocr
|= 0xa0;
357 cs
->writeisac(cs
, ICC_MOCR
, cs
->dc
.icc
.mocr
);
358 cs
->dc
.icc
.mon_rxp
= 0;
359 if (cs
->debug
& L1_DEB_WARN
)
360 debugl1(cs
, "ICC MON RX overflow!");
363 cs
->dc
.icc
.mon_rx
[cs
->dc
.icc
.mon_rxp
++] = cs
->readisac(cs
, ICC_MOR1
);
364 if (cs
->debug
& L1_DEB_MONITOR
)
365 debugl1(cs
, "ICC MOR1 %02x", cs
->dc
.icc
.mon_rx
[cs
->dc
.icc
.mon_rxp
-1]);
366 cs
->dc
.icc
.mocr
|= 0x40;
367 cs
->writeisac(cs
, ICC_MOCR
, cs
->dc
.icc
.mocr
);
371 cs
->dc
.icc
.mocr
&= 0xf0;
372 cs
->writeisac(cs
, ICC_MOCR
, cs
->dc
.icc
.mocr
);
373 cs
->dc
.icc
.mocr
|= 0x0a;
374 cs
->writeisac(cs
, ICC_MOCR
, cs
->dc
.icc
.mocr
);
375 schedule_event(cs
, D_RX_MON0
);
378 cs
->dc
.icc
.mocr
&= 0x0f;
379 cs
->writeisac(cs
, ICC_MOCR
, cs
->dc
.icc
.mocr
);
380 cs
->dc
.icc
.mocr
|= 0xa0;
381 cs
->writeisac(cs
, ICC_MOCR
, cs
->dc
.icc
.mocr
);
382 schedule_event(cs
, D_RX_MON1
);
385 if ((!cs
->dc
.icc
.mon_tx
) || (cs
->dc
.icc
.mon_txc
&&
386 (cs
->dc
.icc
.mon_txp
>= cs
->dc
.icc
.mon_txc
) &&
388 cs
->dc
.icc
.mocr
&= 0xf0;
389 cs
->writeisac(cs
, ICC_MOCR
, cs
->dc
.icc
.mocr
);
390 cs
->dc
.icc
.mocr
|= 0x0a;
391 cs
->writeisac(cs
, ICC_MOCR
, cs
->dc
.icc
.mocr
);
392 if (cs
->dc
.icc
.mon_txc
&&
393 (cs
->dc
.icc
.mon_txp
>= cs
->dc
.icc
.mon_txc
))
394 schedule_event(cs
, D_TX_MON0
);
397 if (cs
->dc
.icc
.mon_txc
&& (cs
->dc
.icc
.mon_txp
>= cs
->dc
.icc
.mon_txc
)) {
398 schedule_event(cs
, D_TX_MON0
);
401 cs
->writeisac(cs
, ICC_MOX0
,
402 cs
->dc
.icc
.mon_tx
[cs
->dc
.icc
.mon_txp
++]);
403 if (cs
->debug
& L1_DEB_MONITOR
)
404 debugl1(cs
, "ICC %02x -> MOX0", cs
->dc
.icc
.mon_tx
[cs
->dc
.icc
.mon_txp
-1]);
408 if ((!cs
->dc
.icc
.mon_tx
) || (cs
->dc
.icc
.mon_txc
&&
409 (cs
->dc
.icc
.mon_txp
>= cs
->dc
.icc
.mon_txc
) &&
411 cs
->dc
.icc
.mocr
&= 0x0f;
412 cs
->writeisac(cs
, ICC_MOCR
, cs
->dc
.icc
.mocr
);
413 cs
->dc
.icc
.mocr
|= 0xa0;
414 cs
->writeisac(cs
, ICC_MOCR
, cs
->dc
.icc
.mocr
);
415 if (cs
->dc
.icc
.mon_txc
&&
416 (cs
->dc
.icc
.mon_txp
>= cs
->dc
.icc
.mon_txc
))
417 schedule_event(cs
, D_TX_MON1
);
420 if (cs
->dc
.icc
.mon_txc
&& (cs
->dc
.icc
.mon_txp
>= cs
->dc
.icc
.mon_txc
)) {
421 schedule_event(cs
, D_TX_MON1
);
424 cs
->writeisac(cs
, ICC_MOX1
,
425 cs
->dc
.icc
.mon_tx
[cs
->dc
.icc
.mon_txp
++]);
426 if (cs
->debug
& L1_DEB_MONITOR
)
427 debugl1(cs
, "ICC %02x -> MOX1", cs
->dc
.icc
.mon_tx
[cs
->dc
.icc
.mon_txp
-1]);
436 ICC_l1hw(struct PStack
*st
, int pr
, void *arg
)
438 struct IsdnCardState
*cs
= (struct IsdnCardState
*) st
->l1
.hardware
;
439 struct sk_buff
*skb
= arg
;
444 case (PH_DATA
|REQUEST
):
445 if (cs
->debug
& DEB_DLOG_HEX
)
446 LogFrame(cs
, skb
->data
, skb
->len
);
447 if (cs
->debug
& DEB_DLOG_VERBOSE
)
448 dlogframe(cs
, skb
, 0);
449 spin_lock_irqsave(&cs
->lock
, flags
);
451 skb_queue_tail(&cs
->sq
, skb
);
452 #ifdef L2FRAME_DEBUG /* psa */
453 if (cs
->debug
& L1_DEB_LAPD
)
454 Logl2Frame(cs
, skb
, "PH_DATA Queued", 0);
459 #ifdef L2FRAME_DEBUG /* psa */
460 if (cs
->debug
& L1_DEB_LAPD
)
461 Logl2Frame(cs
, skb
, "PH_DATA", 0);
465 spin_unlock_irqrestore(&cs
->lock
, flags
);
467 case (PH_PULL
|INDICATION
):
468 spin_lock_irqsave(&cs
->lock
, flags
);
470 if (cs
->debug
& L1_DEB_WARN
)
471 debugl1(cs
, " l2l1 tx_skb exist this shouldn't happen");
472 skb_queue_tail(&cs
->sq
, skb
);
475 if (cs
->debug
& DEB_DLOG_HEX
)
476 LogFrame(cs
, skb
->data
, skb
->len
);
477 if (cs
->debug
& DEB_DLOG_VERBOSE
)
478 dlogframe(cs
, skb
, 0);
481 #ifdef L2FRAME_DEBUG /* psa */
482 if (cs
->debug
& L1_DEB_LAPD
)
483 Logl2Frame(cs
, skb
, "PH_DATA_PULLED", 0);
486 spin_unlock_irqrestore(&cs
->lock
, flags
);
488 case (PH_PULL
| REQUEST
):
489 #ifdef L2FRAME_DEBUG /* psa */
490 if (cs
->debug
& L1_DEB_LAPD
)
491 debugl1(cs
, "-> PH_REQUEST_PULL");
494 test_and_clear_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
);
495 st
->l1
.l1l2(st
, PH_PULL
| CONFIRM
, NULL
);
497 test_and_set_bit(FLG_L1_PULL_REQ
, &st
->l1
.Flags
);
499 case (HW_RESET
| REQUEST
):
500 spin_lock_irqsave(&cs
->lock
, flags
);
501 if ((cs
->dc
.icc
.ph_state
== ICC_IND_EI1
) ||
502 (cs
->dc
.icc
.ph_state
== ICC_IND_DR
))
503 ph_command(cs
, ICC_CMD_DI
);
505 ph_command(cs
, ICC_CMD_RES
);
506 spin_unlock_irqrestore(&cs
->lock
, flags
);
508 case (HW_ENABLE
| REQUEST
):
509 spin_lock_irqsave(&cs
->lock
, flags
);
510 ph_command(cs
, ICC_CMD_DI
);
511 spin_unlock_irqrestore(&cs
->lock
, flags
);
513 case (HW_INFO1
| REQUEST
):
514 spin_lock_irqsave(&cs
->lock
, flags
);
515 ph_command(cs
, ICC_CMD_AR
);
516 spin_unlock_irqrestore(&cs
->lock
, flags
);
518 case (HW_INFO3
| REQUEST
):
519 spin_lock_irqsave(&cs
->lock
, flags
);
520 ph_command(cs
, ICC_CMD_AI
);
521 spin_unlock_irqrestore(&cs
->lock
, flags
);
523 case (HW_TESTLOOP
| REQUEST
):
524 spin_lock_irqsave(&cs
->lock
, flags
);
530 if (test_bit(HW_IOM1
, &cs
->HW_Flags
)) {
533 cs
->writeisac(cs
, ICC_SPCR
, 0xa);
534 cs
->writeisac(cs
, ICC_ADF1
, 0x2);
536 cs
->writeisac(cs
, ICC_SPCR
, val
);
537 cs
->writeisac(cs
, ICC_ADF1
, 0xa);
541 cs
->writeisac(cs
, ICC_SPCR
, val
);
543 cs
->writeisac(cs
, ICC_ADF1
, 0x8);
545 cs
->writeisac(cs
, ICC_ADF1
, 0x0);
547 spin_unlock_irqrestore(&cs
->lock
, flags
);
549 case (HW_DEACTIVATE
| RESPONSE
):
550 skb_queue_purge(&cs
->rq
);
551 skb_queue_purge(&cs
->sq
);
553 dev_kfree_skb_any(cs
->tx_skb
);
556 if (test_and_clear_bit(FLG_DBUSY_TIMER
, &cs
->HW_Flags
))
557 del_timer(&cs
->dbusytimer
);
558 if (test_and_clear_bit(FLG_L1_DBUSY
, &cs
->HW_Flags
))
559 schedule_event(cs
, D_CLEARBUSY
);
562 if (cs
->debug
& L1_DEB_WARN
)
563 debugl1(cs
, "icc_l1hw unknown %04x", pr
);
569 setstack_icc(struct PStack
*st
, struct IsdnCardState
*cs
)
571 st
->l1
.l1hw
= ICC_l1hw
;
575 DC_Close_icc(struct IsdnCardState
*cs
) {
576 kfree(cs
->dc
.icc
.mon_rx
);
577 cs
->dc
.icc
.mon_rx
= NULL
;
578 kfree(cs
->dc
.icc
.mon_tx
);
579 cs
->dc
.icc
.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
, ICC_RBCH
);
590 star
= cs
->readisac(cs
, ICC_STAR
);
592 debugl1(cs
, "D-Channel Busy RBCH %02x STAR %02x",
594 if (rbch
& ICC_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: ICC D-Channel Busy no skb\n");
610 debugl1(cs
, "D-Channel Busy no skb");
612 cs
->writeisac(cs
, ICC_CMDR
, 0x01); /* Transmitter reset */
613 cs
->irq_func(cs
->irq
, cs
);
619 initicc(struct IsdnCardState
*cs
)
621 cs
->setstack_d
= setstack_icc
;
622 cs
->DC_Close
= DC_Close_icc
;
623 cs
->dc
.icc
.mon_tx
= NULL
;
624 cs
->dc
.icc
.mon_rx
= NULL
;
625 cs
->writeisac(cs
, ICC_MASK
, 0xff);
626 cs
->dc
.icc
.mocr
= 0xaa;
627 if (test_bit(HW_IOM1
, &cs
->HW_Flags
)) {
629 cs
->writeisac(cs
, ICC_ADF2
, 0x0);
630 cs
->writeisac(cs
, ICC_SPCR
, 0xa);
631 cs
->writeisac(cs
, ICC_ADF1
, 0x2);
632 cs
->writeisac(cs
, ICC_STCR
, 0x70);
633 cs
->writeisac(cs
, ICC_MODE
, 0xc9);
636 if (!cs
->dc
.icc
.adf2
)
637 cs
->dc
.icc
.adf2
= 0x80;
638 cs
->writeisac(cs
, ICC_ADF2
, cs
->dc
.icc
.adf2
);
639 cs
->writeisac(cs
, ICC_SQXR
, 0xa0);
640 cs
->writeisac(cs
, ICC_SPCR
, 0x20);
641 cs
->writeisac(cs
, ICC_STCR
, 0x70);
642 cs
->writeisac(cs
, ICC_MODE
, 0xca);
643 cs
->writeisac(cs
, ICC_TIMR
, 0x00);
644 cs
->writeisac(cs
, ICC_ADF1
, 0x20);
646 ph_command(cs
, ICC_CMD_RES
);
647 cs
->writeisac(cs
, ICC_MASK
, 0x0);
648 ph_command(cs
, ICC_CMD_DI
);
652 clear_pending_icc_ints(struct IsdnCardState
*cs
)
656 val
= cs
->readisac(cs
, ICC_STAR
);
657 debugl1(cs
, "ICC STAR %x", val
);
658 val
= cs
->readisac(cs
, ICC_MODE
);
659 debugl1(cs
, "ICC MODE %x", val
);
660 val
= cs
->readisac(cs
, ICC_ADF2
);
661 debugl1(cs
, "ICC ADF2 %x", val
);
662 val
= cs
->readisac(cs
, ICC_ISTA
);
663 debugl1(cs
, "ICC ISTA %x", val
);
665 eval
= cs
->readisac(cs
, ICC_EXIR
);
666 debugl1(cs
, "ICC EXIR %x", eval
);
668 val
= cs
->readisac(cs
, ICC_CIR0
);
669 debugl1(cs
, "ICC CIR0 %x", val
);
670 cs
->dc
.icc
.ph_state
= (val
>> 2) & 0xf;
671 schedule_event(cs
, D_L1STATECHANGE
);
672 /* Disable all IRQ */
673 cs
->writeisac(cs
, ICC_MASK
, 0xFF);
677 setup_icc(struct IsdnCardState
*cs
)
679 INIT_WORK(&cs
->tqueue
, icc_bh
);
680 cs
->dbusytimer
.function
= (void *) dbusy_timer_handler
;
681 cs
->dbusytimer
.data
= (long) cs
;
682 init_timer(&cs
->dbusytimer
);