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

Commit 14100076 authored by Ashay Jaiswal's avatar Ashay Jaiswal
Browse files

power: smb5: add support to disable suspend on collapse feature



Add support to disabled suspend on collapse feature of charger
hardware based on device tree property, disabling suspend on
collapse allows charger to recover adapter from collapse state
in the next AICL rerun.

Change-Id: Ib4c0cc6b2b9bcd422d27fe21b9060c29d55201eb
Signed-off-by: default avatarAshay Jaiswal <ashayj@codeaurora.org>
parent f43dabe3
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -251,6 +251,12 @@ Charger specific properties:
  Definition: Boolean flag which when present enables stepwise change in FCC.
		The default stepping rate is 100mA/sec.

- qcom,disable-suspend-on-collapse
  Usage:      optional
  Value type: bool
  Definition: Boolean flag which when present disables suspend on collapse
		feature of charger hardware.

=============================================
Second Level Nodes - SMB5 Charger Peripherals
=============================================
+11 −5
Original line number Diff line number Diff line
@@ -196,6 +196,7 @@ struct smb_dt_props {
	int			term_current_src;
	int			term_current_thresh_hi_ma;
	int			term_current_thresh_lo_ma;
	int			disable_suspend_on_collapse;
};

struct smb5 {
@@ -494,6 +495,8 @@ static int smb5_parse_dt(struct smb5 *chip)
	if (rc < 0)
		return rc;

	chip->dt.disable_suspend_on_collapse = of_property_read_bool(node,
					"qcom,disable-suspend-on-collapse");
	return 0;
}

@@ -1737,7 +1740,7 @@ static int smb5_init_hw(struct smb5 *chip)
{
	struct smb_charger *chg = &chip->chg;
	int rc, type = 0;
	u8 val = 0;
	u8 val = 0, mask = 0;
	union power_supply_propval pval;

	if (chip->dt.no_battery)
@@ -1905,11 +1908,14 @@ static int smb5_init_hw(struct smb5 *chip)
	 * start from min and AICL ADC disable, and enable aicl rerun
	 */
	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;

		rc = smblib_masked_write(chg, USBIN_AICL_OPTIONS_CFG_REG,
				USBIN_AICL_PERIODIC_RERUN_EN_BIT
				| USBIN_AICL_ADC_EN_BIT | USBIN_AICL_EN_BIT,
				USBIN_AICL_PERIODIC_RERUN_EN_BIT
				| USBIN_AICL_EN_BIT);
				mask, val);
		if (rc < 0) {
			dev_err(chg->dev, "Couldn't config AICL rc=%d\n", rc);
			return rc;