Merge "power: qpnp-qg: Add support to clear soh upon first profile load"

This commit is contained in:
qctecmdr 2021-07-08 08:24:30 -07:00 • committed by Gerrit - the friendly Code Review server
commit 0889086dbb
4 changed files with 15 additions and 2 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.
*/
#ifndef __QG_CORE_H__
@ -154,6 +154,7 @@ struct qpnp_qg {
bool fvss_active;
bool tcss_active;
bool bass_active;
bool first_profile_load;
int charge_status;
int charge_type;
int chg_iterm_ma;

View file

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright (c) 2020 The Linux Foundation. All rights reserved.
* Copyright (c) 2020-2021 The Linux Foundation. All rights reserved.
*/
#ifndef __QG_IIO_H
@ -91,6 +91,7 @@ static const struct qg_iio_channels qg_iio_psy_channels[] = {
QG_CHAN_RES("esr_actual", PSY_IIO_ESR_ACTUAL)
QG_CHAN_RES("esr_nominal", PSY_IIO_ESR_NOMINAL)
QG_CHAN_INDEX("soh", PSY_IIO_SOH)
QG_CHAN_INDEX("clear_soh", PSY_IIO_CLEAR_SOH)
QG_CHAN_ENERGY("cc_soc", PSY_IIO_CC_SOC)
QG_CHAN_ACT("fg_reset", PSY_IIO_FG_RESET)
QG_CHAN_VOLT("voltage_avg", PSY_IIO_VOLTAGE_AVG)

View file

@ -2135,6 +2135,9 @@ static int qg_iio_write_raw(struct iio_dev *indio_dev,
if (chip->sp)
soh_profile_update(chip->sp, chip->soh);
break;
case PSY_IIO_CLEAR_SOH:
chip->first_profile_load = val1;
break;
case PSY_IIO_ESR_ACTUAL:
chip->esr_actual = val1;
break;
@ -2260,6 +2263,9 @@ static int qg_iio_read_raw(struct iio_dev *indio_dev,
case PSY_IIO_SOH:
*val1 = chip->soh;
break;
case PSY_IIO_CLEAR_SOH:
*val1 = chip->first_profile_load;
break;
case PSY_IIO_CC_SOC:
rc = qg_get_cc_soc(chip, val1);
break;
@ -3470,6 +3476,7 @@ static int qg_sanitize_sdam(struct qpnp_qg *chip)
rc = qg_sdam_write(SDAM_MAGIC, SDAM_MAGIC_NUMBER);
if (!rc)
qg_dbg(chip, QG_DEBUG_PON, "First boot. SDAM initilized\n");
chip->first_profile_load = true;
} else {
/* SDAM has invalid value */
rc = qg_sdam_clear();
@ -3477,6 +3484,7 @@ static int qg_sanitize_sdam(struct qpnp_qg *chip)
pr_err("SDAM uninitialized, SDAM reset\n");
rc = qg_sdam_write(SDAM_MAGIC, SDAM_MAGIC_NUMBER);
}
chip->first_profile_load = true;
}
if (rc < 0)

View file

@ -151,4 +151,7 @@
/* USB */
#define PSY_IIO_MOISTURE_DETECTION_EN 0x7b
/* BMS */
#define PSY_IIO_CLEAR_SOH 0x7c
#endif /* __QTI_POWER_SUPPLY_IIO_H__ */