2001-01-05 15:49:52 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* i4b_isic.c - global isic stuff
|
|
|
|
* ==============================
|
|
|
|
*
|
2005-02-27 03:26:58 +03:00
|
|
|
* $Id: isic.c,v 1.21 2005/02/27 00:27:01 perry Exp $
|
2001-01-05 15:49:52 +03:00
|
|
|
*
|
|
|
|
* last edit-date: [Fri Jan 5 11:36:10 2001]
|
|
|
|
*
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
|
2001-11-13 16:14:31 +03:00
|
|
|
#include <sys/cdefs.h>
|
2005-02-27 03:26:58 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: isic.c,v 1.21 2005/02/27 00:27:01 perry Exp $");
|
2001-11-13 16:14:31 +03:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/ioccom.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <sys/callout.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
|
|
|
|
#include <netisdn/i4b_debug.h>
|
|
|
|
#include <netisdn/i4b_ioctl.h>
|
|
|
|
#include <netisdn/i4b_trace.h>
|
|
|
|
|
2002-03-24 23:35:43 +03:00
|
|
|
#include <netisdn/i4b_l2.h>
|
|
|
|
#include <netisdn/i4b_l1l2.h>
|
|
|
|
#include <netisdn/i4b_mbuf.h>
|
|
|
|
#include <netisdn/i4b_global.h>
|
|
|
|
|
2001-02-21 01:24:31 +03:00
|
|
|
#include <dev/ic/isic_l1.h>
|
|
|
|
#include <dev/ic/ipac.h>
|
|
|
|
#include <dev/ic/isac.h>
|
|
|
|
#include <dev/ic/hscx.h>
|
2001-01-05 15:49:52 +03:00
|
|
|
|
2002-03-24 23:35:43 +03:00
|
|
|
isdn_link_t *isic_ret_linktab(void*, int channel);
|
|
|
|
void isic_set_link(void*, int channel, const struct isdn_l4_driver_functions *l4_driver, void *l4_driver_softc);
|
2002-03-30 14:15:41 +03:00
|
|
|
void n_connect_request(struct call_desc *cd);
|
|
|
|
void n_connect_response(struct call_desc *cd, int response, int cause);
|
|
|
|
void n_disconnect_request(struct call_desc *cd, int cause);
|
|
|
|
void n_alert_request(struct call_desc *cd);
|
|
|
|
void n_mgmt_command(struct isdn_l3_driver *drv, int cmd, void *parm);
|
2002-03-24 23:35:43 +03:00
|
|
|
|
|
|
|
const struct isdn_l3_driver_functions
|
|
|
|
isic_l3_driver = {
|
|
|
|
isic_ret_linktab,
|
|
|
|
isic_set_link,
|
|
|
|
n_connect_request,
|
|
|
|
n_connect_response,
|
|
|
|
n_disconnect_request,
|
|
|
|
n_alert_request,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
n_mgmt_command
|
|
|
|
};
|
2001-01-05 15:49:52 +03:00
|
|
|
|
|
|
|
/*---------------------------------------------------------------------------*
|
|
|
|
* isic - device driver interrupt routine
|
|
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
int
|
|
|
|
isicintr(void *arg)
|
|
|
|
{
|
2002-03-24 23:35:43 +03:00
|
|
|
struct isic_softc *sc = arg;
|
2002-03-27 10:39:35 +03:00
|
|
|
|
2002-04-08 16:20:49 +04:00
|
|
|
/* could this be an interrupt for us? */
|
2002-04-18 16:19:05 +04:00
|
|
|
if (sc->sc_intr_valid == ISIC_INTR_DYING)
|
|
|
|
return 0; /* do not touch removed hardware */
|
2002-03-27 10:39:35 +03:00
|
|
|
|
2003-01-06 16:04:54 +03:00
|
|
|
if(sc->sc_ipac == 0) /* HSCX/ISAC interrupt routine */
|
2001-01-05 15:49:52 +03:00
|
|
|
{
|
|
|
|
u_char was_hscx_irq = 0;
|
|
|
|
u_char was_isac_irq = 0;
|
|
|
|
|
|
|
|
register u_char hscx_irq_stat;
|
|
|
|
register u_char isac_irq_stat;
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
/* get hscx irq status from hscx b ista */
|
|
|
|
hscx_irq_stat =
|
|
|
|
HSCX_READ(HSCX_CH_B, H_ISTA) & ~HSCX_B_IMASK;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
/* get isac irq status */
|
|
|
|
isac_irq_stat = ISAC_READ(I_ISTA);
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
/* do as long as there are pending irqs in the chips */
|
|
|
|
if(!hscx_irq_stat && !isac_irq_stat)
|
|
|
|
break;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
if(hscx_irq_stat & (HSCX_ISTA_RME | HSCX_ISTA_RPF |
|
|
|
|
HSCX_ISTA_RSC | HSCX_ISTA_XPR |
|
|
|
|
HSCX_ISTA_TIN | HSCX_ISTA_EXB))
|
|
|
|
{
|
|
|
|
isic_hscx_irq(sc, hscx_irq_stat,
|
|
|
|
HSCX_CH_B,
|
|
|
|
hscx_irq_stat & HSCX_ISTA_EXB);
|
2005-02-27 03:26:58 +03:00
|
|
|
was_hscx_irq = 1;
|
2001-01-05 15:49:52 +03:00
|
|
|
}
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
if(hscx_irq_stat & (HSCX_ISTA_ICA | HSCX_ISTA_EXA))
|
|
|
|
{
|
|
|
|
isic_hscx_irq(sc,
|
|
|
|
HSCX_READ(HSCX_CH_A, H_ISTA) & ~HSCX_A_IMASK,
|
|
|
|
HSCX_CH_A,
|
|
|
|
hscx_irq_stat & HSCX_ISTA_EXA);
|
|
|
|
was_hscx_irq = 1;
|
|
|
|
}
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
if(isac_irq_stat)
|
|
|
|
{
|
2002-04-07 01:46:51 +04:00
|
|
|
/* isac handler */
|
|
|
|
isic_isac_irq(sc, isac_irq_stat);
|
2001-01-05 15:49:52 +03:00
|
|
|
was_isac_irq = 1;
|
|
|
|
}
|
|
|
|
}
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
HSCX_WRITE(0, H_MASK, 0xff);
|
|
|
|
ISAC_WRITE(I_MASK, 0xff);
|
|
|
|
HSCX_WRITE(1, H_MASK, 0xff);
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
if (sc->clearirq)
|
|
|
|
{
|
|
|
|
DELAY(80);
|
|
|
|
sc->clearirq(sc);
|
|
|
|
} else
|
|
|
|
DELAY(100);
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
HSCX_WRITE(0, H_MASK, HSCX_A_IMASK);
|
|
|
|
ISAC_WRITE(I_MASK, ISAC_IMASK);
|
|
|
|
HSCX_WRITE(1, H_MASK, HSCX_B_IMASK);
|
2001-01-08 00:47:24 +03:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
return(was_hscx_irq || was_isac_irq);
|
|
|
|
}
|
|
|
|
else /* IPAC interrupt routine */
|
|
|
|
{
|
|
|
|
register u_char ipac_irq_stat;
|
|
|
|
register u_char was_ipac_irq = 0;
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
/* get global irq status */
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
ipac_irq_stat = (IPAC_READ(IPAC_ISTA)) & 0x3f;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
/* check hscx a */
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
if(ipac_irq_stat & (IPAC_ISTA_ICA | IPAC_ISTA_EXA))
|
|
|
|
{
|
|
|
|
/* HSCX A interrupt */
|
|
|
|
isic_hscx_irq(sc, HSCX_READ(HSCX_CH_A, H_ISTA),
|
|
|
|
HSCX_CH_A,
|
|
|
|
ipac_irq_stat & IPAC_ISTA_EXA);
|
2005-02-27 03:26:58 +03:00
|
|
|
was_ipac_irq = 1;
|
2001-01-05 15:49:52 +03:00
|
|
|
}
|
|
|
|
if(ipac_irq_stat & (IPAC_ISTA_ICB | IPAC_ISTA_EXB))
|
|
|
|
{
|
|
|
|
/* HSCX B interrupt */
|
|
|
|
isic_hscx_irq(sc, HSCX_READ(HSCX_CH_B, H_ISTA),
|
|
|
|
HSCX_CH_B,
|
|
|
|
ipac_irq_stat & IPAC_ISTA_EXB);
|
2005-02-27 03:26:58 +03:00
|
|
|
was_ipac_irq = 1;
|
2001-01-05 15:49:52 +03:00
|
|
|
}
|
|
|
|
if(ipac_irq_stat & IPAC_ISTA_ICD)
|
|
|
|
{
|
2002-04-29 17:42:42 +04:00
|
|
|
/* ISAC interrupt, Obey ISAC-IPAC differences */
|
|
|
|
u_int8_t isac_ista = ISAC_READ(I_ISTA);
|
|
|
|
if (isac_ista & 0xfe)
|
|
|
|
isic_isac_irq(sc, isac_ista & 0xfe);
|
|
|
|
if (isac_ista & 0x01) /* unexpected */
|
2005-02-27 03:26:58 +03:00
|
|
|
printf("%s: unexpected ipac timer2 irq\n",
|
2002-04-29 17:42:42 +04:00
|
|
|
sc->sc_dev.dv_xname);
|
2001-01-05 15:49:52 +03:00
|
|
|
was_ipac_irq = 1;
|
|
|
|
}
|
|
|
|
if(ipac_irq_stat & IPAC_ISTA_EXD)
|
|
|
|
{
|
2002-04-29 17:42:42 +04:00
|
|
|
/* ISAC EXI interrupt */
|
|
|
|
isic_isac_irq(sc, ISAC_ISTA_EXI);
|
2001-01-05 15:49:52 +03:00
|
|
|
was_ipac_irq = 1;
|
|
|
|
}
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2001-01-05 15:49:52 +03:00
|
|
|
/* do as long as there are pending irqs in the chip */
|
|
|
|
if(!ipac_irq_stat)
|
|
|
|
break;
|
|
|
|
}
|
2001-01-08 00:47:24 +03:00
|
|
|
|
2002-04-30 16:56:51 +04:00
|
|
|
#if 0
|
|
|
|
/*
|
|
|
|
* This seems not to be necessary on IPACs - no idea why
|
|
|
|
* it is here - but due to limit range of test cards, leave
|
|
|
|
* it in for now, in case we have to resurrect it.
|
|
|
|
*/
|
2001-01-05 15:49:52 +03:00
|
|
|
IPAC_WRITE(IPAC_MASK, 0xff);
|
|
|
|
DELAY(50);
|
|
|
|
IPAC_WRITE(IPAC_MASK, 0xc0);
|
2002-04-30 16:56:51 +04:00
|
|
|
#endif
|
2001-01-05 15:49:52 +03:00
|
|
|
|
|
|
|
return(was_ipac_irq);
|
2005-02-27 03:26:58 +03:00
|
|
|
}
|
2001-01-05 15:49:52 +03:00
|
|
|
}
|
|
|
|
|
2002-03-24 23:35:43 +03:00
|
|
|
int
|
2003-10-03 20:38:44 +04:00
|
|
|
isic_attach_bri(struct isic_softc *sc, const char *cardname, const struct isdn_layer1_isdnif_driver *dchan_driver)
|
2002-03-24 23:35:43 +03:00
|
|
|
{
|
2002-03-25 17:44:46 +03:00
|
|
|
struct isdn_l3_driver * drv;
|
|
|
|
|
2003-10-03 20:38:44 +04:00
|
|
|
drv = isdn_attach_isdnif(sc->sc_dev.dv_xname, cardname,
|
|
|
|
&sc->sc_l2, &isic_l3_driver, NBCH_BRI);
|
2002-03-25 17:44:46 +03:00
|
|
|
sc->sc_l3token = drv;
|
2002-03-24 23:35:43 +03:00
|
|
|
sc->sc_l2.driver = dchan_driver;
|
|
|
|
sc->sc_l2.l1_token = sc;
|
2002-05-21 14:31:10 +04:00
|
|
|
sc->sc_l2.drv = drv;
|
|
|
|
isdn_layer2_status_ind(&sc->sc_l2, drv, STI_ATTACH, 1);
|
2003-10-03 20:38:44 +04:00
|
|
|
isdn_isdnif_ready(drv->isdnif);
|
2002-03-24 23:35:43 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
isic_detach_bri(struct isic_softc *sc)
|
|
|
|
{
|
2002-05-21 14:31:10 +04:00
|
|
|
isdn_layer2_status_ind(&sc->sc_l2, sc->sc_l3token, STI_ATTACH, 0);
|
2003-10-03 20:38:44 +04:00
|
|
|
isdn_detach_isdnif(sc->sc_l3token);
|
2002-03-27 10:39:35 +03:00
|
|
|
sc->sc_l3token = NULL;
|
2002-03-24 23:35:43 +03:00
|
|
|
return 1;
|
|
|
|
}
|