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