rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | /***************************************************************************** |
| 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) 2005 |
| 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_pw.h |
| 41 | * |
| 42 | * Project: |
| 43 | * -------- |
| 44 | * Maui_Software |
| 45 | * |
| 46 | * Description: |
| 47 | * ------------ |
| 48 | * This file is intended for phone on/off control and power on reason |
| 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 | * removed! |
| 96 | * removed! |
| 97 | * |
| 98 | * |
| 99 | *------------------------------------------------------------------------------ |
| 100 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 101 | *============================================================================ |
| 102 | ****************************************************************************/ |
| 103 | |
| 104 | #ifdef DCL_DEFINITION_STRUCT |
| 105 | #ifndef __DCL_PW_H_STRUCT__ |
| 106 | #define __DCL_PW_H_STRUCT__ |
| 107 | |
| 108 | |
| 109 | /******************************************************************************* |
| 110 | * DCL_OPTIONS for PMU |
| 111 | *******************************************************************************/ |
| 112 | #define PW_OPTIONS |
| 113 | |
| 114 | /******************************************************************************* |
| 115 | * DCL_CONFIGURE_T for PMU |
| 116 | *******************************************************************************/ |
| 117 | |
| 118 | #define PW_CONFIGS |
| 119 | |
| 120 | /******************************************************************************* |
| 121 | * DCL_EVENT for PMU |
| 122 | *******************************************************************************/ |
| 123 | #define PW_EVENTS |
| 124 | |
| 125 | |
| 126 | /******************************************************************************* |
| 127 | * DCL_CTRL_DATA_T: Define the Control data structure for each module's command |
| 128 | *******************************************************************************/ |
| 129 | |
| 130 | typedef enum{ |
| 131 | PWRKEYPWRON = 0, /* power on reason is powerkey */ |
| 132 | CHRPWRON = 1, /* power on reason is charger in */ |
| 133 | RTCPWRON = 2, /* power on reason is rtc alarm */ |
| 134 | CHRPWROFF = 3, /* reserved */ |
| 135 | WDTRESET = 4, /* reserved */ |
| 136 | ABNRESET = 5, /* power on reason is abnormal reboot */ |
| 137 | USBPWRON = 6, /* power on reason is usb cable in */ |
| 138 | USBPWRON_WDT = 7, /* power on reason is usb cable in and abnormal reboot*/ |
| 139 | PRECHRPWRON = 8, /* power on reason is precharger power on*/ |
| 140 | UNKNOWN_PWRON = 0xF9 /* power on reason is unknown*/ |
| 141 | }PW_CTRL_POWER_ON_REASON; |
| 142 | |
| 143 | typedef enum{ |
| 144 | PWR_FACTOR_POWER_KEY = 0, |
| 145 | PWR_FACTOR_CHARGER_IN, |
| 146 | PWR_FACTOR_USB_IN, |
| 147 | PWR_FACTOR_RTC_EXPIRE, |
| 148 | PWR_FACTOR_WDT_RESET, |
| 149 | PWR_FACTOR_NORMAL_RESET_FLG, |
| 150 | PWR_FACTOR_CHRPWRON_FLG, |
| 151 | PWR_FACTOR_USBMS_PWRON_FLG, |
| 152 | PWR_FACTOR_RTCPWRON_FLG, |
| 153 | PWR_FACTOR_PRECHRPWRON_FLG, |
| 154 | PWR_FACTOR_SWITCH2IDLE_FLG, |
| 155 | PWR_FACTOR_SWITCH2CHR_FLG, |
| 156 | PWR_FACTOR_SWITCH2USB_FLG, |
| 157 | PWR_FACTOR_MAX |
| 158 | }pwr_factor_enum; |
| 159 | |
| 160 | typedef enum{ |
| 161 | PWR_FACTOR_BL_POWER_KEY = 0x1, |
| 162 | PWR_FACTOR_BL_CABLE_IN = 0x2, |
| 163 | PWR_FACTOR_BL_RTC_EXPIRE = 0x4, |
| 164 | PWR_FACTOR_BL_NORMAL_RESET_FLG = 0x8, |
| 165 | PWR_FACTOR_BL_CHRPWRON_FLG = 0x10, |
| 166 | PWR_FACTOR_BL_USBMS_PWRON_FLG = 0x20, |
| 167 | PWR_FACTOR_BL_RTCPWRON_FLG = 0x40, |
| 168 | PWR_FACTOR_BL_FACTORY_FLG = 0x80, |
| 169 | PWR_FACTOR_BL_MAX |
| 170 | }pw_factor_bl_enum; |
| 171 | |
| 172 | typedef struct |
| 173 | { |
| 174 | DCL_BOOL val; /* Output : TRUE: indicate usb plug in; FALSE: indicate not usb plug in */ |
| 175 | } PW_CTRL_IS_USB_BOOT; |
| 176 | |
| 177 | typedef struct |
| 178 | { |
| 179 | PW_CTRL_POWER_ON_REASON powerOnReason; /* Input : power on reason */ |
| 180 | } PW_CTRL_SET_POWERON_REASON; |
| 181 | |
| 182 | typedef struct |
| 183 | { |
| 184 | PW_CTRL_POWER_ON_REASON powerOnReason; /* Output : power on reason */ |
| 185 | } PW_CTRL_GET_POWERON_REASON; |
| 186 | |
| 187 | /******************************************************************************* |
| 188 | * DCL_CTRL_DATA_T: Define the Control data structure for each module's command |
| 189 | *******************************************************************************/ |
| 190 | #ifdef __BUILD_DOM__ |
| 191 | /* The PW Command Parameter Data Structure for Each Command in DCL_CTRL_DATA_T Enum of dcl.h */ |
| 192 | typedef struct |
| 193 | { |
| 194 | PW_CTRL_SET_POWERON_REASON rPWSetPowerOnReason; /* Data Structure for PW_CMD_SET_POWERON_REASON */ |
| 195 | PW_CTRL_GET_POWERON_REASON rPWGetPowerOnReason; /* Data Structure for PW_CMD_GET_POWERON_REASON */ |
| 196 | PW_CTRL_IS_USB_BOOT rPWIsUsbBoot; /* Data Structure for PW_CMD_IS_USB_BOOT */ |
| 197 | }DCL_CTRL_PW_DATA; |
| 198 | #else /* __BUILD_DOM__ */ |
| 199 | #define PW_CTRLS \ |
| 200 | PW_CTRL_SET_POWERON_REASON rPWSetPowerOnReason; \ |
| 201 | PW_CTRL_GET_POWERON_REASON rPWGetPowerOnReason; \ |
| 202 | PW_CTRL_IS_USB_BOOT rPWIsUsbBoot; |
| 203 | #endif /* __BUILD_DOM__ */ |
| 204 | |
| 205 | |
| 206 | /******************************************************************************* |
| 207 | * DCL_CTRL_CMD for PMU |
| 208 | *******************************************************************************/ |
| 209 | #ifdef __BUILD_DOM__ |
| 210 | /* The PW Command Values in DCL_CTRL_CMD_T Enum of dcl.h */ |
| 211 | typedef enum { |
| 212 | PW_CMD_POWERON, /* call RTC module to latch power and init time if necessary */ |
| 213 | PW_CMD_POWEROFF, /* call RTC module to unlatch power */ |
| 214 | PW_CMD_SET_POWERON_REASON, /* set power on reason */ |
| 215 | PW_CMD_GET_POWERON_REASON, /* get power on reason */ |
| 216 | PW_CMD_SET_SWITCH_TO_IDLE, /* set flag which force phone to enter idle mode */ |
| 217 | PW_CMD_CLEAR_SWITCH_TO_IDLE, /* clear flag which force phone to enter idle mode */ |
| 218 | PW_CMD_POWER_INIT, /* For check power on factors to decide power on reason and save in RTC register */ |
| 219 | PW_CMD_UPDATE_FLAGS, /* update power on reason to rtc register */ |
| 220 | PW_CMD_NFB_POWERON, /* call RTC module to latch power and init time if necessary (only for NAND FLASH BOOTING) */ |
| 221 | PW_CMD_IS_USB_BOOT, /* query is power on reason USB plug in */ |
| 222 | } DCL_CTRL_PW_CMD; |
| 223 | #else /* __BUILD_DOM__ */ |
| 224 | #define PW_CMDS \ |
| 225 | PW_CMD_POWERON, \ |
| 226 | PW_CMD_POWEROFF, \ |
| 227 | PW_CMD_SET_POWERON_REASON, \ |
| 228 | PW_CMD_GET_POWERON_REASON, \ |
| 229 | PW_CMD_SET_SWITCH_TO_IDLE, \ |
| 230 | PW_CMD_CLEAR_SWITCH_TO_IDLE, \ |
| 231 | PW_CMD_POWER_INIT, \ |
| 232 | PW_CMD_UPDATE_FLAGS, \ |
| 233 | PW_CMD_NFB_POWERON, \ |
| 234 | PW_CMD_IS_USB_BOOT, |
| 235 | #endif /* __BUILD_DOM__ */ |
| 236 | |
| 237 | #ifndef __DRV_DEBUG_PWIC_REG_READ_WRITE__ |
| 238 | #define PW_DRV_ClearBits16(addr, data) DRV_ClearBits(addr,data) |
| 239 | #define PW_DRV_SetBits16(addr, data) DRV_SetBits(addr,data) |
| 240 | #define PW_DRV_WriteReg16(addr, data) DRV_WriteReg(addr, data) |
| 241 | #define PW_DRV_WriteReg32(addr, data) DRV_WriteReg32(addr, data) |
| 242 | #define PW_DRV_ReadReg16(addr) DRV_Reg(addr) |
| 243 | #define PW_DRV_ReadReg32(addr) DRV_Reg32(addr) |
| 244 | #else // #ifndef __DRV_DEBUG_PWIC_REG_READ_WRITE__ |
| 245 | #define PW_DRV_ClearBits16(addr,data) DRV_DBG_ClearBits(addr,data) |
| 246 | #define PW_DRV_SetBits16(addr) DRV_DBG_SetBits(addr) |
| 247 | #define PW_DRV_WriteReg16(addr, data) DRV_DBG_WriteReg(addr, data) |
| 248 | #define PW_DRV_WriteReg32(addr, data) DRV_DBG_WriteReg32(addr, data) |
| 249 | #define PW_DRV_ReadReg16(addr) DRV_DBG_Reg(addr) |
| 250 | #define PW_DRV_ReadReg32(addr) DRV_DBG_Reg32(addr) |
| 251 | #endif // #ifndef __DRV_DEBUG_PWIC_REG_READ_WRITE__ |
| 252 | |
| 253 | |
| 254 | #endif // #ifndef __DCL_PMU_H_STRUCT__ |
| 255 | #endif // #ifdef DCL_DEFINITION_STRUCT |
| 256 | |
| 257 | |
| 258 | #ifdef DCL_DEFINITION_PROTOTYPE |
| 259 | #ifndef __DCL_PW_H_PROTOTYPE__ |
| 260 | #define __DCL_PW_H_PROTOTYPE__ |
| 261 | |
| 262 | |
| 263 | |
| 264 | /************************************************************************* |
| 265 | * FUNCTION |
| 266 | * DclPW_Initialize |
| 267 | * |
| 268 | * DESCRIPTION |
| 269 | * This function is to initialize PW module |
| 270 | * |
| 271 | * PARAMETERS |
| 272 | * None |
| 273 | * |
| 274 | * RETURNS |
| 275 | * STATUS_OK |
| 276 | * |
| 277 | *************************************************************************/ |
| 278 | extern DCL_STATUS DclPW_Initialize(void); |
| 279 | /************************************************************************* |
| 280 | * FUNCTION |
| 281 | * DclPW_Open |
| 282 | * |
| 283 | * DESCRIPTION |
| 284 | * This function is to open the PW module and return a handle |
| 285 | * |
| 286 | * PARAMETERS |
| 287 | * dev: only valid for DCL_PW |
| 288 | * flags: no sepcial flags is needed. Please use FLAGS_NONE |
| 289 | * |
| 290 | * RETURNS |
| 291 | * DCL_HANDLE_INVALID: Open failed. |
| 292 | * other value: a valid handle |
| 293 | * |
| 294 | *************************************************************************/ |
| 295 | extern DCL_HANDLE DclPW_Open(DCL_DEV dev, DCL_FLAGS flags); |
| 296 | /************************************************************************* |
| 297 | * FUNCTION |
| 298 | * DclPW_ReadData |
| 299 | * |
| 300 | * DESCRIPTION |
| 301 | * This function is not supported for the PW module now. |
| 302 | * |
| 303 | * PARAMETERS |
| 304 | * N/A |
| 305 | * |
| 306 | * RETURNS |
| 307 | * STATUS_UNSUPPORTED |
| 308 | * |
| 309 | *************************************************************************/ |
| 310 | extern DCL_STATUS DclPW_ReadData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN buf_len, DCL_OPTIONS options); |
| 311 | /************************************************************************* |
| 312 | * FUNCTION |
| 313 | * DclPW_WriteData |
| 314 | * |
| 315 | * DESCRIPTION |
| 316 | * This function is not supported for the PW module now. |
| 317 | * |
| 318 | * PARAMETERS |
| 319 | * N/A |
| 320 | * |
| 321 | * RETURNS |
| 322 | * STATUS_UNSUPPORTED |
| 323 | * |
| 324 | *************************************************************************/ |
| 325 | extern DCL_STATUS DclPW_WriteData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN buf_len, DCL_OPTIONS options); |
| 326 | /************************************************************************* |
| 327 | * FUNCTION |
| 328 | * DclPW_Configure |
| 329 | * |
| 330 | * DESCRIPTION |
| 331 | * This function is not supported for the PW module now. |
| 332 | * |
| 333 | * PARAMETERS |
| 334 | * N/A |
| 335 | * |
| 336 | * RETURNS |
| 337 | * STATUS_UNSUPPORTED |
| 338 | * |
| 339 | *************************************************************************/ |
| 340 | extern DCL_STATUS DclPW_Configure(DCL_HANDLE handle, DCL_CONFIGURE_T *configure); |
| 341 | /************************************************************************* |
| 342 | * FUNCTION |
| 343 | * DclPW_RegisterCallback |
| 344 | * |
| 345 | * DESCRIPTION |
| 346 | * This function is not supported for the PW module now. |
| 347 | * |
| 348 | * PARAMETERS |
| 349 | * N/A |
| 350 | * |
| 351 | * RETURNS |
| 352 | * STATUS_UNSUPPORTED |
| 353 | * |
| 354 | *************************************************************************/ |
| 355 | extern DCL_STATUS DclPW_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event, PFN_DCL_CALLBACK callback); |
| 356 | /************************************************************************* |
| 357 | * FUNCTION |
| 358 | * DclPW_Control |
| 359 | * |
| 360 | * DESCRIPTION |
| 361 | * This function is to send command to control the PW module. |
| 362 | * All command |
| 363 | * |
| 364 | * CALLS |
| 365 | * It is called to send command to control the PW module. |
| 366 | * |
| 367 | * PARAMETERS |
| 368 | * handle: [IN] The handle value returned from DclPW_Open() |
| 369 | * cmd: [IN] A control command for PW module |
| 370 | * 1. PW_CMD_POWERON: call RTC module to latch power and init time if necessary |
| 371 | * 2. PW_CMD_POWEROFF: call RTC module to unlatch power |
| 372 | * 3. PW_CMD_SET_POWERON_REASON: set power on reason |
| 373 | * 4. PW_CMD_GET_POWERON_REASON: get power on reason |
| 374 | * 5. PW_CMD_SET_SWITCH_TO_IDLE: set flag which force phone to enter idle mode |
| 375 | * 6. PW_CMD_CLEAR_SWITCH_TO_IDLE: clear flag which force phone to enter idle mode |
| 376 | * 7. PW_CMD_POWER_INIT: check power on factors to decide power on reason and save in RTC register |
| 377 | * 8. PW_CMD_UPDATE_FLAGS: update power on reason to rtc register |
| 378 | * 9. PW_CMD_NFB_POWERON: call RTC module to latch power and init time if necessary (only for NAND FLASH BOOTING) |
| 379 | * 10. PW_CMD_IS_USB_BOOT: query is power on reason USB plug in |
| 380 | * |
| 381 | * data: The data of the control command |
| 382 | * 1. PW_CMD_POWERON: A null pointer |
| 383 | * 2. PW_CMD_POWEROFF: A null pointer |
| 384 | * 3. PW_CMD_SET_POWERON_REASON: pointer to a PW_CTRL_SET_POWERON_REASON structure |
| 385 | * 4. PW_CMD_GET_POWERON_REASON: pointer to a PW_CTRL_GET_POWERON_REASON structure |
| 386 | * 5. PW_CMD_SET_SWITCH_TO_IDLE: A null pointer |
| 387 | * 6. PW_CMD_CLEAR_SWITCH_TO_IDLE: A null pointer |
| 388 | * 7. PW_CMD_POWER_INIT: A null pointer |
| 389 | * 8. PW_CMD_UPDATE_FLAGS: A null pointer |
| 390 | * 9. PW_CMD_NFB_POWERON: A null pointer |
| 391 | * 10. PW_CMD_IS_USB_BOOT: pointer to a PW_CTRL_IS_USB_BOOT |
| 392 | * |
| 393 | * RETURNS |
| 394 | * STATUS_OK: command is executed successfully. |
| 395 | * STATUS_FAIL: command is failed. |
| 396 | * STATUS_INVALID_CMD: It's a invalid command. |
| 397 | * STATUS_UNSUPPORTED: It's a unsupported command. |
| 398 | * |
| 399 | * GLOBALS AFFECTED |
| 400 | * external_global |
| 401 | *************************************************************************/ |
| 402 | extern DCL_STATUS DclPW_Control(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data); |
| 403 | /************************************************************************* |
| 404 | * FUNCTION |
| 405 | * DclPW_Close |
| 406 | * |
| 407 | * DESCRIPTION |
| 408 | * This function is to close the PW module. |
| 409 | * |
| 410 | * PARAMETERS |
| 411 | * handle: the returned handle value of DclPW_Open |
| 412 | * |
| 413 | * RETURNS |
| 414 | * STATUS_OK |
| 415 | * |
| 416 | *************************************************************************/ |
| 417 | extern DCL_STATUS DclPW_Close(DCL_HANDLE handle); |
| 418 | |
| 419 | |
| 420 | #endif // #ifndef __DCL_PW_H_PROTOTYPE__ |
| 421 | |
| 422 | #endif //#ifdef DCL_DEFINITION_PROTOTYPE |
| 423 | |
| 424 | |
| 425 | |