2 * Copyright (c) 1999 Ari Suutari. All rights reserved.
4 * Copyright (c) 1997, 2001 Hellmuth Michaelis. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 *---------------------------------------------------------------------------
29 * isic - I4B Siemens ISDN Chipset Driver for Asuscom ISDNlink 128K PnP
30 * =====================================================================
32 * This driver works with Asuscom ISDNlink 128K PnP ISA adapter,
33 * which is based on Siemens IPAC chip (my card probes as ASU1690).
34 * Older Asuscom ISA cards are based on different chipset
35 * (containing two chips) - for those cards, one might want
36 * to try the Dynalink driver.
38 * This driver is heavily based on ELSA Quickstep 1000pro PCI
39 * driver written by Hellmuth Michaelis. Card initialization
40 * code is modeled after Linux i4l driver written by Karsten
43 * $FreeBSD: src/sys/i4b/layer1/isic/i4b_asuscom_ipac.c,v 1.5.2.1 2001/08/10 14:08:38 obrien Exp $
44 * $DragonFly: src/sys/net/i4b/layer1/isic/i4b_asuscom_ipac.c,v 1.4 2003/08/07 21:54:31 dillon Exp $
46 * last edit-date: [Wed Jan 24 09:06:30 2001]
48 *---------------------------------------------------------------------------*/
53 #if (NISIC > 0) && defined (ASUSCOM_IPAC)
55 #include <sys/param.h>
56 #include <sys/systm.h>
57 #include <sys/socket.h>
60 #include <net/i4b/include/machine/i4b_ioctl.h>
64 /* masks for register encoded in base addr */
66 #define ASI_BASE_MASK 0x0ffff
67 #define ASI_OFF_MASK 0xf0000
69 /* register id's to be encoded in base addr */
71 #define ASI_IDISAC 0x00000
72 #define ASI_IDHSCXA 0x10000
73 #define ASI_IDHSCXB 0x20000
74 #define ASI_IDIPAC 0x40000
76 /* offsets from base address */
78 #define ASI_OFF_ALE 0x00
79 #define ASI_OFF_RW 0x01
81 /*---------------------------------------------------------------------------*
82 * Asuscom ISDNlink 128K ISAC get fifo routine
83 *---------------------------------------------------------------------------*/
85 asi_read_fifo(struct l1_softc *sc,int what,void *buf,size_t size)
87 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
88 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
93 bus_space_write_1(t,h,ASI_OFF_ALE,IPAC_ISAC_OFF);
94 bus_space_read_multi_1(t,h,ASI_OFF_RW,buf,size);
97 bus_space_write_1(t,h,ASI_OFF_ALE,IPAC_HSCXA_OFF);
98 bus_space_read_multi_1(t,h,ASI_OFF_RW,buf,size);
100 case ISIC_WHAT_HSCXB:
101 bus_space_write_1(t,h,ASI_OFF_ALE,IPAC_HSCXB_OFF);
102 bus_space_read_multi_1(t,h,ASI_OFF_RW,buf,size);
107 /*---------------------------------------------------------------------------*
108 * Asuscom ISDNlink 128K ISAC put fifo routine
109 *---------------------------------------------------------------------------*/
111 asi_write_fifo(struct l1_softc *sc,int what,void *buf,size_t size)
113 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
114 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
119 bus_space_write_1(t,h,ASI_OFF_ALE,IPAC_ISAC_OFF);
120 bus_space_write_multi_1(t,h,ASI_OFF_RW,buf,size);
122 case ISIC_WHAT_HSCXA:
123 bus_space_write_1(t,h,ASI_OFF_ALE,IPAC_HSCXA_OFF);
124 bus_space_write_multi_1(t,h,ASI_OFF_RW,buf,size);
126 case ISIC_WHAT_HSCXB:
127 bus_space_write_1(t,h,ASI_OFF_ALE,IPAC_HSCXB_OFF);
128 bus_space_write_multi_1(t,h,ASI_OFF_RW,buf,size);
133 /*---------------------------------------------------------------------------*
134 * Asuscom ISDNlink 128K ISAC put register routine
135 *---------------------------------------------------------------------------*/
137 asi_write_reg(struct l1_softc *sc,int what,bus_size_t reg,u_int8_t data)
139 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
140 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
145 bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_ISAC_OFF);
146 bus_space_write_1(t,h,ASI_OFF_RW,data);
148 case ISIC_WHAT_HSCXA:
149 bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_HSCXA_OFF);
150 bus_space_write_1(t,h,ASI_OFF_RW,data);
152 case ISIC_WHAT_HSCXB:
153 bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_HSCXB_OFF);
154 bus_space_write_1(t,h,ASI_OFF_RW,data);
157 bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_IPAC_OFF);
158 bus_space_write_1(t,h,ASI_OFF_RW,data);
163 /*---------------------------------------------------------------------------*
164 * Asuscom ISDNlink 128K ISAC get register routine
165 *---------------------------------------------------------------------------*/
167 asi_read_reg(struct l1_softc *sc,int what,bus_size_t reg)
169 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
170 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
175 bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_ISAC_OFF);
176 return bus_space_read_1(t,h,ASI_OFF_RW);
177 case ISIC_WHAT_HSCXA:
178 bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_HSCXA_OFF);
179 return bus_space_read_1(t,h,ASI_OFF_RW);
180 case ISIC_WHAT_HSCXB:
181 bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_HSCXB_OFF);
182 return bus_space_read_1(t,h,ASI_OFF_RW);
184 bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_IPAC_OFF);
185 return bus_space_read_1(t,h,ASI_OFF_RW);
191 /*---------------------------------------------------------------------------*
192 * isic_attach_siemens_isurf - attach for Asuscom ISDNlink 128K
193 *---------------------------------------------------------------------------*/
195 isic_attach_asi(device_t dev)
197 int unit = device_get_unit(dev);
198 struct l1_softc *sc = &l1_sc[unit];
200 /* setup access routines */
203 sc->readreg = asi_read_reg;
204 sc->writereg = asi_write_reg;
206 sc->readfifo = asi_read_fifo;
207 sc->writefifo = asi_write_fifo;
209 /* setup card type */
211 sc->sc_cardtyp = CARD_TYPEP_ASUSCOMIPAC;
213 /* setup IOM bus type */
215 sc->sc_bustyp = BUS_TYPE_IOM2;
217 /* setup chip type = IPAC ! */
220 sc->sc_bfifolen = IPAC_BFIFO_LEN;
222 /* enable hscx/isac irq's */
224 * This has been taken from Linux driver.
225 * (Removed initialization that was not applicaple to
226 * this board or was already register default setting.)
228 IPAC_WRITE (IPAC_ACFG, 0xff); /* Setup AUX pin modes */
229 IPAC_WRITE (IPAC_AOE, 0x0); /* Setup AUX pin modes */
230 IPAC_WRITE (IPAC_MASK, (IPAC_MASK_INT1 | IPAC_MASK_INT0));
234 #endif /* (NISIC > 0) && defined (ASUSCOM_IPAC) */