int asus_charging_for_gague_toggle_write(struct file *file, const char *buffer, unsigned long count, void *data) { struct battery_info_reply tmp_batt_info; //bool eng_charging_limit = true; BAT_DBG("%s:\n", __func__); mutex_lock(&batt_info_mutex); tmp_batt_info = batt_info; mutex_unlock(&batt_info_mutex); //eng_charging_limit = tmp_batt_info.eng_charging_limit; if (buffer[0] == '0') { /* turn on charging limit in eng mode */ //eng_charging_limit = true; BAT_DBG("disable charging:\n"); smb347_charging_toggle(false); } else if (buffer[0] == '1') { /* turn off charging limit in eng mode */ //eng_charging_limit = false; BAT_DBG("enable charging:\n"); smb347_charging_toggle(true); } //tmp_batt_info.eng_charging_limit = eng_charging_limit; mutex_lock(&batt_info_mutex); batt_info = tmp_batt_info; mutex_unlock(&batt_info_mutex); return count; }
static int asus_battery_update_status_no_mutex(int percentage) { int status; int temperature; //int flags; //for bq series struct battery_info_reply tmp_batt_info; u32 cable_status; tmp_batt_info = batt_info; cable_status = tmp_batt_info.cable_status; BAT_DBG("%s , cable status = %d, percentage = %d\n", __func__, cable_status, percentage); if (cable_status == USB_ADAPTER || cable_status == USB_PC) { status = POWER_SUPPLY_STATUS_CHARGING; #ifdef CONFIG_ASUS_FACTORY_MODE /* ME371MG, ME302C eng mode : stop charging when battery percentage is over 60% */ if (percentage >= 60 && tmp_batt_info.eng_charging_limit) { BAT_DBG("in fac mode and capasity > 60%\n"); smb347_charging_toggle(false); status = POWER_SUPPLY_STATUS_DISCHARGING; goto final; }
static int asus_battery_update_status_no_mutex(int percentage) { int status; int temperature; int voltage_change_temperature; int flags; struct battery_info_reply tmp_batt_info; u32 cable_status; tmp_batt_info = batt_info; cable_status = tmp_batt_info.cable_status; if (cable_status == USB_ADAPTER || cable_status == USB_PC || batt_info.cable_status == WIRELESS_ADAPTER) { status = POWER_SUPPLY_STATUS_CHARGING; #ifdef ASUS_ENG_BUILD /* ME371MG, ME302C eng mode : stop charging when battery percentage is over 60% */ if (percentage >= 60 && tmp_batt_info.eng_charging_limit) { smb347_charging_toggle(false); status = POWER_SUPPLY_STATUS_DISCHARGING; goto final; }
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; }