[MTK] 如何实现插上电池自动开机

文摘 MediaTek 2020-10-25 阅读:6979

[DESCRIPTION]

 有些行业应用产品,不需要pwrkey键,而且希望实现插上电池后自动开机

[SOLUTION]

 实现该功能需要两个步骤,首先硬件上将pwrkey直接接地,然后在软件设置中去掉长按关机或重启的功能。

下面详述如何在软件中去掉长按关机或重启的功能:

  1. 请在文件/vendor/mediatek/proprietary/bootable/bootloader/preloader/platform/mt6771/src/drivers/pmic.c中重新定义如下函数:
void PMIC_enable_long_press_reboot(void)
{

    pmic_config_interface(PMIC_RG_PWRKEY_RST_EN_ADDR, 0x00, PMIC_RG_PWRKEY_RST_EN_MASK, PMIC_RG_PWRKEY_RST_EN_SHIFT);
    pmic_config_interface(PMIC_RG_HOMEKEY_RST_EN_ADDR, 0x00, PMIC_RG_HOMEKEY_RST_EN_MASK, PMIC_RG_HOMEKEY_RST_EN_SHIFT);

}

 2.
请在文件/kernel-4.4/drivers/input/keyboard/mediatek/mt6771/hal_kpd.c重新定义如下函数:

void long_press_reboot_function_setting(void)
{

        kpd_info("disable  mode LPRST\n");
        pmic_set_register_value(PMIC_RG_PWRKEY_RST_EN, 0x00);
        pmic_set_register_value(PMIC_RG_HOMEKEY_RST_EN, 0x00);

}

如果用的是MTK的charger IC,比如MT6370,6371。power key有拉到charger IC的话。还需要将charger IC的长按reboot关闭,关闭的方法:

1.kernel-4.4/drivers/misc/mediatek/pmic/mt6370/mt6370_pmu_charger.c

static int mt6370_pmu_charger_probe(struct platform_device *pdev){

int ret = 0;

.......................................

/* Do initial setting */

/*start add*/

dev_err(chg_data->dev, "%s: start MT6370_PMU_REG_CHGPUMP\n", __func__);

ret = mt6370_pmu_reg_set_bit(chg_data->chip,MT6370_PMU_REG_CHGPUMP, 0xE0);

if (ret < 0) {

dev_err(chg_data->dev, "%s: sw init failed\n", __func__);

goto err_chg_init_setting;

}

ret = mt6370_pmu_reg_read(chg_data->chip,MT6370_PMU_REG_CHGPUMP);

if (ret < 0)

 dev_err(chg_data->dev, "%s: read reg0x2A failed\n",__func__);

else

 dev_err(chg_data->dev, "%s: reg0x2A = 0x%02X\n",__func__, ret);

dev_err(chg_data->dev, "%s: end MT6370_PMU_REG_CHGPUMP\n", __func__);

/*end add*/
ret = mt6370_chg_init_setting(chg_data);

if (ret < 0) {

dev_err(chg_data->dev, "%s: sw init failed\n", __func__);

goto err_chg_init_setting;

}
..................................
}

2./vendor/mediatek/proprietary/bootable/bootloader/preloader/platform/mtXXXX/src/drivers/mt6370.c

#ifdef MTK_EXT_CHGDET_SUPPORT
int mtk_ext_chgdet(CHARGER_TYPE *chg_type)
{
 int ret = 0, i = 0;
 const int max_retry_cnt = 5;
 unsigned char usb_status = 0;

 Charger_Detect_Init();

 chg_type = CHARGER_UNKNOWN;
+mt6370_set_bit(0x2A,0x80);
 /* Toggle chgdet flow */
 ret = mt6370_enable_chgdet_flow(false);
 if (ret != I2C_OK)
 goto out;

 ret = mt6370_enable_chgdet_flow(true);
 if (ret != I2C_OK)
 goto out;

0条评论

© 2024 芯缘异码. Powered by Typecho