2 * Copyright (c) 1999, 2000 Udo Schweigert. 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 * Siemens I-Surf 2.0 PnP specific routines for isic driver
35 * --------------------------------------------------------
36 * Based on ELSA Quickstep 1000pro PCI driver (i4b_elsa_qs1p.c)
37 * In case of trouble please contact Udo Schweigert <ust@cert.siemens.de>
39 * last edit-date: [Wed Jan 24 09:13:25 2001]
41 *---------------------------------------------------------------------------*/
43 #include <sys/cdefs.h>
44 __FBSDID("$FreeBSD$");
48 #if defined(SIEMENS_ISURF2)
50 #include <sys/param.h>
51 #include <sys/systm.h>
52 #include <sys/socket.h>
56 #include <i4b/include/i4b_ioctl.h>
58 #include <i4b/layer1/isic/i4b_isic.h>
59 #include <i4b/layer1/isic/i4b_ipac.h>
61 /* masks for register encoded in base addr */
63 #define SIE_ISURF_BASE_MASK 0x0ffff
64 #define SIE_ISURF_OFF_MASK 0xf0000
66 /* register id's to be encoded in base addr */
68 #define SIE_ISURF_IDISAC 0x00000
69 #define SIE_ISURF_IDHSCXA 0x10000
70 #define SIE_ISURF_IDHSCXB 0x20000
71 #define SIE_ISURF_IDIPAC 0x40000
73 /* offsets from base address */
75 #define SIE_ISURF_OFF_ALE 0x00
76 #define SIE_ISURF_OFF_RW 0x01
78 /*---------------------------------------------------------------------------*
79 * Siemens I-Surf 2.0 PnP ISAC get fifo routine
80 *---------------------------------------------------------------------------*/
82 siemens_isurf_read_fifo(struct l1_softc *sc,int what,void *buf,size_t size)
84 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
85 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
90 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,IPAC_ISAC_OFF);
91 bus_space_read_multi_1(t,h,SIE_ISURF_OFF_RW,buf,size);
94 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,IPAC_HSCXA_OFF);
95 bus_space_read_multi_1(t,h,SIE_ISURF_OFF_RW,buf,size);
98 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,IPAC_HSCXB_OFF);
99 bus_space_read_multi_1(t,h,SIE_ISURF_OFF_RW,buf,size);
104 /*---------------------------------------------------------------------------*
105 * Siemens I-Surf 2.0 PnP ISAC put fifo routine
106 *---------------------------------------------------------------------------*/
108 siemens_isurf_write_fifo(struct l1_softc *sc,int what,void *buf,size_t size)
110 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
111 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
116 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,IPAC_ISAC_OFF);
117 bus_space_write_multi_1(t,h,SIE_ISURF_OFF_RW,buf,size);
119 case ISIC_WHAT_HSCXA:
120 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,IPAC_HSCXA_OFF);
121 bus_space_write_multi_1(t,h,SIE_ISURF_OFF_RW,buf,size);
123 case ISIC_WHAT_HSCXB:
124 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,IPAC_HSCXB_OFF);
125 bus_space_write_multi_1(t,h,SIE_ISURF_OFF_RW,buf,size);
130 /*---------------------------------------------------------------------------*
131 * Siemens I-Surf 2.0 PnP ISAC put register routine
132 *---------------------------------------------------------------------------*/
134 siemens_isurf_write_reg(struct l1_softc *sc,int what,bus_size_t reg,u_int8_t data)
136 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
137 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
142 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_ISAC_OFF);
143 bus_space_write_1(t,h,SIE_ISURF_OFF_RW,data);
145 case ISIC_WHAT_HSCXA:
146 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_HSCXA_OFF);
147 bus_space_write_1(t,h,SIE_ISURF_OFF_RW,data);
149 case ISIC_WHAT_HSCXB:
150 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_HSCXB_OFF);
151 bus_space_write_1(t,h,SIE_ISURF_OFF_RW,data);
154 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_IPAC_OFF);
155 bus_space_write_1(t,h,SIE_ISURF_OFF_RW,data);
160 /*---------------------------------------------------------------------------*
161 * Siemens I-Surf 2.0 PnP ISAC get register routine
162 *---------------------------------------------------------------------------*/
164 siemens_isurf_read_reg(struct l1_softc *sc,int what,bus_size_t reg)
166 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
167 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
172 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_ISAC_OFF);
173 return bus_space_read_1(t,h,SIE_ISURF_OFF_RW);
174 case ISIC_WHAT_HSCXA:
175 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_HSCXA_OFF);
176 return bus_space_read_1(t,h,SIE_ISURF_OFF_RW);
177 case ISIC_WHAT_HSCXB:
178 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_HSCXB_OFF);
179 return bus_space_read_1(t,h,SIE_ISURF_OFF_RW);
181 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_IPAC_OFF);
182 return bus_space_read_1(t,h,SIE_ISURF_OFF_RW);
188 /*---------------------------------------------------------------------------*
189 * isic_attach_siemens_isurf - attach for Siemens I-Surf 2.0 PnP
190 *---------------------------------------------------------------------------*/
192 isic_attach_siemens_isurf(device_t dev)
194 int unit = device_get_unit(dev);
195 struct l1_softc *sc = &l1_sc[unit];
197 /* setup access routines */
200 sc->readreg = siemens_isurf_read_reg;
201 sc->writereg = siemens_isurf_write_reg;
203 sc->readfifo = siemens_isurf_read_fifo;
204 sc->writefifo = siemens_isurf_write_fifo;
206 /* setup card type */
208 sc->sc_cardtyp = CARD_TYPEP_SIE_ISURF2;
210 /* setup IOM bus type */
212 sc->sc_bustyp = BUS_TYPE_IOM2;
214 /* setup chip type = IPAC ! */
217 sc->sc_bfifolen = IPAC_BFIFO_LEN;
219 /* enable hscx/isac irq's */
221 IPAC_WRITE(IPAC_MASK, (IPAC_MASK_INT1 | IPAC_MASK_INT0));
223 IPAC_WRITE(IPAC_ACFG, 0); /* outputs are open drain */
224 IPAC_WRITE(IPAC_AOE, /* aux 5..2 are inputs, 7, 6 outputs */
225 (IPAC_AOE_OE5 | IPAC_AOE_OE4 | IPAC_AOE_OE3 | IPAC_AOE_OE2));
226 IPAC_WRITE(IPAC_ATX, 0xff); /* set all output lines high */
230 #endif /* defined(SIEMENS_ISURF2) */