blob: 90fb20d93b97e6554f66810af8c93dc810807fee [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001#ifndef _SI_ADT_H
2#define _SI_ADT_H
3
4#include "proslic.h"
5#include "si3217x_intf.h"
6#include "proslic_mlt.h"
7#include "proslic_mlt_math.h"
8
9#define DEBUG_SLIC_ON
10
11#if 0
12/* Basic info of the Si3217x chip */
13#define NUMBER_OF_DEVICES 1
14#define NUMBER_OF_PROSLIC NUMBER_OF_DEVICES
15#define CHAN_PER_DEVICE 1
16#define NUMBER_OF_CHAN (NUMBER_OF_DEVICES*CHAN_PER_DEVICE)
17#endif
18/* Basic info of the Si3217x chip */
19#define MAX_PORT_NUM 1 /* max port num */
20
21#if 0
22#define PROSLIC_DEVICE_TYPE SI3217X
23#define PROSLIC_TG_TIMER_ENABLED 1
24#define PROSLIC_TG_TIMER_DISABLED 0
25#endif
26
27/* slic line state */
28#define N_STATES 4 /* all phone state */
29#define HOOKON 0 /* had HookOn */
30#define HOOKOFFING 1 /* HookOn turn to HookOff. no finish */
31#define HOOKOFF 2 /* had HookOff */
32#define HOOKONING 3 /* HookOff turn to HookOn. no finish */
33
34/* slic line event */
35#define EV_LOW 0 /* onhook */
36#define EV_HIGH 1 /* offhook */
37#define PULSE_FILTER_TIME 1
38#define FLASH_EV_FLG 0x80
39
40/* daa line event */
41#define EV_RING_ON 1
42#define EV_RING_OFF 0
43#define EV_DAA_HOOK_ON 0
44#define EV_DAA_HOOK_OFF 1
45
46#if 0
47#define MAX_IRQS_NUM 36
48
49#define CHIP_ZARLINK 0
50#define CHIP_SILICONLAB 1
51#endif
52
53#define MAX_RING_CNT 20
54#define MAX_TEST_TIMEOUT 6000 /* 1 Min */
55
56#if 0
57/* power manage for slic */
58#define NORMAL_POWER 0
59#define NO_BATTARY 1
60#define LOW_POWER 2
61#define SHUT_DOWN_POWER 3
62#endif
63
64/******** webÒ³ÃæÅäÖà slicµçÆø²ÎÊý ********/
65#define ELEC_HOOKON_VOLTAGE (1<<0)
66#define ELEC_LOOP_CURRENT (1<<1)
67#define ELEC_RING_VPK (1<<2)
68
69#define MAX_RING_VPK 87
70#define MIN_RING_VPK 63
71#define MAX_LOOP_CUR 33
72#define MIN_LOOP_CUR 18
73#define MAX_OPENCIRCUIT_VOL 60
74#define MIN_OPENCIRCUIT_VOL 48
75
76/*
77 Ó¦Óó¡¾°£º¶ÌÏßµ¥²¿»°»ú 0
78 ¶ÌÏ߶ಿ»°»ú²¢»ú 1
79 ³¤Ïß 2
80 ³ö³§ÅäÖÃ 3
81 ×Ô¶¨Ò峡¾° 4
82*/
83enum {
84 DB_SLC_SINGLEPHONE_SHORTLOOP = 0,
85 DB_SLC_MULTIPHONES_SHORTLOOP = 1,
86 DB_SLC_LONGLOOP = 2,
87 DB_SLC_ORIGINAL_FACTORY = 3,
88 DB_SLC_CUSTOMIZED = 4
89};
90
91typedef struct
92{
93 u8 bCusRingVpk;
94 u8 bCusDcVol;
95 u8 bCusDcLoopCurr;
96}ELECTRIC_CFG_CUSTOMIZED;
97/*************************************/
98
99#define DC_VOLTAGE_48V 48 /* 48V */
100#define DC_VOLTAGE_52V 52 /* 52V */
101
102#define DC_CURRENT_20MA 20 /* 20mA */
103#define DC_CURRENT_24MA 24 /* 24mA */
104#define DC_CURRENT_28MA 28 /* 28mA */
105#define DC_CURRENT_32MA 32 /* 32mA */
106
107#define RING_VOLTAGE_55VPK 55 /* 40vrms */
108#define RING_VOLTAGE_65VPK 65 /* 45vrms */
109#define RING_VOLTAGE_70VPK 70 /* 50vrms */
110#define RING_VOLTAGE_75VPK 75 /* 55vrms */
111#define RING_VOLTAGE_85VPK 85 /* 60vrms */
112
113
114typedef struct
115{
116 u8 flg; /* chip select */
117 u8 cs; /* chip select */
118 u8 chan; /* channel */
119 u8 port; /* logic port */
120 u8 type; /* */
121 u8 tx; /* tx tm */
122 u8 rx; /* rx tm */
123}USL_PORT_MAP;
124
125typedef struct
126{
127 /* slic config */
128 u16 hookoffmin; /* HookOn-> HookOff complete time */
129 u16 hookonmin; /* HookOff-> HookOn complete time */
130 u16 prehookoff; /* HookOn->Pre Hookoff complete time */
131
132 u16 flash_low_min; /* low electric min time for Flash check */
133 u16 flash_low_max;
134
135 u16 flash_high_fix; /* fix high electric interval len */
136
137 u16 dial_high_min; /* high electric interval min for dial check */
138 u16 dial_high_max;
139
140 u16 dial_low_min; /* low electric interval min for dial check */
141 u16 dial_low_max; /* low electric interval max for dial check */
142
143 u16 RingQueneDelay;
144} USL_CONFIG;
145
146typedef struct
147{
148 ProSLICMLTType Mlt;
149 ProSLIC_mlt_foreign_voltages_state vState;
150 ProSLIC_mlt_rmeas_state rMeas;
151 ProSLIC_mlt_capacitance_state CapState;
152 ProSLIC_mlt_ren_state RenState;
153} ProSLICMLT;
154
155typedef struct
156{
157 u8 test_flg; /* 112 test flg,if it isn't 0, it is undering line test. */
158 u8 si_item; /* 112 test item */
159 u16 cnt; /* 112 scan counter */
160 ProSLICMLT *pstMlt; /* temp value in testing */
161 TestResult_t *pstResult; /* 112 test result pointer */
162} LINE_TEST_PARA;
163
164typedef enum
165{
166 NOPTC = 0,
167 HAVEPTC = 1,
168} PTCDATA;
169
170typedef struct
171{
172 u8 bPort;
173 u8 bCusRingVpk;
174 u8 bCusDcVol;
175 u8 bCusDcLoopCurr;
176 u8 bLineOpen100msEn;
177 u8 bDisablePowerSave;
178 u32 dwImpe;
179 s32 i32Rxgain; /* from dsp to slic D-A */
180 s32 i32Txgain; /* from slic to dsp A-D */
181} SLCINF_CFG;
182
183typedef struct
184{
185 PTCDATA ePTC;
186 u32 generel_cfg;
187 u32 ring;
188 u32 dc;
189 u32 tone;
190 u32 Impe;
191 u32 meter;
192 u8 bLineOpen100msEn;
193 u8 bDisablePowerSave;
194 u8 a_u_law;
195 u8 cid;
196 u8 linestaus;
197 u8 wide;
198 u32 offset;
199 s32 rxgain; /* from dsp to slic D-A */
200 s32 txgain; /* from slic to dsp A-D */
201}SILAB_CFG_CHIP_t;
202
203typedef struct {
204 u8 hook_state; /* µ±Ç°Ïß·ժ¹Ò»ú״̬ */
205 u8 pulse_dig; /* Âö³åÊպźÅÂë»òÕßÅŲæ»É */
206 u8 bDialEn; /* Âö³åÊÕºÅʹÄÜ */
207 u32 low_len; /* ¹Ò»úʱ¼ä¼ÆÊý */
208 u32 high_len; /* Õª»úʱ¼ä¼ÆÊý */
209
210 USL_CONFIG stUslConf; /* time para */
211 SILAB_CFG_CHIP_t *pPreCfg; /* board chip cfg */
212 LINE_TEST_PARA stLineTestPara;
213 proslicChanType_ptr ProObj; /* Ö¸ÏòоƬ½á¹¹ÌåµÄÖ¸Õë */
214}Port_t;
215
216typedef enum {
217 NONE = 0,
218 RINGING = 1,
219 PLAYING_TONE = 2,
220} slic_state;
221
222
223typedef enum {
224 A_LAW_INVENT_NONE = 0,
225 U_LAW = 1,
226 LINEAR_CODEC = 2,
227} E_A_U_LAW;
228
229typedef struct {
230 ramData slope_vlim;
231 ramData slope_rfeed;
232 ramData slope_ilim;
233 ramData delta1;
234 ramData delta2;
235 ramData v_vlim;
236 ramData v_rfeed;
237 ramData v_ilim;
238 ramData const_rfeed;
239 ramData const_ilim;
240 ramData i_vlim;
241} Si3217x_Shot_DCfeed_Cfg;
242
243typedef struct {
244 ramData amp;
245 ramData rtacth;
246 ramData vbatr_expect;
247 ramData vcm_ring;
248 ramData vcm_ring_fixed;
249} Si3217x_Shot_Ring_Cfg;
250
251/* init BoardParmCfg para based boardtype */
252void SlicCfgParaBasedBoardType(void);
253
254/* init impendence cfg */
255void slic_inf_precfg(SLCINF_CFG *ptCfg);
256
257/* init the slic chip */
258int InitSlicChip(void);
259
260/* deinit the slic chip */
261void DeinitSlicChip(void);
262
263#endif /* _SI_ADT_H */