2 * Copyright (c) 1997, 1999 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 * isic - I4B Siemens ISDN Chipset Driver for ELSA Quickstep 1000pro ISA
28 * =====================================================================
30 * $Id: i4b_elsa_qs1i.c,v 1.3 1999/12/13 21:25:26 hm Exp $
34 * last edit-date: [Mon Dec 13 21:59:44 1999]
36 *---------------------------------------------------------------------------*/
41 #if (NISIC > 0) && defined(ELSA_QS1ISA)
43 #include <sys/param.h>
44 #include <sys/kernel.h>
45 #include <sys/systm.h>
47 #include <sys/socket.h>
50 #include <sys/ioccom.h>
51 #include <machine/clock.h>
53 #include <machine/i4b_debug.h>
54 #include <machine/i4b_ioctl.h>
56 #include <i4b/include/i4b_global.h>
57 #include <i4b/include/i4b_l1l2.h>
58 #include <i4b/include/i4b_mbuf.h>
60 #include <i4b/layer1/i4b_l1.h>
61 #include <i4b/layer1/i4b_isac.h>
62 #include <i4b/layer1/i4b_hscx.h>
64 static void i4b_eq1i_clrirq(struct l1_softc *sc);
66 /* masks for register encoded in base addr */
68 #define ELSA_BASE_MASK 0x0ffff
69 #define ELSA_OFF_MASK 0xf0000
71 /* register id's to be encoded in base addr */
73 #define ELSA_IDISAC 0x00000
74 #define ELSA_IDHSCXA 0x10000
75 #define ELSA_IDHSCXB 0x20000
77 /* offsets from base address */
79 #define ELSA_OFF_ISAC 0x00
80 #define ELSA_OFF_HSCX 0x02
81 #define ELSA_OFF_OFF 0x03
82 #define ELSA_OFF_CTRL 0x04
83 #define ELSA_OFF_CFG 0x05
84 #define ELSA_OFF_TIMR 0x06
85 #define ELSA_OFF_IRQ 0x07
87 /* control register (write access) */
89 #define ELSA_CTRL_LED_YELLOW 0x02
90 #define ELSA_CTRL_LED_GREEN 0x08
91 #define ELSA_CTRL_RESET 0x20
92 #define ELSA_CTRL_TIMEREN 0x80
93 #define ELSA_CTRL_SECRET 0x50
95 /*---------------------------------------------------------------------------*
96 * ELSA QuickStep 1000pro/ISA clear IRQ routine
97 *---------------------------------------------------------------------------*/
99 i4b_eq1i_clrirq(struct l1_softc *sc)
101 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
102 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
103 bus_space_write_1(t, h, ELSA_OFF_IRQ, 0);
106 /*---------------------------------------------------------------------------*
107 * ELSA QuickStep 1000pro/ISA ISAC get fifo routine
108 *---------------------------------------------------------------------------*/
110 eqs1pi_read_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]);
117 bus_space_write_1(t, h, ELSA_OFF_OFF, 0);
118 bus_space_read_multi_1(t, h, ELSA_OFF_ISAC, buf, size);
120 case ISIC_WHAT_HSCXA:
121 bus_space_write_1(t, h, ELSA_OFF_OFF, 0);
122 bus_space_read_multi_1(t, h, ELSA_OFF_HSCX, buf, size);
124 case ISIC_WHAT_HSCXB:
125 bus_space_write_1(t, h, ELSA_OFF_OFF, 0x40);
126 bus_space_read_multi_1(t, h, ELSA_OFF_HSCX, buf, size);
131 /*---------------------------------------------------------------------------*
132 * ELSA QuickStep 1000pro/ISA ISAC put fifo routine
133 *---------------------------------------------------------------------------*/
135 eqs1pi_write_fifo(struct l1_softc *sc, int what, void *buf, size_t size)
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]);
142 bus_space_write_1(t, h, ELSA_OFF_OFF, 0);
143 bus_space_write_multi_1(t, h, ELSA_OFF_ISAC, buf, size);
145 case ISIC_WHAT_HSCXA:
146 bus_space_write_1(t, h, ELSA_OFF_OFF, 0);
147 bus_space_write_multi_1(t, h, ELSA_OFF_HSCX, buf, size);
149 case ISIC_WHAT_HSCXB:
150 bus_space_write_1(t, h, ELSA_OFF_OFF, 0x40);
151 bus_space_write_multi_1(t, h, ELSA_OFF_HSCX, buf, size);
156 /*---------------------------------------------------------------------------*
157 * ELSA QuickStep 1000pro/ISA ISAC put register routine
158 *---------------------------------------------------------------------------*/
160 eqs1pi_write_reg(struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data)
162 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
163 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
167 bus_space_write_1(t, h, ELSA_OFF_OFF, offs);
168 bus_space_write_1(t, h, ELSA_OFF_ISAC, data);
170 case ISIC_WHAT_HSCXA:
171 bus_space_write_1(t, h, ELSA_OFF_OFF, offs);
172 bus_space_write_1(t, h, ELSA_OFF_HSCX, data);
174 case ISIC_WHAT_HSCXB:
175 bus_space_write_1(t, h, ELSA_OFF_OFF, 0x40+offs);
176 bus_space_write_1(t, h, ELSA_OFF_HSCX, data);
181 /*---------------------------------------------------------------------------*
182 * ELSA QuickStep 1000pro/ISA ISAC get register routine
183 *---------------------------------------------------------------------------*/
185 eqs1pi_read_reg(struct l1_softc *sc, int what, bus_size_t offs)
187 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
188 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
192 bus_space_write_1(t, h, ELSA_OFF_OFF, offs);
193 return bus_space_read_1(t, h, ELSA_OFF_ISAC);
194 case ISIC_WHAT_HSCXA:
195 bus_space_write_1(t, h, ELSA_OFF_OFF, offs);
196 return bus_space_read_1(t, h, ELSA_OFF_HSCX);
197 case ISIC_WHAT_HSCXB:
198 bus_space_write_1(t, h, ELSA_OFF_OFF, 0x40+offs);
199 return bus_space_read_1(t, h, ELSA_OFF_HSCX);
204 /*---------------------------------------------------------------------------*
205 * isic_attach_Eqs1pi - attach for ELSA QuickStep 1000pro/ISA
206 *---------------------------------------------------------------------------*/
208 isic_attach_Eqs1pi(device_t dev)
210 int unit = device_get_unit(dev);
211 struct l1_softc *sc = &l1_sc[unit];
212 bus_space_tag_t t = rman_get_bustag(sc->sc_resources.io_base[0]);
213 bus_space_handle_t h = rman_get_bushandle(sc->sc_resources.io_base[0]);
215 u_char byte = ELSA_CTRL_SECRET;
217 /* setup access routines */
219 sc->clearirq = i4b_eq1i_clrirq;
220 sc->readreg = eqs1pi_read_reg;
221 sc->writereg = eqs1pi_write_reg;
223 sc->readfifo = eqs1pi_read_fifo;
224 sc->writefifo = eqs1pi_write_fifo;
226 /* setup card type */
228 sc->sc_cardtyp = CARD_TYPEP_ELSAQS1ISA;
230 /* setup IOM bus type */
232 sc->sc_bustyp = BUS_TYPE_IOM2;
235 sc->sc_bfifolen = HSCX_FIFO_LEN;
237 /* enable the card */
239 byte &= ~ELSA_CTRL_RESET;
240 bus_space_write_1(t, h, ELSA_OFF_CTRL, byte);
242 byte |= ELSA_CTRL_RESET;
243 bus_space_write_1(t, h, ELSA_OFF_CTRL, byte);
246 bus_space_write_1(t, h, ELSA_OFF_IRQ, 0xff);
250 #endif /* (NISIC > 0) && defined(ELSA_QS1ISA) */