Beispiel #1
0
/*低功耗接口*/
s32 hi6930_wdt_case04(void)
{
	bsp_wdt_start();
	/*设置计数时间35s*/
	bsp_wdt_suspend(35);
	/*计数时间恢复为30s*/
	bsp_wdt_resume();
	bsp_wdt_stop();
	return WDT_OK;
}
/*各模块填写时,注意suspend顺序与resume顺序相反*/
static s32 enter_suspend_and_resume(u32 pm_msg)
{
	s32 ret = 0;
	pm_suspend_flag = 0;
    pm_resume_flag = 0;
	if(PMSG_SUSPEND==pm_msg){
		/*可维可测,记录进入suspend总次数*/
		dpm_debug[DPM_BUTTON][0]++;
		/*本分支回调各设备的suspend回调函数,顺序往下加*/
		writel(bsp_get_slice_value(), DPM_SRAM_TIMER1);
		ret=tem_protect_suspend();
		if(ret !=0)
		{
			pm_suspend_flag = 1;
			dpm_debug[DPM_TEM][0] +=1;
			goto end;
		}
		writel(bsp_get_slice_value(), DPM_SRAM_TIMER2);
		ret=bsp_socp_suspend();
		writel(bsp_get_slice_value(), DPM_SRAM_TIMER3);
		if(ret !=0)
		{
			pm_suspend_flag = 1;
			dpm_debug[DPM_SOCP][0] +=1;
			goto tem_resume;
		}
		bsp_ipc_suspend();
		bsp_amon_suspend();
		writel(bsp_get_slice_value(), DPM_SRAM_TIMER4);
		(void)uart_suspend_port();
		writel(bsp_get_slice_value(), DPM_SRAM_TIMER5);
		ret = ipf_drx_bak_reg();
		writel(bsp_get_slice_value(), DPM_SRAM_TIMER6);
		if(ret !=0)
		{
			pm_suspend_flag = 1;
			dpm_debug[DPM_IPF][0] +=1;
			goto uart_resume;
		}
        ret = bsp_pmu_suspend();
	    writel(bsp_get_slice_value(), DPM_SRAM_TIMER7);
        if(ret != 0)
        {
            pm_suspend_flag = 1;
            dpm_debug[DPM_PMU][0] +=1;
            goto ipf_resume;
        }
        bsp_wdt_suspend(0);

	}
	else if(PMSG_RESUME==pm_msg){
		dpm_debug[DPM_BUTTON][1]++;/*可维可测,记录进入resume总次数*/
		/*本分支回调各设备的resume回调函数,顺序往上加*/
		writel(bsp_get_slice_value(), DPM_SRAM_TIMER8);
        ret = bsp_pmu_resume();
		writel(bsp_get_slice_value(), DPM_SRAM_TIMER9);
        if(ret != 0)
        {
            pm_resume_flag = 1;
            dpm_debug[DPM_PMU][1] +=1;
            goto resume;
        }
	ipf_resume:
		ipf_drx_restore_reg();
		writel(bsp_get_slice_value(), DPM_SRAM_TIMER10);
    uart_resume:
		(void)uart_resume_port();
		writel(bsp_get_slice_value(), DPM_SRAM_TIMER11);
		bsp_amon_resume();
		bsp_ipc_resume();
		writel(bsp_get_slice_value(), DPM_SRAM_TIMER12);
		bsp_socp_resume();
		writel(bsp_get_slice_value(), DPM_SRAM_TIMER13);
	tem_resume:
		tem_protect_resume();
		writel(bsp_get_slice_value(), DPM_SRAM_TIMER14);
		bsp_hkadc_resume();
		writel(bsp_get_slice_value(), DPM_SRAM_TIMER15);
		bsp_wdt_resume();
	}
	end:
	if(PMSG_SUSPEND==pm_msg)
	{
		if(0==pm_suspend_flag)
			return DPM_OK;
		else
			return DPM_ERROR;
	}
    resume:
	if(PMSG_RESUME==pm_msg)
	{
        if(0==pm_resume_flag)
			return DPM_OK;
		else
			return DPM_ERROR;
	}
	return DPM_OK;
}