23 #include <linux/slab.h>
25 #define DBUSY_TIMER_VALUE 80
28 static char *ICCVer[] =
29 {
"2070 A1/A3",
"2070 B1",
"2070 B2/B3",
"2070 V2.4"};
37 printk(
KERN_INFO "%s ICC version (%x): %s\n", s, val, ICCVer[(val >> 5) & 3]);
41 ph_command(
struct IsdnCardState *
cs,
unsigned int command)
43 if (cs->debug & L1_DEB_ISAC)
44 debugl1(cs,
"ph_command %x", command);
45 cs->writeisac(cs,
ICC_CIX0, (command << 2) | 3);
50 icc_new_ph(
struct IsdnCardState *cs)
52 switch (cs->dc.icc.ph_state) {
83 struct IsdnCardState *cs =
89 debugl1(cs,
"D-Channel Busy cleared");
91 while (stptr !=
NULL) {
103 if (!
test_bit(HW_ARCOFI, &cs->HW_Flags))
113 icc_empty_fifo(
struct IsdnCardState *cs,
int count)
117 if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO))
121 if (cs->debug & L1_DEB_WARN)
122 debugl1(cs,
"icc_empty_fifo overrun %d",
128 ptr = cs->rcvbuf + cs->rcvidx;
130 cs->readisacfifo(cs, ptr, count);
132 if (cs->debug & L1_DEB_ISAC_FIFO) {
135 t +=
sprintf(t,
"icc_empty_fifo cnt %d", count);
142 icc_fill_fifo(
struct IsdnCardState *cs)
147 if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO))
153 count = cs->tx_skb->len;
162 ptr = cs->tx_skb->data;
165 cs->writeisacfifo(cs, ptr, count);
166 cs->writeisac(cs,
ICC_CMDR, more ? 0x8 : 0xa);
168 debugl1(cs,
"icc_fill_fifo dbusytimer running");
174 if (cs->debug & L1_DEB_ISAC_FIFO) {
177 t +=
sprintf(t,
"icc_fill_fifo cnt %d", count);
190 if (cs->debug & L1_DEB_ISAC)
191 debugl1(cs,
"ICC interrupt %x", val);
194 if ((exval & 0x70) != 0x20) {
196 if (cs->debug & L1_DEB_WARN)
198 #ifdef ERROR_STATISTIC
202 if (!(exval & 0x20)) {
203 if (cs->debug & L1_DEB_WARN)
205 #ifdef ERROR_STATISTIC
211 count = cs->readisac(cs,
ICC_RBCL) & 0x1f;
214 icc_empty_fifo(cs, count);
215 if ((count = cs->rcvidx) > 0) {
229 icc_empty_fifo(cs, 32);
233 if (cs->debug & L1_DEB_WARN)
234 debugl1(cs,
"ICC RSC interrupt");
242 if (cs->tx_skb->len) {
260 if (cs->debug & L1_DEB_ISAC)
261 debugl1(cs,
"ICC CIR0 %02X", exval);
263 cs->dc.icc.ph_state = (exval >> 2) & 0xf;
264 if (cs->debug & L1_DEB_ISAC)
265 debugl1(cs,
"ph_state change %x", cs->dc.icc.ph_state);
270 if (cs->debug & L1_DEB_ISAC)
271 debugl1(cs,
"ICC CIR1 %02X", exval);
276 if (cs->debug & L1_DEB_WARN)
277 debugl1(cs,
"ICC SIN interrupt");
281 if (cs->debug & L1_DEB_WARN)
282 debugl1(cs,
"ICC EXIR %02x", exval);
290 #ifdef ERROR_STATISTIC
308 if (cs->debug & L1_DEB_MONITOR)
309 debugl1(cs,
"ICC MOSR %02x", v1);
312 if (!cs->dc.icc.mon_rx) {
314 if (cs->debug & L1_DEB_WARN)
315 debugl1(cs,
"ICC MON RX out of memory!");
316 cs->dc.icc.mocr &= 0xf0;
317 cs->dc.icc.mocr |= 0x0a;
318 cs->writeisac(cs,
ICC_MOCR, cs->dc.icc.mocr);
321 cs->dc.icc.mon_rxp = 0;
324 cs->dc.icc.mocr &= 0xf0;
325 cs->dc.icc.mocr |= 0x0a;
326 cs->writeisac(cs,
ICC_MOCR, cs->dc.icc.mocr);
327 cs->dc.icc.mon_rxp = 0;
328 if (cs->debug & L1_DEB_WARN)
329 debugl1(cs,
"ICC MON RX overflow!");
332 cs->dc.icc.mon_rx[cs->dc.icc.mon_rxp++] = cs->readisac(cs,
ICC_MOR0);
333 if (cs->debug & L1_DEB_MONITOR)
334 debugl1(cs,
"ICC MOR0 %02x", cs->dc.icc.mon_rx[cs->dc.icc.mon_rxp - 1]);
335 if (cs->dc.icc.mon_rxp == 1) {
336 cs->dc.icc.mocr |= 0x04;
337 cs->writeisac(cs,
ICC_MOCR, cs->dc.icc.mocr);
342 if (!cs->dc.icc.mon_rx) {
344 if (cs->debug & L1_DEB_WARN)
345 debugl1(cs,
"ICC MON RX out of memory!");
346 cs->dc.icc.mocr &= 0x0f;
347 cs->dc.icc.mocr |= 0xa0;
348 cs->writeisac(cs,
ICC_MOCR, cs->dc.icc.mocr);
351 cs->dc.icc.mon_rxp = 0;
354 cs->dc.icc.mocr &= 0x0f;
355 cs->dc.icc.mocr |= 0xa0;
356 cs->writeisac(cs,
ICC_MOCR, cs->dc.icc.mocr);
357 cs->dc.icc.mon_rxp = 0;
358 if (cs->debug & L1_DEB_WARN)
359 debugl1(cs,
"ICC MON RX overflow!");
362 cs->dc.icc.mon_rx[cs->dc.icc.mon_rxp++] = cs->readisac(cs,
ICC_MOR1);
363 if (cs->debug & L1_DEB_MONITOR)
364 debugl1(cs,
"ICC MOR1 %02x", cs->dc.icc.mon_rx[cs->dc.icc.mon_rxp - 1]);
365 cs->dc.icc.mocr |= 0x40;
366 cs->writeisac(cs,
ICC_MOCR, cs->dc.icc.mocr);
370 cs->dc.icc.mocr &= 0xf0;
371 cs->writeisac(cs,
ICC_MOCR, cs->dc.icc.mocr);
372 cs->dc.icc.mocr |= 0x0a;
373 cs->writeisac(cs,
ICC_MOCR, cs->dc.icc.mocr);
377 cs->dc.icc.mocr &= 0x0f;
378 cs->writeisac(cs,
ICC_MOCR, cs->dc.icc.mocr);
379 cs->dc.icc.mocr |= 0xa0;
380 cs->writeisac(cs,
ICC_MOCR, cs->dc.icc.mocr);
384 if ((!cs->dc.icc.mon_tx) || (cs->dc.icc.mon_txc &&
385 (cs->dc.icc.mon_txp >= cs->dc.icc.mon_txc) &&
387 cs->dc.icc.mocr &= 0xf0;
388 cs->writeisac(cs,
ICC_MOCR, cs->dc.icc.mocr);
389 cs->dc.icc.mocr |= 0x0a;
390 cs->writeisac(cs,
ICC_MOCR, cs->dc.icc.mocr);
391 if (cs->dc.icc.mon_txc &&
392 (cs->dc.icc.mon_txp >= cs->dc.icc.mon_txc))
396 if (cs->dc.icc.mon_txc && (cs->dc.icc.mon_txp >= cs->dc.icc.mon_txc)) {
401 cs->dc.icc.mon_tx[cs->dc.icc.mon_txp++]);
402 if (cs->debug & L1_DEB_MONITOR)
403 debugl1(cs,
"ICC %02x -> MOX0", cs->dc.icc.mon_tx[cs->dc.icc.mon_txp - 1]);
407 if ((!cs->dc.icc.mon_tx) || (cs->dc.icc.mon_txc &&
408 (cs->dc.icc.mon_txp >= cs->dc.icc.mon_txc) &&
410 cs->dc.icc.mocr &= 0x0f;
411 cs->writeisac(cs,
ICC_MOCR, cs->dc.icc.mocr);
412 cs->dc.icc.mocr |= 0xa0;
413 cs->writeisac(cs,
ICC_MOCR, cs->dc.icc.mocr);
414 if (cs->dc.icc.mon_txc &&
415 (cs->dc.icc.mon_txp >= cs->dc.icc.mon_txc))
419 if (cs->dc.icc.mon_txc && (cs->dc.icc.mon_txp >= cs->dc.icc.mon_txc)) {
424 cs->dc.icc.mon_tx[cs->dc.icc.mon_txp++]);
425 if (cs->debug & L1_DEB_MONITOR)
426 debugl1(cs,
"ICC %02x -> MOX1", cs->dc.icc.mon_tx[cs->dc.icc.mon_txp - 1]);
435 ICC_l1hw(
struct PStack *
st,
int pr,
void *
arg)
437 struct IsdnCardState *cs = (
struct IsdnCardState *) st->l1.hardware;
444 if (cs->debug & DEB_DLOG_HEX)
446 if (cs->debug & DEB_DLOG_VERBOSE)
452 if (cs->debug & L1_DEB_LAPD)
459 if (cs->debug & L1_DEB_LAPD)
464 spin_unlock_irqrestore(&cs->lock,
flags);
469 if (cs->debug & L1_DEB_WARN)
470 debugl1(cs,
" l2l1 tx_skb exist this shouldn't happen");
472 spin_unlock_irqrestore(&cs->lock,
flags);
475 if (cs->debug & DEB_DLOG_HEX)
477 if (cs->debug & DEB_DLOG_VERBOSE)
482 if (cs->debug & L1_DEB_LAPD)
486 spin_unlock_irqrestore(&cs->lock,
flags);
490 if (cs->debug & L1_DEB_LAPD)
491 debugl1(cs,
"-> PH_REQUEST_PULL");
506 spin_unlock_irqrestore(&cs->lock,
flags);
511 spin_unlock_irqrestore(&cs->lock,
flags);
516 spin_unlock_irqrestore(&cs->lock,
flags);
521 spin_unlock_irqrestore(&cs->lock,
flags);
530 if (
test_bit(HW_IOM1, &cs->HW_Flags)) {
547 spin_unlock_irqrestore(&cs->lock,
flags);
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)) {
592 debugl1(cs,
"D-Channel Busy RBCH %02x STAR %02x",
597 while (stptr !=
NULL) {
610 debugl1(cs,
"D-Channel Busy no skb");
613 cs->irq_func(cs->irq, 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;
626 cs->dc.icc.mocr = 0xaa;
627 if (
test_bit(HW_IOM1, &cs->HW_Flags)) {
636 if (!cs->dc.icc.adf2)
637 cs->dc.icc.adf2 = 0x80;
638 cs->writeisac(cs,
ICC_ADF2, cs->dc.icc.adf2);
657 debugl1(cs,
"ICC STAR %x", val);
659 debugl1(cs,
"ICC MODE %x", val);
661 debugl1(cs,
"ICC ADF2 %x", val);
663 debugl1(cs,
"ICC ISTA %x", val);
666 debugl1(cs,
"ICC EXIR %x", eval);
669 debugl1(cs,
"ICC CIR0 %x", val);
670 cs->dc.icc.ph_state = (val >> 2) & 0xf;
680 cs->dbusytimer.function = (
void *) dbusy_timer_handler;
681 cs->dbusytimer.data = (
long) cs;