2 * Copyright (c) 2001 Gary Jennejohn. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the author nor the names of any co-contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 * 4. Altered versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software and/or documentation.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 /*---------------------------------------------------------------------------
34 * i4b_ifpi2_pci.c: AVM Fritz!Card PCI hardware driver
35 * --------------------------------------------------
38 *---------------------------------------------------------------------------*/
40 #include <sys/cdefs.h>
41 __FBSDID("$FreeBSD$");
45 #include <sys/param.h>
46 #include <sys/kernel.h>
47 #include <sys/systm.h>
50 #include <machine/bus.h>
54 #include <dev/pci/pcireg.h>
55 #include <dev/pci/pcivar.h>
57 #include <sys/socket.h>
60 #include <i4b/include/i4b_debug.h>
61 #include <i4b/include/i4b_ioctl.h>
62 #include <i4b/include/i4b_trace.h>
64 #include <i4b/include/i4b_global.h>
65 #include <i4b/include/i4b_mbuf.h>
67 #include <i4b/layer1/i4b_l1.h>
68 #include <i4b/layer1/isic/i4b_isic.h>
69 /*#include <i4b/layer1/isic/i4b_isac.h>*/
70 #include <i4b/layer1/isic/i4b_hscx.h>
72 #include <i4b/layer1/ifpi2/i4b_ifpi2_ext.h>
73 #include <i4b/layer1/ifpi2/i4b_ifpi2_isacsx.h>
75 #define PCI_AVMA1_VID 0x1244
76 #define PCI_AVMA1_V2_DID 0x0e00
79 static void avma1pp2_disable(device_t);
80 static void avma1pp2_intr(void *);
81 static void hscx_write_reg(int, u_int, struct l1_softc *);
82 static u_char hscx_read_reg(int, struct l1_softc *);
83 static u_int hscx_read_reg_int(int, struct l1_softc *);
84 static void hscx_read_fifo(int, void *, size_t, struct l1_softc *);
85 static void hscx_write_fifo(int, void *, size_t, struct l1_softc *);
86 static void avma1pp2_hscx_int_handler(struct l1_softc *);
87 static void avma1pp2_hscx_intr(int, u_int, struct l1_softc *);
88 static void avma1pp2_init_linktab(struct l1_softc *);
89 static void avma1pp2_bchannel_setup(int, int, int, int);
90 static void avma1pp2_bchannel_start(int, int);
91 static void avma1pp2_hscx_init(struct l1_softc *, int, int);
92 static void avma1pp2_bchannel_stat(int, int, bchan_statistics_t *);
93 static void avma1pp2_set_linktab(int, int, drvr_link_t *);
94 static isdn_link_t * avma1pp2_ret_linktab(int, int);
95 static int avma1pp2_pci_probe(device_t);
96 static int avma1pp2_hscx_fifo(l1_bchan_state_t *, struct l1_softc *);
97 int avma1pp2_attach_avma1pp(device_t);
98 static void ifpi2_isacsx_intr(struct l1_softc *sc);
100 static device_method_t avma1pp2_pci_methods[] = {
101 /* Device interface */
102 DEVMETHOD(device_probe, avma1pp2_pci_probe),
103 DEVMETHOD(device_attach, avma1pp2_attach_avma1pp),
104 DEVMETHOD(device_shutdown, avma1pp2_disable),
107 DEVMETHOD(bus_print_child, bus_generic_print_child),
108 DEVMETHOD(bus_driver_added, bus_generic_driver_added),
113 static driver_t avma1pp2_pci_driver = {
115 avma1pp2_pci_methods,
116 sizeof(struct l1_softc)
119 static devclass_t avma1pp2_pci_devclass;
121 DRIVER_MODULE(avma1pp2, pci, avma1pp2_pci_driver, avma1pp2_pci_devclass, 0, 0);
123 /* jump table for multiplex routines */
125 struct i4b_l1mux_func avma1pp2_l1mux_func = {
126 avma1pp2_ret_linktab,
127 avma1pp2_set_linktab,
128 ifpi2_mph_command_req,
130 ifpi2_ph_activate_req,
133 struct l1_softc *ifpi2_scp[IFPI2_MAXUNIT];
135 /*---------------------------------------------------------------------------*
136 * AVM PCI Fritz!Card V. 2 special registers
137 *---------------------------------------------------------------------------*/
140 * AVM PCI Status Latch 0 read only bits
142 #define ASL_IRQ_ISAC 0x01 /* ISAC interrupt, active high */
143 #define ASL_IRQ_HSCX 0x02 /* HSX interrupt, active high */
144 #define ASL_IRQ_TIMER 0x04 /* Timer interrupt, active high */
145 #define ASL_IRQ_BCHAN ASL_IRQ_HSCX
146 /* actually active high */
147 #define ASL_IRQ_Pending (ASL_IRQ_ISAC | ASL_IRQ_HSCX | ASL_IRQ_TIMER)
150 * AVM PCI Status Latch 0 read only bits
152 #define ASL_RESET 0x01
153 #define ASL_TIMERRESET 0x04
154 #define ASL_ENABLE_INT 0x08
159 #define HSCX_STAT_RME 0x01
160 #define HSCX_STAT_RDO 0x10
161 #define HSCX_STAT_CRCVFRRAB 0x0E
162 #define HSCX_STAT_CRCVFR 0x06
163 #define HSCX_STAT_RML_MASK 0x3f00
166 * "HSCX" interrupt bits
168 #define HSCX_INT_XPR 0x80
169 #define HSCX_INT_XDU 0x40
170 #define HSCX_INT_RPR 0x20
171 #define HSCX_INT_MASK 0xE0
174 * "HSCX" command bits
176 #define HSCX_CMD_XRS 0x80
177 #define HSCX_CMD_XME 0x01
178 #define HSCX_CMD_RRS 0x20
179 #define HSCX_CMD_XML_MASK 0x3f00
181 /* "HSCX" mode bits */
182 #define HSCX_MODE_ITF_FLG 0x01
183 #define HSCX_MODE_TRANS 0x02
185 /* offsets to various registers in the ASIC, evidently */
186 #define STAT0_OFFSET 0x02
188 #define HSCX_FIFO1 0x10
189 #define HSCX_FIFO2 0x18
191 #define HSCX_STAT1 0x14
192 #define HSCX_STAT2 0x1c
194 #define ISACSX_INDEX 0x04
195 #define ISACSX_DATA 0x08
198 * Commands and parameters are sent to the "HSCX" as a long, but the
199 * fields are handled as bytes.
202 * (prot << 16)|(txl << 8)|cmd
205 * prot = protocol to use
206 * txl = transmit length
207 * cmd = the command to be executed
209 * The fields are defined as u_char in struct l1_softc.
211 * Macro to coalesce the byte fields into a u_int
213 #define AVMA1PPSETCMDLONG(f) (f) = ((sc->avma1pp_cmd) | (sc->avma1pp_txl << 8) \
214 | (sc->avma1pp_prot << 16))
217 * to prevent deactivating the "HSCX" when both channels are active we
218 * define an HSCX_ACTIVE flag which is or'd into the channel's state
219 * flag in avma1pp2_bchannel_setup upon active and cleared upon deactivation.
220 * It is set high to allow room for new flags.
222 #define HSCX_AVMA1PP_ACTIVE 0x1000
224 /*---------------------------------------------------------------------------*
225 * AVM read fifo routines
226 *---------------------------------------------------------------------------*/
229 avma1pp2_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
231 bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
232 bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
237 bus_space_write_4(btag, bhandle, ISACSX_INDEX, 0);
238 /* evidently each byte must be read as a long */
239 for (i = 0; i < size; i++)
240 ((u_int8_t *)buf)[i] = (u_int8_t)bus_space_read_4(btag, bhandle, ISACSX_DATA);
242 case ISIC_WHAT_HSCXA:
243 hscx_read_fifo(0, buf, size, sc);
245 case ISIC_WHAT_HSCXB:
246 hscx_read_fifo(1, buf, size, sc);
252 hscx_read_fifo(int chan, void *buf, size_t len, struct l1_softc *sc)
257 bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
258 bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
260 dataoff = chan ? HSCX_FIFO2 : HSCX_FIFO1;
262 ip = (u_int32_t *)buf;
264 /* what if len isn't a multiple of sizeof(int) and buf is */
268 *ip++ = bus_space_read_4(btag, bhandle, dataoff);
273 /*---------------------------------------------------------------------------*
274 * AVM write fifo routines
275 *---------------------------------------------------------------------------*/
277 avma1pp2_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
279 bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
280 bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
285 bus_space_write_4(btag, bhandle, ISACSX_INDEX, 0);
286 /* evidently each byte must written as a long */
287 for (i = 0; i < size; i++)
288 bus_space_write_4(btag, bhandle, ISACSX_DATA, ((unsigned char *)buf)[i]);
290 case ISIC_WHAT_HSCXA:
291 hscx_write_fifo(0, buf, size, sc);
293 case ISIC_WHAT_HSCXB:
294 hscx_write_fifo(1, buf, size, sc);
300 hscx_write_fifo(int chan, void *buf, size_t len, struct l1_softc *sc)
305 l1_bchan_state_t *Bchan = &sc->sc_chan[chan];
306 bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
307 bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
309 dataoff = chan ? HSCX_FIFO2 : HSCX_FIFO1;
311 sc->avma1pp_cmd &= ~HSCX_CMD_XME;
313 if (Bchan->out_mbuf_cur == NULL)
315 if (Bchan->bprot != BPROT_NONE)
316 sc->avma1pp_cmd |= HSCX_CMD_XME;
318 if (len != sc->sc_bfifolen)
319 sc->avma1pp_txl = len;
321 cnt = 0; /* borrow cnt */
322 AVMA1PPSETCMDLONG(cnt);
323 hscx_write_reg(chan, cnt, sc);
325 ip = (u_int32_t *)buf;
329 bus_space_write_4(btag, bhandle, dataoff, *ip);
335 /*---------------------------------------------------------------------------*
336 * AVM write register routines
337 *---------------------------------------------------------------------------*/
340 avma1pp2_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data)
342 bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
343 bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
347 bus_space_write_4(btag, bhandle, ISACSX_INDEX, offs);
348 bus_space_write_4(btag, bhandle, ISACSX_DATA, data);
350 case ISIC_WHAT_HSCXA:
351 hscx_write_reg(0, data, sc);
353 case ISIC_WHAT_HSCXB:
354 hscx_write_reg(1, data, sc);
360 hscx_write_reg(int chan, u_int val, struct l1_softc *sc)
362 bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
363 bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
366 off = (chan == 0 ? HSCX_STAT1 : HSCX_STAT2);
368 bus_space_write_4(btag, bhandle, off, val);
371 /*---------------------------------------------------------------------------*
372 * AVM read register routines
373 *---------------------------------------------------------------------------*/
375 avma1pp2_read_reg(struct l1_softc *sc, int what, bus_size_t offs)
377 bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
378 bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
383 bus_space_write_4(btag, bhandle, ISACSX_INDEX, offs);
384 val = (u_int8_t)bus_space_read_4(btag, bhandle, ISACSX_DATA);
386 case ISIC_WHAT_HSCXA:
387 return hscx_read_reg(0, sc);
388 case ISIC_WHAT_HSCXB:
389 return hscx_read_reg(1, sc);
395 hscx_read_reg(int chan, struct l1_softc *sc)
397 return(hscx_read_reg_int(chan, sc) & 0xff);
401 * need to be able to return an int because the RBCH is in the 2nd
405 hscx_read_reg_int(int chan, struct l1_softc *sc)
407 bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
408 bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
411 off = (chan == 0 ? HSCX_STAT1 : HSCX_STAT2);
412 return(bus_space_read_4(btag, bhandle, off));
415 /*---------------------------------------------------------------------------*
416 * avma1pp2_probe - probe for a card
417 *---------------------------------------------------------------------------*/
419 avma1pp2_pci_probe(dev)
424 vid = pci_get_vendor(dev);
425 did = pci_get_device(dev);
427 if ((vid == PCI_AVMA1_VID) && (did == PCI_AVMA1_V2_DID)) {
428 device_set_desc(dev, "AVM Fritz!Card PCI Version 2");
435 /*---------------------------------------------------------------------------*
436 * avma1pp2_attach_avma1pp - attach Fritz!Card PCI
437 *---------------------------------------------------------------------------*/
439 avma1pp2_attach_avma1pp(device_t dev)
447 bus_space_handle_t bhandle;
448 bus_space_tag_t btag;
449 l1_bchan_state_t *chan;
453 vid = pci_get_vendor(dev);
454 did = pci_get_device(dev);
455 sc = device_get_softc(dev);
456 unit = device_get_unit(dev);
457 bzero(sc, sizeof(struct l1_softc));
459 /* probably not really required */
460 if(unit >= IFPI2_MAXUNIT) {
461 printf("ifpi2-%d: Error, unit >= IFPI_MAXUNIT!\n", unit);
466 if ((vid != PCI_AVMA1_VID) && (did != PCI_AVMA1_V2_DID)) {
467 printf("ifpi2-%d: unknown device!?\n", unit);
471 ifpi2_scp[unit] = sc;
473 sc->sc_resources.io_rid[0] = PCIR_BAR(1);
474 sc->sc_resources.io_base[0] = bus_alloc_resource_any(dev,
475 SYS_RES_IOPORT, &sc->sc_resources.io_rid[0], RF_ACTIVE);
477 if (sc->sc_resources.io_base[0] == NULL) {
478 printf("ifpi2-%d: couldn't map IO port\n", unit);
483 bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
484 btag = rman_get_bustag(sc->sc_resources.io_base[0]);
486 /* Allocate interrupt */
487 sc->sc_resources.irq_rid = 0;
488 sc->sc_resources.irq = bus_alloc_resource_any(dev, SYS_RES_IRQ,
489 &sc->sc_resources.irq_rid, RF_SHAREABLE | RF_ACTIVE);
491 if (sc->sc_resources.irq == NULL) {
492 bus_release_resource(dev, SYS_RES_IOPORT, PCIR_BAR(1), sc->sc_resources.io_base[0]);
493 printf("ifpi2-%d: couldn't map interrupt\n", unit);
498 error = bus_setup_intr(dev, sc->sc_resources.irq, INTR_TYPE_NET, NULL, avma1pp2_intr, sc, &ih);
501 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_resources.irq);
502 bus_release_resource(dev, SYS_RES_IOPORT, PCIR_BAR(1), sc->sc_resources.io_base[0]);
503 printf("ifpi2-%d: couldn't set up irq\n", unit);
509 /* end of new-bus stuff */
511 ISAC_BASE = (caddr_t)ISIC_WHAT_ISAC;
513 HSCX_A_BASE = (caddr_t)ISIC_WHAT_HSCXA;
514 HSCX_B_BASE = (caddr_t)ISIC_WHAT_HSCXB;
516 /* setup access routines */
519 sc->readreg = avma1pp2_read_reg;
520 sc->writereg = avma1pp2_write_reg;
522 sc->readfifo = avma1pp2_read_fifo;
523 sc->writefifo = avma1pp2_write_fifo;
525 /* setup card type */
527 sc->sc_cardtyp = CARD_TYPEP_AVMA1PCI_V2;
529 /* setup IOM bus type */
531 sc->sc_bustyp = BUS_TYPE_IOM2;
533 /* set up some other miscellaneous things */
535 sc->sc_bfifolen = HSCX_FIFO_LEN;
538 /* the Linux driver does this to clear any pending ISAC interrupts */
540 v = ISAC_READ(I_RMODED);
541 #ifdef AVMA1PCI_V2_DEBUG
542 printf("avma1pp2_attach: I_MODED %x...", v);
544 v = ISAC_READ(I_ISTAD);
545 #ifdef AVMA1PCI_V2_DEBUG
546 printf("avma1pp2_attach: I_ISTAD %x...", v);
548 v = ISAC_READ(I_ISTA);
549 #ifdef AVMA1PCI_V2_DEBUG
550 printf("avma1pp2_attach: I_ISTA %x...", v);
552 ISAC_WRITE(I_MASKD, 0xff);
553 ISAC_WRITE(I_MASK, 0xff);
554 /* the Linux driver does this to clear any pending HSCX interrupts */
555 v = hscx_read_reg_int(0, sc);
556 #ifdef AVMA1PCI_V2_DEBUG
557 printf("avma1pp2_attach: 0 HSCX_STAT %x...", v);
559 v = hscx_read_reg_int(1, sc);
560 #ifdef AVMA1PCI_V2_DEBUG
561 printf("avma1pp2_attach: 1 HSCX_STAT %x\n", v);
564 bus_space_write_1(btag, bhandle, STAT0_OFFSET, 0);
565 DELAY(SEC_DELAY/100); /* 10 ms */
566 bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_RESET);
567 DELAY(SEC_DELAY/100); /* 10 ms */
568 bus_space_write_1(btag, bhandle, STAT0_OFFSET, 0);
569 DELAY(SEC_DELAY/100); /* 10 ms */
571 bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_TIMERRESET);
572 DELAY(SEC_DELAY/100); /* 10 ms */
573 bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_ENABLE_INT);
574 DELAY(SEC_DELAY/100); /* 10 ms */
576 /* from here to the end would normally be done in isic_pciattach */
578 printf("ifpi2-%d: ISACSX %s\n", unit, "PSB3186");
581 ifpi2_isacsx_init(sc);
583 #if defined (__FreeBSD__) && __FreeBSD__ > 4
584 /* Init the channel mutexes */
585 chan = &sc->sc_chan[HSCX_CH_A];
586 if(!mtx_initialized(&chan->rx_queue.ifq_mtx))
587 mtx_init(&chan->rx_queue.ifq_mtx, "i4b_avma1pp2_rx", NULL, MTX_DEF);
588 if(!mtx_initialized(&chan->tx_queue.ifq_mtx))
589 mtx_init(&chan->tx_queue.ifq_mtx, "i4b_avma1pp2_tx", NULL, MTX_DEF);
590 chan = &sc->sc_chan[HSCX_CH_B];
591 if(!mtx_initialized(&chan->rx_queue.ifq_mtx))
592 mtx_init(&chan->rx_queue.ifq_mtx, "i4b_avma1pp2_rx", NULL, MTX_DEF);
593 if(!mtx_initialized(&chan->tx_queue.ifq_mtx))
594 mtx_init(&chan->tx_queue.ifq_mtx, "i4b_avma1pp2_tx", NULL, MTX_DEF);
597 /* init the "HSCX" */
598 avma1pp2_bchannel_setup(sc->sc_unit, HSCX_CH_A, BPROT_NONE, 0);
600 avma1pp2_bchannel_setup(sc->sc_unit, HSCX_CH_B, BPROT_NONE, 0);
602 /* can't use the normal B-Channel stuff */
603 avma1pp2_init_linktab(sc);
605 /* set trace level */
607 sc->sc_trace = TRACE_OFF;
609 sc->sc_state = ISAC_IDLE;
621 sc->sc_freeflag2 = 0;
623 #if defined(__FreeBSD__) && __FreeBSD__ >=3
624 callout_handle_init(&sc->sc_T3_callout);
625 callout_handle_init(&sc->sc_T4_callout);
628 /* init higher protocol layers */
630 i4b_l1_mph_status_ind(L0IFPI2UNIT(sc->sc_unit), STI_ATTACH, sc->sc_cardtyp, &avma1pp2_l1mux_func);
638 * this is the real interrupt routine
641 avma1pp2_hscx_intr(int h_chan, u_int stat, struct l1_softc *sc)
643 register l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
647 NDBGL1(L1_H_IRQ, "%#x", stat);
649 if((stat & HSCX_INT_XDU) && (chan->bprot != BPROT_NONE))/* xmit data underrun */
652 NDBGL1(L1_H_XFRERR, "xmit data underrun");
653 /* abort the transmission */
655 sc->avma1pp_cmd |= HSCX_CMD_XRS;
656 AVMA1PPSETCMDLONG(param);
657 hscx_write_reg(h_chan, param, sc);
658 sc->avma1pp_cmd &= ~HSCX_CMD_XRS;
659 AVMA1PPSETCMDLONG(param);
660 hscx_write_reg(h_chan, param, sc);
662 if (chan->out_mbuf_head != NULL) /* don't continue to transmit this buffer */
664 i4b_Bfreembuf(chan->out_mbuf_head);
665 chan->out_mbuf_cur = chan->out_mbuf_head = NULL;
670 * The following is based on examination of the Linux driver.
672 * The logic here is different than with a "real" HSCX; all kinds
673 * of information (interrupt/status bits) are in stat.
674 * HSCX_INT_RPR indicates a receive interrupt
675 * HSCX_STAT_RDO indicates an overrun condition, abort -
676 * otherwise read the bytes ((stat & HSCX_STZT_RML_MASK) >> 8)
677 * HSCX_STAT_RME indicates end-of-frame and apparently any
678 * CRC/framing errors are only reported in this state.
679 * if ((stat & HSCX_STAT_CRCVFRRAB) != HSCX_STAT_CRCVFR)
683 if(stat & HSCX_INT_RPR)
685 register int fifo_data_len;
687 /* always have to read the FIFO, so use a scratch buffer */
688 u_char scrbuf[HSCX_FIFO_LEN];
690 if(stat & HSCX_STAT_RDO)
693 NDBGL1(L1_H_XFRERR, "receive data overflow");
698 * check whether we're receiving data for an inactive B-channel
699 * and discard it. This appears to happen for telephony when
700 * both B-channels are active and one is deactivated. Since
701 * it is not really possible to deactivate the channel in that
702 * case (the ASIC seems to deactivate _both_ channels), the
703 * "deactivated" channel keeps receiving data which can lead
704 * to exhaustion of mbufs and a kernel panic.
706 * This is a hack, but it's the only solution I can think of
707 * without having the documentation for the ASIC.
710 if (chan->state == HSCX_IDLE)
712 NDBGL1(L1_H_XFRERR, "toss data from %d", h_chan);
716 fifo_data_len = ((stat & HSCX_STAT_RML_MASK) >> 8);
718 if(fifo_data_len == 0)
719 fifo_data_len = sc->sc_bfifolen;
721 /* ALWAYS read data from HSCX fifo */
723 HSCX_RDFIFO(h_chan, scrbuf, fifo_data_len);
724 chan->rxcount += fifo_data_len;
726 /* all error conditions checked, now decide and take action */
730 if(chan->in_mbuf == NULL)
732 if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
733 panic("L1 avma1pp2_hscx_intr: RME, cannot allocate mbuf!\n");
734 chan->in_cbptr = chan->in_mbuf->m_data;
738 if((chan->in_len + fifo_data_len) <= BCH_MAX_DATALEN)
740 /* OK to copy the data */
741 bcopy(scrbuf, chan->in_cbptr, fifo_data_len);
742 chan->in_cbptr += fifo_data_len;
743 chan->in_len += fifo_data_len;
745 /* setup mbuf data length */
747 chan->in_mbuf->m_len = chan->in_len;
748 chan->in_mbuf->m_pkthdr.len = chan->in_len;
750 if(sc->sc_trace & TRACE_B_RX)
753 hdr.unit = L0IFPI2UNIT(sc->sc_unit);
754 hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
756 hdr.count = ++sc->sc_trace_bcount;
758 i4b_l1_trace_ind(&hdr, chan->in_mbuf->m_len, chan->in_mbuf->m_data);
761 if (stat & HSCX_STAT_RME)
763 if((stat & HSCX_STAT_CRCVFRRAB) == HSCX_STAT_CRCVFR)
765 (*chan->isic_drvr_linktab->bch_rx_data_ready)(chan->isic_drvr_linktab->unit);
768 /* mark buffer ptr as unused */
770 chan->in_mbuf = NULL;
771 chan->in_cbptr = NULL;
777 NDBGL1(L1_H_XFRERR, "CRC/RAB");
778 if (chan->in_mbuf != NULL)
780 i4b_Bfreembuf(chan->in_mbuf);
781 chan->in_mbuf = NULL;
782 chan->in_cbptr = NULL;
787 } /* END enough space in mbuf */
790 if(chan->bprot == BPROT_NONE)
792 /* setup mbuf data length */
794 chan->in_mbuf->m_len = chan->in_len;
795 chan->in_mbuf->m_pkthdr.len = chan->in_len;
797 if(sc->sc_trace & TRACE_B_RX)
800 hdr.unit = L0IFPI2UNIT(sc->sc_unit);
801 hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
803 hdr.count = ++sc->sc_trace_bcount;
805 i4b_l1_trace_ind(&hdr, chan->in_mbuf->m_len, chan->in_mbuf->m_data);
808 if(!(i4b_l1_bchan_tel_silence(chan->in_mbuf->m_data, chan->in_mbuf->m_len)))
811 /* move rx'd data to rx queue */
813 #if defined (__FreeBSD__) && __FreeBSD__ > 4
814 (void) IF_HANDOFF(&chan->rx_queue, chan->in_mbuf, NULL);
816 if(!(IF_QFULL(&chan->rx_queue)))
818 IF_ENQUEUE(&chan->rx_queue, chan->in_mbuf);
822 i4b_Bfreembuf(chan->in_mbuf);
825 /* signal upper layer that data are available */
826 (*chan->isic_drvr_linktab->bch_rx_data_ready)(chan->isic_drvr_linktab->unit);
828 /* alloc new buffer */
830 if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
831 panic("L1 avma1pp2_hscx_intr: RPF, cannot allocate new mbuf!\n");
833 /* setup new data ptr */
835 chan->in_cbptr = chan->in_mbuf->m_data;
837 /* OK to copy the data */
838 bcopy(scrbuf, chan->in_cbptr, fifo_data_len);
840 chan->in_cbptr += fifo_data_len;
841 chan->in_len = fifo_data_len;
843 chan->rxcount += fifo_data_len;
847 NDBGL1(L1_H_XFRERR, "RAWHDLC rx buffer overflow in RPF, in_len=%d", chan->in_len);
848 chan->in_cbptr = chan->in_mbuf->m_data;
852 } /* if(error == 0) */
855 /* land here for RDO */
856 if (chan->in_mbuf != NULL)
858 i4b_Bfreembuf(chan->in_mbuf);
859 chan->in_mbuf = NULL;
860 chan->in_cbptr = NULL;
864 sc->avma1pp_cmd |= HSCX_CMD_RRS;
865 AVMA1PPSETCMDLONG(param);
866 hscx_write_reg(h_chan, param, sc);
867 sc->avma1pp_cmd &= ~HSCX_CMD_RRS;
868 AVMA1PPSETCMDLONG(param);
869 hscx_write_reg(h_chan, param, sc);
874 /* transmit fifo empty, new data can be written to fifo */
876 if(stat & HSCX_INT_XPR)
879 * for a description what is going on here, please have
880 * a look at isic_bchannel_start() in i4b_bchan.c !
883 NDBGL1(L1_H_IRQ, "unit %d, chan %d - XPR, Tx Fifo Empty!", sc->sc_unit, h_chan);
885 if(chan->out_mbuf_cur == NULL) /* last frame is transmitted */
887 IF_DEQUEUE(&chan->tx_queue, chan->out_mbuf_head);
889 if(chan->out_mbuf_head == NULL)
891 chan->state &= ~HSCX_TX_ACTIVE;
892 (*chan->isic_drvr_linktab->bch_tx_queue_empty)(chan->isic_drvr_linktab->unit);
896 chan->state |= HSCX_TX_ACTIVE;
897 chan->out_mbuf_cur = chan->out_mbuf_head;
898 chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
899 chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
901 if(sc->sc_trace & TRACE_B_TX)
904 hdr.unit = L0IFPI2UNIT(sc->sc_unit);
905 hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
907 hdr.count = ++sc->sc_trace_bcount;
909 i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
912 if(chan->bprot == BPROT_NONE)
914 if(!(i4b_l1_bchan_tel_silence(chan->out_mbuf_cur->m_data, chan->out_mbuf_cur->m_len)))
924 avma1pp2_hscx_fifo(chan, sc);
927 /* call timeout handling routine */
929 if(activity == ACT_RX || activity == ACT_TX)
930 (*chan->isic_drvr_linktab->bch_activity)(chan->isic_drvr_linktab->unit, activity);
934 * this is the main routine which checks each channel and then calls
935 * the real interrupt routine as appropriate
938 avma1pp2_hscx_int_handler(struct l1_softc *sc)
942 /* has to be a u_int because the byte count is in the 2nd byte */
943 stat = hscx_read_reg_int(0, sc);
944 if (stat & HSCX_INT_MASK)
945 avma1pp2_hscx_intr(0, stat, sc);
946 stat = hscx_read_reg_int(1, sc);
947 if (stat & HSCX_INT_MASK)
948 avma1pp2_hscx_intr(1, stat, sc);
952 avma1pp2_disable(device_t dev)
954 struct l1_softc *sc = device_get_softc(dev);
955 bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
956 bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
958 /* could be still be wrong, but seems to prevent hangs */
959 bus_space_write_1(btag, bhandle, STAT0_OFFSET, 0x00);
963 avma1pp2_intr(void *xsc)
967 bus_space_handle_t bhandle;
968 bus_space_tag_t btag;
971 bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
972 btag = rman_get_bustag(sc->sc_resources.io_base[0]);
974 stat = bus_space_read_1(btag, bhandle, STAT0_OFFSET);
975 NDBGL1(L1_H_IRQ, "stat %x", stat);
976 /* was there an interrupt from this card ? */
977 if ((stat & ASL_IRQ_Pending) == 0)
979 /* For slow machines loop as long as an interrupt is active */
980 for (; ((stat & ASL_IRQ_Pending) != 0) ;)
982 /* interrupts are high active */
983 if (stat & ASL_IRQ_TIMER)
984 NDBGL1(L1_H_IRQ, "timer interrupt ???");
985 if (stat & ASL_IRQ_HSCX)
987 NDBGL1(L1_H_IRQ, "HSCX");
988 avma1pp2_hscx_int_handler(sc);
990 if (stat & ASL_IRQ_ISAC)
992 NDBGL1(L1_H_IRQ, "ISAC");
993 ifpi2_isacsx_intr(sc);
995 stat = bus_space_read_1(btag, bhandle, STAT0_OFFSET);
996 NDBGL1(L1_H_IRQ, "stat %x", stat);
1002 avma1pp2_hscx_init(struct l1_softc *sc, int h_chan, int activate)
1004 l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
1007 NDBGL1(L1_BCHAN, "unit=%d, channel=%d, %s",
1008 sc->sc_unit, h_chan, activate ? "activate" : "deactivate");
1010 sc->avma1pp_cmd = sc->avma1pp_prot = sc->avma1pp_txl = 0;
1014 /* only deactivate if both channels are idle */
1015 if (sc->sc_chan[HSCX_CH_A].state != HSCX_IDLE ||
1016 sc->sc_chan[HSCX_CH_B].state != HSCX_IDLE)
1020 sc->avma1pp_cmd = HSCX_CMD_XRS|HSCX_CMD_RRS;
1021 sc->avma1pp_prot = HSCX_MODE_TRANS;
1022 AVMA1PPSETCMDLONG(param);
1023 hscx_write_reg(h_chan, param, sc);
1026 if(chan->bprot == BPROT_RHDLC)
1028 NDBGL1(L1_BCHAN, "BPROT_RHDLC");
1030 /* HDLC Frames, transparent mode 0 */
1031 sc->avma1pp_cmd = HSCX_CMD_XRS|HSCX_CMD_RRS;
1032 sc->avma1pp_prot = HSCX_MODE_ITF_FLG;
1033 AVMA1PPSETCMDLONG(param);
1034 hscx_write_reg(h_chan, param, sc);
1035 sc->avma1pp_cmd = HSCX_CMD_XRS;
1036 AVMA1PPSETCMDLONG(param);
1037 hscx_write_reg(h_chan, param, sc);
1038 sc->avma1pp_cmd = 0;
1042 NDBGL1(L1_BCHAN, "BPROT_NONE??");
1044 /* Raw Telephony, extended transparent mode 1 */
1045 sc->avma1pp_cmd = HSCX_CMD_XRS|HSCX_CMD_RRS;
1046 sc->avma1pp_prot = HSCX_MODE_TRANS;
1047 AVMA1PPSETCMDLONG(param);
1048 hscx_write_reg(h_chan, param, sc);
1049 sc->avma1pp_cmd = HSCX_CMD_XRS;
1050 AVMA1PPSETCMDLONG(param);
1051 hscx_write_reg(h_chan, param, sc);
1052 sc->avma1pp_cmd = 0;
1057 avma1pp2_bchannel_setup(int unit, int h_chan, int bprot, int activate)
1060 struct l1_softc *sc = ifpi2_scp[unit];
1062 struct l1_softc *sc = isic_find_sc(unit);
1064 l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
1071 chan->state = HSCX_IDLE;
1072 avma1pp2_hscx_init(sc, h_chan, activate);
1075 NDBGL1(L1_BCHAN, "unit=%d, channel=%d, %s",
1076 sc->sc_unit, h_chan, activate ? "activate" : "deactivate");
1080 chan->unit = sc->sc_unit; /* unit number */
1081 chan->channel = h_chan; /* B channel */
1082 chan->bprot = bprot; /* B channel protocol */
1083 chan->state = HSCX_IDLE; /* B channel state */
1087 chan->rx_queue.ifq_maxlen = IFQ_MAXLEN;
1089 i4b_Bcleanifq(&chan->rx_queue); /* clean rx queue */
1091 chan->rxcount = 0; /* reset rx counter */
1093 i4b_Bfreembuf(chan->in_mbuf); /* clean rx mbuf */
1095 chan->in_mbuf = NULL; /* reset mbuf ptr */
1096 chan->in_cbptr = NULL; /* reset mbuf curr ptr */
1097 chan->in_len = 0; /* reset mbuf data len */
1099 /* transmitter part */
1101 chan->tx_queue.ifq_maxlen = IFQ_MAXLEN;
1103 i4b_Bcleanifq(&chan->tx_queue); /* clean tx queue */
1105 chan->txcount = 0; /* reset tx counter */
1107 i4b_Bfreembuf(chan->out_mbuf_head); /* clean tx mbuf */
1109 chan->out_mbuf_head = NULL; /* reset head mbuf ptr */
1110 chan->out_mbuf_cur = NULL; /* reset current mbuf ptr */
1111 chan->out_mbuf_cur_ptr = NULL; /* reset current mbuf data ptr */
1112 chan->out_mbuf_cur_len = 0; /* reset current mbuf data cnt */
1117 avma1pp2_hscx_init(sc, h_chan, activate);
1118 chan->state |= HSCX_AVMA1PP_ACTIVE;
1125 avma1pp2_bchannel_start(int unit, int h_chan)
1128 struct l1_softc *sc = ifpi2_scp[unit];
1130 struct l1_softc *sc = isic_find_sc(unit);
1132 register l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
1136 s = SPLI4B(); /* enter critical section */
1137 if(chan->state & HSCX_TX_ACTIVE) /* already running ? */
1140 return; /* yes, leave */
1143 /* get next mbuf from queue */
1145 IF_DEQUEUE(&chan->tx_queue, chan->out_mbuf_head);
1147 if(chan->out_mbuf_head == NULL) /* queue empty ? */
1149 splx(s); /* leave critical section */
1150 return; /* yes, exit */
1153 /* init current mbuf values */
1155 chan->out_mbuf_cur = chan->out_mbuf_head;
1156 chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
1157 chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
1159 /* activity indicator for timeout handling */
1161 if(chan->bprot == BPROT_NONE)
1163 if(!(i4b_l1_bchan_tel_silence(chan->out_mbuf_cur->m_data, chan->out_mbuf_cur->m_len)))
1171 chan->state |= HSCX_TX_ACTIVE; /* we start transmitting */
1173 if(sc->sc_trace & TRACE_B_TX) /* if trace, send mbuf to trace dev */
1175 i4b_trace_hdr_t hdr;
1176 hdr.unit = L0IFPI2UNIT(sc->sc_unit);
1177 hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
1179 hdr.count = ++sc->sc_trace_bcount;
1180 MICROTIME(hdr.time);
1181 i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
1184 avma1pp2_hscx_fifo(chan, sc);
1186 /* call timeout handling routine */
1188 if(activity == ACT_RX || activity == ACT_TX)
1189 (*chan->isic_drvr_linktab->bch_activity)(chan->isic_drvr_linktab->unit, activity);
1194 /*---------------------------------------------------------------------------*
1195 * return the address of isic drivers linktab
1196 *---------------------------------------------------------------------------*/
1197 static isdn_link_t *
1198 avma1pp2_ret_linktab(int unit, int channel)
1201 struct l1_softc *sc = ifpi2_scp[unit];
1203 struct l1_softc *sc = isic_find_sc(unit);
1205 l1_bchan_state_t *chan = &sc->sc_chan[channel];
1207 return(&chan->isic_isdn_linktab);
1210 /*---------------------------------------------------------------------------*
1211 * set the driver linktab in the b channel softc
1212 *---------------------------------------------------------------------------*/
1214 avma1pp2_set_linktab(int unit, int channel, drvr_link_t *dlt)
1217 struct l1_softc *sc = ifpi2_scp[unit];
1219 struct l1_softc *sc = isic_find_sc(unit);
1221 l1_bchan_state_t *chan = &sc->sc_chan[channel];
1223 chan->isic_drvr_linktab = dlt;
1227 /*---------------------------------------------------------------------------*
1228 * initialize our local linktab
1229 *---------------------------------------------------------------------------*/
1231 avma1pp2_init_linktab(struct l1_softc *sc)
1233 l1_bchan_state_t *chan = &sc->sc_chan[HSCX_CH_A];
1234 isdn_link_t *lt = &chan->isic_isdn_linktab;
1236 /* make sure the hardware driver is known to layer 4 */
1237 /* avoid overwriting if already set */
1238 if (ctrl_types[CTRL_PASSIVE].set_linktab == NULL)
1240 ctrl_types[CTRL_PASSIVE].set_linktab = i4b_l1_set_linktab;
1241 ctrl_types[CTRL_PASSIVE].get_linktab = i4b_l1_ret_linktab;
1245 lt->unit = sc->sc_unit;
1246 lt->channel = HSCX_CH_A;
1247 lt->bch_config = avma1pp2_bchannel_setup;
1248 lt->bch_tx_start = avma1pp2_bchannel_start;
1249 lt->bch_stat = avma1pp2_bchannel_stat;
1250 lt->tx_queue = &chan->tx_queue;
1252 /* used by non-HDLC data transfers, i.e. telephony drivers */
1253 lt->rx_queue = &chan->rx_queue;
1255 /* used by HDLC data transfers, i.e. ipr and isp drivers */
1256 lt->rx_mbuf = &chan->in_mbuf;
1258 chan = &sc->sc_chan[HSCX_CH_B];
1259 lt = &chan->isic_isdn_linktab;
1261 lt->unit = sc->sc_unit;
1262 lt->channel = HSCX_CH_B;
1263 lt->bch_config = avma1pp2_bchannel_setup;
1264 lt->bch_tx_start = avma1pp2_bchannel_start;
1265 lt->bch_stat = avma1pp2_bchannel_stat;
1266 lt->tx_queue = &chan->tx_queue;
1268 /* used by non-HDLC data transfers, i.e. telephony drivers */
1269 lt->rx_queue = &chan->rx_queue;
1271 /* used by HDLC data transfers, i.e. ipr and isp drivers */
1272 lt->rx_mbuf = &chan->in_mbuf;
1276 * use this instead of isic_bchannel_stat in i4b_bchan.c because it's static
1279 avma1pp2_bchannel_stat(int unit, int h_chan, bchan_statistics_t *bsp)
1282 struct l1_softc *sc = ifpi2_scp[unit];
1284 struct l1_softc *sc = isic_find_sc(unit);
1286 l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
1291 bsp->outbytes = chan->txcount;
1292 bsp->inbytes = chan->rxcount;
1300 /*---------------------------------------------------------------------------*
1301 * fill HSCX fifo with data from the current mbuf
1302 * Put this here until it can go into i4b_hscx.c
1303 *---------------------------------------------------------------------------*/
1305 avma1pp2_hscx_fifo(l1_bchan_state_t *chan, struct l1_softc *sc)
1311 /* using a scratch buffer simplifies writing to the FIFO */
1312 u_char scrbuf[HSCX_FIFO_LEN];
1317 * fill the HSCX tx fifo with data from the current mbuf. if
1318 * current mbuf holds less data than HSCX fifo length, try to
1319 * get the next mbuf from (a possible) mbuf chain. if there is
1320 * not enough data in a single mbuf or in a chain, then this
1321 * is the last mbuf and we tell the HSCX that it has to send
1322 * CRC and closing flag
1325 while(chan->out_mbuf_cur && len != sc->sc_bfifolen)
1327 nextlen = min(chan->out_mbuf_cur_len, sc->sc_bfifolen - len);
1330 printf("i:mh=%p, mc=%p, mcp=%p, mcl=%d l=%d nl=%d # ",
1331 chan->out_mbuf_head,
1333 chan->out_mbuf_cur_ptr,
1334 chan->out_mbuf_cur_len,
1339 cmd |= HSCX_CMDR_XTF;
1340 /* collect the data in the scratch buffer */
1341 for (i = 0; i < nextlen; i++)
1342 scrbuf[i + len] = chan->out_mbuf_cur_ptr[i];
1345 chan->txcount += nextlen;
1347 chan->out_mbuf_cur_ptr += nextlen;
1348 chan->out_mbuf_cur_len -= nextlen;
1350 if(chan->out_mbuf_cur_len == 0)
1352 if((chan->out_mbuf_cur = chan->out_mbuf_cur->m_next) != NULL)
1354 chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
1355 chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
1357 if(sc->sc_trace & TRACE_B_TX)
1359 i4b_trace_hdr_t hdr;
1360 hdr.unit = L0IFPI2UNIT(sc->sc_unit);
1361 hdr.type = (chan->channel == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
1363 hdr.count = ++sc->sc_trace_bcount;
1364 MICROTIME(hdr.time);
1365 i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
1370 if (chan->bprot != BPROT_NONE)
1371 cmd |= HSCX_CMDR_XME;
1372 i4b_Bfreembuf(chan->out_mbuf_head);
1373 chan->out_mbuf_head = NULL;
1377 /* write what we have from the scratch buf to the HSCX fifo */
1379 HSCX_WRFIFO(chan->channel, scrbuf, len);
1383 /*---------------------------------------------------------------------------*
1384 * ifpi2 - ISAC interrupt routine
1385 *---------------------------------------------------------------------------*/
1387 ifpi2_isacsx_intr(struct l1_softc *sc)
1389 register u_char isacsx_irq_stat;
1393 /* get isac irq status */
1394 /* ISTA tells us whether it was a C/I or HDLC int. */
1395 isacsx_irq_stat = ISAC_READ(I_ISTA);
1398 ifpi2_isacsx_irq(sc, isacsx_irq_stat); /* isac handler */
1403 ISAC_WRITE(I_MASKD, 0xff);
1404 ISAC_WRITE(I_MASK, 0xff);
1408 ISAC_WRITE(I_MASKD, isacsx_imaskd);
1409 ISAC_WRITE(I_MASK, isacsx_imask);
1412 /*---------------------------------------------------------------------------*
1413 * ifpi2_recover - try to recover from irq lockup
1414 *---------------------------------------------------------------------------*/
1416 ifpi2_recover(struct l1_softc *sc)
1418 printf("ifpi2_recover %d\n", sc->sc_unit);
1419 #if 0 /* fix me later */
1422 /* get isac irq status */
1424 byte = ISAC_READ(I_ISTA);
1426 NDBGL1(L1_ERROR, " ISAC: ISTA = 0x%x", byte);
1428 if(byte & ISACSX_ISTA_EXI)
1429 NDBGL1(L1_ERROR, " ISAC: EXIR = 0x%x", (u_char)ISAC_READ(I_EXIR));
1431 if(byte & ISACSX_ISTA_CISQ)
1433 byte = ISAC_READ(I_CIRR);
1435 NDBGL1(L1_ERROR, " ISAC: CISQ = 0x%x", byte);
1437 if(byte & ISACSX_CIRR_SQC)
1438 NDBGL1(L1_ERROR, " ISAC: SQRR = 0x%x", (u_char)ISAC_READ(I_SQRR));
1441 NDBGL1(L1_ERROR, " ISAC: IMASK = 0x%x", ISACSX_IMASK);
1443 ISAC_WRITE(I_MASKD, 0xff);
1444 ISAC_WRITE(I_MASK, 0xff);
1446 ISAC_WRITE(I_MASKD, isacsx_imaskd);
1447 ISAC_WRITE(I_MASK, isacsx_imask);