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 $
45 * last edit-date: [Wed Jan 24 09:06:30 2001]
47 *---------------------------------------------------------------------------*/
52 #if (NISIC > 0) && defined (ASUSCOM_IPAC)
54 #include <sys/param.h>
55 #include <sys/systm.h>
56 #include <sys/socket.h>
59 #include <machine/i4b_ioctl.h>
60 #include <i4b/layer1/isic/i4b_isic.h>
61 #include <i4b/layer1/isic/i4b_ipac.h>
63 /* masks for register encoded in base addr */
65 #define ASI_BASE_MASK 0x0ffff
66 #define ASI_OFF_MASK 0xf0000
68 /* register id's to be encoded in base addr */
70 #define ASI_IDISAC 0x00000
71 #define ASI_IDHSCXA 0x10000
72 #define ASI_IDHSCXB 0x20000
73 #define ASI_IDIPAC 0x40000
75 /* offsets from base address */
77 #define ASI_OFF_ALE 0x00
78 #define ASI_OFF_RW 0x01
80 /*---------------------------------------------------------------------------*
81 * Asuscom ISDNlink 128K ISAC get fifo routine
82 *---------------------------------------------------------------------------*/
84 asi_read_fifo(struct l1_softc *sc,int what,void *buf,size_t size)
86 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
87 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
92 bus_space_write_1(t,h,ASI_OFF_ALE,IPAC_ISAC_OFF);
93 bus_space_read_multi_1(t,h,ASI_OFF_RW,buf,size);
96 bus_space_write_1(t,h,ASI_OFF_ALE,IPAC_HSCXA_OFF);
97 bus_space_read_multi_1(t,h,ASI_OFF_RW,buf,size);
100 bus_space_write_1(t,h,ASI_OFF_ALE,IPAC_HSCXB_OFF);
101 bus_space_read_multi_1(t,h,ASI_OFF_RW,buf,size);
106 /*---------------------------------------------------------------------------*
107 * Asuscom ISDNlink 128K ISAC put fifo routine
108 *---------------------------------------------------------------------------*/
110 asi_write_fifo(struct l1_softc *sc,int what,void *buf,size_t size)
112 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
113 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
118 bus_space_write_1(t,h,ASI_OFF_ALE,IPAC_ISAC_OFF);
119 bus_space_write_multi_1(t,h,ASI_OFF_RW,buf,size);
121 case ISIC_WHAT_HSCXA:
122 bus_space_write_1(t,h,ASI_OFF_ALE,IPAC_HSCXA_OFF);
123 bus_space_write_multi_1(t,h,ASI_OFF_RW,buf,size);
125 case ISIC_WHAT_HSCXB:
126 bus_space_write_1(t,h,ASI_OFF_ALE,IPAC_HSCXB_OFF);
127 bus_space_write_multi_1(t,h,ASI_OFF_RW,buf,size);
132 /*---------------------------------------------------------------------------*
133 * Asuscom ISDNlink 128K ISAC put register routine
134 *---------------------------------------------------------------------------*/
136 asi_write_reg(struct l1_softc *sc,int what,bus_size_t reg,u_int8_t data)
138 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
139 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
144 bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_ISAC_OFF);
145 bus_space_write_1(t,h,ASI_OFF_RW,data);
147 case ISIC_WHAT_HSCXA:
148 bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_HSCXA_OFF);
149 bus_space_write_1(t,h,ASI_OFF_RW,data);
151 case ISIC_WHAT_HSCXB:
152 bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_HSCXB_OFF);
153 bus_space_write_1(t,h,ASI_OFF_RW,data);
156 bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_IPAC_OFF);
157 bus_space_write_1(t,h,ASI_OFF_RW,data);
162 /*---------------------------------------------------------------------------*
163 * Asuscom ISDNlink 128K ISAC get register routine
164 *---------------------------------------------------------------------------*/
166 asi_read_reg(struct l1_softc *sc,int what,bus_size_t reg)
168 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
169 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
174 bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_ISAC_OFF);
175 return bus_space_read_1(t,h,ASI_OFF_RW);
176 case ISIC_WHAT_HSCXA:
177 bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_HSCXA_OFF);
178 return bus_space_read_1(t,h,ASI_OFF_RW);
179 case ISIC_WHAT_HSCXB:
180 bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_HSCXB_OFF);
181 return bus_space_read_1(t,h,ASI_OFF_RW);
183 bus_space_write_1(t,h,ASI_OFF_ALE,reg+IPAC_IPAC_OFF);
184 return bus_space_read_1(t,h,ASI_OFF_RW);
190 /*---------------------------------------------------------------------------*
191 * isic_attach_siemens_isurf - attach for Asuscom ISDNlink 128K
192 *---------------------------------------------------------------------------*/
194 isic_attach_asi(device_t dev)
196 int unit = device_get_unit(dev);
197 struct l1_softc *sc = &l1_sc[unit];
199 /* setup access routines */
202 sc->readreg = asi_read_reg;
203 sc->writereg = asi_write_reg;
205 sc->readfifo = asi_read_fifo;
206 sc->writefifo = asi_write_fifo;
208 /* setup card type */
210 sc->sc_cardtyp = CARD_TYPEP_ASUSCOMIPAC;
212 /* setup IOM bus type */
214 sc->sc_bustyp = BUS_TYPE_IOM2;
216 /* setup chip type = IPAC ! */
219 sc->sc_bfifolen = IPAC_BFIFO_LEN;
221 /* enable hscx/isac irq's */
223 * This has been taken from Linux driver.
224 * (Removed initialization that was not applicaple to
225 * this board or was already register default setting.)
227 IPAC_WRITE (IPAC_ACFG, 0xff); /* Setup AUX pin modes */
228 IPAC_WRITE (IPAC_AOE, 0x0); /* Setup AUX pin modes */
229 IPAC_WRITE (IPAC_MASK, (IPAC_MASK_INT1 | IPAC_MASK_INT0));
233 #endif /* (NISIC > 0) && defined (ASUSCOM_IPAC) */