dcl_pw.h
14.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* dcl_pw.h
*
* Project:
* --------
* Maui_Software
*
* Description:
* ------------
* This file is intended for phone on/off control and power on reason
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#ifdef DCL_DEFINITION_STRUCT
#ifndef __DCL_PW_H_STRUCT__
#define __DCL_PW_H_STRUCT__
/*******************************************************************************
* DCL_OPTIONS for PMU
*******************************************************************************/
#define PW_OPTIONS
/*******************************************************************************
* DCL_CONFIGURE_T for PMU
*******************************************************************************/
#define PW_CONFIGS
/*******************************************************************************
* DCL_EVENT for PMU
*******************************************************************************/
#define PW_EVENTS
/*******************************************************************************
* DCL_CTRL_DATA_T: Define the Control data structure for each module's command
*******************************************************************************/
typedef enum{
PWRKEYPWRON = 0, /* power on reason is powerkey */
CHRPWRON = 1, /* power on reason is charger in */
RTCPWRON = 2, /* power on reason is rtc alarm */
CHRPWROFF = 3, /* reserved */
WDTRESET = 4, /* reserved */
ABNRESET = 5, /* power on reason is abnormal reboot */
USBPWRON = 6, /* power on reason is usb cable in */
USBPWRON_WDT = 7, /* power on reason is usb cable in and abnormal reboot*/
PRECHRPWRON = 8, /* power on reason is precharger power on*/
UNKNOWN_PWRON = 0xF9 /* power on reason is unknown*/
}PW_CTRL_POWER_ON_REASON;
typedef enum{
PWR_FACTOR_POWER_KEY = 0,
PWR_FACTOR_CHARGER_IN,
PWR_FACTOR_USB_IN,
PWR_FACTOR_RTC_EXPIRE,
PWR_FACTOR_WDT_RESET,
PWR_FACTOR_NORMAL_RESET_FLG,
PWR_FACTOR_CHRPWRON_FLG,
PWR_FACTOR_USBMS_PWRON_FLG,
PWR_FACTOR_RTCPWRON_FLG,
PWR_FACTOR_PRECHRPWRON_FLG,
PWR_FACTOR_SWITCH2IDLE_FLG,
PWR_FACTOR_SWITCH2CHR_FLG,
PWR_FACTOR_SWITCH2USB_FLG,
PWR_FACTOR_LONG_PRESS_SHUTDOWN,
PWR_FACTOR_MAX
}pwr_factor_enum;
typedef enum{
PWR_FACTOR_BL_POWER_KEY = 0x1,
PWR_FACTOR_BL_CABLE_IN = 0x2,
PWR_FACTOR_BL_RTC_EXPIRE = 0x4,
PWR_FACTOR_BL_NORMAL_RESET_FLG = 0x8,
PWR_FACTOR_BL_CHRPWRON_FLG = 0x10,
PWR_FACTOR_BL_USBMS_PWRON_FLG = 0x20,
PWR_FACTOR_BL_RTCPWRON_FLG = 0x40,
PWR_FACTOR_BL_FACTORY_FLG = 0x80,
PWR_FACTOR_BL_MAX
}pw_factor_bl_enum;
typedef enum{
PWR_NONE = 0x0,
PWR_AC_CHR = 0x1,
PWR_USB_CHR = 0x2,
}PWR_CTRL_CABLE_TYPE;
typedef struct
{
DCL_BOOL val; /* Output : TRUE: indicate usb plug in; FALSE: indicate not usb plug in */
} PW_CTRL_IS_USB_BOOT;
typedef struct
{
PW_CTRL_POWER_ON_REASON powerOnReason; /* Input : power on reason */
} PW_CTRL_SET_POWERON_REASON;
typedef struct
{
PW_CTRL_POWER_ON_REASON powerOnReason; /* Output : power on reason */
} PW_CTRL_GET_POWERON_REASON;
typedef struct
{
PWR_CTRL_CABLE_TYPE pw_chr_type;
} PW_CTRL_GET_CHARGER_TYPE;
/*******************************************************************************
* DCL_CTRL_DATA_T: Define the Control data structure for each module's command
*******************************************************************************/
#ifdef __BUILD_DOM__
/* The PW Command Parameter Data Structure for Each Command in DCL_CTRL_DATA_T Enum of dcl.h */
typedef struct
{
PW_CTRL_SET_POWERON_REASON rPWSetPowerOnReason; /* Data Structure for PW_CMD_SET_POWERON_REASON */
PW_CTRL_GET_POWERON_REASON rPWGetPowerOnReason; /* Data Structure for PW_CMD_GET_POWERON_REASON */
PW_CTRL_IS_USB_BOOT rPWIsUsbBoot; /* Data Structure for PW_CMD_IS_USB_BOOT */
PW_CTRL_GET_CHARGER_TYPE rPWChrType; /* Cable type for PW_CMD_GET_CABLE_BOOT_TYPE */
}DCL_CTRL_PW_DATA;
#else /* __BUILD_DOM__ */
#define PW_CTRLS \
PW_CTRL_SET_POWERON_REASON rPWSetPowerOnReason; \
PW_CTRL_GET_POWERON_REASON rPWGetPowerOnReason; \
PW_CTRL_IS_USB_BOOT rPWIsUsbBoot; \
PW_CTRL_GET_CHARGER_TYPE rPWChrType;
#endif /* __BUILD_DOM__ */
/*******************************************************************************
* DCL_CTRL_CMD for PMU
*******************************************************************************/
#ifdef __BUILD_DOM__
/* The PW Command Values in DCL_CTRL_CMD_T Enum of dcl.h */
typedef enum {
PW_CMD_POWERON, /* call RTC module to latch power and init time if necessary */
PW_CMD_POWEROFF, /* call RTC module to unlatch power */
PW_CMD_SET_POWERON_REASON, /* set power on reason */
PW_CMD_GET_POWERON_REASON, /* get power on reason */
PW_CMD_SET_SWITCH_TO_IDLE, /* set flag which force phone to enter idle mode */
PW_CMD_CLEAR_SWITCH_TO_IDLE, /* clear flag which force phone to enter idle mode */
PW_CMD_POWER_INIT, /* For check power on factors to decide power on reason and save in RTC register */
PW_CMD_UPDATE_FLAGS, /* update power on reason to rtc register */
PW_CMD_NFB_POWERON, /* call RTC module to latch power and init time if necessary (only for NAND FLASH BOOTING) */
PW_CMD_IS_USB_BOOT, /* query is power on reason USB plug in */
PW_CMD_GET_CHARGER_BOOT_TYPE, /* query which is power on reason, AC or USB or non-cable */
} DCL_CTRL_PW_CMD;
#else /* __BUILD_DOM__ */
#define PW_CMDS \
PW_CMD_POWERON, \
PW_CMD_POWEROFF, \
PW_CMD_SET_POWERON_REASON, \
PW_CMD_GET_POWERON_REASON, \
PW_CMD_SET_SWITCH_TO_IDLE, \
PW_CMD_CLEAR_SWITCH_TO_IDLE, \
PW_CMD_POWER_INIT, \
PW_CMD_UPDATE_FLAGS, \
PW_CMD_NFB_POWERON, \
PW_CMD_IS_USB_BOOT, \
PW_CMD_GET_CHARGER_BOOT_TYPE,
#endif /* __BUILD_DOM__ */
#ifndef __DRV_DEBUG_PWIC_REG_READ_WRITE__
#define PW_DRV_ClearBits16(addr, data) DRV_ClearBits(addr,data)
#define PW_DRV_SetBits16(addr, data) DRV_SetBits(addr,data)
#define PW_DRV_WriteReg16(addr, data) DRV_WriteReg(addr, data)
#define PW_DRV_WriteReg32(addr, data) DRV_WriteReg32(addr, data)
#define PW_DRV_ReadReg16(addr) DRV_Reg(addr)
#define PW_DRV_ReadReg32(addr) DRV_Reg32(addr)
#else // #ifndef __DRV_DEBUG_PWIC_REG_READ_WRITE__
#define PW_DRV_ClearBits16(addr,data) DRV_DBG_ClearBits(addr,data)
#define PW_DRV_SetBits16(addr) DRV_DBG_SetBits(addr)
#define PW_DRV_WriteReg16(addr, data) DRV_DBG_WriteReg(addr, data)
#define PW_DRV_WriteReg32(addr, data) DRV_DBG_WriteReg32(addr, data)
#define PW_DRV_ReadReg16(addr) DRV_DBG_Reg(addr)
#define PW_DRV_ReadReg32(addr) DRV_DBG_Reg32(addr)
#endif // #ifndef __DRV_DEBUG_PWIC_REG_READ_WRITE__
#endif // #ifndef __DCL_PMU_H_STRUCT__
#endif // #ifdef DCL_DEFINITION_STRUCT
#ifdef DCL_DEFINITION_PROTOTYPE
#ifndef __DCL_PW_H_PROTOTYPE__
#define __DCL_PW_H_PROTOTYPE__
/*************************************************************************
* FUNCTION
* DclPW_Initialize
*
* DESCRIPTION
* This function is to initialize PW module
*
* PARAMETERS
* None
*
* RETURNS
* STATUS_OK
*
*************************************************************************/
extern DCL_STATUS DclPW_Initialize(void);
/*************************************************************************
* FUNCTION
* DclPW_Open
*
* DESCRIPTION
* This function is to open the PW module and return a handle
*
* PARAMETERS
* dev: only valid for DCL_PW
* flags: no sepcial flags is needed. Please use FLAGS_NONE
*
* RETURNS
* DCL_HANDLE_INVALID: Open failed.
* other value: a valid handle
*
*************************************************************************/
extern DCL_HANDLE DclPW_Open(DCL_DEV dev, DCL_FLAGS flags);
/*************************************************************************
* FUNCTION
* DclPW_ReadData
*
* DESCRIPTION
* This function is not supported for the PW module now.
*
* PARAMETERS
* N/A
*
* RETURNS
* STATUS_UNSUPPORTED
*
*************************************************************************/
extern DCL_STATUS DclPW_ReadData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN buf_len, DCL_OPTIONS options);
/*************************************************************************
* FUNCTION
* DclPW_WriteData
*
* DESCRIPTION
* This function is not supported for the PW module now.
*
* PARAMETERS
* N/A
*
* RETURNS
* STATUS_UNSUPPORTED
*
*************************************************************************/
extern DCL_STATUS DclPW_WriteData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN buf_len, DCL_OPTIONS options);
/*************************************************************************
* FUNCTION
* DclPW_Configure
*
* DESCRIPTION
* This function is not supported for the PW module now.
*
* PARAMETERS
* N/A
*
* RETURNS
* STATUS_UNSUPPORTED
*
*************************************************************************/
extern DCL_STATUS DclPW_Configure(DCL_HANDLE handle, DCL_CONFIGURE_T *configure);
/*************************************************************************
* FUNCTION
* DclPW_RegisterCallback
*
* DESCRIPTION
* This function is not supported for the PW module now.
*
* PARAMETERS
* N/A
*
* RETURNS
* STATUS_UNSUPPORTED
*
*************************************************************************/
extern DCL_STATUS DclPW_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event, PFN_DCL_CALLBACK callback);
/*************************************************************************
* FUNCTION
* DclPW_Control
*
* DESCRIPTION
* This function is to send command to control the PW module.
* All command
*
* CALLS
* It is called to send command to control the PW module.
*
* PARAMETERS
* handle: [IN] The handle value returned from DclPW_Open()
* cmd: [IN] A control command for PW module
* 1. PW_CMD_POWERON: call RTC module to latch power and init time if necessary
* 2. PW_CMD_POWEROFF: call RTC module to unlatch power
* 3. PW_CMD_SET_POWERON_REASON: set power on reason
* 4. PW_CMD_GET_POWERON_REASON: get power on reason
* 5. PW_CMD_SET_SWITCH_TO_IDLE: set flag which force phone to enter idle mode
* 6. PW_CMD_CLEAR_SWITCH_TO_IDLE: clear flag which force phone to enter idle mode
* 7. PW_CMD_POWER_INIT: check power on factors to decide power on reason and save in RTC register
* 8. PW_CMD_UPDATE_FLAGS: update power on reason to rtc register
* 9. PW_CMD_NFB_POWERON: call RTC module to latch power and init time if necessary (only for NAND FLASH BOOTING)
* 10. PW_CMD_IS_USB_BOOT: query is power on reason USB plug in
*
* data: The data of the control command
* 1. PW_CMD_POWERON: A null pointer
* 2. PW_CMD_POWEROFF: A null pointer
* 3. PW_CMD_SET_POWERON_REASON: pointer to a PW_CTRL_SET_POWERON_REASON structure
* 4. PW_CMD_GET_POWERON_REASON: pointer to a PW_CTRL_GET_POWERON_REASON structure
* 5. PW_CMD_SET_SWITCH_TO_IDLE: A null pointer
* 6. PW_CMD_CLEAR_SWITCH_TO_IDLE: A null pointer
* 7. PW_CMD_POWER_INIT: A null pointer
* 8. PW_CMD_UPDATE_FLAGS: A null pointer
* 9. PW_CMD_NFB_POWERON: A null pointer
* 10. PW_CMD_IS_USB_BOOT: pointer to a PW_CTRL_IS_USB_BOOT
*
* RETURNS
* STATUS_OK: command is executed successfully.
* STATUS_FAIL: command is failed.
* STATUS_INVALID_CMD: It's a invalid command.
* STATUS_UNSUPPORTED: It's a unsupported command.
*
* GLOBALS AFFECTED
* external_global
*************************************************************************/
extern DCL_STATUS DclPW_Control(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data);
/*************************************************************************
* FUNCTION
* DclPW_Close
*
* DESCRIPTION
* This function is to close the PW module.
*
* PARAMETERS
* handle: the returned handle value of DclPW_Open
*
* RETURNS
* STATUS_OK
*
*************************************************************************/
extern DCL_STATUS DclPW_Close(DCL_HANDLE handle);
#endif // #ifndef __DCL_PW_H_PROTOTYPE__
#endif //#ifdef DCL_DEFINITION_PROTOTYPE