21 #include <linux/slab.h>
24 #define DBUSY_TIMER_VALUE 80
28 {
"2086/2186 V1.1",
"2085 B1",
"2085 B2",
36 printk(
KERN_INFO "%s ISAC version (%x): %s\n", s, val, ISACVer[(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,
ISAC_CIX0, (command << 2) | 3);
49 isac_new_ph(
struct IsdnCardState *cs)
51 switch (cs->dc.isac.ph_state) {
86 struct IsdnCardState *cs =
92 debugl1(cs,
"D-Channel Busy cleared");
94 while (stptr !=
NULL) {
106 if (!
test_bit(HW_ARCOFI, &cs->HW_Flags))
120 if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO))
121 debugl1(cs,
"isac_empty_fifo");
124 if (cs->debug & L1_DEB_WARN)
125 debugl1(cs,
"isac_empty_fifo overrun %d",
131 ptr = cs->rcvbuf + cs->rcvidx;
133 cs->readisacfifo(cs, ptr, count);
135 if (cs->debug & L1_DEB_ISAC_FIFO) {
138 t +=
sprintf(t,
"isac_empty_fifo cnt %d", count);
145 isac_fill_fifo(
struct IsdnCardState *cs)
150 if ((cs->debug & L1_DEB_ISAC) && !(cs->debug & L1_DEB_ISAC_FIFO))
156 count = cs->tx_skb->len;
165 ptr = cs->tx_skb->data;
168 cs->writeisacfifo(cs, ptr, count);
169 cs->writeisac(cs,
ISAC_CMDR, more ? 0x8 : 0xa);
171 debugl1(cs,
"isac_fill_fifo dbusytimer running");
177 if (cs->debug & L1_DEB_ISAC_FIFO) {
180 t +=
sprintf(t,
"isac_fill_fifo cnt %d", count);
193 if (cs->debug & L1_DEB_ISAC)
194 debugl1(cs,
"ISAC interrupt %x", val);
197 if ((exval & 0x70) != 0x20) {
199 if (cs->debug & L1_DEB_WARN)
201 #ifdef ERROR_STATISTIC
205 if (!(exval & 0x20)) {
206 if (cs->debug & L1_DEB_WARN)
208 #ifdef ERROR_STATISTIC
214 count = cs->readisac(cs,
ISAC_RBCL) & 0x1f;
218 if ((count = cs->rcvidx) > 0) {
236 if (cs->debug & L1_DEB_WARN)
237 debugl1(cs,
"ISAC RSC interrupt");
245 if (cs->tx_skb->len) {
263 if (cs->debug & L1_DEB_ISAC)
264 debugl1(cs,
"ISAC CIR0 %02X", exval);
266 cs->dc.isac.ph_state = (exval >> 2) & 0xf;
267 if (cs->debug & L1_DEB_ISAC)
268 debugl1(cs,
"ph_state change %x", cs->dc.isac.ph_state);
273 if (cs->debug & L1_DEB_ISAC)
274 debugl1(cs,
"ISAC CIR1 %02X", exval);
279 if (cs->debug & L1_DEB_WARN)
280 debugl1(cs,
"ISAC SIN interrupt");
284 if (cs->debug & L1_DEB_WARN)
285 debugl1(cs,
"ISAC EXIR %02x", exval);
293 #ifdef ERROR_STATISTIC
306 debugl1(cs,
"ISAC XDU no skb");
311 if (cs->debug & L1_DEB_MONITOR)
312 debugl1(cs,
"ISAC MOSR %02x", v1);
315 if (!cs->dc.isac.mon_rx) {
317 if (cs->debug & L1_DEB_WARN)
318 debugl1(cs,
"ISAC MON RX out of memory!");
319 cs->dc.isac.mocr &= 0xf0;
320 cs->dc.isac.mocr |= 0x0a;
321 cs->writeisac(cs,
ISAC_MOCR, cs->dc.isac.mocr);
324 cs->dc.isac.mon_rxp = 0;
327 cs->dc.isac.mocr &= 0xf0;
328 cs->dc.isac.mocr |= 0x0a;
329 cs->writeisac(cs,
ISAC_MOCR, cs->dc.isac.mocr);
330 cs->dc.isac.mon_rxp = 0;
331 if (cs->debug & L1_DEB_WARN)
332 debugl1(cs,
"ISAC MON RX overflow!");
335 cs->dc.isac.mon_rx[cs->dc.isac.mon_rxp++] = cs->readisac(cs,
ISAC_MOR0);
336 if (cs->debug & L1_DEB_MONITOR)
337 debugl1(cs,
"ISAC MOR0 %02x", cs->dc.isac.mon_rx[cs->dc.isac.mon_rxp - 1]);
338 if (cs->dc.isac.mon_rxp == 1) {
339 cs->dc.isac.mocr |= 0x04;
340 cs->writeisac(cs,
ISAC_MOCR, cs->dc.isac.mocr);
345 if (!cs->dc.isac.mon_rx) {
347 if (cs->debug & L1_DEB_WARN)
348 debugl1(cs,
"ISAC MON RX out of memory!");
349 cs->dc.isac.mocr &= 0x0f;
350 cs->dc.isac.mocr |= 0xa0;
351 cs->writeisac(cs,
ISAC_MOCR, cs->dc.isac.mocr);
354 cs->dc.isac.mon_rxp = 0;
357 cs->dc.isac.mocr &= 0x0f;
358 cs->dc.isac.mocr |= 0xa0;
359 cs->writeisac(cs,
ISAC_MOCR, cs->dc.isac.mocr);
360 cs->dc.isac.mon_rxp = 0;
361 if (cs->debug & L1_DEB_WARN)
362 debugl1(cs,
"ISAC MON RX overflow!");
365 cs->dc.isac.mon_rx[cs->dc.isac.mon_rxp++] = cs->readisac(cs,
ISAC_MOR1);
366 if (cs->debug & L1_DEB_MONITOR)
367 debugl1(cs,
"ISAC MOR1 %02x", cs->dc.isac.mon_rx[cs->dc.isac.mon_rxp - 1]);
368 cs->dc.isac.mocr |= 0x40;
369 cs->writeisac(cs,
ISAC_MOCR, cs->dc.isac.mocr);
373 cs->dc.isac.mocr &= 0xf0;
374 cs->writeisac(cs,
ISAC_MOCR, cs->dc.isac.mocr);
375 cs->dc.isac.mocr |= 0x0a;
376 cs->writeisac(cs,
ISAC_MOCR, cs->dc.isac.mocr);
380 cs->dc.isac.mocr &= 0x0f;
381 cs->writeisac(cs,
ISAC_MOCR, cs->dc.isac.mocr);
382 cs->dc.isac.mocr |= 0xa0;
383 cs->writeisac(cs,
ISAC_MOCR, cs->dc.isac.mocr);
387 if ((!cs->dc.isac.mon_tx) || (cs->dc.isac.mon_txc &&
388 (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc) &&
390 cs->dc.isac.mocr &= 0xf0;
391 cs->writeisac(cs,
ISAC_MOCR, cs->dc.isac.mocr);
392 cs->dc.isac.mocr |= 0x0a;
393 cs->writeisac(cs,
ISAC_MOCR, cs->dc.isac.mocr);
394 if (cs->dc.isac.mon_txc &&
395 (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc))
399 if (cs->dc.isac.mon_txc && (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc)) {
404 cs->dc.isac.mon_tx[cs->dc.isac.mon_txp++]);
405 if (cs->debug & L1_DEB_MONITOR)
406 debugl1(cs,
"ISAC %02x -> MOX0", cs->dc.isac.mon_tx[cs->dc.isac.mon_txp - 1]);
410 if ((!cs->dc.isac.mon_tx) || (cs->dc.isac.mon_txc &&
411 (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc) &&
413 cs->dc.isac.mocr &= 0x0f;
414 cs->writeisac(cs,
ISAC_MOCR, cs->dc.isac.mocr);
415 cs->dc.isac.mocr |= 0xa0;
416 cs->writeisac(cs,
ISAC_MOCR, cs->dc.isac.mocr);
417 if (cs->dc.isac.mon_txc &&
418 (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc))
422 if (cs->dc.isac.mon_txc && (cs->dc.isac.mon_txp >= cs->dc.isac.mon_txc)) {
427 cs->dc.isac.mon_tx[cs->dc.isac.mon_txp++]);
428 if (cs->debug & L1_DEB_MONITOR)
429 debugl1(cs,
"ISAC %02x -> MOX1", cs->dc.isac.mon_tx[cs->dc.isac.mon_txp - 1]);
438 ISAC_l1hw(
struct PStack *
st,
int pr,
void *
arg)
440 struct IsdnCardState *cs = (
struct IsdnCardState *) st->l1.hardware;
447 if (cs->debug & DEB_DLOG_HEX)
449 if (cs->debug & DEB_DLOG_VERBOSE)
455 if (cs->debug & L1_DEB_LAPD)
462 if (cs->debug & L1_DEB_LAPD)
467 spin_unlock_irqrestore(&cs->lock,
flags);
472 if (cs->debug & L1_DEB_WARN)
473 debugl1(cs,
" l2l1 tx_skb exist this shouldn't happen");
476 if (cs->debug & DEB_DLOG_HEX)
478 if (cs->debug & DEB_DLOG_VERBOSE)
483 if (cs->debug & L1_DEB_LAPD)
488 spin_unlock_irqrestore(&cs->lock,
flags);
492 if (cs->debug & L1_DEB_LAPD)
493 debugl1(cs,
"-> PH_REQUEST_PULL");
509 spin_unlock_irqrestore(&cs->lock,
flags);
514 spin_unlock_irqrestore(&cs->lock,
flags);
519 spin_unlock_irqrestore(&cs->lock,
flags);
528 if (
test_bit(HW_IOM1, &cs->HW_Flags)) {
545 spin_unlock_irqrestore(&cs->lock,
flags);
560 if (cs->debug & L1_DEB_WARN)
561 debugl1(cs,
"isac_l1hw unknown %04x", pr);
567 setstack_isac(
struct PStack *st,
struct IsdnCardState *cs)
569 st->l1.l1hw = ISAC_l1hw;
573 DC_Close_isac(
struct IsdnCardState *cs)
575 kfree(cs->dc.isac.mon_rx);
576 cs->dc.isac.mon_rx =
NULL;
577 kfree(cs->dc.isac.mon_tx);
578 cs->dc.isac.mon_tx =
NULL;
582 dbusy_timer_handler(
struct IsdnCardState *cs)
584 struct PStack *stptr;
587 if (
test_bit(FLG_DBUSY_TIMER, &cs->HW_Flags)) {
591 debugl1(cs,
"D-Channel Busy RBCH %02x STAR %02x",
596 while (stptr !=
NULL) {
609 debugl1(cs,
"D-Channel Busy no skb");
612 cs->irq_func(cs->irq, cs);
619 cs->setstack_d = setstack_isac;
620 cs->DC_Close = DC_Close_isac;
621 cs->dc.isac.mon_tx =
NULL;
622 cs->dc.isac.mon_rx =
NULL;
624 cs->dc.isac.mocr = 0xaa;
625 if (
test_bit(HW_IOM1, &cs->HW_Flags)) {
634 if (!cs->dc.isac.adf2)
635 cs->dc.isac.adf2 = 0x80;
636 cs->writeisac(cs,
ISAC_ADF2, cs->dc.isac.adf2);
653 debugl1(cs,
"ISAC STAR %x", val);
655 debugl1(cs,
"ISAC MODE %x", val);
657 debugl1(cs,
"ISAC ADF2 %x", val);
659 debugl1(cs,
"ISAC ISTA %x", val);
662 debugl1(cs,
"ISAC EXIR %x", eval);
665 debugl1(cs,
"ISAC CIR0 %x", val);
666 cs->dc.isac.ph_state = (val >> 2) & 0xf;
676 cs->dbusytimer.function = (
void *) dbusy_timer_handler;
677 cs->dbusytimer.data = (
long) cs;