/************************************************************************* * FUNCTION * Drv_query_boot_mode * * DESCRIPTION * Return boot mode. * * PARAMETERS * * RETURNS * FACTORY_BOOT, NORMAL_BOOT and USBMS_BOOT * * GLOBALS AFFECTED * *************************************************************************/ boot_mode_type Drv_query_boot_mode(void) { #ifdef __MULTI_BOOT__ #ifdef __USB_ENABLE__ PW_CTRL_IS_USB_BOOT CtrlVal; DCL_HANDLE handle; #endif /* __USB_ENABLE__ */ if( INT_BootMode() == MTK_FACTORY_MODE ) return FACTORY_BOOT; #ifdef __USB_ENABLE__ handle=DclPW_Open(DCL_PW, FLAGS_NONE); DclPW_Control(handle, PW_CMD_IS_USB_BOOT,(DCL_CTRL_DATA_T *)&CtrlVal); DclPW_Close(handle); if(CtrlVal.val == KAL_TRUE ) return USBMS_BOOT; #endif /* __USB_ENABLE__ */ #endif /* __MULTI_BOOT__ */ return NORMAL_BOOT; }
kal_uint8 bmt_Get_PowerOn_Type(void) { PW_CTRL_GET_POWERON_REASON CtrlVal; DCL_HANDLE pmu_handle; pmu_handle = DclPW_Open(DCL_PW, FLAGS_NONE); DclPW_Control(pmu_handle, PW_CMD_GET_POWERON_REASON, (DCL_CTRL_DATA_T *)&CtrlVal); DclPW_Close(pmu_handle); return CtrlVal.powerOnReason; }
void bmt_Modify_PowerOn_Type(kal_uint8 power_type) { PW_CTRL_SET_POWERON_REASON CtrlVal; DCL_HANDLE pmu_handle; CtrlVal.powerOnReason = (PW_CTRL_POWER_ON_REASON)power_type; pmu_handle=DclPW_Open(DCL_PW, FLAGS_NONE); DclPW_Control(pmu_handle, PW_CMD_SET_POWERON_REASON, (DCL_CTRL_DATA_T *)&CtrlVal); DclPW_Close(pmu_handle); }
void ft_util_reboot_to_normal_mode(FT_UTILITY_COMMAND_REQ *req, FT_UTILITY_COMMAND_CNF *cnf) { DCL_HANDLE handle; handle=DclPW_Open(DCL_PW, FLAGS_NONE); /* RCT_PDN2 bit1: make sure the the next boot is IDLE (normal mode) */ DclPW_Control(handle,PW_CMD_SET_SWITCH_TO_IDLE,NULL); DclPW_Close(handle); // enable watchdog timer ft_util_watch_dog_start(req, cnf, NULL); }
/******************************************************************************* * * FUNCTION * FT_PowerOff * * DESCRIPTION * Power off sequence in META mode * * CALLS * custom_ft_util_check_if_usb_enable_support for check the USB_ENABLE compile option * USB_PowerControl * DclRTC_Open/DclRTC_Control (RTC_CMD_FT_POWEROFF command)/DclRTC_Close for RTC power off sequence (scramble PDN1 bit 7 for flashtool entering META mode) * DclPW_Open/DclPW_Control (PW_CMD_POWEROFF command)/DclPW_Close for Driver power off sequence * DclWDT_Open/DclWDT_Control (WDT_CMD_DRV_RESET command)/DclWDT_Close for Driver reset sequence * * PARAMETERS * void * * RETURNS * void * * GLOBALS AFFECTED * N/A * *******************************************************************************/ void FT_PowerOff(void) { #if (!defined(__SMART_PHONE_MODEM__)) kal_bool toolUsbReset = KAL_FALSE; if(true == custom_ft_util_check_if_usb_enable_support()) { // shutdown USB module /** * USB_PowerControl(KAL_FALSE) is no longer * to disable the usb power anymore. **/ #if defined(__USB_ENABLE__) DCL_BOOL dcl_data = DCL_TRUE; DCL_HANDLE usb_dcl_handle; usb_dcl_handle = DclUSB_DRV_Open(DCL_USB, FLAGS_NONE); DclUSB_DRV_Control(usb_dcl_handle, USB_DRV_CMD_PDN_ENABLE, (DCL_CTRL_DATA_T *)&dcl_data); DclUSB_DRV_Close(usb_dcl_handle); // USB_PDNmode(KAl_TRUE); #endif //#if defined(__USB_ENABLE__) } Custom_META_USBVirtualComDisconnect(); toolUsbReset = FT_ClearPowerKey(); if(tst_hal_USBDL_Is_USB_Download_Mode() == KAL_TRUE || /* Note: FEATURE compile option and references should be checked before patch-back */ tst_hal_USBDL_Is_USB_Fast_Meta_Mode() == KAL_TRUE) { // Driver power off sequence { DCL_HANDLE dcl_pmu_handle; dcl_pmu_handle=DclPW_Open(DCL_PW, FLAGS_NONE); DclPW_Control(dcl_pmu_handle,PW_CMD_POWEROFF,NULL); DclPW_Close(dcl_pmu_handle); } // really turn off the target because USB will provide power automatically to target side if(toolUsbReset == KAL_FALSE) { DCL_HANDLE dcl_wdt_handle; dcl_wdt_handle = DclWDT_Open(DCL_WDT, FLAGS_NONE); DclWDT_Control(dcl_wdt_handle, WDT_CMD_DRV_RESET, FLAGS_NONE); DclWDT_Close(dcl_wdt_handle); } else { while(1); } } #endif // #if (!defined(__SMART_PHONE_MODEM__)) }
/***************************************************************************** * FUNCTION * nvram_util_poweron * DESCRIPTION * old function name: DRV_POWERON * PARAMETERS * RETURNS *****************************************************************************/ void nvram_util_poweroff(void) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ DCL_HANDLE handle; /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ handle=DclPW_Open(DCL_PW, FLAGS_NONE); DclPW_Control(handle,PW_CMD_POWEROFF,NULL); DclPW_Close(handle); }
/***************************************************************************** * FUNCTION * nvram_util_poweron * DESCRIPTION * old function name: DRV_POWERON * PARAMETERS * RETURNS *****************************************************************************/ kal_bool nvram_util_poweron(void) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ DCL_HANDLE handle; /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ handle=DclPW_Open(DCL_PW, FLAGS_NONE); DclPW_Control(handle,PW_CMD_POWERON,NULL); DclPW_Close(handle); return KAL_TRUE; }
/***************************************************************************** * FUNCTION * nvram_util_is_usbboot * DESCRIPTION * old function name: INT_USBBoot * PARAMETERS * RETURNS *****************************************************************************/ kal_bool nvram_util_is_usbboot(void) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ PW_CTRL_IS_USB_BOOT CtrlVal; DCL_HANDLE handle; /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ handle=DclPW_Open(DCL_PW, FLAGS_NONE); DclPW_Control(handle, PW_CMD_IS_USB_BOOT,(DCL_CTRL_DATA_T *)&CtrlVal); DclPW_Close(handle); return ((kal_bool)CtrlVal.val); }
/************************************************************************* * FUNCTION * Drv_PW_Init * * DESCRIPTION * PW initialization * * PARAMETERS * * RETURNS * * GLOBALS AFFECTED * *************************************************************************/ void Drv_PW_Init(void) { DclBMT_Initialize(); #ifndef __L1_STANDALONE__ #ifdef PMIC_PRESENT print_bootup_trace_enter(SST_INIT_DRV1_PW); { DCL_HANDLE handle; Dcl_Chr_Det_Initialize(); handle=DclPW_Open(DCL_PW, FLAGS_NONE); DclPW_Control(handle, PW_CMD_POWER_INIT, NULL); DclPW_Close(handle); } print_bootup_trace_exit(SST_INIT_DRV1_PW); #if defined(DRV_BMT_HW_PRECC_WORKAROUND) { PW_CTRL_GET_POWERON_REASON CtrlVal; DCL_HANDLE pmu_handle; pmu_handle = DclPW_Open(DCL_PW, FLAGS_NONE); DclPW_Control(pmu_handle, PW_CMD_GET_POWERON_REASON, (DCL_CTRL_DATA_T *)&CtrlVal); if(CtrlVal.powerOnReason == CHRPWRON || CtrlVal.powerOnReason == USBPWRON_WDT || CtrlVal.powerOnReason == USBPWRON) { // For Pre-cc 3.2~3.3V VCore Drop Issue DclPW_Control(pmu_handle, PW_CMD_POWERON, NULL); } DclPW_Close(pmu_handle); } #endif #if defined(__DRV_NO_USB_CHARGER__) { DCL_HANDLE handle; handle=DclPW_Open(DCL_PW, FLAGS_NONE); DclPW_Control(handle,PW_CMD_POWERON,NULL); DclPW_Close(handle); } #endif /* if(BMT.PWRon == PWRKEYPWRON) GPTI_BusyWait(Custom_Keypress_Period); */ #else #ifdef __USB_ENABLE__ { extern charger_usb_present_enum PW_is_charger_usb_present(void); switch (PW_is_charger_usb_present()) { case CHARGER_PRESENT: break; #if defined(__CHINA_CHARGER_STANDARD__) case CHARGER_PRESENT_NON: //non-standard china charger break; #endif case USB_PRESENT: #if defined(DRV_PW_NONE_USB_POWER_ON) BMT.PWRon = CHRPWRON; #else //#if defined(DRV_PW_NONE_USB_POWER_ON) BMT.PWRon = USBPWRON; #endif //#if defined(DRV_PW_NONE_USB_POWER_ON) break; case NO_PRESENT: break; } } #endif /*__USB_ENABLE__*/ handle=DclPW_Open(DCL_PW, FLAGS_NONE); DclPW_Control(handle,PW_CMD_POWERON,NULL); DclPW_Close(handle); #endif /*PMIC_PRESENT*/ #else /*__L1_STANDALONE__*/ { DCL_HANDLE handle; handle=DclPW_Open(DCL_PW, FLAGS_NONE); DclPW_Control(handle,PW_CMD_POWERON,NULL); DclPW_Close(handle); } #endif /*__L1_STANDALONE__*/ }