int update_from_normal_mode(void) { int cell_type=0; int curr_cell_type=TYPE_LG, fw_cell_type=TYPE_LG; int ret = UPDATE_NONE; int curr_volt; int i,j; int fw_cfg_version; BAT_DBG("(%s) enter\n", __func__); #if 0 curr_cell_type = bq27520_batt_current_sel_type(); #endif fw_cell_type = bq27520_batt_fw_sel_type(); curr_volt = bq27520_asus_battery_dev_read_volt(); fw_cfg_version = bq27520_asus_battery_dev_read_fw_cfg_version(); BAT_DBG("(%s) current_cell_type %d, fw_cell_type %d, current_volt %d, fw_cfg_version 0x%04X\n", __func__, curr_cell_type, fw_cell_type, curr_volt, fw_cfg_version ); if (curr_cell_type == fw_cell_type) { if (fw_cfg_version == LATEST_FW_CFG_VERSION) { BAT_DBG(" No need to flash battery cell data due to that both firmware config version are equal"); return ret; } } //Need update, check update voltage ret = UPDATE_VOLT_NOT_ENOUGH; if (curr_volt < 0 || curr_volt < 3700) { BAT_DBG_E("Voltage not enough \n"); return ret; } ret = update_normal(curr_cell_type); return ret; }
int update_from_normal_mode(bool forceupdate) { int curr_cell_type=TYPE_LG, fw_cell_type=TYPE_LG; int ret = UPDATE_NONE; int curr_volt; int fw_cfg_version; BAT_DBG("(%s) enter\n", __func__); #if 0 curr_cell_type = bq27520_batt_current_sel_type(); #endif fw_cell_type = bq27520_batt_fw_sel_type(); curr_volt = bq27520_asus_battery_dev_read_volt(); fw_cfg_version = bq27520_asus_battery_dev_read_fw_cfg_version(); BAT_DBG("(%s) current_cell_type %d, fw_cell_type %d, current_volt %d, fw_cfg_version 0x%04X\n", __func__, curr_cell_type, fw_cell_type, curr_volt, fw_cfg_version ); if (!forceupdate) { if (fw_cfg_version == LATEST_FW_CFG_VERSION) { BAT_DBG("========= No need to flash battery cell data due to that both data flash version are equal ========="); goto Done; } } //Need update, check update voltage ret = UPDATE_VOLT_NOT_ENOUGH; if (curr_volt < 0 || curr_volt < 3700) { BAT_DBG_E("Voltage not enough \n"); goto Done; } if (batt_info.gauge_version == IC_VERSION_G3) { BAT_DBG("bq27520 gauge is G3, no need enter ROM mode.\n"); } else if (batt_info.gauge_version == IC_VERSION_G4) { //unseal for enter rom mode ret = bq27520_default_unseal(); if (ret < 0) { // default password unseal fail BAT_DBG_E("bq27520_default_unseal fail !!!!\n"); bq27520_rom_mode_wait(5000); ret = bq27520_ME560CG_unseal(); if (ret < 0) { // ME560CG password unseal fail BAT_DBG_E("bq27520_ME560CG_unseal fail !!!!\n"); ret = UPDATE_CHECK_MODE_FAIL; goto Done; } } } smb347_charging_toggle(false); ret = update_normal(curr_cell_type); smb347_charging_toggle(true); Done: flash_gauge_status = ret; return ret; }