关机时充电器检测代码在lk部分,当接入充电器时,PMIC会通过ADC采样,检测Vchrg(charger/usb电源)电压,
判断Vchrg的值如果在这个区间:4.4v~6.5v,系统就会开始进入充电过程,这个过程包括show low battery logo,接着
显示充电电量logo。
相关代码:
boottable/bbotloader/lk/platform/mt6735/platform.c
中查看函数void platform_init(void):
充电器检测:
充电过程中,upmu_is_chr_det() 检测Vchrg状态,返回KAL_FALSE则power off。
#ifdef MTK_KERNEL_POWER_OFF_CHARGING
if((g_boot_arg->boot_reason == BR_USB) && (upmu_is_chr_det() == KAL_FALSE))
{
printf("[%s] Unplugged Charger/Usb between Pre-loader and Uboot in Kernel Charging Mode, Power Off \n", __func__);
mt6575_power_off();
}
#endif
显示LCM背光:
#ifndef DISABLE_FOR_BRING_UP
mt65xx_backlight_on(); //[TODO] workaround
#endif
boot模式选择,用于区分开机过程。
boot_mode_select();
显示low battery logo,点亮充电指示灯:
if(kernel_charging_boot() == 1) //关机充电状态
{
mt_disp_power(TRUE);
mt_disp_show_low_battery();
mt_disp_wait_idle();
#ifndef DISABLE_FOR_BRING_UP
mt65xx_leds_brightness_set(6, 110);
#endif
}
kernel_charging_boot定义:
#if defined (MTK_KERNEL_POWER_OFF_CHARGING)
int kernel_charging_boot(void)
{
if((g_boot_mode == KERNEL_POWER_OFF_CHARGING_BOOT || g_boot_mode == LOW_POWER_OFF_CHARGING_BOOT) && upmu_is_chr_det() == KAL_TRUE)
{
printf("[%s] Kernel Power Off Charging with Charger/Usb \n", __func__);
return 1;
}
else if((g_boot_mode == KERNEL_POWER_OFF_CHARGING_BOOT || g_boot_mode == LOW_POWER_OFF_CHARGING_BOOT) && upmu_is_chr_det() == KAL_FALSE)
{
printf("[%s] Kernel Power Off Charging without Charger/Usb \n", __func__);
return -1;
}
else
return 0;
}
#endif
判断Vchrg的值如果在这个区间:4.4v~6.5v,系统就会开始进入充电过程,这个过程包括show low battery logo,接着
显示充电电量logo。
相关代码:
boottable/bbotloader/lk/platform/mt6735/platform.c
中查看函数void platform_init(void):
充电器检测:
充电过程中,upmu_is_chr_det() 检测Vchrg状态,返回KAL_FALSE则power off。
#ifdef MTK_KERNEL_POWER_OFF_CHARGING
if((g_boot_arg->boot_reason == BR_USB) && (upmu_is_chr_det() == KAL_FALSE))
{
printf("[%s] Unplugged Charger/Usb between Pre-loader and Uboot in Kernel Charging Mode, Power Off \n", __func__);
mt6575_power_off();
}
#endif
显示LCM背光:
#ifndef DISABLE_FOR_BRING_UP
mt65xx_backlight_on(); //[TODO] workaround
#endif
boot模式选择,用于区分开机过程。
boot_mode_select();
显示low battery logo,点亮充电指示灯:
if(kernel_charging_boot() == 1) //关机充电状态
{
mt_disp_power(TRUE);
mt_disp_show_low_battery();
mt_disp_wait_idle();
#ifndef DISABLE_FOR_BRING_UP
mt65xx_leds_brightness_set(6, 110);
#endif
}
kernel_charging_boot定义:
#if defined (MTK_KERNEL_POWER_OFF_CHARGING)
int kernel_charging_boot(void)
{
if((g_boot_mode == KERNEL_POWER_OFF_CHARGING_BOOT || g_boot_mode == LOW_POWER_OFF_CHARGING_BOOT) && upmu_is_chr_det() == KAL_TRUE)
{
printf("[%s] Kernel Power Off Charging with Charger/Usb \n", __func__);
return 1;
}
else if((g_boot_mode == KERNEL_POWER_OFF_CHARGING_BOOT || g_boot_mode == LOW_POWER_OFF_CHARGING_BOOT) && upmu_is_chr_det() == KAL_FALSE)
{
printf("[%s] Kernel Power Off Charging without Charger/Usb \n", __func__);
return -1;
}
else
return 0;
}
#endif