Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / net / i4b / layer1 / isic / i4b_isac.h
1 /*
2  *   Copyright (c) 1996, 2000 Gary Jennejohn. All rights reserved. 
3  *
4  *   Redistribution and use in source and binary forms, with or without
5  *   modification, are permitted provided that the following conditions
6  *   are met:
7  *
8  *   1. Redistributions of source code must retain the above copyright
9  *      notice, this list of conditions and the following disclaimer.
10  *   2. Redistributions in binary form must reproduce the above copyright
11  *      notice, this list of conditions and the following disclaimer in the
12  *      documentation and/or other materials provided with the distribution.
13  *   3. Neither the name of the author nor the names of any co-contributors
14  *      may be used to endorse or promote products derived from this software
15  *      without specific prior written permission.
16  *   4. Altered versions must be plainly marked as such, and must not be
17  *      misrepresented as being the original software and/or documentation.
18  *   
19  *   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20  *   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  *   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  *   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23  *   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  *   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  *   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  *   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  *   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  *   SUCH DAMAGE.
30  *
31  *---------------------------------------------------------------------------
32  *
33  * $FreeBSD: src/sys/i4b/layer1/isic/i4b_isac.h,v 1.2.2.1 2001/08/10 14:08:38 obrien Exp $
34  *
35  *      last edit-date: [Wed Jan 24 09:10:42 2001]
36  *
37  *---------------------------------------------------------------------------*/
38  
39 #ifndef I4B_ISAC_H_
40 #define I4B_ISAC_H_
41
42 /*
43  * The ISAC databook specifies a delay of 2.5 DCL clock cycles between
44  * writes to the ISAC command register CMDR. This is the delay used to
45  * satisfy this requirement.
46  */
47
48 #define I4B_ISAC_CMDRWRDELAY    30
49
50 #if (I4B_ISAC_CMDRWRDELAY > 0)
51 #define ISACCMDRWRDELAY() DELAY(I4B_ISAC_CMDRWRDELAY)
52 #else
53 #warning "I4B_ISAC_CMDRWRDELAY set to 0!"
54 #define ISACCMDRWRDELAY()
55 #endif
56  
57 enum ISAC_VERSIONS {
58         ISAC_VA,        /* 2085 A1 or A2, 2086/2186 V1.1        */
59         ISAC_VB1,       /* 2085 B1                              */
60         ISAC_VB2,       /* 2085 B2                              */
61         ISAC_VB3,       /* 2085 B3/V2.3                         */
62         ISAC_UNKN       /* unknown version                      */
63 };
64
65 #define ISAC_FIFO_LEN   32      /* 32 bytes FIFO on chip */
66
67 /*
68  * definitions of registers and bits for the ISAC ISDN chip.
69  */
70  
71 typedef struct isac_reg {
72
73         /* 32 byte deep FIFO always first */
74
75         unsigned char isac_fifo [ISAC_FIFO_LEN];
76
77         /* most registers can be read/written, but have different names */
78         /* so define a union with read/write names to make that clear */
79
80         union {
81                 struct {
82                         unsigned char isac_ista;
83                         unsigned char isac_star;
84                         unsigned char isac_mode;
85                         unsigned char isac_timr;
86                         unsigned char isac_exir;
87                         unsigned char isac_rbcl;
88                         unsigned char isac_sapr;
89                         unsigned char isac_rsta;
90                         unsigned char dummy_28;
91                         unsigned char isac_rhcr;
92                         unsigned char isac_rbch;
93                         unsigned char isac_star2;
94                         unsigned char dummy_2c;
95                         unsigned char dummy_2d;
96                         unsigned char dummy_2e;
97                         unsigned char dummt_2f;
98                         unsigned char isac_spcr;
99                         unsigned char isac_cirr;
100                         unsigned char isac_mor;
101                         unsigned char isac_sscr;
102                         unsigned char isac_sfcr;
103                         unsigned char isac_c1r;
104                         unsigned char isac_c2r;
105                         unsigned char isac_b1cr;
106                         unsigned char isac_b2cr;
107                         unsigned char isac_adf2;
108                         unsigned char isac_mosr;
109                         unsigned char isac_sqrr;
110                 } isac_r;
111                 struct {
112                         unsigned char isac_mask;
113                         unsigned char isac_cmdr;
114                         unsigned char isac_mode;
115                         unsigned char isac_timr;
116                         unsigned char isac_xad1;
117                         unsigned char isac_xad2;
118                         unsigned char isac_sap1;
119                         unsigned char isac_sap2;
120                         unsigned char isac_tei1;
121                         unsigned char isac_tei2;
122                         unsigned char dummy_2a;
123                         unsigned char isac_star2;
124                         unsigned char dummy_2c;
125                         unsigned char dummy_2d;
126                         unsigned char dummy_2e;
127                         unsigned char dummt_2f;
128                         unsigned char isac_spcr;
129                         unsigned char isac_cixr;
130                         unsigned char isac_mox;
131                         unsigned char isac_sscx;
132                         unsigned char isac_sfcw;
133                         unsigned char isac_c1r;
134                         unsigned char isac_c2r;
135                         unsigned char isac_stcr;
136                         unsigned char isac_adf1;
137                         unsigned char isac_adf2;
138                         unsigned char isac_mocr;
139                         unsigned char isac_sqxr;
140                 } isac_w;
141         } isac_rw;
142 } isac_reg_t;
143
144 #define REG_OFFSET(type, field) (int)(&(((type *)0)->field))
145
146 /* ISAC read registers */
147
148 #define i_ista isac_rw.isac_r.isac_ista
149 #define I_ISTA REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_ista)
150 #define i_star isac_rw.isac_r.isac_star
151 #define I_STAR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_star)
152 #define i_mode isac_rw.isac_r.isac_mode
153 #define I_MODE REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_mode)
154 #define i_timr isac_rw.isac_r.isac_timr
155 #define I_TIMR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_timr)
156 #define i_exir isac_rw.isac_r.isac_exir
157 #define I_EXIR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_exir)
158 #define i_rbcl isac_rw.isac_r.isac_rbcl
159 #define I_RBCL REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_rbcl)
160 #define i_sapr isac_rw.isac_r.isac_sapr
161 #define I_SAPR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_sapr)
162 #define i_rsta isac_rw.isac_r.isac_rsta
163 #define I_RSTA REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_rsta)
164 #define i_rhcr isac_rw.isac_r.isac_rhcr
165 #define I_RHCR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_rhcr)
166 #define i_rbch isac_rw.isac_r.isac_rbch
167 #define I_RBCH REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_rbch)
168 #define i_star2 isac_rw.isac_r.isac_star2
169 #define I_STAR2 REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_star2)
170 #define i_spcr isac_rw.isac_r.isac_spcr
171 #define I_SPCR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_spcr)
172 #define i_cirr isac_rw.isac_r.isac_cirr
173 #define I_CIRR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_cirr)
174 #define i_mor isac_rw.isac_r.isac_mor
175 #define I_MOR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_mor)
176 #define i_sscr isac_rw.isac_r.isac_sscr
177 #define I_SSCR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_sscr)
178 #define i_sfcr isac_rw.isac_r.isac_sfcr
179 #define I_SFCR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_sfcr)
180 #define i_c1r isac_rw.isac_r.isac_c1r
181 #define I_C1R REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_c1r)
182 #define i_c2r isac_rw.isac_r.isac_c2r
183 #define I_C2R REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_c2r)
184 #define i_b1cr isac_rw.isac_r.isac_b1cr
185 #define I_B1CR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_b1cr)
186 #define i_b2cr isac_rw.isac_r.isac_b2cr
187 #define I_B2CR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_b2cr)
188 #define i_adf2 isac_rw.isac_r.isac_adf2
189 #define I_ADF2 REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_adf2)
190 #define i_mosr isac_rw.isac_r.isac_mosr
191 #define I_MOSR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_mosr)
192 #define i_sqrr isac_rw.isac_r.isac_sqrr
193 #define I_SQRR REG_OFFSET(isac_reg_t, isac_rw.isac_r.isac_sqrr)
194
195 /* ISAC write registers - isac_mode, isac_timr, isac_star2, isac_spcr, */
196 /* isac_c1r, isac_c2r, isac_adf2 see read registers */
197
198 #define i_mask isac_rw.isac_w.isac_mask
199 #define I_MASK REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_mask)
200 #define i_cmdr isac_rw.isac_w.isac_cmdr
201 #define I_CMDR REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_cmdr)
202 #define i_xad1 isac_rw.isac_w.isac_xad1
203 #define I_XAD1 REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_xad1)
204 #define i_xad2 isac_rw.isac_w.isac_xad2
205 #define I_XAD2 REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_xad2)
206 #define i_sap1 isac_rw.isac_w.isac_sap1
207 #define I_SAP1 REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_sap1)
208 #define i_sap2 isac_rw.isac_w.isac_sap2
209 #define I_SAP2 REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_sap2)
210 #define i_tei1 isac_rw.isac_w.isac_tei1
211 #define i_tei2 isac_rw.isac_w.isac_tei2
212 #define i_cixr isac_rw.isac_w.isac_cixr
213 #define I_CIXR REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_cixr)
214 #define I_CIX0 I_CIXR
215 #define i_mox isac_rw.isac_w.isac_mox
216 #define I_MOX REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_mox)
217 #define i_sscx isac_rw.isac_w.isac_sscx
218 #define I_SSCX REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_sscx)
219 #define i_sfcw isac_rw.isac_w.isac_sfcw
220 #define I_SFCW REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_sfcw)
221 #define i_stcr isac_rw.isac_w.isac_stcr
222 #define I_STCR REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_stcr)
223 #define i_adf1 isac_rw.isac_w.isac_adf1
224 #define I_ADF1 REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_adf1)
225 #define i_mocr isac_rw.isac_w.isac_mocr
226 #define I_MOCR REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_mocr)
227 #define i_sqxr isac_rw.isac_w.isac_sqxr
228 #define I_SQXR REG_OFFSET(isac_reg_t, isac_rw.isac_w.isac_sqxr)
229
230 #define ISAC_ISTA_RME  0x80
231 #define ISAC_ISTA_RPF  0x40
232 #define ISAC_ISTA_RSC  0x20
233 #define ISAC_ISTA_XPR  0x10
234 #define ISAC_ISTA_TIN  0x08
235 #define ISAC_ISTA_CISQ 0x04
236 #define ISAC_ISTA_SIN  0x02
237 #define ISAC_ISTA_EXI  0x01
238
239 #define ISAC_MASK_RME  0x80
240 #define ISAC_MASL_RPF  0x40
241 #define ISAC_MASK_RSC  0x20
242 #define ISAC_MASK_XPR  0x10
243 #define ISAC_MASK_TIN  0x08
244 #define ISAC_MASK_CISQ 0x04
245 #define ISAC_MASK_SIN  0x02
246 #define ISAC_MASK_EXI  0x01
247 #define ISAC_MASK_ALL  0xff
248
249 #define ISAC_STAR_XDOV 0x80
250 #define ISAC_STAR_XFW  0x40
251 #define ISAC_STAR_XRNR 0x20
252 #define ISAC_STAR_RRNR 0x10
253 #define ISAC_STAR_MBR  0x08
254 #define ISAC_STAR_MAC1 0x04
255 #define ISAC_STAR_BVS  0x02
256 #define ISAC_STAR_MAC0 0x01
257
258 #define ISAC_CMDR_RMC  0x80
259 #define ISAC_CMDR_RRES 0x40
260 #define ISAC_CMDR_RNR  0x20
261 #define ISAC_CMDR_STI  0x10
262 #define ISAC_CMDR_XTF  0x08
263 #define ISAC_CMDR_XIF  0x04
264 #define ISAC_CMDR_XME  0x02
265 #define ISAC_CMDR_XRES 0x01
266
267 #define ISAC_MODE_MDS2 0x80
268 #define ISAC_MODE_MDS1 0x40
269 #define ISAC_MODE_MDS0 0x20
270 #define ISAC_MODE_TMD  0x10
271 #define ISAC_MODE_RAC  0x08
272 #define ISAC_MODE_DIM2 0x04
273 #define ISAC_MODE_DIM1 0x02
274 #define ISAC_MODE_DIM0 0x01
275
276 #define ISAC_EXIR_XMR  0x80
277 #define ISAC_EXIR_XDU  0x40
278 #define ISAC_EXIR_PCE  0x20
279 #define ISAC_EXIR_RFO  0x10
280 #define ISAC_EXIR_SOV  0x08
281 #define ISAC_EXIR_MOS  0x04
282 #define ISAC_EXIR_SAW  0x02
283 #define ISAC_EXIR_WOV  0x01
284
285 #define ISAC_RSTA_RDA  0x80
286 #define ISAC_RSTA_RDO  0x40
287 #define ISAC_RSTA_CRC  0x20
288 #define ISAC_RSTA_RAB  0x10
289 #define ISAC_RSTA_SA1  0x08
290 #define ISAC_RSTA_SA0  0x04
291 #define ISAC_RSTA_CR   0x02
292 #define ISAC_RSTA_TA   0x01
293
294 #define ISAC_RSTA_MASK 0x70     /* the interesting bits */
295
296 #define ISAC_RBCH_XAC  0x80
297 #define ISAC_RBCH_VN1  0x40
298 #define ISAC_RBCH_VN0  0x20
299 #define ISAC_RBCH_OV   0x10
300 /* the other 4 bits are the high bits of the receive byte count */
301
302 #define ISAC_SPCR_SPU  0x80
303 #define ISAC_SPCR_SAC  0x40
304 #define ISAC_SPCR_SPM  0x20
305 #define ISAC_SPCR_TLP  0x10
306 #define ISAC_SPCR_C1C1 0x08
307 #define ISAC_SPCR_C1C0 0x04
308 #define ISAC_SPCR_C2C1 0x02
309 #define ISAC_SPCR_C2C0 0x01
310
311 #define ISAC_CIRR_SQC  0x80
312 #define ISAC_CIRR_BAS  0x40
313 /* bits 5-2 CODR */
314 #define ISAC_CIRR_CIC0 0x02
315 /* bit 0 is always 0 */
316 /* C/I codes from bits 5-2 (>> 2 & 0xf) */
317 /* the indications */
318 #define ISAC_CIRR_IPU   0x07
319 #define ISAC_CIRR_IDR   0x00
320 #define ISAC_CIRR_ISD   0x02
321 #define ISAC_CIRR_IDIS  0x03
322 #define ISAC_CIRR_IEI   0x06
323 #define ISAC_CIRR_IRSY  0x04
324 #define ISAC_CIRR_IARD  0x08
325 #define ISAC_CIRR_ITI   0x0a
326 #define ISAC_CIRR_IATI  0x0b
327 #define ISAC_CIRR_IAI8  0x0c
328 #define ISAC_CIRR_IAI10 0x0d
329 #define ISAC_CIRR_IDID  0x0f
330
331 #define ISAC_CI_MASK    0x0f
332
333 #define ISAC_CIXR_RSS  0x80
334 #define ISAC_CIXR_BAC  0x40
335 /* bits 5-2 CODX */
336 #define ISAC_CIXR_TCX  0x02
337 #define ISAC_CIXR_ECX  0x01
338 /* in IOM-2 mode the low bits are always 1 */
339 #define ISAC_CIX0_LOW  0x03
340 /* C/I codes from bits 5-2 (>> 2 & 0xf) */
341 /* the commands */
342 #define ISAC_CIXR_CTIM  0
343 #define ISAC_CIXR_CRS   0x01
344 #define ISAC_CIXR_CSCZ  0x04
345 #define ISAC_CIXR_CSSZ  0x02
346 #define ISAC_CIXR_CAR8  0x08
347 #define ISAC_CIXR_CAR10 0x09
348 #define ISAC_CIXR_CARL  0x0a
349 #define ISAC_CIXR_CDIU  0x0f
350
351 #define ISAC_STCR_TSF  0x80
352 #define ISAC_STCR_TBA2 0x40
353 #define ISAC_STCR_TBA1 0x20
354 #define ISAC_STCR_TBA0 0x10
355 #define ISAC_STCR_ST1  0x08
356 #define ISAC_STCR_ST0  0x04
357 #define ISAC_STCR_SC1  0x02
358 #define ISAC_STCR_SC0  0x01
359
360 #define ISAC_ADF1_WTC1 0x80
361 #define ISAC_ADF1_WTC2 0x40
362 #define ISAC_ADF1_TEM  0x20
363 #define ISAC_ADF1_PFS  0x10
364 #define ISAC_ADF1_CFS  0x08
365 #define ISAC_ADF1_FC2  0x04
366 #define ISAC_ADF1_FC1  0x02
367 #define ISAC_ADF1_ITF  0x01
368
369 #define ISAC_ADF2_IMS  0x80
370 /* all other bits are 0 */
371
372 /* bits 7-5 are always 0 */
373 #define ISAC_SQRR_SYN  0x10
374 #define ISAC_SQRR_SQR1 0x08
375 #define ISAC_SQRR_SQR2 0x04
376 #define ISAC_SQRR_SQR3 0x02
377 #define ISAC_SQRR_SQR4 0x01
378
379 #define ISAC_SQXR_IDC  0x80
380 #define ISAC_SQXR_CFS  0x40
381 #define ISAC_SQXR_CI1E 0x20
382 #define ISAC_SQXR_SQIE 0x10
383 #define ISAC_SQXR_SQX1 0x08
384 #define ISAC_SQXR_SQX2 0x04
385 #define ISAC_SQXR_SQX3 0x02
386 #define ISAC_SQXR_SQX4 0x01
387
388 #endif /* I4B_ISAC_H_ */