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

Commit f0835a3d authored by Xiaozhe Shi's avatar Xiaozhe Shi
Browse files

power: qpnp-smbcharger: fix vbus oscillations



When charging at high currents, the charger buck instabilities can cause
large oscillations on vbus (USB voltage). These oscillations in turn
cause many different other issues, such as large swings in battery current
readings.

Work around this problem by increasing the switching rate of the charger
buck, so that the wave form smoothens out.

CRs-Fixed: 710498
Change-Id: I80bc158eab8051c6a31ad14f08d541fe59c0744c
Signed-off-by: default avatarXiaozhe Shi <xiaozhes@codeaurora.org>
parent 12502eea
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -2016,6 +2016,8 @@ static inline int get_bpd(const char *name)
#define USB51_COMMAND_POL		BIT(2)
#define USB51AC_CTRL			BIT(1)
#define SFT_CFG				0xFD
#define TR_8OR32B			0xFE
#define BUCK_8_16_FREQ_BIT		BIT(0)
#define SFT_EN_MASK			SMB_MASK(5, 4)
#define SFT_TO_MASK			SMB_MASK(3, 2)
#define PRECHG_SFT_TO_MASK		SMB_MASK(1, 0)
@@ -2185,6 +2187,15 @@ static int smbchg_hw_init(struct smbchg_chip *chip)
		}
	}

	/* make the buck switch faster to prevent some vbus oscillation */
	rc = smbchg_sec_masked_write(chip,
			chip->usb_chgpth_base + TR_8OR32B,
			BUCK_8_16_FREQ_BIT, 0);
	if (rc < 0) {
		dev_err(chip->dev, "Couldn't set buck frequency rc = %d\n", rc);
		return rc;
	}

	/* battery missing detection */
	mask =  BATT_MISSING_ALGO_BIT;
	reg = chip->bmd_algo_disabled ? BATT_MISSING_ALGO_BIT : 0;