コード例 #1
0
ファイル: usbdl_pmu.c プロジェクト: WayWingsDev/testmywatch
void BL_HV_detection_init(void)
{
#if defined(__BMT_2_0_ARCHITECTURE__)
	DCL_BOOL chr_hv_enable = DCL_TRUE;
	#if defined(DRV_BMT_HIGH_VCHG_ADAPTIVE_CHARGE_CURRENT_SUPPORT)
	kal_uint32 hv_voltage = CHR_VCHARGER_HV_HIGH;
	#else
	kal_uint32 hv_voltage = CHR_VCHARGER_HW_HIGH;
	#endif


	/*trigger HW Charger OVP before backlight on*/
	bl_chr_control_handler(BMT_BL_CHARGING_CMD_SET_HV_VOLTAGE, &hv_voltage);
	bl_chr_control_handler(BMT_BL_CHARGING_CMD_SET_HV_ENABLE, &chr_hv_enable);

	

#else
	DCL_UINT32 voltage;
	DCL_HANDLE pmu_handle;
	PMU_CTRL_CHR_GET_HV_DETECTION_VOLTAGE_LIST hv_voltage_list;
	PMU_CTRL_CHR_SET_HV_DETECTION_VOLTAGE hv_voltage;
	DCL_STATUS  status;

	DclPMU_Initialize();

	pmu_handle = DclPMU_Open(DCL_PMU, FLAGS_NONE);
	status=DclPMU_Control(pmu_handle, CHR_GET_HV_DETECTION_VOLTAGE_LIST, (
DCL_CTRL_DATA_T *)&hv_voltage_list);

	if(status==STATUS_UNSUPPORTED)
	{
		//drv_trace1(TRACE_GROUP_10, BMT_PMU_DO_NOT_SUPPORT_TRC, 0);
		return;
	}

#if defined(DRV_BMT_HIGH_VCHG_ADAPTIVE_CHARGE_CURRENT_SUPPORT)
		voltage=CHR_VCHARGER_HV_HIGH;
#else
#if defined(CHR_HW_VCHARGER_HIGH)
		voltage=CHR_HW_VCHARGER_HIGH;
#else
		voltage=CHR_VCHARGER_HIGH;
#endif //#if defined(CHR_HW_VCHARGER_HIGH)
#endif

	hv_voltage.voltage=(PMU_VOLTAGE_ENUM)bmt_find_closest_level(hv_voltage_list.pVoltageList
		,hv_voltage_list.number,(DCL_UINT32)voltage);
	
	DclPMU_Control(pmu_handle, CHR_SET_HV_DETECTION_VOLTAGE, (DCL_CTRL_DATA_T *)&hv_voltage);
	DclPMU_Close(pmu_handle);   

#endif //#if defined(__BMT_2_0_ARCHITECTURE__)

}
コード例 #2
0
ファイル: bmtutil.c プロジェクト: WayWingsDev/testmywatch
void bmt_charge_clear_wdt(void *parameter)
{
	
	DCL_STATUS status;
	SGPT_CTRL_START_T start;

   

	// Clear charge WDT
	drv_trace0(TRACE_GROUP_10, BMT_CHARGING_WDT_CLR_TRC);
	DclPMU_Control(bmt_PmuHandler, CHR_SET_WDT_CLEAR, NULL);	
	   

	if (bmt_wdt_handle != 0xFF)
	{
		start.u2Tick=BMT_CHARGE_CLEAR_WDT_PERIOD;
		start.pfCallback=bmt_charge_clear_wdt;
		start.vPara=NULL;
		//this is for handle type transfer between new and old API.
		status = DclSGPT_Control(bmt_wdt_handle, SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);
        
        if(status != STATUS_OK)
        {
        	ASSERT(0);  		
        }  	        
	}
}
コード例 #3
0
ファイル: bmtutil.c プロジェクト: WayWingsDev/testmywatch
void bmt_chr_force_enable(kal_bool enable)
{
    
    PMU_CTRL_CHR_SET_CHR_FORCE_EN force_en;
   
    force_en.enable = enable;
    DclPMU_Control(bmt_PmuHandler, CHR_SET_CHR_FORCE_EN, (DCL_CTRL_DATA_T *)&force_en);
    
}
コード例 #4
0
ファイル: bmtutil.c プロジェクト: WayWingsDev/testmywatch
kal_bool bmt_is_chr_valid(void)
{
    
    PMU_CTRL_CHR_GET_IS_CHR_VALID bIsChrValid;
	DclPMU_Control(bmt_PmuHandler, CHR_GET_IS_CHR_VALID, (DCL_CTRL_DATA_T *)&bIsChrValid);
	
    
    return (kal_bool)bIsChrValid.enable;
}
コード例 #5
0
ファイル: bmtutil.c プロジェクト: WayWingsDev/testmywatch
kal_bool bmt_get_chr_cv_det(void)
{
	
	PMU_CTRL_CHR_GET_CV_DETECTION_STATUS Get_CV_Detect_Status;
    
	
	DclPMU_Control(bmt_PmuHandler, CHR_GET_CV_DETECTION_STATUS, (DCL_CTRL_DATA_T *)&Get_CV_Detect_Status);
	
	return (kal_bool)Get_CV_Detect_Status.enable;
}
コード例 #6
0
ファイル: bmtutil.c プロジェクト: WayWingsDev/testmywatch
kal_bool bmt_chr_chrdet(void)
{
    
    PMU_CTRL_CHR_GET_CHR_DET_STATUS chr_det_status;
    
    
    DclPMU_Control(bmt_PmuHandler, CHR_GET_CHR_DET_STATUS, (DCL_CTRL_DATA_T *)&chr_det_status);
     
    return (kal_bool)chr_det_status.enable;
}
コード例 #7
0
ファイル: bmtutil.c プロジェクト: WayWingsDev/testmywatch
void bmt_sw_polling_ov(void *timer_param)
{

	PMU_CTRL_CHR_GET_VCDT_HV_DET chr_hv_det;
		
	DclPMU_Control(bmt_PmuHandler, CHR_GET_VCDT_HV_DET, (DCL_CTRL_DATA_T *)&chr_hv_det);

	if (chr_hv_det.HV_deteted)
	{
		drv_trace0(TRACE_GROUP_10, BMT_SW_POLLING_CHARGER_OV_TRC);
		BMT_Charge(KAL_FALSE);
	}
	else
	{	
		DclPMU_Control(bmt_PmuHandler, CHR_SET_WDT_CLEAR, NULL);
	}	

	kal_set_timer(bmt_sw_polling_timerId, (kal_timer_func_ptr)bmt_sw_polling_ov, NULL,43 ,	0); //200ms
}
コード例 #8
0
kal_bool pmic_adpt_charge_source(void)
{
	DCL_HANDLE handle;
	PMU_CTRL_CHR_GET_CHR_DET_STATUS chrStatus;
	handle=DclPMU_Open(DCL_PMU, FLAGS_NONE);
	DclPMU_Control(handle, CHR_GET_CHR_DET_STATUS, (DCL_CTRL_DATA_T *)&chrStatus);
	DclPMU_Close(handle);

	return (kal_bool)chrStatus.enable;

}
コード例 #9
0
ファイル: bmtutil.c プロジェクト: WayWingsDev/testmywatch
void bmt_find_and_set_the_nearest_charger_high_voltage(DCL_UINT32 voltage)
{
	PMU_CTRL_CHR_GET_HV_DETECTION_VOLTAGE_LIST hv_voltage_list;
	PMU_CTRL_CHR_SET_HV_DETECTION_VOLTAGE hv_voltage;
	DCL_STATUS  status;
	
	status=DclPMU_Control(bmt_PmuHandler, CHR_GET_HV_DETECTION_VOLTAGE_LIST, (DCL_CTRL_DATA_T *)&hv_voltage_list);

	if(status==STATUS_UNSUPPORTED)
	{
		drv_trace1(TRACE_GROUP_10, BMT_PMU_DO_NOT_SUPPORT_TRC, 0);
		return;
	}

	hv_voltage.voltage=(PMU_VOLTAGE_ENUM)bmt_find_closest_level(hv_voltage_list.pVoltageList
		,hv_voltage_list.number,(DCL_UINT32)voltage);
	
	DclPMU_Control(bmt_PmuHandler, CHR_SET_HV_DETECTION_VOLTAGE, (DCL_CTRL_DATA_T *)&hv_voltage);

}
コード例 #10
0
ファイル: bmtutil.c プロジェクト: WayWingsDev/testmywatch
kal_bool bmt_check_if_bat_on(void)
{
	
	PMU_CTRL_CHR_GET_IS_BATTERY_ON chr;
    
	
	DclPMU_Control(bmt_PmuHandler, CHR_GET_IS_BATTERY_ON, (DCL_CTRL_DATA_T *)&chr);
	
    
	return (kal_bool)chr.enable;
}
コード例 #11
0
ファイル: bmtutil.c プロジェクト: WayWingsDev/testmywatch
void bmt_find_and_set_the_nearest_current(PMU_CHR_CURRENT_ENUM SetCurrent)
{
	
	PMU_CTRL_CHR_GET_CHR_CURRENT_LIST get_chr_current_list;
	PMU_CTRL_CHR_SET_CHR_CURRENT set_chr_current;
	DCL_STATUS  status;
	
	status=DclPMU_Control(bmt_PmuHandler, CHR_GET_CHR_CURRENT_LIST, (DCL_CTRL_DATA_T *)&get_chr_current_list);

	if(status==STATUS_UNSUPPORTED)
	{
		drv_trace1(TRACE_GROUP_10, BMT_PMU_DO_NOT_SUPPORT_TRC, 1);
		return;
	}

	set_chr_current.current=(PMU_CHR_CURRENT_ENUM)bmt_find_closest_level(get_chr_current_list.pCurrentList
		,get_chr_current_list.number,(DCL_UINT32)SetCurrent);

	drv_trace1(TRACE_GROUP_10, BMT_FIND_AND_SET_THE_NEAREST_CURRENT_TRC, set_chr_current.current);
	DclPMU_Control(bmt_PmuHandler, CHR_SET_CHR_CURRENT, (DCL_CTRL_DATA_T *)&set_chr_current);
}
コード例 #12
0
ファイル: ft_fnc_util.c プロジェクト: WayWingsDev/testmywatch
void ft_util_get_vpa_voltage_list(const FT_UTILITY_COMMAND_REQ *req, FT_UTILITY_COMMAND_CNF *cnf, peer_buff_struct **peer_buff_ret)
{
    DCL_HANDLE handle;
    PMU_CTRL_VPA_GET_VOLTAGE_LIST voltageList;
    handle=DclPMU_Open(DCL_PMU, FLAGS_NONE);
    if(DclPMU_Control(handle, VPA_GET_VOLTAGE_LIST, (DCL_CTRL_DATA_T *)&voltageList) != STATUS_OK)
    {
        cnf->status = FT_CNF_FAIL;
    }
    else
    {
        cnf->status = FT_CNF_OK;
    }
    DclPMU_Close(handle);
    if(cnf->status == FT_CNF_OK)
    {
        if( NULL != (*peer_buff_ret=construct_peer_buff(sizeof(FtUtilCmdCnfVpaVoltageList), 0, 0, TD_CTRL)) )
        {
            kal_uint32 i;
            FtUtilCmdCnfVpaVoltageList * pdu_ptr = get_pdu_ptr( *peer_buff_ret, &((*peer_buff_ret)->pdu_len) );
            if(pdu_ptr != NULL)
            {
                kal_mem_set(pdu_ptr, 0, sizeof(FtUtilCmdCnfVpaVoltageList));
                for(i=0;i<voltageList.number;i++)
                {
                    /******************************************************
                     * if the voltage is valid, pass the information to PC
                     *****************************************************/
                    if(voltageList.pVoltageList[i] != PMU_VOLT_INVALID)
                    {
                        pdu_ptr->voltageList[pdu_ptr->validNumber]   = voltageList.pVoltageList[i];
                        pdu_ptr->registerValue[pdu_ptr->validNumber] = i;
                        pdu_ptr->validNumber++;
                    }
                }
            }
            else
            {
                ASSERT(pdu_ptr);
            }
        }
        else
        {
            ASSERT(0);
        }
    }
}
コード例 #13
0
/**
 * This function calls Dcl PMU interface to read PMIC register
 * @param data the register value to be written to PMIC
 * @param register_index the index of the register to be written
 */
kal_bool ft_pmic_reg_write(kal_uint16 data, kal_uint16 register_index)
{
    kal_bool status;
    DCL_HANDLE handle;
    PMU_CTRL_MISC_SET_REGISTER_VALUE val;
    val.offset=register_index;
    val.value=data;
    handle=DclPMU_Open(DCL_PMU, FLAGS_NONE);
    if(DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&val) != STATUS_OK)
    {
        // in this case, there might be not supported (if the driver did not support yet, usually in development phase)
        status = KAL_FALSE;
    }
    else
    {
        status = KAL_TRUE;
    }
    DclPMU_Close(handle);
    return status;
}
コード例 #14
0
// called by DclPW
CHR_DET_TYPE_ENUM Dcl_Chr_Det_is_charger_usb_present(void)
{
	PMU_CTRL_CHR_GET_CHR_DET_STATUS val;
	CHR_DET_TYPE_ENUM state = PW_NO_CHR;
	DclPMU_Control(chrDet_PmuHandler, CHR_GET_CHR_DET_STATUS, (DCL_CTRL_DATA_T *)&val);

	if (val.enable==DCL_TRUE)
	{
		#if defined (__CHARGER_USB_DETECT_WIHT_ONE_EINT__)
			if (chr_usb_det_mgr.pw_is_charger_usb_det != NULL)
			{
				state = chr_usb_det_mgr.pw_is_charger_usb_det();
			}
		#else
				state = PW_AC_CHR;
		#endif

	}

	return state;
}
コード例 #15
0
ファイル: usbdl_pmu.c プロジェクト: WayWingsDev/testmywatch
/*************************************************************************
* FUNCTION
*	BL_Raise_Charger_Current
*
* DESCRIPTION
*	if charger is present and battery voltage is low (VBAT_CC_DET is false) , start charging to avoid shutdown before maui
*
* PARAMETERS
*	None
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void BL_Raise_Charger_Current(void)
{
#if defined(__BMT_2_0_ARCHITECTURE__)

	DCL_BOOL chr_det_status = DCL_FALSE;
	DCL_BOOL vbat_cc_det_status = DCL_FALSE;
	DCL_BOOL enable = DCL_TRUE;
	PMU_CHR_CURRENT_ENUM set_charging_current = PMU_CHARGE_CURRENT_500_00_MA;



	bl_chr_control_handler(BMT_BL_CHARGING_CMD_GET_CC_STATUS, &vbat_cc_det_status);
	bl_chr_control_handler(BMT_BL_CHARGING_CMD_GET_CHR_DET_STATUS, &chr_det_status);


	if (vbat_cc_det_status == DCL_FALSE && chr_det_status == DCL_TRUE)
	{
		// find the nearest current
		bl_chr_control_handler(BMT_BL_CHARGING_CMD_GET_CHARGING_CURRENT, &set_charging_current);

		// set the current
		bl_chr_control_handler(BMT_BL_CHARGING_CMD_SET_CHARGING_CURRENT, &set_charging_current);		

		bl_chr_control_handler(BMT_BL_CHARGING_CMD_SET_CSDAC_ENABLE, &enable);		

		bl_chr_control_handler(BMT_BL_CHARGING_CMD_SET_CHR_ENABLE, &enable);		
	}
#else
	DCL_HANDLE pmu_handle;
	PMU_CTRL_CHR_SET_CHR_EN CtrlChrEn;
	PMU_CTRL_CHR_GET_CHR_CURRENT_LIST get_chr_current_list;
	PMU_CTRL_CHR_SET_CHR_CURRENT set_chr_current;
	PMU_CTRL_CHR_SET_CSDAC_EN chr_csdac_en;
	PMU_CTRL_CHR_GET_CC_DET ChrCcDet;
	PMU_CTRL_CHR_GET_CHR_DET_STATUS chrStatus;
	kal_int32 i;

	DclPMU_Initialize();

	pmu_handle = DclPMU_Open(DCL_PMU, FLAGS_NONE);

	DclPMU_Control(pmu_handle, CHR_GET_CC_DET, (DCL_CTRL_DATA_T *)&ChrCcDet);
	DclPMU_Control(pmu_handle, CHR_GET_CHR_DET_STATUS, (DCL_CTRL_DATA_T *)&chrStatus);


	if (ChrCcDet.vbat_cc_det == DCL_FALSE && chrStatus.enable == DCL_TRUE)
	{
		// 找接近電流檔位
		{
			DclPMU_Control(pmu_handle, CHR_GET_CHR_CURRENT_LIST, (DCL_CTRL_DATA_T *)&get_chr_current_list);

			for(i = (get_chr_current_list.number - 1); i >=0; i--)
			{
				if(get_chr_current_list.pCurrentList[i] <= PMU_CHARGE_CURRENT_500_00_MA)
				{
					set_chr_current.current = (PMU_CHR_CURRENT_ENUM)get_chr_current_list.pCurrentList[i];
					break;
				}    
			}

			if(i <= 0)
			{
				set_chr_current.current = (PMU_CHR_CURRENT_ENUM)get_chr_current_list.pCurrentList[0];
			}

			DclPMU_Control(pmu_handle, CHR_SET_CHR_CURRENT, (DCL_CTRL_DATA_T *)&set_chr_current);
		
		}
		
		chr_csdac_en.enable = DCL_TRUE;
		DclPMU_Control(pmu_handle, CHR_SET_CSDAC_EN, (DCL_CTRL_DATA_T *)&chr_csdac_en);		  

		CtrlChrEn.enable = DCL_TRUE;
		DclPMU_Control(pmu_handle, CHR_SET_CHR_EN, (DCL_CTRL_DATA_T *)&CtrlChrEn);
	}

	DclPMU_Close(pmu_handle);   


#endif
	
}
コード例 #16
0
ファイル: drv_comm.c プロジェクト: WayWingsDev/testmywatch
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

}
コード例 #17
0
DCL_STATUS gpio_15_segment_led_control(kal_uint8 word1, kal_uint8 word2)
{
#if defined(DRV_GPIO_FOR_LED_AND_15_SEGMENT)
	kal_uint32 savedMask;
	DCL_HANDLE handle;
	PMU_CTRL_LDO_BUCK_SET_EN val;
	PMU_CTRL_LDO_BUCK_SET_VOLTAGE val1;
	val1.voltage = PMU_VOLT_02_800000_V;
	val1.mod = VMC;
	handle = DclPMU_Open(DCL_PMU,FLAGS_NONE);
	DclPMU_Control(handle, LDO_BUCK_SET_VOLTAGE,(DCL_CTRL_DATA_T *)&val1);

	val.enable = DCL_TRUE;
	val.mod = VMC;
	DclPMU_Control(handle, LDO_BUCK_SET_EN,(DCL_CTRL_DATA_T *)&val);
	DclPMU_Close(handle);
	if(debug1_Handle == 0 || debug2_Handle == 0 || debug3_Handle == 0 || debug4_Handle == 0)
	{
		debug1_Handle = DclGPIO_Open(DCL_GPIO,62);
		debug2_Handle = DclGPIO_Open(DCL_GPIO,63);
		debug3_Handle = DclGPIO_Open(DCL_GPIO,64);
		debug4_Handle = DclGPIO_Open(DCL_GPIO,65);
	}
	if(fifteen_segment_timer == NULL)
		fifteen_segment_timer = kal_create_timer("15_segment_TIMER");
	
	switch(word1)
	{
		case '2':
		{
			savedMask = SaveAndSetIRQMask();
			word_to_display = char_to_display_table1;
			table_count = 6;
			RestoreIRQMask(savedMask);
			kal_set_timer(fifteen_segment_timer,(kal_timer_func_ptr) gpio_15_segment_display, NULL, 1, 1);
			break;
		}
		case '3':
		{
			if(word2 == 1)
			{
				savedMask = SaveAndSetIRQMask();
				word_to_display = char_to_display_table7;
				table_count = 7;
				RestoreIRQMask(savedMask);
				kal_set_timer(fifteen_segment_timer,(kal_timer_func_ptr) gpio_15_segment_display, NULL, 1, 1);
			}
			else
			{
				savedMask = SaveAndSetIRQMask();
				word_to_display = char_to_display_table6;
				table_count = 6;
				RestoreIRQMask(savedMask);
				kal_set_timer(fifteen_segment_timer, (kal_timer_func_ptr)gpio_15_segment_display,NULL, 1, 1);
			}
			break;
		}
		case '6':
		{
			if(word2 == 1)
				{
				savedMask = SaveAndSetIRQMask();
				word_to_display = char_to_display_table3;
				table_count = 8;
				RestoreIRQMask(savedMask);
				kal_set_timer(fifteen_segment_timer, (kal_timer_func_ptr)gpio_15_segment_display, NULL, 1, 1);
				}
			else
				{
				savedMask = SaveAndSetIRQMask();
				word_to_display = char_to_display_table2;
				table_count = 7;
				RestoreIRQMask(savedMask);
				kal_set_timer(fifteen_segment_timer,(kal_timer_func_ptr) gpio_15_segment_display, NULL, 1, 1);
				}
			break;
		}
		case 'd':
		{
			savedMask = SaveAndSetIRQMask();
			word_to_display = char_to_display_table12;
			table_count = 7;
			RestoreIRQMask(savedMask);
			kal_set_timer(fifteen_segment_timer,(kal_timer_func_ptr) gpio_15_segment_display, NULL, 1, 1);
			break;
		}
		case 'E':
		{
			if(word2 == 1)
				{
				savedMask = SaveAndSetIRQMask();
				word_to_display = char_to_display_table5;
				table_count = 7;
				RestoreIRQMask(savedMask);
				kal_set_timer(fifteen_segment_timer, (kal_timer_func_ptr)gpio_15_segment_display, NULL, 1, 1);
				}
			else
				{
				savedMask = SaveAndSetIRQMask();
				word_to_display = char_to_display_table4;
				table_count = 6;
				RestoreIRQMask(savedMask);
				kal_set_timer(fifteen_segment_timer,(kal_timer_func_ptr) gpio_15_segment_display, NULL, 1, 1);
				}
			break;
		}
		case 'h':
		{
			if(word2 == 1)
				{
				savedMask = SaveAndSetIRQMask();
				word_to_display = char_to_display_table9;
				table_count = 6;
				RestoreIRQMask(savedMask);
				kal_set_timer(fifteen_segment_timer, (kal_timer_func_ptr)gpio_15_segment_display, NULL, 1, 1);
				}
			else
				{
				savedMask = SaveAndSetIRQMask();
				word_to_display = char_to_display_table8;
				table_count = 5;
				RestoreIRQMask(savedMask);
				kal_set_timer(fifteen_segment_timer, (kal_timer_func_ptr)gpio_15_segment_display, NULL, 1, 1);
				}
			break;
		}
		case 'H':
		{
			if(word2 == 1)
				{
				savedMask = SaveAndSetIRQMask();
				word_to_display = char_to_display_table11;
				table_count = 7;
				RestoreIRQMask(savedMask);
				kal_set_timer(fifteen_segment_timer, (kal_timer_func_ptr)gpio_15_segment_display, NULL, 1, 1);
				}
			else
				{
				savedMask = SaveAndSetIRQMask();
				word_to_display = char_to_display_table10;
				table_count = 6;
				RestoreIRQMask(savedMask);
				kal_set_timer(fifteen_segment_timer,(kal_timer_func_ptr) gpio_15_segment_display, NULL, 1, 1);
				}
			break;
		}
		case 'I':
		{
			savedMask = SaveAndSetIRQMask();
			word_to_display = char_to_display_table17;
			table_count = 4;
			RestoreIRQMask(savedMask);
			kal_set_timer(fifteen_segment_timer, (kal_timer_func_ptr)gpio_15_segment_display, NULL, 1, 1);
			break;
		}
		case 'L':
		{
			savedMask = SaveAndSetIRQMask();
			word_to_display = char_to_display_table15;
			table_count = 3;
			RestoreIRQMask(savedMask);
			kal_set_timer(fifteen_segment_timer,(kal_timer_func_ptr) gpio_15_segment_display, NULL, 1, 1);
			break;
		}
		case 'N':
		{
			savedMask = SaveAndSetIRQMask();
			word_to_display = char_to_display_table16;
			table_count = 6;
			RestoreIRQMask(savedMask);
			kal_set_timer(fifteen_segment_timer,(kal_timer_func_ptr) gpio_15_segment_display, NULL, 1, 1);
			break;
		}
		case 'X':
		{
			savedMask = SaveAndSetIRQMask();
			word_to_display = char_to_display_table13;
			table_count = 4;
			RestoreIRQMask(savedMask);
			kal_set_timer(fifteen_segment_timer,(kal_timer_func_ptr) gpio_15_segment_display, NULL, 1, 1);
			break;
		}
		case 0:
		{
			kal_cancel_timer(fifteen_segment_timer);
			DclGPIO_Control(debug1_Handle,GPIO_CMD_WRITE_HIGH,0);
			DclGPIO_Control(debug2_Handle,GPIO_CMD_WRITE_HIGH,0);
			DclGPIO_Control(debug3_Handle,GPIO_CMD_WRITE_HIGH,0);
			DclGPIO_Control(debug4_Handle,GPIO_CMD_WRITE_HIGH,0);
			break;
		}
		default:
		{
			ASSERT(0);
			return STATUS_INVALID_CTRL_DATA;
		}
	}

	return STATUS_OK;
#else
	return STATUS_FAIL;
#endif
}
コード例 #18
0
DCL_STATUS gpio_led_control(LED_NUM led_num, LED_CTRL_CMD cmd, kal_uint16 freq)
{
	#if defined(DRV_GPIO_FOR_LED_AND_15_SEGMENT)
	DCL_HANDLE handle;
	PMU_CTRL_LDO_BUCK_SET_EN val;
	PMU_CTRL_LDO_BUCK_SET_VOLTAGE val1;
	val1.voltage = PMU_VOLT_02_800000_V;
	val1.mod = VMC;
	handle = DclPMU_Open(DCL_PMU,FLAGS_NONE);
	DclPMU_Control(handle, LDO_BUCK_SET_VOLTAGE,(DCL_CTRL_DATA_T *)&val1);

	val.enable = DCL_TRUE;
	val.mod = VMC;
	DclPMU_Control(handle, LDO_BUCK_SET_EN,(DCL_CTRL_DATA_T *)&val);
	DclPMU_Close(handle);
	#endif
	
	#if defined(GPIO_NUMBER_FOR_LED1)
	if(led1_handle == 0)
	{
		ASSERT(0);
	}
	#endif
	
	#if defined(GPIO_NUMBER_FOR_LED2)
	if(led2_handle == 0)
	{
		ASSERT(0);
	}
	#endif
	switch(cmd)
	{
		case LED_CMD_FLICKER:
		{
			if(led_num == GPIO_LED1)
				{
				
				kal_set_timer(led1_timer, (kal_timer_func_ptr)led1_flicker, NULL, freq, freq);
				}
			else
				{
			
				kal_set_timer(led2_timer, (kal_timer_func_ptr)led2_flicker, NULL, freq, freq);
				}
			
			
			break;
		}
		case LED_CMD_DIMMING:
		{
			led_Dimming(led_num);//always diming
			break;
		}
		case LED_CMD_BRIGHTING:
		{
			led_brighting(led_num);//always lighting
			break;
		}
		default:
		{
            ASSERT(0);
            return STATUS_INVALID_CMD;
		}
	}
	return STATUS_OK;
}
void PMIC_AudioConfig(void)
{
	kal_uint32 addr;
	kal_uint16 data;
	DCL_HANDLE handle;
	PMU_CTRL_MISC_SET_REGISTER_VALUE setVal;
	PMU_CTRL_MISC_GET_REGISTER_VALUE getVal;
	
	setVal.offset = (0<<31) | addr; 
	setVal.value = data; 

	handle = DclPMU_Open(DCL_PMU, FLAGS_NONE);

	// 	0x0102 bit[0] to be 1, eable clock source	
	getVal.offset = ((0<<31) | 0x0102); 
	DclPMU_Control(handle, MISC_GET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&getVal);
	setVal.value = (getVal.value | 0x0001);
	setVal.offset = ((0<<31) | 0x0102); 
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	// 	0x010C 0x0100 0x0100 Turn on clock, [OK]
	getVal.offset = ((0<<31) | 0x010C); 
	DclPMU_Control(handle, MISC_GET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&getVal);
	setVal.value = (getVal.value | 0x0100);
	setVal.offset = ((0<<31) | 0x010C); 
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	// 	0x4024 0xffff 0x3330	DL Sampline rate config [check]
	setVal.offset = ((0<<31) | 0x4024); 
	setVal.value = (0x3330);
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	// 0x4028 0xffff 0x342F UL Sampline rate config	[check]	
	setVal.offset = ((0<<31) | 0x4028); 
	setVal.value = (0x342F);
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);
	
	// 0x4002	0xffff 0x0004 may need to check for dl 16K UL 16K [check]
	setVal.offset = ((0<<31) | 0x4002); 
	setVal.value = (0x0004);
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	// 0x4016 	triger dl 1 read it out then write back 
	getVal.offset = ((0<<31) | 0x4016); 
	DclPMU_Control(handle, MISC_GET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&getVal);
	setVal.value = ((~((getVal.value)<< 8)) & 0x0300);
	setVal.offset = ((0<<31) | 0x4016); 
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);
	
	// 	0x4000 0xffff 0x0003 this is for turn on	
	setVal.offset = ((0<<31) | 0x4000); 
	setVal.value = (0x0003);
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	// 	0x0700 0xffff 0x79B0 MIC 0	
	setVal.offset = ((0<<31) | 0x0700); 
	setVal.value = (0x79B0);
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	// 	0x0702 0xffff 0x0210 MIC 1	[ok]
	setVal.offset = ((0<<31) | 0x0702); 
	setVal.value = (0x0210);
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	// 	0x0704 0xffff 0x00F3 UL	
	setVal.offset = ((0<<31) | 0x0704); 
	setVal.value = (0x00F3);
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	setVal.offset = ((0<<31) | 0x0710);  // add
	setVal.value = (0x0208);
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);
	
	// 0x070E 0xffff 0x2400 DL turn on
	setVal.offset = ((0<<31) | 0x070E); 
	setVal.value = (0x2400);
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);
	
	// 0x0708 0xffff 0x0014 DL turn on // add
	setVal.offset = ((0<<31) | 0x0708); 
	setVal.value = (0x007C);
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	// 0x0708 0xffff 0x0014 DL turn on // add
	setVal.offset = ((0<<31) | 0x070A); 
	setVal.value = (0x2214);
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	// 0x070C	0xffff 0xB7F6 DL turn on // check
	setVal.offset = ((0<<31) | 0x070C); 
	setVal.value = (0xF5BA);
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	// 0x070E 0xffff 0x2500 DL turn on
	setVal.offset = ((0<<31) | 0x070E); 
	setVal.value = (0x2500);
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	// 0x070E 0xffff 0x25B0 DL turn on
	setVal.offset = ((0<<31) | 0x070E); 
	setVal.value = (0x25B0);
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	setVal.offset = ((0<<31) | 0x402c);  // loopback
	setVal.value = (0x4000);
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);
	
	DclPMU_Close(handle);
}
コード例 #20
0
/*
* FUNCTION
*	   CHRDET_HISR
*
* DESCRIPTION
*   	This function is the interrupt handler for EINT1
*
* CALLS
*
* PARAMETERS
*	   None
*
* RETURNS
*	   None
*
* GLOBALS AFFECTED
*     None
*/
void CHRDET_HISR(void)
{
	#ifndef __DRV_NO_USB_CHARGER__
	extern void bmt_charger_action(kal_bool in);
	#endif /*__DRV_NO_USB_CHARGER__*/
	kal_uint32 state;
	#if defined(PMIC_6326_REG_API)
	static kal_bool chr_status = KAL_FALSE;
	#endif // #if defined(PMIC_6326_REG_API)

#if defined(PMIC_6326_REG_API)

	{
		PMU_CTRL_CHR_GET_CHR_DET_STATUS chrStatus;
		DclPMU_Control(chrDet_PmuHandler, CHR_GET_CHR_DET_STATUS, (DCL_CTRL_DATA_T *)&chrStatus);
		DclPMU_Close(chrDet_PmuHandler);
	

		if (chr_status == chrStatus.enable){
			#if ( (!defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__)) && defined(PMIC_6326_REG_API) )
			#if (!defined(__DRV_EXT_CHARGER_DETECTION__))
			EINT_UnMask(gCHRDET_EINT_NO);
			#endif // #if (!defined(__DRV_EXT_CHARGER_DETECTION__))
			#endif // #if ( (!defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__)) && defined(PMIC_6326_REG_API) )
			return;
		}
	}
	
	chr_status =(kal_bool)(!((kal_uint8)chr_status));
	if (chr_status == KAL_TRUE){
		state = DETECTCHRIN;
	}else{
		state = DETECTCHROUT;
	}
	// Should PMIC6326 update the flag?
	BMT.EINT2STATE = !state;

#else // #if defined(PMIC_6326_REG_API)

	BMT.EINT2STATE = !BMT.EINT2STATE;
	#if (!defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__) )
	#if (!defined(__DRV_EXT_CHARGER_DETECTION__))
	chrdet_level_config(BMT.EINT2STATE);
	#endif // #if (!defined(__DRV_EXT_CHARGER_DETECTION__))
	#endif // #if ( (!defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__)) && ( defined(PMIC_6305_REG_API) || defined(PMIC_6223_REG_API)|| defined(PMIC_6238_REG_API) || defined(PMIC_6253_REG_API) || defined(PMIC_6236_REG_API) || defined(PMIC_6251_REG_API)) )
	state = !BMT.EINT2STATE;

#endif // #if defined(PMIC_6326_REG_API)


	if (state == DETECTCHRIN)
	{
		//DclPMU_Control(chrDet_PmuHandler, CHR_SET_CV_DETECTION_VOLTAGE_CALIBRATION, NULL);	
		#ifdef BMT_DEBUG
		dbg_printWithTime("CHARGER_PLUGIN\r\n");
		#endif // #ifdef BMT_DEBUG
		#if defined(__DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__)
		BMT_VbatInHISR(); //save current vbat, otherwise turn on LCD backlight may cause VBAT decrease.
		#endif //#if defined(__DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__)
		bmt_set_chr_status(bmt_chr_in);
		#ifndef __DRV_NO_USB_CHARGER__
		bmt_charger_action(KAL_TRUE);
		#endif // #ifndef __DRV_NO_USB_CHARGER__
	}
	else
	{
		#ifdef BMT_DEBUG
		dbg_printWithTime("CHARGER_PLUGOUT\r\n");
		#endif // #ifdef BMT_DEBUG
		bmt_set_chr_status(bmt_chr_out);
		#ifndef __DRV_NO_USB_CHARGER__
		bmt_charger_action(KAL_FALSE);
		#endif // #ifndef __DRV_NO_USB_CHARGER__
	}

	#if ( (!defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__))  )
	#if (!defined(__DRV_EXT_CHARGER_DETECTION__))
	EINT_UnMask(gCHRDET_EINT_NO);
	#endif // #if (!defined(__DRV_EXT_CHARGER_DETECTION__))
	#endif // #if ( (!defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__))  )

}
コード例 #21
0
ファイル: bmtutil.c プロジェクト: WayWingsDev/testmywatch
/*
* FUNCTION
*	   bmt_charge_start
*
* DESCRIPTION                                                           
*   	This function is to start charging algorithm.
*
* CALLS  
*
* PARAMETERS
*	   None
*	
* RETURNS
*	   None
*
* GLOBALS AFFECTED
*     None
*/
void bmt_charge_start(void)
{
#if defined(__EVB__) && defined(__MTK_INTERNAL__)
/* under construction !*/
#elif defined(__DRV_BMT_NO_CHARGING__)
   return;
#else //#if defined(__EVB__)
  
#if defined(__DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__)
	double adc;
#endif //#if defined(__DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__)
    DCL_STATUS adc_status;
	ADC_CTRL_MODIFY_PARAM_T adc_para;   
#if defined(MT6236) || defined(MT6252)
   
  	PMU_CTRL_CHR_SET_CHR_CURRENT set_chr_current;
#endif

//#ifdef __DRV_BMT_SW_POLLING_CHARGER_OV__
//	kal_set_timer(bmt_sw_polling_timerId, (kal_timer_func_ptr)bmt_sw_polling_ov, NULL,43 ,	0);
//#endif //#ifdef __DRV_BMT_SW_POLLING_CHARGER_OV__


   BMT_Charge(KAL_FALSE);
   BMT.pmictrl_state = PMIC_CHARGEOFF;
#if defined(__DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__)
	if(g_battery_pre_voltage == 0)
	  BMT_Current_Voltage(DCL_VBAT_ADC_CHANNEL, &g_battery_pre_voltage,&adc);
	BMT.bat_state = CHR_PRE_FULL_CHECK;
#else //defined(__DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__)
   BMT.bat_state = CHR_PRE;
#endif //defined(__DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__)
   BMT.VBAT_UEM= VBAT_UEM_CHR_IN_FISRT;
   low_charger_count = 0;
   low_current_count = 0;
   low_temper_count = 0;
   over_temper_count = 0;
#if defined(DRV_BMT_HW_PRECC_WORKAROUND)
    SW_Workaround_Flag = KAL_TRUE;
    HW_Plug_Status = bmt_chr_uninit; 
    Manual_Disable_Charge_Flag = KAL_FALSE;
#endif
#if defined(DRV_BMT_HIGH_VCHG_ADAPTIVE_CHARGE_CURRENT_SUPPORT)
   First_Time_Charge_Enable = KAL_TRUE;
   bmt_high_vchg_current = 0xFFFFFFF;
   Pre_VCharge_AVG = 0;
   Cur_VCharge_MAX = 0;
#endif

   
	bmt_enable_sleepmode(KAL_FALSE);

 //  #ifdef MTK_SLEEP_ENABLE
 //  L1SM_SleepDisable(bmt_sm_handle);
 //  #endif
		

      adc_para.u4Period = 1;
	  adc_para.u1EvaluateCount = 1;
	  adc_status = DclSADC_Control(bmt_adc_handle, ADC_CMD_MODIFY_PARAM, (DCL_CTRL_DATA_T *)&adc_para);
	  if(adc_status != STATUS_OK)
	  {
			ASSERT(0);
	  }   	
	 
	  adc_status = DclSADC_Control(bmt_adc_handle, ADC_CMD_START_MEASURE, NULL);
	  if(adc_status != STATUS_OK)
	  {
			ASSERT(0);  		
	  }	      
	
#ifdef __BMT_CHARGE_GUARD_TIME__
	bmt_set_guardtimer(KAL_TICKS_1_MIN*BMT_CHARGE_GUARD_TIME_PERIOD);
	drv_trace2(TRACE_GROUP_10, BMT_SAFETY_AND_GUARD_TIMER_START_TRC, BMT_TOTAL_CHARGE_TIME, BMT_CHARGE_GUARD_TIME_PERIOD);
#else // __BMT_CHARGE_GUARD_TIME__

#if defined(DRV_BMT_HIGH_VCHG_ADAPTIVE_CHARGE_CURRENT_SUPPORT)
    bmt_safety_timer_config = KAL_FALSE;
#else
	stack_start_timer(&ChargeTimeout_timer, 0, KAL_TICKS_1_MIN*BMT_TOTAL_CHARGE_TIME);
	drv_trace1(TRACE_GROUP_10, BMT_SAFETY_TIMER_START_TRC, BMT_TOTAL_CHARGE_TIME);
	SaftyTimer_Flag = BMT_SAFETY_TIMER_ON; 
#endif //#if defined(DRV_BMT_HIGH_VCHG_ADAPTIVE_CHARGE_CURRENT_SUPPORT)

#endif // __BMT_CHARGE_GUARD_TIME__
	
   

#if defined(MT6236)  || defined(MT6252)
    
    set_chr_current.current = PMU_CHARGE_CURRENT_200_00_MA; // Pre-CC 200mA
    DclPMU_Control(bmt_PmuHandler, CHR_SET_CHR_CURRENT, (DCL_CTRL_DATA_T *)&set_chr_current);
                  
#else   
   bmt_set_chr_current();
#endif
   
   #if defined(PMIC_CHARGE_WDT)  // Defined in pmic_features.h
   bmt_charge_enable_wdt(KAL_TRUE);
   #endif // #if defined(PMIC_CHARGE_WDT)
   
   drv_trace0(TRACE_GROUP_10, BMT_CHARGING_START_TRC);
#endif//#if defined(__EVB__)
}
コード例 #22
0
void Dcl_chr_det_reg_chr_usb(void)
{

#if defined(__MAUI_BASIC__) || defined(PMIC_CHR_DETECT_NONE)
	// In Basic load, we do NOT perform cable detection, just return
	return;

#elif defined(__DRV_EXT_CHARGER_DETECTION__)

	#ifndef IC_MODULE_TEST // When module test, we don't want to perform cable detection (For saving module time)
	#if defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__)
	#if defined(__USB_ENABLE__)
	ext_charger_det->reg_usb_hisr(chr_usb_det_mgr.usb_det_hisr);
	#endif // #if defined(__USB_ENABLE__)
	#endif // #if defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__)
	ext_charger_det->reg_chr_hisr(CHRDET_HISR);
	ext_charger_det->set_chr_deb_time(40);
	ext_charger_det->enable_intr();
	#endif // #ifndef IC_MODULE_TEST // When module test, we don't want to perform cable detection (For saving module time)

	return; // Return immediately here to avoid running to original PMU setting, which may make confusion

#elif defined(PMIC_PMU_SERIES)

	#if !defined (__CHARGER_USB_DETECT_WIHT_ONE_EINT__)
	// Register gCHRDET_EINT_NO with CHRDET_HISR directly
	EINT_SW_Debounce_Modify(gCHRDET_EINT_NO, 40); // Set de-bounce time
	#if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_HIGH)
	EINT_Registration(gCHRDET_EINT_NO, KAL_TRUE, LEVEL_HIGH, CHRDET_HISR, KAL_FALSE);
	#endif //defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_HIGH)
	#if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_LOW)
	EINT_Registration(gCHRDET_EINT_NO, KAL_TRUE, LEVEL_LOW, CHRDET_HISR, KAL_FALSE);
	#endif //defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_LOW)
	#endif // #if !defined (__CHARGER_USB_DETECT_WIHT_ONE_EINT__)

	#if defined (__CHARGER_USB_DETECT_WIHT_ONE_EINT__)
	#ifndef IC_MODULE_TEST // When module test, we don't want to perform cable detection (For saving module time)
	EINT_SW_Debounce_Modify(chr_usb_detect.chr_usb_eint, 40); // Set de-bounce time
	#if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_HIGH)
	EINT_Registration(chr_usb_detect.chr_usb_eint, KAL_TRUE, LEVEL_HIGH, CHR_USB_EINT_HISR, KAL_FALSE);
	#endif //defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_HIGH)
	#if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_LOW)
	EINT_Registration(chr_usb_detect.chr_usb_eint, KAL_TRUE, LEVEL_LOW, CHR_USB_EINT_HISR, KAL_FALSE);
	#endif //defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_LOW)
		#endif // #ifndef IC_MODULE_TEST
	#endif // #if defined (__CHARGER_USB_DETECT_WIHT_ONE_EINT__)

	{
	#ifndef IC_MODULE_TEST // When module test, we don't want to perform cable detection (For saving module time)
		PMU_CTRL_CHR_GET_CHR_DET_STATUS chrStatus;
		DclPMU_Control(chrDet_PmuHandler, CHR_GET_CHR_DET_STATUS, (DCL_CTRL_DATA_T *)&chrStatus);
		
		if (chrStatus.enable==DCL_TRUE)
		{
	#if !defined (__CHARGER_USB_DETECT_WIHT_ONE_EINT__)
			CHRDET_HISR();
	#else
            chr_usb_detect.chr_usb_state = KAL_FALSE;
			CHR_USB_EINT_HISR();
	#endif //#if !defined (__CHARGER_USB_DETECT_WIHT_ONE_EINT__)
		}
	#endif	
	}
	


#elif defined(PMIC_PMIC_SERIES)
	/*PMIC uses charger's interrupt*/
	#if defined(PMIC_6326_REG_API)
	#if !defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__)
	// TTTTTTTTT
	dcl_pmic6326_ChrDet_Registration(AC_CHR, CHRDET_HISR);
	EINT_SW_Debounce_Modify(gCHRDET_EINT_NO, 40);
	/*lint -e64*/
	EINT_Registration(gCHRDET_EINT_NO,KAL_TRUE,LEVEL_HIGH,dcl_pmic6326_HISR, KAL_FALSE);
	/*lint +e64*/
	#endif // #if !defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__)

	#if defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__)
	dcl_pmic6326_ChrDet_Registration(AC_CHR_CALLBACK, CHR_USB_EINT_HISR);
	// PMIC6326 can only detect chr in, can NOT distinguish Charger or USB
	//if (pmic_is_chr_det(AC_CHR)){
	// TTTTTTTTTTTTTTTTTTTTTTTTT
	chr_usb_detect.chr_usb_state = KAL_FALSE;
	// If we nsert USB cable and serviced the intr, then re-boot device
	// PMIC6326 won't assert intr because the cable status is NOT changed
	// Then we need to check the cable status at boot time
	// If cable is inserted, we manually call HISR to handle
	if (dcl_pmic6326_chrdet_status()){
		//PMIC_CHRDET.pmic_ac_det();
		dcl_pmic6326_HISR();
	}

	EINT_SW_Debounce_Modify(chr_usb_detect.chr_usb_eint, 40);
	//EINT_SW_Debounce_Modify(chr_usb_detect.chr_usb_eint, gDebounceTime);
	/*lint -e64*/
	EINT_Registration(chr_usb_detect.chr_usb_eint,KAL_TRUE,LEVEL_HIGH,dcl_pmic6326_HISR, KAL_FALSE);
			/*lint +e64*/
	#endif // #if !defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__)
	#endif //defined(PMIC_6326_REG_API)

#endif //#if defined(__MAUI_BASIC__) || defined(PMIC_CHR_DETECT_NONE)


}
コード例 #23
0
ファイル: bmtutil.c プロジェクト: WayWingsDev/testmywatch
// DCL PMU/PWIC Interface
void BMT_Charge(kal_bool enable)
{
#if ( !defined(__DRV_NO_CHARGER__) && !defined(__MAUI_BASIC__) )
	kal_bool data = enable;

	PMU_CTRL_CHR_SET_WDT_TIMER CtrlWdtTd;
	PMU_CTRL_CHR_SET_CHR_EN CtrlChrEn;
	PMU_CTRL_CHR_GET_CHR_DET_STATUS ctrlChrStatus;
#ifdef __MULTI_BOOT__
#ifdef __TC01__
/* under construction !*/
#endif // #ifdef __TC01__
#endif // #ifdef __MULTI_BOOT__
	
    drv_trace1(TRACE_GROUP_10, BMT_CHARGE_ENABLE_TRC, enable);


	#ifdef __MULTI_BOOT__
	#ifdef __TC01__
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
	#endif // #ifdef __TC01__
	#endif // #ifdef __MULTI_BOOT__

	#ifdef __CS_FAC_DET__
	// Check if fac det return force to IDLE
	{
		cs_fac_boot_mode_enum fac_boot_mode;
		fac_boot_mode = cs_fac_det->factory_det_get_boot_mode();
		switch (fac_boot_mode)
		{
			case CS_FAC_BOOT_IDLE:
				data = KAL_TRUE;
			    break;
			default:
			    break;
		}
	}
	#endif // #ifdef __CS_FAC_DET__
	data = KAL_FALSE;
#if 0 
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif    

	if (data==DCL_TRUE)
	{	
		DclPMU_Control(bmt_PmuHandler, CHR_SET_WDT_CLEAR, NULL);
	    CtrlWdtTd.secs=PMU_CHR_WDT_TD_32SEC;
		DclPMU_Control(bmt_PmuHandler, CHR_SET_WDT_TIMER, (DCL_CTRL_DATA_T *)&CtrlWdtTd);	
	}


#if defined(DRV_BMT_HIGH_VCHG_ADAPTIVE_CHARGE_CURRENT_SUPPORT)
		bmt_find_and_set_the_nearest_charger_high_voltage(bmt_high_vchg_para->VCHG_HV_VTH);
#else

#if defined(CHR_HW_VCHARGER_HIGH)
		bmt_find_and_set_the_nearest_charger_high_voltage(CHR_HW_VCHARGER_HIGH);
#else
		bmt_find_and_set_the_nearest_charger_high_voltage(bmt_charging_para->VCHARGER_HIGH);
#endif //#if defined(CHR_HW_VCHARGER_HIGH)

#endif

	DclPMU_Control(bmt_PmuHandler, CHR_GET_CHR_DET_STATUS, (DCL_CTRL_DATA_T *)&ctrlChrStatus);

	if (ctrlChrStatus.enable==DCL_TRUE)
	{
		CtrlChrEn.enable=enable;
		DclPMU_Control(bmt_PmuHandler, CHR_SET_CHR_EN, (DCL_CTRL_DATA_T *)&CtrlChrEn);
	}
#if defined(DRV_BMT_PULSE_CV_CHARGING)
	else
	{
		CtrlChrEn.enable=enable;
		DclPMU_Control(bmt_PmuHandler, CHR_SET_CHR_EN, (DCL_CTRL_DATA_T *)&CtrlChrEn);
	}		
#endif //#if defined(DRV_BMT_PULSE_CV_CHARGING)

	

#if defined(__PMU_WITH_EXTERNL_CHARGER__)
	{
		kal_uint32 savedMask;
		savedMask = SaveAndSetIRQMask();
		if ((kal_bool)data == KAL_TRUE)
		{
			// Set CTRL pin to LOW to enable charging
			GPIO_WriteIO(0, gpio_ext_chr_ctrl_pin);
		}
		else
		{
			// Set CTRL pin to HIGH to enable charging
			GPIO_WriteIO(1, gpio_ext_chr_ctrl_pin);
		}
		RestoreIRQMask(savedMask);
	}
#endif // #if defined(__PMU_WITH_EXTERNL_CHARGER__)

#if defined(__GENERAL_EXTERNAL_CHARGER__)
	{
		ext_charger->charge_enable((kal_bool)data);
	}
#endif // #if defined(__GENERAL_EXTERNAL_CHARGER__)


#endif // #if ( !defined(__DRV_NO_CHARGER__) && !defined(__MAUI_BASIC__) )
}
コード例 #24
0
/*************************************************************************
* FUNCTION
*	CHRDET_USB_HISR
*
* DESCRIPTION
*	1. HISR of charger and usb external interrupt
*
* PARAMETERS
*	None
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
static void CHR_USB_EINT_HISR(void)
{
#ifdef __OTG_ENABLE__
	static kal_bool g_usb_host_turn_on_vbus = KAL_FALSE;
#endif // #ifdef __OTG_ENABLE__

//#if defined(PMIC_6305_REG_API) || defined(PMIC_6318_REG_API) || defined(PMIC_6238_REG_API) || defined(PMIC_6326_REG_API) || defined(PMIC_6253_REG_API) || defined(PMIC_6236_REG_API) || defined(PMIC_6276_REG_API) || defined(PMIC_6255_REG_API)

	#if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_HIGH)
	EINT_Set_Polarity(chr_usb_detect.chr_usb_eint, (kal_bool)(chr_usb_detect.chr_usb_state));
	#endif // #if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_HIGH)

	#if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_LOW)
	EINT_Set_Polarity(chr_usb_detect.chr_usb_eint, (kal_bool)(!chr_usb_detect.chr_usb_state));
	#endif // #if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_LOW)

	#if defined(PMIC_6326_REG_API)
	//if (pmic_chrdet_status() == chr_usb_detect.chr_usb_state){
	//	ASSERT(0);	// There is problem!!!! Because whenever the program goes here, we should get invert state
	//					// In => Out => In => Out
	//}
	{
		PMU_CTRL_CHR_GET_CHR_DET_STATUS chrStatus;
		DclPMU_Control(chrDet_PmuHandler, CHR_GET_CHR_DET_STATUS, (DCL_CTRL_DATA_T *)&chrStatus);
	
		if (chrStatus.enable== chr_usb_detect.chr_usb_state)
		{
			// When the detected status is same as the current state, do nothing!
			//kal_prompt_trace(MOD_BMT,"CHRDet status is same as chr_usb_state");
			EINT_UnMask(chr_usb_detect.chr_usb_eint); // unmask eint here, otherwise it never comes interrupt again.
			//CHR_USB_EINT_Owner_SetMask(CHR_DET_EINT_OWNER_BMT); // Set owner mask flag of BMT
			//CHR_USB_EINT_UnMask(CHR_DET_EINT_OWNER_BMT); // EINT_UnMask(chr_usb_detect.chr_usb_eint);
			return;
		}
	}
	#endif // #if defined(PMIC_6326_REG_API)

	

	chr_usb_detect.chr_usb_state = (kal_bool)(!((kal_uint8)chr_usb_detect.chr_usb_state));
	if (chr_usb_detect.chr_usb_state)
	{
		//kal_prompt_trace(MOD_BMT,"CHR_USB IN");
		kal_brief_trace( TRACE_STATE,BMT_CABLE_IN_TRC);

		#ifdef __USB_UART_MULTIPLEXED_WITH_EXT_SWITCH__
		GPIO_WriteIO(1, gpio_usb_uart_switch_pin);	//switch to usb mode
		#endif

		#ifdef __OTG_ENABLE__
		{
			DCL_HANDLE  otg_dcl_handle;
			DCL_BOOL dcl_data;
			kal_bool b_is_host_on_vbus;
			otg_dcl_handle = DclOTG_DRV_Open(DCL_USB, FLAGS_NONE);
			DclOTG_DRV_Control(otg_dcl_handle, OTG_DRV_CMD_IS_HOST_TURN_ON_VBUS, (DCL_CTRL_DATA_T  *)&dcl_data);
			b_is_host_on_vbus = (kal_bool)dcl_data;
			DclOTG_DRV_Close(otg_dcl_handle);
			
			if (b_is_host_on_vbus== KAL_TRUE)
		{
			g_usb_host_turn_on_vbus = KAL_TRUE;
			// Force to unmask EINT for OTG case
			CHR_USB_EINT_UnMask(USB_DET_EINT_OWNER_FORCE_UNMASK); // EINT_UnMask(chr_usb_detect.chr_usb_eint);
			return;
		}
		}
		#endif // #ifdef __OTG_ENABLE__

		// Clear EINT owner bit mask
		CHR_USB_EINT_Owner_ClrMask();

		ASSERT(chr_usb_det_mgr.pw_is_charger_usb_det_eint != NULL);
		chr_usb_det_mgr.pw_is_charger_usb_det_eint();


	}
	else
	{

		#ifdef __USB_UART_MULTIPLEXED_WITH_EXT_SWITCH__
		GPIO_WriteIO(0, gpio_usb_uart_switch_pin);	//switch to uart mode
		#endif

		#ifdef __OTG_ENABLE__
		if (g_usb_host_turn_on_vbus == KAL_TRUE)
		{
			g_usb_host_turn_on_vbus = KAL_FALSE;
			// Force to unmask EINT for OTG case
			CHR_USB_EINT_UnMask(USB_DET_EINT_OWNER_FORCE_UNMASK); // EINT_UnMask(chr_usb_detect.chr_usb_eint);
			return;
		}
		#endif // #ifdef __OTG_ENABLE__

			CHR_USB_PLUG_OUT();
	}


}
void PMIC_AudioConfig_Loopback(void)
{
	kal_uint32 addr;
	kal_uint16 data;
	DCL_HANDLE handle;
	PMU_CTRL_MISC_SET_REGISTER_VALUE setVal;
	PMU_CTRL_MISC_GET_REGISTER_VALUE getVal;
	
	setVal.offset = (0<<31) | addr; 
	setVal.value = data; 

	handle = DclPMU_Open(DCL_PMU, FLAGS_NONE);

	// 	0x0102 bit[0] to be 1, eable clock source	
	/*
	getVal.offset = ((0<<31) | 0x0102); 
	DclPMU_Control(handle, MISC_GET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&getVal);
	setVal.value = (getVal.value | 0x0001);
	setVal.offset = ((0<<31) | 0x0102); 
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);
	*/
	
	// 	0x010C 0x0100 0x0100 Turn on clock
	getVal.offset = ((0<<31) | 0x010C); 
	DclPMU_Control(handle, MISC_GET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&getVal);
	setVal.value = (getVal.value | 0x0100);
	setVal.offset = ((0<<31) | 0x010C); 
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	// 	0x010C 0x0100 0x0100 Turn on clock
	#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
	#endif 
	setVal.offset = ((0<<31) | 0x402C); 
	setVal.value = (0x0000);	
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	setVal.offset = ((0<<31) | 0x4024); 
	setVal.value = (0x3330);	// 16k : 0x3330, 8k : 0x0330
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	setVal.offset = ((0<<31) | 0x4028); 
	setVal.value = (0x3c2f);	
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	setVal.offset = ((0<<31) | 0x4002); 
	setVal.value = (0x0004);    // 16k : 0x0004, 8k : 0x0000
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);


	// sine tone generation
	setVal.offset = ((0<<31) | 0x4004); 
	setVal.value = (0x0000); // loopback 	
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	/*
	setVal.offset = ((0<<31) | 0x4010); 
	setVal.value = (0x9010);	
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);
	*/
	// sine tone generation 
	
	setVal.offset = ((0<<31) | 0x4016); 
	setVal.value = (0x0100);	
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	setVal.offset = ((0<<31) | 0x4000); 
	setVal.value = (0x0003);	
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	setVal.offset = ((0<<31) | 0x0700); 
	setVal.value = (0x79A0);	
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	setVal.offset = ((0<<31) | 0x0702); 
	setVal.value = (0x0200);	
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	setVal.offset = ((0<<31) | 0x0704); 
	setVal.value = (0x00F3);	
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	setVal.offset = ((0<<31) | 0x0706); 
	setVal.value = (0x0000);	
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);
	
	setVal.offset = ((0<<31) | 0x0710); 
	setVal.value = (0x0208);	
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	setVal.offset = ((0<<31) | 0x0708); 
	setVal.value = (0x007c);	
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	setVal.offset = ((0<<31) | 0x070A); 
	setVal.value = (0x2214);	
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	setVal.offset = ((0<<31) | 0x070C); 
	setVal.value = (0xF5BA);	
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

	setVal.offset = ((0<<31) | 0x070E); 
	setVal.value = (0x25B0);	
	DclPMU_Control(handle, MISC_SET_REGISTER_VALUE, (DCL_CTRL_DATA_T *)&setVal);

}