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

Commit aa319baa authored by David Collins's avatar David Collins
Browse files

regulator: spm-regulator: fall back on SPMI write if msm_spm_set_vdd fails



Update the spm-regulator driver so that it falls back on an SPMI
register write if the msm_spm_set_vdd() call to set the voltage
of a regulator fails.  This retry mechanism is needed because
msm_spm_set_vdd() is not guaranteed to work for all regulators at
all times.  It can only work if at least one processor core
powered by the regulator is online.  Unfortunately, the clock
driver may request a voltage during the process of bringing the
first such core online.

Change-Id: I93980d603a324da2b8d21e0b78958ff5032168b0
Signed-off-by: default avatarDavid Collins <collinsd@codeaurora.org>
parent 70d51296
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -138,7 +138,8 @@ static int qpnp_fts2_set_mode(struct spm_vreg *vreg, u8 mode)
static int _spm_regulator_set_voltage(struct regulator_dev *rdev)
{
	struct spm_vreg *vreg = rdev_get_drvdata(rdev);
	int rc;
	bool spm_failed = false;
	int rc = 0;
	u8 reg;

	if (vreg->vlevel == vreg->last_set_vlevel)
@@ -157,11 +158,13 @@ static int _spm_regulator_set_voltage(struct regulator_dev *rdev)
		/* Set voltage control register via SPM. */
		rc = msm_spm_set_vdd(vreg->cpu_num, vreg->vlevel);
		if (rc) {
			pr_err("%s: msm_spm_set_vdd failed %d\n",
			pr_err("%s: msm_spm_set_vdd failed, rc=%d; falling back on SPMI write\n",
				vreg->rdesc.name, rc);
			return rc;
			spm_failed = true;
		}
	} else {
	}

	if (unlikely(vreg->bypass_spm || spm_failed)) {
		/* Set voltage control register via SPMI. */
		reg = vreg->vlevel;
		rc = spmi_ext_register_writel(vreg->spmi_dev->ctrl,
@@ -169,7 +172,7 @@ static int _spm_regulator_set_voltage(struct regulator_dev *rdev)
			vreg->spmi_base_addr + QPNP_SMPS_REG_VOLTAGE_SETPOINT,
			&reg, 1);
		if (rc) {
			pr_err("%s: spmi_ext_register_writel failed %d\n",
			pr_err("%s: spmi_ext_register_writel failed, rc=%d\n",
				vreg->rdesc.name, rc);
			return rc;
		}