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_l1.h - isdn4bsd layer 1 header file
28 * ---------------------------------------
30 * $FreeBSD: src/sys/i4b/layer1/isic/i4b_isic.h,v 1.3.2.1 2001/08/10 14:08:38 obrien Exp $
31 * $DragonFly: src/sys/net/i4b/layer1/isic/i4b_isic.h,v 1.3 2003/08/07 21:17:26 dillon Exp $
33 * last edit-date: [Fri Jan 26 13:55:12 2001]
35 *---------------------------------------------------------------------------*/
40 #include <sys/resource.h>
42 #include <i386/include/bus.h>
44 #include <i386/include/resource.h>
46 #include "../../include/i4b_l3l4.h"
48 #include "i4b_isic_ext.h"
50 /*---------------------------------------------------------------------------
51 * isic driver: max no of units
52 * Teles/Creatix/Neuhaus cards have a hardware limitation
53 * as one is able to set 3 (sometimes 4) different configurations by
54 * jumpers so a maximum of 3 (4) cards per ISA bus is possible.
55 *---------------------------------------------------------------------------*/
56 #define ISIC_MAXUNIT 3 /* max no of supported units 0..3 */
58 #define INFO_IO_BASES 50 /* 49 needed for USR */
61 struct resource * io_base[INFO_IO_BASES];
62 int io_rid [INFO_IO_BASES];
63 struct resource * irq;
65 struct resource * mem;
69 /*---------------------------------------------------------------------------*
70 * l1_bchan_state: the state of one B channel
71 *---------------------------------------------------------------------------*/
74 int unit; /* cards unit number */
75 int channel; /* which channel is this*/
76 caddr_t hscx; /* HSCX address */
77 u_char hscx_mask; /* HSCX interrupt mask */
78 int bprot; /* B channel protocol */
79 int state; /* this channels state */
80 #define HSCX_IDLE 0x00 /* channel idle */
81 #define HSCX_TX_ACTIVE 0x01 /* tx running */
83 /* receive data from ISDN */
85 struct ifqueue rx_queue; /* receiver queue */
87 int rxcount; /* rx statistics counter*/
89 struct mbuf *in_mbuf; /* rx input buffer */
90 u_char *in_cbptr; /* curr buffer pointer */
91 int in_len; /* rx input buffer len */
93 /* transmit data to ISDN */
95 struct ifqueue tx_queue; /* transmitter queue */
97 int txcount; /* tx statistics counter*/
99 struct mbuf *out_mbuf_head; /* first mbuf in possible chain */
100 struct mbuf *out_mbuf_cur; /* current mbuf in possbl chain */
101 unsigned char *out_mbuf_cur_ptr; /* data pointer into mbuf */
102 int out_mbuf_cur_len; /* remaining bytes in mbuf */
104 /* link between b channel and driver */
106 isdn_link_t isic_isdn_linktab; /* b channel addresses */
107 drvr_link_t *isic_drvr_linktab; /* ptr to driver linktab*/
113 int stat_VFR; /* HSCX RSTA Valid FRame */
114 int stat_RDO; /* HSCX RSTA Rx Data Overflow */
115 int stat_CRC; /* HSCX RSTA CRC */
116 int stat_RAB; /* HSCX RSTA Rx message ABorted */
120 int stat_XDU; /* HSCX EXIR tx data underrun */
121 int stat_RFO; /* HSCX EXIR rx frame overflow */
125 /*---------------------------------------------------------------------------*
126 * l1_softc: the state of the layer 1 of the D channel
127 *---------------------------------------------------------------------------*/
130 int sc_unit; /* unit number */
131 int sc_irq; /* interrupt vector */
132 struct i4b_info sc_resources;
134 int sc_port; /* port base address */
136 int sc_cardtyp; /* CARD_TYPEP_xxxx */
138 int sc_bustyp; /* IOM1 or IOM2 */
139 #define BUS_TYPE_IOM1 0x01
140 #define BUS_TYPE_IOM2 0x02
142 int sc_trace; /* output protocol data for tracing */
143 unsigned int sc_trace_dcount;/* d channel trace frame counter */
144 unsigned int sc_trace_bcount;/* b channel trace frame counter */
146 int sc_state; /* ISAC state flag */
147 #define ISAC_IDLE 0x00 /* state = idle */
148 #define ISAC_TX_ACTIVE 0x01 /* state = transmitter active */
150 int sc_init_tries; /* no of out tries to access S0 */
152 caddr_t sc_vmem_addr; /* card RAM virtual memory base */
153 caddr_t sc_isac; /* ISAC port base addr */
154 #define ISAC_BASE (sc->sc_isac)
156 caddr_t sc_ipacbase; /* IPAC port base addr */
157 #define IPAC_BASE (sc->sc_ipacbase)
159 u_char sc_isac_mask; /* ISAC IRQ mask */
160 #define ISAC_IMASK (sc->sc_isac_mask)
162 l1_bchan_state_t sc_chan[2]; /* B-channel state */
163 #define HSCX_A_BASE (sc->sc_chan[0].hscx)
164 #define HSCX_A_IMASK (sc->sc_chan[0].hscx_mask)
165 #define HSCX_B_BASE (sc->sc_chan[1].hscx)
166 #define HSCX_B_IMASK (sc->sc_chan[1].hscx_mask)
168 struct mbuf *sc_ibuf; /* input buffer mgmt */
171 /* this is for the irq TX routine */
172 struct mbuf *sc_obuf; /* pointer to an mbuf with TX frame */
173 u_char *sc_op; /* ptr to next chunk of frame to tx */
174 int sc_ol; /* length of remaining frame to tx */
175 int sc_freeflag; /* m_freem mbuf if set */
177 struct mbuf *sc_obuf2; /* pointer to an mbuf with TX frame */
178 int sc_freeflag2; /* m_freem mbuf if set */
180 int sc_isac_version; /* version number of ISAC */
181 int sc_hscx_version; /* version number of HSCX */
182 int sc_ipac_version; /* version number of IPAC */
184 int sc_I430state; /* I.430 state F3 .... F8 */
186 int sc_I430T3; /* I.430 Timer T3 running */
188 struct callout_handle sc_T3_callout;
190 int sc_I430T4; /* Timer T4 running */
192 struct callout_handle sc_T4_callout;
195 * byte fields for the AVM Fritz!Card PCI. These are packed into
196 * a u_int in the driver.
202 int sc_enabled; /* daemon is running */
204 int sc_ipac; /* flag, running on ipac */
205 int sc_bfifolen; /* length of b channel fifos */
207 #define ISIC_WHAT_ISAC 0
208 #define ISIC_WHAT_HSCXA 1
209 #define ISIC_WHAT_HSCXB 2
210 #define ISIC_WHAT_IPAC 3
212 u_int8_t (*readreg) (struct l1_softc *sc, int what, bus_size_t offs);
213 void (*writereg) (struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data);
214 void (*readfifo) (struct l1_softc *sc, int what, void *buf, size_t size);
215 void (*writefifo) (struct l1_softc *sc, int what, void *data, size_t size);
216 void (*clearirq) (struct l1_softc *sc);
218 #define ISAC_READ(r) (*sc->readreg)(sc, ISIC_WHAT_ISAC, (r))
219 #define ISAC_WRITE(r,v) (*sc->writereg)(sc, ISIC_WHAT_ISAC, (r), (v))
220 #define ISAC_RDFIFO(b,s) (*sc->readfifo)(sc, ISIC_WHAT_ISAC, (b), (s))
221 #define ISAC_WRFIFO(b,s) (*sc->writefifo)(sc, ISIC_WHAT_ISAC, (b), (s))
223 #define HSCX_READ(n,r) (*sc->readreg)(sc, ISIC_WHAT_HSCXA+(n), (r))
224 #define HSCX_WRITE(n,r,v) (*sc->writereg)(sc, ISIC_WHAT_HSCXA+(n), (r), (v))
225 #define HSCX_RDFIFO(n,b,s) (*sc->readfifo)(sc, ISIC_WHAT_HSCXA+(n), (b), (s))
226 #define HSCX_WRFIFO(n,b,s) (*sc->writefifo)(sc, ISIC_WHAT_HSCXA+(n), (b), (s))
228 #define IPAC_READ(r) (*sc->readreg)(sc, ISIC_WHAT_IPAC, (r))
229 #define IPAC_WRITE(r, v) (*sc->writereg)(sc, ISIC_WHAT_IPAC, (r), (v))
232 /*---------------------------------------------------------------------------*
233 * possible I.430/ISAC states
234 *---------------------------------------------------------------------------*/
236 ST_F3, /* F3 Deactivated */
237 ST_F4, /* F4 Awaiting Signal */
238 ST_F5, /* F5 Identifying Input */
239 ST_F6, /* F6 Synchronized */
240 ST_F7, /* F7 Activated */
241 ST_F8, /* F8 Lost Framing */
242 ST_ILL, /* Illegal State */
246 /*---------------------------------------------------------------------------*
247 * possible I.430/ISAC events
248 *---------------------------------------------------------------------------*/
250 EV_PHAR, /* PH ACTIVATE REQUEST */
251 EV_T3, /* Timer 3 expired */
252 EV_INFO0, /* receiving INFO0 */
253 EV_RSY, /* receiving any signal */
254 EV_INFO2, /* receiving INFO2 */
255 EV_INFO48, /* receiving INFO4 pri 8/9 */
256 EV_INFO410, /* receiving INFO4 pri 10/11 */
257 EV_DR, /* Deactivate Request */
258 EV_PU, /* Power UP */
259 EV_DIS, /* Disconnected (only 2085) */
260 EV_EI, /* Error Indication */
261 EV_ILL, /* Illegal Event */
266 CMD_TIM, /* Timing */
268 CMD_AR8, /* Activation request pri 8 */
269 CMD_AR10, /* Activation request pri 10 */
270 CMD_DIU, /* Deactivate Indication Upstream */
271 CMD_ILL /* Illegal command */
274 #define N_COMMANDS CMD_ILL
276 extern struct l1_softc l1_sc[];
278 extern void isicintr(struct l1_softc *sc);
279 extern int isic_attach_common(device_t dev);
280 extern void isic_detach_common(device_t dev);
281 extern void isic_recover(struct l1_softc *sc);
283 extern void isic_bchannel_setup (int unit, int hscx_channel, int bprot, int activate );
285 extern void isic_init_linktab ( struct l1_softc *sc );
286 extern int isic_isac_init ( struct l1_softc *sc );
287 extern void isic_isac_irq ( struct l1_softc *sc, int r );
288 extern void isic_isac_l1_cmd ( struct l1_softc *sc, int command );
289 extern void isic_next_state ( struct l1_softc *sc, int event );
290 extern char *isic_printstate ( struct l1_softc *sc );
292 extern int isic_hscx_fifo(l1_bchan_state_t *, struct l1_softc *);
293 extern void isic_hscx_init ( struct l1_softc *sc, int hscx_channel, int activate );
294 extern void isic_hscx_irq ( struct l1_softc *sc, u_char ista, int hscx_channel, u_char ex_irq );
295 extern int isic_hscx_silence ( unsigned char *data, int len );
296 extern void isic_hscx_cmd( struct l1_softc *sc, int h_chan, unsigned char cmd );
297 extern void isic_hscx_waitxfw( struct l1_softc *sc, int h_chan );
299 extern int isic_probe_s016 (device_t dev);
300 extern int isic_attach_s016 (device_t dev);
302 extern int isic_probe_s08 (device_t dev);
303 extern int isic_attach_s08 (device_t dev);
305 extern int isic_probe_Epcc16 (device_t dev);
306 extern int isic_attach_Epcc16 (device_t dev);
308 extern int isic_probe_s0163 (device_t dev);
309 extern int isic_attach_s0163 (device_t dev);
311 extern int isic_probe_avma1 (device_t dev);
312 extern int isic_attach_avma1 (device_t dev);
314 extern int isic_probe_usrtai (device_t dev);
315 extern int isic_attach_usrtai (device_t dev);
317 extern int isic_probe_itkix1 (device_t dev);
318 extern int isic_attach_itkix1 (device_t dev);
320 extern int isic_attach_drnngo (device_t dev);
321 extern int isic_attach_Cs0P (device_t dev);
322 extern int isic_attach_Eqs1pi(device_t dev);
323 extern int isic_attach_sws(device_t dev);
324 extern int isic_attach_siemens_isurf(device_t dev);
325 extern int isic_attach_asi(device_t dev);
326 extern int isic_attach_Dyn(device_t dev);
327 extern int isic_attach_diva(device_t dev);
328 extern int isic_attach_diva_ipac(device_t dev);
330 #endif /* _I4B_ISIC_H_ */