iwl-4965-hw.h: clean up unused eeprom structures and definitions
[linux-2.6] / drivers / telephony / ixj.h
1 /******************************************************************************
2  *    ixj.h
3  *
4  *
5  * Device Driver for Quicknet Technologies, Inc.'s Telephony cards
6  * including the Internet PhoneJACK, Internet PhoneJACK Lite,
7  * Internet PhoneJACK PCI, Internet LineJACK, Internet PhoneCARD and
8  * SmartCABLE
9  *
10  *    (c) Copyright 1999-2001  Quicknet Technologies, Inc.
11  *
12  *    This program is free software; you can redistribute it and/or
13  *    modify it under the terms of the GNU General Public License
14  *    as published by the Free Software Foundation; either version
15  *    2 of the License, or (at your option) any later version.
16  *
17  * Author:          Ed Okerson, <eokerson@quicknet.net>
18  *    
19  * Contributors:    Greg Herlein, <gherlein@quicknet.net>
20  *                  David W. Erhart, <derhart@quicknet.net>
21  *                  John Sellers, <jsellers@quicknet.net>
22  *                  Mike Preston, <mpreston@quicknet.net>
23  *
24  * More information about the hardware related to this driver can be found
25  * at our website:    http://www.quicknet.net
26  *
27  * Fixes:
28  *
29  * IN NO EVENT SHALL QUICKNET TECHNOLOGIES, INC. BE LIABLE TO ANY PARTY FOR
30  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
31  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF QUICKNET
32  * TECHNOLOGIES, INC.HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * QUICKNET TECHNOLOGIES, INC. SPECIFICALLY DISCLAIMS ANY WARRANTIES,
35  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
36  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
37  * ON AN "AS IS" BASIS, AND QUICKNET TECHNOLOGIES, INC. HAS NO OBLIGATION 
38  * TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
39  *
40  *****************************************************************************/
41 #define IXJ_VERSION 3031
42
43 #include <linux/types.h>
44
45 #include <linux/ixjuser.h>
46 #include <linux/phonedev.h>
47
48 typedef __u16 WORD;
49 typedef __u32 DWORD;
50 typedef __u8 BYTE;
51
52 #ifndef IXJMAX
53 #define IXJMAX 16
54 #endif
55
56 /******************************************************************************
57 *
58 *  This structure when unioned with the structures below makes simple byte
59 *  access to the registers easier.
60 *
61 ******************************************************************************/
62 typedef struct {
63         unsigned char low;
64         unsigned char high;
65 } BYTES;
66
67 typedef union {
68         BYTES bytes;
69         short word;
70 } IXJ_WORD;
71
72 typedef struct{
73         unsigned int b0:1;
74         unsigned int b1:1;
75         unsigned int b2:1;
76         unsigned int b3:1;
77         unsigned int b4:1;
78         unsigned int b5:1;
79         unsigned int b6:1;
80         unsigned int b7:1;
81 } IXJ_CBITS;
82
83 typedef union{
84         IXJ_CBITS cbits;
85           char  cbyte;
86 } IXJ_CBYTE;
87
88 /******************************************************************************
89 *
90 *  This structure represents the Hardware Control Register of the CT8020/8021
91 *  The CT8020 is used in the Internet PhoneJACK, and the 8021 in the
92 *  Internet LineJACK
93 *
94 ******************************************************************************/
95 typedef struct {
96         unsigned int rxrdy:1;
97         unsigned int txrdy:1;
98         unsigned int status:1;
99         unsigned int auxstatus:1;
100         unsigned int rxdma:1;
101         unsigned int txdma:1;
102         unsigned int rxburst:1;
103         unsigned int txburst:1;
104         unsigned int dmadir:1;
105         unsigned int cont:1;
106         unsigned int irqn:1;
107         unsigned int t:5;
108 } HCRBIT;
109
110 typedef union {
111         HCRBIT bits;
112         BYTES bytes;
113 } HCR;
114
115 /******************************************************************************
116 *
117 *  This structure represents the Hardware Status Register of the CT8020/8021
118 *  The CT8020 is used in the Internet PhoneJACK, and the 8021 in the
119 *  Internet LineJACK
120 *
121 ******************************************************************************/
122 typedef struct {
123         unsigned int controlrdy:1;
124         unsigned int auxctlrdy:1;
125         unsigned int statusrdy:1;
126         unsigned int auxstatusrdy:1;
127         unsigned int rxrdy:1;
128         unsigned int txrdy:1;
129         unsigned int restart:1;
130         unsigned int irqn:1;
131         unsigned int rxdma:1;
132         unsigned int txdma:1;
133         unsigned int cohostshutdown:1;
134         unsigned int t:5;
135 } HSRBIT;
136
137 typedef union {
138         HSRBIT bits;
139         BYTES bytes;
140 } HSR;
141
142 /******************************************************************************
143 *
144 *  This structure represents the General Purpose IO Register of the CT8020/8021
145 *  The CT8020 is used in the Internet PhoneJACK, and the 8021 in the
146 *  Internet LineJACK
147 *
148 ******************************************************************************/
149 typedef struct {
150         unsigned int x:1;
151         unsigned int gpio1:1;
152         unsigned int gpio2:1;
153         unsigned int gpio3:1;
154         unsigned int gpio4:1;
155         unsigned int gpio5:1;
156         unsigned int gpio6:1;
157         unsigned int gpio7:1;
158         unsigned int xread:1;
159         unsigned int gpio1read:1;
160         unsigned int gpio2read:1;
161         unsigned int gpio3read:1;
162         unsigned int gpio4read:1;
163         unsigned int gpio5read:1;
164         unsigned int gpio6read:1;
165         unsigned int gpio7read:1;
166 } GPIOBIT;
167
168 typedef union {
169         GPIOBIT bits;
170         BYTES bytes;
171         unsigned short word;
172 } GPIO;
173
174 /******************************************************************************
175 *
176 *  This structure represents the Line Monitor status response
177 *
178 ******************************************************************************/
179 typedef struct {
180         unsigned int digit:4;
181         unsigned int cpf_valid:1;
182         unsigned int dtmf_valid:1;
183         unsigned int peak:1;
184         unsigned int z:1;
185         unsigned int f0:1;
186         unsigned int f1:1;
187         unsigned int f2:1;
188         unsigned int f3:1;
189         unsigned int frame:4;
190 } LMON;
191
192 typedef union {
193         LMON bits;
194         BYTES bytes;
195 } DTMF;
196
197 typedef struct {
198         unsigned int z:7;
199         unsigned int dtmf_en:1;
200         unsigned int y:4;
201         unsigned int F3:1;
202         unsigned int F2:1;
203         unsigned int F1:1;
204         unsigned int F0:1;
205 } CP;
206
207 typedef union {
208         CP bits;
209         BYTES bytes;
210 } CPTF;
211
212 /******************************************************************************
213 *
214 *  This structure represents the Status Control Register on the Internet
215 *  LineJACK
216 *
217 ******************************************************************************/
218 typedef struct {
219         unsigned int c0:1;
220         unsigned int c1:1;
221         unsigned int stereo:1;
222         unsigned int daafsyncen:1;
223         unsigned int led1:1;
224         unsigned int led2:1;
225         unsigned int led3:1;
226         unsigned int led4:1;
227 } PSCRWI;                       /* Internet LineJACK and Internet PhoneJACK Lite */
228
229 typedef struct {
230         unsigned int eidp:1;
231         unsigned int eisd:1;
232         unsigned int x:6;
233 } PSCRWP;                       /* Internet PhoneJACK PCI */
234
235 typedef union {
236         PSCRWI bits;
237         PSCRWP pcib;
238         char byte;
239 } PLD_SCRW;
240
241 typedef struct {
242         unsigned int c0:1;
243         unsigned int c1:1;
244         unsigned int x:1;
245         unsigned int d0ee:1;
246         unsigned int mixerbusy:1;
247         unsigned int sci:1;
248         unsigned int dspflag:1;
249         unsigned int daaflag:1;
250 } PSCRRI;
251
252 typedef struct {
253         unsigned int eidp:1;
254         unsigned int eisd:1;
255         unsigned int x:4;
256         unsigned int dspflag:1;
257         unsigned int det:1;
258 } PSCRRP;
259
260 typedef union {
261         PSCRRI bits;
262         PSCRRP pcib;
263         char byte;
264 } PLD_SCRR;
265
266 /******************************************************************************
267 *
268 *  These structures represents the SLIC Control Register on the
269 *  Internet LineJACK
270 *
271 ******************************************************************************/
272 typedef struct {
273         unsigned int c1:1;
274         unsigned int c2:1;
275         unsigned int c3:1;
276         unsigned int b2en:1;
277         unsigned int spken:1;
278         unsigned int rly1:1;
279         unsigned int rly2:1;
280         unsigned int rly3:1;
281 } PSLICWRITE;
282
283 typedef struct {
284         unsigned int state:3;
285         unsigned int b2en:1;
286         unsigned int spken:1;
287         unsigned int c3:1;
288         unsigned int potspstn:1;
289         unsigned int det:1;
290 } PSLICREAD;
291
292 typedef struct {
293         unsigned int c1:1;
294         unsigned int c2:1;
295         unsigned int c3:1;
296         unsigned int b2en:1;
297         unsigned int e1:1;
298         unsigned int mic:1;
299         unsigned int spk:1;
300         unsigned int x:1;
301 } PSLICPCI;
302
303 typedef union {
304         PSLICPCI pcib;
305         PSLICWRITE bits;
306         PSLICREAD slic;
307         char byte;
308 } PLD_SLICW;
309
310 typedef union {
311         PSLICPCI pcib;
312         PSLICREAD bits;
313         char byte;
314 } PLD_SLICR;
315
316 /******************************************************************************
317 *
318 *  These structures represents the Clock Control Register on the
319 *  Internet LineJACK
320 *
321 ******************************************************************************/
322 typedef struct {
323         unsigned int clk0:1;
324         unsigned int clk1:1;
325         unsigned int clk2:1;
326         unsigned int x0:1;
327         unsigned int slic_e1:1;
328         unsigned int x1:1;
329         unsigned int x2:1;
330         unsigned int x3:1;
331 } PCLOCK;
332
333 typedef union {
334         PCLOCK bits;
335         char byte;
336 } PLD_CLOCK;
337
338 /******************************************************************************
339 *
340 *  These structures deal with the mixer on the Internet LineJACK
341 *
342 ******************************************************************************/
343
344 typedef struct {
345         unsigned short vol[10];
346         unsigned int recsrc;
347         unsigned int modcnt;
348         unsigned short micpreamp;
349 } MIX;
350
351 /******************************************************************************
352 *
353 *  These structures deal with the control logic on the Internet PhoneCARD
354 *
355 ******************************************************************************/
356 typedef struct {
357         unsigned int x0:4;      /* unused bits */
358
359         unsigned int ed:1;      /* Event Detect */
360
361         unsigned int drf:1;     /* SmartCABLE Removal Flag 1=no cable */
362
363         unsigned int dspf:1;    /* DSP Flag 1=DSP Ready */
364
365         unsigned int crr:1;     /* Control Register Ready */
366
367 } COMMAND_REG1;
368
369 typedef union {
370         COMMAND_REG1 bits;
371         unsigned char byte;
372 } PCMCIA_CR1;
373
374 typedef struct {
375         unsigned int x0:4;      /* unused bits */
376
377         unsigned int rstc:1;    /* SmartCABLE Reset */
378
379         unsigned int pwr:1;     /* SmartCABLE Power */
380
381         unsigned int x1:2;      /* unused bits */
382
383 } COMMAND_REG2;
384
385 typedef union {
386         COMMAND_REG2 bits;
387         unsigned char byte;
388 } PCMCIA_CR2;
389
390 typedef struct {
391         unsigned int addr:5;    /* R/W SmartCABLE Register Address */
392
393         unsigned int rw:1;      /* Read / Write flag */
394
395         unsigned int dev:2;     /* 2 bit SmartCABLE Device Address */
396
397 } CONTROL_REG;
398
399 typedef union {
400         CONTROL_REG bits;
401         unsigned char byte;
402 } PCMCIA_SCCR;
403
404 typedef struct {
405         unsigned int hsw:1;
406         unsigned int det:1;
407         unsigned int led2:1;
408         unsigned int led1:1;
409         unsigned int ring1:1;
410         unsigned int ring0:1;
411         unsigned int x:1;
412         unsigned int powerdown:1;
413 } PCMCIA_SLIC_REG;
414
415 typedef union {
416         PCMCIA_SLIC_REG bits;
417         unsigned char byte;
418 } PCMCIA_SLIC;
419
420 typedef struct {
421         unsigned int cpd:1;     /* Chip Power Down */
422
423         unsigned int mpd:1;     /* MIC Bias Power Down */
424
425         unsigned int hpd:1;     /* Handset Drive Power Down */
426
427         unsigned int lpd:1;     /* Line Drive Power Down */
428
429         unsigned int spd:1;     /* Speaker Drive Power Down */
430
431         unsigned int x:2;       /* unused bits */
432
433         unsigned int sr:1;      /* Software Reset */
434
435 } Si3CONTROL1;
436
437 typedef union {
438         Si3CONTROL1 bits;
439         unsigned char byte;
440 } Si3C1;
441
442 typedef struct {
443         unsigned int al:1;      /* Analog Loopback DAC analog -> ADC analog */
444
445         unsigned int dl2:1;     /* Digital Loopback DAC -> ADC one bit */
446
447         unsigned int dl1:1;     /* Digital Loopback ADC -> DAC one bit */
448
449         unsigned int pll:1;     /* 1 = div 10, 0 = div 5 */
450
451         unsigned int hpd:1;     /* HPF disable */
452
453         unsigned int x:3;       /* unused bits */
454
455 } Si3CONTROL2;
456
457 typedef union {
458         Si3CONTROL2 bits;
459         unsigned char byte;
460 } Si3C2;
461
462 typedef struct {
463         unsigned int iir:1;     /* 1 enables IIR, 0 enables FIR */
464
465         unsigned int him:1;     /* Handset Input Mute */
466
467         unsigned int mcm:1;     /* MIC In Mute */
468
469         unsigned int mcg:2;     /* MIC In Gain */
470
471         unsigned int lim:1;     /* Line In Mute */
472
473         unsigned int lig:2;     /* Line In Gain */
474
475 } Si3RXGAIN;
476
477 typedef union {
478         Si3RXGAIN bits;
479         unsigned char byte;
480 } Si3RXG;
481
482 typedef struct {
483         unsigned int hom:1;     /* Handset Out Mute */
484
485         unsigned int lom:1;     /* Line Out Mute */
486
487         unsigned int rxg:5;     /* RX PGA Gain */
488
489         unsigned int x:1;       /* unused bit */
490
491 } Si3ADCVOLUME;
492
493 typedef union {
494         Si3ADCVOLUME bits;
495         unsigned char byte;
496 } Si3ADC;
497
498 typedef struct {
499         unsigned int srm:1;     /* Speaker Right Mute */
500
501         unsigned int slm:1;     /* Speaker Left Mute */
502
503         unsigned int txg:5;     /* TX PGA Gain */
504
505         unsigned int x:1;       /* unused bit */
506
507 } Si3DACVOLUME;
508
509 typedef union {
510         Si3DACVOLUME bits;
511         unsigned char byte;
512 } Si3DAC;
513
514 typedef struct {
515         unsigned int x:5;       /* unused bit */
516
517         unsigned int losc:1;    /* Line Out Short Circuit */
518
519         unsigned int srsc:1;    /* Speaker Right Short Circuit */
520
521         unsigned int slsc:1;    /* Speaker Left Short Circuit */
522
523 } Si3STATUSREPORT;
524
525 typedef union {
526         Si3STATUSREPORT bits;
527         unsigned char byte;
528 } Si3STAT;
529
530 typedef struct {
531         unsigned int sot:2;     /* Speaker Out Attenuation */
532
533         unsigned int lot:2;     /* Line Out Attenuation */
534
535         unsigned int x:4;       /* unused bits */
536
537 } Si3ANALOGATTN;
538
539 typedef union {
540         Si3ANALOGATTN bits;
541         unsigned char byte;
542 } Si3AATT;
543
544 /******************************************************************************
545 *
546 *  These structures deal with the DAA on the Internet LineJACK
547 *
548 ******************************************************************************/
549
550 typedef struct _DAA_REGS {
551         /*----------------------------------------------- */
552         /* SOP Registers */
553         /* */
554         BYTE bySOP;
555
556         union _SOP_REGS {
557                 struct _SOP {
558                         union   /* SOP - CR0 Register */
559                          {
560                                 BYTE reg;
561                                 struct _CR0_BITREGS {
562                                         BYTE CLK_EXT:1;         /* cr0[0:0] */
563
564                                         BYTE RIP:1;     /* cr0[1:1] */
565
566                                         BYTE AR:1;      /* cr0[2:2] */
567
568                                         BYTE AX:1;      /* cr0[3:3] */
569
570                                         BYTE FRR:1;     /* cr0[4:4] */
571
572                                         BYTE FRX:1;     /* cr0[5:5] */
573
574                                         BYTE IM:1;      /* cr0[6:6] */
575
576                                         BYTE TH:1;      /* cr0[7:7] */
577
578                                 } bitreg;
579                         } cr0;
580
581                         union   /* SOP - CR1 Register */
582                          {
583                                 BYTE reg;
584                                 struct _CR1_REGS {
585                                         BYTE RM:1;      /* cr1[0:0] */
586
587                                         BYTE RMR:1;     /* cr1[1:1] */
588
589                                         BYTE No_auto:1;         /* cr1[2:2] */
590
591                                         BYTE Pulse:1;   /* cr1[3:3] */
592
593                                         BYTE P_Tone1:1;         /* cr1[4:4] */
594
595                                         BYTE P_Tone2:1;         /* cr1[5:5] */
596
597                                         BYTE E_Tone1:1;         /* cr1[6:6] */
598
599                                         BYTE E_Tone2:1;         /* cr1[7:7] */
600
601                                 } bitreg;
602                         } cr1;
603
604                         union   /* SOP - CR2 Register */
605                          {
606                                 BYTE reg;
607                                 struct _CR2_REGS {
608                                         BYTE Call_II:1;         /* CR2[0:0] */
609
610                                         BYTE Call_I:1;  /* CR2[1:1] */
611
612                                         BYTE Call_en:1;         /* CR2[2:2] */
613
614                                         BYTE Call_pon:1;        /* CR2[3:3] */
615
616                                         BYTE IDR:1;     /* CR2[4:4] */
617
618                                         BYTE COT_R:3;   /* CR2[5:7] */
619
620                                 } bitreg;
621                         } cr2;
622
623                         union   /* SOP - CR3 Register */
624                          {
625                                 BYTE reg;
626                                 struct _CR3_REGS {
627                                         BYTE DHP_X:1;   /* CR3[0:0] */
628
629                                         BYTE DHP_R:1;   /* CR3[1:1] */
630
631                                         BYTE Cal_pctl:1;        /* CR3[2:2] */
632
633                                         BYTE SEL:1;     /* CR3[3:3] */
634
635                                         BYTE TestLoops:4;       /* CR3[4:7] */
636
637                                 } bitreg;
638                         } cr3;
639
640                         union   /* SOP - CR4 Register */
641                          {
642                                 BYTE reg;
643                                 struct _CR4_REGS {
644                                         BYTE Fsc_en:1;  /* CR4[0:0] */
645
646                                         BYTE Int_en:1;  /* CR4[1:1] */
647
648                                         BYTE AGX:2;     /* CR4[2:3] */
649
650                                         BYTE AGR_R:2;   /* CR4[4:5] */
651
652                                         BYTE AGR_Z:2;   /* CR4[6:7] */
653
654                                 } bitreg;
655                         } cr4;
656
657                         union   /* SOP - CR5 Register */
658                          {
659                                 BYTE reg;
660                                 struct _CR5_REGS {
661                                         BYTE V_0:1;     /* CR5[0:0] */
662
663                                         BYTE V_1:1;     /* CR5[1:1] */
664
665                                         BYTE V_2:1;     /* CR5[2:2] */
666
667                                         BYTE V_3:1;     /* CR5[3:3] */
668
669                                         BYTE V_4:1;     /* CR5[4:4] */
670
671                                         BYTE V_5:1;     /* CR5[5:5] */
672
673                                         BYTE V_6:1;     /* CR5[6:6] */
674
675                                         BYTE V_7:1;     /* CR5[7:7] */
676
677                                 } bitreg;
678                         } cr5;
679
680                         union   /* SOP - CR6 Register */
681                          {
682                                 BYTE reg;
683                                 struct _CR6_REGS {
684                                         BYTE reserved:8;        /* CR6[0:7] */
685
686                                 } bitreg;
687                         } cr6;
688
689                         union   /* SOP - CR7 Register */
690                          {
691                                 BYTE reg;
692                                 struct _CR7_REGS {
693                                         BYTE reserved:8;        /* CR7[0:7] */
694
695                                 } bitreg;
696                         } cr7;
697                 } SOP;
698
699                 BYTE ByteRegs[sizeof(struct _SOP)];
700
701         } SOP_REGS;
702
703         /* DAA_REGS.SOP_REGS.SOP.CR5.reg */
704         /* DAA_REGS.SOP_REGS.SOP.CR5.bitreg */
705         /* DAA_REGS.SOP_REGS.SOP.CR5.bitreg.V_2 */
706         /* DAA_REGS.SOP_REGS.ByteRegs[5] */
707
708         /*----------------------------------------------- */
709         /* XOP Registers */
710         /* */
711         BYTE byXOP;
712
713         union _XOP_REGS {
714                 struct _XOP {
715                         union   XOPXR0/* XOP - XR0 Register - Read values */
716                          {
717                                 BYTE reg;
718                                 struct _XR0_BITREGS {
719                                         BYTE SI_0:1;    /* XR0[0:0] - Read */
720
721                                         BYTE SI_1:1;    /* XR0[1:1] - Read */
722
723                                         BYTE VDD_OK:1;  /* XR0[2:2] - Read */
724
725                                         BYTE Caller_ID:1;       /* XR0[3:3] - Read */
726
727                                         BYTE RING:1;    /* XR0[4:4] - Read */
728
729                                         BYTE Cadence:1;         /* XR0[5:5] - Read */
730
731                                         BYTE Wake_up:1;         /* XR0[6:6] - Read */
732
733                                         BYTE RMR:1;     /* XR0[7:7] - Read */
734
735                                 } bitreg;
736                         } xr0;
737
738                         union   /* XOP - XR1 Register */
739                          {
740                                 BYTE reg;
741                                 struct _XR1_BITREGS {
742                                         BYTE M_SI_0:1;  /* XR1[0:0] */
743
744                                         BYTE M_SI_1:1;  /* XR1[1:1] */
745
746                                         BYTE M_VDD_OK:1;        /* XR1[2:2] */
747
748                                         BYTE M_Caller_ID:1;     /* XR1[3:3] */
749
750                                         BYTE M_RING:1;  /* XR1[4:4] */
751
752                                         BYTE M_Cadence:1;       /* XR1[5:5] */
753
754                                         BYTE M_Wake_up:1;       /* XR1[6:6] */
755
756                                         BYTE unused:1;  /* XR1[7:7] */
757
758                                 } bitreg;
759                         } xr1;
760
761                         union   /* XOP - XR2 Register */
762                          {
763                                 BYTE reg;
764                                 struct _XR2_BITREGS {
765                                         BYTE CTO0:1;    /* XR2[0:0] */
766
767                                         BYTE CTO1:1;    /* XR2[1:1] */
768
769                                         BYTE CTO2:1;    /* XR2[2:2] */
770
771                                         BYTE CTO3:1;    /* XR2[3:3] */
772
773                                         BYTE CTO4:1;    /* XR2[4:4] */
774
775                                         BYTE CTO5:1;    /* XR2[5:5] */
776
777                                         BYTE CTO6:1;    /* XR2[6:6] */
778
779                                         BYTE CTO7:1;    /* XR2[7:7] */
780
781                                 } bitreg;
782                         } xr2;
783
784                         union   /* XOP - XR3 Register */
785                          {
786                                 BYTE reg;
787                                 struct _XR3_BITREGS {
788                                         BYTE DCR0:1;    /* XR3[0:0] */
789
790                                         BYTE DCR1:1;    /* XR3[1:1] */
791
792                                         BYTE DCI:1;     /* XR3[2:2] */
793
794                                         BYTE DCU0:1;    /* XR3[3:3] */
795
796                                         BYTE DCU1:1;    /* XR3[4:4] */
797
798                                         BYTE B_off:1;   /* XR3[5:5] */
799
800                                         BYTE AGB0:1;    /* XR3[6:6] */
801
802                                         BYTE AGB1:1;    /* XR3[7:7] */
803
804                                 } bitreg;
805                         } xr3;
806
807                         union   /* XOP - XR4 Register */
808                          {
809                                 BYTE reg;
810                                 struct _XR4_BITREGS {
811                                         BYTE C_0:1;     /* XR4[0:0] */
812
813                                         BYTE C_1:1;     /* XR4[1:1] */
814
815                                         BYTE C_2:1;     /* XR4[2:2] */
816
817                                         BYTE C_3:1;     /* XR4[3:3] */
818
819                                         BYTE C_4:1;     /* XR4[4:4] */
820
821                                         BYTE C_5:1;     /* XR4[5:5] */
822
823                                         BYTE C_6:1;     /* XR4[6:6] */
824
825                                         BYTE C_7:1;     /* XR4[7:7] */
826
827                                 } bitreg;
828                         } xr4;
829
830                         union   /* XOP - XR5 Register */
831                          {
832                                 BYTE reg;
833                                 struct _XR5_BITREGS {
834                                         BYTE T_0:1;     /* XR5[0:0] */
835
836                                         BYTE T_1:1;     /* XR5[1:1] */
837
838                                         BYTE T_2:1;     /* XR5[2:2] */
839
840                                         BYTE T_3:1;     /* XR5[3:3] */
841
842                                         BYTE T_4:1;     /* XR5[4:4] */
843
844                                         BYTE T_5:1;     /* XR5[5:5] */
845
846                                         BYTE T_6:1;     /* XR5[6:6] */
847
848                                         BYTE T_7:1;     /* XR5[7:7] */
849
850                                 } bitreg;
851                         } xr5;
852
853                         union   /* XOP - XR6 Register - Read Values */
854                          {
855                                 BYTE reg;
856                                 struct _XR6_BITREGS {
857                                         BYTE CPS0:1;    /* XR6[0:0] */
858
859                                         BYTE CPS1:1;    /* XR6[1:1] */
860
861                                         BYTE unused1:2;         /* XR6[2:3] */
862
863                                         BYTE CLK_OFF:1;         /* XR6[4:4] */
864
865                                         BYTE unused2:3;         /* XR6[5:7] */
866
867                                 } bitreg;
868                         } xr6;
869
870                         union   /* XOP - XR7 Register */
871                          {
872                                 BYTE reg;
873                                 struct _XR7_BITREGS {
874                                         BYTE unused1:1;         /* XR7[0:0] */
875
876                                         BYTE Vdd0:1;    /* XR7[1:1] */
877
878                                         BYTE Vdd1:1;    /* XR7[2:2] */
879
880                                         BYTE unused2:5;         /* XR7[3:7] */
881
882                                 } bitreg;
883                         } xr7;
884                 } XOP;
885
886                 BYTE ByteRegs[sizeof(struct _XOP)];
887
888         } XOP_REGS;
889
890         /* DAA_REGS.XOP_REGS.XOP.XR7.reg */
891         /* DAA_REGS.XOP_REGS.XOP.XR7.bitreg */
892         /* DAA_REGS.XOP_REGS.XOP.XR7.bitreg.Vdd0 */
893         /* DAA_REGS.XOP_REGS.ByteRegs[7] */
894
895         /*----------------------------------------------- */
896         /* COP Registers */
897         /* */
898         BYTE byCOP;
899
900         union _COP_REGS {
901                 struct _COP {
902                         BYTE THFilterCoeff_1[8];        /* COP - TH Filter Coefficients,      CODE=0, Part 1 */
903
904                         BYTE THFilterCoeff_2[8];        /* COP - TH Filter Coefficients,      CODE=1, Part 2 */
905
906                         BYTE THFilterCoeff_3[8];        /* COP - TH Filter Coefficients,      CODE=2, Part 3 */
907
908                         BYTE RingerImpendance_1[8];     /* COP - Ringer Impendance Coefficients,  CODE=3, Part 1 */
909
910                         BYTE IMFilterCoeff_1[8];        /* COP - IM Filter Coefficients,      CODE=4, Part 1 */
911
912                         BYTE IMFilterCoeff_2[8];        /* COP - IM Filter Coefficients,      CODE=5, Part 2 */
913
914                         BYTE RingerImpendance_2[8];     /* COP - Ringer Impendance Coefficients,  CODE=6, Part 2 */
915
916                         BYTE FRRFilterCoeff[8];         /* COP - FRR Filter Coefficients,      CODE=7 */
917
918                         BYTE FRXFilterCoeff[8];         /* COP - FRX Filter Coefficients,      CODE=8 */
919
920                         BYTE ARFilterCoeff[4];  /* COP - AR Filter Coefficients,      CODE=9 */
921
922                         BYTE AXFilterCoeff[4];  /* COP - AX Filter Coefficients,      CODE=10  */
923
924                         BYTE Tone1Coeff[4];     /* COP - Tone1 Coefficients,        CODE=11 */
925
926                         BYTE Tone2Coeff[4];     /* COP - Tone2 Coefficients,        CODE=12 */
927
928                         BYTE LevelmeteringRinging[4];   /* COP - Levelmetering Ringing,        CODE=13 */
929
930                         BYTE CallerID1stTone[8];        /* COP - Caller ID 1st Tone,        CODE=14 */
931
932                         BYTE CallerID2ndTone[8];        /* COP - Caller ID 2nd Tone,        CODE=15 */
933
934                 } COP;
935
936                 BYTE ByteRegs[sizeof(struct _COP)];
937
938         } COP_REGS;
939
940         /* DAA_REGS.COP_REGS.COP.XR7.Tone1Coeff[3] */
941         /* DAA_REGS.COP_REGS.COP.XR7.bitreg */
942         /* DAA_REGS.COP_REGS.COP.XR7.bitreg.Vdd0 */
943         /* DAA_REGS.COP_REGS.ByteRegs[57] */
944
945         /*----------------------------------------------- */
946         /* CAO Registers */
947         /* */
948         BYTE byCAO;
949
950         union _CAO_REGS {
951                 struct _CAO {
952                         BYTE CallerID[512];     /* CAO - Caller ID Bytes */
953
954                 } CAO;
955
956                 BYTE ByteRegs[sizeof(struct _CAO)];
957         } CAO_REGS;
958
959         union                   /* XOP - XR0 Register - Write values */
960          {
961                 BYTE reg;
962                 struct _XR0_BITREGSW {
963                         BYTE SO_0:1;    /* XR1[0:0] - Write */
964
965                         BYTE SO_1:1;    /* XR1[1:1] - Write */
966
967                         BYTE SO_2:1;    /* XR1[2:2] - Write */
968
969                         BYTE unused:5;  /* XR1[3:7] - Write */
970
971                 } bitreg;
972         } XOP_xr0_W;
973
974         union                   /* XOP - XR6 Register - Write values */
975          {
976                 BYTE reg;
977                 struct _XR6_BITREGSW {
978                         BYTE unused1:4;         /* XR6[0:3] */
979
980                         BYTE CLK_OFF:1;         /* XR6[4:4] */
981
982                         BYTE unused2:3;         /* XR6[5:7] */
983
984                 } bitreg;
985         } XOP_xr6_W;
986
987 } DAA_REGS;
988
989 #define ALISDAA_ID_BYTE      0x81
990 #define ALISDAA_CALLERID_SIZE  512
991
992 /*------------------------------ */
993 /* */
994 /*  Misc definitions */
995 /* */
996
997 /* Power Up Operation */
998 #define SOP_PU_SLEEP    0
999 #define SOP_PU_RINGING    1
1000 #define SOP_PU_CONVERSATION  2
1001 #define SOP_PU_PULSEDIALING  3
1002 #define SOP_PU_RESET    4
1003
1004 #define ALISDAA_CALLERID_SIZE 512
1005
1006 #define PLAYBACK_MODE_COMPRESSED        0       /*        Selects: Compressed modes, TrueSpeech 8.5-4.1, G.723.1, G.722, G.728, G.729 */
1007 #define PLAYBACK_MODE_TRUESPEECH_V40    0       /*        Selects: TrueSpeech 8.5, 6.3, 5.3, 4.8 or 4.1 Kbps */
1008 #define PLAYBACK_MODE_TRUESPEECH        8       /*        Selects: TrueSpeech 8.5, 6.3, 5.3, 4.8 or 4.1 Kbps Version 5.1 */
1009 #define PLAYBACK_MODE_ULAW              2       /*        Selects: 64 Kbit/sec MuA-law PCM */
1010 #define PLAYBACK_MODE_ALAW              10      /*        Selects: 64 Kbit/sec A-law PCM */
1011 #define PLAYBACK_MODE_16LINEAR          6       /*        Selects: 128 Kbit/sec 16-bit linear */
1012 #define PLAYBACK_MODE_8LINEAR           4       /*        Selects: 64 Kbit/sec 8-bit signed linear */
1013 #define PLAYBACK_MODE_8LINEAR_WSS       5       /*        Selects: 64 Kbit/sec WSS 8-bit unsigned linear */
1014
1015 #define RECORD_MODE_COMPRESSED          0       /*        Selects: Compressed modes, TrueSpeech 8.5-4.1, G.723.1, G.722, G.728, G.729 */
1016 #define RECORD_MODE_TRUESPEECH          0       /*        Selects: TrueSpeech 8.5, 6.3, 5.3, 4.8 or 4.1 Kbps */
1017 #define RECORD_MODE_ULAW                4       /*        Selects: 64 Kbit/sec Mu-law PCM */
1018 #define RECORD_MODE_ALAW                12      /*        Selects: 64 Kbit/sec A-law PCM */
1019 #define RECORD_MODE_16LINEAR            5       /*        Selects: 128 Kbit/sec 16-bit linear */
1020 #define RECORD_MODE_8LINEAR             6       /*        Selects: 64 Kbit/sec 8-bit signed linear */
1021 #define RECORD_MODE_8LINEAR_WSS         7       /*        Selects: 64 Kbit/sec WSS 8-bit unsigned linear */
1022
1023 enum SLIC_STATES {
1024         PLD_SLIC_STATE_OC = 0,
1025         PLD_SLIC_STATE_RINGING,
1026         PLD_SLIC_STATE_ACTIVE,
1027         PLD_SLIC_STATE_OHT,
1028         PLD_SLIC_STATE_TIPOPEN,
1029         PLD_SLIC_STATE_STANDBY,
1030         PLD_SLIC_STATE_APR,
1031         PLD_SLIC_STATE_OHTPR
1032 };
1033
1034 enum SCI_CONTROL {
1035         SCI_End = 0,
1036         SCI_Enable_DAA,
1037         SCI_Enable_Mixer,
1038         SCI_Enable_EEPROM
1039 };
1040
1041 enum Mode {
1042         T63, T53, T48, T40
1043 };
1044 enum Dir {
1045         V3_TO_V4, V4_TO_V3, V4_TO_V5, V5_TO_V4
1046 };
1047
1048 typedef struct Proc_Info_Tag {
1049         enum Mode convert_mode;
1050         enum Dir convert_dir;
1051         int Prev_Frame_Type;
1052         int Current_Frame_Type;
1053 } Proc_Info_Type;
1054
1055 enum PREVAL {
1056         NORMAL = 0,
1057         NOPOST,
1058         POSTONLY,
1059         PREERROR
1060 };
1061
1062 enum IXJ_EXTENSIONS {
1063         G729LOADER = 0,
1064         TS85LOADER,
1065         PRE_READ,
1066         POST_READ,
1067         PRE_WRITE,
1068         POST_WRITE,
1069         PRE_IOCTL,
1070         POST_IOCTL
1071 };
1072
1073 typedef struct {
1074         char enable;
1075         char en_filter;
1076         unsigned int filter;
1077         unsigned int state;     /* State 0 when cadence has not started. */
1078
1079         unsigned int on1;       /* State 1 */
1080
1081         unsigned long on1min;   /* State 1 - 10% + jiffies */
1082         unsigned long on1dot;   /* State 1 + jiffies */
1083
1084         unsigned long on1max;   /* State 1 + 10% + jiffies */
1085
1086         unsigned int off1;      /* State 2 */
1087
1088         unsigned long off1min;
1089         unsigned long off1dot;  /* State 2 + jiffies */
1090         unsigned long off1max;
1091         unsigned int on2;       /* State 3 */
1092
1093         unsigned long on2min;
1094         unsigned long on2dot;
1095         unsigned long on2max;
1096         unsigned int off2;      /* State 4 */
1097
1098         unsigned long off2min;
1099         unsigned long off2dot;  /* State 4 + jiffies */
1100         unsigned long off2max;
1101         unsigned int on3;       /* State 5 */
1102
1103         unsigned long on3min;
1104         unsigned long on3dot;
1105         unsigned long on3max;
1106         unsigned int off3;      /* State 6 */
1107
1108         unsigned long off3min;
1109         unsigned long off3dot;  /* State 6 + jiffies */
1110         unsigned long off3max;
1111 } IXJ_CADENCE_F;
1112
1113 typedef struct {
1114         unsigned int busytone:1;
1115         unsigned int dialtone:1;
1116         unsigned int ringback:1;
1117         unsigned int ringing:1;
1118         unsigned int playing:1;
1119         unsigned int recording:1;
1120         unsigned int cringing:1;
1121         unsigned int play_first_frame:1;
1122         unsigned int pstn_present:1;
1123         unsigned int pstn_ringing:1;
1124         unsigned int pots_correct:1;
1125         unsigned int pots_pstn:1;
1126         unsigned int g729_loaded:1;
1127         unsigned int ts85_loaded:1;
1128         unsigned int dtmf_oob:1;        /* DTMF Out-Of-Band */
1129
1130         unsigned int pcmciascp:1;       /* SmartCABLE Present */
1131
1132         unsigned int pcmciasct:2;       /* SmartCABLE Type */
1133
1134         unsigned int pcmciastate:3;     /* SmartCABLE Init State */
1135
1136         unsigned int inwrite:1; /* Currently writing */
1137
1138         unsigned int inread:1;  /* Currently reading */
1139
1140         unsigned int incheck:1; /* Currently checking the SmartCABLE */
1141
1142         unsigned int cidplay:1; /* Currently playing Caller ID */
1143
1144         unsigned int cidring:1; /* This is the ring for Caller ID */
1145
1146         unsigned int cidsent:1; /* Caller ID has been sent */
1147
1148         unsigned int cidcw_ack:1; /* Caller ID CW ACK (from CPE) */
1149         unsigned int firstring:1; /* First ring cadence is complete */
1150         unsigned int pstncheck:1;       /* Currently checking the PSTN Line */
1151         unsigned int pstn_rmr:1;
1152         unsigned int x:3;       /* unsed bits */
1153
1154 } IXJ_FLAGS;
1155
1156 /******************************************************************************
1157 *
1158 *  This structure holds the state of all of the Quicknet cards
1159 *
1160 ******************************************************************************/
1161
1162 typedef struct {
1163         int elements_used;
1164         IXJ_CADENCE_TERM termination;
1165         IXJ_CADENCE_ELEMENT *ce;
1166 } ixj_cadence;
1167
1168 typedef struct {
1169         struct phone_device p;
1170         struct timer_list timer;
1171         unsigned int board;
1172         unsigned int DSPbase;
1173         unsigned int XILINXbase;
1174         unsigned int serial;
1175         atomic_t DSPWrite;
1176         struct phone_capability caplist[30];
1177         unsigned int caps;
1178         struct pnp_dev *dev;
1179         unsigned int cardtype;
1180         unsigned int rec_codec;
1181         unsigned int cid_rec_codec;
1182         unsigned int cid_rec_volume;
1183         unsigned char cid_rec_flag;
1184         signed char rec_mode;
1185         unsigned int play_codec;
1186         unsigned int cid_play_codec;
1187         unsigned int cid_play_volume;
1188         unsigned char cid_play_flag;
1189         signed char play_mode;
1190         IXJ_FLAGS flags;
1191         unsigned long busyflags;
1192         unsigned int rec_frame_size;
1193         unsigned int play_frame_size;
1194         unsigned int cid_play_frame_size;
1195         unsigned int cid_base_frame_size;
1196         unsigned long cidcw_wait;
1197         int aec_level;
1198         int cid_play_aec_level;
1199         int readers, writers;
1200         wait_queue_head_t poll_q;
1201         wait_queue_head_t read_q;
1202         char *read_buffer, *read_buffer_end;
1203         char *read_convert_buffer;
1204         size_t read_buffer_size;
1205         unsigned int read_buffer_ready;
1206         wait_queue_head_t write_q;
1207         char *write_buffer, *write_buffer_end;
1208         char *write_convert_buffer;
1209         size_t write_buffer_size;
1210         unsigned int write_buffers_empty;
1211         unsigned long drybuffer;
1212         char *write_buffer_rp, *write_buffer_wp;
1213         char dtmfbuffer[80];
1214         char dtmf_current;
1215         int dtmf_wp, dtmf_rp, dtmf_state, dtmf_proc;
1216         int tone_off_time, tone_on_time;
1217         struct fasync_struct *async_queue;
1218         unsigned long tone_start_jif;
1219         char tone_index;
1220         char tone_state;
1221         char maxrings;
1222         ixj_cadence *cadence_t;
1223         ixj_cadence *cadence_r;
1224         int tone_cadence_state;
1225         IXJ_CADENCE_F cadence_f[6];
1226         DTMF dtmf;
1227         CPTF cptf;
1228         BYTES dsp;
1229         BYTES ver;
1230         BYTES scr;
1231         BYTES ssr;
1232         BYTES baseframe;
1233         HSR hsr;
1234         GPIO gpio;
1235         PLD_SCRR pld_scrr;
1236         PLD_SCRW pld_scrw;
1237         PLD_SLICW pld_slicw;
1238         PLD_SLICR pld_slicr;
1239         PLD_CLOCK pld_clock;
1240         PCMCIA_CR1 pccr1;
1241         PCMCIA_CR2 pccr2;
1242         PCMCIA_SCCR psccr;
1243         PCMCIA_SLIC pslic;
1244         char pscdd;
1245         Si3C1 sic1;
1246         Si3C2 sic2;
1247         Si3RXG sirxg;
1248         Si3ADC siadc;
1249         Si3DAC sidac;
1250         Si3STAT sistat;
1251         Si3AATT siaatt;
1252         MIX mix;
1253         unsigned short ring_cadence;
1254         int ring_cadence_t;
1255         unsigned long ring_cadence_jif;
1256         unsigned long checkwait;
1257         int intercom;
1258         int m_hook;
1259         int r_hook;
1260         int p_hook;
1261         char pstn_envelope;
1262         char pstn_cid_intr;
1263         unsigned char fskz;
1264         unsigned char fskphase;
1265         unsigned char fskcnt;
1266         unsigned int cidsize;
1267         unsigned int cidcnt;
1268         unsigned long pstn_cid_received;
1269         PHONE_CID cid;
1270         PHONE_CID cid_send;
1271         unsigned long pstn_ring_int;
1272         unsigned long pstn_ring_start;
1273         unsigned long pstn_ring_stop;
1274         unsigned long pstn_winkstart;
1275         unsigned long pstn_last_rmr;
1276         unsigned long pstn_prev_rmr;
1277         unsigned long pots_winkstart;
1278         unsigned int winktime;
1279         unsigned long flash_end;
1280         char port;
1281         char hookstate;
1282         union telephony_exception ex;
1283         union telephony_exception ex_sig;
1284         int ixj_signals[35];
1285         IXJ_SIGDEF sigdef;
1286         char daa_mode;
1287         char daa_country;
1288         unsigned long pstn_sleeptil;
1289         DAA_REGS m_DAAShadowRegs;
1290         Proc_Info_Type Info_read;
1291         Proc_Info_Type Info_write;
1292         unsigned short frame_count;
1293         unsigned int filter_hist[4];
1294         unsigned char filter_en[6];
1295         unsigned short proc_load;
1296         unsigned long framesread;
1297         unsigned long frameswritten;
1298         unsigned long read_wait;
1299         unsigned long write_wait;
1300         unsigned long timerchecks;
1301         unsigned long txreadycheck;
1302         unsigned long rxreadycheck;
1303         unsigned long statuswait;
1304         unsigned long statuswaitfail;
1305         unsigned long pcontrolwait;
1306         unsigned long pcontrolwaitfail;
1307         unsigned long iscontrolready;
1308         unsigned long iscontrolreadyfail;
1309         unsigned long pstnstatecheck;
1310 #ifdef IXJ_DYN_ALLOC
1311         short *fskdata;
1312 #else
1313         short fskdata[8000];
1314 #endif
1315         int fsksize;
1316         int fskdcnt;
1317 } IXJ;
1318
1319 typedef int (*IXJ_REGFUNC) (IXJ * j, unsigned long arg);
1320
1321 extern IXJ *ixj_pcmcia_probe(unsigned long, unsigned long);
1322