[MTK] 如何长按电源键关机,而非重启

文摘 MediaTek 2020-05-7 阅读:1903

[DESCRIPTION]

PMIC有長按電源鍵關機的功能, 但關機後會因為使用者持續按壓電源鍵而開機

[SOLUTION]

在preloader內判斷前次關機是否為長按關機, 若是則必須等到pwrkey release才會繼續boot flow.

In vendor\mediatek\proprietary\bootable\bootloader\preloader\platform\mt6771\src\drivers\keypad.c

bool mtk_detect_key(unsigned short key)  /* key: HW keycode */
{
...
 U32 just_rst;
 int itimeout = 200; /* set timeout for 20 sec */
...
 if (key == MTK_PMIC_PWR_KEY) {
  just_rst = is_pmic_long_press_reset();
  if (just_rst) {
  while (itimeout--) {
   mdelay(100);
   pmic_config_interface(PMIC_RG_STRUP_PWRKEY_COUNT_RESET_ADDR, 0x1, 0x1, 0);
   platform_wdt_kick();
   printf("[%s] timeout %d", __func__, itimeout);
   if (!(pmic_detect_powerkey())) {
    return false;
   }
  }
 }
...
}


0条评论

© 2021 芯缘异码. Powered by Typecho