Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 62d14b68 authored by Fenglin Wu's avatar Fenglin Wu
Browse files

power: supply: smb5: Configure charger termination condition



Configure charger termination based on the number of the disqualified
IBAT samples. If there are less than MAX_FAILED_IBATT_SAMPLE_FOR_TERM
disqualified IBAT samples within one IBAT conversion cycle, then
charging is terminated.

Change-Id: I7a8104e84a241f6549d599edbd379b03e470c6d2
Signed-off-by: default avatarFenglin Wu <fenglinw@codeaurora.org>
parent 2acd0f4c
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -2232,9 +2232,18 @@ static int smb5_configure_iterm_thresholds_adc(struct smb5 *chip)
static int smb5_configure_iterm_thresholds(struct smb5 *chip)
{
	int rc = 0;
	struct smb_charger *chg = &chip->chg;

	switch (chip->dt.term_current_src) {
	case ITERM_SRC_ADC:
		rc = smblib_masked_write(chg, CHGR_ADC_TERM_CFG_REG,
				TERM_BASED_ON_SYNC_CONV_OR_SAMPLE_CNT,
				TERM_BASED_ON_SAMPLE_CNT);
		if (rc < 0) {
			dev_err(chg->dev, "Couldn't configure ADC_ITERM_CFG rc=%d\n",
					rc);
			return rc;
		}
		rc = smb5_configure_iterm_thresholds_adc(chip);
		break;
	default:
+5 −0
Original line number Diff line number Diff line
@@ -86,6 +86,11 @@ enum {
#define NO_OF_SAMPLE_FOR_RCHG_SHIFT		2
#define NO_OF_SAMPLE_FOR_RCHG			GENMASK(3, 2)

#define CHGR_ADC_TERM_CFG_REG			(CHGR_BASE + 0x6C)
#define TERM_BASED_ON_SYNC_CONV_OR_SAMPLE_CNT	BIT(0)
#define TERM_BASED_ON_SYNC_CONV			0
#define TERM_BASED_ON_SAMPLE_CNT		1

#define CHGR_FLOAT_VOLTAGE_CFG_REG		(CHGR_BASE + 0x70)

#define CHARGE_INHIBIT_THRESHOLD_CFG_REG	(CHGR_BASE + 0x72)