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
31 *---------------------------------------------------------------------------
33 * Siemens I-Surf 2.0 PnP specific routines for isic driver
34 * --------------------------------------------------------
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 * $FreeBSD: src/sys/i4b/layer1/isic/i4b_siemens_isurf.c,v 1.5.2.1 2001/08/10 14:08:38 obrien Exp $
40 * $DragonFly: src/sys/net/i4b/layer1/isic/i4b_siemens_isurf.c,v 1.2 2003/06/17 04:28:40 dillon Exp $
42 * last edit-date: [Wed Jan 24 09:13:25 2001]
44 *---------------------------------------------------------------------------*/
49 #if NISIC > 0 && defined(SIEMENS_ISURF2)
51 #include <sys/param.h>
52 #include <sys/systm.h>
53 #include <sys/socket.h>
57 #include <machine/i4b_ioctl.h>
59 #include <i4b/layer1/isic/i4b_isic.h>
60 #include <i4b/layer1/isic/i4b_ipac.h>
62 /* masks for register encoded in base addr */
64 #define SIE_ISURF_BASE_MASK 0x0ffff
65 #define SIE_ISURF_OFF_MASK 0xf0000
67 /* register id's to be encoded in base addr */
69 #define SIE_ISURF_IDISAC 0x00000
70 #define SIE_ISURF_IDHSCXA 0x10000
71 #define SIE_ISURF_IDHSCXB 0x20000
72 #define SIE_ISURF_IDIPAC 0x40000
74 /* offsets from base address */
76 #define SIE_ISURF_OFF_ALE 0x00
77 #define SIE_ISURF_OFF_RW 0x01
79 /*---------------------------------------------------------------------------*
80 * Siemens I-Surf 2.0 PnP ISAC get fifo routine
81 *---------------------------------------------------------------------------*/
83 siemens_isurf_read_fifo(struct l1_softc *sc,int what,void *buf,size_t size)
85 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
86 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
91 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,IPAC_ISAC_OFF);
92 bus_space_read_multi_1(t,h,SIE_ISURF_OFF_RW,buf,size);
95 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,IPAC_HSCXA_OFF);
96 bus_space_read_multi_1(t,h,SIE_ISURF_OFF_RW,buf,size);
99 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,IPAC_HSCXB_OFF);
100 bus_space_read_multi_1(t,h,SIE_ISURF_OFF_RW,buf,size);
105 /*---------------------------------------------------------------------------*
106 * Siemens I-Surf 2.0 PnP ISAC put fifo routine
107 *---------------------------------------------------------------------------*/
109 siemens_isurf_write_fifo(struct l1_softc *sc,int what,void *buf,size_t size)
111 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
112 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
117 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,IPAC_ISAC_OFF);
118 bus_space_write_multi_1(t,h,SIE_ISURF_OFF_RW,buf,size);
120 case ISIC_WHAT_HSCXA:
121 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,IPAC_HSCXA_OFF);
122 bus_space_write_multi_1(t,h,SIE_ISURF_OFF_RW,buf,size);
124 case ISIC_WHAT_HSCXB:
125 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,IPAC_HSCXB_OFF);
126 bus_space_write_multi_1(t,h,SIE_ISURF_OFF_RW,buf,size);
131 /*---------------------------------------------------------------------------*
132 * Siemens I-Surf 2.0 PnP ISAC put register routine
133 *---------------------------------------------------------------------------*/
135 siemens_isurf_write_reg(struct l1_softc *sc,int what,bus_size_t reg,u_int8_t data)
137 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
138 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
143 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_ISAC_OFF);
144 bus_space_write_1(t,h,SIE_ISURF_OFF_RW,data);
146 case ISIC_WHAT_HSCXA:
147 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_HSCXA_OFF);
148 bus_space_write_1(t,h,SIE_ISURF_OFF_RW,data);
150 case ISIC_WHAT_HSCXB:
151 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_HSCXB_OFF);
152 bus_space_write_1(t,h,SIE_ISURF_OFF_RW,data);
155 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_IPAC_OFF);
156 bus_space_write_1(t,h,SIE_ISURF_OFF_RW,data);
161 /*---------------------------------------------------------------------------*
162 * Siemens I-Surf 2.0 PnP ISAC get register routine
163 *---------------------------------------------------------------------------*/
165 siemens_isurf_read_reg(struct l1_softc *sc,int what,bus_size_t reg)
167 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
168 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
173 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_ISAC_OFF);
174 return bus_space_read_1(t,h,SIE_ISURF_OFF_RW);
175 case ISIC_WHAT_HSCXA:
176 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_HSCXA_OFF);
177 return bus_space_read_1(t,h,SIE_ISURF_OFF_RW);
178 case ISIC_WHAT_HSCXB:
179 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_HSCXB_OFF);
180 return bus_space_read_1(t,h,SIE_ISURF_OFF_RW);
182 bus_space_write_1(t,h,SIE_ISURF_OFF_ALE,reg+IPAC_IPAC_OFF);
183 return bus_space_read_1(t,h,SIE_ISURF_OFF_RW);
189 /*---------------------------------------------------------------------------*
190 * isic_attach_siemens_isurf - attach for Siemens I-Surf 2.0 PnP
191 *---------------------------------------------------------------------------*/
193 isic_attach_siemens_isurf(device_t dev)
195 int unit = device_get_unit(dev);
196 struct l1_softc *sc = &l1_sc[unit];
198 /* setup access routines */
201 sc->readreg = siemens_isurf_read_reg;
202 sc->writereg = siemens_isurf_write_reg;
204 sc->readfifo = siemens_isurf_read_fifo;
205 sc->writefifo = siemens_isurf_write_fifo;
207 /* setup card type */
209 sc->sc_cardtyp = CARD_TYPEP_SIE_ISURF2;
211 /* setup IOM bus type */
213 sc->sc_bustyp = BUS_TYPE_IOM2;
215 /* setup chip type = IPAC ! */
218 sc->sc_bfifolen = IPAC_BFIFO_LEN;
220 /* enable hscx/isac irq's */
222 IPAC_WRITE(IPAC_MASK, (IPAC_MASK_INT1 | IPAC_MASK_INT0));
224 IPAC_WRITE(IPAC_ACFG, 0); /* outputs are open drain */
225 IPAC_WRITE(IPAC_AOE, /* aux 5..2 are inputs, 7, 6 outputs */
226 (IPAC_AOE_OE5 | IPAC_AOE_OE4 | IPAC_AOE_OE3 | IPAC_AOE_OE2));
227 IPAC_WRITE(IPAC_ATX, 0xff); /* set all output lines high */
231 #endif /* NISIC > 0 && defined(SIEMENS_ISURF2) */