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