2 * Copyright (c) 1999, 2000 Dave Boyce. 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_iwic - isdn4bsd Winbond W6692 driver
28 * ----------------------------------------
30 * $FreeBSD: src/sys/i4b/layer1/iwic/i4b_iwic.h,v 1.2.2.1 2001/08/10 14:08:40 obrien Exp $
32 * last edit-date: [Sun Jan 21 11:08:44 2001]
34 *---------------------------------------------------------------------------*/
39 #include <i4b/layer1/iwic/i4b_iwic_ext.h>
41 /*---------------------------------------------------------------------------*
43 *---------------------------------------------------------------------------*/
45 #define INFO_IO_BASES 2
48 struct resource * io_base[INFO_IO_BASES];
49 int io_rid [INFO_IO_BASES];
50 struct resource * irq;
52 struct resource * mem;
56 /*---------------------------------------------------------------------------*
57 * state of a B channel
58 *---------------------------------------------------------------------------*/
61 int unit; /* unit number */
62 int channel; /* channel number */
63 int offset; /* offset from iobase */
64 int bprot; /* b channel protocol used */
65 int state; /* transceiver state: */
66 #define ST_IDLE 0x00 /* channel idle */
67 #define ST_TX_ACTIVE 0x01 /* tx running */
71 /* receive data from ISDN */
73 struct ifqueue rx_queue; /* receiver queue */
74 int rxcount; /* rx statistics counter*/
75 struct mbuf *in_mbuf; /* rx input buffer */
76 u_char *in_cbptr; /* curr buffer pointer */
77 int in_len; /* rx input buffer len */
79 /* transmit data to ISDN */
81 struct ifqueue tx_queue; /* transmitter queue */
82 int txcount; /* tx statistics counter */
83 struct mbuf *out_mbuf_head; /* first mbuf in possible chain */
84 struct mbuf *out_mbuf_cur; /* current mbuf in possbl chain */
85 unsigned char *out_mbuf_cur_ptr; /* data pointer into mbuf */
86 int out_mbuf_cur_len; /* remaining bytes in mbuf */
90 isdn_link_t iwic_isdn_linktab;
91 drvr_link_t *iwic_drvr_linktab;
94 /*---------------------------------------------------------------------------*
95 * state of a D channel
96 *---------------------------------------------------------------------------*/
102 u_char *ibuf_ptr; /* Input buffer pointer */
103 int ibuf_len; /* Current length of input buffer */
104 int ibuf_max_len; /* Max length in input buffer */
107 int tx_ready; /* Can send next 64 bytes of data. */
119 /*---------------------------------------------------------------------------*
120 * state of one iwic unit
121 *---------------------------------------------------------------------------*/
134 struct iwic_dchan sc_dchan;
135 struct iwic_bchan sc_bchan[2];
137 struct i4b_info sc_resources;
140 /*---------------------------------------------------------------------------*
141 * rd/wr register/fifo macros
142 *---------------------------------------------------------------------------*/
143 #define IWIC_READ(sc,reg) (inb ((sc)->sc_iobase + (u_int32_t)(reg)))
144 #define IWIC_WRITE(sc,reg,val) (outb ((sc)->sc_iobase + (u_int32_t)(reg), (val)))
145 #define IWIC_WRDFIFO(sc,p,l) (outsb ((sc)->sc_iobase + D_XFIFO, (p), (l)))
146 #define IWIC_RDDFIFO(sc,p,l) (insb ((sc)->sc_iobase + D_RFIFO, (p), (l)))
147 #define IWIC_WRBFIFO(sc,b,p,l) (outsb (((sc)->sc_iobase + (b)->offset + B_XFIFO), (p), (l)))
148 #define IWIC_RDBFIFO(sc,b,p,l) (insb (((sc)->sc_iobase + (b)->offset + B_RFIFO), (p), (l)))
150 /*---------------------------------------------------------------------------*
151 * possible I.430 states
152 *---------------------------------------------------------------------------*/
155 ST_F3N, /* F3 Deactivated, no clock */
156 ST_F3, /* F3 Deactivated */
157 ST_F4, /* F4 Awaiting Signal */
158 ST_F5, /* F5 Identifying Input */
159 ST_F6, /* F6 Synchronized */
160 ST_F7, /* F7 Activated */
161 ST_F8, /* F8 Lost Framing */
162 ST_ILL, /* Illegal State */
166 /*---------------------------------------------------------------------------*
167 * possible I.430 events
168 *---------------------------------------------------------------------------*/
171 EV_PHAR, /* PH ACTIVATE REQUEST */
172 EV_CE, /* Clock enabled */
173 EV_T3, /* Timer 3 expired */
174 EV_INFO0, /* receiving INFO0 */
175 EV_RSY, /* receiving any signal */
176 EV_INFO2, /* receiving INFO2 */
177 EV_INFO48, /* receiving INFO4 pri 8/9 */
178 EV_INFO410, /* receiving INFO4 pri 10/11 */
179 EV_DR, /* Deactivate Request */
180 EV_PU, /* Power UP */
181 EV_DIS, /* Disconnected (only 2085) */
182 EV_EI, /* Error Indication */
183 EV_ILL, /* Illegal Event */
187 /*---------------------------------------------------------------------------*
189 *---------------------------------------------------------------------------*/
192 CMD_ECK, /* Enable clock */
193 CMD_TIM, /* Timing */
195 CMD_AR8, /* Activation request pri 8 */
196 CMD_AR10, /* Activation request pri 10 */
197 CMD_DIU, /* Deactivate Indication Upstream */
198 CMD_ILL /* Illegal command */
202 extern struct iwic_softc iwic_sc[];
204 #define iwic_find_sc(unit) (&iwic_sc[(unit)])
206 extern void iwic_init(struct iwic_softc *);
207 extern void iwic_next_state(struct iwic_softc *, int);
209 extern void iwic_dchan_init(struct iwic_softc *);
210 extern void iwic_dchan_xirq(struct iwic_softc *);
211 extern void iwic_dchan_xfer_irq(struct iwic_softc *, int);
212 extern void iwic_dchan_disable(struct iwic_softc *sc);
213 extern int iwic_dchan_data_req(struct iwic_softc *sc, struct mbuf *m, int freeflag);
214 extern void iwic_dchan_transmit(struct iwic_softc *sc);
216 char *iwic_printstate(struct iwic_softc *sc);
218 void iwic_init_linktab(struct iwic_softc *sc);
219 void iwic_bchan_xirq(struct iwic_softc *, int);
220 void iwic_bchannel_setup(int unit, int h_chan, int bprot, int activate);
222 #endif /* _I4B_IWIC_H_ */