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

Commit c139d688 authored by Harry Yang's avatar Harry Yang Committed by Guru Das Srinagesh
Browse files

power: smb5-lib: Fix SBUx resistance measurement in moisture detection



Liquid presence is decided by SBUx resistance measured lower than
certain threshold. However, the measurement can be distorted if done
right after Type-C removal because SBUx may not be completely
released. As a result, moisture can be falsely detected.

Fix it by delaying moisture detection 1s after Type-C cable removal.

CRs-Fixed: 2325898
Change-Id: I4f932f53792c38434c76cfaec2e29b8f91e78927
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
parent b834e952
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -5010,6 +5010,7 @@ irqreturn_t typec_attach_detach_irq_handler(int irq, void *data)
	}

	if (stat & TYPEC_ATTACH_DETACH_STATE_BIT) {
		cancel_delayed_work_sync(&chg->lpd_detach_work);
		chg->lpd_stage = LPD_STAGE_FLOAT_CANCEL;
		cancel_delayed_work_sync(&chg->lpd_ra_open_work);
		vote(chg->awake_votable, LPD_VOTER, false, 0);
@@ -5054,7 +5055,7 @@ irqreturn_t typec_attach_detach_irq_handler(int irq, void *data)

		if (chg->lpd_stage == LPD_STAGE_FLOAT_CANCEL)
			schedule_delayed_work(&chg->lpd_detach_work,
					msecs_to_jiffies(100));
					msecs_to_jiffies(1000));
	}

	power_supply_changed(chg->usb_psy);
@@ -5747,16 +5748,9 @@ static void smblib_lpd_ra_open_work(struct work_struct *work)
		goto out;
	}

	/* Wait 1.5ms to read src status */
	/* Wait 1.5ms to get SBUx ready */
	usleep_range(1500, 1510);

	rc = smblib_read(chg, TYPE_C_SRC_STATUS_REG, &stat);
	if (rc < 0) {
		smblib_err(chg, "Couldn't read TYPE_C_SRC_STATUS_REG rc=%d\n",
				rc);
		goto out;
	}

	if (smblib_rsbux_low(chg, RSBU_K_300K_UV)) {
		/* Moisture detected, enable sink only mode */
		pval.intval = POWER_SUPPLY_TYPEC_PR_SINK;