void Custom_META_USBVirtualComDisconnect(void) { #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); #endif // #if defined(__USB_ENABLE__) }
/******************************************************************************* * * 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__)) }
CHR_DET_TYPE_ENUM DclPW_charger_usb_det_USB(void) { #if defined(__USB_ENABLE__) kal_uint32 i; CHR_DET_TYPE_ENUM state = PW_NO_CHR; // Call this function to init USB H/W DclUSB_DRV_Control(chrDet_UsbHandler, USB_DRV_CMD_INITIALIZE_DRV_PHASE_1, NULL); //USB_Initialize_Drv_Phase1(); // Detect init setting USB_Charger_Detect_Init(); // Init setting debounce for (i=0;i<1000000;i++){ ; } // Check USB or Charger if (USB_Detect_Is_Charger_In()){ // Charger // Init setting to detect Standard/Non-standard charger USB_Check_Standard_Charger(); // Init setting debounce for (i=0;i<10000;i++){ ; } if (USB_Detect_Is_Standard_Charger_In()){ // Standard charger state = PW_AC_CHR; }else{ // Non-standard charger state = PW_AC_NON_STD_CHR; } } else { // USB state = PW_USB_CHR; } USB_Charger_Detect_Release(); return state; #else // #if defined(__USB_ENABLE__) return PW_NO_CHR; #endif // #if defined(__USB_ENABLE__) }
void CHR_USB_Det_EINT_Return(CHR_DET_TYPE_ENUM state) { if ( state == PW_USB_CHR || state == PW_USB_CHARGING_HOST_CHR) { // kal_prompt_trace(MOD_BMT,"USB IN"); if(state == PW_USB_CHR) { kal_brief_trace( TRACE_STATE,BMT_USB_IN_TRC); } else { kal_brief_trace( TRACE_STATE,BMT_USB_CHARGING_HOST_IN_TRC); } chr_usb_detect.chr_usb_present = USB_PRESENT; // Set central control owner bit CHR_USB_EINT_Owner_SetMask(CHR_DET_EINT_OWNER_BMT); CHR_USB_EINT_Owner_SetMask(CHR_DET_EINT_OWNER_USB); CHRDET_HISR(); #if defined(__USB_ENABLE__) chr_usb_det_mgr.usb_det_hisr(); #endif // #if defined(__USB_ENABLE__) } else if (state == PW_AC_CHR || state==PW_AC_NON_STD_CHR) { if(state == PW_AC_CHR) { //kal_prompt_trace(MOD_BMT,"AC IN"); kal_brief_trace( TRACE_STATE,BMT_AC_IN_TRC); chr_usb_detect.chr_usb_present = CHARGER_PRESENT; } else // non standard charger { //kal_prompt_trace(MOD_BMT,"Non AC IN"); kal_brief_trace( TRACE_STATE,BMT_NON_AC_IN_TRC); chr_usb_detect.chr_usb_present = CHARGER_PRESENT_NON; } CHR_USB_EINT_Owner_SetMask(CHR_DET_EINT_OWNER_BMT); CHRDET_HISR(); #if ( defined(__USB_AND_UART_WITH_ONE_GPIO__) || defined(__USB_AND_UART_WITH_ONE_PORT__) ) /* We must call this function in chr_usb_det_mgr.usb_det_hisr() in the case that USB and UART with one GPIO */ //USB_UART_Share(KAL_TRUE); { DCL_HANDLE usb_dcl_handle; DCL_BOOL dcl_data; usb_dcl_handle = DclUSB_DRV_Open(DCL_USB, FLAGS_NONE); dcl_data = DCL_TRUE; DclUSB_DRV_Control(usb_dcl_handle, USB_DRV_CMD_USB_UART_SHARE, (DCL_CTRL_DATA_T *)&dcl_data); DclUSB_DRV_Close(usb_dcl_handle); } #endif // #if ( defined(__USB_AND_UART_WITH_ONE_GPIO__) || defined(__USB_AND_UART_WITH_ONE_PORT__) ) //#endif // #if defined(__CHINA_CHARGER_STANDARD__) } CHR_USB_EINT_UnMask(CHR_DET_EINT_OWNER_BMT); // EINT_UnMask(chr_usb_detect.chr_usb_eint); }
void Drv_Init_Phase1(void) { #if defined(DRV_GPT_GPT3) DCL_HANDLE gpt_handle; #endif //defined(DRV_GPT_GPT3) #ifndef DRV_RTC_NOT_EXIST DCL_HANDLE rtc_handler; #endif //#ifndef DRV_RTC_NOT_EXIST DCL_HANDLE uart_handle; UART_CTRL_INIT_T data_init; extern Seriport_HANDLER_T Uart_Drv_Handler; #ifdef __USB_COM_PORT_ENABLE__ DCL_HANDLE usb_dcl_handle; DCL_BOOL dcl_data; kal_bool b_is_dl_mode; usb_dcl_handle = DclUSB_DRV_Open(DCL_USB, FLAGS_NONE); DclUSB_DRV_Control(usb_dcl_handle, USB_DRV_CMD_USBDL_UPDATE_USB_DL_MODE, NULL); DclUSB_DRV_Control(usb_dcl_handle, USB_DRV_CMD_USBDL_IS_USB_DL_MODE, (DCL_CTRL_DATA_T *)&dcl_data); b_is_dl_mode = (kal_bool)dcl_data; if(b_is_dl_mode == KAL_TRUE) { UPLL_Enable(UPLL_OWNER_USB); } DclUSB_DRV_Close(usb_dcl_handle); #endif //__USB_COM_PORT_ENABLE__ #if defined(__HW_US_TIMER_SUPPORT__ ) USC_Start(); #endif #ifdef __BACKUP_DOWNLOAD_RESTORE_WITHOUT_BATTERY__ if (INT_GetSysStaByCmd(CHK_USB_META_WO_BAT, NULL)==KAL_TRUE) { DCL_HANDLE handle; DclPMU_Initialize(); handle = DclPMU_Open(DCL_PMU, FLAGS_NONE); DclPMU_Control(handle, CHR_SET_CHARGE_WITHOUT_BATTERY, NULL); DclPMU_Close(handle); } #endif //#ifdef __BACKUP_DOWNLOAD_RESTORE_WITHOUT_BATTERY__ print_bootup_trace_enter(SST_INIT_DRV1_DRVHISR); drv_hisr_init(); print_bootup_trace_exit(SST_INIT_DRV1_DRVHISR); #if defined(__DSP_FCORE4__) print_bootup_trace_enter(SST_INIT_DRV1_MDCIHW); mdci_hw_init(1,0x0); print_bootup_trace_exit(SST_INIT_DRV1_MDCIHW); #endif #if defined(__SMART_PHONE_MODEM__) print_bootup_trace_enter(SST_INIT_DRV1_CCCI); ccif_init(1,0x0); ipc_msgsvc_init(); FS_CCCI_Init(); ccci_init(CCCI_FS_CHANNEL, FS_CCCI_Callback); ccci_init(CCCI_FS_ACK_CHANNEL, FS_CCCI_Callback); uart_handle = DclSerialPort_Open(uart_port_tst_ccci, 0); DclSerialPort_RegisterCallback(uart_handle, &CCCI_Uart_Drv_Handler); uart_handle = DclSerialPort_Open(uart_port_at_ccci, 0); DclSerialPort_RegisterCallback(uart_handle, &CCCI_Uart_Drv_Handler); #if defined(__UPS_SUPPORT__) uart_handle = DclSerialPort_Open(uart_port_ccmni1_ccci, 0); DclSerialPort_RegisterCallback(uart_handle, &CCCI_Uart_Drv_Handler); uart_handle = DclSerialPort_Open(uart_port_ccmni2_ccci, 0); DclSerialPort_RegisterCallback(uart_handle, &CCCI_Uart_Drv_Handler); uart_handle = DclSerialPort_Open(uart_port_ccmni3_ccci, 0); DclSerialPort_RegisterCallback(uart_handle, &CCCI_Uart_Drv_Handler); #endif /* __UPS_SUPPORT__ */ uart_handle = DclSerialPort_Open(uart_port_gps_ccci, 0); DclSerialPort_RegisterCallback(uart_handle, &CCCI_Uart_Drv_Handler); print_bootup_trace_exit(SST_INIT_DRV1_CCCI); #endif /* __SMART_PHONE_MODEM__ */ #if defined(DRV_EMIMPU) print_bootup_trace_enter(SST_INIT_DRV1_EMIMPU); emimpu_init(); print_bootup_trace_exit(SST_INIT_DRV1_EMIMPU); #endif /* DRV_EMIMPU */ print_bootup_trace_enter(SST_INIT_DRV1_LPWR); lpwr_init(); print_bootup_trace_exit(SST_INIT_DRV1_LPWR); print_bootup_trace_enter(SST_INIT_DRV1_DRVPDN); DRVPDN_ini(); print_bootup_trace_exit(SST_INIT_DRV1_DRVPDN); print_bootup_trace_enter(SST_INIT_DRV1_PWM); DclPWM_Initialize(); print_bootup_trace_exit(SST_INIT_DRV1_PWM); /*To get all customized data*/ print_bootup_trace_enter(SST_INIT_DRV1_CUSTOM); DclSADC_Initialize(); Drv_Customize_Init(); custom_drv_init(); print_bootup_trace_exit(SST_INIT_DRV1_CUSTOM); #if defined(DRV_GPT_GPT3) print_bootup_trace_enter(SST_INIT_DRV1_GPT3); /*turn on gpt3 to count powen on period*/ DclFGPT_Initialize(); gpt_handle=DclFGPT_Open(DCL_GPT_FreeRUN3,0); DclFGPT_Control(gpt_handle,FGPT_CMD_START,0); DclFGPT_Close(gpt_handle); print_bootup_trace_exit(SST_INIT_DRV1_GPT3); #endif #if !defined(__L1_STANDALONE__) && !defined(__MAUI_BASIC__) && !defined(__SMART_PHONE_MODEM__) print_bootup_trace_enter(SST_INIT_DRV1_VISUAL); Visual_Init(); print_bootup_trace_exit(SST_INIT_DRV1_VISUAL); #endif /*!defined(__L1_STANDALONE__) && !defined(__MAUI_BASIC__) && !defined(__SMART_PHONE_MODEM__)*/ #if defined(DRV_TIMING_DEBUG) && defined(DRV_GPT_6218B_GPT3_TIMING_DEBUG) DRV_MISC_WriteReg(0x8010001c,1); DRV_MISC_WriteReg(0x80100024,0x04); //DRV_WriteReg(0x80100024,1); // (1/16K) #endif #ifdef DRV_MISC_DMA_NO_MEMCPY DRV_MEMCPY = (MEMCPY_FUNC)0x48000150; #elif defined(DRV_MISC_DMA_MEMCPY) DRV_MEMCPY_PTR = (MEMCPY_FUNC)0x48000134; #endif print_bootup_trace_enter(SST_INIT_DRV1_GPTI); DclSGPT_Initialize(); print_bootup_trace_exit(SST_INIT_DRV1_GPTI); print_bootup_trace_enter(SST_INIT_DRV1_WDT); WDT_init(); print_bootup_trace_exit(SST_INIT_DRV1_WDT); print_bootup_trace_enter(SST_INIT_DRV1_DMA); DMA_Ini(); print_bootup_trace_exit(SST_INIT_DRV1_DMA); #ifndef DRV_RTC_NOT_EXIST // need to set XOSC earlier print_bootup_trace_enter(SST_INIT_DRV1_XOSC); rtc_handler = DclRTC_Open(DCL_RTC,FLAGS_NONE); DclRTC_Control(rtc_handler, RTC_CMD_SETXOSC, (DCL_CTRL_DATA_T *)NULL); print_bootup_trace_exit(SST_INIT_DRV1_XOSC); #endif /*DRV_RTC_NOT_EXIST*/ print_bootup_trace_enter(SST_INIT_DRV1_ADC); DclHADC_Initialize( ); print_bootup_trace_exit(SST_INIT_DRV1_ADC); #ifdef __CS_FAC_DET__ print_bootup_trace_enter(SST_INIT_DRV1_CSFACDET); cs_fac_det = cs_fac_det_get_interface(); cs_fac_det->drv_init(); print_bootup_trace_exit(SST_INIT_DRV1_CSFACDET); #endif // #ifdef __CS_FAC_DET__ #ifdef __DRV_EXT_ACCESSORY_DETECTION__ #ifdef __USB_COM_PORT_ENABLE__ usb_dcl_handle = DclUSB_DRV_Open(DCL_USB, FLAGS_NONE); DclUSB_DRV_Control(usb_dcl_handle, USB_DRV_CMD_USBDL_IS_USB_DL_MODE, (DCL_CTRL_DATA_T *)&dcl_data); b_is_dl_mode = (kal_bool)dcl_data; DclUSB_DRV_Close(usb_dcl_handle); if(b_is_dl_mode == KAL_FALSE) #endif { print_bootup_trace_enter(SST_INIT_DRV1_EXTACCDET); aux_ext_acc_det = aux_custom_get_ext_accessory_det(); aux_ext_acc_det->drv_init(); print_bootup_trace_exit(SST_INIT_DRV1_EXTACCDET); } #endif // #ifdef __DRV_EXT_ACCESSORY_DETECTION__ //#if (defined(__ACCDET_SUPPORT__) && !defined(__L1_STANDALONE__)) print_bootup_trace_enter(SST_INIT_DRV1_ACCDET); DclAUX_Initialize(); print_bootup_trace_exit(SST_INIT_DRV1_ACCDET); //#endif //#if defined(__ACCDET_SUPPORT__) #if defined(__RESOURCE_MANAGER__) print_bootup_trace_enter(SST_INIT_DRV1_RM); RMInit(); print_bootup_trace_exit(SST_INIT_DRV1_RM); #endif //__RESOURCE_MANAGER__ #ifndef DRV_LCD_NOT_EXIST print_bootup_trace_enter(SST_INIT_DRV1_LCD); lcd_system_init(); print_bootup_trace_exit(SST_INIT_DRV1_LCD); #endif /*DRV_LCD_NOT_EXIST*/ #ifndef DRV_RTC_NOT_EXIST #ifdef DRV_RTC_HW_CALI print_bootup_trace_enter(SST_INIT_DRV1_RTCHW); DclRTC_Control(rtc_handler, RTC_CMD_HW_INIT, (DCL_CTRL_DATA_T *)NULL); print_bootup_trace_exit(SST_INIT_DRV1_RTCHW); #endif #endif /*DRV_RTC_NOT_EXIST*/ DclPW_Initialize(); DclPMU_Initialize(); Drv_PW_Init(); /* update the system boot mode */ /*lint -e552*/ system_boot_mode = Drv_query_boot_mode(); /*lint +e552*/ print_boot_mode(); #ifdef __DMA_UART_VIRTUAL_FIFO__ // print_bootup_trace_enter(SST_INIT_DRV1_DMAVFIFO); // DMA_Vfifo_init(); // print_bootup_trace_exit(SST_INIT_DRV1_DMAVFIFO); #if defined(__MD_STANDALONE__) // This is to configure AP side VFIFO ALT register, to avoid un-init AP side DMA setting // conflict MD side setting // This is only used in MD DVT load, when both side are ready, we shouldn't overwrite AP side setting via back door // Hack DMA channel 13 (VFIFO channel) in AP side in order to avoid conflict *(volatile kal_uint32 *)(0xF0022000 + 0xD40) = 0x3F; // Hack DMA channel 14 (VFIFO channel) in AP side in order to avoid conflict *(volatile kal_uint32 *)(0xF0022000 + 0xE40) = 0x3F; #endif // #if defined(__MD_STANDALONE__) #endif print_bootup_trace_enter(SST_INIT_DRV1_UART1); data_init.u4Flag = KAL_FALSE; uart_handle = DclSerialPort_Open(uart_port1, 0); DclSerialPort_RegisterCallback(uart_handle, &Uart_Drv_Handler); // Initialization DclSerialPort_Control(uart_handle,SIO_CMD_INIT,(DCL_CTRL_DATA_T *)&data_init); print_bootup_trace_exit(SST_INIT_DRV1_UART1); // Register the callback function print_bootup_trace_enter(SST_INIT_DRV1_UART2); uart_handle = DclSerialPort_Open(uart_port2, 0); DclSerialPort_RegisterCallback(uart_handle, &Uart_Drv_Handler); // Initialization DclSerialPort_Control(uart_handle,SIO_CMD_INIT,(DCL_CTRL_DATA_T *)&data_init); print_bootup_trace_exit(SST_INIT_DRV1_UART2); #ifdef __UART3_SUPPORT__ print_bootup_trace_enter(SST_INIT_DRV1_UART3); // Register the callback function uart_handle = DclSerialPort_Open(uart_port3, 0); DclSerialPort_RegisterCallback(uart_handle,&Uart_Drv_Handler); DclSerialPort_Control(uart_handle,SIO_CMD_INIT,(DCL_CTRL_DATA_T *)&data_init); print_bootup_trace_exit(SST_INIT_DRV1_UART3); #endif }