2 * Copyright (c) 1997, 2001 Hellmuth Michaelis. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 *---------------------------------------------------------------------------
27 * i4b_drn_ngo.c - Dr. Neuhaus Niccy GO@ and SAGEM Cybermod
28 * --------------------------------------------------------
30 * $FreeBSD: src/sys/i4b/layer1/isic/i4b_drn_ngo.c,v 1.5.2.1 2001/08/10 14:08:38 obrien Exp $
31 * $DragonFly: src/sys/net/i4b/layer1/isic/i4b_drn_ngo.c,v 1.5 2006/12/22 23:44:56 swildner Exp $
33 * last edit-date: [Wed Jan 24 09:07:44 2001]
35 *---------------------------------------------------------------------------*/
40 #if (NISIC > 0) && defined(DRN_NGO)
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/socket.h>
47 #include <net/i4b/include/machine/i4b_ioctl.h>
52 /*---------------------------------------------------------------------------*
53 * Niccy GO@ definitions
55 * the card uses 2 i/o addressranges each using 2 bytes
58 * offset 0 - ISAC dataregister
59 * offset 1 - HSCX dataregister
61 * offset 0 - ISAC addressregister
62 * offset 1 - HSCX addressregister
64 * to access an ISAC/HSCX register, you have to write the register
65 * number into the ISAC or HSCX addressregister and then read/write
66 * data for the ISAC/HSCX register into/from the corresponding
69 * Thanks to Klaus Muehle of Dr. Neuhaus Telekommunikation for giving
70 * out this information!
72 *---------------------------------------------------------------------------*/
73 #define NICCY_PORT_MIN 0x200
74 #define NICCY_PORT_MAX 0x3e0
76 #define HSCX_ABIT 0x1000 /* flag, HSCX A is meant */
77 #define HSCX_BBIT 0x2000 /* flag, HSCX B is meant */
79 #define HSCX_BOFF 0x40
81 #define ADDR_OFF 2 /* address register range offset */
89 /*---------------------------------------------------------------------------*
90 * Dr. Neuhaus Niccy GO@ read fifo routine
91 *---------------------------------------------------------------------------*/
93 drnngo_read_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
95 bus_space_tag_t tdata, tadr;
96 bus_space_handle_t hdata, hadr;
98 tdata = rman_get_bustag(sc->sc_resources.io_base[0]);
99 hdata = rman_get_bushandle(sc->sc_resources.io_base[0]);
100 tadr = rman_get_bustag(sc->sc_resources.io_base[1]);
101 hadr = rman_get_bushandle(sc->sc_resources.io_base[1]);
106 bus_space_write_1 (tadr ,hadr, ISAC_ADDR,0x0);
107 bus_space_read_multi_1(tdata,hdata,ISAC_DATA,buf,size);
109 case ISIC_WHAT_HSCXA:
110 bus_space_write_1 (tadr ,hadr ,HSCX_ADDR,0x0);
111 bus_space_read_multi_1(tdata,hdata,HSCX_DATA,buf,size);
113 case ISIC_WHAT_HSCXB:
114 bus_space_write_1 (tadr ,hadr ,HSCX_ADDR,HSCX_BOFF);
115 bus_space_read_multi_1(tdata,hdata,HSCX_DATA,buf,size);
120 /*---------------------------------------------------------------------------*
121 * Dr. Neuhaus Niccy GO@ write fifo routine
122 *---------------------------------------------------------------------------*/
124 drnngo_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
126 bus_space_tag_t tdata, tadr;
127 bus_space_handle_t hdata, hadr;
129 tdata = rman_get_bustag(sc->sc_resources.io_base[0]);
130 hdata = rman_get_bushandle(sc->sc_resources.io_base[0]);
131 tadr = rman_get_bustag(sc->sc_resources.io_base[1]);
132 hadr = rman_get_bushandle(sc->sc_resources.io_base[1]);
137 bus_space_write_1 (tadr ,hadr, ISAC_ADDR,0x0);
138 bus_space_write_multi_1(tdata,hdata,ISAC_DATA,buf,size);
140 case ISIC_WHAT_HSCXA:
141 bus_space_write_1 (tadr ,hadr ,HSCX_ADDR,0x0);
142 bus_space_write_multi_1(tdata,hdata,HSCX_DATA,buf,size);
144 case ISIC_WHAT_HSCXB:
145 bus_space_write_1 (tadr ,hadr ,HSCX_ADDR,HSCX_BOFF);
146 bus_space_write_multi_1(tdata,hdata,HSCX_DATA,buf,size);
151 /*---------------------------------------------------------------------------*
152 * Dr. Neuhaus Niccy GO@ write register routine
153 *---------------------------------------------------------------------------*/
155 drnngo_write_reg(struct l1_softc *sc, int what, bus_size_t reg, u_int8_t data)
157 bus_space_tag_t tdata, tadr;
158 bus_space_handle_t hdata, hadr;
160 tdata = rman_get_bustag(sc->sc_resources.io_base[0]);
161 hdata = rman_get_bushandle(sc->sc_resources.io_base[0]);
162 tadr = rman_get_bustag(sc->sc_resources.io_base[1]);
163 hadr = rman_get_bushandle(sc->sc_resources.io_base[1]);
168 bus_space_write_1(tadr ,hadr, ISAC_ADDR,reg);
169 bus_space_write_1(tdata,hdata,ISAC_DATA,data);
171 case ISIC_WHAT_HSCXA:
172 bus_space_write_1(tadr ,hadr ,HSCX_ADDR,reg);
173 bus_space_write_1(tdata,hdata,HSCX_DATA,data);
175 case ISIC_WHAT_HSCXB:
176 bus_space_write_1(tadr ,hadr ,HSCX_ADDR,reg+HSCX_BOFF);
177 bus_space_write_1(tdata,hdata,HSCX_DATA,data);
182 /*---------------------------------------------------------------------------*
183 * Dr. Neuhaus Niccy GO@ read register routine
184 *---------------------------------------------------------------------------*/
186 drnngo_read_reg(struct l1_softc *sc, int what, bus_size_t reg)
188 bus_space_tag_t tdata, tadr;
189 bus_space_handle_t hdata, hadr;
191 tdata = rman_get_bustag(sc->sc_resources.io_base[0]);
192 hdata = rman_get_bushandle(sc->sc_resources.io_base[0]);
193 tadr = rman_get_bustag(sc->sc_resources.io_base[1]);
194 hadr = rman_get_bushandle(sc->sc_resources.io_base[1]);
199 bus_space_write_1(tadr ,hadr, ISAC_ADDR,reg);
200 return bus_space_read_1(tdata,hdata,ISAC_DATA);
201 case ISIC_WHAT_HSCXA:
202 bus_space_write_1(tadr ,hadr ,HSCX_ADDR,reg);
203 return bus_space_read_1(tdata,hdata,HSCX_DATA);
204 case ISIC_WHAT_HSCXB:
205 bus_space_write_1(tadr ,hadr ,HSCX_ADDR,reg+HSCX_BOFF);
206 return bus_space_read_1(tdata,hdata,HSCX_DATA);
212 /*---------------------------------------------------------------------------*
213 * probe for ISA PnP cards
214 *---------------------------------------------------------------------------*/
216 isic_attach_drnngo(device_t dev)
218 int unit = device_get_unit(dev);
219 struct l1_softc *sc = &l1_sc[unit];
221 sc->sc_resources.io_rid[1] = 1;
224 * this card needs a second io_base,
225 * free resources if we don't get it
228 if(!(sc->sc_resources.io_base[1] =
229 bus_alloc_resource(dev, SYS_RES_IOPORT,
230 &sc->sc_resources.io_rid[1],
231 0UL, ~0UL, 1, RF_ACTIVE)))
233 kprintf("isic%d: Failed to get second io base.\n", unit);
234 isic_detach_common(dev);
238 /* setup ISAC access routines */
241 sc->readreg = drnngo_read_reg;
242 sc->writereg = drnngo_write_reg;
244 sc->readfifo = drnngo_read_fifo;
245 sc->writefifo = drnngo_write_fifo;
247 /* setup card type */
249 sc->sc_cardtyp = CARD_TYPEP_DRNNGO;
251 /* setup IOM bus type */
253 sc->sc_bustyp = BUS_TYPE_IOM2;
256 sc->sc_bfifolen = HSCX_FIFO_LEN;
261 #endif /* (NISIC > 0) && defined(DRN_NGO) */