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

Commit 1ce74997 authored by Xiaozhe Shi's avatar Xiaozhe Shi Committed by Abhijeet Dharmapurikar
Browse files

power: qpnp-smbcharger: do not charge during profile loading



When the profile is reloaded, a new hardware OCV is taken. If the device
is charging, the readings will be off, and can cause SOC errors.

Disable charging during profile loading so that this does not happen.

Change-Id: I6719bf3d1cfcc17320cd5e01cc802826ed51fdf6
Signed-off-by: default avatarXiaozhe Shi <xiaozhes@codeaurora.org>
parent dc6a6fba
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -1912,7 +1912,16 @@ static void smbchg_restart_charging(struct smbchg_chip *chip)
	}
}

#define CMD_CHG_REG	0x42
#define EN_BAT_CHG_BIT		BIT(1)
static int smbchg_charging_en(struct smbchg_chip *chip, bool en)
{
	return smbchg_masked_write(chip, chip->bat_if_base + CMD_CHG_REG,
			EN_BAT_CHG_BIT, en ? 0 : EN_BAT_CHG_BIT);
}

#define UNKNOWN_BATT_TYPE	"Unknown Battery"
#define LOADING_BATT_TYPE	"Loading Battery Data"
static void smbchg_external_power_changed(struct power_supply *psy)
{
	struct smbchg_chip *chip = container_of(psy,
@@ -1930,6 +1939,8 @@ static void smbchg_external_power_changed(struct power_supply *psy)
				POWER_SUPPLY_PROP_BATTERY_TYPE, &prop);
		en = strcmp(prop.strval, UNKNOWN_BATT_TYPE) != 0;
		smbchg_unknown_battery_en(chip, en);
		en = strcmp(prop.strval, LOADING_BATT_TYPE) != 0;
		smbchg_charging_en(chip, en);

		if (get_prop_batt_capacity(chip) <= chip->resume_soc_threshold
				&& chip->resume_soc_threshold >= 0
@@ -2027,7 +2038,6 @@ static int smbchg_float_voltage_set(struct smbchg_chip *chip, int vfloat_mv)
			VFLOAT_MASK, temp);
}

#define CMD_CHG_REG	0x42
#define OTG_EN		BIT(0)
static int smbchg_otg_regulator_enable(struct regulator_dev *rdev)
{