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 $
31 * $DragonFly: src/sys/net/i4b/layer1/iwic/i4b_iwic.h,v 1.2 2003/06/17 04:28:40 dillon Exp $
33 * last edit-date: [Sun Jan 21 11:08:44 2001]
35 *---------------------------------------------------------------------------*/
40 #include <i4b/layer1/iwic/i4b_iwic_ext.h>
42 /*---------------------------------------------------------------------------*
44 *---------------------------------------------------------------------------*/
46 #define INFO_IO_BASES 2
49 struct resource * io_base[INFO_IO_BASES];
50 int io_rid [INFO_IO_BASES];
51 struct resource * irq;
53 struct resource * mem;
57 /*---------------------------------------------------------------------------*
58 * state of a B channel
59 *---------------------------------------------------------------------------*/
62 int unit; /* unit number */
63 int channel; /* channel number */
64 int offset; /* offset from iobase */
65 int bprot; /* b channel protocol used */
66 int state; /* transceiver state: */
67 #define ST_IDLE 0x00 /* channel idle */
68 #define ST_TX_ACTIVE 0x01 /* tx running */
72 /* receive data from ISDN */
74 struct ifqueue rx_queue; /* receiver queue */
75 int rxcount; /* rx statistics counter*/
76 struct mbuf *in_mbuf; /* rx input buffer */
77 u_char *in_cbptr; /* curr buffer pointer */
78 int in_len; /* rx input buffer len */
80 /* transmit data to ISDN */
82 struct ifqueue tx_queue; /* transmitter queue */
83 int txcount; /* tx statistics counter */
84 struct mbuf *out_mbuf_head; /* first mbuf in possible chain */
85 struct mbuf *out_mbuf_cur; /* current mbuf in possbl chain */
86 unsigned char *out_mbuf_cur_ptr; /* data pointer into mbuf */
87 int out_mbuf_cur_len; /* remaining bytes in mbuf */
91 isdn_link_t iwic_isdn_linktab;
92 drvr_link_t *iwic_drvr_linktab;
95 /*---------------------------------------------------------------------------*
96 * state of a D channel
97 *---------------------------------------------------------------------------*/
103 u_char *ibuf_ptr; /* Input buffer pointer */
104 int ibuf_len; /* Current length of input buffer */
105 int ibuf_max_len; /* Max length in input buffer */
108 int tx_ready; /* Can send next 64 bytes of data. */
120 /*---------------------------------------------------------------------------*
121 * state of one iwic unit
122 *---------------------------------------------------------------------------*/
135 struct iwic_dchan sc_dchan;
136 struct iwic_bchan sc_bchan[2];
138 struct i4b_info sc_resources;
141 /*---------------------------------------------------------------------------*
142 * rd/wr register/fifo macros
143 *---------------------------------------------------------------------------*/
144 #define IWIC_READ(sc,reg) (inb ((sc)->sc_iobase + (u_int32_t)(reg)))
145 #define IWIC_WRITE(sc,reg,val) (outb ((sc)->sc_iobase + (u_int32_t)(reg), (val)))
146 #define IWIC_WRDFIFO(sc,p,l) (outsb ((sc)->sc_iobase + D_XFIFO, (p), (l)))
147 #define IWIC_RDDFIFO(sc,p,l) (insb ((sc)->sc_iobase + D_RFIFO, (p), (l)))
148 #define IWIC_WRBFIFO(sc,b,p,l) (outsb (((sc)->sc_iobase + (b)->offset + B_XFIFO), (p), (l)))
149 #define IWIC_RDBFIFO(sc,b,p,l) (insb (((sc)->sc_iobase + (b)->offset + B_RFIFO), (p), (l)))
151 /*---------------------------------------------------------------------------*
152 * possible I.430 states
153 *---------------------------------------------------------------------------*/
156 ST_F3N, /* F3 Deactivated, no clock */
157 ST_F3, /* F3 Deactivated */
158 ST_F4, /* F4 Awaiting Signal */
159 ST_F5, /* F5 Identifying Input */
160 ST_F6, /* F6 Synchronized */
161 ST_F7, /* F7 Activated */
162 ST_F8, /* F8 Lost Framing */
163 ST_ILL, /* Illegal State */
167 /*---------------------------------------------------------------------------*
168 * possible I.430 events
169 *---------------------------------------------------------------------------*/
172 EV_PHAR, /* PH ACTIVATE REQUEST */
173 EV_CE, /* Clock enabled */
174 EV_T3, /* Timer 3 expired */
175 EV_INFO0, /* receiving INFO0 */
176 EV_RSY, /* receiving any signal */
177 EV_INFO2, /* receiving INFO2 */
178 EV_INFO48, /* receiving INFO4 pri 8/9 */
179 EV_INFO410, /* receiving INFO4 pri 10/11 */
180 EV_DR, /* Deactivate Request */
181 EV_PU, /* Power UP */
182 EV_DIS, /* Disconnected (only 2085) */
183 EV_EI, /* Error Indication */
184 EV_ILL, /* Illegal Event */
188 /*---------------------------------------------------------------------------*
190 *---------------------------------------------------------------------------*/
193 CMD_ECK, /* Enable clock */
194 CMD_TIM, /* Timing */
196 CMD_AR8, /* Activation request pri 8 */
197 CMD_AR10, /* Activation request pri 10 */
198 CMD_DIU, /* Deactivate Indication Upstream */
199 CMD_ILL /* Illegal command */
203 extern struct iwic_softc iwic_sc[];
205 #define iwic_find_sc(unit) (&iwic_sc[(unit)])
207 extern void iwic_init(struct iwic_softc *);
208 extern void iwic_next_state(struct iwic_softc *, int);
210 extern void iwic_dchan_init(struct iwic_softc *);
211 extern void iwic_dchan_xirq(struct iwic_softc *);
212 extern void iwic_dchan_xfer_irq(struct iwic_softc *, int);
213 extern void iwic_dchan_disable(struct iwic_softc *sc);
214 extern int iwic_dchan_data_req(struct iwic_softc *sc, struct mbuf *m, int freeflag);
215 extern void iwic_dchan_transmit(struct iwic_softc *sc);
217 char *iwic_printstate(struct iwic_softc *sc);
219 void iwic_init_linktab(struct iwic_softc *sc);
220 void iwic_bchan_xirq(struct iwic_softc *, int);
221 void iwic_bchannel_setup(int unit, int h_chan, int bprot, int activate);
223 #endif /* _I4B_IWIC_H_ */