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

Commit 114a47f1 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: qpnp-smbcharger: Add support to configure recharge threshold source



Currently, we're configuring the recharge threshold source as analog
ADC by default. In certain cases like where the system load is high
and the input current is lesser than 500mA, charger inhibit interrupt
fires frequently right after the charger insertion. Since the power
supply change notification for battery full is sent based on this
interrupt, an interrupt storm prematurely indicates battery full to
the userspace.

To avoid this, we should program the recharge threshold source as fuel
gauge.This will make the charger to be in sync with the fuel gauge and
helping in reducing spurious chg-inhibit interrupts.

CRs-Fixed: 723434
Change-Id: I784d885f80c1944bd64e779a5946227e7b18ef8d
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 260ef090
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -140,6 +140,9 @@ Optional Properties:
				should resume charging. If this is not defined,
				the only way to resume charging is through the
				voltage drop specified by qcom,resume-delta-mv.
- qcom,chg-inhibit-fg		Indicates if the recharge threshold source has
				to be Fuel gauge ADC. If this is not set, it
				will be analog sensor by default.
- qcom,bmd-algo-disabled	Indicates if the battery missing detection
				algorithm is disabled. If this node is present
				SMB uses the THERM pin for battery missing
+35 −18
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ struct smbchg_chip {
	bool				low_icl_wa_on;
	bool				battery_unknown;
	bool				charge_unknown_battery;
	bool				chg_inhibit_source_fg;
	u8				original_usbin_allowance;
	struct parallel_usb_cfg		parallel;
	struct delayed_work		parallel_en_work;
@@ -2911,11 +2912,18 @@ static int smbchg_hw_init(struct smbchg_chip *chip)
	}

	/*
	 * use the analog sensors instead of the fuelgauge adcs so that
	 * tcc detection works without trimmed parts
	 * Based on the configuration, use the analog sensors or the fuelgauge
	 * adc for recharge threshold source.
	 */

	if (chip->chg_inhibit_source_fg)
		rc = smbchg_sec_masked_write(chip, chip->chgr_base + CHGR_CFG1,
			TERM_I_SRC_BIT | RECHG_THRESHOLD_SRC_BIT,
			RECHG_THRESHOLD_SRC_BIT);
	else
		rc = smbchg_sec_masked_write(chip, chip->chgr_base + CHGR_CFG1,
			TERM_I_SRC_BIT | RECHG_THRESHOLD_SRC_BIT, 0);

	if (rc < 0) {
		dev_err(chip->dev, "Couldn't set chgr_cfg2 rc=%d\n", rc);
		return rc;
@@ -3047,6 +3055,12 @@ static int smbchg_hw_init(struct smbchg_chip *chip)
	smbchg_dc_en(chip, chip->chg_enabled, REASON_USER);
	/* resume threshold */
	if (chip->resume_delta_mv != -EINVAL) {

		/*
		 * Configure only if the recharge threshold source is not
		 * fuel gauge ADC.
		 */
		if (!chip->chg_inhibit_source_fg) {
			if (chip->resume_delta_mv < 100)
				reg = CHG_INHIBIT_50MV_VAL;
			else if (chip->resume_delta_mv < 200)
@@ -3064,6 +3078,7 @@ static int smbchg_hw_init(struct smbchg_chip *chip)
						rc);
				return rc;
			}
		}

		rc = smbchg_sec_masked_write(chip,
				chip->chgr_base + CHGR_CFG,
@@ -3205,6 +3220,8 @@ static int smb_parse_dt(struct smbchg_chip *chip)
						"qcom,charging-disabled"));
	chip->charge_unknown_battery = of_property_read_bool(node,
						"qcom,charge-unknown-battery");
	chip->chg_inhibit_source_fg = of_property_read_bool(node,
						"qcom,chg-inhibit-fg");

	/* parse the battery missing detection pin source */
	rc = of_property_read_string(chip->spmi->dev.of_node,