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 * i4b_l1.h - isdn4bsd layer 1 header file
28 * ---------------------------------------
30 * $Id: i4b_l1.h,v 1.3 1999/12/13 21:25:26 hm Exp $
34 * last edit-date: [Mon Dec 13 22:02:07 1999]
36 *---------------------------------------------------------------------------*/
41 #include <sys/resource.h>
43 #include <i386/include/bus.h>
45 #include <i386/include/resource.h>
47 #include <i4b/include/i4b_l3l4.h>
49 /*---------------------------------------------------------------------------
50 * kernel config file flags definition
51 *---------------------------------------------------------------------------*/
52 #define FLAG_TELES_S0_8 1
53 #define FLAG_TELES_S0_16 2
54 #define FLAG_TELES_S0_163 3
56 #define FLAG_TELES_S0_163_PnP 5
57 #define FLAG_CREATIX_S0_PnP 6
58 #define FLAG_USR_ISDN_TA_INT 7
59 #define FLAG_DRN_NGO 8
61 #define FLAG_AVM_A1_PCMCIA 10
62 #define FLAG_DYNALINK 11
63 #define FLAG_BLMASTER 12
64 #define FLAG_ELSA_QS1P_ISA 13
65 #define FLAG_ELSA_QS1P_PCI 14
66 #define FLAG_SIEMENS_ITALK 15
67 #define FLAG_ELSA_MLIMC 16
68 #define FLAG_ELSA_MLMCALL 17
69 #define FLAG_ITK_IX1 18
70 #define FLAG_AVMA1PCI 19
71 #define FLAG_ELSA_PCC16 20
72 #define FLAG_AVM_PNP 21
73 #define FLAG_SIEMENS_ISURF2 22
74 #define FLAG_ASUSCOM_IPAC 23
76 #define SEC_DELAY 1000000 /* one second DELAY for DELAY*/
78 #define MAX_DFRAME_LEN 264 /* max length of a D frame */
80 #define min(a,b) ((a)<(b)?(a):(b))
82 #define INFO_IO_BASES 50 /* 49 needed for USR */
85 struct resource * io_base[INFO_IO_BASES];
86 int io_rid [INFO_IO_BASES];
87 struct resource * irq;
89 struct resource * mem;
93 /*---------------------------------------------------------------------------*
94 * l1_bchan_state: the state of one B channel
95 *---------------------------------------------------------------------------*/
98 int unit; /* cards unit number */
99 int channel; /* which channel is this*/
100 caddr_t hscx; /* HSCX address */
101 u_char hscx_mask; /* HSCX interrupt mask */
102 int bprot; /* B channel protocol */
103 int state; /* this channels state */
104 #define HSCX_IDLE 0x00 /* channel idle */
105 #define HSCX_TX_ACTIVE 0x01 /* tx running */
107 /* receive data from ISDN */
109 struct ifqueue rx_queue; /* receiver queue */
111 int rxcount; /* rx statistics counter*/
113 struct mbuf *in_mbuf; /* rx input buffer */
114 u_char *in_cbptr; /* curr buffer pointer */
115 int in_len; /* rx input buffer len */
117 /* transmit data to ISDN */
119 struct ifqueue tx_queue; /* transmitter queue */
121 int txcount; /* tx statistics counter*/
123 struct mbuf *out_mbuf_head; /* first mbuf in possible chain */
124 struct mbuf *out_mbuf_cur; /* current mbuf in possbl chain */
125 unsigned char *out_mbuf_cur_ptr; /* data pointer into mbuf */
126 int out_mbuf_cur_len; /* remaining bytes in mbuf */
128 /* link between b channel and driver */
130 isdn_link_t isdn_linktab; /* b channel addresses */
131 drvr_link_t *drvr_linktab; /* ptr to driver linktab*/
137 int stat_VFR; /* HSCX RSTA Valid FRame */
138 int stat_RDO; /* HSCX RSTA Rx Data Overflow */
139 int stat_CRC; /* HSCX RSTA CRC */
140 int stat_RAB; /* HSCX RSTA Rx message ABorted */
144 int stat_XDU; /* HSCX EXIR tx data underrun */
145 int stat_RFO; /* HSCX EXIR rx frame overflow */
149 /*---------------------------------------------------------------------------*
150 * l1_softc: the state of the layer 1 of the D channel
151 *---------------------------------------------------------------------------*/
154 int sc_unit; /* unit number */
155 int sc_irq; /* interrupt vector */
156 struct i4b_info sc_resources;
159 int sc_port; /* port base address */
161 int sc_cardtyp; /* CARD_TYPEP_xxxx */
163 int sc_bustyp; /* IOM1 or IOM2 */
164 #define BUS_TYPE_IOM1 0x01
165 #define BUS_TYPE_IOM2 0x02
167 int sc_trace; /* output protocol data for tracing */
168 unsigned int sc_trace_dcount;/* d channel trace frame counter */
169 unsigned int sc_trace_bcount;/* b channel trace frame counter */
171 int sc_state; /* ISAC state flag */
172 #define ISAC_IDLE 0x00 /* state = idle */
173 #define ISAC_TX_ACTIVE 0x01 /* state = transmitter active */
175 int sc_init_tries; /* no of out tries to access S0 */
177 caddr_t sc_vmem_addr; /* card RAM virtual memory base */
178 caddr_t sc_isac; /* ISAC port base addr */
179 #define ISAC_BASE (sc->sc_isac)
181 caddr_t sc_ipacbase; /* IPAC port base addr */
182 #define IPAC_BASE (sc->sc_ipacbase)
184 u_char sc_isac_mask; /* ISAC IRQ mask */
185 #define ISAC_IMASK (sc->sc_isac_mask)
187 l1_bchan_state_t sc_chan[2]; /* B-channel state */
188 #define HSCX_A_BASE (sc->sc_chan[0].hscx)
189 #define HSCX_A_IMASK (sc->sc_chan[0].hscx_mask)
190 #define HSCX_B_BASE (sc->sc_chan[1].hscx)
191 #define HSCX_B_IMASK (sc->sc_chan[1].hscx_mask)
193 struct mbuf *sc_ibuf; /* input buffer mgmt */
196 /* this is for the irq TX routine */
197 struct mbuf *sc_obuf; /* pointer to an mbuf with TX frame */
198 u_char *sc_op; /* ptr to next chunk of frame to tx */
199 int sc_ol; /* length of remaining frame to tx */
200 int sc_freeflag; /* m_freem mbuf if set */
202 struct mbuf *sc_obuf2; /* pointer to an mbuf with TX frame */
203 int sc_freeflag2; /* m_freem mbuf if set */
205 int sc_isac_version; /* version number of ISAC */
206 int sc_hscx_version; /* version number of HSCX */
208 int sc_I430state; /* I.430 state F3 .... F8 */
210 int sc_I430T3; /* I.430 Timer T3 running */
212 struct callout_handle sc_T3_callout;
214 int sc_I430T4; /* Timer T4 running */
216 struct callout_handle sc_T4_callout;
219 * byte fields for the AVM Fritz!Card PCI. These are packed into
220 * a u_int in the driver.
226 int sc_enabled; /* daemon is running */
228 int sc_ipac; /* flag, running on ipac */
229 int sc_bfifolen; /* length of b channel fifos */
231 #define ISIC_WHAT_ISAC 0
232 #define ISIC_WHAT_HSCXA 1
233 #define ISIC_WHAT_HSCXB 2
234 #define ISIC_WHAT_IPAC 3
236 u_int8_t (*readreg) (struct l1_softc *sc, int what, bus_size_t offs);
237 void (*writereg) (struct l1_softc *sc, int what, bus_size_t offs, u_int8_t data);
238 void (*readfifo) (struct l1_softc *sc, int what, void *buf, size_t size);
239 void (*writefifo) (struct l1_softc *sc, int what, void *data, size_t size);
240 void (*clearirq) (struct l1_softc *sc);
242 #define ISAC_READ(r) (*sc->readreg)(sc, ISIC_WHAT_ISAC, (r))
243 #define ISAC_WRITE(r,v) (*sc->writereg)(sc, ISIC_WHAT_ISAC, (r), (v))
244 #define ISAC_RDFIFO(b,s) (*sc->readfifo)(sc, ISIC_WHAT_ISAC, (b), (s))
245 #define ISAC_WRFIFO(b,s) (*sc->writefifo)(sc, ISIC_WHAT_ISAC, (b), (s))
247 #define HSCX_READ(n,r) (*sc->readreg)(sc, ISIC_WHAT_HSCXA+(n), (r))
248 #define HSCX_WRITE(n,r,v) (*sc->writereg)(sc, ISIC_WHAT_HSCXA+(n), (r), (v))
249 #define HSCX_RDFIFO(n,b,s) (*sc->readfifo)(sc, ISIC_WHAT_HSCXA+(n), (b), (s))
250 #define HSCX_WRFIFO(n,b,s) (*sc->writefifo)(sc, ISIC_WHAT_HSCXA+(n), (b), (s))
252 #define IPAC_READ(r) (*sc->readreg)(sc, ISIC_WHAT_IPAC, (r))
253 #define IPAC_WRITE(r, v) (*sc->writereg)(sc, ISIC_WHAT_IPAC, (r), (v))
256 /*---------------------------------------------------------------------------*
257 * possible I.430/ISAC states
258 *---------------------------------------------------------------------------*/
260 ST_F3, /* F3 Deactivated */
261 ST_F4, /* F4 Awaiting Signal */
262 ST_F5, /* F5 Identifying Input */
263 ST_F6, /* F6 Synchronized */
264 ST_F7, /* F7 Activated */
265 ST_F8, /* F8 Lost Framing */
266 ST_ILL, /* Illegal State */
270 /*---------------------------------------------------------------------------*
271 * possible I.430/ISAC events
272 *---------------------------------------------------------------------------*/
274 EV_PHAR, /* PH ACTIVATE REQUEST */
275 EV_T3, /* Timer 3 expired */
276 EV_INFO0, /* receiving INFO0 */
277 EV_RSY, /* receiving any signal */
278 EV_INFO2, /* receiving INFO2 */
279 EV_INFO48, /* receiving INFO4 pri 8/9 */
280 EV_INFO410, /* receiving INFO4 pri 10/11 */
281 EV_DR, /* Deactivate Request */
282 EV_PU, /* Power UP */
283 EV_DIS, /* Disconnected (only 2085) */
284 EV_EI, /* Error Indication */
285 EV_ILL, /* Illegal Event */
290 CMD_TIM, /* Timing */
292 CMD_AR8, /* Activation request pri 8 */
293 CMD_AR10, /* Activation request pri 10 */
294 CMD_DIU, /* Deactivate Indication Upstream */
295 CMD_ILL /* Illegal command */
298 #define N_COMMANDS CMD_ILL
301 extern struct l1_softc l1_sc[];
303 extern void isicintr(struct l1_softc *sc);
304 extern int isic_attach_common(device_t dev);
305 extern void isic_detach_common(device_t dev);
306 extern void isic_recover(struct l1_softc *sc);
308 extern void isic_bchannel_setup (int unit, int hscx_channel, int bprot, int activate );
310 extern void isic_init_linktab ( struct l1_softc *sc );
311 extern int isic_isac_init ( struct l1_softc *sc );
312 extern void isic_isac_irq ( struct l1_softc *sc, int r );
313 extern void isic_isac_l1_cmd ( struct l1_softc *sc, int command );
314 extern void isic_next_state ( struct l1_softc *sc, int event );
315 extern char *isic_printstate ( struct l1_softc *sc );
317 extern int isic_hscx_fifo(l1_bchan_state_t *, struct l1_softc *);
318 extern void isic_hscx_init ( struct l1_softc *sc, int hscx_channel, int activate );
319 extern void isic_hscx_irq ( struct l1_softc *sc, u_char ista, int hscx_channel, u_char ex_irq );
320 extern int isic_hscx_silence ( unsigned char *data, int len );
321 extern void isic_hscx_cmd( struct l1_softc *sc, int h_chan, unsigned char cmd );
322 extern void isic_hscx_waitxfw( struct l1_softc *sc, int h_chan );
324 extern int isic_probe_s016 (device_t dev);
325 extern int isic_attach_s016 (device_t dev);
327 extern int isic_probe_s08 (device_t dev);
328 extern int isic_attach_s08 (device_t dev);
330 extern int isic_probe_Epcc16 (device_t dev);
331 extern int isic_attach_Epcc16 (device_t dev);
333 extern int isic_probe_s0163 (device_t dev);
334 extern int isic_attach_s0163 (device_t dev);
336 extern int isic_probe_avma1 (device_t dev);
337 extern int isic_attach_avma1 (device_t dev);
339 extern int isic_attach_drnngo (device_t dev);
340 extern int isic_attach_Cs0P (device_t dev);
341 extern int isic_attach_Eqs1pi(device_t dev);
342 extern int isic_attach_sws(device_t dev);
343 extern int isic_attach_siemens_isurf(device_t dev);
344 extern int isic_attach_asi(device_t dev);
347 #endif /* I4B_L1_H_ */