2 * Copyright (c) 1999, 2000 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
31 *---------------------------------------------------------------------------
33 * i4b_ifpi_pci.c: AVM Fritz!Card PCI hardware driver
34 * --------------------------------------------------
36 * $Id: i4b_ifpi_pci.c,v 1.4 2000/06/02 11:58:56 hm Exp $
38 * $FreeBSD: src/sys/i4b/layer1/ifpi/i4b_ifpi_pci.c,v 1.6.2.1 2001/08/10 14:08:37 obrien Exp $
40 * last edit-date: [Fri Jan 12 17:01:26 2001]
42 *---------------------------------------------------------------------------*/
48 #if (NIFPI > 0) && (NPCI > 0)
50 #include <sys/param.h>
51 #include <sys/kernel.h>
52 #include <sys/systm.h>
56 #include <sys/socket.h>
57 #include <sys/thread2.h>
59 #include <bus/pci/pcireg.h>
60 #include <bus/pci/pcivar.h>
63 #include <net/i4b/include/machine/i4b_debug.h>
64 #include <net/i4b/include/machine/i4b_ioctl.h>
65 #include <net/i4b/include/machine/i4b_trace.h>
67 #include "../../include/i4b_global.h"
68 #include "../../include/i4b_mbuf.h"
70 #include "../i4b_l1.h"
71 #include "../isic/i4b_isic.h"
72 #include "../isic/i4b_isac.h"
73 #include "../isic/i4b_hscx.h"
75 #include "i4b_ifpi_ext.h"
77 #define PCI_AVMA1_VID 0x1244
78 #define PCI_AVMA1_DID 0x0a00
81 static void avma1pp_disable(device_t);
83 static void avma1pp_intr(void *);
84 static void hscx_write_reg(int, u_int, u_int, struct l1_softc *);
85 static u_char hscx_read_reg(int, u_int, struct l1_softc *);
86 static u_int hscx_read_reg_int(int, u_int, struct l1_softc *);
87 static void hscx_read_fifo(int, void *, size_t, struct l1_softc *);
88 static void hscx_write_fifo(int, void *, size_t, struct l1_softc *);
89 static void avma1pp_hscx_int_handler(struct l1_softc *);
90 static void avma1pp_hscx_intr(int, u_int, struct l1_softc *);
91 static void avma1pp_init_linktab(struct l1_softc *);
92 static void avma1pp_bchannel_setup(int, int, int, int);
93 static void avma1pp_bchannel_start(int, int);
94 static void avma1pp_hscx_init(struct l1_softc *, int, int);
95 static void avma1pp_bchannel_stat(int, int, bchan_statistics_t *);
96 static void avma1pp_set_linktab(int, int, drvr_link_t *);
97 static isdn_link_t * avma1pp_ret_linktab(int, int);
98 static int avma1pp_pci_probe(device_t);
99 static int avma1pp_hscx_fifo(l1_bchan_state_t *, struct l1_softc *);
100 int avma1pp_attach_avma1pp(device_t);
101 static void ifpi_isac_intr(struct l1_softc *sc);
103 static device_method_t avma1pp_pci_methods[] = {
104 /* Device interface */
105 DEVMETHOD(device_probe, avma1pp_pci_probe),
106 DEVMETHOD(device_attach, avma1pp_attach_avma1pp),
107 DEVMETHOD(device_shutdown, avma1pp_disable),
110 DEVMETHOD(bus_print_child, bus_generic_print_child),
111 DEVMETHOD(bus_driver_added, bus_generic_driver_added),
116 #if 0 /* use what's in l1_softc */
117 /* a minimal softc for the Fritz!Card PCI */
120 bus_space_handle_t avma1pp_bhandle;
121 bus_space_tag_t avma1pp_btag;
122 void *avma1pp_intrhand;
123 struct resource *avma1pp_irq;
124 struct resource *avma1pp_res;
125 /* pointer to ifpi_sc */
126 struct l1_softc *avma1pp_isc;
130 static driver_t avma1pp_pci_driver = {
133 sizeof(struct l1_softc)
136 static devclass_t avma1pp_pci_devclass;
138 DRIVER_MODULE(avma1pp, pci, avma1pp_pci_driver, avma1pp_pci_devclass, NULL, NULL);
140 /* jump table for multiplex routines */
142 struct i4b_l1mux_func avma1pp_l1mux_func = {
145 ifpi_mph_command_req,
147 ifpi_ph_activate_req,
150 struct l1_softc *ifpi_scp[IFPI_MAXUNIT];
152 /*---------------------------------------------------------------------------*
153 * AVM PCI Fritz!Card special registers
154 *---------------------------------------------------------------------------*/
157 * register offsets from i/o base
159 #define STAT0_OFFSET 0x02
160 #define STAT1_OFFSET 0x03
161 #define ADDR_REG_OFFSET 0x04
162 /*#define MODREG_OFFSET 0x06
163 #define VERREG_OFFSET 0x07*/
165 /* these 2 are used to select an ISAC register set */
166 #define ISAC_LO_REG_OFFSET 0x04
167 #define ISAC_HI_REG_OFFSET 0x06
169 /* offset higher than this goes to the HI register set */
170 #define MAX_LO_REG_OFFSET 0x2f
172 /* mask for the offset */
173 #define ISAC_REGSET_MASK 0x0f
175 /* the offset from the base to the ISAC registers */
176 #define ISAC_REG_OFFSET 0x10
178 /* the offset from the base to the ISAC FIFO */
179 #define ISAC_FIFO 0x02
181 /* not really the HSCX, but sort of */
182 #define HSCX_FIFO 0x00
183 #define HSCX_STAT 0x04
186 * AVM PCI Status Latch 0 read only bits
188 #define ASL_IRQ_ISAC 0x01 /* ISAC interrupt, active low */
189 #define ASL_IRQ_HSCX 0x02 /* HSX interrupt, active low */
190 #define ASL_IRQ_TIMER 0x04 /* Timer interrupt, active low */
191 #define ASL_IRQ_BCHAN ASL_IRQ_HSCX
192 /* actually active LOW */
193 #define ASL_IRQ_Pending (ASL_IRQ_ISAC | ASL_IRQ_HSCX | ASL_IRQ_TIMER)
196 * AVM Status Latch 0 write only bits
198 #define ASL_RESET_ALL 0x01 /* reset siemens IC's, active 1 */
199 #define ASL_TIMERDISABLE 0x02 /* active high */
200 #define ASL_TIMERRESET 0x04 /* active high */
201 #define ASL_ENABLE_INT 0x08 /* active high */
202 #define ASL_TESTBIT 0x10 /* active high */
205 * AVM Status Latch 1 write only bits
207 #define ASL1_INTSEL 0x0f /* active high */
208 #define ASL1_ENABLE_IOM 0x80 /* active high */
213 #define HSCX_MODE_ITF_FLG 0x01
214 #define HSCX_MODE_TRANS 0x02
215 #define HSCX_MODE_CCR_7 0x04
216 #define HSCX_MODE_CCR_16 0x08
217 #define HSCX_MODE_TESTLOOP 0x80
222 #define HSCX_STAT_RME 0x01
223 #define HSCX_STAT_RDO 0x10
224 #define HSCX_STAT_CRCVFRRAB 0x0E
225 #define HSCX_STAT_CRCVFR 0x06
226 #define HSCX_STAT_RML_MASK 0x3f00
229 * "HSCX" interrupt bits
231 #define HSCX_INT_XPR 0x80
232 #define HSCX_INT_XDU 0x40
233 #define HSCX_INT_RPR 0x20
234 #define HSCX_INT_MASK 0xE0
237 * "HSCX" command bits
239 #define HSCX_CMD_XRS 0x80
240 #define HSCX_CMD_XME 0x01
241 #define HSCX_CMD_RRS 0x20
242 #define HSCX_CMD_XML_MASK 0x3f00
245 * Commands and parameters are sent to the "HSCX" as a long, but the
246 * fields are handled as bytes.
249 * (prot << 16)|(txl << 8)|cmd
252 * prot = protocol to use
253 * txl = transmit length
254 * cmd = the command to be executed
256 * The fields are defined as u_char in struct l1_softc.
258 * Macro to coalesce the byte fields into a u_int
260 #define AVMA1PPSETCMDLONG(f) (f) = ((sc->avma1pp_cmd) | (sc->avma1pp_txl << 8) \
261 | (sc->avma1pp_prot << 16))
264 * to prevent deactivating the "HSCX" when both channels are active we
265 * define an HSCX_ACTIVE flag which is or'd into the channel's state
266 * flag in avma1pp_bchannel_setup upon active and cleared upon deactivation.
267 * It is set high to allow room for new flags.
269 #define HSCX_AVMA1PP_ACTIVE 0x1000
271 /*---------------------------------------------------------------------------*
272 * AVM read fifo routines
273 *---------------------------------------------------------------------------*/
276 avma1pp_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
278 bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
279 bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
283 bus_space_write_1(btag, bhandle, ADDR_REG_OFFSET, ISAC_FIFO);
284 bus_space_read_multi_1(btag, bhandle, ISAC_REG_OFFSET, buf, size);
286 case ISIC_WHAT_HSCXA:
287 hscx_read_fifo(0, buf, size, sc);
289 case ISIC_WHAT_HSCXB:
290 hscx_read_fifo(1, buf, size, sc);
296 hscx_read_fifo(int chan, void *buf, size_t len, struct l1_softc *sc)
300 bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
301 bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
303 bus_space_write_4(btag, bhandle, ADDR_REG_OFFSET, chan);
304 ip = (u_int32_t *)buf;
306 /* what if len isn't a multiple of sizeof(int) and buf is */
310 *ip++ = bus_space_read_4(btag, bhandle, ISAC_REG_OFFSET);
315 /*---------------------------------------------------------------------------*
316 * AVM write fifo routines
317 *---------------------------------------------------------------------------*/
319 avma1pp_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
321 bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
322 bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
326 bus_space_write_1(btag, bhandle, ADDR_REG_OFFSET, ISAC_FIFO);
327 bus_space_write_multi_1(btag, bhandle, ISAC_REG_OFFSET, (u_int8_t*)buf, size);
329 case ISIC_WHAT_HSCXA:
330 hscx_write_fifo(0, buf, size, sc);
332 case ISIC_WHAT_HSCXB:
333 hscx_write_fifo(1, buf, size, sc);
339 hscx_write_fifo(int chan, void *buf, size_t len, struct l1_softc *sc)
343 l1_bchan_state_t *Bchan = &sc->sc_chan[chan];
344 bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
345 bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
348 sc->avma1pp_cmd &= ~HSCX_CMD_XME;
350 if (Bchan->out_mbuf_cur == NULL)
352 if (Bchan->bprot != BPROT_NONE)
353 sc->avma1pp_cmd |= HSCX_CMD_XME;
355 if (len != sc->sc_bfifolen)
356 sc->avma1pp_txl = len;
358 cnt = 0; /* borrow cnt */
359 AVMA1PPSETCMDLONG(cnt);
360 hscx_write_reg(chan, HSCX_STAT, cnt, sc);
362 ip = (u_int32_t *)buf;
366 bus_space_write_4(btag, bhandle, ISAC_REG_OFFSET, *ip);
372 /*---------------------------------------------------------------------------*
373 * AVM write register routines
374 *---------------------------------------------------------------------------*/
377 avma1pp_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data)
380 bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
381 bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
385 reg_bank = (offs > MAX_LO_REG_OFFSET) ? ISAC_HI_REG_OFFSET:ISAC_LO_REG_OFFSET;
386 #ifdef AVMA1PCI_DEBUG
387 kprintf("write_reg bank %d off %ld.. ", (int)reg_bank, (long)offs);
389 /* set the register bank */
390 bus_space_write_1(btag, bhandle, ADDR_REG_OFFSET, reg_bank);
391 bus_space_write_1(btag, bhandle, ISAC_REG_OFFSET + (offs & ISAC_REGSET_MASK), data);
393 case ISIC_WHAT_HSCXA:
394 hscx_write_reg(0, offs, data, sc);
396 case ISIC_WHAT_HSCXB:
397 hscx_write_reg(1, offs, data, sc);
403 hscx_write_reg(int chan, u_int off, u_int val, struct l1_softc *sc)
405 bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
406 bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
408 /* point at the correct channel */
409 bus_space_write_4(btag, bhandle, ADDR_REG_OFFSET, chan);
410 bus_space_write_4(btag, bhandle, ISAC_REG_OFFSET + off, val);
413 /*---------------------------------------------------------------------------*
414 * AVM read register routines
415 *---------------------------------------------------------------------------*/
417 avma1pp_read_reg(struct l1_softc *sc, int what, bus_size_t offs)
420 bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
421 bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
425 reg_bank = (offs > MAX_LO_REG_OFFSET) ? ISAC_HI_REG_OFFSET:ISAC_LO_REG_OFFSET;
426 #ifdef AVMA1PCI_DEBUG
427 kprintf("read_reg bank %d off %ld.. ", (int)reg_bank, (long)offs);
429 /* set the register bank */
430 bus_space_write_1(btag, bhandle, ADDR_REG_OFFSET, reg_bank);
431 return(bus_space_read_1(btag, bhandle, ISAC_REG_OFFSET +
432 (offs & ISAC_REGSET_MASK)));
433 case ISIC_WHAT_HSCXA:
434 return hscx_read_reg(0, offs, sc);
435 case ISIC_WHAT_HSCXB:
436 return hscx_read_reg(1, offs, sc);
442 hscx_read_reg(int chan, u_int off, struct l1_softc *sc)
444 return(hscx_read_reg_int(chan, off, sc) & 0xff);
448 * need to be able to return an int because the RBCH is in the 2nd
452 hscx_read_reg_int(int chan, u_int off, struct l1_softc *sc)
454 bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
455 bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
457 /* point at the correct channel */
458 bus_space_write_4(btag, bhandle, ADDR_REG_OFFSET, chan);
459 return(bus_space_read_4(btag, bhandle, ISAC_REG_OFFSET + off));
462 /*---------------------------------------------------------------------------*
463 * avma1pp_probe - probe for a card
464 *---------------------------------------------------------------------------*/
466 avma1pp_pci_probe(device_t dev)
470 vid = pci_get_vendor(dev);
471 did = pci_get_device(dev);
473 if ((vid == PCI_AVMA1_VID) && (did == PCI_AVMA1_DID)) {
474 device_set_desc(dev, "AVM Fritz!Card PCI");
481 /*---------------------------------------------------------------------------*
482 * avma1pp_attach_avma1pp - attach Fritz!Card PCI
483 *---------------------------------------------------------------------------*/
485 avma1pp_attach_avma1pp(device_t dev)
492 bus_space_handle_t bhandle;
493 bus_space_tag_t btag;
497 vid = pci_get_vendor(dev);
498 did = pci_get_device(dev);
499 sc = device_get_softc(dev);
500 unit = device_get_unit(dev);
501 bzero(sc, sizeof(struct l1_softc));
503 /* probably not really required */
504 if(unit > IFPI_MAXUNIT) {
505 kprintf("avma1pp%d: Error, unit > IFPI_MAXUNIT!\n", unit);
510 if ((vid != PCI_AVMA1_VID) && (did != PCI_AVMA1_DID)) {
511 kprintf("avma1pp%d: unknown device!?\n", unit);
517 sc->sc_resources.io_rid[0] = PCIR_MAPS+4;
518 sc->sc_resources.io_base[0] = bus_alloc_resource(dev, SYS_RES_IOPORT,
519 &sc->sc_resources.io_rid[0],
520 0, ~0, 1, RF_ACTIVE);
522 if (sc->sc_resources.io_base[0] == NULL) {
523 kprintf("avma1pp%d: couldn't map IO port\n", unit);
528 bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
529 btag = rman_get_bustag(sc->sc_resources.io_base[0]);
531 /* Allocate interrupt */
532 sc->sc_resources.irq_rid = 0;
533 sc->sc_resources.irq = bus_alloc_resource(dev, SYS_RES_IRQ,
534 &sc->sc_resources.irq_rid, 0, ~0, 1, RF_SHAREABLE | RF_ACTIVE);
536 if (sc->sc_resources.irq == NULL) {
537 bus_release_resource(dev, SYS_RES_IOPORT, PCIR_MAPS+4, sc->sc_resources.io_base[0]);
538 kprintf("avma1pp%d: couldn't map interrupt\n", unit);
543 error = bus_setup_intr(dev, sc->sc_resources.irq, 0,
544 avma1pp_intr, sc, &ih, NULL);
547 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_resources.irq);
548 bus_release_resource(dev, SYS_RES_IOPORT, PCIR_MAPS+4, sc->sc_resources.io_base[0]);
549 kprintf("avma1pp%d: couldn't set up irq\n", unit);
555 /* end of new-bus stuff */
557 ISAC_BASE = (caddr_t)ISIC_WHAT_ISAC;
559 HSCX_A_BASE = (caddr_t)ISIC_WHAT_HSCXA;
560 HSCX_B_BASE = (caddr_t)ISIC_WHAT_HSCXB;
562 /* setup access routines */
565 sc->readreg = avma1pp_read_reg;
566 sc->writereg = avma1pp_write_reg;
568 sc->readfifo = avma1pp_read_fifo;
569 sc->writefifo = avma1pp_write_fifo;
571 /* setup card type */
573 sc->sc_cardtyp = CARD_TYPEP_AVMA1PCI;
575 /* setup IOM bus type */
577 sc->sc_bustyp = BUS_TYPE_IOM2;
579 /* set up some other miscellaneous things */
581 sc->sc_bfifolen = HSCX_FIFO_LEN;
584 /* the Linux driver does this to clear any pending ISAC interrupts */
586 v = ISAC_READ(I_STAR);
587 #ifdef AVMA1PCI_DEBUG
588 kprintf("avma1pp_attach: I_STAR %x...", v);
590 v = ISAC_READ(I_MODE);
591 #ifdef AVMA1PCI_DEBUG
592 kprintf("avma1pp_attach: I_MODE %x...", v);
594 v = ISAC_READ(I_ADF2);
595 #ifdef AVMA1PCI_DEBUG
596 kprintf("avma1pp_attach: I_ADF2 %x...", v);
598 v = ISAC_READ(I_ISTA);
599 #ifdef AVMA1PCI_DEBUG
600 kprintf("avma1pp_attach: I_ISTA %x...", v);
602 if (v & ISAC_ISTA_EXI)
604 v = ISAC_READ(I_EXIR);
605 #ifdef AVMA1PCI_DEBUG
606 kprintf("avma1pp_attach: I_EXIR %x...", v);
609 v = ISAC_READ(I_CIRR);
610 #ifdef AVMA1PCI_DEBUG
611 kprintf("avma1pp_attach: I_CIRR %x...", v);
613 ISAC_WRITE(I_MASK, 0xff);
614 /* the Linux driver does this to clear any pending HSCX interrupts */
615 v = hscx_read_reg_int(0, HSCX_STAT, sc);
616 #ifdef AVMA1PCI_DEBUG
617 kprintf("avma1pp_attach: 0 HSCX_STAT %x...", v);
619 v = hscx_read_reg_int(1, HSCX_STAT, sc);
620 #ifdef AVMA1PCI_DEBUG
621 kprintf("avma1pp_attach: 1 HSCX_STAT %x\n", v);
624 bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_RESET_ALL|ASL_TIMERDISABLE);
625 DELAY(SEC_DELAY/100); /* 10 ms */
626 bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_TIMERRESET|ASL_ENABLE_INT|ASL_TIMERDISABLE);
627 DELAY(SEC_DELAY/100); /* 10 ms */
628 #ifdef AVMA1PCI_DEBUG
629 bus_space_write_1(btag, bhandle, STAT1_OFFSET, ASL1_ENABLE_IOM|sc->sc_irq);
630 DELAY(SEC_DELAY/100); /* 10 ms */
631 v = bus_space_read_1(btag, bhandle, STAT1_OFFSET);
632 kprintf("after reset: S1 %#x\n", v);
634 v = bus_space_read_4(btag, bhandle, 0);
635 kprintf("avma1pp_attach_avma1pp: v %#x\n", v);
638 /* from here to the end would normally be done in isic_pciattach */
640 kprintf("ifpi%d: ISAC %s (IOM-%c)\n", unit,
641 "2085 Version A1/A2 or 2086/2186 Version 1.1",
642 sc->sc_bustyp == BUS_TYPE_IOM1 ? '1' : '2');
647 /* init the "HSCX" */
648 avma1pp_bchannel_setup(sc->sc_unit, HSCX_CH_A, BPROT_NONE, 0);
650 avma1pp_bchannel_setup(sc->sc_unit, HSCX_CH_B, BPROT_NONE, 0);
652 /* can't use the normal B-Channel stuff */
653 avma1pp_init_linktab(sc);
655 /* set trace level */
657 sc->sc_trace = TRACE_OFF;
659 sc->sc_state = ISAC_IDLE;
671 sc->sc_freeflag2 = 0;
673 callout_init(&sc->sc_T3_timeout);
674 callout_init(&sc->sc_T4_timeout);
676 /* init higher protocol layers */
678 i4b_l1_mph_status_ind(L0IFPIUNIT(sc->sc_unit), STI_ATTACH, sc->sc_cardtyp, &avma1pp_l1mux_func);
686 * this is the real interrupt routine
689 avma1pp_hscx_intr(int h_chan, u_int stat, struct l1_softc *sc)
691 l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
695 NDBGL1(L1_H_IRQ, "%#x", stat);
697 if((stat & HSCX_INT_XDU) && (chan->bprot != BPROT_NONE))/* xmit data underrun */
700 NDBGL1(L1_H_XFRERR, "xmit data underrun");
701 /* abort the transmission */
703 sc->avma1pp_cmd |= HSCX_CMD_XRS;
704 AVMA1PPSETCMDLONG(param);
705 hscx_write_reg(h_chan, HSCX_STAT, param, sc);
706 sc->avma1pp_cmd &= ~HSCX_CMD_XRS;
707 AVMA1PPSETCMDLONG(param);
708 hscx_write_reg(h_chan, HSCX_STAT, param, sc);
710 if (chan->out_mbuf_head != NULL) /* don't continue to transmit this buffer */
712 i4b_Bfreembuf(chan->out_mbuf_head);
713 chan->out_mbuf_cur = chan->out_mbuf_head = NULL;
718 * The following is based on examination of the Linux driver.
720 * The logic here is different than with a "real" HSCX; all kinds
721 * of information (interrupt/status bits) are in stat.
722 * HSCX_INT_RPR indicates a receive interrupt
723 * HSCX_STAT_RDO indicates an overrun condition, abort -
724 * otherwise read the bytes ((stat & HSCX_STZT_RML_MASK) >> 8)
725 * HSCX_STAT_RME indicates end-of-frame and apparently any
726 * CRC/framing errors are only reported in this state.
727 * if ((stat & HSCX_STAT_CRCVFRRAB) != HSCX_STAT_CRCVFR)
731 if(stat & HSCX_INT_RPR)
735 /* always have to read the FIFO, so use a scratch buffer */
736 u_char scrbuf[HSCX_FIFO_LEN];
738 if(stat & HSCX_STAT_RDO)
741 NDBGL1(L1_H_XFRERR, "receive data overflow");
746 * check whether we're receiving data for an inactive B-channel
747 * and discard it. This appears to happen for telephony when
748 * both B-channels are active and one is deactivated. Since
749 * it is not really possible to deactivate the channel in that
750 * case (the ASIC seems to deactivate _both_ channels), the
751 * "deactivated" channel keeps receiving data which can lead
752 * to exhaustion of mbufs and a kernel panic.
754 * This is a hack, but it's the only solution I can think of
755 * without having the documentation for the ASIC.
758 if (chan->state == HSCX_IDLE)
760 NDBGL1(L1_H_XFRERR, "toss data from %d", h_chan);
764 fifo_data_len = ((stat & HSCX_STAT_RML_MASK) >> 8);
766 if(fifo_data_len == 0)
767 fifo_data_len = sc->sc_bfifolen;
769 /* ALWAYS read data from HSCX fifo */
771 HSCX_RDFIFO(h_chan, scrbuf, fifo_data_len);
772 chan->rxcount += fifo_data_len;
774 /* all error conditions checked, now decide and take action */
778 if(chan->in_mbuf == NULL)
780 if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
781 panic("L1 avma1pp_hscx_intr: RME, cannot allocate mbuf!\n");
782 chan->in_cbptr = chan->in_mbuf->m_data;
786 if((chan->in_len + fifo_data_len) <= BCH_MAX_DATALEN)
788 /* OK to copy the data */
789 bcopy(scrbuf, chan->in_cbptr, fifo_data_len);
790 chan->in_cbptr += fifo_data_len;
791 chan->in_len += fifo_data_len;
793 /* setup mbuf data length */
795 chan->in_mbuf->m_len = chan->in_len;
796 chan->in_mbuf->m_pkthdr.len = chan->in_len;
798 if(sc->sc_trace & TRACE_B_RX)
801 hdr.unit = L0IFPIUNIT(sc->sc_unit);
802 hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
804 hdr.count = ++sc->sc_trace_bcount;
806 i4b_l1_trace_ind(&hdr, chan->in_mbuf->m_len, chan->in_mbuf->m_data);
809 if (stat & HSCX_STAT_RME)
811 if((stat & HSCX_STAT_CRCVFRRAB) == HSCX_STAT_CRCVFR)
813 (*chan->isic_drvr_linktab->bch_rx_data_ready)(chan->isic_drvr_linktab->unit);
816 /* mark buffer ptr as unused */
818 chan->in_mbuf = NULL;
819 chan->in_cbptr = NULL;
825 NDBGL1(L1_H_XFRERR, "CRC/RAB");
826 if (chan->in_mbuf != NULL)
828 i4b_Bfreembuf(chan->in_mbuf);
829 chan->in_mbuf = NULL;
830 chan->in_cbptr = NULL;
835 } /* END enough space in mbuf */
838 if(chan->bprot == BPROT_NONE)
840 /* setup mbuf data length */
842 chan->in_mbuf->m_len = chan->in_len;
843 chan->in_mbuf->m_pkthdr.len = chan->in_len;
845 if(sc->sc_trace & TRACE_B_RX)
848 hdr.unit = L0IFPIUNIT(sc->sc_unit);
849 hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
851 hdr.count = ++sc->sc_trace_bcount;
853 i4b_l1_trace_ind(&hdr, chan->in_mbuf->m_len, chan->in_mbuf->m_data);
856 if(!(i4b_l1_bchan_tel_silence(chan->in_mbuf->m_data, chan->in_mbuf->m_len)))
859 /* move rx'd data to rx queue */
861 if(!(IF_QFULL(&chan->rx_queue)))
863 IF_ENQUEUE(&chan->rx_queue, chan->in_mbuf);
867 i4b_Bfreembuf(chan->in_mbuf);
869 /* signal upper layer that data are available */
870 (*chan->isic_drvr_linktab->bch_rx_data_ready)(chan->isic_drvr_linktab->unit);
872 /* alloc new buffer */
874 if((chan->in_mbuf = i4b_Bgetmbuf(BCH_MAX_DATALEN)) == NULL)
875 panic("L1 avma1pp_hscx_intr: RPF, cannot allocate new mbuf!\n");
877 /* setup new data ptr */
879 chan->in_cbptr = chan->in_mbuf->m_data;
881 /* OK to copy the data */
882 bcopy(scrbuf, chan->in_cbptr, fifo_data_len);
884 chan->in_cbptr += fifo_data_len;
885 chan->in_len = fifo_data_len;
887 chan->rxcount += fifo_data_len;
891 NDBGL1(L1_H_XFRERR, "RAWHDLC rx buffer overflow in RPF, in_len=%d", chan->in_len);
892 chan->in_cbptr = chan->in_mbuf->m_data;
896 } /* if(error == 0) */
899 /* land here for RDO */
900 if (chan->in_mbuf != NULL)
902 i4b_Bfreembuf(chan->in_mbuf);
903 chan->in_mbuf = NULL;
904 chan->in_cbptr = NULL;
908 sc->avma1pp_cmd |= HSCX_CMD_RRS;
909 AVMA1PPSETCMDLONG(param);
910 hscx_write_reg(h_chan, HSCX_STAT, param, sc);
911 sc->avma1pp_cmd &= ~HSCX_CMD_RRS;
912 AVMA1PPSETCMDLONG(param);
913 hscx_write_reg(h_chan, HSCX_STAT, param, sc);
918 /* transmit fifo empty, new data can be written to fifo */
920 if(stat & HSCX_INT_XPR)
923 * for a description what is going on here, please have
924 * a look at isic_bchannel_start() in i4b_bchan.c !
927 NDBGL1(L1_H_IRQ, "unit %d, chan %d - XPR, Tx Fifo Empty!", sc->sc_unit, h_chan);
929 if(chan->out_mbuf_cur == NULL) /* last frame is transmitted */
931 IF_DEQUEUE(&chan->tx_queue, chan->out_mbuf_head);
933 if(chan->out_mbuf_head == NULL)
935 chan->state &= ~HSCX_TX_ACTIVE;
936 (*chan->isic_drvr_linktab->bch_tx_queue_empty)(chan->isic_drvr_linktab->unit);
940 chan->state |= HSCX_TX_ACTIVE;
941 chan->out_mbuf_cur = chan->out_mbuf_head;
942 chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
943 chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
945 if(sc->sc_trace & TRACE_B_TX)
948 hdr.unit = L0IFPIUNIT(sc->sc_unit);
949 hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
951 hdr.count = ++sc->sc_trace_bcount;
953 i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
956 if(chan->bprot == BPROT_NONE)
958 if(!(i4b_l1_bchan_tel_silence(chan->out_mbuf_cur->m_data, chan->out_mbuf_cur->m_len)))
968 avma1pp_hscx_fifo(chan, sc);
971 /* call timeout handling routine */
973 if(activity == ACT_RX || activity == ACT_TX)
974 (*chan->isic_drvr_linktab->bch_activity)(chan->isic_drvr_linktab->unit, activity);
978 * this is the main routine which checks each channel and then calls
979 * the real interrupt routine as appropriate
982 avma1pp_hscx_int_handler(struct l1_softc *sc)
986 /* has to be a u_int because the byte count is in the 2nd byte */
987 stat = hscx_read_reg_int(0, HSCX_STAT, sc);
988 if (stat & HSCX_INT_MASK)
989 avma1pp_hscx_intr(0, stat, sc);
990 stat = hscx_read_reg_int(1, HSCX_STAT, sc);
991 if (stat & HSCX_INT_MASK)
992 avma1pp_hscx_intr(1, stat, sc);
996 avma1pp_disable(device_t dev)
998 struct l1_softc *sc = device_get_softc(dev);
999 bus_space_handle_t bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
1000 bus_space_tag_t btag = rman_get_bustag(sc->sc_resources.io_base[0]);
1002 bus_space_write_1(btag, bhandle, STAT0_OFFSET, ASL_RESET_ALL|ASL_TIMERDISABLE);
1006 avma1pp_intr(void *xsc)
1009 struct l1_softc *sc;
1010 bus_space_handle_t bhandle;
1011 bus_space_tag_t btag;
1014 bhandle = rman_get_bushandle(sc->sc_resources.io_base[0]);
1015 btag = rman_get_bustag(sc->sc_resources.io_base[0]);
1017 stat = bus_space_read_1(btag, bhandle, STAT0_OFFSET);
1018 NDBGL1(L1_H_IRQ, "stat %x", stat);
1019 /* was there an interrupt from this card ? */
1020 if ((stat & ASL_IRQ_Pending) == ASL_IRQ_Pending)
1022 /* interrupts are low active */
1023 if (!(stat & ASL_IRQ_TIMER))
1024 NDBGL1(L1_H_IRQ, "timer interrupt ???");
1025 if (!(stat & ASL_IRQ_HSCX))
1027 NDBGL1(L1_H_IRQ, "HSCX");
1028 avma1pp_hscx_int_handler(sc);
1030 if (!(stat & ASL_IRQ_ISAC))
1032 NDBGL1(L1_H_IRQ, "ISAC");
1038 avma1pp_hscx_init(struct l1_softc *sc, int h_chan, int activate)
1040 l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
1043 NDBGL1(L1_BCHAN, "unit=%d, channel=%d, %s",
1044 sc->sc_unit, h_chan, activate ? "activate" : "deactivate");
1048 /* only deactivate if both channels are idle */
1049 if (sc->sc_chan[HSCX_CH_A].state != HSCX_IDLE ||
1050 sc->sc_chan[HSCX_CH_B].state != HSCX_IDLE)
1054 sc->avma1pp_cmd = HSCX_CMD_XRS|HSCX_CMD_RRS;
1055 sc->avma1pp_prot = HSCX_MODE_TRANS;
1056 AVMA1PPSETCMDLONG(param);
1057 hscx_write_reg(h_chan, HSCX_STAT, param, sc);
1060 if(chan->bprot == BPROT_RHDLC)
1062 NDBGL1(L1_BCHAN, "BPROT_RHDLC");
1064 /* HDLC Frames, transparent mode 0 */
1065 sc->avma1pp_cmd = HSCX_CMD_XRS|HSCX_CMD_RRS;
1066 sc->avma1pp_prot = HSCX_MODE_ITF_FLG;
1067 AVMA1PPSETCMDLONG(param);
1068 hscx_write_reg(h_chan, HSCX_STAT, param, sc);
1069 sc->avma1pp_cmd = HSCX_CMD_XRS;
1070 AVMA1PPSETCMDLONG(param);
1071 hscx_write_reg(h_chan, HSCX_STAT, param, sc);
1072 sc->avma1pp_cmd = 0;
1076 NDBGL1(L1_BCHAN, "BPROT_NONE??");
1078 /* Raw Telephony, extended transparent mode 1 */
1079 sc->avma1pp_cmd = HSCX_CMD_XRS|HSCX_CMD_RRS;
1080 sc->avma1pp_prot = HSCX_MODE_TRANS;
1081 AVMA1PPSETCMDLONG(param);
1082 hscx_write_reg(h_chan, HSCX_STAT, param, sc);
1083 sc->avma1pp_cmd = HSCX_CMD_XRS;
1084 AVMA1PPSETCMDLONG(param);
1085 hscx_write_reg(h_chan, HSCX_STAT, param, sc);
1086 sc->avma1pp_cmd = 0;
1091 avma1pp_bchannel_setup(int unit, int h_chan, int bprot, int activate)
1093 struct l1_softc *sc = ifpi_scp[unit];
1094 l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
1101 chan->state = HSCX_IDLE;
1102 avma1pp_hscx_init(sc, h_chan, activate);
1105 NDBGL1(L1_BCHAN, "unit=%d, channel=%d, %s",
1106 sc->sc_unit, h_chan, activate ? "activate" : "deactivate");
1110 chan->unit = sc->sc_unit; /* unit number */
1111 chan->channel = h_chan; /* B channel */
1112 chan->bprot = bprot; /* B channel protocol */
1113 chan->state = HSCX_IDLE; /* B channel state */
1117 chan->rx_queue.ifq_maxlen = IFQ_MAXLEN;
1119 i4b_Bcleanifq(&chan->rx_queue); /* clean rx queue */
1121 chan->rxcount = 0; /* reset rx counter */
1123 i4b_Bfreembuf(chan->in_mbuf); /* clean rx mbuf */
1125 chan->in_mbuf = NULL; /* reset mbuf ptr */
1126 chan->in_cbptr = NULL; /* reset mbuf curr ptr */
1127 chan->in_len = 0; /* reset mbuf data len */
1129 /* transmitter part */
1131 chan->tx_queue.ifq_maxlen = IFQ_MAXLEN;
1133 i4b_Bcleanifq(&chan->tx_queue); /* clean tx queue */
1135 chan->txcount = 0; /* reset tx counter */
1137 i4b_Bfreembuf(chan->out_mbuf_head); /* clean tx mbuf */
1139 chan->out_mbuf_head = NULL; /* reset head mbuf ptr */
1140 chan->out_mbuf_cur = NULL; /* reset current mbuf ptr */
1141 chan->out_mbuf_cur_ptr = NULL; /* reset current mbuf data ptr */
1142 chan->out_mbuf_cur_len = 0; /* reset current mbuf data cnt */
1147 avma1pp_hscx_init(sc, h_chan, activate);
1148 chan->state |= HSCX_AVMA1PP_ACTIVE;
1155 avma1pp_bchannel_start(int unit, int h_chan)
1157 struct l1_softc *sc = ifpi_scp[unit];
1158 l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
1162 if(chan->state & HSCX_TX_ACTIVE) /* already running ? */
1165 return; /* yes, leave */
1168 /* get next mbuf from queue */
1170 IF_DEQUEUE(&chan->tx_queue, chan->out_mbuf_head);
1172 if(chan->out_mbuf_head == NULL) /* queue empty ? */
1175 return; /* yes, exit */
1178 /* init current mbuf values */
1180 chan->out_mbuf_cur = chan->out_mbuf_head;
1181 chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
1182 chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
1184 /* activity indicator for timeout handling */
1186 if(chan->bprot == BPROT_NONE)
1188 if(!(i4b_l1_bchan_tel_silence(chan->out_mbuf_cur->m_data, chan->out_mbuf_cur->m_len)))
1196 chan->state |= HSCX_TX_ACTIVE; /* we start transmitting */
1198 if(sc->sc_trace & TRACE_B_TX) /* if trace, send mbuf to trace dev */
1200 i4b_trace_hdr_t hdr;
1201 hdr.unit = L0IFPIUNIT(sc->sc_unit);
1202 hdr.type = (h_chan == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
1204 hdr.count = ++sc->sc_trace_bcount;
1205 MICROTIME(hdr.time);
1206 i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
1209 avma1pp_hscx_fifo(chan, sc);
1211 /* call timeout handling routine */
1213 if(activity == ACT_RX || activity == ACT_TX)
1214 (*chan->isic_drvr_linktab->bch_activity)(chan->isic_drvr_linktab->unit, activity);
1219 /*---------------------------------------------------------------------------*
1220 * return the address of isic drivers linktab
1221 *---------------------------------------------------------------------------*/
1222 static isdn_link_t *
1223 avma1pp_ret_linktab(int unit, int channel)
1225 struct l1_softc *sc = ifpi_scp[unit];
1226 l1_bchan_state_t *chan = &sc->sc_chan[channel];
1228 return(&chan->isic_isdn_linktab);
1231 /*---------------------------------------------------------------------------*
1232 * set the driver linktab in the b channel softc
1233 *---------------------------------------------------------------------------*/
1235 avma1pp_set_linktab(int unit, int channel, drvr_link_t *dlt)
1237 struct l1_softc *sc = ifpi_scp[unit];
1238 l1_bchan_state_t *chan = &sc->sc_chan[channel];
1240 chan->isic_drvr_linktab = dlt;
1244 /*---------------------------------------------------------------------------*
1245 * initialize our local linktab
1246 *---------------------------------------------------------------------------*/
1248 avma1pp_init_linktab(struct l1_softc *sc)
1250 l1_bchan_state_t *chan = &sc->sc_chan[HSCX_CH_A];
1251 isdn_link_t *lt = &chan->isic_isdn_linktab;
1253 /* make sure the hardware driver is known to layer 4 */
1254 /* avoid overwriting if already set */
1255 if (ctrl_types[CTRL_PASSIVE].set_linktab == NULL)
1257 ctrl_types[CTRL_PASSIVE].set_linktab = avma1pp_set_linktab;
1258 ctrl_types[CTRL_PASSIVE].get_linktab = avma1pp_ret_linktab;
1262 lt->unit = sc->sc_unit;
1263 lt->channel = HSCX_CH_A;
1264 lt->bch_config = avma1pp_bchannel_setup;
1265 lt->bch_tx_start = avma1pp_bchannel_start;
1266 lt->bch_stat = avma1pp_bchannel_stat;
1267 lt->tx_queue = &chan->tx_queue;
1269 /* used by non-HDLC data transfers, i.e. telephony drivers */
1270 lt->rx_queue = &chan->rx_queue;
1272 /* used by HDLC data transfers, i.e. ipr and isp drivers */
1273 lt->rx_mbuf = &chan->in_mbuf;
1275 chan = &sc->sc_chan[HSCX_CH_B];
1276 lt = &chan->isic_isdn_linktab;
1278 lt->unit = sc->sc_unit;
1279 lt->channel = HSCX_CH_B;
1280 lt->bch_config = avma1pp_bchannel_setup;
1281 lt->bch_tx_start = avma1pp_bchannel_start;
1282 lt->bch_stat = avma1pp_bchannel_stat;
1283 lt->tx_queue = &chan->tx_queue;
1285 /* used by non-HDLC data transfers, i.e. telephony drivers */
1286 lt->rx_queue = &chan->rx_queue;
1288 /* used by HDLC data transfers, i.e. ipr and isp drivers */
1289 lt->rx_mbuf = &chan->in_mbuf;
1293 * use this instead of isic_bchannel_stat in i4b_bchan.c because it's static
1296 avma1pp_bchannel_stat(int unit, int h_chan, bchan_statistics_t *bsp)
1298 struct l1_softc *sc = ifpi_scp[unit];
1299 l1_bchan_state_t *chan = &sc->sc_chan[h_chan];
1303 bsp->outbytes = chan->txcount;
1304 bsp->inbytes = chan->rxcount;
1312 /*---------------------------------------------------------------------------*
1313 * fill HSCX fifo with data from the current mbuf
1314 * Put this here until it can go into i4b_hscx.c
1315 *---------------------------------------------------------------------------*/
1317 avma1pp_hscx_fifo(l1_bchan_state_t *chan, struct l1_softc *sc)
1323 /* using a scratch buffer simplifies writing to the FIFO */
1324 u_char scrbuf[HSCX_FIFO_LEN];
1329 * fill the HSCX tx fifo with data from the current mbuf. if
1330 * current mbuf holds less data than HSCX fifo length, try to
1331 * get the next mbuf from (a possible) mbuf chain. if there is
1332 * not enough data in a single mbuf or in a chain, then this
1333 * is the last mbuf and we tell the HSCX that it has to send
1334 * CRC and closing flag
1337 while(chan->out_mbuf_cur && len != sc->sc_bfifolen)
1339 nextlen = min(chan->out_mbuf_cur_len, sc->sc_bfifolen - len);
1342 kprintf("i:mh=%p, mc=%p, mcp=%p, mcl=%d l=%d nl=%d # ",
1343 chan->out_mbuf_head,
1345 chan->out_mbuf_cur_ptr,
1346 chan->out_mbuf_cur_len,
1351 cmd |= HSCX_CMDR_XTF;
1352 /* collect the data in the scratch buffer */
1353 for (i = 0; i < nextlen; i++)
1354 scrbuf[i + len] = chan->out_mbuf_cur_ptr[i];
1357 chan->txcount += nextlen;
1359 chan->out_mbuf_cur_ptr += nextlen;
1360 chan->out_mbuf_cur_len -= nextlen;
1362 if(chan->out_mbuf_cur_len == 0)
1364 if((chan->out_mbuf_cur = chan->out_mbuf_cur->m_next) != NULL)
1366 chan->out_mbuf_cur_ptr = chan->out_mbuf_cur->m_data;
1367 chan->out_mbuf_cur_len = chan->out_mbuf_cur->m_len;
1369 if(sc->sc_trace & TRACE_B_TX)
1371 i4b_trace_hdr_t hdr;
1372 hdr.unit = L0IFPIUNIT(sc->sc_unit);
1373 hdr.type = (chan->channel == HSCX_CH_A ? TRC_CH_B1 : TRC_CH_B2);
1375 hdr.count = ++sc->sc_trace_bcount;
1376 MICROTIME(hdr.time);
1377 i4b_l1_trace_ind(&hdr, chan->out_mbuf_cur->m_len, chan->out_mbuf_cur->m_data);
1382 if (chan->bprot != BPROT_NONE)
1383 cmd |= HSCX_CMDR_XME;
1384 i4b_Bfreembuf(chan->out_mbuf_head);
1385 chan->out_mbuf_head = NULL;
1389 /* write what we have from the scratch buf to the HSCX fifo */
1391 HSCX_WRFIFO(chan->channel, scrbuf, len);
1395 /*---------------------------------------------------------------------------*
1396 * ifpi - ISAC interrupt routine
1397 *---------------------------------------------------------------------------*/
1399 ifpi_isac_intr(struct l1_softc *sc)
1401 u_char isac_irq_stat;
1405 /* get isac irq status */
1406 isac_irq_stat = ISAC_READ(I_ISTA);
1409 ifpi_isac_irq(sc, isac_irq_stat); /* isac handler */
1414 ISAC_WRITE(I_MASK, 0xff);
1418 ISAC_WRITE(I_MASK, ISAC_IMASK);
1421 /*---------------------------------------------------------------------------*
1422 * ifpi_recover - try to recover from irq lockup
1423 *---------------------------------------------------------------------------*/
1425 ifpi_recover(struct l1_softc *sc)
1429 /* get isac irq status */
1431 byte = ISAC_READ(I_ISTA);
1433 NDBGL1(L1_ERROR, " ISAC: ISTA = 0x%x", byte);
1435 if(byte & ISAC_ISTA_EXI)
1436 NDBGL1(L1_ERROR, " ISAC: EXIR = 0x%x", (u_char)ISAC_READ(I_EXIR));
1438 if(byte & ISAC_ISTA_CISQ)
1440 byte = ISAC_READ(I_CIRR);
1442 NDBGL1(L1_ERROR, " ISAC: CISQ = 0x%x", byte);
1444 if(byte & ISAC_CIRR_SQC)
1445 NDBGL1(L1_ERROR, " ISAC: SQRR = 0x%x", (u_char)ISAC_READ(I_SQRR));
1448 NDBGL1(L1_ERROR, " ISAC: IMASK = 0x%x", ISAC_IMASK);
1450 ISAC_WRITE(I_MASK, 0xff);
1452 ISAC_WRITE(I_MASK, ISAC_IMASK);
1456 #endif /* NIFPI > 0 */