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

Commit 90f5662b authored by Anirudh Ghayal's avatar Anirudh Ghayal Committed by Ankit Sharma
Browse files

msm: qpnp-haptic: Manage the state of PON regulator



Control the PON regulator (required to force MBG_ON) based on
the current state of haptic and maintain the regulator state
to avoid frequent enable/disable.

CRs-Fixed: 1111145
Change-Id: Ic7238a7828d1694192e890433d4247b25b5b15e1
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent 92bf9e3e
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -353,6 +353,7 @@ struct qpnp_hap {
	u8				lra_res_cal_period;
	u8				sc_duration;
	u8				ext_pwm_dtest_line;
	bool				vcc_pon_enabled;
	bool				state;
	bool				use_play_irq;
	bool				use_sc_irq;
@@ -1718,13 +1719,15 @@ static void qpnp_hap_worker(struct work_struct *work)
	struct qpnp_hap *hap = container_of(work, struct qpnp_hap,
					 work);
	u8 val = 0x00;
	int rc, reg_en = 0;
	int rc;

	if (hap->vcc_pon) {
		reg_en = regulator_enable(hap->vcc_pon);
		if (reg_en)
			pr_err("%s: could not enable vcc_pon regulator\n",
				 __func__);
	if (hap->vcc_pon && hap->state && !hap->vcc_pon_enabled) {
		rc = regulator_enable(hap->vcc_pon);
		if (rc < 0)
			pr_err("%s: could not enable vcc_pon regulator rc=%d\n",
				 __func__, rc);
		else
			hap->vcc_pon_enabled = true;
	}

	/* Disable haptics module if the duration of short circuit
@@ -1739,11 +1742,13 @@ static void qpnp_hap_worker(struct work_struct *work)
		qpnp_hap_set(hap, hap->state);
	}

	if (hap->vcc_pon && !reg_en) {
	if (hap->vcc_pon && !hap->state && hap->vcc_pon_enabled) {
		rc = regulator_disable(hap->vcc_pon);
		if (rc)
			pr_err("%s: could not disable vcc_pon regulator\n",
				 __func__);
			pr_err("%s: could not disable vcc_pon regulator rc=%d\n",
				 __func__, rc);
		else
			hap->vcc_pon_enabled = false;
	}
}