qg: disable charging pump when do ESR

The product is designed with charging pump and use
internal QG. If we don't disable CP, QG can't get valid
ESR value when CP enabe.

Porting from (CR)

Change-Id: I27ea8ae254555afdf37676124a859ce3a179fc76
Reviewed-on: https://gerrit.mot.com/1978508
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
chailu1 2021-06-13 18:40:29 +08:00 • committed by Xiaojun Ji
commit e628b2580e
2 changed files with 20 additions and 1 deletions

View file

@ -81,6 +81,7 @@ struct qg_dt {
bool multi_profile_load;
bool tcss_enable;
bool bass_enable;
bool cp_use_internal_qg;
};
struct qg_esr_data {

View file

@ -1103,6 +1103,15 @@ static int qg_esr_estimate(struct qpnp_qg *chip)
goto done;
}
if (chip->dt.cp_use_internal_qg) {
rc = qg_write_iio_chan(chip, CP_CHARGING_ENABLED, 0);
if (rc < 0)
pr_err("Failed to force disable cp rc=%d\n", rc);
else
qg_dbg(chip, QG_DEBUG_STATUS, "disable cp\n");
msleep(1000);
}
for (i = 0; i < qg_esr_count; i++) {
/* Fire ESR measurement */
rc = qg_masked_write(chip,
@ -1191,6 +1200,14 @@ static int qg_esr_estimate(struct qpnp_qg *chip)
msleep(200);
}
if (chip->dt.cp_use_internal_qg) {
rc = qg_write_iio_chan(chip, CP_CHARGING_ENABLED, 1);
if (rc < 0)
pr_err("Failed to force enable cp rc=%d\n", rc);
else
qg_dbg(chip, QG_DEBUG_STATUS, "enable cp\n");
}
rc = qg_process_esr_data(chip);
if (rc < 0)
pr_err("Failed to process ESR data rc=%d\n", rc);
@ -4369,7 +4386,8 @@ static int qg_parse_dt(struct qpnp_qg *chip)
chip->dt.esr_discharge_enable = of_property_read_bool(node,
"qcom,esr-discharge-enable");
chip->dt.cp_use_internal_qg = of_property_read_bool(node,
"mmi,cp-use-internal-qg");
rc = of_property_read_u32(node, "qcom,esr-qual-current-ua", &temp);
if (rc < 0)
chip->dt.esr_qual_i_ua = DEFAULT_ESR_QUAL_CURRENT_UA;