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

Commit 5437ac9c authored by Umang Agrawal's avatar Umang Agrawal Committed by Guru Das Srinagesh
Browse files

power: smb5: Fix AICL configuration for pmi632



Currently, AICL rerun is disabled for pmi632 and the default AICL
step time and input collapse deglitch filter time is reconfigured
to minimum period. This in turn is restricting the AICL capability
of pmi632 for weak adapters leading to low AICL values and henceforth
low charge current. Hence, enable AICL rerun and restore the default
step time and deglitch filter time for pmi632 charger.

Change-Id: I536b99ec7c009006185467e3ddd8f0009aaad798
Signed-off-by: default avatarUmang Agrawal <uagrawal@codeaurora.org>
parent b062bdd7
Loading
Loading
Loading
Loading
+28 −21
Original line number Diff line number Diff line
@@ -206,6 +206,7 @@ struct smb_dt_props {
	bool			no_battery;
	bool			hvdcp_disable;
	bool			hvdcp_autonomous;
	bool			adc_based_aicl;
	int			sec_charger_config;
	int			auto_recharge_soc;
	int			auto_recharge_vbat_mv;
@@ -542,6 +543,9 @@ static int smb5_parse_dt_misc(struct smb5 *chip, struct device_node *node)
	chip->dt.disable_suspend_on_collapse = of_property_read_bool(node,
					"qcom,disable-suspend-on-collapse");

	chip->dt.adc_based_aicl = of_property_read_bool(node,
					"qcom,adc-based-aicl");

	return 0;
}

@@ -1909,14 +1913,17 @@ static int smb5_configure_typec(struct smb_charger *chg)
		return rc;
	}

	if (chg->smb_version != PMI632_SUBTYPE) {
		rc = smblib_masked_write(chg, USBIN_LOAD_CFG_REG,
		USBIN_IN_COLLAPSE_GF_SEL_MASK | USBIN_AICL_STEP_TIMING_SEL_MASK,
				USBIN_IN_COLLAPSE_GF_SEL_MASK |
				USBIN_AICL_STEP_TIMING_SEL_MASK,
				0);
		if (rc < 0) {
			dev_err(chg->dev,
				"Couldn't set USBIN_LOAD_CFG_REG rc=%d\n", rc);
			return rc;
		}
	}

	/* Set CC threshold to 1.6 V in source mode */
	rc = smblib_masked_write(chg, TYPE_C_EXIT_STATE_CFG_REG,
@@ -2418,15 +2425,16 @@ static int smb5_init_hw(struct smb5 *chip)
		return rc;

	/*
	 * AICL configuration:
	 * start from min and AICL ADC disable, and enable aicl rerun
	 * AICL configuration: enable aicl and aicl rerun and based on DT
	 * configuration enable/disable ADB based AICL and Suspend on collapse.
	 */
	if (chg->smb_version != PMI632_SUBTYPE) {
	mask = USBIN_AICL_PERIODIC_RERUN_EN_BIT | USBIN_AICL_ADC_EN_BIT
			| USBIN_AICL_EN_BIT | SUSPEND_ON_COLLAPSE_USBIN_BIT;
	val = USBIN_AICL_PERIODIC_RERUN_EN_BIT | USBIN_AICL_EN_BIT;
	if (!chip->dt.disable_suspend_on_collapse)
		val |= SUSPEND_ON_COLLAPSE_USBIN_BIT;
	if (chip->dt.adc_based_aicl)
		val |= USBIN_AICL_ADC_EN_BIT;

	rc = smblib_masked_write(chg, USBIN_AICL_OPTIONS_CFG_REG,
			mask, val);
@@ -2434,7 +2442,6 @@ static int smb5_init_hw(struct smb5 *chip)
		dev_err(chg->dev, "Couldn't config AICL rc=%d\n", rc);
		return rc;
	}
	}

	rc = smblib_write(chg, AICL_RERUN_TIME_CFG_REG,
				AICL_RERUN_TIME_12S_VAL);