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 | * Filename: |
| 38 | * --------- |
| 39 | * dcl_chr_det.h |
| 40 | * |
| 41 | * Project: |
| 42 | * -------- |
| 43 | * Maui_Software |
| 44 | * |
| 45 | * Description: |
| 46 | * ------------ |
| 47 | * This Module defines functions of charger detection |
| 48 | * |
| 49 | * Author: |
| 50 | * ------- |
| 51 | * ------- |
| 52 | * |
| 53 | *============================================================================ |
| 54 | * HISTORY |
| 55 | * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 56 | *------------------------------------------------------------------------------ |
| 57 | * removed! |
| 58 | * removed! |
| 59 | * removed! |
| 60 | * |
| 61 | * removed! |
| 62 | * removed! |
| 63 | * removed! |
| 64 | * |
| 65 | * removed! |
| 66 | * removed! |
| 67 | * removed! |
| 68 | * |
| 69 | * removed! |
| 70 | * removed! |
| 71 | * removed! |
| 72 | * |
| 73 | * removed! |
| 74 | * removed! |
| 75 | * removed! |
| 76 | * |
| 77 | * removed! |
| 78 | * removed! |
| 79 | * removed! |
| 80 | * |
| 81 | * removed! |
| 82 | * removed! |
| 83 | * removed! |
| 84 | * |
| 85 | * removed! |
| 86 | * removed! |
| 87 | * removed! |
| 88 | * |
| 89 | * removed! |
| 90 | * removed! |
| 91 | * removed! |
| 92 | * |
| 93 | *------------------------------------------------------------------------------ |
| 94 | * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 95 | *============================================================================ |
| 96 | ****************************************************************************/ |
| 97 | |
| 98 | |
| 99 | #ifdef DCL_DEFINITION_STRUCT |
| 100 | |
| 101 | #ifndef __DCL_CHR_DET_H_STRUCT__ |
| 102 | #define __DCL_CHR_DET_H_STRUCT__ |
| 103 | |
| 104 | |
| 105 | /******************************************************************************* |
| 106 | * DCL_OPTIONS for PMU |
| 107 | *******************************************************************************/ |
| 108 | #define CHR_DET_OPTIONS |
| 109 | |
| 110 | /******************************************************************************* |
| 111 | * DCL_CONFIGURE_T for PMU |
| 112 | *******************************************************************************/ |
| 113 | |
| 114 | #define CHR_DET_CONFIGS |
| 115 | |
| 116 | /******************************************************************************* |
| 117 | * DCL_EVENT for PMU |
| 118 | *******************************************************************************/ |
| 119 | #define CHR_DET_EVENTS |
| 120 | |
| 121 | /* Enum of Charger type */ |
| 122 | typedef enum |
| 123 | { |
| 124 | PW_AC_CHR=0, /* AC CHARGER */ |
| 125 | PW_USB_CHR, /* USB CHARGER */ |
| 126 | PW_AC_NON_STD_CHR, /* NON-STANDARD AC CHARGER */ |
| 127 | PW_USB_CHARGING_HOST_CHR, /* USB CHARGING HOST */ |
| 128 | PW_NO_CHR // Indicate NO charger |
| 129 | }CHR_DET_TYPE_ENUM; |
| 130 | |
| 131 | /* For CHR_DET_CMD_QUERY_CHR_TYPE command. */ |
| 132 | typedef struct |
| 133 | { |
| 134 | CHR_DET_TYPE_ENUM Chr_det_type; /* Output : Value of Charger type */ |
| 135 | }CHR_DET_CTRL_QUERY_IS_CHR_IN_BY_PW; |
| 136 | |
| 137 | /* For RTC_CMD_CONFIG_AL_TC command. */ |
| 138 | typedef struct |
| 139 | { |
| 140 | CHR_DET_TYPE_ENUM Chr_det_type; /* Output : Value of Charger type */ |
| 141 | }CHR_DET_CTRL_QUERY_CHR_TYPE; |
| 142 | |
| 143 | typedef struct |
| 144 | { |
| 145 | void (*usb_det_hisr)(void); |
| 146 | }CHR_DET_CTRL_REGISTER_USB_HISR; |
| 147 | |
| 148 | /******************************************************************************* |
| 149 | * DCL_CTRL_DATA_T: Define the Control data structure for each module's command |
| 150 | *******************************************************************************/ |
| 151 | #ifdef __BUILD_DOM__ |
| 152 | /* The CHR_DET Command Parameter Data Structure for Each Command in DCL_CTRL_DATA_T Enum of dcl.h */ |
| 153 | typedef struct |
| 154 | { |
| 155 | CHR_DET_CTRL_QUERY_IS_CHR_IN_BY_PW rChrDetQueryIsChrInByPW; /* Data Structure for CHR_DET_CMD_QUERY_IS_CHR_IN_BY_PW */ |
| 156 | CHR_DET_CTRL_QUERY_CHR_TYPE rChrDetQueryChrType; /* Data Structure for CHR_DET_CMD_QUERY_CHR_TYPE */ |
| 157 | CHR_DET_CTRL_REGISTER_USB_HISR rChrDetUSBHISR; /* Data Structure for CHR_DET_CTRL_REGISTER_USB_HISR */ |
| 158 | } DCL_CTRL_CHR_DET_DATA; |
| 159 | #else /* __BUILD_DOM__ */ |
| 160 | #define CHR_DET_CTRLS \ |
| 161 | CHR_DET_CTRL_QUERY_IS_CHR_IN_BY_PW rChrDetQueryIsChrInByPW; \ |
| 162 | CHR_DET_CTRL_QUERY_CHR_TYPE rChrDetQueryChrType; \ |
| 163 | CHR_DET_CTRL_REGISTER_USB_HISR rChrDetUSBHISR; |
| 164 | #endif /* __BUILD_DOM__ */ |
| 165 | |
| 166 | |
| 167 | /******************************************************************************* |
| 168 | * DCL_CTRL_CMD for PMU |
| 169 | *******************************************************************************/ |
| 170 | #ifdef __BUILD_DOM__ |
| 171 | /* The CHR DET Command Values in DCL_CTRL_CMD_T Enum of dcl.h */ |
| 172 | typedef enum |
| 173 | { |
| 174 | CHR_DET_CMD_QUERY_IS_CHR_IN_BY_PW, |
| 175 | CHR_DET_CMD_QUERY_CHR_TYPE, |
| 176 | CHR_DET_CMD_REGISTER_CHR_USB, |
| 177 | CHR_DET_CMD_UNMASK_EINT, |
| 178 | CHR_DET_CMD_REGISTER_CHR_USB_EINT, |
| 179 | CHR_DET_CMD_REGISTER_USB_HISR, |
| 180 | } DCL_CTRL_CHR_DET_CMD; |
| 181 | #else /* __BUILD_DOM__ */ |
| 182 | #define CHR_DET_CMDS \ |
| 183 | CHR_DET_CMD_QUERY_IS_CHR_IN_BY_PW=0, \ |
| 184 | CHR_DET_CMD_QUERY_CHR_TYPE, \ |
| 185 | CHR_DET_CMD_REGISTER_CHR_USB, \ |
| 186 | CHR_DET_CMD_UNMASK_EINT, \ |
| 187 | CHR_DET_CMD_REGISTER_CHR_USB_EINT,\ |
| 188 | CHR_DET_CMD_REGISTER_USB_HISR, |
| 189 | #endif /* __BUILD_DOM__ */ |
| 190 | |
| 191 | |
| 192 | // CHR_USB_EINT control owner list |
| 193 | // Only the tasks listed can control CHR_USB_EINT Unmask |
| 194 | typedef enum |
| 195 | { |
| 196 | CHR_DET_EINT_OWNER_USB = 0x01, // Bit00 |
| 197 | CHR_DET_EINT_OWNER_BMT = 0x02, // Bit01 |
| 198 | USB_DET_EINT_OWNER_FORCE_UNMASK = 0x80 // Bit7 // It means we should skip bit match and directly unmask EINT |
| 199 | }CHR_DET_EINT_OWNER; |
| 200 | |
| 201 | |
| 202 | typedef struct |
| 203 | { |
| 204 | CHR_DET_TYPE_ENUM (*pw_is_charger_usb_det)(void); |
| 205 | void (*pw_is_charger_usb_det_eint)(void); |
| 206 | void (*usb_det_hisr)(void); |
| 207 | }CHR_USB_DET_MGR_T; |
| 208 | |
| 209 | |
| 210 | |
| 211 | #endif // #ifndef __DCL_PMU_H_STRUCT__ |
| 212 | #endif // #ifdef DCL_DEFINITION_STRUCT |
| 213 | |
| 214 | |
| 215 | #ifdef DCL_DEFINITION_PROTOTYPE |
| 216 | #ifndef __DCL_CHR_DET_H_PROTOTYPE__ |
| 217 | #define __DCL_CHR_DET_H_PROTOTYPE__ |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | /************************************************************************* |
| 223 | * FUNCTION |
| 224 | * Dcl_Chr_Det_Initialize |
| 225 | * |
| 226 | * DESCRIPTION |
| 227 | * This function is to initialize Chr_Det module |
| 228 | * |
| 229 | * PARAMETERS |
| 230 | * None |
| 231 | * |
| 232 | * RETURNS |
| 233 | * STATUS_OK |
| 234 | * |
| 235 | *************************************************************************/ |
| 236 | extern DCL_STATUS Dcl_Chr_Det_Initialize(void); |
| 237 | /************************************************************************* |
| 238 | * FUNCTION |
| 239 | * Dcl_Chr_Det_Open |
| 240 | * |
| 241 | * DESCRIPTION |
| 242 | * This function is to open the Chr_Det module and return a handle |
| 243 | * |
| 244 | * PARAMETERS |
| 245 | * dev: only valid for DCL_CHR_USB_DET |
| 246 | * flags: no sepcial flags is needed. Please use FLAGS_NONE |
| 247 | * |
| 248 | * RETURNS |
| 249 | * DCL_HANDLE_INVALID: Open failed. |
| 250 | * other value: a valid handle |
| 251 | * |
| 252 | *************************************************************************/ |
| 253 | extern DCL_HANDLE Dcl_Chr_Det_Open(DCL_DEV dev, DCL_FLAGS flags); |
| 254 | /************************************************************************* |
| 255 | * FUNCTION |
| 256 | * Dcl_Chr_Det_ReadData |
| 257 | * |
| 258 | * DESCRIPTION |
| 259 | * This function is not supported for the Chr_Det module now. |
| 260 | * |
| 261 | * PARAMETERS |
| 262 | * N/A |
| 263 | * |
| 264 | * RETURNS |
| 265 | * STATUS_OK |
| 266 | * |
| 267 | *************************************************************************/ |
| 268 | extern DCL_STATUS Dcl_Chr_Det_ReadData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN buf_len, DCL_OPTIONS options); |
| 269 | /************************************************************************* |
| 270 | * FUNCTION |
| 271 | * Dcl_Chr_Det_WriteData |
| 272 | * |
| 273 | * DESCRIPTION |
| 274 | * This function is not supported for the Chr_Det module now. |
| 275 | * |
| 276 | * PARAMETERS |
| 277 | * N/A |
| 278 | * |
| 279 | * RETURNS |
| 280 | * STATUS_OK |
| 281 | * |
| 282 | *************************************************************************/ |
| 283 | extern DCL_STATUS Dcl_Chr_Det_WriteData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN buf_len, DCL_OPTIONS options); |
| 284 | /************************************************************************* |
| 285 | * FUNCTION |
| 286 | * Dcl_Chr_Det_Configure |
| 287 | * |
| 288 | * DESCRIPTION |
| 289 | * This function is to close the Chr_Det module. |
| 290 | * |
| 291 | * PARAMETERS |
| 292 | * N/A |
| 293 | * |
| 294 | * RETURNS |
| 295 | * STATUS_OK |
| 296 | * |
| 297 | *************************************************************************/ |
| 298 | extern DCL_STATUS Dcl_Chr_Det_Configure(DCL_HANDLE handle, DCL_CONFIGURE_T *configure); |
| 299 | /************************************************************************* |
| 300 | * FUNCTION |
| 301 | * Dcl_Chr_Det_RegisterCallback |
| 302 | * |
| 303 | * DESCRIPTION |
| 304 | * This function is not supported for the Chr_Det module now. |
| 305 | * |
| 306 | * PARAMETERS |
| 307 | * N/A |
| 308 | * |
| 309 | * RETURNS |
| 310 | * STATUS_OK |
| 311 | * |
| 312 | *************************************************************************/ |
| 313 | extern DCL_STATUS Dcl_Chr_Det_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event, PFN_DCL_CALLBACK callback); |
| 314 | /************************************************************************* |
| 315 | * FUNCTION |
| 316 | * Dcl_Chr_Det_Control |
| 317 | * |
| 318 | * DESCRIPTION |
| 319 | * This function is to send command to control the Chr_Det module. |
| 320 | * All command |
| 321 | * |
| 322 | * CALLS |
| 323 | * It is called to send command to control the Chr_Det module. |
| 324 | * |
| 325 | * PARAMETERS |
| 326 | * handle: [IN] The handle value returned from Dcl_Chr_Det_Open() |
| 327 | * cmd: [IN] A control command for Chr_Det module |
| 328 | * 1. PW_CMD_POWERON: call RTC module to latch power and init time if necessary |
| 329 | * 2. PW_CMD_POWEROFF: call RTC module to unlatch power |
| 330 | * 3. PW_CMD_SET_POWERON_REASON: set power on reason |
| 331 | * 4. PW_CMD_GET_POWERON_REASON: get power on reason |
| 332 | * 5. PW_CMD_SET_SWITCH_TO_IDLE: set flag which force phone to enter idle mode |
| 333 | * 6. PW_CMD_CLEAR_SWITCH_TO_IDLE: clear flag which force phone to enter idle mode |
| 334 | * 7. PW_CMD_POWER_INIT: check power on factors to decide power on reason and save in RTC register |
| 335 | * 8. PW_CMD_UPDATE_FLAGS: update power on reason to rtc register |
| 336 | * 9. PW_CMD_NFB_POWERON: call RTC module to latch power and init time if necessary (only for NAND FLASH BOOTING) |
| 337 | * 10. PW_CMD_IS_USB_BOOT: query is power on reason USB plug in |
| 338 | * |
| 339 | * data: The data of the control command |
| 340 | * 1. PW_CMD_POWERON: A null pointer |
| 341 | * 2. PW_CMD_POWEROFF: A null pointer |
| 342 | * 3. PW_CMD_SET_POWERON_REASON: pointer to a PW_CTRL_SET_POWERON_REASON structure |
| 343 | * 4. PW_CMD_GET_POWERON_REASON: pointer to a PW_CTRL_GET_POWERON_REASON structure |
| 344 | * 5. PW_CMD_SET_SWITCH_TO_IDLE: A null pointer |
| 345 | * 6. PW_CMD_CLEAR_SWITCH_TO_IDLE: A null pointer |
| 346 | * 7. PW_CMD_POWER_INIT: A null pointer |
| 347 | * 8. PW_CMD_UPDATE_FLAGS: A null pointer |
| 348 | * 9. PW_CMD_NFB_POWERON: A null pointer |
| 349 | * 10. PW_CMD_IS_USB_BOOT: pointer to a PW_CTRL_IS_USB_BOOT |
| 350 | * |
| 351 | * RETURNS |
| 352 | * STATUS_OK: command is executed successfully. |
| 353 | * STATUS_FAIL: command is failed. |
| 354 | * STATUS_INVALID_CMD: It's a invalid command. |
| 355 | * STATUS_UNSUPPORTED: It's a unsupported command. |
| 356 | * |
| 357 | * GLOBALS AFFECTED |
| 358 | * external_global |
| 359 | *************************************************************************/ |
| 360 | extern DCL_STATUS Dcl_Chr_Det_Control(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data); |
| 361 | /************************************************************************* |
| 362 | * FUNCTION |
| 363 | * Dcl_Chr_Det_Close |
| 364 | * |
| 365 | * DESCRIPTION |
| 366 | * This function is to close the Chr_Det module. |
| 367 | * |
| 368 | * PARAMETERS |
| 369 | * handle: the returned handle value of Dcl_Chr_Det_Open |
| 370 | * |
| 371 | * RETURNS |
| 372 | * STATUS_OK |
| 373 | * |
| 374 | *************************************************************************/ |
| 375 | extern DCL_STATUS Dcl_Chr_Det_Close(DCL_HANDLE handle); |
| 376 | |
| 377 | |
| 378 | #endif // #ifndef __DCL_CHR_DET_H_PROTOTYPE__ |
| 379 | #endif //#ifdef DCL_DEFINITION_PROTOTYPE |
| 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 | |