blob: 7f68611775d78c2e8570d345dc20c9d950befaa7 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001/*****************************************************************************
2* Copyright Statement:
3* --------------------
4* This software is protected by Copyright and the information contained
5* herein is confidential. The software may not be copied and the information
6* contained herein may not be used or disclosed except with the written
7* permission of MediaTek Inc. (C) 2010
8*
9* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
10* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
11* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
12* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
13* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
14* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
15* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
16* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
17* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
18* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
19* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
20* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
21*
22* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
23* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
24* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
25* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
26* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
27*
28* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
29* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
30* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
31* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
32* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
33*
34*****************************************************************************/
35
36/*****************************************************************************
37 *
38 * Filename:
39 * ---------
40 * dcl_bmt.h
41 *
42 * Project:
43 * --------
44 * Maui
45 *
46 * Description:
47 * ------------
48 * Header file of DCL (Driver Common Layer) for BMT.
49 *
50 * Author:
51 * -------
52 * -------
53 *
54 *============================================================================
55 * HISTORY
56 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
57 *------------------------------------------------------------------------------
58 * removed!
59 * removed!
60 * removed!
61 *
62 * removed!
63 * removed!
64 * removed!
65 *
66 * removed!
67 * removed!
68 * removed!
69 *
70 * removed!
71 * removed!
72 * removed!
73 *
74 * removed!
75 * removed!
76 * removed!
77 *
78 * removed!
79 * removed!
80 * removed!
81 *
82 * removed!
83 * removed!
84 * removed!
85 *
86 * removed!
87 * removed!
88 * removed!
89 *
90 * removed!
91 * removed!
92 * removed!
93 *
94 * removed!
95 *
96 *------------------------------------------------------------------------------
97 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
98 *============================================================================
99 ****************************************************************************/
100
101#ifdef DCL_DEFINITION_STRUCT
102#ifndef __DCL_BMT_H_STRUCT__
103#define __DCL_BMT_H_STRUCT__
104
105/*******************************************************************************
106 * DCL_OPTIONS for BMT
107 *******************************************************************************/
108#define BMT_OPTIONS
109
110/*******************************************************************************
111 * DCL_CONFIGURE_T for BMT
112 *******************************************************************************/
113#define BMT_CONFIGS
114
115/*******************************************************************************
116 * DCL_EVENT for BMT
117 *******************************************************************************/
118#define BMT_EVENTS
119
120/*******************************************************************************
121 * DCL_CTRL_CMD for BMT
122 *******************************************************************************/
123#ifdef __BUILD_DOM__
124/* The BMT Command Values in DCL_CTRL_CMD_T Enum of dcl.h */
125typedef enum {
126 BMT_CMD_CALLSTATE, /* To Set BMT Call State */
127 BMT_CMD_CHARGE, /* To Enable/Disable Charge */
128 BMT_CMD_GET_CUSTOMIZED_PARA, /* To Get Customized Parameters */
129 BMT_CMD_SET_EXT_CHARGER, /* To Set External Charger */
130 BMT_CMD_INITIALIZE, /* To Initialize BMT Module */
131 BMT_CMD_IS_BAT_ON, /* To Check If Battery Exist or Not */
132 BMT_CMD_SENDMES2UEM, /* To Send Message to UEM via BMT */
133 BMT_CMD_SET_CHR_STATUS, /* To Set Charger Status */
134 BMT_CMD_VBATINHISR, /* To Save The Battery Voltage in HISR */
135 BMT_CMD_WDT_INIT, /
136} DCL_CTRL_CMD_T;
137#else /* __BUILD_DOM__ */
138#define BMT_CMDS \
139 BMT_CMD_CALLSTATE, \
140 BMT_CMD_CHARGE, \
141 BMT_CMD_GET_CUSTOMIZED_PARA, \
142 BMT_CMD_SET_EXT_CHARGER, \
143 BMT_CMD_INITIALIZE, \
144 BMT_CMD_IS_BAT_ON, \
145 BMT_CMD_SENDMES2UEM, \
146 BMT_CMD_SET_CHR_STATUS, \
147 BMT_CMD_VBATINHISR, \
148 BMT_CMD_WDT_INIT,
149#endif /* __BUILD_DOM__ */
150
151/*******************************************************************************
152 * DCL_CTRL_DATA_T: Define the Control data structure for each module's command
153 *******************************************************************************/
154
155/* For BMT_CMD_CALLSTATE command. */
156typedef struct
157{
158 DCL_UINT8 call_state; /* Input : Phone State */
159}BMT_CTRL_CALLSTATE_T;
160
161/* For BMT_CMD_CHARGE command. */
162typedef struct
163{
164 DCL_BOOLEAN bEnable; /* Input : Enable/Disable Charge */
165}BMT_CTRL_CHARGE_T;
166
167/* Enum for Get Commands of Charge Parameter. */
168typedef enum
169{
170 DCL_GET_BATTERY_TYPE, /* Get Bettery Type */
171 DCL_GET_CHECK_BATTERY, /* Get Check Battery Configuration */
172 DCL_GET_CHECK_CHARGER_VOLTAGE, /* Get Check Charger Voltage Configuration */
173 DCL_GET_CHECK_BATT_TEMP, /* Get Check Battery Temperature Configuration */
174 DCL_GET_MAX_VBAT_LI /* Get Max Voltage of Li Battery */
175}DCL_GET_CUSTOM_CHR_PARA;
176
177/* For BMT_CMD_GET_CUSTOMIZED_PARA command. */
178typedef struct
179{
180 DCL_UINT32 u4ChargingParameter; /* Output : Result of Charge Parameter */
181 DCL_GET_CUSTOM_CHR_PARA eGetParaCmd; /* Input : Get Command of Charge Parameter */
182}BMT_CTRL_GET_CUSTOMIZED_PARA_T;
183
184/* Enum for Commands of External Charger. */
185typedef enum
186{
187 DCL_BMT_EXT_CHR_DRV_INIT = 0, /* Called at Driver Init Phase */
188 DCL_BMT_EXT_CHR_ENABLE_INTR, /* Called at PMIC Adpt Layer Init Phase */
189 DCL_BMT_EXT_CHR_CHARGE_ENABLE, /* Control Charge Enable/Disable */
190 DCL_BMT_EXT_CHR_SET_CHARGE_CURRENT, /* Set Charge Current */
191 DCL_BMT_EXT_CHR_GET_CHR_FAC_MEASURE_SUPPORT, /* Whether the External Charger Can Measure the Passed-in Charging Factor */
192 DCL_BMT_EXT_CHR_GET_CHR_FAC_CHECK_SUPPORT, /* Whether the External Charger Can Check the Passed-in Charging Factor */
193 DCL_BMT_EXT_CHR_CHECK_CHR_STATUS, /* Charger Device Can Calculate the Charger Status Through the Passed-in Information */
194 DCL_BMT_EXT_CHR_GET_CHR_STATUS, /* Return calculated charger status */
195 DCL_BMT_EXT_CHR_GET_VBAT, /* Get VBAT */
196 DCL_BMT_EXT_CHR_GET_ISENSE, /* Get ISENSE */
197 DCL_BMT_EXT_CHR_GET_VCHARGER, /* Get VCHARGER */
198 DCL_BMT_EXT_CHR_GET_BAT_TEMP, /* Get Battery Temperature */
199 DCL_BMT_EXT_CHR_GET_CHARGE_FULL, /* Return If Charge Full */
200 DCL_BMT_EXT_CHR_GET_CHARGE_UNDER_EXTREMETMP, /* Return If It's Under Extreme Temperature */
201 DCL_BMT_EXT_CHR_GET_CHARGE_EXTREMETMP_FULL, /* Return If Charge Full When Under Extreme Temperature */
202 DCL_BMT_EXT_CHR_GET_CHARGE_EXTREMETMP_RECHARGE, /* Return If Charge Should Recharge When Under Extreme Temperature */
203 DCL_BMT_EXT_CHR_GET_CHARGE_HOLD, /* Return If It's Need to Hold Charging */
204 DCL_BMT_EXT_CHR_GET_CHR_BATT_STATE_TRANSIT_SUPPORT, /* Whether the External Charger Can Handle the Specific Charging Battery State */
205 DCL_BMT_EXT_CHR_CHR_BATT_STATE_TRANSIT, /* Perform Charging Battery State Transit */
206 DCL_BMT_EXT_CHR_GET_CURR_CHR_BATT_STATE, /* Get Current Charging Battery State */
207 DCL_BMT_EXT_CHR_GET_SPECIFIC_CHR_CURRENT, /* Get Custom Charge Current According to Specific Charger */
208 DCL_BMT_EXT_CHR_GET_VBAT_SPECIFIC_FULL_VOLTAGE_STATE /* Whether the VBAT is Higher Than Specific Full Check Vaule or Not */
209}DCL_BMT_EXT_CHR_CMD;
210
211/* For BMT_CMD_SET_EXT_CHARGER command. */
212typedef struct
213{
214 DCL_BMT_EXT_CHR_CMD eExtChargerCtrl; /* Input : Command of External Charger */
215}BMT_CTRL_SET_EXT_CHARGER_T;
216
217/* For BMT_CMD_IS_BAT_ON command. */
218typedef struct
219{
220 DCL_BOOLEAN fgBatIsOn; /* Output : Battery Exist or Not */
221}BMT_CTRL_IS_BAT_ON_T;
222
223/* Enum for BMT to UEM Messages. */
224typedef enum
225{
226 DCL_BMT_CHARGER_IN = 0, /* Charger In */
227 DCL_BMT_CHARGER_OUT, /* Charger Out */
228 DCL_BMT_OVERVOLPROTECT, /* Battery Over Voltage Protect */
229 DCL_BMT_OVERBATTEMP, /* Battery Over Temperature */
230 DCL_BMT_LOWBATTEMP, /* Battery Low Temperature */
231 DCL_BMT_OVERCHARGECURRENT, /* Over Charger Current */
232 DCL_BMT_CHARGE_COMPLETE, /* Charge Complete */
233 DCL_BMT_INVALID_BAT, /* Invalid Battery */
234 DCL_BMT_INVALID_CHARGER, /* Invalid Charger */
235 DCL_BMT_CHARGE_TIMEOUT, /* Charge Time Out */
236 DCL_BMT_LOWCHARGECURRENT, /* Low Charger Current */
237 DCL_BMT_CHARGE_BAD_CONTACT, /* Charger Bat Contact */
238 DCL_BMT_BATTERY_BAD_CONTACT, /* Battery Bad Contact */
239 DCL_BMT_USB_CHARGER_IN, /* USB Charger In */
240 DCL_BMT_USB_CHARGER_OUT, /* USB Charger Out */
241 DCL_BMT_USB_NO_CHARGING_IN, /* USB No Charger In */
242 DCL_BMT_USB_NO_CHARGING_OUT, /* USB No Charger Out */
243 DCL_BMT_BATT_IN, /* Battery In */
244 DCL_BMT_BATT_OUT /* Battery Out */
245}DCL_BMT_CHR_MSG;
246
247/* For BMT_CMD_SENDMES2UEM command. */
248typedef struct
249{
250 DCL_BMT_CHR_MSG ChargerMsg; /* Input : BMT to UEM Message */
251}BMT_CTRL_SENDMES2UEM_T;
252
253/* Enum for Charger Status. */
254typedef enum {
255 DCL_BMT_CHR_IN = 0, /* Charger In */
256 DCL_BMT_CHR_OUT, /* Charger Out */
257 DCL_BMT_CHR_UNINIT = 0xff /* Charger Uninitialized */
258}DCL_BMT_CHR_STAT;
259
260/* For BMT_CMD_SET_CHR_STATUS command. */
261typedef struct
262{
263 DCL_BMT_CHR_STAT ChargerStat; /* Input : Charger State */
264}BMT_CTRL_SET_CHR_STATUS_T;
265
266/* For BMT_CMD_VBATINHISR command. */
267// BMT_CMD_VBATINHISR does NOT need parameters
268
269#ifdef __BUILD_DOM__
270/* The BMT Command Parameter Data Structure for Each Command in DCL_CTRL_DATA_T Enum of dcl.h */
271typedef struct
272{
273 BMT_CTRL_CALLSTATE_T rCallState; /* Data Structure for BMT_CMD_CALLSTATE */
274 BMT_CTRL_CHARGE_T rChargeControl; /* Data Structure for BMT_CMD_CHARGE */
275 BMT_CTRL_GET_CUSTOMIZED_PARA_T rGetCustomizedPara; /* Data Structure for BMT_CMD_GET_CUSTOMIZED_PARA */
276 BMT_CTRL_SET_EXT_CHARGER_T rSetExtChr; /* Data Structure for BMT_CMD_SET_EXT_CHARGER */
277 BMT_CTRL_IS_BAT_ON_T rIsBatOn; /* Data Structure for BMT_CMD_IS_BAT_ON */
278 BMT_CTRL_SENDMES2UEM_T rSendMes2Uem; /* Data Structure for BMT_CMD_SENDMES2UEM */
279 BMT_CTRL_SET_CHR_STATUS_T rSetChrStatus; /* Data Structure for BMT_CMD_SET_CHR_STATUS */
280}DCL_CTRL_DATA_T;
281#else /* __BUILD_DOM__ */
282#define BMT_CTRLS \
283 BMT_CTRL_CALLSTATE_T rCallState; \
284 BMT_CTRL_CHARGE_T rChargeControl; \
285 BMT_CTRL_GET_CUSTOMIZED_PARA_T rGetCustomizedPara; \
286 BMT_CTRL_SET_EXT_CHARGER_T rSetExtChr; \
287 BMT_CTRL_IS_BAT_ON_T rIsBatOn; \
288 BMT_CTRL_SENDMES2UEM_T rSendMes2Uem; \
289 BMT_CTRL_SET_CHR_STATUS_T rSetChrStatus;
290#endif /* __BUILD_DOM__ */
291
292#endif // #ifndef __DCL_BMT_H_STRUCT__
293#endif // #ifdef DCL_DEFINITION_STRUCT
294
295
296#ifdef DCL_DEFINITION_PROTOTYPE
297#ifndef __DCL_BMT_H_PROTOTYPE__
298#define __DCL_BMT_H_PROTOTYPE__
299
300/*************************************************************************
301* FUNCTION
302* DclBMT_Initialize
303*
304* DESCRIPTION
305* This function is to initialize BMT module
306*
307* PARAMETERS
308* None
309*
310* RETURNS
311* Return the status of DclBMT_Initialize
312*
313* RETURN VALUES
314* STATUS_OK: Initialize Finished
315*
316*************************************************************************/
317extern DCL_STATUS DclBMT_Initialize(void);
318/*************************************************************************
319* FUNCTION
320* DclBMT_Open
321*
322* DESCRIPTION
323* This function is to open the BMT module and return a handle
324*
325* PARAMETERS
326* dev: [IN] Only valid for DCL_BMT
327* flags: [IN] No sepcial flags is needed. Please use FLAGS_NONE
328*
329* RETURNS
330* Return DCL_HANDLE of BMT
331*
332* RETURN VALUES
333* DCL_HANDLE_INVALID : Open failed
334* Other value : A valid handle
335*
336*************************************************************************/
337extern DCL_HANDLE DclBMT_Open(DCL_DEV dev, DCL_FLAGS flags);
338/*************************************************************************
339* FUNCTION
340* DclBMT_ReadData
341*
342* DESCRIPTION
343* This function is not supported for the BMT module now.
344*
345* PARAMETERS
346* N/A
347*
348* RETURNS
349* STATUS_UNSUPPORTED
350*
351*************************************************************************/
352extern DCL_STATUS DclBMT_ReadData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN *buf_len, DCL_OPTIONS options);
353/*************************************************************************
354* FUNCTION
355* DclBMT_WriteData
356*
357* DESCRIPTION
358* This function is not supported for the BMT module now.
359*
360* PARAMETERS
361* N/A
362*
363* RETURNS
364* STATUS_UNSUPPORTED
365*
366*************************************************************************/
367extern DCL_STATUS DclBMT_WriteData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN *buf_len, DCL_OPTIONS options);
368/*************************************************************************
369* FUNCTION
370* DclBMT_Configure
371*
372* DESCRIPTION
373* This function is not supported for the BMT module now.
374*
375* PARAMETERS
376* N/A
377*
378* RETURNS
379* STATUS_UNSUPPORTED
380*
381*************************************************************************/
382extern DCL_STATUS DclBMT_Configure(DCL_HANDLE handle, DCL_CONFIGURE_T *configure);
383/*************************************************************************
384* FUNCTION
385* DclBMT_RegisterCallback
386*
387* DESCRIPTION
388* This function is not supported for the BMT module now.
389*
390* PARAMETERS
391* N/A
392*
393* RETURNS
394* STATUS_UNSUPPORTED
395*
396*************************************************************************/
397extern DCL_STATUS DclBMT_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event, PFN_DCL_CALLBACK callback);
398/*************************************************************************
399* FUNCTION
400* DclBMT_Control
401*
402* DESCRIPTION
403* This function is to send command to control the BMT module.
404*
405* PARAMETERS
406* handle: [IN] The handle value returned from DclBMT_Open
407* cmd: [IN] A control command for BMT module
408* 1. BMT_CMD_CALLSTATE: to nodify talk/idle state to BMT task
409* 2. BMT_CMD_CHARGE: to enable/disble charge
410* 3. BMT_CMD_GET_CUSTOMIZED_PARA: to get customized charge parameters
411* 4. BMT_CMD_SET_EXT_CHARGER: to control the external charger
412* 5. BMT_CMD_INITIALIZE: to initialize BMT Module
413* 6. BMT_CMD_IS_BAT_ON: to check is battery exist or not
414* 7. BMT_CMD_SENDMES2UEM: to send message from BMT to UEM
415* 8. BMT_CMD_SET_CHR_STATUS: to set charger status
416* 9. BMT_CMD_VBATINHISR: to save the Battery voltage in HISR
417*
418* data: [IN] The data of the control command
419* 1. BMT_CMD_CALLSTATE: pointer to a BMT_CTRL_CALLSTATE_T structure
420* 2. BMT_CMD_CHARGE: pointer to a BMT_CTRL_CHARGE_T structure
421* 3. BMT_CMD_GET_CUSTOMIZED_PARA: pointer to a BMT_CTRL_GET_CUSTOMIZED_PARA_T structure
422* 4. BMT_CMD_SET_EXT_CHARGER: pointer to a BMT_CTRL_SET_EXT_CHARGER_T structure
423* 5. BMT_CMD_INITIALIZE: A null pointer
424* 6. BMT_CMD_IS_BAT_ON: pointer to a BMT_CTRL_IS_BAT_ON_T structure
425* 7. BMT_CMD_SENDMES2UEM: pointer to a BMT_CTRL_SENDMES2UEM_T structure
426* 8. BMT_CMD_SET_CHR_STATUS: pointer to a BMT_CTRL_SET_CHR_STATUS_T structure
427* 9. BMT_CMD_VBATINHISR: A null pointer
428*
429* RETURNS
430* Return the status of DclBMT_Control
431*
432* RETURN VALUES
433* STATUS_OK: Command is executed successfully.
434* STATUS_FAIL: Command is failed.
435* STATUS_INVALID_CMD: It's a invalid command.
436*
437*************************************************************************/
438extern DCL_STATUS DclBMT_Control(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data);
439/*************************************************************************
440* FUNCTION
441* DclBMT_Close
442*
443* DESCRIPTION
444* This function is to close the BMT module.
445*
446* PARAMETERS
447* handle: [IN] The returned handle value of DclBMT_Open
448*
449* RETURNS
450* Return the status of DclBMT_Close
451*
452* RETURN VALUES
453* STATUS_OK
454*
455*************************************************************************/
456extern DCL_STATUS DclBMT_Close(DCL_HANDLE handle);
457
458
459#endif // #ifndef __DCL_BMT_H_PROTOTYPE__
460#endif // #ifdef DCL_DEFINITION_PROTOTYPE
461