/*
************************************************************************************************************
*
*                                             function
*
*    name          :
*
*    parmeters     :  standby_mode: 0, 普通模式,需要检测电源状态
*
*					                1, 测试模式,强制进入standby模式,不论电源状态
*
*    return        :
*
*    note          :  probe power and other condition
*
*
*
************************************************************************************************************
*/
void board_status_probe(int standby_mode)
{
	int ret;

	//清除power按键
	axp_probe_key();
	//启动条件判断,第一阶段,检测电源电压状态
	if(!standby_mode)
	{
		ret = board_probe_power_level();	//负数:关机;0:进入系统;正数:待机
		debug("stage1 resule %d\n", ret);
		if(ret < 0)
		{
			do_shutdown(NULL, 0, 1, NULL);
		}
		else if(!ret)
		{
			return ;
		}
		//启动条件判断,第二阶段,检测开机原因
		ret = board_probe_poweron_cause();		//负数,0:进入系统;正数:待机或者直接关机
		debug("stage2 resule %d\n", ret);
		if(ret <= 0)
		{
			return ;
		}
		else if(ret == AXP_VBUS_DCIN_NOT_EXIST) //当前一次为boot standby状态,但是启动时检查无外部电源,直接关机
		{
			do_shutdown(NULL, 0, 1, NULL);
		}
	}
	//启动条件判断,第三阶段,检测电池存在
	//负数:关机;0:进入系统;正数:待机
	ret = board_probe_bat_status(standby_mode);
	debug("stage3 resule %d\n", ret);
	if(ret < 0)
	{
		do_shutdown(NULL, 0, 1, NULL);
	}
	else if(!ret)
	{
		return ;
	}
	//启动条件判断,第四阶段,进入boot待机
	//负数:关机,其它:进入系统
	ret = board_standby_status(ret);
	debug("stage4 resule %d\n", ret);
	if(ret < 0)
	{
		do_shutdown(NULL, 0, 1, NULL);
	}

	return ;
}
Example #2
0
/*
************************************************************************************************************
*
*                                             function
*
*    name          :
*
*    parmeters     :  standby_mode: 0, 普通模式,需要检测电源状态
*
*					                1, 测试模式,强制进入standby模式,不论电源状态
*
*    return        :
*
*    note          :  probe power and other condition
*
*
*
************************************************************************************************************
*/
void board_status_probe(int standby_mode)
{
	int ret;
	int start_condition = 0;
	int bat_exist;

	//清除power按键
	axp_probe_key();
	//启动条件判断,第一阶段,检测电源电压状态
	if(!standby_mode)
	{
		ret = board_probe_power_level();	//负数:关机;0:进入系统;正数:检测
		debug("stage1 resule %d\n", ret);
		if(ret < 0)
		{
			do_shutdown(NULL, 0, 1, NULL);
		}
		else if(!ret)
		{
			return ;
		}
		else if(ret == 2)           //按键则显示低电图标然后关机,插入火牛则待机
		{
			start_condition = 1;
		}
		//启动条件判断,第二阶段,检测开机原因
		ret = board_probe_poweron_cause();		//负数,0:进入系统;正数:待机或者直接关机
		debug("stage2 resule %d\n", ret);
		if(ret <= 0)
		{
			if(!start_condition)
			{
				return ;
			}
			else
			{
				tick_printf("battery low power with dc or ac, should charge longer\n");
				sunxi_bmp_display("bat\\bempty.bmp");
				__msdelay(3000);

				do_shutdown(NULL, 0, 1, NULL);
			}
		}
		else if(ret == AXP_VBUS_DCIN_NOT_EXIST) //当前一次为boot standby状态,但是启动时检查无外部电源,直接关机
		{
			do_shutdown(NULL, 0, 1, NULL);
		}
	}
#ifdef FORCE_BOOT_STANDBY
	bat_exist = 1;
#else
	if(standby_mode)
	{
		bat_exist = 1;
	}
	else
	{
		bat_exist = board_probe_battery_exist();
		if(bat_exist <= 0)
		{
			tick_printf("no battery exist\n");

			return;
		}
	}
#endif
	//启动条件判断,第三阶段,检测电池存在
	//负数:关机;0:进入系统;正数:待机
	ret = board_probe_bat_status(standby_mode);
	debug("stage3 resule %d\n", ret);
	if(ret < 0)
	{
		do_shutdown(NULL, 0, 1, NULL);
	}
	else if(!ret)
	{
		return ;
	}
#ifndef CONFIG_NO_BOOT_STANDBY
        //启动条件判断,第四阶段,进入boot待机
	//负数:关机,其它:进入系统
	ret = board_standby_status(ret);
	debug("stage4 resule %d\n", ret);
	if(ret < 0)
	{
		do_shutdown(NULL, 0, 1, NULL);
	}
#endif
	return ;
}