2 * Copyright (c) 1998 Martijn Plak. 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 * isdn4bsd layer1 driver for Dynalink IS64PH isdn TA
35 * ==================================================
36 * last edit-date: [Wed Jan 24 09:08:03 2001]
38 *---------------------------------------------------------------------------*/
40 #include <sys/cdefs.h>
41 __FBSDID("$FreeBSD$");
45 This driver was written for the Dynalink IS64PH ISDN TA, based on two
46 Siemens chips (HSCX 21525 and ISAC 2186). It is sold in the Netherlands.
48 model numbers found on (my) card:
49 IS64PH, TAS100H-N, P/N:89590555, TA200S100045521
52 Siemens PSB 21525N, HSCX TE V2.1
53 Siemens PSB 2186N, ISAC-S TE V1.1
60 i/o port 4 byte alignment, 4 bytes requested,
61 10 bit i/o decoding, 0x100-0x3f8 (?)
62 irq 3,4,5,9,10,11,12,15, high true, edge sensitive
64 At the moment I'm writing this Dynalink is replacing this card with
65 one based on a single Siemens chip (IPAC). It will apparently be sold
66 under the same model name.
68 This driver might also work for Asuscom cards.
75 #include <sys/param.h>
76 #include <sys/systm.h>
77 #include <sys/socket.h>
80 #include <i4b/include/i4b_ioctl.h>
81 #include <i4b/include/i4b_trace.h>
83 #include <i4b/layer1/i4b_l1.h>
84 #include <i4b/layer1/isic/i4b_isic.h>
85 #include <i4b/layer1/isic/i4b_hscx.h>
87 /* io address mapping */
96 /* HSCX register offsets */
100 /* LOW-LEVEL DEVICE ACCESS
104 dynalink_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
106 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
107 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
111 bus_space_write_1(t, h, ADDR, 0);
112 bus_space_read_multi_1(t, h, ISAC, buf, size);
114 case ISIC_WHAT_HSCXA:
115 bus_space_write_1(t, h, ADDR, HSCXA);
116 bus_space_read_multi_1(t, h, HSCX, buf, size);
118 case ISIC_WHAT_HSCXB:
119 bus_space_write_1(t, h, ADDR, HSCXB);
120 bus_space_read_multi_1(t, h, HSCX, buf, size);
126 dynalink_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
128 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
129 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
133 bus_space_write_1(t, h, ADDR, 0);
134 bus_space_write_multi_1(t, h, ISAC, (u_int8_t*)buf, size);
136 case ISIC_WHAT_HSCXA:
137 bus_space_write_1(t, h, ADDR, HSCXA);
138 bus_space_write_multi_1(t, h, HSCX, (u_int8_t*)buf, size);
140 case ISIC_WHAT_HSCXB:
141 bus_space_write_1(t, h, ADDR, HSCXB);
142 bus_space_write_multi_1(t, h, HSCX, (u_int8_t*)buf, size);
148 dynalink_write_reg(struct l1_softc *sc, int what, bus_size_t reg, u_int8_t data)
150 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
151 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
155 bus_space_write_1(t, h, ADDR, reg);
156 bus_space_write_1(t, h, ISAC, data);
158 case ISIC_WHAT_HSCXA:
159 bus_space_write_1(t, h, ADDR, HSCXA+reg);
160 bus_space_write_1(t, h, HSCX, data);
162 case ISIC_WHAT_HSCXB:
163 bus_space_write_1(t, h, ADDR, HSCXB+reg);
164 bus_space_write_1(t, h, HSCX, data);
170 dynalink_read_reg(struct l1_softc *sc, int what, bus_size_t reg)
172 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
173 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
177 bus_space_write_1(t, h, ADDR, reg);
178 return bus_space_read_1(t, h, ISAC);
179 case ISIC_WHAT_HSCXA:
180 bus_space_write_1(t, h, ADDR, HSCXA+reg);
181 return bus_space_read_1(t, h, HSCX);
182 case ISIC_WHAT_HSCXB:
183 bus_space_write_1(t, h, ADDR, HSCXB+reg);
184 return bus_space_read_1(t, h, HSCX);
189 /* attach callback routine */
191 isic_attach_Dyn(device_t dev)
193 int unit = device_get_unit(dev); /* get unit */
194 struct l1_softc *sc = &l1_sc[unit]; /* pointer to softc */
196 struct i4b_info * info = &(sc->sc_resources);
197 bus_space_tag_t t = rman_get_bustag(info->io_base[0]);
198 bus_space_handle_t h = rman_get_bushandle(info->io_base[0]);
200 /* fill in l1_softc structure */
201 sc->readreg = dynalink_read_reg;
202 sc->writereg = dynalink_write_reg;
203 sc->readfifo = dynalink_read_fifo;
204 sc->writefifo = dynalink_write_fifo;
206 sc->sc_cardtyp = CARD_TYPEP_DYNALINK;
207 sc->sc_bustyp = BUS_TYPE_IOM2;
209 sc->sc_bfifolen = HSCX_FIFO_LEN;
211 /* Read HSCX A/B VSTR. Expected value is 0x05 (V2.1). */
212 if( ((HSCX_READ(0, H_VSTR) & 0xf) != 0x5) ||
213 ((HSCX_READ(1, H_VSTR) & 0xf) != 0x5) )
215 printf("isic%d: HSCX VSTR test failed for Dynalink\n",
217 printf("isic%d: HSC0: VSTR: %#x\n",
218 sc->sc_unit, HSCX_READ(0, H_VSTR));
219 printf("isic%d: HSC1: VSTR: %#x\n",
220 sc->sc_unit, HSCX_READ(1, H_VSTR));
225 bus_space_write_1(t,h,ADDR,RESET);
226 DELAY(SEC_DELAY / 10);
227 bus_space_write_1(t,h,ADDR,0);
228 DELAY(SEC_DELAY / 10);
233 #endif /* defined(DYNALINK) */