Merge "power: smb5-lib: Add additional check to exit charge-termination WA"

This commit is contained in:
qctecmdr 2021-02-03 12:03:00 -08:00 • committed by Gerrit - the friendly Code Review server
commit 86b4635874
3 changed files with 25 additions and 3 deletions

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
*/
#include <linux/debugfs.h>
@ -446,6 +446,9 @@ static int smb5_parse_dt_misc(struct smb5 *chip, struct device_node *node)
chg->sw_jeita_enabled = of_property_read_bool(node,
"qcom,sw-jeita-enable");
chg->jeita_arb_enable = of_property_read_bool(node,
"qcom,jeita-arb-enable");
chg->pd_not_supported = chg->pd_not_supported ||
of_property_read_bool(node, "qcom,usb-pd-disable");

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
*/
#include <linux/device.h>
@ -7591,8 +7591,10 @@ static void smblib_chg_termination_work(struct work_struct *work)
int val;
struct smb_charger *chg = container_of(work, struct smb_charger,
chg_termination_work);
union power_supply_propval pval = {0, };
int rc, input_present, delay = CHG_TERM_WA_ENTRY_DELAY_MS;
int vbat_now_uv, max_fv_uv;
u8 stat = 0;
/*
* Hold awake votable to prevent pm_relax being called prior to
@ -7612,6 +7614,21 @@ static void smblib_chg_termination_work(struct work_struct *work)
goto out;
}
if ((rc < 0) || (pval.intval < 100)) {
rc = smblib_read(chg, BATTERY_CHARGER_STATUS_1_REG, &stat);
if (rc < 0)
goto out;
/* check we are not in termination to exit the WA */
if ((stat & BATTERY_CHARGER_STATUS_MASK) != TERMINATE_CHARGE) {
vote(chg->usb_icl_votable, CHG_TERMINATION_VOTER,
false, 0);
vote(chg->dc_suspend_votable, CHG_TERMINATION_VOTER,
false, 0);
goto out;
}
}
/* Get the battery float voltage */
rc = smblib_get_prop_from_bms(chg, SMB5_QG_VOLTAGE_MAX, &val);
if (rc < 0) {
@ -8283,7 +8300,8 @@ int smblib_init(struct smb_charger *chg)
}
rc = qcom_step_chg_init(chg->dev, chg->step_chg_enabled,
chg->sw_jeita_enabled, false, chg->iio_chans);
chg->sw_jeita_enabled, chg->jeita_arb_enable,
chg->iio_chans);
if (rc < 0) {
smblib_err(chg, "Couldn't init qcom_step_chg_init rc=%d\n",
rc);

View file

@ -519,6 +519,7 @@ struct smb_charger {
int fake_batt_status;
bool step_chg_enabled;
bool sw_jeita_enabled;
bool jeita_arb_enable;
bool typec_legacy_use_rp_icl;
bool is_hdc;
bool chg_done;