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 $
32 * last edit-date: [Fri Jan 26 13:55:12 2001]
34 *---------------------------------------------------------------------------*/
39 #include <sys/resource.h>
41 #include <i386/include/bus.h>
43 #include <i386/include/resource.h>
45 #include <i4b/include/i4b_l3l4.h>
47 #include <i4b/layer1/isic/i4b_isic_ext.h>
49 /*---------------------------------------------------------------------------
50 * isic driver: max no of units
51 * Teles/Creatix/Neuhaus cards have a hardware limitation
52 * as one is able to set 3 (sometimes 4) different configurations by
53 * jumpers so a maximum of 3 (4) cards per ISA bus is possible.
54 *---------------------------------------------------------------------------*/
55 #define ISIC_MAXUNIT 3 /* max no of supported units 0..3 */
57 #define INFO_IO_BASES 50 /* 49 needed for USR */
60 struct resource * io_base[INFO_IO_BASES];
61 int io_rid [INFO_IO_BASES];
62 struct resource * irq;
64 struct resource * mem;
68 /*---------------------------------------------------------------------------*
69 * l1_bchan_state: the state of one B channel
70 *---------------------------------------------------------------------------*/
73 int unit; /* cards unit number */
74 int channel; /* which channel is this*/
75 caddr_t hscx; /* HSCX address */
76 u_char hscx_mask; /* HSCX interrupt mask */
77 int bprot; /* B channel protocol */
78 int state; /* this channels state */
79 #define HSCX_IDLE 0x00 /* channel idle */
80 #define HSCX_TX_ACTIVE 0x01 /* tx running */
82 /* receive data from ISDN */
84 struct ifqueue rx_queue; /* receiver queue */
86 int rxcount; /* rx statistics counter*/
88 struct mbuf *in_mbuf; /* rx input buffer */
89 u_char *in_cbptr; /* curr buffer pointer */
90 int in_len; /* rx input buffer len */
92 /* transmit data to ISDN */
94 struct ifqueue tx_queue; /* transmitter queue */
96 int txcount; /* tx statistics counter*/
98 struct mbuf *out_mbuf_head; /* first mbuf in possible chain */
99 struct mbuf *out_mbuf_cur; /* current mbuf in possbl chain */
100 unsigned char *out_mbuf_cur_ptr; /* data pointer into mbuf */
101 int out_mbuf_cur_len; /* remaining bytes in mbuf */
103 /* link between b channel and driver */
105 isdn_link_t isic_isdn_linktab; /* b channel addresses */
106 drvr_link_t *isic_drvr_linktab; /* ptr to driver linktab*/
112 int stat_VFR; /* HSCX RSTA Valid FRame */
113 int stat_RDO; /* HSCX RSTA Rx Data Overflow */
114 int stat_CRC; /* HSCX RSTA CRC */
115 int stat_RAB; /* HSCX RSTA Rx message ABorted */
119 int stat_XDU; /* HSCX EXIR tx data underrun */
120 int stat_RFO; /* HSCX EXIR rx frame overflow */
124 /*---------------------------------------------------------------------------*
125 * l1_softc: the state of the layer 1 of the D channel
126 *---------------------------------------------------------------------------*/
129 int sc_unit; /* unit number */
130 int sc_irq; /* interrupt vector */
131 struct i4b_info sc_resources;
133 int sc_port; /* port base address */
135 int sc_cardtyp; /* CARD_TYPEP_xxxx */
137 int sc_bustyp; /* IOM1 or IOM2 */
138 #define BUS_TYPE_IOM1 0x01
139 #define BUS_TYPE_IOM2 0x02
141 int sc_trace; /* output protocol data for tracing */
142 unsigned int sc_trace_dcount;/* d channel trace frame counter */
143 unsigned int sc_trace_bcount;/* b channel trace frame counter */
145 int sc_state; /* ISAC state flag */
146 #define ISAC_IDLE 0x00 /* state = idle */
147 #define ISAC_TX_ACTIVE 0x01 /* state = transmitter active */
149 int sc_init_tries; /* no of out tries to access S0 */
151 caddr_t sc_vmem_addr; /* card RAM virtual memory base */
152 caddr_t sc_isac; /* ISAC port base addr */
153 #define ISAC_BASE (sc->sc_isac)
155 caddr_t sc_ipacbase; /* IPAC port base addr */
156 #define IPAC_BASE (sc->sc_ipacbase)
158 u_char sc_isac_mask; /* ISAC IRQ mask */
159 #define ISAC_IMASK (sc->sc_isac_mask)
161 l1_bchan_state_t sc_chan[2]; /* B-channel state */
162 #define HSCX_A_BASE (sc->sc_chan[0].hscx)
163 #define HSCX_A_IMASK (sc->sc_chan[0].hscx_mask)
164 #define HSCX_B_BASE (sc->sc_chan[1].hscx)
165 #define HSCX_B_IMASK (sc->sc_chan[1].hscx_mask)
167 struct mbuf *sc_ibuf; /* input buffer mgmt */
170 /* this is for the irq TX routine */
171 struct mbuf *sc_obuf; /* pointer to an mbuf with TX frame */
172 u_char *sc_op; /* ptr to next chunk of frame to tx */
173 int sc_ol; /* length of remaining frame to tx */
174 int sc_freeflag; /* m_freem mbuf if set */
176 struct mbuf *sc_obuf2; /* pointer to an mbuf with TX frame */
177 int sc_freeflag2; /* m_freem mbuf if set */
179 int sc_isac_version; /* version number of ISAC */
180 int sc_hscx_version; /* version number of HSCX */
181 int sc_ipac_version; /* version number of IPAC */
183 int sc_I430state; /* I.430 state F3 .... F8 */
185 int sc_I430T3; /* I.430 Timer T3 running */
187 struct callout_handle sc_T3_callout;
189 int sc_I430T4; /* Timer T4 running */
191 struct callout_handle sc_T4_callout;
194 * byte fields for the AVM Fritz!Card PCI. These are packed into
195 * a u_int in the driver.
201 int sc_enabled; /* daemon is running */
203 int sc_ipac; /* flag, running on ipac */
204 int sc_bfifolen; /* length of b channel fifos */
206 #define ISIC_WHAT_ISAC 0
207 #define ISIC_WHAT_HSCXA 1
208 #define ISIC_WHAT_HSCXB 2
209 #define ISIC_WHAT_IPAC 3
211 u_int8_t (*readreg) (struct l1_softc *sc, int what, bus_size_t offs);
212 void (*writereg) (struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data);
213 void (*readfifo) (struct l1_softc *sc, int what, void *buf, size_t size);
214 void (*writefifo) (struct l1_softc *sc, int what, void *data, size_t size);
215 void (*clearirq) (struct l1_softc *sc);
217 #define ISAC_READ(r) (*sc->readreg)(sc, ISIC_WHAT_ISAC, (r))
218 #define ISAC_WRITE(r,v) (*sc->writereg)(sc, ISIC_WHAT_ISAC, (r), (v))
219 #define ISAC_RDFIFO(b,s) (*sc->readfifo)(sc, ISIC_WHAT_ISAC, (b), (s))
220 #define ISAC_WRFIFO(b,s) (*sc->writefifo)(sc, ISIC_WHAT_ISAC, (b), (s))
222 #define HSCX_READ(n,r) (*sc->readreg)(sc, ISIC_WHAT_HSCXA+(n), (r))
223 #define HSCX_WRITE(n,r,v) (*sc->writereg)(sc, ISIC_WHAT_HSCXA+(n), (r), (v))
224 #define HSCX_RDFIFO(n,b,s) (*sc->readfifo)(sc, ISIC_WHAT_HSCXA+(n), (b), (s))
225 #define HSCX_WRFIFO(n,b,s) (*sc->writefifo)(sc, ISIC_WHAT_HSCXA+(n), (b), (s))
227 #define IPAC_READ(r) (*sc->readreg)(sc, ISIC_WHAT_IPAC, (r))
228 #define IPAC_WRITE(r, v) (*sc->writereg)(sc, ISIC_WHAT_IPAC, (r), (v))
231 /*---------------------------------------------------------------------------*
232 * possible I.430/ISAC states
233 *---------------------------------------------------------------------------*/
235 ST_F3, /* F3 Deactivated */
236 ST_F4, /* F4 Awaiting Signal */
237 ST_F5, /* F5 Identifying Input */
238 ST_F6, /* F6 Synchronized */
239 ST_F7, /* F7 Activated */
240 ST_F8, /* F8 Lost Framing */
241 ST_ILL, /* Illegal State */
245 /*---------------------------------------------------------------------------*
246 * possible I.430/ISAC events
247 *---------------------------------------------------------------------------*/
249 EV_PHAR, /* PH ACTIVATE REQUEST */
250 EV_T3, /* Timer 3 expired */
251 EV_INFO0, /* receiving INFO0 */
252 EV_RSY, /* receiving any signal */
253 EV_INFO2, /* receiving INFO2 */
254 EV_INFO48, /* receiving INFO4 pri 8/9 */
255 EV_INFO410, /* receiving INFO4 pri 10/11 */
256 EV_DR, /* Deactivate Request */
257 EV_PU, /* Power UP */
258 EV_DIS, /* Disconnected (only 2085) */
259 EV_EI, /* Error Indication */
260 EV_ILL, /* Illegal Event */
265 CMD_TIM, /* Timing */
267 CMD_AR8, /* Activation request pri 8 */
268 CMD_AR10, /* Activation request pri 10 */
269 CMD_DIU, /* Deactivate Indication Upstream */
270 CMD_ILL /* Illegal command */
273 #define N_COMMANDS CMD_ILL
275 extern struct l1_softc l1_sc[];
277 extern void isicintr(struct l1_softc *sc);
278 extern int isic_attach_common(device_t dev);
279 extern void isic_detach_common(device_t dev);
280 extern void isic_recover(struct l1_softc *sc);
282 extern void isic_bchannel_setup (int unit, int hscx_channel, int bprot, int activate );
284 extern void isic_init_linktab ( struct l1_softc *sc );
285 extern int isic_isac_init ( struct l1_softc *sc );
286 extern void isic_isac_irq ( struct l1_softc *sc, int r );
287 extern void isic_isac_l1_cmd ( struct l1_softc *sc, int command );
288 extern void isic_next_state ( struct l1_softc *sc, int event );
289 extern char *isic_printstate ( struct l1_softc *sc );
291 extern int isic_hscx_fifo(l1_bchan_state_t *, struct l1_softc *);
292 extern void isic_hscx_init ( struct l1_softc *sc, int hscx_channel, int activate );
293 extern void isic_hscx_irq ( struct l1_softc *sc, u_char ista, int hscx_channel, u_char ex_irq );
294 extern int isic_hscx_silence ( unsigned char *data, int len );
295 extern void isic_hscx_cmd( struct l1_softc *sc, int h_chan, unsigned char cmd );
296 extern void isic_hscx_waitxfw( struct l1_softc *sc, int h_chan );
298 extern int isic_probe_s016 (device_t dev);
299 extern int isic_attach_s016 (device_t dev);
301 extern int isic_probe_s08 (device_t dev);
302 extern int isic_attach_s08 (device_t dev);
304 extern int isic_probe_Epcc16 (device_t dev);
305 extern int isic_attach_Epcc16 (device_t dev);
307 extern int isic_probe_s0163 (device_t dev);
308 extern int isic_attach_s0163 (device_t dev);
310 extern int isic_probe_avma1 (device_t dev);
311 extern int isic_attach_avma1 (device_t dev);
313 extern int isic_probe_usrtai (device_t dev);
314 extern int isic_attach_usrtai (device_t dev);
316 extern int isic_probe_itkix1 (device_t dev);
317 extern int isic_attach_itkix1 (device_t dev);
319 extern int isic_attach_drnngo (device_t dev);
320 extern int isic_attach_Cs0P (device_t dev);
321 extern int isic_attach_Eqs1pi(device_t dev);
322 extern int isic_attach_sws(device_t dev);
323 extern int isic_attach_siemens_isurf(device_t dev);
324 extern int isic_attach_asi(device_t dev);
325 extern int isic_attach_Dyn(device_t dev);
326 extern int isic_attach_diva(device_t dev);
327 extern int isic_attach_diva_ipac(device_t dev);
329 #endif /* _I4B_ISIC_H_ */