fg: optimization fg batt status
current between -10~10mA read from fg when charger present is invalid, change batt status to not chargering Change-Id: Idc1f1e5ed148ea49aa9a539e4014ff4146519460 Signed-off-by: xuxj12 <xuxj12@motorola.com> Reviewed-on: https://gerrit.mot.com/2516321 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Reviewed-by: Yonghua Yan <yanyh2@motorola.com> Reviewed-by: Jianqi Yang <yangj@motorola.com> Tested-by: Jira Key Submit-Approved: Jira Key
This commit is contained in:
1 parent
7720276df2
commit
f1cd82577b
1 file changed
+7
-5
@@ -76,6 +76,7 @@
|
|||||||
#define CW_VOL_UNIT 1000
|
#define CW_VOL_UNIT 1000
|
||||||
#define CW_CUR_UNIT 1000
|
#define CW_CUR_UNIT 1000
|
||||||
|
|
||||||
|
#define CW_CUR_ACCURACY 10000
|
||||||
|
|
||||||
#define CW2217_NOT_ACTIVE 1
|
#define CW2217_NOT_ACTIVE 1
|
||||||
#define CW2217_PROFILE_NOT_READY 2
|
#define CW2217_PROFILE_NOT_READY 2
|
||||||
@@ -933,12 +934,13 @@ static void cw_get_batt_status(struct cw_battery *cw_bat)
|
|||||||
cw_bat->batt_status = POWER_SUPPLY_STATUS_UNKNOWN;
|
cw_bat->batt_status = POWER_SUPPLY_STATUS_UNKNOWN;
|
||||||
} else if (cw_bat->ui_soc == CW_UI_FULL) {
|
} else if (cw_bat->ui_soc == CW_UI_FULL) {
|
||||||
cw_bat->batt_status = POWER_SUPPLY_STATUS_FULL;
|
cw_bat->batt_status = POWER_SUPPLY_STATUS_FULL;
|
||||||
} else if (batt_curr > 0)
|
} else if (abs(batt_curr) < CW_CUR_ACCURACY) {
|
||||||
cw_bat->batt_status = POWER_SUPPLY_STATUS_CHARGING;
|
|
||||||
else if (batt_curr < 0)
|
|
||||||
cw_bat->batt_status = POWER_SUPPLY_STATUS_DISCHARGING;
|
|
||||||
else
|
|
||||||
cw_bat->batt_status = POWER_SUPPLY_STATUS_NOT_CHARGING;
|
cw_bat->batt_status = POWER_SUPPLY_STATUS_NOT_CHARGING;
|
||||||
|
} else if (batt_curr * cw_bat->ibat_polority < 0) {
|
||||||
|
cw_bat->batt_status = POWER_SUPPLY_STATUS_CHARGING;
|
||||||
|
} else {
|
||||||
|
cw_bat->batt_status = POWER_SUPPLY_STATUS_DISCHARGING;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int cw_get_charge_counter(struct cw_battery *cw_bat)
|
static unsigned int cw_get_charge_counter(struct cw_battery *cw_bat)
|
||||||
|
|||||||
Reference in new issue
Block a user